| ▲ | sagenschneider 3 hours ago | |||||||||||||||||||||||||
Yes, the formula does make some approximations. The problem with cohesion is understanding what is "single purpose". Nothing can determine this without interpreting the code and making a judgement call on whether it needs to be refactored into two or more classes. So I'm looking to approximate this. Instead of looking for cohesion, Change Impact formula approximates this by looking at existing complexity in the file. If the change adds more complex functions to an already complex class, it scores high. Smell of it doing too many things. If the change adds a complex function to an empty file, it's likely just a complex single problem. If the change adds simple change to complex file, then if this happens too many times, we flag it for concern. Especially if it changes a lot of other files too. So it's not mean to measure your code exactly. It's meant to highlight smell that needs investigation. And the formula points out the classes that need looking at. Plus I'm not sure that all changes are equivalent. I'm not looking at single one off changes. I'm looking at 60 changes in a row. The first 20 might go through fine. However, after the changes pile on, there needs to be some refactoring to keep the code clean. This is trying to catch it before it becomes a mess. | ||||||||||||||||||||||||||
| ▲ | eithed 2 hours ago | parent [-] | |||||||||||||||||||||||||
> If the change adds a complex function to an empty file, it's likely just a complex single problem. How do you determine that this is correct = adding complexity to a single file vs adding less complexity to multiple files that this one file then orchestrates. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||