| Author |
Layering in JS
|
Antonio Fornie
Ranch Hand
Joined: Aug 07, 2008
Posts: 117
|
|
Hello and thanks for the chance to ask about OO JS. I'm used to think about layering in the context of a J2EE architecture, but when we face a js development what are the typical layers involved? Further, how can I manage to separate those layers other than using separate js files? Thank you very much. Sorry for my bad use of English. Antonio [ August 26, 2008: Message edited by: Ulf Dittmer ]
|
I feel there must be far better ways to do what I do... that makes learning even funnier
|
 |
Stoyan Stefanov
author
Ranch Hand
Joined: Jul 16, 2008
Posts: 61
|
|
Thanks Antonio, could you give me some more context or examples what do you mean by layers. I think your English is excellent (but I'm a Bulgarian myself, so I could be wrong )
|
<a href="http://www.thinkinginjavascript.com" target="_blank" rel="nofollow">my OOJS book</a>
|
 |
Antonio Fornie
Ranch Hand
Joined: Aug 07, 2008
Posts: 117
|
|
For example, when I work on a design I usually separate concerns like persistence, presentation, domain, logging... in separate layers. Each layer could be a logical separation from the rest of the components and it's usually formed of various packages. I guess if I tried to develop a project with much javascript I would need to separate some concerns in different modules too. Am I wrong? Of course I know I won't find such layers, but a few other like for example: one for objects, another for handlers, etc... I mean there's not only the need to separate the code in classes as a OO aproach, but to separate those clases themselves. What I really can't be sure of, is the kind of concerns I should localize and separate when I start to design my project. The different coarse-grained responsibilities (using a typical GRASP term) I'll find if a face a project with much javascript. Hope I explained myself :/ I did my best. Thank you very much for your answers. It's great to have you at the forums. Antonio [ August 26, 2008: Message edited by: Antonio Fornie ]
|
 |
Antonio Fornie
Ranch Hand
Joined: Aug 07, 2008
Posts: 117
|
|
I'm afraid my post went to the second page. I gave it a chance to be answered Thank you. Bye. Antonio [ August 27, 2008: Message edited by: Antonio Fornie ]
|
 |
Stoyan Stefanov
author
Ranch Hand
Joined: Jul 16, 2008
Posts: 61
|
|
Hi Antonio, I'm afraid I don't have any best practices for you. You just go with whatever you and your team feel comfortable with. BTW, you can have packages-like functionality in JavaScript too. Actually, it's a good practice to have at least one, just to namespace your application and avoid naming collisions. This is achieved with simple object. then you can do: You can even come up with a convenience namespace() method to help with naming the "packages", so you can do stuff like:
|
 |
Antonio Fornie
Ranch Hand
Joined: Aug 07, 2008
Posts: 117
|
|
Thank you very much. It's good to learn it. Furthermore, I can feel better now that I see I wasn't missing so many things about it Bye. Antonio
|
 |
 |
|
|
subject: Layering in JS
|
|
|