Creating a Cake Maker
Meet Bob, the cake maker. Bob knows how to make cakes and likes to use a special ingredient which only he knows about. Naturally, Bob wants to keep this ingredient secret. He also wants to keep to himself the exact method he uses to prepare cakes (Yes, Bob is surprisingly secretive). So, how would we make Bob?
Well, in a classical language like C# we would define a class to represent a cake maker. We would then create a publicly accessible method others can call to make cakes. And we would make everything else (secret ingredient, steps to bake) private.
Perhaps the best way to understand this is to see it side by side:
Just to complete the picture, the way you actually create Bob is using this CakeMaker module is quite similar in both languages:
The Bottom Line
You may also like:
Did you love / hate / were unmoved by this post?
Then show your support / disgust / indifference by following me on Twitter!