Design patterns

Design patterns are common approaches to common problems that can be found when creating software; they are created for the purpose of solving problems which were solved before, so we can speed up implementation process. They are a sort of general manual a developer can follow in order to implement a solution to a specific problem or requirement in their code. Usually, design patterns describe the problem that they solve, describe the thought solution and how does it work and its consequences. It is up to the developer to implement the solution to its desired programming language, but often design patterns also come with examples and implementation hints.

Why are they good

Design patterns help speed up the development process. They provide a tested and proven solution to a problem which has been already solved in the past, meaning we don’t need to re-invent the wheel every time. Design patterns save us a lot of time in debugging code because they consider issues or bugs that often won’t pop up until later in development, which may happen with fresh code not following a design pattern. Also they add readability for someone who also is familiar with them.

There are three main types of design patterns:

Creational design pattern
these design patterns manage class instantiation or object creation. These patterns are divided into Class-creational patterns and object-creational patterns. Class-creational patterns use inheritance in the instantiation process; object-creational patterns use delegation instead.

Structural
these design patterns organize different classes and objects to form larger structures and provide new functionality. They can be used for scalability and of course organization.

Behavioral
Behavioral patterns identify common communication patterns between objects and realize these patterns. These are used to modify or add some behavior to existing or new objects and often pay attention to inputs and outputs.

Resultado de imagen para all design patterns

Anti-design patterns

Anti-design patterns are certain patterns in software development that are considered bad programming practices and are not wanted or are avoided through the development of software. They are considered anti patterns because they generate negative consequences within the software, these tend to be things like adding unnecessary complexity, approaching dull solutions that might need to be rewritten later or simply making the code unreadable (Creating spaghetti code). And so developers should avoid using anti patterns as often as they can.

An example of an anti-design pattern is a well-known anti pattern named God Object.

A god object is an object that does too much for its own good. This object has been given too much functionality and too many functions so that it becomes illegible or too complex for human understanding. This is then a bad practice which is common to see in software development, hence, it is an anti-design pattern.

Visual Example of a god object in an object diagram

A common programming counterpart, which is a good practice, is to separate a large problem into several small problems and solve them individually. This is called divide and conquer. And so we should try and avoid the god object pattern by exerting the divide and conquer tactic.

Here are some of the existing anti-patterns which would be wise to read and familiarize ourselves with them in order to avoid them.

For more information about these anti-patterns (why are they bad and how to avoid them) you can enter the link embeded in each of them.

Leave a comment

Design a site like this with WordPress.com
Get started