Skip to content

Comment on Ask HN: How do you guys avoid duplication of code?parent

Comments

I do know that you can create StyleCop rules to try to check for redundancy. For example, we had a type derived from System.DateTime in .NET that was to be used (instead of System.DateTime) and the smoketest builds would fail for the StyleCop violation.

So, using your version example, you could create a rule that checks if the method .ctor() has the word version in it and if it leverages any of the same single lines of code; however, I haven't the faintest idea of if I'm right in that it was StyleCop or how you would go about implementing it but I believe what you're looking for can be done.

Most companies don't go that route, though, unless there's security implications because the ROI is so high for the implementation.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.