maintainability over coding speed is priority for large scale applications

There's something I actually learned and know first-hand a while back, but I never talked about it really, since I wasn't as into development as I am now. That is, coding something to work gets down in a matter of minutes, whereas coding it to make it so that other future coders will ONLY have to change in one file despite the fact that multiple files will have to change due to the coupling of the components takes much more than a few minutes. I'm talking about ease of maintenability. I wish I can show the code so you know what I"m talking about but I cannot due to the following reasons: 1 ) it's prioprietary in a way and 2 ) there is multiple files that coupled the feature I was working on in a way so there is no way I'm going to post them all.

But main thing is that once any coder makes this change in this file, they will have to go to another file to do something to it.. now whether they even know if that other files need to be change is up in the air and that is the problem. I am trying to avoid that so that they only have to change it in 1 place and that is the challenge.. and it's not as simple as declaring globals or just const number. The feature has to do with Toolbars and enhance it so it can lock and unlock down it so it can be moved around is easy because the QT documentation is very clear and made easy. But it is making it all change in one file that is the goal. But right now due to the framework it is in, the toolbar stuff is actually in 2 or 3 files and changing one without changing the other can easily 'break' the system... although it will not core-dump which is the good thing. Now add elegance look to the code so that there is no redundancy adds another layer to it.

So the maintenance utopia is when a coder only needs to change one small thing in one file and every other files will get update automatically. But reaching this utopia is nearly impossible. That's why it's call utopia!

Another thing I noticed is that I tend to use Singleton all over the place. I guess it is the easily route since it's similar to having globals.. But it is also not the best route since all other files will then have to be touched upon because of inserting the Singleton. This was my initial approach. But I changed it later. To make a long boring story short, I made it so that any maintainer can just change 2 lines of code in a single file without referring to another one. Furthermore, I made it so that if there is a new toolbar to add and want it to have the same features of lock down, then can just create the file and then cut and paste my section of the code to the new file, then change just 2 lines again. So my code in this function is like a template for other future ones.

The thing is that to make it work without caring who is going to read it/maintain took me 10 minutes. I know because I want to make sure the feature works before I work on upgrading the code into a maintainable animal. But it took me 4 hours to code it up into the maintainable animal that it is now. Although to any novice, it looks like a complicated piece of work. But once they use it, it's simple as 1,2,3. For the 10 minutes one, a novice will be able to detect it easily, but it will be a maintenance nightmare in the future if the code and GUI grows larger and features changes keep happening, which is inevitable in the software development world.

No comments: