Design and readability

I am working on a project written in C ++ that includes modifying existing code. The code uses object-oriented principles (design patterns), as well as complex things, such as smart pointers.
When trying to understand the code using gdb, I had to be very careful about the various polymorphic functions called by different subclasses.

Everyone knows that the goal of using design patterns and other complex things in your code is to make it more reusable, i.e. supported, but I personally find it much easier to understand and debug procedurally-oriented code since you definitely know the function will actually be called.

Any ideas or advice on dealing with such situations are welcome.

PS: I am relatively less experienced with OOP and large projects.

+3
source share
5 answers

gdbIt is not a tool for understanding code, it is a tool for low-level debugging. Especially when using C ++ as a higher level language in a larger project, it’s not easy to get the big picture of going through the code in the debugger.

If you think that smart pointers and design patterns are β€œcomplex,” I respectfully suggest that you study their use until they seem complex. They should be used to make things easier, not harder.

, , , .

- , . , , . , , , .

, , . - : " ?". , overriden , , , overriden, , .

+11

Doxygen. . Doxygen .

, , , Doxygen. SOB,

+4
+4

. IDE , ? . , , ? , , , ? (, ), , ).

Also, do you know which design patterns were used? Do they have names? Can you find them and find other simpler examples of them? Perhaps try writing a small application that also implements a design template, just to try it for yourself. It can also improve understanding.

+2
source

I usually do the following:

  • Draw a simplified class diagram

  • Write some pseudo code

  • Ask a developer who is likely to be familiar with the layout of the code.

0
source

Source: https://habr.com/ru/post/1723558/


All Articles