What techniques do you use to maximise code reuse?

后端 未结 7 1613
别那么骄傲
别那么骄傲 2021-01-04 02:36

Some years ago I was told about a study into code reuse. Apparently it was found that, on average, programmers have a 7 minute window when searching for code to reuse. If th

7条回答
  •  孤独总比滥情好
    2021-01-04 02:56

    Try using TDD if your aren't already is my initial repsonse.

    I think the use of TDD is a great way to keep code coupling low, amongst other benefits. While that inherently doesnt prevent the same behaviour from being implemented twice, it makes it a great deal easier when you DO identify an area in which you could remove duplication.

    Another benefit, TDD has a step for removing dupication (refactoring) as part of the cycle.

    Also, tests form part of your codes documentation, thus making it easier to identify duplicated behaviour.

提交回复
热议问题