Skip to content

iarash84/design_patterns_implemented_by_php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design patterns implemented in Php

Introduction

Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems. They are not classes, packages or libraries that you can plug into your application and wait for the magic to happen. These are, rather, guidelines on how to tackle certain problems in certain situations.

Design patterns are solutions to recurring problems; guidelines on how to tackle certain problems

Wikipedia describes them as

In software engineering, a software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations

Types of Design Patterns

  • Behavioral
  • Creational
  • Structural

Behavioral Patterns:

In plain words

Structural patterns are mostly concerned with object composition or in other words how the entities can use each other. Or yet another explanation would be, they help in answering "How to build a software component?"

Wikipedia says

In software engineering, structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.

Pattern Description Wiki
Chain apply a chain of successive handlers to try and process the data wiki
Command bundle a command and arguments to call later wiki
Iterator traverse a container and access the container's elements wiki
Memento generate an opaque token that can be used to go back to a previous state wiki
Observer provide a callback for notification of events/changes to data wiki
Registry keep track of all subclasses of a given class wiki
Strategy selectable operations over the same data wiki
Visitor invoke a callback for all items of a collection wiki

Creational Patterns:

In plain words

Creational patterns are focused towards how to instantiate an object or group of related objects.

Wikipedia says

In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

Pattern Description Wiki
Abstract Factory use a generic function with specific factories wiki
Builder instead of using multiple constructors, builder object receives parameters and returns constructed objects wiki
FactoryMethod delegate a specialized function/method to create instances wiki
Pool preinstantiate and maintain a group of instances of the same type wiki
Prototype use a factory and clones of a prototype for new instances (if instantiation is expensive) wiki
Singleton To have only one instance of this object in the application that will handle all calls. wiki

Structural Patterns:

In plain words

Structural patterns are mostly concerned with object composition or in other words how the entities can use each other. Or yet another explanation would be, they help in answering "How to build a software component?"

Wikipedia says

In software engineering, structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.

Pattern Description Wiki
Adapter adapt one interface to another using a white-list wiki
Bridge a client-provider middleman to soften interface changes wiki
Composite lets clients treat individual objects and compositions uniformly wiki
Decorator wrap functionality with other functionality in order to affect outputs wiki
Facade use one class as an API to a number of others wiki
Flyweight transparently reuse existing instances of objects with similar/identical state wiki
Proxy an object funnels operations to something else wiki

License

This project is licensed under the terms of the MIT license.

About

Some design patterns implemented by PHP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages