MVC Design Pattern

MVC is a design pattern for implementing user interface. It consists of three parts, Model, View and Controller, where each one of them is called components and has their own functionality.

Model manages all the data and logic of a software. It is the core component.

View is an interface responsible for taking all information from model and representing them to user.

Controller takes all commands from users sends them to model.

In this way, a software is loosely coupled and well organized into modules. We can very easily add new functions and features to it. And it is also very easy to maintain.

Singleton -> Object Pool

Singleton is a design pattern where you allow only one instance of a class. In some cases, like its private variables don’t change, singleton is useful.

Later, to extend this we could use object pool where we allow multiple instances of a class. This could be useful when we need a couple of object at the same time while it’s expensive to create them. A good example would be service connections. We can use two hash tables to implement this. One for available objects and one for unavailable objects.

Factory ->Abstract Factory

Factory is a design pattern that allows us to dynamically specify an object’s class without calling constructor.

Prototype

  • Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype.

  • Co-opt one instance of a class for use as a breeder of all future instances.

  • Thenewoperator considered harmful.

Builder

  • Separate the construction of a complex object from its representation so that the same construction process can create different representations.
  • Parse a complex representation, create one of several targets.

An application needs to create the elements of a complex aggregate. The specification for the aggregate exists on secondary storage and one of many representations needs to be built in primary storage.

Adapter

Adapter is a wrapper of old interface. We add it because the current function needs a new interface which is incompatible with the old one.

Facade is just a wrapper that aggregates some functionalities required by clients. By doing this, the whole system is easier to understand, to use and to test.

Composite

Composite is a design pattern that allows tree structure. It contains either variables we need, or a list objects of itself.

Proxy

  • Provide a surrogate or placeholder for another object to control access to it.

  • Use an extra level of indirection to support distributed, controlled, or intelligent access.

  • Add a wrapper and delegation to protect the real component from undue complexity.

.

Iterator

It’s just a pattern for iterating a data structure. By doing this, we can encapsulate the implementation of our own data structure and just provide the iterator interface.

State, Strategy

They both keep data as their member variables which can be changed in runtime.

results matching ""

    No results matching ""