YAGNI, KISS, DRY, WET, SLAP, ASAP, YOLO - what does it all mean?
Ave, Coder! If you've ever read English programming literature, took courses in English, worked with English-speaking fellow coders, or just corresponded with them, you've probably come across these abbreviations and when one bearded coder said KISS to another, I guarantee that your eyebrow at least slightly raised.
In this article, we will analyze what these words, or rather abbreviations, are popular among English-speaking IT-shniks.
Visuals here: youtu.be/ub0YtnSwqRA
KISS ("Keep it simple, stupid")
This is not a pattern, not an anti-pattern, or even a rock band from the seventies, in this case, it is one of the most popular principles or approaches to programming anything.
In fact, this principle requires that your code be as simple as possible, because a pile of unnecessary functions that duplicate each other and the habit of scratching your left ear with your right hand are not a sign of a professional programmer.
The simpler the code, the easier it is to understand it, respectively, the less chance of burning a chair under a person who will rake this code after you.
Steve McConnell once said: "Write the code as if it would be supported by a violent psychopath who knows where you live."
Therefore, it is better to really not complicate things that do not require it.
DRY ("Don't repeat yourself")
The Don't Repeat Yourself principle is very similar in nature to KISS. This is quite simple and at the same time has a broad meaning. This is quite simple and at the same time has a broad meaning - got the joke?
Copying and pasting and duplicating fragments of your own code like scoliosis or visual impairment - over time, all programmers suffer from this. There is nothing wrong. Everyone sometimes needs to quickly check something (expected behavior or something else) to then determine if it's worth writing it right. But it is definitely unacceptable to send such code to production.
DRY reminds us that every repetitive behavior in code can and should be retrieved (for example, inside a function) for later reuse. Having two pieces of the same code in your codebase is not a good thing. This can often lead to desynchronization and other errors in your code, not to mention the increase in program size.
WET ("We enjoy typing")
WET solutions are widespread in multi-tier architectures where a developer can be tasked with, for example, adding a comment field to a form in a web application. The "comment" text string can be repeated in a label, HTML tag, read function name, private variable, database DDL, queries, etc. The DRY approach removes this redundancy by using frameworks that reduce or eliminate all but the most important editing tasks, while leaving the ability to add new variables in one place.
YAGNI ("You ain't gonna need it")
You don't need this - this is a principle that may contradict the views of some programmers, as well as those who have added decimeters to the school curriculum.
Being future-ready is generally good, but not in programming. Leaving any code intended only for future extensions is not a big deal.
But if you are a cyber-plushkin by nature, and from the very thought of leaving only the necessary, the chair under your rolls begins to melt, then let's figure it out - is this a bad approach to programming or is it a clinic in life?
Coder projects are not things that have a clear ending. Unless the author gives up on the idea (and doesn't pass it on to someone else), the project essentially continues. Therefore, there is and will always be room for improvement, be it the concept, the architecture, or even the code itself.
It's one thing - how the ideal code looks in your head - without errors and crutches, and another thing - what is really happening.
Naturally, a slight touch of sadness and apathy can comprehend the coder on a chilly autumn evening and the coder may decide to put in the program so-called "extension points" (places designed to easily take into account new functionality) if they are not used reasonably or are not a mandatory function then become just a monument to procrastination and add unnecessary complexity and size to the codebase. Come to think of it, it even goes against the previously discussed KISS principle.
SLAP ("Single level of abstraction principle")
The Single Layer of Abstraction Principle (SLAP) defines how we should organize our code (functions to be specific) in order to keep it maintainable.
Long and complex functions are hard to live with. They are difficult for other developers to understand and difficult to test. If at all on our fingers, then, as soon as we are faced with such an abomination, we must immediately transform it into several small functions!
As Robert Martin said, "Functions should only do one thing, and they should do it well."
But how exactly should we organize our functions? As you, my furry friend, gain more experience in programming, you will begin to understand more of the practical, aesthetic and functional aspects of programming and a principle called SLAP that is intended to help.
Roughly speaking, your functions should do only one thing, or in other SLAP words, should have only one level of abstraction.
Basically, a function that reads user input, for example, doesn't need to process it either. Instead, you will need to use a separate function that sits at a different, lower level of abstraction. The more general a function and the more other functions it uses, the higher it is in the hierarchy of abstractions.
FOOBAR (“F **** d up beyond all recognition”)
To paraphrase in Russian: “broken so that it cannot be restored”.
This is a wonderful expression that came to IT from military slang, along with other masterpieces such as, for example, SNAFU - "Situation Normal - all fucked up"; it is something like: "the situation is quite natural, but it was all in vain."
Legend has it that C programmers used the names "foo" and "bar" for variables as so-called "placeholders" or placeholders, especially in the tutorial examples. So, their bright little heads were freed from the burden of coming up with new names and could concentrate on solving problems.
Over time, this became a tradition and migrated from C to many not so ancient languages, so examples of such names can be found in textbooks everywhere, and the word "FooBar", applied to the project, means that you can start looking for something else ...
ASAP ("As soon as possible")
"As soon as possible."
Recently, it has become a trend "As soon as reasonably possible" - "as soon as possible, but within reasonable limits."
It also came into use from the army slang already during the First World War. It is actively used to this day, if this acronym is often used in correspondence with superiors, then this can eloquently indicate the level of organization in the company or management skills and the ability to prioritize among the bosses. But there are, of course, exceptions, when the situation got out of control and Foobar in general.
FYI ("For your information")
The official meaning is "I bring it to your attention", but loosely translated: "so that you know." It is found in e-mail correspondence everywhere, especially when the correspondence is not conducted personally with you, in the clear sun, but, nevertheless, they decided to inform you.
TL; DR ("Too long; didn't read")
An analogue of our "multi-letter, neosilil". This can often be seen under long posts, in which the author reveals his soul and tears off the veils, but the reader is too lazy to delve into this opus.
DIY ("Do it yourself")
Do it yourself. Comes from the names of small construction shops selling goods for repairing a house rather than building it. The implication was that the work is small things and you can do it yourself, without hiring qualified personnel.
Subsequently, the concept migrated to IT and can be suitable, for example, in situations where a specialist needs to do work from a related field, but it is so small and trivial that it is easier to do it yourself.
YOLO ("You only live once")
"You only live once." By analogy with the Latin “carpe diem” (“seize the moment”), this is a call for a full life, even for behavior that may carry some risk. It is the last argument on the border with unreasonable experience or unrestrained fun, but sometimes it can carry a more reasonable message: it's stupid to let fear rule your decisions, because you only live once.
And remember, YOLO, so KISS. It was V. See you on the channel! Ave!