A very simple explanation of the principles of SOLID

Disclaimer: Everyone can, well, I am worse !?
SOLID is a set of principles for organizing code. In fact, they declare certain rules that will help you to save your own and others' nerves and time. And they may not help.
Let's try to understand these principles on your fingers, without examples of code and SMS.

S - Principle of Single Responsibility (Single Responsibility Principle or SRP)

There must be one and only one reason for changing the class ("A class should have only one reason to change." Robert C. Martin.)
Imagine that you have on your computer a heft of your favorite ...[/h]
+ 0 -

On the decomposition of the code, put in a word: context programming

Of course, ideally is generally better. Do not write unnecessary code . And if you write, then, as you know, you need to think
well. bones of the system
architecture of the system and implement
meat system
logic of the system. In this note, we give recipes for the convenient implementation of the latter.
here .
Let's say that we have users, with money, and lots that cost money and which users can buy. We want to write a code that will carry out the purchase of the lot:
buy-lot (user_id, lot_id) ->[:ok updated_user]| |[:error reason]

For simplicity, the amount ...

+ 0 -

The patented dream of programmers of the 80-90's

The patented dream of programmers of the 80-90'sThis spring, I finally managed to realize the old dream of the builders of designers: to build among the American patents of a quarter century ago a very simple solution to all their problems. In fact, it is emulation of the application database, in the construction of which all the rough, routine work of the programmer is rendered "beyond the brackets".
In the solution's solution, the data storage system and the way of processing them, the result is an alternative to existing ORMs. The stated advantages: Increase the reliability of the database by minimizing errors when adding new data and creating ...
+ 0 -

Integer arithmetic. Divide with rounding the result. Part 1

Integer arithmetic. Divide with rounding the result. Part 1The simpler, at first glance, the task, the less the developer thinks about how to implement it correctly, and makes an error at best, at best, discovers it late, at worst - does not notice at all. It's about one of these tasks, namely, on fractional division and on scaling in controllers that support only integer arithmetic.
Why do not the developers of application programs pay attention to the subtleties of calculations under such arithmetic, the question. I'll venture to just assume that, in all likelihood, the habit of calculating on a calculator is affecting In any case, with an enviable ...
+ 0 -

Do not write too much

Everyone thinks that the programmer writes most of his working time code. Except for the programmers themselves. They know that most of the time they read this code. Read, trying to understand how it works, why it is written here and what to do with it now.
The longest is to read not tricky algorithms, nor solutions with algebraic data types and monads, but huge pieces of simple code: 500-line methods, ?000-line scripts, 1500-line classes. All of them provide the industry with problems no less than the infamous ...
+ 0 -

Check the incoming data. The initial cause of vulnerability and attacks on Cisco IOS

Check the incoming data. The initial cause of vulnerability and attacks on Cisco IOS
On Friday, April ? 2018 started. a powerful attack on the Cisco equipment. .
Many people write that the main reason for this attack is successful is the Cisco Smart Install service ports that are open to external networks.
These ports are open by default. And people in the mass leave what is configured /selected /configured as it was by default. As we see, with the example of this case, this applies not only to home routers, but also to serious equipment in large companies, where the price of the error is much higher.
When creating a system, you do not have the right to expect that the ...
+ 0 -

Code Conventions: how we store the fast paced development of the PHP

Code Conventions: how we store the fast paced development of the PHPproject.Hello, Habr. My name is Eugene Udodov, I'm the co-founder and technical director of Roistat. I want to share our experience of developing a large and complex product - the analytics system.   TL; DR : We posted it on github our Code Conventions and told in the article how to apply it in practice.  When developing large products, there is a common problem - over time, a lot of legacy code is accumulating, tasks are becoming slower and slower. Also, with the growth of the team, developers start to write the code in different ways and the lack of uniform rules can lead to conflicts and ...
+ 0 -

Requiem for a Dream


- You, the main thing, do not leave! Hold on to me, do as I do, and everything will be chiki-pukey.
Sergei always infuriated such, collective-farm, style of communication, especially among unfamiliar people. It is not clear how to react. It seems to be called an idiot in person, but it's not enough, suddenly a person is not always like that, just does not know how to express emotions with words. Moreover, Sergei is the first day at this job. At his first real work.
- Kohl, let's be more serious. - Jeanne looked severely at the round, smug face. Then she looked at the newcomer...[/h]
+ 0 -

Anatomical metaphor for

Anatomical metaphor forcode.Thinking about the code, programming and all that; wandered all sorts of thoughts. And what if we take, for example, and make two developers write simple programs for one TK. Programmers of the same level. They write independently of each other. The code for them, of course, turns out different. However, if you extract from the code of each program lines that perform real work (converting the original data to the desired result) and dump them into two large "heaps", then these "heaps" seem to be very similar. Because based on the task, both programmers will probably apply similar calculations ...
+ 0 -