1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Structures or javascript/json objects in progress ABL?

Discussão em 'StackOverflow' iniciado por fdantas, Julho 25, 2016.

  1. fdantas

    fdantas Administrator Moderador

    We're migrating to 11.6 and I think it's a great moment to rethink old habits and improve some concepts.

    On of this things is the way we've been dealing with parameters definition in functions and procedures.

    Often times we have procedures and functions that need a lot of parameters, either inputs or outputs. Personally, for readability and maintenability reasons, I don't like to have methods with too many parameters explicitly declared.

    In order to avoid this problem and still allow a large number of parameters, we've manually implemented a key-value pair approach with a single parameter.

    But there are some drawbacks with this approach:

    • It's not possible to tell which parameters are needed just inspecting the method signature.
    • You'll always need some boilerplate code, like methods for pushing and pulling values.

    So with that said, I would like to hear some thoughts of yours. Have you ever implemented something similar?

    Is there something that could work as a javascript/json object in ABL?

    Current implementation.

    DEFINE VARIABLE param as CHARACTER NO-UNDO.

    addValue('id', '1', param).
    addValue('date', STRING(TODAY), param).

    RUN internalProc (INPUT param).


    Desired implementation

    param.id = 1
    param.date = TODAY

    RUN internalProc (INPUT param)

    Continue reading...

Compartilhe esta Página