Replace conditional with polymorphism – nice in theory but not practical

You’re right – “the conditionals are getting pushed up to the top of the chain” – but there’s no “just” about it. It’s very powerful. As @thkala says, you just make the choice once; from there on out, the object knows how to go about its business. The approach you describe – BaseAction, ViewAction, and … Read more

What’s the difference between Remove and Exclude when refactoring with PyCharm?

Final effect is the same – entry which was Removed or Excluded won’t be refactored, the difference is in presentation. After selecting Exclude you keep entry in the Refactoring Preview, but Remove deletes it from that window. I think that Remove could be useful when you deal with quite large refactoring and marking everything as … Read more

What can you do to a legacy codebase that will have the greatest impact on improving the quality?

Read Michael Feather’s book “Working effectively with Legacy Code” This is a GREAT book. If you don’t like that answer, then the best advice I can give would be: First, stop making new legacy code[1] [1]: Legacy code = code without unit tests and therefore an unknown Changing legacy code without an automated test suite … Read more

When is it good (if ever) to scrap production code and start over? [closed]

Without any offense intended, the decision to rewrite a codebase from scratch is a common, and serious management mistake newbie software developers make. There are many disadvantages to be wary of. Rewrites stop new features from being developed cold for months/years. Few, if any companies can afford to stand-still for this long. Most development schedules … Read more

How much duplicated code do you tolerate? [closed]

Refactoring: Improving the Design of Existing Code The Rule of Three The first time you do something, you just do it. The second time you do something similar, you wince at the duplication, but you do the duplicate thing anyway. The third time you do something similar, you refactor. Three strikes and you refactor. Coders … Read more

Do you find cyclomatic complexity a useful measure?

We refactor mercilessly, and use Cyclomatic complexity as one of the metrics that gets code on our ‘hit list’. 1-6 we don’t flag for complexity (although it could get questioned for other reasons), 7-9 is questionable, and any method over 10 is assumed to be bad unless proven otherwise. The worst we’ve seen was 87 … Read more

tech