Posts

Showing posts from May, 2016

Observer design pattern for beginners.

Image
Problem statement – Nowadays we all are very active on the internet. Many times we see educational web sites offering free learning with lots of topics. Different people will be interesting on various topics. And web site has millions of users. Now, if you think to design such kind software. How you will keep track of who likes which topics? If u apply simple math, billion users, one user can love as much topic as he/she wish to learn. And you have to send them regular updates related to those topics. Like new chapter has been added or modified on that topic. To all enrolled learners. U ser very from 1 to 1 million from topic to topic.  Actually we can address this problem through observer design pattern, we will see how in this article. Prerequisite – All users shall have one unique identity. For example, email IDs, or say roll numbers, or employee ID, etc. All shall be uniquely identified . You must have noticed. To register in any online forum, it ask your email ID

Bridge design pattern for beginners.

Image
Problem statement – You have got into a situation, where you need to add, or maybe remove, a new feature in the existing software system. But you have no permission to modify the current concrete implementation. How you will address that problem ?  Also, can we refine our interfaces for different requirements?  Background – As standard, we expose abstract layer to the client. The client calls to those APIs without bothering how it is implemented in your library. The library is a black box for clients. Whatever we add or remove any functionality, we have to maintain our interface in such a way, the client code shall not break. To achieve that, we can create layers of abstraction (interfaces) and separate the concrete implementation from the abstract layer. Not all interfaces need to expose the same APIs. For example, company A is using some payment gateway called X in the online e-commerce portal's transactions. But as payment gateway, Y becomes more secure, 

Decorator design pattern for beginners.

Image
Background  In the existing software system. How to add a new functionality at run time? Let’s understand it through an example, we have a text editor class. Who facilitates us write/edit/modify text. As per standard, we should have 80 characters width and 100 lines per page. Again that depends upon the individual user editor’s setting. Now, what if the user wrote more content, and cross the page size limit? Typically a user can start writing on a new page, and he can go to the previous page through arrow key ( ^ ) present in keyboard.  User is looking for vertical and horizontal scroll bars to appear on the page. So that, instead of using arrow key ( ^ )  present in the keyboard, users can use vertical and horizontal scroll bars (graphically) and navigate pages easily. As we understood correctly, vertical and horizontal scroll bars will appear on run time. It will not be there from the starting. It will appear only when we cross-page size limits (vertical or horiz