Tuesday, September 2, 2014

API Facade Pattern

A simple interface to a complex system!

Furniture showrooms display the furniture to customers in a pleasing manner so that buyers can make better choices.

Figure: Furniture showroom

It is not practical to store the furniture like that for variety of reasons including space, transportation, identification, etc. Furniture warehouses are not so pleasing to browse with piled up with furniture but they do serve the business requirements of storing them in a way that helps the business.

Figure: Furniture warehouse

It is difficult for customers to visualize what the end product look like if the business only operated a warehouse. It looks way too complicated for customers. Showrooms hide all the complexity of storing the furniture in a warehouse and showing furniture in a way that helps customers to make smart buying choices. In other words, showrooms are facades of warehouses.

You've just learnt the facade pattern!

This is exactly what happens in the digital world as well. Organizations have complex and legacy systems. They are way too complex and inflexible to consume. Further, most consumer applications now obtain information from multiple systems. The API facade pattern hides all the complexity and present a simple interface to consumers.

It looks all spaghetti with no Facade. It is just like customers browsing the warehouse:

Figure: No Facade Architecture

Facade pattern hides the complexity of connecting to multiple systems, dealing with multiple security issues, message formats by presenting a simple interface to clients.

Figure: Facade Pattern in Action

How do we implement such a system? It is actual a simple three step process:

Figure: Three Step Process of Implementation

OK great. Do I have to implement these three steps from scratch? That sounds a lot of work. Yes, you are right - it's a lot of work to implement them on your own. The good news is that there are both commercial as well as open source products available for you to just focus only on the business logic and let these products take care of the rest. Can you give a practical architecture for it? You can use an API gateway together with an ESB. You just need to write the 

Figure: A Practical Architecture to Realize Facade Pattern


1 comment:

Unknown said...

It is available as a ppt here: http://www.slideshare.net/nabeel_yoosuf/api-faade-pattern