Planning takes time and time is money.
On its face, this is a true statement. However, the costs of not planning are almost universally higher than the costs of planning.
Or, rather, you will do all the planning needed for a given project at some point or another. Let me explain.
According to the standard project lifecycle, a given project will need to go through the following stages:
- Requirements gathering
- Requiremens analysis
- Architectural analysis
- High-level design (API decomposition, for example)
- High-level design verification
- Low-level design (This function does X, that function does Y)
- High-level design verification
- Coding
- Code verification
- System verification
- Roll-out
Maintenance is a repetition of the above steps, but with a slightly different focus at each one. For example, architectural analysis goes from analysing what you'd like to analysing what you can get away with.
Now, most "authorities" state that a given project should go through those steps in that order. Most real-world project, however, don't. Instead, they lump most of those activies in the Coding bucket. Instead of analysing requirements, someone starts coding and bitches about the poor requirements. Instead of architectural analysis, the coder just uses whatever s/he feels comfortable with.
What ends up happening is that a given project will go through those steps, just without the benefit of being able to change their mind about previous choices. This means that what turn out to be poor architectural choices cannot be altered without significant cost.
There is a reason why over two thirds of all projects started in corporate America fail. They fail because too much money has been sunk into coding by the time it's realized that the architecture or requirements are flat-out wrong. So, the company loses often 2-5 million dollars and 6-12 months. Why? It wasn't over-planning ...
because if you end up needing that data once you're working on a different part of the script
That's what orthogonal coding is for. I wrote about this in Maintainable code is the best code. Maintenance isn't just for when you have released a project. Maintenance is when you have finished a requirement and are going on to the next. If you have a set of functions that are the accessors for a given data structure, then any piece of code can call those functions and access that data structure. If you need to change the data structure, you need to change only those accessor functions. Nothing else needs to know that the data structure changed! "A stitch in time saves nine."
I don't think much about making each routine suitable for a module
I think this demonstrates your lack of experience in the industry. I'm not being mean. I work with several people who have less than 2-3 years under their belt. They're still very wet behind the ears. Writing modular code as a habit is a paradigm shift, and not a small one. That's perfectly fine. Every single programmer wrote their first program at some point, and I don't think any first program was ever modular. I know mine wasn't. It took me several years to understand why I wanted to do this modular crap. But, I chose to change my habits. Not because someone told me to, though that helped. Not because I had an epiphany. I chose to change because I found it easier to work that way. Less time was spent tracking down the same bug, because I knew I fixed it in the one place it could occur. That was my reason for doing things in a modular fashion.
Later, I found it made things easier for me to code, by allowing me to focus on higher-level abstractions vs. having to constantly juggle a million things in my head. I'm not a very smart man - I can't keep more than 5 or 6 things in my head at once before I start to get a headache. So, I work in a way that fits my limitations.
I also learned patience. I'm currently working on a log-analysis website. Writing it modularly does take more time.
But, I was able to benefit from modular code I used in another project so that I didn't have to write the database accessor code or the web-application framework or the main templating framework. It was already done and in a way that was reusable. So, even though I don't have many of the pages done, and those that are up aren't finished, I'm actually further ahead than I would have been if I had started from scratch. Plus, I know that half the code is already tested, so my verification burden is smaller than it would have been. If I find a bug, I know that it probably isn't in the code I am reusing, because that code is more likely to be bugfree.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested