Facade & Adapter Design in the action

--

Hello geek… let’s learn something about facade design pattern and adapter design pattern with real world scenarios.
(Yet to cover coding part)

How SLF4j became facade?

So, What is facade design in general?:
Logically we can achieve loose coupling between one or more similar components and to the gateway which showcases all components at a glance.
Typically it hides the implementation of subsystem features and gives access to all of them on single dashboard.
Technically slf4j also called as Simple Logging Facade for Java, is an abstraction for all the supported logging frameworks. We can use log4j into that, We can user logback framework, or Jakarta as well, or util package logging provided by java. If we feel uncomfortable with current logging system or the existing system not serving the actual purpose, we can switch to anther logging framework very easily.

Let’s try to understand it with a use-case:
Suppose we wanted to setup a home theater sound box to our home which gives a best quality and includes only two buttons at dashboard or hand-held controller ( Play music, Pause music). These two functionalities were provided by sound system company. Behind the scene there will exists lot more complex sub functionalities involved in it. Lets say user presses play button, Then sound system will receives the input from user and contact’s the resource where the song contains, and provides it to audio encoder and then to amplifier and then to speakers. All these will be done without user’s efforts.

Adapter Design Pattern:

An adapter in real world acts as a support to the unknown target.

--

--

Kumar Nellipudi

Exploring emerging technologies, Exploring problem solving