CodeX
Published in

CodeX

Dive into Design Patterns

The first question you ask yourself is …

What is design patterns?

Design patterns are solutions to general problems that software developers faced during software development. These solutions were obtained by trial and error by numerous software developers over quite a substantial period of time.

The pattern is not a specific piece of code, but a general concept for solving a particular problem, You can follow the pattern details and implement a solution that suits the realities of your own program.

Patterns is not Algorithms!

Patterns are often confused with algorithms, because both concepts describe typical solutions to some known problems.While an algorithm always defines a clear set of actions that can achieve some goal, a pattern is a more high-level description of a solution. The code of the same pattern applied to two different programs may be different.

An analogy to an algorithm is a cooking recipe: both have clear steps to achieve a goal. On the other hand, a pattern is more like a blueprint: you can see what the result and its features are, but the exact order of implementation is up to you.

What does the pattern consist of?

Most of the patterns are described very formally so you can reproduce them in many contacts, design patterns are just pattern for solve problems you can merge two or more design pattern together to solve your own problem.

Why should I learn patterns?

You shouldn't learn patterns, you can work as a programmer for many years without knowing about single parents a lot of people do just that. Even in that case, though, you might be implementing some patterns without even knowing it, So why would you spend time learning them?

  • Design patterns define a common language that you and your teammates can use to communicate more efficiently. You can say, “Oh, just use a Singleton for that,” and everyone will understand the idea behind your suggestion. No need to explain what a singleton is if you know the pattern and its name.
  • Design patterns are a toolkit of tried and tested solutions to common problems in software design. Even if you never encounter these problems, knowing patterns is still useful because it teaches you how to solve all sorts of problems using principles of object-oriented design.

Remember this: when you wanna draw circle you’ll use circle pattern, programming is like drawing you use patterns to solve your problem, you can draw circle without a pattern but imagine if your hand tremor that shape will not be circle.

How many design pattern does he have?

We have 23 design patterns named:

  • Factory Method
  • Abstract Factory
  • Builder
  • Prototype
  • Singleton
  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Facade
  • Flyweight
  • Proxy
  • Iterator
  • Mediator
  • Memento
  • Observer
  • State
  • Strategy
  • Template Method
  • Visitor
  • Chain of Responsibility
  • Command
  • Interpreter

Source: Dive Into Design Patterns Book

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store