Design patterns allow for extensibility in the O-O design,
so that particular functionalities can be enhanced, debugged, modified, made
secure or performance-tuned without breaking the rest of the surrounding code. You
can apply code access security to one object, while applying role based
security to another; so if you have 3 security experts, you could split up
their work on that basis.
They allow for a need-to-know approach to development (I bet
they use them a lot at the CIA). Suppose you have a secret routine with a lot
of industry-intelligence in it and your company’s survival depends on it. If a
new programmer joins your company and has not yet earned a high level of trust,
do you expose the new-programmer to the inner guts of the weather-prediction
code or do you have him instantiate classes by an object-factory which is accessible
only to your lead developers? Creational patterns help you to implement
solutions to this dilemma.
Design patterns also allow you to separate the Object-Model
from the Operations which must be carried out on the structure representing the
Object Model. The Trinity of Composite, Iterator and Visitor patterns help you
to achieve this. Interpreter and Composite patterns also help to accomplish
this by separating the grammar which describes a language from the algorithms
that figure out the meaning of sequences of words in that language. You can
actually overhaul Object-Models extensively without touching a line of code
which traverses and evaluates it!
Design patterns allow you to extend the functionality of
classes defined in class libraries from third party developers, even if they
are scoped in a way so as to disallow extension. Supposing a function in a
class library is marked as “not override ready,” you can still extend the operations
by using the decorator or adapter patterns. Obviously, you should be careful
about the extension in these circumstances since the manufacturer must have had
reasons for not allowing you to easily extend the functionality.
Without using design patterns, classes will multiply within
your code in order to represent every possible combination of behaviors. Either
that or you will put in so many if-then-else case statements that you will
choke on them the first time you try to unravel them.
Why should your clients, boss or customers care if you use
design patterns? Well it will help you to avoid the conundrum that is facing
the automobile industry right now. There is a need to move toward renewable
sources of energy and so solar powered cars must take prominence in the future.
The problem lies in that trillions of dollars is invested in the current
infrastructure which produces gas-powered cars. The new technology is
incompatible with the old and the introduction of the new will mean throwing
out the old. This is what happens with badly designed software. In order to
introduce new changes you have to discard what exists since it is not extensible
enough to permit changes that the client requires. Design patterns help you to
avoid this problem.
Design patterns also represent the natural boundaries for
subsystems when designing and testing, since the sum of parts should interact
in a predictable and interface-able manner.
It represents a predictable way of maintaining systems. The
very expensive nature of cars dictates that they be built on similar platforms
for cost savings and also that they be maintainable based on a engineered
similarity – 4 wheels, a steering wheel, front-end, water pump, ignition
systems – that all follow a common model. A mechanic who has never worked on a
particular brand of car before is still able to perform many of the fixes on it
because he knows what the general arrangement of parts will look like and what
tends to cause the problems. A Toyota specialist, once he understands the
design patterns of a Toyota, can look at a fairly new model from Toyota and fix it. Software must become like this.
Security can also be improved with the use of design
patterns since the layer which interacts with databases can be abstracted out of
the reach of the user-programmer who then has no need to dig around in the
database to do their GUI work.
Conclusion
Design patterns are repeatable solutions to the problems
faced my programmers today who work in object-oriented systems. The more you know
about them the more I know you will want to learn more. They offer endless
possibilities to the computer world.