Skip to content

Enhance handling of calls #72

@aalramadan

Description

@aalramadan

For stereotypes such as command, a list of calls to the methods in the class is needed. As of now, Stereocode assumes that any call to any method in the class is a mutator for the mutator stereotypes (e.g., set or command). However, that is not always the case. An example of such call:

foo();

Where foo is a call to a method in the class.

Moreover, calls on data members are also assumed to be mutators. Which is not always the case either. For example:

var.foo();

Where var is a data member.

On the other hand, Stereotypes such as predicate and property return a value computed from the use of data members in class and/or having at least one accessor method (e.g., get)

For example:

class foo{
    public:
    int bar() {
       return 4;
    }

    // predicate
    bool test() {
        return bar() + 5;
    }
};

For this case, Stereocode assigns the stereotype predicate to test(). However, bar() is not an accessor, so the stereotype assigned to test() is incorrect. The issue being in Stereocode assuming that all calls to methods in class are accessors for the accessor stereotypes.

Ideally, to solve all of the previous cases, we need a call graph that distinguishes between accessor and mutator calls. A proposed solution would be to perform a pass where the stereotypes for accessor methods (e.g., get) are computed. Then, a second pass is performed to find the other stereotypes while having this information.

This case with the var could be harder to determine as var could be a variable (i.e., not a data member) that is defined externally. Otherwise, we can track the method that var calls by identifying the class it belongs to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions