Coding Standards |
---|
Coding standards are a set of guidelines, best practices, programming styles and conventions followed by developers. Because I do not strictly enforce coding standards, I will instead say coding preferences. Most of my programming is in the "bracing" languages: JavaScript, PHP, Java, and C#. Some of my preferences may not apply to every language.
General Preferencesthis
. It's required when a class name has the same name as a private variable or parameter.static
if it makes sense.get
/set
in JavaScript and C#. Good stuff.Customer
, CustomerPurchase
.customer
, customerPurchase
.customers
, purchases
.const MAX_LINES = 1000;
txtMessage
, btnSubmit
.Not everybody will agree with my preferences, especially when it comes to braces. Look at the following two Basic-like examples, and see which one you prefer.
Example 1 | Example 2 |
---|---|
if triState is 0 then doThing0() else if triState is 1 then doThing1() else doThing2() end if |
if triState is 0 then doThing0() else if triState is 1 then doThing1() else doThing2() end if |