The pattern achieves 2 goals:
- To compose nested structures of objects.
- To deal with the classes for these objects uniformly.

Visualization of the composite:

Festina Lente
The pattern achieves 2 goals:

Visualization of the composite:

Problem: the output of one system my not conform to the expected input of another system.
The Adapter design pattern will help to facilitate communication between two existing systems by providing a compatible interface.

The Adapter essentially encapsulates the adaptee and presents a new interface, or appearance, to the client class. It does this by wrapping the adaptee’s interface and exposing a new target interface that makes sense to the client.
Continue reading “Adapter pattern”Larger system => more complex system, which potentially confusing for the client classes in your system to use. System complexity is not always a sign for poor design, though.
The Facade design pattern provides a single simplified interface for client classes to interact with the subsystem. It doesn’t add any functionality, it simply acts as a point of entry into your subsystem. It’s wrapper class that encapsulates a subsystem in order to hide the complexity.
A Facade class can be used to wrap all the interfaces and classes for a subsystem.
Continue reading “Facade Pattern”Factory creates objects. The clients who use the factory can focus on other behavior. So the object creation delegated to another object.
Benefits: if there are multiple clients that want to instantiate the same set of classes, then by using a Factory object, you have cut out redundant code and made software easier to modify. Means if need a change of object creation, then have to modify just a factory instead of every client and it’s calling coding to an interface, not an implementation.
Factory:
public class CarFactory(){
public Car createCar(string carType) {
Car car;
if(carType.Equals("sport")){
car = new SportCar();
}
else if(carType.Equals("city")){
car = new CityCar();
}
return car;
}
}
The singleton pattern refers to having only one object of a class. Again, enforces one and only one object of a Singleton class which globally accessible within a program.
Code example:
public sealed class Singleton
{
private static volatile Singleton instance;
private static object syncRoot = new Object();
private Singleton() {}
public static Singleton Instance
{
get
{
if (instance == null)
{
lock (syncRoot)
{
if (instance == null)
instance = new Singleton();
}
}
return instance;
}
}
}

The design patterns will help you to make flexible, reusable, and maintainable software.
How to make sure the system that you’ve created is correct?
For example, you can run tests and see if the actual behavior matches what you expect. But there is another technique called model checking.
Model Checking is a systematic check of your systems state model in all its possible states, can help to find laws. Its done after code has been written and before deployment.
How to model check software? Model checkers generate a State Model from your code.
State Model is an abstract state machine that can be in one of various states. The model checker then checks that the state model conforms to certain behavioral properties.
There are 3 different phases to performing model checking:
Separation of Concerns principle helps to create flexible, reusable and maintainable software systems. But it is an ongoing process throughout the design process.
Concern it is anything that matters in providing a solution to a problem. Some of the concerns in software may involve:
Example with SmartPhone, let’s say we have the next class:
Continue reading “Separation of Concerns”Coupling and cohesion are metrics to evaluate design complexity.
These metrics helps to achieve a more manageable system.
Coupling focuses on complexity between a module and other modules. If your module is highly reliant on other modules, then this module is tightly coupled to others (puzzle). If your module finds it easy to connect to other modules, this module is loosely coupled to others (Lego).

When evaluating the coupling of a module, you need to consider degree, ease and flexibility.
Continue reading “Coupling and Cohesion”
This example has the next 4 entities:
All of the connections are composition. The system has the next generalization connections: