Giter Site home page Giter Site logo

Structure with INCLUDE TYPE about styleguides HOT 5 CLOSED

sap avatar sap commented on May 29, 2024 2
Structure with INCLUDE TYPE

from styleguides.

Comments (5)

nomssi avatar nomssi commented on May 29, 2024 1

I am writing a numerical tower where the structure for complex numbers is

  TYPES: BEGIN OF complex,
           type TYPE number_type.
           INCLUDE TYPE number AS real_part.
  TYPES:   imag_part TYPE number,
         END OF complex.

with the structure for "simple" numbers (integer, rational, real) being used twice.

TYPES: BEGIN OF number,
         subtype TYPE number_type,
         int     TYPE int,
         real    TYPE real,
         nummer  TYPE int,
         denom   TYPE int,
         infnan  TYPE tv_flag,
         exact   TYPE flag,
         ref     TYPE REF TO lcl_number,
       END OF number.

The components of the imaginary part (a real sub-structure) can only be accessed as imag_part-int. The components of the real part can be accessed either directly as int or indirectly as real_part-int.

The help want us to prefer real sub-structures because of the following issues:

  1. Changing the structure later in another program can lead to syntax error, naming conflicts
  2. The structure cannot be addressed as such
  3. The metadata are stored multiple times
  4. Include type cannot be used as static boxes (boxed components)

The help warns such type definitions should not be leaked outside their scope to avoid incompatible structure change. I think I get it, but we have had this for years with the enhancement category of dictionary structures. I get a warning from the syntax check, but I still have to enhance existing structures because it is so useful to do.

I find the ability to access both the structure and its components individually very useful. This means I would advocate for
INCLUDE TYPE AS NAME as a way to design a large structure to be able to pass part of it as a parameter to a routine as a substructure.

I see the points with metadata storage and static boxes as performance enhancements in some specific contexts. From my current perspective, they are not relevant.

I wanted to express my dissent on this topic of the online help that is not covered in the main text. It is OK with me if it is only expressed here and the question is closed.

best regards,

JNN

from styleguides.

HrFlorianHoffmann avatar HrFlorianHoffmann commented on May 29, 2024

Interesting question. My team has been using INCLUDE TYPE extensively over the years, and we didn't observe any dramatic conflicts. There are also prominent wide-spread examples such as BOPF that includes sub-structures for keys and administrative data in the same fashion.

While sub-structures, as recommended in the help, are generally easy to use, they can become a problem when defining table types.

Should we give this some more thorough discussion?

from styleguides.

HrFlorianHoffmann avatar HrFlorianHoffmann commented on May 29, 2024

Suggest to close this question. After some initial discussion, there was no activity anymore.

from styleguides.

pokrakam avatar pokrakam commented on May 29, 2024

For what it's worth, I agree INCLUDE TYPE is useful. The documented risks make sense but largely mitigated by Clean Code and TDD as conflicts should immediately become apparent and are easy to address.

from styleguides.

bjoern-jueliger-sap avatar bjoern-jueliger-sap commented on May 29, 2024

Consensus here appears to be to not change the style guide - use INCLUDE TYPE as you will (or won't).

from styleguides.

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.