Interface oriented
Interface oriented is something like having contract-based approach, means whatsoever be there under the Contract you have to implement all of it. A good example of this is : WCF.
Object oriented is based on
abstraction – which means making things loosely coupled so that in future they can be easily handled without affecting the system.
encapsulation(data hiding) – categorizing data as per their role i.e private, public, etc.
inheritance – provides the real world genetic mechanism as what’s there in the parent would be there in the child too(or not).
and polymorphism – means same look and feel but different functional abiltity.
Aspect oriented programming
Aspect oriented programming can be done either on Interface oriented or an Object oriented code. It can not exist alone. AOP is another method of reducing the redundant code and its impact. Let’s see an example:
You have a class ResultGraph in a Stock Application, which has say 5 methods (like MethodA, MethodB, MethodC, MethodD, UpdateGraphics).
Assume that just after a method (say, MethodX) is executed, the stock price changes – hence the graph needs to be re-rendered. In such case, UpdateGraphics needs to be called. Which means all 5 functions will call UpdateGraphics.
This appears to be simple since the number of functions is less. In a real time scenario, there are 100’s of methods and implementing this becomes tough.
AOP enables doing it in an easier manner. We write something like:-
after() : set() {
ResultGraph.UpdateGraphics();
}
pointcut set() : execution(* set*(*) ) && this(StockClass) && within(com.company.*);
The first code means, whenever any set is called, call ResultGraph.UpdateGraphics()
The second code interprets as,
if a method is named set*:(* means any name might follow after set), regardless of what the method returns (first asterisk) or what parameters it takes (third asterisk) and it is a method of StockClass and this class is part of the package “com.company.*”, then this is a set() pointcut. And our first code says “after running any method that is a set pointcut, run the following code”.