Core Logic - Question #2

Open
james-gardner opened this Issue Mar 6, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@james-gardner

More of a question than a concern as I've been trying to learn more about JavaScript from your example.

In app.core the define function creates a var called 'temp' and runs the constructor. I don't understand why app.f.define is passed in as a parameter when the following check will work without it.

temp = constructor();
if (temp.init && app.utils.typeEqual(temp.init, 'function') && temp.destroy && app.utils.typeEqual(temp.destroy, 'function')) {
// Works just the same.
}

Perhaps I am not understanding the bigger picture here. Is this simply a matter of good practice?

Any help appreciated!

@mpodriezov

This comment has been minimized.

Show comment Hide comment
@mpodriezov

mpodriezov Jul 30, 2012

... looks like Addy tried to encapsulate mediator (publish, subscribe system) and DOM specific methods (HTML elements find, query, bind,unbind, etc) into facade object 'f' and pass it into each module during its "installation" inside core.define method. This facade pattern allows modules to use libraries like JQuery, Dojo etc in one single interface... so they can be changed in any time..

... looks like Addy tried to encapsulate mediator (publish, subscribe system) and DOM specific methods (HTML elements find, query, bind,unbind, etc) into facade object 'f' and pass it into each module during its "installation" inside core.define method. This facade pattern allows modules to use libraries like JQuery, Dojo etc in one single interface... so they can be changed in any time..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment