It is typical of development projects that the developers usually fall in love with some particular implementation mechanisms and they repeat the same code over and over again.
When you look at the code all you see is the same patterns over and over again:
mechanism1
mechanism2
mechanism3
mechanism1
mechanism3
mechanism2
mechanism1
...
So in reality this developer has learned 2 or 3 tricks and applies them to no avail.
The only problem with this approach is that several days, months or even years later the developer learns that his tricks has a bug.
Either:
1. A programming bug,
2. A design bug (the design doesn't handle some important cases), or
3. An analysis bug (the requirements were not the correct requirements)
So we need to make some changes, but the code has been copied around in too many places and now making a change is too expensive... because we need to change the code in so many places and when we change the code in one place to fix a bug, we introduce 2 more bugs and we destroy what was originally working. Managers feel really frustrated when they find out this and they think it is better to hire more developers, since the amount of bugs is increasing instead of decreasing.
Inevitably developers think it is cheaper to rewrite the whole thing. Managers tend to think it is waste of time. Unfortunately both are correct.
Developers are correct because actually the mechanisms were buggy, so instead of fixing the same 10 lines of code during 3 months, you can simply rewrite the whole thing in 2 months using the improved mechanism.
Managers are correct because rewriting the same thing is only going to lead to missing cases being managed, they code will look correct but the code won't work as expected and we will wonder why did we rewrite the whole thing anyway. Something that took so much time to tweak, now it will be clean and simple, but it will not handle all the special cases. In order to handle the special cases, developers will have to tweak the code and therefore the code will become a mess anyway. If it is already a mess, it is for a reason, go with it.
So I'm saying both are correct and both are saying just the opposite. What gives?
If developers rewirte the whole system, they will throw away the old mechanism and write the new mechanism over and over again. They think the future will be better, and they are correct, but no mechanism is perfect. So eventually they will realize the new mechanism is also buggy, differently buggy, maybe a lot less buggy, but buggy anyway. so the correct answer is:
Developers have to write the intent, and the mechanism must be hidden inside a library (an abstraction layer), so that whenever something needs to be changed, it is changed at the library level (assuming the business intent was correctly explicited in the business code).
I will say it again in different ways:
1. Do not write mechanisms in your business code, but write only business intent.
2. Hide implementation details in libraries.
3. Create abstraction layers.
4. Write black boxes.
No hay comentarios:
Publicar un comentario