Webcast (in Italian)
Legacy code is simply code without tests.The goal of every competent software developer is to create designs that tolerate change! This is why it is critical to learn how to confidently make changes in any code base.
Preserving existing behaviour is one of the largest challenges in software development.The three main questions to ask are:
Legacy Code Dilemma
When we change code, we should have tests in place. To put tests in place, we often have to change code.
It is important to know what can be affected by the changes we are making!Effect Sketching is a useful technique that can be used to answer this question. The idea is to create a little graph that shows the effect of your changes. Navigation tools like ReSharper can help you identify all usages of a particular piece of code. However, if your class has a superclass or subclasses pay attention because there might be other clients that you haven't considered.
Working in legacy code is surgery, and doctors never operate alone.Consider reading the book Pair Programming Illuminated. Refactoring
The best way to get better at finding responsibilities is to read more books about design patterns and in particular to read more code.
Programming is the art of doing one thing at a time!Ask your partner to challenge you constantly asking: What are you doing?
Remove duplication as much as possible!You end up with very small focused methods. The goal is to have orthogonality in the system. Your system is orthogonal when there is only one place you have to go to make a change. Removing duplication often reveals design.
Remember, code is your house, and you have to live in it.Rename Class is the most powerful refactoring. It changes the way people see code and lets them notice possibilities that they might not have considered before.
A method should be a command or a query, but not both. A command is a method that can modify the state of the object but that doesn't return a value. A query is a method that returns a value but that does not modify the object.Extract Method is a core technique for working with legacy code. You can use it to extract duplication, separate responsibilities, and break down long methods. It is also recommended to extract methods in a bottom up approach. Extract small pieces first!
In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.I think that learning design patterns and the underline Object Oriented Design principles is really important. However, it is really difficult and time consuming. It requires a fair amount of discipline.
"Having knowledge is not the same as having the skill and practical ability to apply that knowledge to create software applications. This is where craftsmanship comes in."
"If you are serious about achieving mastery, be tenacious about finding mentors to guide you."
"The goal is to find ways to expose yourself to the daily working habits of other skilled people, and observe the ways in which they gradually refine those habits into even greater skill"The main question was: Who to choose?
"Digging deep into a technology is that you can actually explain what’s going on beneath the surface of the systems you work on. This understanding will distinguish you from other who can’t describe the software they've helped build in a meaningful way because all they understand is one little portion. Once you’re part of a team, it’s the application of this pattern that separates out those who are making random piles of rubble (the Pragmatic Programmers called this “programming by coincidence” while Steve McConnell calls it “cargo cult software engineering”) from those who are building cathedrals."