Perhaps someone will perceive this article as another whining on the topic of "how bad to live." But I will still write it in the hope that it will encourage someone to cultivate. And, suddenly, the current release of our reasonable (I would like to believe) civilization will become a bit more stable.
The reason for my discontent was another bad experience with a freelancer who calls himself a "mobile developer." The task was assigned to a person, he even completed it - the application somehow worked, although some bugs with the removal of objects brought sad thoughts about incorrect work with indexes of lists. And this is a bad omen. If a person does not know how to work with the removal from the lists, then this is most likely just the beginning of problems, and then we should expect the worst.
So, in principle, everything happened. When the TK was almost completed, fully paid for, and the source code was transferred, I realized that I just threw away money in vain.
Let me remind you that Android applications are written in Java - an object (with a few reservations) PL. Or even some object-functional (also with reservations) PLs like Kotlin and Scala.
Our hero, who called himself “the developer of Android,” did not even master procedural programming (a kind of “bronze age” of programming) and remained somewhere at the structural level (“stone age”). With his stone ax on a stick with a single save-and-paste function, he made all my future application.
Oh, this man is a copy-paste genius. For example, every time when it was necessary to take an object by id from the list, he wrote a cycle. And when he came across a list of lists, he wrote a nested loop. Therefore, my new application for 80% consisted of "ladders" cycles of varying degrees of nesting ...
All these cycles were painfully similar to each other, but the "developer" never guessed to create a private method, for example, getObjectById. Do I have to say that the insert and update methods with a length of 200 lines coincided by 90 percent?
I started refactoring this “suitcase without a handle” (it is inconvenient to carry, it is a pity to quit - the money has been consolidated). IDEA honestly highlighted to me duplicate pieces and offered to put them in the function. By simply pressing F2 (moving to the next warning), Alt-Enter (show options) and Enter (choosing the first default option). I managed to reduce the source code by 1.5 times. It remains a mystery that prevented the developer from doing so. Ignorance of IDEA warnings?
Then I started refactoring classes, which were also stupidly copied, without the slightest attempt to create superclasses with general functionality. We had to seriously work on the encapsulation and side effects - the static public properties of classes successfully replaced the lack of global variables in Java for a person. For example, the id of the object being edited was just the global variable of the main Activity ...
In general, the source code was bloated at least three to four. And I remind the main axiom of programming:
The less code, the less glitches.
Only the code that does not exist is not buggy. Missing code (while maintaining functionality) is the limit to which we must strive. From this axiom, the statement “more code - more glitches” follows in no wonder. Redundant code is the main problem of copy-paste - it roughly quadratically increases the number of bugs in the code. To combat this phenomenon, procedures were invented at the dawn of imperative programming. But our programmer was not looking for easy ways ...
But stop whining. This is not about him, but about methods of teaching programming in universities, when a fresh first-year student is put on some C ++ right away (frankly, not the best language for beginners) to learn OOP or cram sorting algorithms with “o-big-o en-logarithm-en. And it’s good if before that they were at least explained to them by "turtle graphics." In fact, people do not know the very basics of programming.
But let's go for garlic! Here you are sitting there so clever now and thinking, "Well, this is a kindergarten! I would never do that." Suppose everything is so, and you do not write so stupid code with copy-paste. But how much have you learned (and apply) the rest, more complex concepts and paradigms? After all, any modern PL is multi-paradigm. And all these paradigms should be applied at the same time: creating object methods, allocate meaningful or repetitive code in procedures, returning closures as a result of a generalized function, not forgetting encapsulation, starting a new utilitarian module in a project, recalling the solvable aspect, and so on. d.
Below in the article vote - check yourself if you know all of the above. There is no technology or library specific to the domain, only the general paradigm. I am convinced that anyone who calls himself a programmer is simply obliged to know and apply all the listed approaches in any programming language (from CSS to Erlang, from God forgive me to 1C to Rust).
So, what do you know (can you explain the essence and pluses-minuses in 2-3 sentences and give examples of how you used it lately)?
If there is something new for you there, or you are not sure that you can correctly explain it, I advise you to google it at your leisure and raise your level a little from “developer” (in the bad sense of the word) to a real tube “programmer”.
PS: the list of paradigms does not claim to be complete. Suggest your additions in the comments.
Source: https://habr.com/ru/post/349500/
All Articles