My Philosphy

Steps To Building A Website

10 Tips to Writing Clean Code

 

 

1. Indent Properly

 

I use indents and white space to show structure and ensure I am consistent with page space and indentations throughout the code.

 

 

2. Logical Ordering

 

Write my code in the order that the website is going to display how the program is going to run. Functions collected together logically on their own pages. The footer section of the code should be positioned at the bottom.

 

 

3. Write Explanatory Comments

 

Write comments that are easy, fast, and straight to the point. Avoid fogging up your code with too many comments though; only include them where they're necessary.

 

 

4. Avoid Large Functions

 

Tidy up your code by breaking large functions into smaller segments. It becomes confusing when one function has hundreds of lines of code within it.

 

 

5. Use Descriptive Variable Names

 

Name variables so it is clear what the variable contains. If you're using a longer name make sure it's descriptive and meaningful.

 

 

6. Check

 

Always go back and look over your code to make sure that it's functional. Alternatively, I put my code through validating programs to ensure that there aren't any mistakes.

 

 

7. Avoid Copy and Pasting

 

If you write a block of code that is 10 lines long and you have to repeat it, rather than rewriting or copying, create a function/method. This can substitute 10 more lines with just 2.

 

 

8. Alphabetize

 

Alphabetize your properties to help reduce the time it takes to find certain properties. It's a lot easier to find something when you know what order it is in and where it should be.

 

 

9. Organization and Consistency

 

The most important variables are declair at the top and be consistent with the code so it can be easy to read. Stick with whatever way I choose to organize the code indenting and how it is typed. Make code organized and use same font or underline convention to keep the code consistant for easy reading. I always structure code in a way that's organized and understandable.  Easy reading means easy use later.

 

 

10. Plan Before You Write

 

Outline websites and projects before writing. It's always better approach something prepared than to realize halfway through that you need to go back and make various revisions. I always make sure I know what I need, planning makes for good code and great programs.