C
C
Cyril2020-07-21 18:19:24
Web development
Cyril, 2020-07-21 18:19:24

Is it true that complex code is written by non-professionals?

If a person writes complex code and does it not on purpose, but based on, say, a mindset, etc., does that mean that he is still far from a professional level?

As far as I know, almost all tasks can always be done simply, without complicated logic.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
maaGames, 2020-07-21
@maaGames

Complicated code is written by Olympiads.
But seriously, there is no need to complicate the code for the sake of complication. If you can write something simply and clearly - write. If this becomes a bottleneck and the code becomes difficult to understand when optimized, carefully document the reasons for the complication and what the code snippet does.

O
Oleg, 2020-07-21
@402d

I will answer like this. Simple code is written by beginners and super gurus. The rest are complex.
Often the code becomes more complicated because of the desire to boast "look what I know about the language"
Hypertrophied example.

bool function primer($a,$b){
 return $a<$b;
}
новичок напишет
bool function primer($a,$b){
  if($a<$b){
    return true;
  }else{
   return false;
  }
}

But in reality, it all depends on how, in a more complex case, the code will be easy to read.
maybe so ;)
if($used<$quota){
   return ALLOW_ACTION;
 }
 return DENY;

And here is IMHO the itch of a jun when switching to middles
return $used<$quota?ALLOW:DENY;
ps Sorry if anyone did not like the examples. They are hypertrophied

R
Roman Mirilaczvili, 2020-07-21
@2ord

If the concept of "complex" is invested with the meaning of the words "tangled", "piled up", then most likely such code will be written by those who have little experience. Usually due to ignorance of some shortcuts or a fuzzy idea of ​​​​how something works.
If we are talking about complexity as a sense of "sophistication", then this can happen when the programmer initially builds a model of the "whole universe" so that the code is suitable for all occasions. And it also happens that you are too lazy to simplify an overcomplicated system or there is not enough time, as a result of which the programmer decides that it is easier to add a slight complication. Then the software can reach a critical point where it becomes too expensive to change anything in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question