-
Notifications
You must be signed in to change notification settings - Fork 2
Home
- Set up a new enhancement issue stating:
- the problem the new functionality is supposed to solve
- the new functionality, how it solves the problem
- suggestion for a way to implement it
- suggestion for how to test/evaluate it
- The enhancement issue is reviewed and approved in the enhancement issue.
- After approval the new functionality is implemented and tested in a separate branch. Commits shall link to the enhancement issue.
- When the functionality is properly implemented a pull-request to the devel branch is made.
- Eventually the new functionality ends up on master.
The interface of GeometricPrimitiveMap is designed to always require the type of the geometric primitive to operate on when calling for instance getGeometricPrimitive. Another solution could be to store a type identifier in each subclass of GeometricPrimitive, which can be used once a GeometricPrimitive pointer has been gotten from the map to downcast it to the actual subclass. This latter design choice contains code smells, and the usage of such coding styles will lead to code defects. To quote:
"Dynamic casts are generally a code smell.
Assuming you are using dependency inversion correctly, any dynamic casts in your code should be to a base class. And thanks to the implementation details behind dynamic casts, casting to the base is nearly free.
My guess is you are forgetting your SOLID development principles, particularly the L and D. You should have interfaces for everything, and everything that satisfies the interface is interchangeable. If you need to do a dynamic cast to anything other than the base interface you are probably too dependent on the concrete types.
Invariably over time these grow into serious code defects."
got from https://www.gamedev.net/topic/671003-c-dynamic-cast/