What are the characteristics of good design? How can we identify the gaps in design? How to review other designs? We shall try to find answers to those questions.
The fowling characteristics are considered to be adhered in a good design.
• Strong cohesion
• Loose coupling
• No redundancy
• Testability of all the features by itself.
Strong cohesion
In computer programming, cohesion is a measure of how strongly-related the functionality expressed by the source code of a software module is. Cohesion of class/method is about having single responsibility and fulfilling it. It is not about how strongly they are related to each other.
Loose coupling
In computing and systems design a loosely coupled system is one where each of its components has, or makes use of, little or no knowledge of the definitions of other separate components.
The coupling can be observed in the code wherever (as class variables, method parameters or return types or method variables) class is accessed from other class. Worst form of coupling is one class accessing base type and sub type of a class hierarchy). Except while constructing the object, everywhere else the base type should be used.
let us continue...
Showing posts with label Design Patterns. Show all posts
Showing posts with label Design Patterns. Show all posts
Tuesday, 11 January 2011
Basic terminology of software design
Here are the cryptic definitions and what they mean in your code?
Abstraction
A concept or idea not associated with any specific instance. It is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail), It is simplifying complex reality by modeling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.
Abstraction can be implemented via Abstract Class/Interface. In both cases, abstract behavior needs to be implemented by the extending/implementing classes. However the catch is we shouldn’t use the implementing class name anywhere in the code except in creation. If the extending/implementing class used as parameter to methods, variable in other classes then note that you are not abstracting it. I will be posting various examples in later, please pay attention to this.
Abstract class x
{
method();
}
Interface x
{
method();
}
Class Y: (extends/implements) x
{
Method()
{
Do something;
}
}
Do not refer Y anywhere in the code except while creation.
Always
X x = new Y();
x.method();
If there is code like below then Y is not abstracted.
Class Z
{
Y y;
Or
OtherMethod(Y y)
Or
Y OtherMethod()
}
Let us continue ...
Abstraction
A concept or idea not associated with any specific instance. It is an emphasis on the idea, qualities and properties rather than the particulars (a suppression of detail), It is simplifying complex reality by modeling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.
Abstraction can be implemented via Abstract Class/Interface. In both cases, abstract behavior needs to be implemented by the extending/implementing classes. However the catch is we shouldn’t use the implementing class name anywhere in the code except in creation. If the extending/implementing class used as parameter to methods, variable in other classes then note that you are not abstracting it. I will be posting various examples in later, please pay attention to this.
Abstract class x
{
method();
}
Interface x
{
method();
}
Class Y: (extends/implements) x
{
Method()
{
Do something;
}
}
Do not refer Y anywhere in the code except while creation.
Always
X x = new Y();
x.method();
If there is code like below then Y is not abstracted.
Class Z
{
Y y;
Or
OtherMethod(Y y)
Or
Y OtherMethod()
}
Let us continue ...
Understanding software design Vs. Designing software applications
The design principles are least applied by most of the software professionals. The series of post on software design basics are targeted towards bridging the gap between understanding software design and designing software applications. It covers the following aspects
• Basics terminology of software design
• Basics of software design
• Design patterns
• Sample applications using these patterns
• Basics terminology of software design
• Basics of software design
• Design patterns
• Sample applications using these patterns
Subscribe to:
Posts (Atom)