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

fix virtual specifiers, remove redundant methods, unclutter #228

Merged
merged 12 commits into from
Sep 2, 2024

Conversation

m-fila
Copy link
Contributor

@m-fila m-fila commented Aug 23, 2024

BEGINRELEASENOTES

  • fixed virtual specifiers, removed redundant methods, uncluttered code

ENDRELEASENOTES

This is an attempt to slightly reduce the amount of dated and obsolete code:

  • missing or redundant virtual, override, final specifiers
  • redundant declarations of trivial virtual destruction when base method already has virtual destructor,
  • removed redundant empty destructors
  • use empty() methods instead of comparison for vector and string
  • use make smart pointer instead of reset(new
  • use auto instead of repeating a type or type long iterator types

@m-fila m-fila changed the title fix specifiers, remove redundant methods, unclutter fix virtual specifiers, remove redundant methods, unclutter Aug 23, 2024
Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was necessary ;)

I have two general-ish comments / questions

  • Should we explicitly default the empty destructors that we would otherwise remove here? It's not necessary from a c++ point of view, but it would make it very clear that nothing special is happening in this class destructor from just looking at the code.
  • We seem to have an arbitrary mix of override and final in our algorithms and classes. I think all algorithms could probably be final (especially the test and example ones). It's not very likely that something will inherit from them. For all the services a similar argument holds probably, so we could make almost everything final(?). This doesn't matter too much with functional algorithms, so I am not sure whether it's worth the effort in the end.

@m-fila
Copy link
Contributor Author

m-fila commented Aug 26, 2024

Thank you

Should we explicitly default the empty destructors that we would otherwise remove here? It's not necessary from a c++ point of view, but it would make it very clear that nothing special is happening in this class destructor from just looking at the code.

I'd prefer to use implicit destructors when possible in the spirit of rule 0 (having = default reads like there was a need to be explicit because the class does something not trivial with memory). But if there is a strong preference to have explicit destructors in the codebase then I can bring them back no problem

We seem to have an arbitrary mix of override and final in our algorithms and classes. I think all algorithms could probably be final (especially the test and example ones). It's not very likely that something will inherit from them. For all the services a similar argument holds probably, so we could make almost everything final(?). This doesn't matter too much with functional algorithms, so I am not sure whether it's worth the effort in the end.

I was wondering if there is some conventions/deeper reason for the mix. Is there really a reason to not allow further overriding (final doesn't have performance benefits and to me most of )? In that case maybe the classes should be final?

@tmadlener
Copy link
Contributor

I'd prefer to use implicit destructors when possible in the spirit of rule 0 (having = default reads like there was a need to be explicit because the class does something not trivial with memory). But if there is a strong preference to have explicit destructors in the codebase then I can bring them back no problem

Good point. I haven't really checked the existence of the constructors. So if we can go with rule of 0 let's go with that.

I was wondering if there is some conventions/deeper reason for the mix. Is there really a reason to not allow further overriding (final doesn't have performance benefits and to me most of )? In that case maybe the classes should be final?

Maybe it's time to come up with a convention and write it down into some general guidelines document.

@jmcarcell
Copy link
Contributor

Anything left here or can we merge this @m-fila?

@m-fila
Copy link
Contributor Author

m-fila commented Sep 2, 2024

It's good to go. I think we could propose a convention for final later as no-one seems to have now a very strong opinion

@jmcarcell
Copy link
Contributor

I agree with algorithms being final, for services we should check if no one has derived another service from any of them.

@jmcarcell jmcarcell merged commit ddd3ff3 into key4hep:main Sep 2, 2024
3 of 7 checks passed
@m-fila m-fila deleted the unclutter branch September 2, 2024 17:32
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

Successfully merging this pull request may close these issues.

4 participants