We are always trying to improve on our ability to apply our skills to solve a problem. Software engineering principles have significantly helped my ability to write higher quality code. This includes testing, modularization, using OO where appropriate, etc.
Here's an example of how I achieved some modularization in my JS. Maybe it is a bad way to achieve this, but it serves as an example of what I mean and contains a few questions of its own.
framework.js
Framework = {
CurrentState : {
IsConfigurationLoaded : false,
IsCurrentConfigurationValid : false,
Configuration : undefined //undefined .. good? bad? undefined?
},
Event : {
//event lib
},
//you get the idea
}
Question:
In what ways do you apply software engineering principles to improve the readability, maintainability, and other quality attributes of your JS?
Other Related (more specific) Questions to help in answering:
I had once written a simple JS unit testing framework, which had simple asserts and a test helper method taking a lambda. What are your thoughts on unit testing javascript?
How important is defining the boundary between your code and framework?
JS is mostly used in a browser or in a website. Does this reduce/nullify certain concerns?
Do you suggest usage of Classes and OO principles?
Usage of undefined and/or null? Should it be forbidden?
Usage of try/catch? Suggested?
When do you go from JSON to classes? Do you use Util methods that operate on the data?
Usage of prototype? Suggested? What is a good case where you wouldn't use it?