openedge - Structures or javascript/json objects in progress ABL? -


we're migrating 11.6 , think it's great moment rethink old habits , improve concepts.

one of these things way we've been dealing parameter definitions in functions , procedures.

often times have procedures , functions need lot of parameters, either inputs or outputs. personally, readability , maintainability reasons, don't have methods many parameters explicitly declared.

in order avoid problem , still allow large number of parameters, we've manually implemented key-value pair approach single parameter.

but there drawbacks approach:

  • it's not possible tell parameters needed inspecting method signature.
  • you'll need boilerplate code, methods pushing , pulling values.

so said, hear others' thoughts. have ever implemented similar?

is there work javascript/json object in abl?

current implementation.

define variable param 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)   

since mentioning 11.6, why not use real class based object (available since 10.1a).

yourpackage\yourparameter.cls:

class yourpackage.yourclass:       define public property date date no-undo      get.     set.       define public property id integer no-undo      get.     set.       constructor public yourclass ():         super ().      end constructor.      constructor public yourclass (pid integer, pdate date):         super ().          assign this-object:id = pid                this-object:date = date .       end constructor.  end class. 

and internal procedure:

define input parameter poparameter yourpackage.yourclass no-undo . 

and caller:

define variable o yourpackage.yourclass no-undo.  o = new yourpackage.yourclass(). o:id = 42. o:date = today.  run internalproc (o) .  

alternative caller:

run internalproc (new yourpackage.yourclass (1, today)) . 

the abl provides full oo capabilities 10.1a on , can mixed nicely procedural code. , parameter objects (structs) great way started few inital classes in legacy code.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -