from Hacker News

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

by hobabaObama on 4/18/19, 7:18 AM with 5 comments

As the organisation grows even past 10 people, we see that people create modules which are already present and duplicate the code. What is the most effective way to control this? A partial solution would be Sonar code scan. But then it can catch the syntactical duplication if I am not wrong. What about logical duplication like to read release version we can have 2 classes - ReleaseVersionReader and ReleaseVersionInfo.

It looks almost impossible to achieve in larger organisation with 100s of employees.

Thoughts?

  • by externalreality on 4/18/19, 7:48 AM

    Does the code work? When it stops working then worry about it. Why are you pulling your hair out over duplicate code. Do you know how much duplicate code there is in the Linux Kernel? Gee man, my nerves a shock!
  • by maxheadroom on 4/18/19, 8:50 AM

    IMPE, the most seasoned developers on the project (e.g.: ten years or more) had the experience, that comes with age in position, to know when redundant code was being made and they voiced such during code-reviews for pull-requests.

    The intrinsic problem with this approach, of course, is that you need the people to stick around for this to work and to force code-reviews for check-ins.

  • by pragmaticlurker on 4/18/19, 10:25 AM

    Code Reviews can avoid duplication.