Click here to Skip to main content
16,017,235 members
Articles
(untagged)

Adam's Rules of Coding

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
19 Feb 2013CPOL2 min read 5.7K   2
These may be obvious to some, but I wanted to get them written down.

I have been writing software for a long time. During that time, some "rules" have presented themselves to me. These may be obvious to some, but I wanted to get them written down.

1. Do the work where it is most appropriate.

I like LINQ a lot. It allows me to do the same kind of selection, sorting, etc. with objects that SQL does with data. You can use it to get your data from a database. In some cases, LINQ will do an admirable job of building a SQL statement to get your data. When you have a complex LINQ query against a database, it will have issues. LINQ will download data (and sometimes huge amounts of it) to process data for a complex query when you are looking for a small data set result. In this situation, writing a SQL query is much more efficient.

2. Clean up your mess.

If you open it, close it. If you make it, destroy it. If you close it, open it. Return things to how you found them. Just like your parents taught you.

3. Before you touch any data, make a backup.

You can do this with most databases by using a Begin Transaction statement. This will give you the opportunity to Rollback if something fails. When working with files, they are fairly simple to make a copy. You can log all changes (old value, new value) to your own transaction log file.

4. Use the right tool for the job.

When you have to mow your lawn, you wouldn't use a bulldozer. Using a compiled Java program to only perform web form validation is not only overkill, but will slow downloading your web pages to a crawl. It will also significantly increase your bandwidth usage. JavaScript would be a much better fit for this situation.

These rules are not yet complete.

What are your coding rules?

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Long time software engineer who rambles occasionally about coding, best practices, and other random things.

Comments and Discussions

 
GeneralRoutine rule Pin
kevenm25-Feb-13 8:06
professionalkevenm25-Feb-13 8:06 
Another rule I am trying to follow for myself,
is to have routines always return a value. No void routines.
Even if its just 1 or 0.
If allows you to place a call to the routine in an expression
like an if statement.

I don't like complex expressions with variable assignments and
function calls -- it makes debugging hard like seeing the return value.
(Especially when stepping thru java)

But occationally, a simple if() statement with the one call seems
worthwhile.
(maybe a dubble standard - I'm still struggling with it)

Keven Miller
GeneralRoutine rule Pin
kevenm25-Feb-13 7:56
professionalkevenm25-Feb-13 7:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.