Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Adam's Rules of Coding

0.00/5 (No votes)
19 Feb 2013CPOL2 min read 5.8K  
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)