Tips for you ...
This is my first time reading Friday Facts. On the one hand, because English is simply difficult, I have no talent for languages. Second, because I didn't know what could be in it
. I'm an avid gamer, Factorio is the game of games for me. However, I've never been a good player
So I'm a legacy code specialist. I am extremely pleased that you are making the right decisions here. I am called when a team is desperate about its own code, when a small bug regularly lasts for several days, when features are as complex as a new program and still in the wrong place, generated duplicate code and ignored existing interfaces, etc. Just before the whole program is buried, then I come to the train.
I have already encountered dozens of functions / methods that were over 40,000 lines in size. Or classes over 700,000 lines
All of the scenarios described are simple truths of a developer’s life. I myself also constantly step into the traps, although I have always paid full attention to these issues.
However, through my almost 30 years of experience, I have developed / discovered a few tips and behavior tools here and there that will help me and hopefully you too.
The scenarios you describe are quite normal. Even to myself it happens with guarantee over time that I will also create code like this. Decreasing sharply for 4-5 years. And from it the first tips, exclusively for you
. I determined the tips myself and I am sure that others have already mentioned them.
1. As soon as every (!) Developer sees something that he can improve, which is wrong or simply ugly in the old code -> improve immediately!
a. Immediately means in the same week. So that's how I do it.
i. Develop for 4 days and write down everything I see
ii. On Friday the day is reserved to do this refactoring, I say refactoring because I want to encourage people to do it right, i.e. to delete files and code from time to time, so that something better is created.
2. Almost from the start, refactoring 20% of the weekly workload.
i. Rework classes and interfaces,
ii. make it better and easier to use,
iii. document here, in the head of the code, in such a way that one imagines that a colleague from another area should write an extension here in this code and that you make the instructions and assistance easily accessible to him here in the comment.
b. All of that on Friday. Otherwise, Friday afternoon is always the team game afternoon / evening - if I can decide that.
3. If Friday is not enough to include the points in the next sprint planning.
Now a tip for the style, so that the structure of the code can be read and assessed more professionally and faster:
- K&R Style (Resharper setting)
- No blank lines
- 42 inch monitors (at least two) with 4K resolution
- My daughter is currently learning to read. Your books have a large font, lots of spacing and only two or three sentences per page before you have to turn the pages.
- This is helpful for beginners. The complete overview is not exactly important to the beginner - he is caught in the details.
- As a journalist - I was a radio journalist about two years ago thirty years ago - you read a lot. And fast. Sometimes I can do 20 times as much as a normal reader.
- In the 1950s, when their customers were high-volume readers, the big newspapers adapted their font and style to accommodate these high and high-volume readers. I know that the New York Times and the NZZ Neue Zürcher Zeitung did that. In the meantime they have switched again because they now have different readers than they did then.
- At the time, the changeover was scientifically supported and researched on it. It is based on the visual visual way we read. We don't actually read letters, but word, sentence and even paragraph images.
- With its structural properties, the program code is excellently suited to processing the figuratively oriented reading of letters and symbols.
- Now in addition to uniform rules that every editor and program language offers, this visual reading and recognition can still be massively promoted:
o Well then: As a programmer, I feel like a professional reader, like an old-school journalist. Code that looks like a first grade read-study book makes me tremble.
o It is important to design the code in such a way that the structured text is optimally used:
The high structural fidelity of a program code goes far beyond newspaper articles. The code has many structures that are excellent for visual processing.
These are to be used. This means,
Methods one page long (well-known rule)
No blank lines, the structure makes it easy for us to see that something new is beginning. (K&R Style)
Beginning brace at the end of the line.
It is important to read and recognize as much as possible at a glance (= picture).
The effect is that the superordinate structure becomes visually visible -> already when reading the code.
o Regularly consult and work with automatically generated graphics of class hierarchies.
And the last thing to remember
The constant refactoring of the newly emerging code is absolutely decisive.
So nothing beats constantly rolling refactoring refactoring. !!!
If you want, I can also check your code, for free of course.