How to KISS榕暇?

首先,準(zhǔn)備兩張干凈的嘴喻杈。 然后彤枢,醞釀好情感,比如臉紅心跳等筒饰。接下來(lái)缴啡,咳咳,前方高能預(yù)警瓷们,非戰(zhàn)斗人員請(qǐng)迅速撤離(斜眼笑)

**********************************我是華麗的分割線(xiàn)**********************************

What does KISS stand for?

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

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.

How will I benefit from 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

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
  • 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.
    Not only will this be easier to read and maintain, but you will find bugs a lot faster.
    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

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

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 :)

小姐姐對(duì) KISS Principle的簡(jiǎn)記:

什么是KISS业栅?

Keep It Stupid Simple or Keep It Simple, Stupid

如何在工作中使用KISS原則

1.保持謙遜
2.分解任務(wù),每個(gè)子任務(wù)可在 4h-12h內(nèi)完成
3.分解問(wèn)題谬晕,每個(gè)小問(wèn)題可以用一個(gè)或者有限幾個(gè)classes解決
4.保持方法短小碘裕,每個(gè)方法不超過(guò) 30-40 lines.單一職責(zé),一個(gè)方法解決一個(gè)問(wèn)題攒钳,而不是很多情況
5.保持類(lèi)短小帮孔, 同4
6.先解決問(wèn)題,再開(kāi)始寫(xiě)代碼不撑。而不是相反
7.別擔(dān)心刪除代碼文兢, 重命名和重構(gòu)非常重要
8.最后一點(diǎn),適應(yīng)所有情況焕檬,盡可能地保持代碼簡(jiǎn)潔姆坚,這也是最難的一點(diǎn)。

小姐姐對(duì)KISS Principle的總結(jié):

兩個(gè)字簡(jiǎn)單实愚,四個(gè)字盡量簡(jiǎn)單兼呵,六個(gè)字盡可能地簡(jiǎn)單。

請(qǐng)問(wèn)你學(xué)會(huì)KISS了嗎(挑眉)爆侣。什么萍程? 標(biāo)題黨?欺騙讀者感情兔仰?哈哈哈茫负,別激動(dòng),騙的就是你乎赴。小姐姐的標(biāo)題還是挺有吸引力的嘛忍法,就問(wèn)你服不服潮尝!畢竟小姐姐的KISS can apply to emotions, love and even your marriage!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市饿序,隨后出現(xiàn)的幾起案子勉失,更是在濱河造成了極大的恐慌,老刑警劉巖原探,帶你破解...
    沈念sama閱讀 216,496評(píng)論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件乱凿,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡咽弦,警方通過(guò)查閱死者的電腦和手機(jī)徒蟆,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,407評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)型型,“玉大人段审,你說(shuō)我怎么就攤上這事∧炙猓” “怎么了寺枉?”我有些...
    開(kāi)封第一講書(shū)人閱讀 162,632評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀(guān)的道長(zhǎng)绷落。 經(jīng)常有香客問(wèn)我姥闪,道長(zhǎng),這世上最難降的妖魔是什么嘱函? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,180評(píng)論 1 292
  • 正文 為了忘掉前任甘畅,我火速辦了婚禮,結(jié)果婚禮上往弓,老公的妹妹穿的比我還像新娘疏唾。我一直安慰自己,他們只是感情好函似,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,198評(píng)論 6 388
  • 文/花漫 我一把揭開(kāi)白布槐脏。 她就那樣靜靜地躺著,像睡著了一般撇寞。 火紅的嫁衣襯著肌膚如雪顿天。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,165評(píng)論 1 299
  • 那天蔑担,我揣著相機(jī)與錄音牌废,去河邊找鬼。 笑死啤握,一個(gè)胖子當(dāng)著我的面吹牛鸟缕,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 40,052評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼懂从,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼授段!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起番甩,我...
    開(kāi)封第一講書(shū)人閱讀 38,910評(píng)論 0 274
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤侵贵,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后缘薛,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體窍育,經(jīng)...
    沈念sama閱讀 45,324評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,542評(píng)論 2 332
  • 正文 我和宋清朗相戀三年掩宜,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蔫骂。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,711評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡牺汤,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出浩嫌,到底是詐尸還是另有隱情檐迟,我是刑警寧澤,帶...
    沈念sama閱讀 35,424評(píng)論 5 343
  • 正文 年R本政府宣布码耐,位于F島的核電站追迟,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏骚腥。R本人自食惡果不足惜敦间,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,017評(píng)論 3 326
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望束铭。 院中可真熱鬧廓块,春花似錦、人聲如沸契沫。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,668評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)懈万。三九已至拴清,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間会通,已是汗流浹背口予。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,823評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留涕侈,地道東北人沪停。 一個(gè)月前我還...
    沈念sama閱讀 47,722評(píng)論 2 368
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像驾凶,于是被迫代替她去往敵國(guó)和親牙甫。 傳聞我的和親對(duì)象是個(gè)殘疾皇子掷酗,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,611評(píng)論 2 353

推薦閱讀更多精彩內(nèi)容