How many great frameworks have been created by this programming principle of the US military 60 years ago - the KISS principle

Excerpted from: https://kb.cnblogs.com/page/654057/

Author: He Zhuofan Source: ImportSource Published: 2020-01-23 19:52 Read: 2324 Times Recommended: 20Original    links   [collect]  

  About 60 years ago, software development in the US military began to follow a principle called the KISS principle. They want every command used in the weapon system to be extremely simple and foolproof. This principle was later widely adopted in the programming field, and many well-known open source frameworks are now developed following this principle, and eventually achieved great success.

  In the previous article " 30 Design Principles Followed by Apache Architects ", the first principle is the KISS principle. I briefly understood this principle a few years ago, and I turned it out a few days ago. After careful inspection, I feel more Shocked, this original text can be said to break the secret of programming. Translation of the following original text:

  What does KISS stand for?

  KISS is the abbreviation of Keep It Stupid Simple or Keep It Simple, Stupid.

  Meaning of KISS

  This principle has been pivotal and hugely successful in my many years of software engineering. Today's software engineers and developers have a common problem, that is, they are always slowly complicating problems. The correct approach should be when developers encounter a problem, split the problem into small pieces that can be understood one by one, and then enter the coding stage. But I would say that 8 or 9 out of 10 developers don't break the problem down into small enough or understandably small enough pieces. This leads to a very simple problem that turns into a very complex implementation. Another side effect is spaghetti code, which is just a goto statement in BASIC, but requires 500 to 1000 lines of code in Java. Each method has several hundred lines of code.

  You need to think about the problem-solving steps, which are divided into several steps, and then enter the coding. Instead of getting the requirements, start writing code to meet the requirements. The advantage of this is that your code will be easy enough to understand and clear enough.

  What benefits can we get from KISS?

  1. You can solve more problems better.

  2. You will be able to solve complex problems with just a few lines of code.

  3. You will be able to produce high quality code.

  4. You will be able to build larger and more maintainable systems.

  5. When new requirements come, your code will be more flexible, easy to extend, easy to modify and refactor.

  6. You will accomplish more than you can imagine.

  7. You will be able to work in a large development team and large projects because all the code is stupid simple.

  How can I apply the KISS principle to my work?

  There are a few simple steps to follow here, but there are challenges. It's as simple as it says, keep it simple, mainly requires patience, and more on yourself.

  • Be humble and don't think you're a genius, this is your first misconception. Only by being humble can you truly reach the level of super genius, even if not, who cares! Your code is so stupid simple, so you don't need to be a genius!

  • Break your tasks down into 4-12 hour subtasks.

  • Break your question into multiple sub-questions. Each problem is solved with one or a few classes.

  • Keep your methods small enough and never exceed 30-40 lines of code per method. Each method should only deal with a small problem, not too many uses cases into it. If your method has multiple branches, try to split them into multiple smaller methods. This is not only easier to read and maintain, but also faster to find bugs. Slowly you will learn to love.

  • Make your class smaller, the principle is the same as the above method.

  • Fix the problem first, then start coding. Don't code and solve problems at the same time. There's nothing wrong with that, but it's probably better if you have the ability to break things up into smaller chunks ahead of time and start coding. But please don't be afraid to refactor your code over and over again. In addition, the number of lines is not a measure of quality, but a basic ruler.

  • Don't be afraid to kill the code. Refactoring and redoing are two very important aspects. If you follow the advice above, the amount of code to rewrite will be minimized, if you don't, the code will most likely be rewritten.

  • Any other scene, please try to be as simple as possible, simple, this is also the hardest step, but once you have it, when you look back, you will say that the previous thing was a piece of shit.

  Are there some examples of the KISS principle?

  Too many, I will post some good cases here in the future. But now I want to give you some of my views and thoughts first:

  Many of the world's great algorithms almost always have very few lines of code. When we look at these, we will find it easy to understand. These algorithm inventors, they break the problem down to the point where it's easy to understand, and then go to implement it.

Many great problem solvers were not great coders, but yet they produced great code!

  Many great problem solvers were not great programmers, but they produced great code!

  KISS can only be used for java code?

  Obviously not, it can be used in many programming languages, and even in other areas of your life. Certainly not for your affection, love, and more importantly, not for your marriage.

  Related Reading:

  30 design principles followed by Apache's architects

  How to write a clear bug

Related Posts