Basic rules of Software Design
Whenever we start to develop or design any software before that we must have knowledge about "Basic rules of Software Design".
We can divide Software Design into two part:
1. Software Design Principles
2. Software Design Patterns
If we talk about Design Principles so this is nothing just a set of guidelines that helps developers to make a good system design.
Look at the following design principles:
1. SOLID: It is combination of five concepts:
a.) Single Responsibility Principle (SRP):- This means that we should design our classes in such way that each class should have a single purpose.
b.) Open/Closed Principle: - Software entities should be open for extension but closed for modification.
c.) Liscov Substitution Principle: - Pointers or references to base classes must be able to use objects of derived class without any prior information.
d.) Interface Segregation Principle (ISP):- Client should not be forced to depend upon interface that they don't use. Means the service interface that is exposed to the client should contains only client related methods not all.
e.) Dependency Inversion Principle: - High level modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions.
2. DRY (Don’t Repeat Yourself): The code should occur only once in our system. This helps us to write scalable, maintainable and reusable code. Asp.Net MVC framework works on this principle.
3. KISS (Keep it simple and stupid!!!) : Our code should be simple and we should avoid unnecessary complexity. This helps us to write easy maintainable code.
4. YAGNI (You aren’t going to need it): We should always implement things when we actually need them never implements things before we need them.
Now we move ahead and discuss basic about "Design Patterns". The core concepts of Design Patterns to provide solutions of common problems which we face in software design. If we go through with design patterns then we can organized this into four separate pattern group base on the nature of the design problem they intend to solve.
Look at the following design patterns:
1. Gang of Four Patterns (Most Popular)
2. Enterprise Patterns
3. SOA and Messaging Patterns
4. Model-View Patterns
In 1994 four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book (Design Patterns: Elements of Reusable Object-Oriented Software) for explaining the concept of Design Pattern in Software development. These four authors are collectively known as Gang of Four (GOF). There are 23 design patterns available under GOF design patterns. They all are divided into three groups.
1. Creational Design Patterns:
These patterns deal with the process of objects creation in such a way that they can be decoupled from their implementing system. This provides more flexibility in deciding which objects need to be created for a given use case/ scenario. There are as follows:
a.) Factory Method: Create instances of derived classes
b.) Abstract Factory: Create instances of several classes belonging to different families
c.) Builder: Separates an object construction from its representation
d.) Prototype: Create a duplicate object or clone of the object
e.) Singleton: Ensures that a class can has only one instance
2. Structural Design Patterns:
These patterns deal with the composition of objects structures. The concept of inheritance is used to compose interfaces and define various ways to compose objects for obtaining new functionalities. There are as follows:
a.) Adapter: Match interfaces of different classes
b.) Bridge: Separates an object’s abstraction from its implementation
c.) Composite: A tree structure of simple and composite objects
d.) Decorator: Add responsibilities to objects dynamically
e.) Façade: A single class that represents an entire complex system
f.) Flyweight: Minimize memory usage by sharing as much data as possible with similar objects
g.) Proxy: Provides a surrogate object, which references to other object
3. Behavioural Design Patterns:
These patterns deal with the process of communication, managing relationships, and responsibilities between objects. There are as follows:
a.) Chain of Responsibility: Passes a request among a list or chain of objects.
b.) Command: Wraps a request under an object as a command and passed to invoker object.
k.) Template Method
I hope we will understand the basic concepts of Software Design Principles and Patterns. We will discuss all these design patterns in sequence in coming blogs.
The final goal of any engineering activity is to create some kind of documentation. When a design effort is complete, the design documentation is given to the manufacturing team. This is a different set of people with a different set of skills from those of the design team. If the design documents truly represent a complete design, the manufacturing team can proceed to build the product. In fact, they can proceed to build much of the product without further assistance from the designers. After reviewing the software development life cycle today, it appears that the only software documentation that actually seems to satisfy the criteria of an engineering design are the source code listings.
Happy reading !!!