Re: C++ exercises
Mare nga pergjigjia qe bera per nje detyre shtepie per klasen OOD.
Since the early 1990’s when Object Oriented Design became popular, most programming languages tried to incorporate Object Oriented features. All types of languages from classical procedural like FORTRAN to functional like Haskell, APL and even special purpose like CLIPS, support programming with objects. This approach works well but these languages are hampered by backward compatibility issues. New languages on the other hand, are truly Object Oriented. One of them is Microsoft™ .NET Framework.
.NET framework is not a language per se. It is a framework that supports a number of languages as long as their compiler abides to the CLS (Common Language Specification). This is achieved by having the same class names across different languages which in turn are translated into MSIL (Microsoft Intermediate Language) code.
Object Identity Every type in .NET is an object, meaning that it must derive directly or indirectly from the Object class. If you don’t specify a base class when you define a class, the compiler will inject this requirement. The Object class exposes four public methods which you can invoke on any .NET object at runtime. One of these methods is GetHashCode(), which gets the objects hash code. In .NET, hash codes are used as a mechanism for determining object uniqueness in runtime.
Inheritance As mentioned above, everything in .NET is a class which is derived from the Object class. All classes written in a .NET aware language can reuse the functionality that is implemented by their predecessor/parent classes through inheritance. Moreover, a class written in C# can inherit the functionality of a class written in VB.NET and a third class written in .NET aware PERL can inherit the functionality of both previous classes.
Polymorphism .NET Framework allows derived classes to override the implementation and behavior inherited from the base class. Polymorphism like Inheritance works across different .NET aware languages. For example a child class written in C# can override the virtual methods of an abstract base class written in Managed C++.
Information/Implementation Hiding .NET Framework provides support for Information/Implementation Hiding in similar way to other OO programming languages but it also introduces a new construct, property. A .NET class besides attributes and operations also has properties associated with its attributes. Usually all attributes of a .NET class are declared private. External access to them is restricted through the property associated with it. A property is a set of two functions get and set which control access to the underlying attribute. A property can either implement the set or get functions or both. Properties might look like just “syntactic sugar”, but they are the best example of Information/Implementation Hiding in my opinion.
Genericity .NET Framework provides many important namespaces and classes that provide support for almost any application that one will develop. Few of the most important namespaces are:
System Includes basic classes that almost every program will use like Object, Char, String, Array and Exception.
System.IO Provides support foe synchronous and asynchronous IO manipulation for data stream. Also provide classes to manipulate the file-system.
System.Collections Includes a set of classes that allows management of collections of objects like ArrayList, DictonaryBase, Hashtable, Queue, and Stack.
System.Net Provides support for network programming (eg. IpAddress, Dns, Connection, HttpWebRequest.
System.Data Provides DataBase connectivity support, including XML.
System.Web.Services Web Services programming.
System.Windows.Forms Graphical User Interface support.
.NET Framework is a new approach to OO software development. It supports all common elements of the object model. Moreover, it goes one step further. Programming in .NET relieves the programmer from the constraints of a particular language constructs. Any language that abides to .NET rules can be used. The emphasis stays with the overall Object Oriented design of the system.