-
Notifications
You must be signed in to change notification settings - Fork 343
[Framework] Apply template method design pattern to Contact #5456
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
base: master
Are you sure you want to change the base?
Conversation
|
[ci-depends-on] detected during build #1. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #2. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #3. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #4. To unlock the merge button, you must
|
789c8a0 to
109fed4
Compare
|
[ci-depends-on] detected during build #5. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #6. To unlock the merge button, you must
|
|
[ci-build][with-all-tests] |
|
[ci-depends-on] detected during build #7. To unlock the merge button, you must
|
| * which is the method to override from now on. | ||
| * | ||
| **/ | ||
| virtual void createResponse(objectmodel::BaseContext* group) final |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure it makes sens to move from absrtact method to a virtual final. Shouldn't it be a non virtual one ? (same comment apply everywhere)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to talk about this to the team during the daily meeting, might apply to all the SED Sprint PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damienmarchal Talked about it with the team, for us it's important to declare them as virtual final to ensure child class cannot shadow them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I confirm, putting virtual final will make sure no one override it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@damienmarchal's point is pertinent but the context must be taken into account:
The function createResponse was virtual. There are chances that someone overloaded this function in a derived class. And there are two cases:
- The overload has the
overridekeyword:- if the base class function is virtual final, it will trigger a compilation error because of a final method cannot be overloaded.
- If the base class function is a non-virtual function, it will also trigger a compilation error because there is nothing to override.
- The overload has not the
overridekeyword:- if the base class function is virtual final, it will trigger a compilation error because it tries to override a final function.
- If the base class function is a non-virtual function, the function in the derived class will be valid. And that's not what we want. We want to notice the derived class that something changed and the code must be adapted. This case will not notice the developer of the derived class, and will introduce a bug.
Because of that, virtual final is not silly. However, this case should be rare because the override keyword should be widely used. So going with a non-virtual function should not be risky, and be the objective.
applications/plugins/PersistentContact/PersistentFrictionContact.h
Outdated
Show resolved
Hide resolved
applications/plugins/PersistentContact/PersistentFrictionContact.h
Outdated
Show resolved
Hide resolved
|
[ci-depends-on] detected during build #8. To unlock the merge button, you must
|
|
[ci-depends-on] detected during build #9. To unlock the merge button, you must
|
Co-authored-by: Damien Marchal <[email protected]>
04c368d to
ac5ac59
Compare
|
[ci-depends-on] detected during build #10. To unlock the merge button, you must
|
SED Sprint 2025
Base class
Contact, function modified:getCollisionModelssetDetectionOuputscreateResponseremoveResponseChild classes modified:
BarycentricStickContactBarycentricPenaltyContactBaseUnilateralContactResponseRayContactStickContactConstraintRegistrationContactmodified in Registration plugin (see below)[ci-depends-on https://github.com/sofa-framework/Registration/pull/24]
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if