Weeds
"Weed is a plant that has ended up in the wrong place. Either it got there through carelessness or it has been allowed to germinate and grow from being insignificant. "(New Farmers Handbook)Software is full of weeds. With weeds in this case I mean badly architectured software and not pure bugs. But, believe me: bugs arize from this later even if the are not there yet. This is not only from sloppy programmers and architects. In my last blog post I wrote about architecture in legacy software and with weeds I mean parts of the software not adhering to the architecture. Vines going between layers in the chosen software model.
When creating an architecture we often have high ambitions. Whichever framework we use: Domain Driven Design, Model View Controller or similar. Folders and modules created for the then current ways of working and separation of concern.
Since starting work, the product owner has ordered thins and you have had to solve problems. You are forced to be pragmatic to create the feature that should be in the sprint. An advanced architecture sometimes feels as if it opposes the simple solutions required to handle all the problems you need to solve. You take shortcuts and allows a view to do something that a controller should have done, only because it is convenient or because you do not want to infringe someone else's code.
The project also evolves as it continues. Someone new takes over parts of the code and start writing things. This new person has a different view of architecture and it starts to become inconsistent. Different parts of the code follows different cultures and the cultures evolve. The way of writing code over time is not the same. Old code can have fine "structured programming" as the paradigm was called then. Then there might be a time of object orientation. Object orientation itself has evolved from complex objects handling everything from infrastructure to apis in the same object to modern ways of looking in separation of concern. The revolution of patterns-thinking can leave traces. It is like archeology with cultural layers to dig through.
Weeding
It is
important to remove weeds. Keep in mind that a lot of weeds can be
useful to others. It's often something that has
ended up in the wrong place, rather than being wrong in itself. A
good refactoring tool allows it to be moved to the right place with
some clicks if you know where to put it. Step one is to separate the
misplaced code to a new method if it is not separated from the
beginning. Often the IDE will have refactoring tools to help with
extracting a new method. Then move the method to the class it
belongs to. Is it not useful at the moment so “compost” it: Remove
it and allow revision management system take care of it.
Inga kommentarer:
Skicka en kommentar