Solving Design Problems by Design Patterns
Today I am going to describe design patterns. The very first question that can arise in anyone’s mind is what is a design pattern? where we use it? why do we use it? hold on… let’s go through this one by one.
What is a design pattern?
In simple sentence, a design pattern is a way to design our software/application. Each design pattern addresses a problem or set of problem and describe a solution for it. So these design patterns help us understand those problems and solve them effectively.
Designing object-oriented software is hard, and designing a good, reusable object-oriented software is even harder. We need to find objects, factor them into classes at the right granularity, define class interfaces and establish relationship among them to make a good software. Our software design should be flexible enough that can handle future problems and for modifications. This means it’s impossible to find exactly right design for any software but we can make it in such a way that can cover maximum solutions for future issues.
Why and where we use it?
It’s one of the most time taking process in any software design, as per my experience. And it takes a long time for someone to learn these design patterns from scratch. An experienced architect never solve any problem from first rules rather they use experience that have helped them in past. Consequently, we find recurring patterns of classes and their communications. These patterns solve some specific design problems and make object-oriented designs more flexible, elegant and reusable, which is the main philosophy behind object oriented systems.
So at this point now we are able to define what is a design pattern? Its a description of communicating objects and classes that are customized to solve a general design problem in a particular context.
So basically a design pattern has following elements –
- 1. Problem
- 2. Solution
- 3. Future consequences
Still one question can come into ones’ mind that How these design patterns solve design problems?
Well its a vast topic and lets walk through it.
Design patterns solve many problems object-oriented designers face.
Followings are few of them –
Designing appropriate objects – The most complex part of any object-oriented design is decomposing a system into objects. This is difficult because of many factors like our object should be reusable, it should address future problems, should be flexible etc. Think of a scenario where an architect designs a bad software, how costly that can be for the organization in future? So design patterns helps you identify your problems and create objects that can capture them.
Determining Object Level – Objects can vary in size. They can represent anything from hardware to the complete application. So how do we decide what should be an object? Design pattern solves this problem also.
In this context let me introduce you with very common terms of object-oriented design. Every operation declared by an object specifies the operation’s name, the objects it takes as parameters, and the return value. This is known as the operation’s signature. The set of all signatures defined by an object’s operations is called the interface to the object. An object’s interface characterizes the complete set of requests that can be sent to the object. An object is the set of operations it can perform and set of states it can be in. There are several kind of design patterns e.g. Abstract, Factory, Singleton etc. I will try to cover them in my next posts.
Content Source: http://www.raakeshkumar.in/
Ready to Take the Next Step?
Empower your business with cutting-edge technology solutions tailored for success.