Posts

Showing posts from June, 2015

Composite design pattern.

Image
Background  – Before we jump into composite design pattern first let’s focus on whole-part relationship. What is whole-part relationship? When an object contains (or holds) another object in it ,   we say it is a whole-part relationship.  types of whole-part relationship – There are two kind of whole-pert relationship –         a.    Composition         b.       Aggregation Composition – If you destroy whole part will also gets destroyed. Or if you delete whole object part object will be deleted. For example – There is a single room constructed by 4 walls like it is mentioned at below image. If we blast or destroy room all 4 walls will be destroyed.  Here walls are part object and whole is room object. Aggregation – Destroying whole will not destroy part. Or deleting whole object will not delete part object. For example – Consider 2 rooms with 7 walls where 1 wall is common among them same as mentioned at below. Now if I destroy room 1, r

Proxy design pattern for beginners.

Image
Introduction – Remember your school or college days? We used to proxy attendance in the classroom for our best friends, and sometimes we request our friends to proxy our presence. To manage a minimum percentage of classroom attendance. In this proxy game, the main rule was – girls cannot proxy attendance of any their male friends, and vise-versa. Question here is why? Because the voice  is different. This means to proxy someone you both should have/share the same interface. Technically what we are achieving by proxy? We are creating an environment for our teacher. Where the teacher is feeling student X is present in the classroom. But actually/physically he/she is not present. Now one essential concept called location transparency comes into the picture. In proxy design pattern, we achieve location transparency. Means we pretend source is here, but actually, it is not present. Proxy is acting as a source. Till now, we understood how to make a proxy system. Of any