[Proto-Scripty] Re: $$ is a violation of Model-View-Controller
Hi all, I think $$ is not so good for the reason you give, but how about using the select() method?? you have one reference to the parent object and then you use CSS selector to find childrens. So when moving some pDOM art from a place to another, you just have to change the parent element to the new one, and that' all. -- david On 29 oct, 23:03, Rick.Wellman wrote: > Though I consider javascript/prototype to be one of my weaker web app skills > (which is why I like Prototype in the first place), I feel compelled to add > to this discussion in that: > > While I certainly agree with the Use Case that you are describing (and the > one referenced in the response) I guess I have been "lucky" enough to have > never used $$() that way. However, I have used it (and will most likely > continue to do so) to retrieve elements based on their CSS class selector. > In fact, some of the page "effects" that I have been asked to implement rely > on the use of $$(). So, IMHO, maybe it is better stated that $$() is part of > the View in the MVC paradigm? Just like Struts is a Controller but many > people use the Struts tags which are part of the View? > > -Original Message- > From: prototype-scriptaculous@googlegroups.com > [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of kangax > Sent: Thursday, October 29, 2009 4:51 PM > To: Prototype & script.aculo.us > Subject: [Proto-Scripty] Re: $$ is a violation of Model-View-Controller > > On Oct 29, 4:36 pm, JoJo wrote: > > Is it poor practice to use $$? > > > $$('#grandparent #parent tag.class'); > > > I've been using $$ quite a lot because it has sped up DEVELOPMENT, but > > now I have realized that it will slow down MAINTENANCE. Recently, my > > boss asked me to move a whole div to another part of the page. Since > > I was accessing that div with $$, I was forced to change my JS along > > with my HTML. If I had accessed that div with $('elementID'), I would > > have only needed to edit my HTML. > > > For this, I believe that $$ is a violation of the model-view- > > controller paradigm. HTML and CSS are the view. JS should be thought > > of as the controller. If you think about it, JS processes user input > > just like PHP, except on a livelier schedule. To make your website > > easier to implement, you should refrain from using $$ to describe the > > HTML structure. > > > What are your thoughts? > > Yep. I came to the very same conclusion recently > -http://stackoverflow.com/questions/1567496/jquery-anti-pattern-buildi... > > -- > kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: $$ is a violation of Model-View-Controller
Though I consider javascript/prototype to be one of my weaker web app skills (which is why I like Prototype in the first place), I feel compelled to add to this discussion in that: While I certainly agree with the Use Case that you are describing (and the one referenced in the response) I guess I have been "lucky" enough to have never used $$() that way. However, I have used it (and will most likely continue to do so) to retrieve elements based on their CSS class selector. In fact, some of the page "effects" that I have been asked to implement rely on the use of $$(). So, IMHO, maybe it is better stated that $$() is part of the View in the MVC paradigm? Just like Struts is a Controller but many people use the Struts tags which are part of the View? -Original Message- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of kangax Sent: Thursday, October 29, 2009 4:51 PM To: Prototype & script.aculo.us Subject: [Proto-Scripty] Re: $$ is a violation of Model-View-Controller On Oct 29, 4:36 pm, JoJo wrote: > Is it poor practice to use $$? > > $$('#grandparent #parent tag.class'); > > I've been using $$ quite a lot because it has sped up DEVELOPMENT, but > now I have realized that it will slow down MAINTENANCE. Recently, my > boss asked me to move a whole div to another part of the page. Since > I was accessing that div with $$, I was forced to change my JS along > with my HTML. If I had accessed that div with $('elementID'), I would > have only needed to edit my HTML. > > For this, I believe that $$ is a violation of the model-view- > controller paradigm. HTML and CSS are the view. JS should be thought > of as the controller. If you think about it, JS processes user input > just like PHP, except on a livelier schedule. To make your website > easier to implement, you should refrain from using $$ to describe the > HTML structure. > > What are your thoughts? Yep. I came to the very same conclusion recently - http://stackoverflow.com/questions/1567496/jquery-anti-pattern-building-selectors-with-string-manipulation/1567743#1567743 -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: $$ is a violation of Model-View-Controller
On Oct 29, 4:36 pm, JoJo wrote: > Is it poor practice to use $$? > > $$('#grandparent #parent tag.class'); > > I've been using $$ quite a lot because it has sped up DEVELOPMENT, but > now I have realized that it will slow down MAINTENANCE. Recently, my > boss asked me to move a whole div to another part of the page. Since > I was accessing that div with $$, I was forced to change my JS along > with my HTML. If I had accessed that div with $('elementID'), I would > have only needed to edit my HTML. > > For this, I believe that $$ is a violation of the model-view- > controller paradigm. HTML and CSS are the view. JS should be thought > of as the controller. If you think about it, JS processes user input > just like PHP, except on a livelier schedule. To make your website > easier to implement, you should refrain from using $$ to describe the > HTML structure. > > What are your thoughts? Yep. I came to the very same conclusion recently — http://stackoverflow.com/questions/1567496/jquery-anti-pattern-building-selectors-with-string-manipulation/1567743#1567743 -- kangax --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---