KISS 原则翻译

原文地址 https://people.apache.org/~fhanik/kiss.html


What does KISS stand for?

KISS 代表什么?

The KISS is an abbreviation of Keep It Stupid Simple or Keep It Simple, Stupid

KISS 是 保持愚蠢的简单 或 保持简单,愚蠢 的缩写。


补充

Keep It Simple & Stupid;
Keep It Sweet & Simple;
Keep It Short & Simple;
Keep it Simple, Sweetheart;
Keep it Simple, Sherlock。


What does that mean?

这是什么意思?


This principle has been a key, and a huge success in my years of software engineering.A common problem among software engineers and developers today is that they tend to over complicate problems.

这一原则是我多年软件工程取得巨大成功的关键.   今天的软件工程师和开发人员之间的一个常见的问题是,他们往往会使问题复杂化。


Typically when a developer is faced with a problem, they break it down into smaller pieces that they think they understand and then try to implement the solution in code. I would say 8 or 9 out of 10 developers make the mistake that they don't break down the problem into small enough or understandable enough pieces. This results in very complex implementations of even the most simple problems, another side effect is spagetthi code, something we tought only BASIC would do with its goto statements, but in Java this results in classes with 500-1000 lines of code, methods that each have several hundreds of lines.
This code clutter is a result of the developer realizing exception cases to his original solution while he is typing in code. These exception cases would have solved if the developer had broken down the problem further.

通常当一个开发人员面临着一个问题, 他们把它分成小块,他们思考,他们推断 然后试着在代码中实现解决方案。我想说十之八九的开发人员所犯的错误,他们不能将问题分解成足够小 或 足够理解的小块。这会导致即使是最简单的问题 有非常复杂的实现。 另一个副作用是spagetthi代码, 值得重视的是,我们只做基本的goto语句,但是在JAVA里 这会导致类中多500---1000行代码,每个方法多数百行。

这些杂乱的代码会导致开发人员输入他的原方案代码时 出现异常情况,如果开发者进一步分解问题 这些异常情况会被解决。

How will I benefit from KISS

我将从KISS 中获得哪些好处

  • You will be able to solve more problems, faster.
  • 你将更快速的解决更多问题
  • You will be able to produce code to solve complex problems in fewer lines of code
  • 你将能写出更少的代码解决负载的问题
  • You will be able to produce higher quality code
  • 你将能写出高质量的代码
  • You will be able to build larger systems, easier to maintain
  • 你将能够建立更大的系统,更容易维护
  • You're code base will be more flexible, easier to extend, modify or refactor when new requirements arrive
  • 当有新的需求 需要修改或重构时,你的代码库会更灵活,更容易扩展
  • You will be able to achieve more than you ever imagined
  • 你将能够实现比你想像的还要好
  • You will be able to work in large development groups and large projects since all the code is stupid simple
  • 你将能够在大开发团队和大项目中工作,应为所有代码都是简单的愚蠢的

How can I apply the KISS principle to my work

如何将KISS原则应用于我的工作

There are several steps to take, very simple, but could be challenging for some. As easy as it sounds, keeping it simple, is a matter of patience, mostly with yourself.

有几个步骤,非常简单,但对一些人来说是一个挑战,主要是对自己,保持它的简单,这是一种耐心,像听起来那么容易。

  • Be Humble, don't think of yourself as a super genius, this is your first mistake
  • 要谦虚,不要认为自己是一个超级天才,这是你的第一个错误
    By being humble, you will eventually achieve super genius status =), and even if you don't, who cares! your code is stupid simple, so you don't have to be a genius to work with it.
  • 谦虚,你最终会实现超级天才状态=),甚至如果你不,谁在乎!代码是愚蠢的简单,所以你不必是一个天才。
  • Break down your tasks into sub tasks that you think should take no longer than 4-12 hours to code
  • 你的任务分解成子任务,你认为应采取不超过4 - 12小时去写代码
  • Break down your problems into many small problems. Each problem should be able to be solved within one or a very few classes
  • 你的问题分解成许多小问题每个问题应该能在很少的类中解决。
  • Keep your methods small, each method should never be more than 30-40 lines. Each method should only solve one little problem, not many uses cases
    If you have a lot of conditions in your method, break these out into smaller methods.
  • 保持你的小方法,每个方法不应该超过30 - 40行每个方法应该只解决一个小问题,而不是许多用例
    如果你有很多的条件方法,这些分解成更小的方法。

    Not only will this be easier to read and maintain, but you will find bugs a lot faster.
  • 这不仅可以更容易阅读和维护,二期你发现bug会快很多。
    You will learn to love Right Click+Refactor in your editor.
  • 你将学会爱你的编辑器中右键单击+重构。
  • Keep your classes small, same methodology applies here as we described for methods.
  • 保持你的类小,我们描述方法在此是同样适用的。
  • Solve the problem, then code it. Not the other way around
  • 解决这个问题,然后写代码,而不是相反
    Many developers solve their problem while they are coding, and there is nothing wrong doing that. As a matter of fact, you can do that and still adhere to the above statement.
  • 许多开发人员解决他们的问题时编码,这样做没有错。事实上,你可以这样做,仍然坚持上述声明。
    If you have the ability to mentally break down things into very small pieces, then by all means, do that while you are coding. But don't be afraid of refactor your code over and over and over and over again. Its the end result that counts, and number of lines is not a measurement, unless you measure that fewer is better of course.
  • 如果你有精力把事物分解成很小的碎片,你编码尽力分解。不要害怕一次次的重构代码,最终结果才是最重要的。行数不是一个测量措施,减少当然更好
  • Don't be afraid to throw away code. Refactoring and recoding are two very important areas. As you come across requirements that didn't exist, or you weren't aware of when you wrote the code to begin with you might be able to solve the old and the new problems with an even better solution.
    If you had followed the advice above, the amount of code to rewrite would have been minimal, and if you hadn't followed the advice above, then the code should probably be rewritten anyway.
  • 不要害怕扔掉代码重构和重新编码是两个非常重要的领域。当你遇到新的要求(需求),,或者你没有意识到当你开始写代码 可以解决 旧的和新的问题 更好的解决方案。如果你遵循上面的建议,重写代码的数量是最少的,如果你没有遵循上面的建议,然后代码应该被重写。
  • And for all other scenarios, try to keep it as simple as possible, this is the hardest behavior pattern to apply to, but once you have it, you'll look back and will say, I can't imagine how I was doing work before.
  • 和其他所有情景一样,尽可能让它简单,这是最难应用的行为规范,但一旦你拥有它(行为规范),你会回头看,会说,我无法想象我是如何工作(我以前写的代码都是垃圾)

Are there any examples of the KISS principle

有KISS原则的例子吗

There are many, and I will look for some really great one to post here. But I will leave you with the following thought:

有很多,我将寻找一些真正伟大的一个帖子贴在这,但是我将留给你们思路

Some of the world's greatest algorithms are always the ones with the fewest lines of code. And when we go through the lines of code, we can easily understand them. The innovator of that algorithm, broke down the problem until it was so easy to understand that he/she could implement it.
Many great problem solvers were not great coders, but yet they produced great code!

一些世界上最伟大的算法总是的最少的代码行。当我们浏览代码,我们可以很容易的理解。算法的创新者,分解问题,直到他/她可以理解问题并实现它

许多重大的问题的解决者不是伟大的程序员,但是他们写出了极好的代码

Does KISS only apply to java coding

KISS只适用于JAVA吗

Absolutely not, it applies to many other programming languages and extends to many other areas in your life.
The areas that the principle doesn't apply to are: emotions, love and most importantly, your marriage :)

绝对不是,它也适用于许多其他编程语言和延伸到生活中的许多其它领域。

原则不适用的地区是:情感,爱,最重要的是,你的婚姻:)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值