[Noisebridge-discuss] Information Hiding

Garrett Smith dhtmlkitchen at gmail.com
Sat Jan 25 14:23:28 UTC 2014

Good morning JavaScripters,

Last night's class, Michael showed his clock implementation. There
were some code comments and then we concluded with discussion about
scope, the module pattern, and information hiding using functions.

Feedback and comments:
 Suggestion for updating the position of the Hour hand.
 Consider using requestAnimationFrame (with fallback to
vendor-prefixed, and then to setInterval, where needed)
 Something strange happened just before 8:00 on the minutes hand. Is
it related to setInterval?

Code design:
For something such as Michael's clock, adding that to a system of
other objects and having those objects talk to each other, two things
can be used:
1) Closures to hide information from other objects
2) Events to notify when something interesting happened.

Information hiding with closures is intuitive when you get used to
doing it. Just ask yourself: Is this the narrowest possible scope
needed for this particular property or method? What else requires this

This sort of class format works well.

More information about the Noisebridge-discuss mailing list