Joined October 2012
·

Adam Chambers

Senior Engineer at Digital Surgeons
·
Bedfordshire, UK
·
·
·

Posted to Object Orientated Javascript over 1 year ago

No worries. You should certainly check out the modular design pattern though. It's very similar to the code you already write but extra cool because you can store private properties and methods and return just the stuff you need to be public, keeping your code more secure.

Posted to Object Orientated Javascript over 1 year ago

To me that is only object oriented in the sense that you are using an object to organise your code.

A true OO JS approach would be to write interacting classes with distinct roles which contain methods and properties - https://developer.mozilla.org/en-US/docs/JavaScript/Introduction_to_Object-Oriented_JavaScript.

I like to use a true OO approach in combination with the modular design pattern which is similar to your code above but declares the object inside a self invoking function housing private methods and properties and returning only the public data. - http://javascriptplayground.com/blog/2012/04/javascript-module-pattern

Achievements
111 Karma
6,432 Total ProTip Views