• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jquery and object oriented structure

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to organize/structure/encapsulate all my jquery javascript code:

I have a file "mypage_version1.js" with the following content (VERSION 1):



How can I organize it better?

Does the file "mypage_version2.js" with the following content (VERSION 2) structures the code better than "VERSION 1"?:



I am in doubt, which version is better (both works).

Version 1 is shorter, but cluttered within the file.

What is best practice?

 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which is clearer? WHich is easier to understand for someone who didn't write the code? WHich will be easier to maintain later on?

Too many people try to over-think things and just make things complicated for no reason.
 
reply
    Bookmark Topic Watch Topic
  • New Topic