Tuesday, December 14, 2010

PIMPLE Design Pattern : Design Pattern : Private Class Data Pattern

http://img3.visualizeus.com/thumbs/09/10/05/blue,by,apalalaa,colorful,design,art,green,pattern,square,yellow-ee2a0389178aa073045e70f1bc4fb2c8_m.jpgA very basic design pattern which is used in lot of languages. Ever heard of a PIMPLE design pattern
( Private IMPLEmentation Design Pattern). this is how i remember all the design patterns (). We all have private data some from our dad, some from our friends and some from the whole world. SO to reflect this real world scenario in the object oriented language we need to have a mechanism where we can keep things private.

May be if i have a Dad.class and there is a You.class and you want some information in You hidden from your Dad, then you can declare these items as private. So that your Dad would not be able to see them.


But sometime down the line we have to spill out the secrets to some one for some reason . So You can have a getter or setter method through which you can give access (with caution ) to only those people whom you want to expose the secrets after validating using some logic. This pattern is just about encapsulating the private variables.

One way this pattern is very special is that it gives a mechanism to achieve the final kind of functionality but with some limitation. This feature is something unique. We can decide whether to give read access or write access or decide upon the either too based on the logic that we have in our getter and setter methods.
Related Posts Plugin for WordPress, Blogger...