+90 (312) 244 63 25
tr
tr

Design Patterns

507
Design Patterns

While making application designs in object oriented programming, We try to obtain a new design that is free from problems by constantly erasing all sorts of problems that we encounter. Solving problems always starting all over again is a very laborious and time consuming process. Due to many disadvantages like this, design patterns have become a candle light for our design and software life.

Because each of the design patterns is analyzed, tested, proved and modeled, they have positive effects on the application development process. This allows to complete processes faster. Thanks to a beautiful software design, it ensures us to take into problems that may appear later in the applications we develop. Continuous reuse of design patterns helps eliminate small problems before they grow. For application developers and architects who are constantly using and familiar with patterns, reading the code is much easier.

Design Patterns;

Builder Design

Structural Design

Behavioral Design

It is divided into three different categories.

Builder Design Patterns

They are design patterns that deal with the way object creation works and try to create objects according to the situation. Simple object creation methods except the pattern can lead to problems in designs and complexity in designs.

The purpose of the creator design patterns;

It provides flexibility to the code structure.

It allows the code to be used repeatedly.

If we examine constitutive parts of the builder design patterns

Abstract Factory Design Patterns

This design pattern offers us an interface that allows us to create related or dependent objects without specifying concrete classes.

Builder Design Pattern

The constructor ensures us to create our object structure step by step, which is complex in the design pattern.

For example, let’s consider building a house. When we define it as a single object, a house can have many features. Since the house with the same property will not be created every time, the variables that will not be used will always return as null value and this is an undesired type of structure. Instead, with the help of the constructor, an object is divided into multiple builder objects, and the house with the desired property is created.

Factory Method Design Pattern

It provides an interface for us to create object in a parent class, and this allows us to replace the type of object we create with subclasses.

Prototype Design Pattern

It ensures us to copy our code structure and the objects that we create regardless of classes.

Singleton Design Pattern

Allows only one instance that belongs a class. It provides a global access point to the object.

Object Pool Design Pattern

Performance takes an important place in software development. Often we can face performance problems. Creating an object is an important event in terms of performance. Prototype design pattern contributes significantly to performance by copying objects. The object pool design pattern gives us a way of working to use objects that are difficult to create. It ensures clients to share for several clients for a specified period of time.

Structural Design Pattern

It shows how we can combine different parts of a system in a flexible and extensible manner. It explains how we should include objects and classes in larger structures.

Adapter Design Pattern

It allows you to transform the interfaces of a class or classes into a different interface that clients can understand. It ensures adapter classes to work together which cannot work together. Otherwise, this will not be possible due to incompatible interfaces.

As an example, we can create adapters from XML to JSON. When the adapter receives a call, it allows us to convert it to JSON structure and process it as JSON.

Bridge Design Pattern

Two components that can be developed without being dependent on classes which close related to each other or large classes in our design namely it ensures us to distinguish between abstraction and application.

As an example, suppose there is a large class definition. In this class, you get a X model white car with a Y model white and a X model red car with a Y model red car. The car and color class are created. Two different classes are created under the car model, namely x model and y model cars. Under the color class, two different classes are created in white and red colors. After that, we can generate new objects by bridging classes in the model and color we want.

Composite Design Pattern

It allows us to organize our objects while programming. It transforms our objects into tree structure in the form of hierarchical structures. This tree structure that we created allows us to work like individual objects.

For example, military structures will explain this design pattern very well. When the rank at the top of the hierarchy publishes a circular, everyone learns what to do until it reaches the bottom rank, and the whole structure is updated.

Decorator Design Pattern

It is the design pattern that allows us to dynamically add new behavior and features to our objects in applications.

Although it seems a bit complicated to define a new feature in the object, it eliminates the need to define a class under the class.

Facade Design Pattern

Sub-systems are not used directly in this design pattern. Sub-systems are made easier to use by writing auxiliary interfaces.

There are more than one class in the system created in the facade design pattern. There are relationships between classes. When an operation is wanted to realize, methods in classes created for subsystems should be called in a certain order. When there is a growing facade class, a new facade class can be created by moving a certain part of the behavior to a different class.

Flyweight Design Pattern

Rather than keeping all the datas in a single object, it is shared between multiple objects and ensures more objects to fit in the amount of Ram. In this way, it enables us to saving Ram.

Proxy Design Pattern

As the name suggests, it provides a proxy or placeholder in place of the original objects. It hides the original object that we created and controls access to it.

Behavioral Design Pattern

These design patterns relate to the determination of common communications between different objects. Thus, they add flexibility to communication.

Chain of Responsibility

It ensures the process the incoming request along the processor chains. This design pattern allows the object to send a command without knowing which object to get and process. The incoming request circulates between the objects, making it part of the chain. Each of the objects in the chain can transfer the incoming request to another object in the chain, finalize or both transfer and finalize.

Command Design Patterns

It packs the incoming request with all its information into an object, in other words, it encapsulate. Thus, it hides from other objects and restricts their access. These processes play a role in extending and queuing the time for executing any request with different requests from other clients.

If an example is given to be more understandable, as a client, when we go to a tea house, we declare our request to the waiter. The waiter writes our requests and transmits it to the business department. Our request is processed. When its turn comes, our request is processed and comes to us after the checks.

Mediator Design Pattern

It imposes restrictions on the communication of objects in our applications. It ensures objects to work with the help of a common mediator.

For the sake of clarity, the best example is the operation of the airport. Not all planes communicate directly with each other, but all transactions are coordinated through the tower in between

Ziyaretçi Yorumları

Henüz yorum yapılmamış. İlk yorumu aşağıdaki form aracılığıyla siz yapabilirsiniz.