Add reminder/tooltip/comment to show logical connection between 2 or more chunks of code

60 views Asked by At

I have 2 functions (sometimes, in different classes or even different files).
A part of them have to work consistent with each other (#A and #B).

void generateBox(BoxStruct& boxStruct){
    Vector3 coor=boxStruct.getWorldCoor(); //#A
    //... some complex thing ...
}

void generateWorld(WorldStruct& worldStruct){
    Vector3 coor=worldStruct.calWorldCoor(); //#B
    //... some complex thing ...
}

The code is OK, but I am afraid of its maintainability.
If I edited #A, I am supposed to edit #B too.

If Visual Studio is a graphical tool, I would like to draw a red line between two parts of code.

Question:-

How to add reminder/tooltip/comment which can describe the connection between code that is clean and noticeable?

I have faced this light-weight problem for every programming language I have ever coded.

For Visual Studio, I don't mind plugin, but I don't think it is necessary.

My poor solution:-

It is quite dirty.

void generateBox(BoxStruct& boxStruct){
    Vector3 coor=boxStruct.getWorldCoor(); //It is not local coordinate. #A
    //^ Must be consistent with #B in "generateWorld"
    //... some complex thing ...
}

void generateWorld(WorldStruct& worldStruct){
    Vector3 coor=worldStruct.calWorldCoor(); //It is not local coordinate.  #B
    //^ Must be consistent with #A in "generateBox"
    //... some complex thing ...
}
0

There are 0 answers