Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addObjectType.... does not return new Node ID when "mandatory" is set to true (default) #17

Open
manfredholl opened this issue Nov 4, 2021 · 1 comment

Comments

@manfredholl
Copy link

I'm currently evaluating your solution for a personal project, thanks for all your hard work.
I noticed that the methods ServerObjectType::
addObjectTypeVariable
addObjectTypeArrayVariable
addObjectTypeFolder
addHistoricalObjectTypeVariable

will not return the new node ID, when the "mandatory" parameter is true.

The code pattern is identical in all methods:

        if (_server.addVariableNode(...) {
            if (mandatory) {
                return _server.addReference(....);
            }
            if (!nodeId.isNull())
                nodeId = newNode;
            return true;
        }

So if mandatory is set it will return without doing the assignment "nodeId = newNode;".
Generally suggest using "return early" pattern only for unsuccessful return, i.e. there is only one successful return point at the end of the function, all other early returns are "false".

@bazza2jw
Copy link
Owner

I think it is correct. If an entry is not mandatory then an empty, but non-null node is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants