Subscribe by Email

Thursday, April 21, 2011

How to implement Controllers - Programming Guidelines

To implement controllers, a good programming practice is to use abstract classes and interfaces. It increases the ability of the software to be reusable and manageable. It allows the software to have plug and play options.


Abstract class is a class that cannot be instantiated. It is located at the top of an object oriented class hierarchy. It defines the actions possible with objects of all subclasses of class. The methods defined in abstract class are called abstract methods.


Interfaces define the signatures of a set of methods withoutthe body. Interfaces define a standard and public way of specifying the behavior of classes. Interface can only contain abstract methods, properties but we don’t need to put abstract and public keyword. All the methods and properties defined in Interface are by default public and abstract. Interfaces exhibits polymorphism.

- Interfaces are needed when similar methods are implemented by unrelated classes.
- Through interfaces, we can actually capture similarities among unrelated classes without artificially forcing a class relationship.
- Interfaces are needed to reveal an object's programming interface without revealing its class.
- Interfaces are needed to model multiple inheritance which allows aclass to have more than one superclass.


The metrics used for implementation are the metrics for the design. These are:
- Lines of Code (LOC)
- Number of classes.
- Number of documentation pages.
- Total cost.
- Effort.

No comments:

Facebook activity