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

Discussion: namespace vs prefix #728

Closed
jslee02 opened this issue May 17, 2016 · 2 comments
Closed

Discussion: namespace vs prefix #728

jslee02 opened this issue May 17, 2016 · 2 comments
Labels
help wanted Indicates wanting help on an issue or pull request

Comments

@jslee02
Copy link
Member

jslee02 commented May 17, 2016

Since #652, DART has been composed as the core library dart and several component libraries like dart-optimizer-nlopt, and the component libraries get compiled only when the required dependencies are installed. We then introduced dart::gui::osg namespace for OpenSceneGraph dependent library rather than using prefix like dart::gui::OsgViewer. However, we still use prefixes for other component classes like NloptSolver and IpoptSolver. I think we should follow one rule for consistency, but not sure which one is preferred way.

After Googling, I learned that using namespaces is the C++ way while using prefixes is the C way, and I'm inclined to using namespaces because of this reason.

Downsides of using namespace I can imagine would be (1) that it would require more typing for :: (e.g., NloptSolver vs nlopt::Solver) and (2) that it could cause namespace conflict with the dependency namespace (e.g., dart::collision::fcl of DART and fcl of FCL). (2) can be resolved by using the global namespace specifier like ::fcl for FCL namespace, though.

Here are some examples of current, namespace, and prefix cases.

current

dart::collision::FCLCollisionDetector
dart::collision::BulletCollisionDetector
dart::collision::DARTCollisionDetector

dart::optimizer::NloptSolver
dart::optimizer::IpoptSolver

dart::gui::GlutWindow
dart::gui::osg::[~]

prefix

dart::collision::FCLCollisionDetector
dart::collision::BulletCollisionDetector
dart::collision::DARTCollisionDetector

dart::optimizer::NloptSolver
dart::optimizer::IpoptSolver

dart::gui::GlutWindow
dart::gui::GlfwWindow
dart::gui::Osg[~]

namespace

dart::collision::fcl::CollisionDetector
dart::collision::bullet::CollisionDetector
dart::collision::dart::CollisionDetector // or something like dart::collision::builtin::CollisionDetector since dart::collision::dart would be ambiguous

dart::optimizer::nlopt::Solver
dart::optimizer::ipopt::Solver

dart::gui::glut::Window
dart::gui::glfw::Window
dart::gui::osg::[~]
@stale stale bot added the stale label Feb 13, 2018
@jslee02 jslee02 added status: on hold help wanted Indicates wanting help on an issue or pull request labels Feb 13, 2018
@stale stale bot removed stale labels Feb 13, 2018
@mxgrey
Copy link
Member

mxgrey commented Apr 6, 2018

I think we can close this, since we've settled pretty strongly on using namespaces instead of prefixes.

@mxgrey mxgrey closed this as completed Apr 6, 2018
@dartsim dartsim deleted a comment from stale bot Apr 6, 2018
@jslee02
Copy link
Member Author

jslee02 commented Apr 6, 2018

I agree on using namespace over prefixes, but we still use prefixes for optimizers and collision detectors. If we close this, then let's create an issue to track it.

@jslee02 jslee02 mentioned this issue Apr 6, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates wanting help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants