代码可重用性:值得吗? [英] Code Reusability: Is it worth it?

查看:92
本文介绍了代码可重用性:值得吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们所有人都编写可重用的类和代码.

We all write reusable classes and code.

我们将可配置性考虑在内,以允许我们一次又一次地重用这个出色的新类.

We factor in configurability to allow us to reuse this fantastic new class again and again.

我们告诉老板,现在花这些额外的时间可以节省我们以后的时间和金钱.

We tell our bosses that spending this extra time now will save us time and money later.

但是实际上,对于那些不编写第三方库并花时间在整个应用程序上工作的人来说,您花一个额外的时间编写一个类要重用的次数实际上得到了重用在另一个项目中?

But in reality, for those of us who don't write third party libraries, and spend our time working on a application as a whole, how many times does that one class you spent extra time writing to be reused actually get reused in another project?

您的库中有多少个定制类,这些类将在多个项目中使用?

How many bespoke classes do you have in your library which will get used in more than one project?

推荐答案

我的一般经验法则是:

  1. 如果重复一次,请复制一次.
  2. 如果重复两次,则将其重构.

这篇关于代码可重用性:值得吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆