image alt

Facade Design Pattern

blog image

Laravel 8 PHP Tutorial Series 

Tutorial 07

Facade design Pattern in Laravel 

Link: PHP Laravel Intermediate tutorial | What is Facade design pattern ? - Tutorial 07 - YouTube

 

Example Blog Create

Controller-:

public function store(Request $request)

{

   BlogFacade::create($request->all());

}

Facade-:

class BlogFacade extends Facade

{

  protected static function getFacadeAccessor()

  {

    return BlogService::class;

  }

}

 

Service-:

public function create(array $data): void

{

   $this->blogs->create($data);

}

 

 

Structural Design Patterns

Structural design patterns are concerned with how classes and objects can be composed, to form larger structures. The structural design patterns simplify the structure by identifying the relationships. These patterns focus on, how the classes inherit from each other and how they are composed of other classes.

Adapter: Adapter is a structural design pattern that allows objects with incompatible interfaces to collaborate.

Bridge: Bridge is a structural design pattern that lets you split a large class or a set of closely related classes into two separate hierarchies—abstraction and implementation—which can be developed independently of each other.

Composite: Composite is a structural design pattern that lets you compose objects into tree structures and then work with these structures as if they were individual objects.

Decorator: Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.

Facade: Facade is a structural design pattern that provides a simplified interface to a library, a framework, or any other complex set of classes.

More Info : https://www.javatpoint.com/structural-design-patterns

        : https://refactoring.guru/design-patterns/structural-patterns

 

Facade Design Pattern

The facade is a part of the Gang of Four design pattern and it is categorized under Structural design patterns. Before we dig into the details of it, let us discuss some examples which will be solved by this particular Pattern. So, As the name suggests, it means the face of the building. The people walking past the road can only see this glass face of the building. They do not know anything about it, the wiring, the pipes, and other complexities. It hides all the complexities of the building and displays a friendly face. In Java, the interface JDBC can be called a facade because we as users or clients create connections using the “java.sql.Connection” interface, the implementation of which we are not concerned about. The implementation is left to the vendor of the driver. Another good example can be the startup of a computer. When a computer starts up, it involves the work of CPU, memory, hard drive, etc. To make it easy to use for users, we can add a facade that wraps the complexity of the task, and provide one simple interface instead. The same goes for the Facade Design Pattern. It hides the complexities of the system and provides an interface to the client from where the client can access the system.

More Info: https://www.geeksforgeeks.org/facade-design-pattern-introduction/

Facebook   : https://www.facebook.com/CyberElysium

Instagram   : https://www.instagram.com/cyber_elysium/

Twitter     : https://twitter.com/CyberElysium

LinkedIn   : https://www.linkedin.com/company/CyberElysium

Facebook Community : https://www.facebook.com/groups/2945714992424838/

Visit our website for more details: https://cyberelysium.com/

Share this post with your friends

Thanks for reading ❤

Ready to grow your business digitally?