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

Feature request: remove CREATE PRIVATE/PUBLIC when ABSTRACT #293

Open
openPhiL opened this issue Apr 16, 2024 · 2 comments
Open

Feature request: remove CREATE PRIVATE/PUBLIC when ABSTRACT #293

openPhiL opened this issue Apr 16, 2024 · 2 comments

Comments

@openPhiL
Copy link

HI @jmgrassau ,

in my understanding, an abstract class cannot be created.
Therefore we don't need extra definition how it is allowed to be created.

before:

CLASS ycl_test DEFINITION
  ABSTRACT
  FINAL
  CREATE PUBLIC.

after:

CLASS ycl_test DEFINITION
  ABSTRACT
  FINAL.

What do you think?
Thanks
PhiL

@ConjuringCoffee
Copy link
Contributor

This would only be relevant when the class is also FINAL, right?

(Also, relevant issue from the past: #104 )

@jmgrassau
Copy link
Member

jmgrassau commented May 10, 2024

Hi PhiL,

as mentioned by ConjuringCoffee, CREATE PUBLIC would still make sense for an abstract non-final class, because this information is then inherited by its subclasses:

  • if the superclass is ABSTRACT CREATE PUBLIC and the subclass does not explicitly specify a more restricted CREATE level, the subclass can't declare its constructor in the PROTECTED SECTION, otherwise you get a syntax error.
  • if you then change the superclass(!) to CREATE PROTECTED, the syntax error in the subclass is gone.

By contrast, for an ABSTRACT FINAL class, no constructor can be declared anywhere, so as far as I can see, you're right that CREATE {PUBLIC|PROTECTED|PRIVATE} could be removed in such a case. I could just imagine this to be a hint in the sense of "for now, we'll prevent instantiation of this class, but if we ever change our minds and remove the FINAL, we then want the class to be CREATE PUBLIC" (but that may be a bit far-fetched…)

Therefore, not entirely sure what to do with this. One argument that came up in a different place is that unfortunately, ABAP classes are by default CREATE PUBLIC (while CREATE PRIVATE would be desirable to enforce static CREATE methods with good, semantic names); therefore, you should keep CREATE PUBLIC in the code as a reminder that the class design is not yet ideal. (But admittedly, that's a different story).

Kind regards,
Jörg-Michael

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

No branches or pull requests

3 participants