Software Development Principles with Javascript

We always try to improve our ability to apply our skills to solve problems. The principles of software development have greatly helped me write better code. This includes testing, modulation, using OO, if necessary, etc.

Here is an example of how I achieved some modulation in my JS. This may not be a good 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:

How do you apply the principles of software development to improve the readability, maintainability and other quality attributes of your JS?

Other related (more specific) questions that will help in answering:

I once wrote a simple JS module testing platform that had simple statements and a test helper method using lambda. What do you think of javascript unit testing?

How important is it to determine the boundary between your code and the framework?

JS is mainly used in a browser or on a website. Does this decrease / nullify certain problems?

Do you suggest using OO classes and principles?

Using undefined and / or null? Should this be prohibited?

Using try / catch? Suggested?

When do you switch from JSON to classes? Do you use Util methods that work with data?

Using a prototype? Suggested? What a good case when you have not used it?

+6
javascript software-quality
source share
1 answer

in a large project, I tend to differ between model, control, and view files ([mvc-pattern] [1]).

the model file contains everything regarding data, especially my class (OOP). An example for a model file might be:

 function myClass(){ //private variable var variable=5; //public variable this.newVariable = 10; function myFunction() { //do some stuff alert("my function"); } //public stuff return { myPublicFunction: myFunction } } 

the view file contains everything related to the layout and presentation, and the control file is populated with material related to data processing. control-file uses the class declared in the model file and works with it. therefore, only the control file should be included in the view and call the functions necessary for the layout.

but overall it is completely different to summarize. I like the o-image and the template to use, if that makes sense. but I only have experience developing iPhone, so I can’t say anything about a web developer.

  [1]: http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller 
+1
source share

All Articles