Tear it down immediately



    Andrey Aksenov shares difficulties in preparing slides for the report. This is a transcript of the Highload ++ performance .



    If you see this slide, I didn’t have much time for the pictures. Bunin came, made sure that his speaker did not disappear and asked a vile question. We are preparing the conference in advance, September 1, the reception of reports. I also wanted to prepare in advance. Yesterday at 6 pm I began to draw slides for another report, and for this at 11, so that's it.

    You’ll have to make a clean stand-up - and listen with your ear, but this is probably for the better, because you can safely go blunt on the phone.

    What does clean standup mean? No code at all, I specifically tried to minimize the number of lines of code in the presentation, although the pair leaked anyway. No revolutionary considerations on any topic. Well, pure bydlyatsky humor.

    Perhaps this is a federal crime and the FSB will notice me immediately after I leave the scene. Take a chance, at the same time get acquainted, let's go.

    What is the report about?


    On the one hand, it is about bad code and bad architecture. Because it was inspired by the idea of ​​making a report about bad code and bad architecture, at the moment when I read a post on the forum with the question: “how is your company doing a quality audit and code review?”

    Good question .

    We don’t know the code we have is good, the code is bad. This architecture is still incomprehensible, especially. At the moment when we do not check it. Does anyone check the code? Did anyone look at the code? Or purely write only? Or I went to hell, and almost everyone here writes in Perl, except for these two. They are old-school and write sendmail.cf, with hands. All others are exclusively write only languages, nobody reads in read only languages. Or is someone still reviewing?

    Quite a large percentage of coverage. The rest either do not review, or do not scorch. Perhaps I came to a very depressing forum where only a Russian person who, if happy, thumps and writes nothing. And if you are unhappy, then share your pain with everyone. Therefore, all the reviews are like that. Review did not see at all during a career, at best there is CI, there are tests. Why review code to watch? Nobody is looking at him in his own team, and it’s expensive and timeless. And if the company is large, then for someone from another team to look at the code of the other team, this is generally impossible.

    The most sunken tip, because it’s funny. This is the last, like everything is there, all the technical means, a lot of keywords. I haven’t heard many of them at all, and if I’ve heard of any, they cost as much as I can’t earn for my life, I guess.

    Everything is like, but there is no happiness. All the same, solid govnokod. One of the two, either there is no happiness anywhere, or the happy ones do not write on the forum. Are you happy? Like yes, you implemented code review, we have perfect code and perfect architecture. One happy person. The rest will either boast of nothing, or be ashamed if such a minor key is chosen. It can not be. I do not believe .

    I believe that somewhere in nature there are still megaprojects with good code, we can be not perfect, but good and perfect architecture.

    We must set the bar high. Does anyone know good projects with perfect code and impeccable architecture?

    Let's get top 3. We all know a certain top 3. Favorite Pokémon, a bad topic, I don’t know anyone. Pikachu Pokemon? Does anyone know? And nobody about Pokemon. Build an internal list.
    Nginx, yet? Any other hypotheses?

    You can work with this, but you need a certain correction: the fourth version of the sphinx. The third I started writing, it is not publicly available, but it really exists, I can get a laptop and show it is there.

    In general, I tried to come up with projects, but set myself the generally unattainable bar under the title " Let's get the perfect code and completely flawless architecture ."

    I managed to recall several projects, of course, not one of those that I worked on, it would be too good, when you look at them you feel “Wah! Boars wrote. " To be honest, I recalled one and more just in case, plus therefore again the lazy one and at the last second was preparing to not review this code today, and in order not to tarnish such childhood memories, twenty years ago, when I read the Doom sources, Quake'a and so on. The only approximation to the list called "somewhere in nature is probably a cool code, impeccable architecture, la-la three rubles." As an approximation, I’m probably bringing the source code of the old ID Software, such a personal professional accentuation or the sin of youth, as I call it, but as if I don’t even feel like it’s technically possible to add it to the mega list.

    True, there was a hypothesis about nginx.

    Are there Sysoev in the hall ? It doesn’t burn.

    Are there any nginx's in the hall ? Again do not scorch.

    Well, I’ll just ask you to comment on whether you agree that in nginx'e there is perfect code and perfect architecture? No more.

    The question, of course, is somewhat holistic about whether there is flawless code in nature, perfect architecture, and at least good codes, good architecture so that it does not make you sick.

    But again, it seems to me that on average we know these three projects.



    And of course IDTech, but that was 20 years ago. Remember all those times when the 286 computer, VR1 helmet and a resolution of 320x200 and Doom sources and you kind of read them and don’t know which hand to study whose code: with your left hand you study pocket, with another abrash and pray for these two gods. More such revelations from the code in life did not occur. Moreover, if you think about a complex question called "where did we see the perfect code and good architecture?" And remember about your own pet projects, to hell with them with the workers, it’s not your fault there, you’re probably there alone.

    Programmers, by the way, are interesting people, including myself, damn it. A normal person has a hobby: he works as a security guard, and he drinks vodka as a hobby, well, norms, in principle, this is my retirement plan. A programmer, he has a project at work, and he comes to a hobby at home and also saws something. And sometimes it happens so in gamedev'e that the dude writes the engine at work, but at work he writes shit, he knows it, the whole team knows it, and even the producer who finances all this from the publisher about something a little guesses, but there’s no way to turn back. But how it breaks completely and from the fact that he writes shit, he comes home and writes what? That's right - the engine for the game, but at best for another. I’m not joking, for some reason in gamedev'e such a trick called "something is missing for me at work, I write on technology A in the afternoon, and come home I write on technology B ”. She was decidedly not common.

    People who wrote the engine in the afternoon wrote the engine in the evening, some even wrote a little pee on the weekend. In WebDev, the situation is somewhat less depressing, but nevertheless, in my personal pet project, I think that not everyone will have the audacity to say that everything is fine. The overwhelming majority, maybe just a projection such a half-glass, an incorrect projection, it seems to me that looks exactly like this.

    How does this happen? It happens, so it’s clear where. The inevitable life path, which is due to the fact that a person is born completely without brains, then his brain volume gradually increases and completely without knowledge in these brains, and accordingly several stages of filling these brains must go through.

    In order for something to work out with a particular thing, be it a programming language, a new cool technology, or at least the ability to paint fences with a brush. Inevitably, you go through 3 standard stages: I don’t know how to “dig,” I learned to “dig,” and you feel an inner spiritual uplift from “yes, I’ve mastered the new megatechnology, now I can“ dig, ”I’m the best digger in the world, all the lights on me” . And at that moment when you learned all this, you can do everything with this shovel: draw a picture, build a cathedral, whatever.

    After studying the second technology, the third and even the tenth, it becomes clear that you can still not “dig.” This is an important point. I would like to draw attention to it. It happens so, thank God it’s not without exception that people are fixed in development at the stage, I know how to “dig”. Naturally I am able to write in C without crosses, so as not to offend anyone badly, that's all. I can write C, I can’t write C ++, I don’t want to look at other languages, I’ll write in C everywhere. Even if the party forces me, and C compilers die without exception, they will have to go to some hated company where everyone writes in java, I will write on it, as in C, to destroy objects with my hand. I'm used to it, I like it.

    At the end of all, death befalls. To my personal deep misfortune, death overtakes everyone too late, a little less than all can, with two exceptions, such as karmak and abrash. During that time, while death has not yet overtaken, people manage to write some code, and some even redesign architecture.

    The second important determining moment is that you are on the rise, you hoo, they gave you a shovel in your hands, now we will heal from that shovel now. At the moment when you have such a shovel, even when some new one has appeared, it is somehow not easy to think about how you should. The first step, entitled "damn it, would sit to think that it’s possible not to dig a hole here with a shovel, we were still asked to make a pole." If we dug a 100x100 pit, we’ll erect such a burial ground, respectively, 100x100, this is not entirely in accordance with the statement of work. Thoughts about this do not arise, they just gave us a shovel, God forbid, give such a person an excavator. Even less often, this is embodied in the life of thought, even if it suddenly flashes in a dull head. And of course, even if it suddenly flashed and reached the stage of “we will not try to realize it,” it never reaches the end. Excuses are completely standard - it is always long, always expensive, and why bother doing this at all, tyap-blunder will do. And as if this well-known book, there should have been a picture about "herak, herak and production".

    Well, motivational speaker, the second day, already afternoon zone, of course, I can’t talk about C ++ at the moment. I can only work as a motivational speaker.

    There is exactly one problem, well, okay convinced, we start to write cool. I’ll come straight tomorrow and start writing cool, or even tonight I’ll come home and start there. And tomorrow at work, oh-go-go as I continue. One small problem, a skill called “Let's write cool,” as it were, is not defined on the one hand and is not common on the other. There are no general rules, observing which you would be considered a worthy member of a programming society that writes good, clear or even perfect code. I don’t know what to compare with. If you wash at least once a week and change your socks once every two days, then you are already a normal member of society. They don’t shy away from you and they don’t stink very much from you. Follow simple rules and in terms of social everything will be fine. No, there are no such rules at all. There are no simple, computable metrics that would not just cut off some unimportant moments, but we would be sure that everything is fine with architecture. And there are no tools to understand this, there is no automated verification. And there is no holy bible either. I don’t know how one should look from the point of view of development applications.

    Imagine for a moment, there is a holy Bible. Personally, the god gave the ten commandments: do not kill, do not steal, and of course do not use singleton'ami. Does a person use singleton, Orthodox or Muslim? Isn’t it time for a bonfire? Immediately cross wars, bonfires and all is well. Within each specific group. On the left are Orthodox, on the right are Muslims, on top, Buddhists look melancholy and spit on the bones of cherries. Within each social group that externally successfully set cool commandments, such as the holy bible. In principle, everything is fine, sometimes of course a war with another social group. So then everything is fine. But unfortunately this is not. Or if there is, then it is very fragmented. Too many groups, and each group is small.

    Since no one has given us anything like this outside, we can come up with a cool idea for ourselves and try to build this one really cool. Build the very perfect code and perfect architecture.

    How to achieve this? What is good? I don’t know what is good, I really don’t know.

    What can i do? This is an attempt to determine this.



    Here's a funny quote from a project manager.



    There is another Zen definition. What’s good is when it’s not bad. That is, when it’s bad, it’s not good yet.

    They don’t fry me at the stake, on the one hand it’s not bad, but not necessarily good.

    At a time when we have a better definition than it means so good, but the rest is not, in fact, if you think a little and be, then most likely it can’t.

    Come on, for lack of a better one, don't do badly.

    For particularly corrosive readers who were preparing in advance for the conference, there are at least one. Who read the abstract, in which it was written about the perfect code, which is simple, elegant, self-documenting. Theoretically, in inanimate nature, it probably exists in Knut’s books and is written in the little-known language mix, literal programming. Everything was originally invented there in order to self-document. Failure is clear. Find Knut's mistake, he has been looking for them for about 40 years. One problem with him is that this code never exists, in principle, at all, with the exception of Knut’s book. It says exactly one production program is written.

    In any case, this is not a constructive definition, they say write simple, elegant, self-documented, etc. Advised, thanks captain.

    The ideal architecture is also difficult to determine constructively. That is, the thought stops approximately on the classical wtf / min metric. Further, this is one dream so that you don’t naturally put a microphone around qbicle for this wtf / min and do not attach your annual bonus to wtf / min.
    Here, interesting political games immediately begin, you can run, run to someone else's door and yell wtf many times and the enemy was cut off the annual bonus. It would be interesting from the point of view of team building, but not that.

    What is the perfect code? Does anyone know


    I don’t know, I tried to think, but as usual I didn’t succeed. But as a first approximation, it turned out that the ideal code is a code that is clear at least immediately, preferably all. Not all is possible, but immediately clear.

    A perfect architecture ? Here I wanted to write a lot of words, regarding the fact that it is very different. The account is immediately clear, I immediately had doubts. The architecture, which is immediately clear to the middle-person, who can hold about 7 things in his head, and the eighth is lost. As you know from the joke, three balls, the second was not immediately. At the same time, it is rather strange to demand that architecture be completely clear for a minimum large project, at least longer than 200 lines.

    Therefore, I came to the conclusion that a more or less good architecture is a key requirement, I personally have one. So that she does not interfere. Because poor architecture, I can articulate it right away. A step to the left there is a stake, a step to the right of the guillotine, a step to the northeast there, it would seem, are safe places, I actually tried with my foot, there is a swamp, inside the cave, and dragons live under it.

    Some kind of horror. Why is that? Why exactly such strange conclusions, called "immediately clear and does not interfere"?

    Because the average working day of a programmer without meetings is organized like this:



    With meetings, blue is replaced by meetings.

    Do not think that managers live better. The fact is that the manager’s working day is organized like this: everything is flooded with blue, the legend is meetings, but I want to write code. This is the manager who left the programmer left. It is clear that the task of any normally programmer in this difficult situation is faster, more efficient, cooler to pick the shit and throw 10-20-30 tons of the angle over the wall. Then at the end you die and Stakhanov Street is called in your honor. Not.

    The goal is to drink more coffee. Therefore, lunch is very long impossible. And coffee can be drunk endlessly. To do this, you need to increase personal efficiency and reduce picking of the govnokod, because you will still not be allowed to leave work to skip. To do this, you need to arrange this code in such a way, at least around you personally, not necessarily throughout the project. To make this valiant code pick it faster.

    What operations do we usually perform when picking govnokoda?

    You sit and think what to do. About 90-99% is not spent on writing a new cool code, from which the radiance will start to come, and the company will earn the first trillion. 90-99% of the time is spent sorting out this code. And there is a lot of it, to find a mistake or find a place where you need to make changes or something else to this repository and make the necessary changes. Unfortunately, a good old joke about a hammer strike is one ruble; knowledge is 99 rubles. Before the invention of programmers, it was quite relevant, with the invention of programmers in general. Hammers are very funny. I remember cool achievements under the title “I’ve been valiantly researching something for two weeks, catching bugs, experimenting, writing kilometer logs”, one line in minus output. After that, the miracle disappears.

    To speed up these fascinating archaeological penalties, I would like to do two things. Firstly, it’s stupidly faster to read locally. There is some kind of sheet, depending on who has what reading speed, monitor size and other attributes, different context. That piece of code that you are working with now, you want to be able to read it quickly and more or less understand it.

    But this, unfortunately, does not always affect the architecture of a globally shared application; we have 300 megabytes of code that are wrapped in microservices. Some of us are chasing under Windows, because it is there that there is a certain proprietary software, around it there is some kind of wrapper on .net'e, and it gives data via http, json, a million keywords. Emc is a small part of the stack, we also have cool production servers, on solaris. Why on it? Because admins really like to profile, and programmers cannot sell us to kill this solaris. The stack can be large, common stack, general project, etc. The local context is always quite small, otherwise it just does not fit in the head. I don’t want to keep the context in my head, I can’t remember either 20 megabytes of the project code, 2 gigabytes of the project code, or even 200 kilobytes of the current module code, I don’t want to remember

    This is influenced by a simple list of 4 pieces:
    1. Making this whole thing so that brackets and line breaks do not interfere with reading
    2. Sensible naming
    3. Compact code, where one line is needed, should not be written 30
    4. The presence or absence of comments is not always necessary, but in some places it is necessary so that you want to strangle someone who did not write them.

    To stupidly quickly understand how it is globally arranged and what is the place of this piece of code in a global large project of 20-300-5000 megabytes of source, suddenly architecture bites us in the ass. We have a completely different set of requirements.

    After all, architecture is not just lines of code. Architecture is classes, these are entities, possibly super-entities in the form of entire systems, clusters and the relationship between them. Therefore, in order to understand what is happening in this, we all need it to be properly designed, properly named, written out compactly enough so that this sheet can be read in a reasonable amount of time and at least commented out a little.

    The moment is again holivarny. Someone at this moment has emotions, wait, it can’t be, an ideal code, impeccable architecture. What does he carry? Design, naming, compactness and comments. This is a kindergarten. This is a primitive. It may not be too easy. A set of primitive requirements is erroneously extended to the code, at the micro level and to the architecture of everything, at the macro level.

    It sounds completely unfashionable, we are silent that the set of necessary words, extreme programming, the correct architecture. There are no fashionable architectural innovations, some basic things. It is completely unacceptable for 2016, there is no machine learning, deep machine learning, no neural networks. It is not clear why to buy a new NVIDIA machine for 130 thousand dollars, so that neural networks quickly learn. It may not be too simple. To hell with it with your code, the code is something so mundane, uninteresting.

    Let's talk about architecture. It cannot be so simple with architecture. Be sure to at least need design patterns, be sure to follow the SOLID principles, GRASP principles, without TDD, CI not CI. Agile in its purest form is quite complicated inside, therefore they introduce one or another set of agile practices, here is a piece of Kanban, here is a piece of another process, etc.

    We are silent about all sorts of esoteric principles, about which some have heard, and some even try to apply. You should never name a class that is er or or. This principle sometimes works. I even partially agree with this, it’s not good to call helper class, a garbage can form there, there is an addition to the principle on the one hand, and a formal cheat code on the other. You call the helper class, you are instantly caught on this, found through a search and now renamed urgently. At this point, the misc class or utility class appears.

    By way of unification, I would suggest calling these classes TMM (here is my grave), but probably it won’t work. Obviously, a lot of complex principles were invented by mankind. Without teams of architects, nowhere.

    Who remembers what SOLID is? Seem to be. You do not need the next slide, which says what it means. You remember it by heart, well done! I only remember the letter L, the rest was copied from Wikipedia. We will be honest, I remember the letter L, not because I constantly consciously follow the letter L. The principle itself is correct, that the heir to the class should not be surprised when you stick it in the place where the base class was expected, but we will be honest. The principle was remembered for another reason, because Liskov is a famous man by the name of Barbara, not yet a man. But for how long the American is Liskov, not Liskov. This is the only reason why I remember the name of this principle.

    In addition to the mass of principles under the general umbrella of SOLID, in addition to the mass of principles under the general umbrella of GRASP, in addition to the mass of principles about patterns, visitor's, singleton, and the factory. In C ++, there’s a cool bugbear, simply because it is not particularly joyfully cut out in C ++ under the name: dual dispatch or dynamic dispatch. It's just about organizing code, and it's just about object-oriented design.

    The code is not limited to object-oriented code, there are still a lot of wonderful great words. About functionality, about the actor model, about the programming model, when everything is asynchronous and completely incomprehensible which of the 17 docked callbacks is called at what moment, but somehow everything works. Until the last programmer on NodeJS and switches to Go.

    In addition, this should not only be at the code level. Architecture is not only the level of code, it is also the level of construction of the system itself. Also a lot of all sorts of principles. On the one hand, a lot of keywords, without them everything seems unfashionable, non-expandable, unsupported.

    How do we write a graphic editor without a factory of graphic objects? I don’t know, without a double factory nowhere. At the moment when it comes to writing code, the head is already a little swollen. But we are programmers, we love to automate everything. We should have tools, they probably are. Depending on what language is in the yard, there are either more or less.

    What do we want from these tools? Within the framework of simple requirements, under the name we want a normal design, normal names, compact, commented out, etc. and so that the machine monitors this itself.

    What is on this subject?


    There is almost nothing. In the C ++ world, I am an old believer and I don’t know how to write in all other languages. I know a little about C ++. In the C ++ world, by 2016, formatting had recently won, thanks to Apple for some reason. By first writing lvm, then the hose, then clang-format.

    With all the other items, some kind of priest.

    Naming is a keen eye and personal sense of taste.

    Compact code- There are no automated verification tools either; you can come up with some automated metrics. Conditionally, there is such and such cyclomatic complexity, here there are so many lines of code for such and such a user story. Some other incomprehensible things. But an automatic tool that just like the neighbor programmer Vasya would look into the code and say: why did you deer write these two pages? You see helper, there are 3000 lines in total. Why did we do this helper, there is everything right there, for you they did it.

    The trouble with compactness, the trouble with naming, automatic testing has not yet been learned, although the success of neural networks on the basis of text analysis is inspiring. There is a risk that after 5 years we will drive the name of the identifiers through the neural network, and it will either wink with a green eye or a red eye and you can say or not.

    With comments, I do not hope so. I do not hope for the adequacy of the comments in the codebase. Maybe someday artificial intelligence will grow, look at us and destroy everyone. But I won’t live to see it.

    Purely theoretically, some tools to build in order to analyze at least the general correspondence of the naming of classes, methods, functions, variables, etc. on the one hand, just at least the rule of the English language, this can be done.

    To make it compact, at least you can catch certain anti-patterns in the code too.

    With comments only a keen eye.

    How is it usually?


    The design happens for everyone, because gradually everyone has grown to the point that you need to write normally, otherwise it is impossible to read at all. Everything else is all the same.

    What is architecture? Perfect or just good.

    I think two schools of thought.



    School of thought number 1. Architecture is a gigantic ivory castle hovering in a cloud, which without cool keywords, without all the principles, moreover, for the special. People who, not just monitoring compliance, but sitting on a cloud and lowering valuable instructions from the ivory tower, down to slaves, black monkeys, are completely impossible.

    Perhaps this model works well in Mumbai, Delhi, etc. But in the case when more intelligent developers want exactly the opposite and it does not work.

    Option 2 . My current worldview is much simpler. And let's make simple, code style, design, naming, comments, etc. After that, one of two things. Or in the course of planting a simple one you will learn well, and the architecture will improve from this, and the rest will follow. Or this will not happen. Even if this does not happen, at least you have a bad architecture, but inside this architecture there is a beautiful, well-read, clearly designed code.

    As I immediately promised, no revolutions and breakthroughs in scientific and philosophical thought happened.



    Therefore, a grandfather with a beard looks at us condemningly.



    There will be no happiness. Ideal codes and perfect architecture will not be let down from above. Even if they hire a special architect, nothing will happen. Life is pain, code is always shit. The only thing we can do with these is to impose a practice on among each specific programmer, under a simple name: I see shit, wash off. Details on the slide.

    You need to see a jamb in the code, not ignore it, but immediately get distracted and fix it, or at least create a ticket about what you should someday fix. Sometimes, this is still an interesting hotel pain, here I am sure everyone will share stories that evil bosses never give time to refactor, to pay off technical debt, to learn new technologies, etc. To have like this, from under the floor. It will not give. Since such matters, then the super-architect, who will come and put things in order and ensure accession to the European Union, will also not give money, and even less time. We have to somehow ourselves, which is important, we must do this constantly. This is my eternal pain, called seizures, then I can tell beautifully, but in such a way that every day and every first line is not methodically. It is not easy, it is difficult. It could seem, that the so-called “just” we have at least 50% everything, or even 90% according to internal estimates. Not really.

    Bring a wad of money, bring examples of your code, sit, laugh, sort it out.

    In a typical case, the maximum that I believe in is the presence of a code style, and even then with certain reservations. Not the fact that there is a formal document, not the fact that this document is relevant, moreover not the fact that automatic checks or automatic forcing, automatic reformatting are implemented.

    Comments are the eternal pain of any programmer. Worse than comments - this is only documentation.

    One problem . If this documentation is our method of shitting on the user’s head, that is, when we write poor documentation this is it, we can express our deserved hatred in this way. When we write bad comments, we put our heads on it. Unpleasant, especially when to myself, doubly unpleasant.

    Here the position is simple . If they are better, don’t write them at all. Let there be nothing at all than this trivial rubbish, which in addition breaches.

    I’ll share my personal grief, you can automatically check the number of comments, but you can’t check the quality, you need a live person who will read, and this is a long time.

    Compactness. I will give the first example that came into my mind.
    It looks like this:



    Normal code, everyone writes such and I wrote such. There is nothing shameful about this. Moreover, this most fascinating code that does something there, some cycles, surfaces, is not clear. It can be precisely in this form to be historically determined. It should be like that if there were 20 checks inside and then they decreased to one. One problem. I want to see one line in the place of this hell:



    I specially wrote it with incorrect syntax that cannot be compiled.

    I repeat in C ++, you can get closer to the ideal, because 11th C ++ gives some lambdas and you can pass a lambda function there, define the agrument, it will be a little more authentic, half a line.

    But even on wretched C ++ 0.3, without any lambdas, you can write in two lines, as at the bottom of the slide. Even in old C ++ you can write much more compactly than it was.

    I get these 3 lines, but ideally 1 is much faster at times. If you do this with each line, then the reading of the code as a whole will improve significantly.

    It’s useful to do it simply on any floor, even if it doesn’t grow miraculously either through personal efforts or by a specially trained and hired architect, some mega architecture at the top and all the same will constantly beat with a bat on the head from the back, then at least every minute processes of working with a dumb code on the first floor that lies beneath all this architecture.

    After the implementation of certain simply hygienic practices about design, naming, etc. etc. the code will greatly ease. The super goals that I need before myself, it seems and which I personally have not achieved, are to learn to write so that no one, and this is an important point, in general, no one in your team wanted to throw it out. So that the code that you write and commit always, always emphasize, is such that it is easier to work with it than to say "what kind of ghoul wrote it?" Throw it to hell and rewrite the whole. " And this was naturally justified, because it’s really faster to rewrite it.

    The second super-goal at the moment when you learned to write this way, do it not on holidays, on the patronal day of November 7th, but always, even when you write, as it seems to you, a draft. We all know that a draft is usually 20 years in the repository and settles.

    To do this, bad news, a special architect who is hired at a higher level or a special consultant who is hired at a side level, in principle, is not able to come and do well and leave, and then come back in a year. Unfortunately, in order for the code to come close to certain standards, such personal or non-personal qualities, to some ideal, and so on, painstaking work every minute. A - to be able to write in principle more or less suitable, B - to constantly apply. Minute hard work. Any external cowboy jump into the code may reveal obvious gigantic obvious problems, but it will not help you either with complex logical bugs on the one hand, or with a muddy shit shaft, because it is impossible to rewrite twenty million lines in one helmet.

    The obvious point. In the best case, if everything is bad at the low level, and the architecture at the top is divine, then in the course of preparation I had a mental image that I definitely could not get rid of.

    At the lower level, everything is bad and the implementation is bad. On the foundation of shit we build a house of shit, but from far away and in poor lighting this house ideally repeats the divine achievement of architecture with the sagrada surname in Barcelona, ​​with which it has already been completed, but not in Barcelona yet. At worst, even this will not happen, at worst we will build a sagrada surname, and it will turn out some kind of puddle, it’s not clear from what and we come to the standard architecture review, it’s completely not clear why we did it like this.

    Minute simple practices are unfortunately more important, and they most likely will not save you, or rather they are not obliged to save you.

    I’m already at minus the fifth minute, I don’t have time to cheat on specific projects, in which I planned for five minutes that there is a project, a bunch of cool guys from interesting companies are working on it, everything is there, everything is done there, written clearly, code, style, design, comments such that God forbid everyone. I'd rather strangle myself than go to work there. Any editing is just some kind of hell. Precisely because at the lower level it is formally not bad, but at the architecture level it is quite large, branchy and complex, and high-level documentation about architecture, specifically an incredible number of classes, is arranged to work with each other, which particular piece does what it does not exist at all.

    This moment, at least for new fighters, would save either a separate document, which is bad, or a large sheet with comments, with short comments at the beginning of the file, that they say it’s arranged like this: “this class is responsible for this, and the other for this , such changes are made there, and some are made there. ”

    “Have you tried it yourself?” An important question must arise, although there is no time to tell, but yes, I tried. I can say something like the following, what it feels like to write like this, it’s absolutely at five with a plus, let's call it, it doesn’t take much more time. Maybe 10%, maybe 20% more than usual, there are about three artifacts from there in time.

    The first artifact - you naturally like it yourself.

    Second artifact- Some teammates recognize by force that it turned out cool. Not all, it is inevitable.

    The third artifact - there are simply fewer defects, a certain amount of bugs are caught at the stage of accurate writing, careful commenting in the first place. Well, I literally wrote a specific subsystem, a piece of code for a couple of thousand lines and sat down to write a comment on it, how it all works. I sat down to write a comment - I went into development for another four days, because during the writing of the comment, as arranged, I came up with five test cases and they all worked. Output quality is improved.

    This is a bit unnatural behavior, you will have to make some efforts on yourself, try, perhaps, to break the writing style, introduce forced design, never cut corners in any way, implement forced commenting.

    Moreover, it is physically painful to say such a thing, but I don’t specifically cite specific rules, I specially refrain from doing so, because they should always be tailored to a specific team, to certain rules for formatting, commenting, and so on. For some kind of kalk, I would personally like to strangle the remainder in the code, but in principle, if it works for your team, if 20 people think of kalk the rest in the subject, then 20 people will strangle me.

    One megametric that can be introduced, idealized and not true, but nevertheless at least somewhat tied to reality, for the sake of which all exercises on oneself about code on the one hand and about making better architecture, on the other hand, are worth doing, because it’s lightness changes. A code that does not change constantly is dead. The code you work with is constantly changing, and this is actually the work of the programmer and the programmers department. Everything is done for the sake of ease of change. Perhaps there are PMs in the hall.

    Slide for PM's. Is it really all about programming? No PMs are also needed, because, despite the fascinating motivational reports, programmers rarely self-organize and implement everything like that themselves. It is much more efficient to instill fire, a sword, in the sense of depressions and dismissals. All the same is nothing interesting, we introduce code-style, we introduce forced review, knowledge transfer processes, who are interested in the details, let's discuss it on the sidelines.

    What to do with architecture?


    It is even more difficult to give unified advice simply because all the projects are different and somewhere quite simple enough, somewhere it is not enough at all.

    So what to do ?

    If you see this in the code:



    Or this:



    It is simply ingenious, I cried in a voice, I was envious, it’s a genius.

    Why did someone come up with this? Why not me? I will never write like that, it is brilliant.

    You see this in the code, or this (I wrote this):



    Take it immediately, now, don’t delay. Make it better, the rule is simple, do it now. After that, it will become easier for you to live right tomorrow.

    The report was entitled “Take It Off Immediately.” My name is Andrew. They’ll kick me out now.



    Andrey Aksenov - Take it down immediately.

    Also popular now: