When I went to CodeStock this year, I think there were maybe two discussions where the topic of code minimization didn't come up. Yes, it's important. It can also go too far.
Specifically, there's this tendency to jam multiple functions into partial forms and stored procedures, as if you had only a limited number of them, or that too many would slow down the program.
Take, for example, a simple Add Event procedure. Something is going to happen, and you want to be able to add it to your database. Now, you find that you ALSO want to edit it. There is a tendency to make these into the same form.
Why? Add and Edit are two very different things, and now you're packing a procedure with if/then statements because either you want to insert or update, return a record number or a coded evaluation of success/failure, etc.
On top of this, you've created a trouble-shooting nightmare because, if you're doing this, then odds are you're combining this functionality across the program, where multiple controllers cross models and call this in to play. This is where you get the 'fix it here, break it over there' that keeps people like me in expensive beer.
Some things lend themselves to reusable code. File upload springs to mind. All file uploads should look alike for ease of use. Other forms need to be evaluated on a case-by-case basis, asking:
- Does it make the program easier to maintain?
- Does it create problems that it doesn't solve?
- Is it making more work for me, or less?