Clip Art Best Practices
Pierce Home
Computer Science 555 Website Development using JavaScript and AJAX - 3 Units
Section:
3179
Instructor:
Brad Gilbert
Pierce Mailbox:
612
Email:
pierce@wavethunder.com
Wednesday Office Hours:
5:00 -   5:40 PM COSC 1507
Wednesday Lab:
5:45 -   7:50 PM COSC 1507
Wednesday Lecture:
7:55 - 10:00 PM MATH 1511
Other classes:
CS-575
best practices
Question:

What does "Best Practices" mean?

Answer:

Best Practices means building software, including web applications, that:
runs efficiently, is bug free, and is easy to maintain and update - including by someone other that the original developer, which means the source code must be clear, understandable, and well commented.

Question:

I've heard the term "elegant" applied to source code, what does that mean?

Answer:

The goal is for source code to be as simple as possible, with the least lines of code needed, providing for the software to run as efficiently as possible. For example: if you want to get the total of 10 scores, you could declare 10 variables, and write 10 lines of code to add each score into a variable named nTot. In addition, you could write that same code over and over again, wherever you want to total some scores.

A better (more elegant) approach would be to use an array, and write a function using a loop, that could be called anywhere you need to total some scores. The advantages of this approach include:

  1. Your code is easier to maintain, because the work is done in only one place.
  2. Your code is more flexible - you could add 2 numbers or a hundred numbers.
  3. Your code is easier to maintain, because the work is done in only one place.
  4. Your code is less apt to break if you need to change what scores you are totaling.
  5. Your JavaScript file is smaller, using less band-width and space on the server hard-drive, saving time and money in that: the webpage downloads faster for visitors to your site, and you do not have to buy more band-width or server space.

On the other hand, writing an extra function, loop, and array just to add 2 numbers one time is called "over-engineering". It is the developer's job to find the right balance between elegant and over-engineering. Keep in mind: more often than not, when you think you are only going to do something simple and only one time - you will later realize you want to do that again, with a slight variation.

Question:

What are some specific examples of Best Practices?

Answer:

Click on the below links for specific examples.

Brad Gilbert · Fall 2011
Computer Science · Pierce College · Woodland Hills CA · 818-719-6401