How to edit gigantic codes? [closed]

1

It's a question I've had since I started reading codes. I see some classes with thousand, two thousand, thousands of lines.

How can a programmer edit so much without "getting lost" in the middle of so much?

Even commenting on the code, using logical names for variables, procedures / functions etc, it is still very difficult to change even the name of a variable in scope, thus having to change all the inputs and outputs in the code. At the moment I am developing a code for hotel reservation (a college work, in a group). The code is with about a thousand lines and no one can manage so much more, even with comments, switchs , if nested etc.

In general, I want to know if there are any rules or badass used by professional programmers to be able to edit huge codes without getting lost in the middle of them. I hope I was not too vague. I looked for answers in forums but without success.

    
asked by anonymous 19.11.2017 / 02:51

2 answers

3
  

I see some classes with thousand, two thousand, thousands of lines

A thousand lines is too much? I do not think so.

  

How can a programmer edit so much without "getting lost" in the middle of so much?

Doing what computers do very well and what humans should know how to do all the time. Dividing to conquer .

Handle with one part at a time. Build each part so that it depends minimally on other parts. Plan before. Create a summary of it all. Understand what you are doing. Do not put anything you do not need there.

Making big, messy, inefficient is easy, making it organized, small and efficient is difficult, but this pays for itself. This is how people manage large code bases, doing right and decupado according to the responsibility of each thing, putting in the function and structure of data only what it does, without relying on anything external without necessity and giving good names do everything is simple.

When you separate and deal with one part at a time there is nothing gigantic about it.

A good IDE can help. It's just a help tool, you have to know how to use it correctly.

  

Even commenting on the code, using logical names for variables, procedures / functions etc, it is still very difficult to change even the name of a variable in scope, thus having to change all the inputs and outputs in the code. p>

It seems to me to be incongruous things. Are you giving good names because need to comment on the code? I think I know the answer, it's not giving good names.

Actually comment usually does more harm than good .

If you change the name of a variable in the scope it is difficult this scope must be very wrong.

I think people do very long functions, obviously with many variables, and put the variable declaration away from its use and in a rather unreasonable way. The error starts there.

The description shows symptoms of other problems.

  

At the moment I am developing a code for hotel reservation (a college work, in a group). The code is with about a thousand lines and no one else can manage so much, even with comments, switchs, if nested etc.

Aside from being too complicated it may be that they actually do not yet understand what they are doing. It is obvious that if you learn things with a lot of the gap you can not use what you have learned properly. And most people learn this way. They do something, but they do not understand what they are doing, then when they move from the minimal complexity of an isolated exercise to the real complexity of a real problem they can no longer manage that.

And there is a lot of case that is not knowing programming, is not knowing math (not decorate formulas), communication and expression, scientific method, philosophy (yes, it is important for correct logic), and other basic things that build ability to deal with problems.

I will rule out the person's cognitive problems, but there is a lot of it.

  

In general, I want to know if there are any rules or badass used by professional programmers to be able to edit huge codes without getting lost in the middle of them.

Magic rule has no. It is to evolve gradually, not to want to burn steps, to dedicate oneself, to look for every individual aspect that is having difficulty, to ask for help with specific things, to train, to ask for feedback from experienced, recognized (real) people and confront the feddback of other people who think differently. Of course, organize and simplify (but first you have to learn to do this).

  

Let's say that in this group work a person alone wrote 1000 lines of code. I said it was unnecessary

If it is unnecessary, make it smaller. If the team does not accept make yours and present, after all a few hundred lines can do in a few hours, if it is already defined and only need to code maybe take minutes.

I could even say other things about this, but it would be very out of scope.

    
24.11.2017 / 15:29
1

If you have a well-documented system, no matter what the size of the code it is easy to identify what each method does within a class, something else, a documentation with well-defined requirements there is no need to change variable name at most add or decrease.

    
19.11.2017 / 03:20