编码优先级:性能、可维护性、可重用性? [英] Coding Priorities: Performance, Maintainability, Reusability?

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

问题描述

这主要是由于对 SQL 问题的回答.由于性能原因,有意省略了 UDF 和子查询.我没有包括可靠性并不是说它应该被视为理所当然,但代码必须工作.

This came about mainly due to answers to SQL questions. UDF's and Sub Queries are intentionally omitted because of performance. I didn't include reliability not that it should be taken for granted, but the code has to work.

性能总是第一位的吗?提供了许多以性能为主要优先事项的答案.我的用户似乎更关心代码的修改速度.因此,运行报告需要 15 秒而不是 12 秒.只要我不为不提供解决方案找借口,他们就可以接受.

Does performance always come first? So many answers are provided with performance as the main priority. My users seem to be more concerned with how quickly the code can be modified. So a report takes 15 seconds instead of 12 to run. They can live with that as long as I'm not making excuses for not providing solutions.

很明显,如果 15 秒变成 15 分钟,那就有问题了,但用户想要这个功能.他们希望应用程序适应业务规则更改和增强请求.我希望能够在 6 个月后查看代码,并且能够在一个容易识别的地方进行更改,而不是追查所有那些复制和粘贴代码的地方,因为他们认为调用另一个函数或子例程或 Udf 会阻碍性能.

Obviously if the 15 seconds turns into 15 minutes, there is an issue, but users want the functionality. They want the application to adapt with the business rule changes and enhancement requests. I want to be able to look at the code 6 months from now and be able to make the change in one easily identified spot and not chase down all those places soneone copied and pasted code because they thought calling another function or sub routine or Udf would hinder performance.

综上所述,我会排序:可维护性(变化是生活中的事实.)、性能(没有人喜欢盯着沙漏.)、可重用性(很难确定应该再次使用哪些代码.).

All that being said, I would order: Maintainability (Change is a fact of life.), Performance (No one likes to stare at the hourglass.), Reusability (Difficult to determine what code should be used again.).

推荐答案

1.可维护性:如果代码不可读,那么它就毫无用处,无论它有多快.而且绝对不会被重复使用.

1. Maintainability: If the code is un-readable it's useless, no matter how fast it is. And it definitely won't be be re-used.

2.可重用性: 并非所有代码都是可重用的,但很多都是.如果可以,请务必使您的代码更简单.最简单的就是分而治之.例如,创建您将反复使用的简单组件.UI 小部件是最常见的.但公用事业也是如此.同样,为代码创建结构/框架也有帮助.错误验证码等

2. Reusability: Not all code is reusable, but a lot of it is. If you can, by all means make your code simpler. The easiest is divide and conquer. For example, create simple components you'll use over and over and over. UI widgets are the most common. But it's the same with utilities. As well, creating a structure/framework to your code helps. Error validation code, etc.

3.性能:通常大多数代码的性能都足够.如果没有,请使用代码分析器.通常情况下,瓶颈远远超过您可以以牺牲可读性或可重用性为代价进行的任何小代码优化.

3. Performance: Generally most code is performant enough. And if not, use a code profiler. More often than the bottleneck will far outweigh any small code optimizations you could have made at the cost of either readability or re-useability.

这篇关于编码优先级:性能、可维护性、可重用性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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