LOC Milestones and Limiting Your Code Size
In almost every one of my coding projects, I watch out for milestones when it comes to lines of code. Generally, I prefer short, concise, and simple code, which makes them a bit more interesting. I set my LOC milestones depending on the size of a project. For example, for a little app I'm building, every 200 lines of code is a new milestone. For other apps, like, for example, a class project, my milestones might be three or four hundred lines of code.
Another thing I like to do is set a limit for the size of my code, in terms of lines, that is. I usually begin by estimating the size and complexity of the application, and set my limits accordingly. I try to go below what would make development comfortable, for example, for that app I'm making, I limited my authentication module to under 50 lines of code. It is not done yet, but so far, I have gone past the limit. When it's done, I will be forced to cut down my code enough for it to be within my set limits. Keep in mind that I'm using ruby, which means that I can't place a lot of code in a single line as I could in, say, C++.
Some might consider this unnecessary, but it will contribute to making you a better programmer. Writing less code to achieve the same results is definitely smarter, and will make it easier to maintain and modify in the future: both for you and anyone who stumbles upon your code. There's an adage that goes somewhat along the liens of "always right your code as if the person who will be reviewing it is a criminal psychopath, and knows where you live". I've adapted that philosophy to my development cycle, even if no one is going to review my code (except, maybe sometimes, teachers). Limiting my code size has helped me score some points with professors as well: when comparing two programs which are meant to produce the same results, the one with the shortest code will stand out, especially if it is also the better one. Less is definitely more.
Comments [0]