Go ahead and read it. It'll take 5 minutes.
So I agree that those changes were probably improvements to the code. But when I see code, I see layers and coupling and dependencies. So I thought I'd post a refactoring here that is very different than you'll see in most places.
First, the original code...
And now the original refactored code...
So here is my refactoring. You will see that it is very, very different than the original improved suggested version.
I bet you weren't expecting that. I have been a developer for over 30 years and it has taken some time to see software the way I do. So lets evaluate this. Is the code better? It depends.
- The code above has separation of logging, error flow, and notification and emphasizes composition instead of inheritance.
- The main business logic (found in InvoiceBasics) is very simple and clean.
- More functionality can be added without disturbing everything else.
- It is far more testable than the original.
- It conforms more to the Single Responsibility Principle than the original.