What techniques do you use to maximise code reuse?

后端 未结 7 1559
别那么骄傲
别那么骄傲 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 03:15

    Refactor mercilessly and hope for the best.

    Update (4 years later and hopefully wiser)

    • Like S.Lott's comment says: Pay attention to Naming. Spread the word to all 'committers' in the team. Good names make things searchable and thereby reduces duplication.
    • Have ONE way of doing something and keep it ACCESSIBLE and SEARCHABLE.
    • Write code for the average (L.C.D.) programmer.. Don't be clever where simple would suffice. (That includes design-pattern shoe-horning compulsion and related disorders)
    • Adopt a common set of conventions, styles, guidelines, standards, et.all early. Ensure buy-in and thereby compliance within the team. (This means everyone uses the tabs (or spaces)!). It doesn't matter what you choose - the goal is that the code should look consistent
    • Have a gatekeeper (respected by the team), who eyeballs all check-ins for red-flags.
    • Write code test-first / outside-in. This usually ensures that your code is usable by multiple clients. (See GOOS's bullet on context-independence)
    0 讨论(0)
提交回复
热议问题