Use a language with Design-by-Contract or "Code-contracts" (preconditions, check assertions, post-conditions, class-invariants, etc) to get "testing" as close to your classes and class features (methods and properties) as possible. Then use TDD to test your code with its contracts.
Use as much self-built code-generation as you possibly can. Generated code is proven, predictable, easier to debug, and easier/faster to fix than all-hand-coded code. Why write what you can generate? However, do not use OPG (other-peoples-generators)! Code YOU generate is code you control and know.
You can expect to spend an inverting ratio over the course of your project--that is--you will write lots of hand-code and contracts in the start (1:1) of your project. As you see patterns, teach a code generator YOU WRITE to generate the code for you and reuse it. The more you generate, the less you design, write, debug, and test. By the end of the project, you will find that your equation has inverted: You're writing less of your core-code, and your focus shifts to your "leaf-code" (last-mile) or specialized (vs generalized and generated) code.
Finally--get a code analyzer. A good, automated code analysis rule system and engine will save you oodles of time finding "stupid-bugs" because there are well-known gotchas in how people write code in particular languages. In Eiffel, we now have Eiffel Inspector, where we not only use the 90+ rules coming with it, but are learning to write our own rules for our own discovered "gotchas". Such analyzers not only save you in terms of bugs, but enhance your design--even GREEN programmers "get it" rather quickly and stop making rookie mistakes earlier and learn faster!
The rule of thumb for rewriting existing systems is this: "If it took 10 years to write, it will take 10 years to re-write." In our case, using Eiffel, Design-by-Contract, Code Analysis, and Code Generation, we have re-written a 14 year system in 4 years and will fully deliver in 4 1/2. The new system is about 4x to 5x more complex than the old system, so this is saying a lot!
p. 31: "Testing [...] accounts for 45% of initial development of a product." A good rule of thumb is thus to allocate about half of your total effort to testing during initial development.
Only a good amount of accumulated statistics from previous projects can help you to give precise estimates. If you have a well defined set of requirements, you can make a rough calculation of how many use cases you have. As I said you need to have some statistics for your team. You need to know average bugs-per-loc number to estimate total bugs count. If you don't have such numbers for your team, you can use industry average numbers. After you have estimated LOC (number of use cases * NLOC) and average bugs-per-lines, you can give more or less accurate estimation on time required to release project.
From my practical experience, time spent on bug-fixing is equal to or more (in 99% cases :) ) than time spent on original implementation.
Maybe I just write buggy code, but I like having a 1:1 ratio between devs and tests. I don't wait until alpha to test, but rather do it throughout the whole project. The logic? Depending on your release schedule, there could be a good deal of time between when development starts and when your alpha, beta, and ship dates are. Furthermore, the earlier you catch bugs, the easier (and cheaper) they are to fix.
A good tester, who find bugs soon after each check-in, is invaluable. (Or, better yet, before a check-in from a PR or DPK) Simply put, I am still extremely familiar with my code, so most bug fixes become super simple. With this approach, I tend to leave roughly 15% of my dev time to bug fixing. At least when I do estimates. So in a 16 week run I'd leave around 2-3 weeks.
It really depends on a lot of factors. To mention but a few: the development methodology you are using, the amount of testing resource you have, the number of developers available at this stage in the project (many project managers will move people onto something new at the end).
As Rob Rolnick says 1:1 is a good rule of thumb- however in cases where a specification is bad the client may push for "bugs" which are actually badly specified features. I was recently involved in a project which used many releases but more time was spent on bug fixing than actual development due to the terrible specification.
Ensure a good specification/design and your testing/bug fixing time will be reduced because it will be easier for testers to see what and how to test and any clients will have less lee-way to push for extra features.
发布评论
评论(5)
使用具有契约设计或“代码契约”(前置条件、检查断言、后置条件、类不变量等)的语言来获得尽可能接近您的类和类功能(方法和属性)的“测试”可能的。 然后使用 TDD 来测试您的代码及其合约。
尽可能多地使用自建代码生成。 生成的代码经过验证、可预测、更易于调试,并且比全手工编码的代码更容易/更快地修复。 为什么要写你能生成的东西? 但是,请勿使用 OPG(其他人生成器)! 您生成的代码是您控制和了解的代码。
您可以期望在项目过程中花费相反的比率,也就是说,您将在项目开始时(1:1)编写大量手动代码和合同。 当您看到模式时,教您编写的代码生成器为您生成代码并重用它。 生成的内容越多,设计、编写、调试和测试的内容就越少。 到项目结束时,您会发现您的方程式已经颠倒了:您编写的核心代码更少,并且您的重点转移到“叶代码”(最后一英里)或专用代码(与通用和生成的代码相比) ) 代码。
最后——得到一个代码分析器。 良好的自动化代码分析规则系统和引擎将为您节省大量查找“愚蠢错误”的时间,因为人们在使用特定语言编写代码时存在众所周知的陷阱。 在 Eiffel,我们现在有了 Eiffel Inspector,我们不仅使用它附带的 90 多个规则,而且正在学习为我们自己发现的“陷阱”编写我们自己的规则。 这样的分析器不仅可以减少错误,还可以增强您的设计——即使是绿色程序员也能很快地“掌握”,并尽早停止犯菜鸟错误并学得更快!
重写现有系统的经验法则是:“如果需要 10 年的时间来编写,那么就需要 10 年的时间来重新编写。” 在我们的案例中,使用 Eiffel、合同设计、代码分析和代码生成,我们在 4 年内重写了 14 年的系统,并将在 4 1/2 内完全交付。 新系统比旧系统复杂大约 4 到 5 倍,所以这说明了很多!
Use a language with Design-by-Contract or "Code-contracts" (preconditions, check assertions, post-conditions, class-invariants, etc) to get "testing" as close to your classes and class features (methods and properties) as possible. Then use TDD to test your code with its contracts.
Use as much self-built code-generation as you possibly can. Generated code is proven, predictable, easier to debug, and easier/faster to fix than all-hand-coded code. Why write what you can generate? However, do not use OPG (other-peoples-generators)! Code YOU generate is code you control and know.
You can expect to spend an inverting ratio over the course of your project--that is--you will write lots of hand-code and contracts in the start (1:1) of your project. As you see patterns, teach a code generator YOU WRITE to generate the code for you and reuse it. The more you generate, the less you design, write, debug, and test. By the end of the project, you will find that your equation has inverted: You're writing less of your core-code, and your focus shifts to your "leaf-code" (last-mile) or specialized (vs generalized and generated) code.
Finally--get a code analyzer. A good, automated code analysis rule system and engine will save you oodles of time finding "stupid-bugs" because there are well-known gotchas in how people write code in particular languages. In Eiffel, we now have Eiffel Inspector, where we not only use the 90+ rules coming with it, but are learning to write our own rules for our own discovered "gotchas". Such analyzers not only save you in terms of bugs, but enhance your design--even GREEN programmers "get it" rather quickly and stop making rookie mistakes earlier and learn faster!
The rule of thumb for rewriting existing systems is this: "If it took 10 years to write, it will take 10 years to re-write." In our case, using Eiffel, Design-by-Contract, Code Analysis, and Code Generation, we have re-written a 14 year system in 4 years and will fully deliver in 4 1/2. The new system is about 4x to 5x more complex than the old system, so this is saying a lot!
来自测试圣经:
测试计算机软件
img src="https://images-na.ssl-images-amazon.com/images/I/51EZ3VV7STL._SL160_.jpg" alt="测试计算机软件">
< 31:“测试 [...] 占产品初始开发的 45%。” 因此,一个好的经验法则是在初始开发期间将大约一半的总工作量分配给测试。
From the testing Bible:
Testing Computer Software
p. 31: "Testing [...] accounts for 45% of initial development of a product." A good rule of thumb is thus to allocate about half of your total effort to testing during initial development.
只有从以前的项目中积累大量的统计数据才能帮助您做出精确的估计。 如果您有一组明确定义的需求,您可以粗略计算您有多少用例。 正如我所说,你需要为你的团队提供一些统计数据。 您需要知道每个位置的平均错误数才能估计错误总数。 如果您的团队没有此类数字,您可以使用 行业平均数字。 在估计了 LOC(用例数量 * NLOC)和每行平均错误后,您可以对发布项目所需的时间给出或多或少准确的估计。
根据我的实践经验,修复错误所花费的时间等于或更多(在 99% 的情况下:))花费在原始实现上的时间。
Only a good amount of accumulated statistics from previous projects can help you to give precise estimates. If you have a well defined set of requirements, you can make a rough calculation of how many use cases you have. As I said you need to have some statistics for your team. You need to know average bugs-per-loc number to estimate total bugs count. If you don't have such numbers for your team, you can use industry average numbers. After you have estimated LOC (number of use cases * NLOC) and average bugs-per-lines, you can give more or less accurate estimation on time required to release project.
From my practical experience, time spent on bug-fixing is equal to or more (in 99% cases :) ) than time spent on original implementation.
也许我只是编写了有缺陷的代码,但我喜欢开发人员和测试人员之间的比例为 1:1。 我不会等到 alpha 版本才进行测试,而是在整个项目中进行测试。 逻辑? 根据您的发布时间表,开发开始与 alpha、beta 和发布日期之间可能需要很长时间。 此外,越早发现错误,修复起来就越容易(也更便宜)。
一名优秀的测试人员在每次签入后很快就能发现错误,这是非常宝贵的。 (或者,更好的是,在从 PR 或 DPK 签入之前)简单地说,我仍然非常熟悉我的代码,因此大多数错误修复变得非常简单。 通过这种方法,我倾向于将大约 15% 的开发时间用于修复错误。 至少在我做估算时是这样。 因此,在 16 周的跑步中,我会离开大约 2-3 周。
Maybe I just write buggy code, but I like having a 1:1 ratio between devs and tests. I don't wait until alpha to test, but rather do it throughout the whole project. The logic? Depending on your release schedule, there could be a good deal of time between when development starts and when your alpha, beta, and ship dates are. Furthermore, the earlier you catch bugs, the easier (and cheaper) they are to fix.
A good tester, who find bugs soon after each check-in, is invaluable. (Or, better yet, before a check-in from a PR or DPK) Simply put, I am still extremely familiar with my code, so most bug fixes become super simple. With this approach, I tend to leave roughly 15% of my dev time to bug fixing. At least when I do estimates. So in a 16 week run I'd leave around 2-3 weeks.
这确实取决于很多因素。 仅举几例:您正在使用的开发方法、您拥有的测试资源量、项目中此阶段可用的开发人员数量(许多项目经理会在最后将人员转移到新的东西上)。
正如 Rob Rolnick 所说,1:1 是一个很好的经验法则 - 然而,在规范不好的情况下,客户端可能会提出“错误”,而这些错误实际上是指定错误的功能。 我最近参与了一个项目,该项目使用了许多版本,但由于糟糕的规范,花在错误修复上的时间比实际开发的时间多。
确保良好的规范/设计,您的测试/错误修复时间将会减少,因为测试人员将更容易了解测试什么以及如何测试,并且任何客户都将没有多少余地来推动额外的功能。
It really depends on a lot of factors. To mention but a few: the development methodology you are using, the amount of testing resource you have, the number of developers available at this stage in the project (many project managers will move people onto something new at the end).
As Rob Rolnick says 1:1 is a good rule of thumb- however in cases where a specification is bad the client may push for "bugs" which are actually badly specified features. I was recently involved in a project which used many releases but more time was spent on bug fixing than actual development due to the terrible specification.
Ensure a good specification/design and your testing/bug fixing time will be reduced because it will be easier for testers to see what and how to test and any clients will have less lee-way to push for extra features.