0 Comments

The planning phase of most projects no matter the size result in some kind of documentation or manuals for coding. It could be a rough sketch of the data flow, a UML diagram, feature specifications etc. Some big enterprise projects probably also have a detailed explanation of the individual classes, so that the developers knows exactly what the class has to do and why.

Then again, most projects do not undergo such an elaborate planning phase for various reasons. It might be a one-man hobby application or a simple little website. We all do them from time to time so here is a little trick for adding a planning phase while coding.

Create a new class

Because you haven’t done any real planning, you go ahead and creates a new class with a vague idea about what it has to do and why it has to do it. Instead of just adding properties and methods right away, you can force yourself to think about it and thereby do a little planning. That will help you to keep the class more focused and refactored as you write it and you might find that you need another class instead of just the one.

Comment it

With only the class declaration written in your editor, try to comment the class as thorough as possible. At least answer the three questions what, why and how. This will force you to think about the responsibilities, interface, cohesion and a lot of other things that probably saves you a lot of coding time and effort in the end.

The best thing about this approach is that you get right into the code without doing pre-planning, which most of the smaller hobby projects don’t have. You get the benefits of the planning with the pleasure of just diving into the code right away. It can never remove the need for proper planning for more important projects, but it will get your home project running smoother and better architected with little to no effort.