Update README.md

This commit is contained in:
Wei Seng 2020-08-09 03:10:43 +08:00 committed by GitHub
parent 1f6e6f34ea
commit 08cec0e254
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,12 +18,15 @@ attributes by encapsulating them in single Data object.
Real world example Real world example
> Imagine you are cooking a stew for your family for dinner.You want to prevent your family members from comsuming the stew by tasting it while you are cooking, otherwise there will be no more stew for dinner later. > Imagine you are cooking a stew for your family for dinner.You want to prevent your family members from comsuming the stew by tasting it while you are cooking, otherwise there will be no more stew for dinner later.
In plain words In plain words
> Private class data pattern prevent manipulation of data that is meant to be immutable by seperating the data from methods that use it into a class that maintains the data state. > Private class data pattern prevent manipulation of data that is meant to be immutable by seperating the data from methods that use it into a class that maintains the data state.
Wikipedia says Wikipedia says
> Private class data is a design pattern in computer programming used to encapsulate class attributes and their manipulation. > Private class data is a design pattern in computer programming used to encapsulate class attributes and their manipulation.
**Programmatic Example** **Programmatic Example**
Taking our stew example from above. First we have a Stew class where its data is not protected by private class data, making the stew's ingredient mutable to class methods. Taking our stew example from above. First we have a Stew class where its data is not protected by private class data, making the stew's ingredient mutable to class methods.