Giter VIP home page Giter VIP logo

Comments (3)

ConjuringCoffee avatar ConjuringCoffee commented on August 22, 2024 1

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

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

from abap-cleaner.

openPhiL avatar openPhiL commented on August 22, 2024 1

Let me get back to this before the thread becomes stale :)

I do agree with the need to differentiate between FINAL and non-FINAL.
as in: Sometimes, the create public is needed, sometimes it can be removed as not needed.
as in: Somtimes, the exporting argument in a method call is needed, sometimes it can be removed as not needed :)

So I am voting for having an option in one of the rules to remove the create public if not needed, and that is if it is a abstract final class.

from abap-cleaner.

jmgrassau avatar jmgrassau commented on August 22, 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

from abap-cleaner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.