Jump to content

js coding style is awful!


defuzed

Recommended Posts

There we go again: the style police!

 

I started using Prestashop with version 1.4. Since then version 1.5 brought multishop and 1.6 was responsive. But for the rest functionality stayed largely the same and it looks like the PS staff is spending most of the time beautifying the code so that it conforms to all kinds of standards. Unfortunately that seems to imply more files and more complexity and as a consequence less transparency for the incidental user who wants to make some modification.

 

The increasing complexity also affects the Prestashop staff. When there were problems with the VAT calculation it took major lobbying from the users to get it improved - as the guy who had programmed the original code had left and people were afraid to touch it. 

 

I would prefer to see a concrete discussion about how we can improve the code rather than some abstract discussion of how we can conform to the latest fad in programming style.

Link to comment
Share on other sites

I'm not asking to follow some fads but best-practices that have become industry standards and are widely being used AND advocated*. JSHint / JSLint provide simple and customizeable tools that help follow these best-practices and are trivial to use.

 

Files like 'order-address.js', where even lax configurations of jshint display over 30 errors on ~220 lines of code -  stuff ranging from more or less trivial "no brackets around if statements" to undefined variables and using "==". This not only makes for poor readability but can also lead to stuff just breaking when using anything other than the default presta config / modules etc. 

 

These coding standards are there exactly for these reasons. You obviously cannot test prestashop for every configuration that users and developers will throw at it. Using these best practices not only prevents a multitude of bugs, compatibility errors, it can also increase performance and increases productivity by making more experienced developers happy and encouraging proper coding standards for novice developers / amateurs.

 

AirBnBs Javascript Styleguide

Idiomatic.js

Google Javascript Styleguide (older but also relevant)

Crockfords Code Conventions (also old but relevant)

...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...