Skip to content

Always create methods in classes #6

@ASmoliak

Description

@ASmoliak

In C++ you can take advantage of classes even you don't need to have members with the power of 'static' classes
You can write static functions, and they'll still abide by the public/private accessibility you set for them, and they can be called without even initializing the class:

class myClass { public: static bool DoSomething(); };

can be called like this:
myClass::DoSomething();

In serverImp.cpp there are many functions that are not declared in the header, but in the source file, this is not great because of two reasons:

  1. You have to call the functions in reverse, the functions have to be declared before the first call, this means the direction of where you are calling goes "up", which can be very confusing. If the functions you wrote can be private static functions of the server class, you can place the CALLER functions ABOVE the called ones, without having to declare a prototype inside the source file.
  2. The functions are in global scope, it is difficult to determine in a large project whether you're calling a function from another header, or calling a function from inside the class that you reside.

What I'm asking you to do here is to convert every function in serverImp.cpp into a private static function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions