MortezaBashsiz / nipovpn

Powerfull http proxy
GNU General Public License v3.0
183 stars 11 forks source link

Suggestions for Code Improvement #94

Open thesudoer2 opened 2 months ago

thesudoer2 commented 2 months ago

Hello there, I have some recommendation that can enhance maintainability, and performance and generally improve overall project quality.

Maintainability

  1. In general, comments make maintainability more difficult, because if you want to change a part of the code, you have to change its comment too, thus violating the duplication principle (DRY principle). Therefore, it is good to use comments only where needed and avoid commenting where the function of the code is obvious.
  2. Making the logging approach more controllable! In the current codebase, there is a general syntax for logging messages, but no function to generate them (messages are generated directly within the code). If you decide to change the logging message syntax, you would need to update all logging-related code manually, or developers would have to write the message syntax every time.
  3. Adding at least one level of abstraction for the Boost library to make the code more maintainable.

Performance

  1. Using std::make_shared instead of new for keep shared pointer control block and object block in contiguous memory blocks (better performance).

General

  1. Using #ifndef/#define and #pragma once as include guards is redundant. #ifndef/#define can be removed, and only #pragma once can be used because almost all modern C++ compilers support it.
MortezaBashsiz commented 2 months ago

@thesudoer2 Thanks a lot for this evaluable suggestions All your PRs regarding these improvements are appreciated.

thesudoer2 commented 2 months ago

@MortezaBashsiz My pleasure :) I will work on "Maintainability - 1" and "General - 1" sub-issues until further notice.