Today I want to talk a little bit about coding standards. - TopicsExpress



          

Today I want to talk a little bit about coding standards. Probably the easiest way to get lost in old code, lose desire to maintain projects or libraries, and consume extra time that could have been avoided is to write spaghetti code. But its not always easy to tell that youre beginning to write bad code (sometimes it is and you should catch yourself right then and there). Having a good coding standard helps a lot in the long run and makes it easy to figure out what you or another programmer were trying to do. ~~~~ The first big thing for any good coding standard is to WRITE IT OUT. Have a document that actually lists what you expect when writing code on the team and explain why youre doing it that way. Programmers tend to be very logical, and if you can explain your reasons in logic theyll tend to adhere to them better. Its also easier to pin the blame to someone who IS writing spaghetti code if theres a place they could easily check how it should have been written, thus increasing the likelihood they wont continue going rogue in the future. ~~~~ A big misuse in programming standards is definitely comments. People always talk about how comments are important for reusable and maintainable code, which is true, but many people end up writing comments that are self explained by the code. Function() // Does Function is a bit redundant, and I see this all the time. If it isnt expanding on the functionality, or explaining in further detail its purpose, it probably isnt necessary. Just make sure you DO include the comments when necessary, for things such as elaborating on parameters or return values or explaining what a block of logic does if it uses abbreviations. (On a side note, AVOID ABBREVIATIONS! Intellisense is an industry standard, and it will auto complete your calls.) ~~~~ Probably the biggest thing to actually improve yourself personally in terms of writing better code is to write it right the first time. Now, I dont mean to avoid writing bugs and making your code perfect on the first try, Im saying if you know what function or variable youre about to make (and you should) then write the necessary comments FIRST. If you just wrote a function or variable name and you couldnt tell what its used for without a comment [as a new user], then its probably a bad name and you should think about renaming it. ~~~~ Well Im running out of words and this is already a wall of text. Hopefully someone out there found use from this and Id like to see a discussion to further elaborate about the topic in the comments. Thanks for reading!
Posted on: Thu, 20 Mar 2014 14:47:41 +0000

Trending Topics



Recently Viewed Topics




© 2015