How many times have I started to write a program only to find out it has a major flaw, that won't be easy to fix and will require a major rewrite. There are 2 easy ways to over come this, one of which is so obvious but no one really likes to do, PLAN!
Plan out your design and code. At least give a project 5 mins of figuring out how you want it to work and the code that is needed to fulfill this. Get a sheet of real paper(yes real paper) and just jot down notes and ideas about the project. Such as doing this operation might take more resources so we might need to cache or do it in steps. Lets say you know you were going to get information from a database and then fill objects with that information. Lets say we know there might be hundreds, thousands, or even millions of objects made in all. A few mins should be put into thinking about this at least. Should you create the objects as we go? should we keep all the objects in memory till the end? Should we just wait till we reach a limit on resources and then dump what has been done to a binary file and keep loading the rest, or might there be a better way? Without thinking the solution to this could be any number of things and it is likely going to have massive problems.
The second way to make sure you will have less flaws is to just write a prototype. Yes that does mean writing the code then rewriting it again, but that doesn't mean we
have to write the whole thing. We could first write a parse for the problem as stated above and test various operations and see which might be best for your problem.
I'm sure I'll write more on this later but for now it is food for thought when working on your next project. Don't let the language own you, find a better solution than hitting your head on the desk!
Thursday, April 27, 2006
Subscribe to:
Posts (Atom)