Skip to content

4. Interface-Object-Aspect- Oriented Programing, Interface/Class, Reflection

February 22, 2011

10. Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programing.
Now it’s getting very sexy, might be the right time to turn the lights off. Interface-Oriented programing is a concept that has a close relationship with Modular programing. Modular programing defines the application as a collection of intercoupled modules. This increases the modularity of an application and hence its maintainability. Interface-oriented programing views the entire system as Components and the interfaces that help them to interact, total system complexity is greatly reduced. The publisher assures that he will not change the interface and the subscriber agrees to implement the interface as a whole without any deviation. An interface is said to be a contractual agreement. Thus Interface Oriented programing is a contractual based approach. The internals are seen as a blackbox and neither side cares how the internals or interface work only that they can communicate via an agreed upon contract. A web service based on WSDL is a good example of this. Object-Oriented programing is a programing paradigm using objects “data structures” consisting of data fields and methods together with their interactions – to design applications and computer programs. Programing techniques may include features such as data abstraction: the use of subprograms and control flows as well as data abstractions which allows handling of bits in meaningful ways, see data types. Encapsulation: a language mechanism for restricting access to some of the components, information hiding, this can be done using the keywords public and private. Messaging: communication, the sending and receiving of messages to other processes. Modularity: the application is composed of separate, interchangeable modules. Modules represent a separation of concerns and increase maintainability. Modules talk to one another via interfaces. Polymorphism: create a variable, function or object that has more than one form. A prime example is operator overloading of numeric operators(+,-,*,/). A Shape class may have Square and Circle subclasses that implement the public fields in a different ways; Virtual and Override. Inheritance: compartmentalize and reuse code, objects are defined by classes and these classes can be inherited. The new classes, derived classes, inherit attributes and behaviors of the preexisting classes. Aspect-Oriented programing aims to increase the modularity by allowing separation of cross-cutting concerns. Cross-cutting concerns touch more parts of the program, writing records to a database or an authentication system are some examples for this. AOP entails breaking down program logic into separate parts, so called concerns, grouped together based on similar functionalities. This seems pretty close to the SRP, Single Responsibility Principle, a concern could be thought of this way.

11. Describe what an interface is and how it’s different from a class.
Interface is used to define an abstract type that contains no data but exposes behaviors defined as methods and properties. A class implementing that interface will have an implementation of all methods and properties of the interface. A class can implement multiple interfaces, but only inherit from one class in the .NET world. Thus interfaces define a contract, an implementation but no executable code. The interface is implemented by the class. A class is a blueprint used to create, instantiate objects of the class. The blueprint describes the state and behavior that all the objects of the class share. An object of a given class is called an instance of the class. The class that was used to create the object can be considered the type of the object, an object instance of the “square” class would be of type “square”.

12. What is reflection?
Reflection is a process by which a computer program can observe and modify its own structure at runtime. Reflection is useful when you need to access attributes in your programs metadata, for examining and instantiating types in your assembly, for building new types at runtime, performing latebinding, accessing methods on types created at runtime. Reflection is a way to explore the structure of assemblies at run time(classes, resources, methods).

Happy Programing! =)

Source: mostly wikipedia.


From → OOP

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: