Getting properties of class - Forum - OpenEdge Development - Progress Community
 Forum

Getting properties of class

  • Is there any way to iterate through the properties of a class and retrieve the name, type and default value of each property ?

    How does the OEA do this ?

  • Not in the same way as for procedures. You can get something out of the XREF. That's what we use for generating documentation (together with method comments).

    My assumption is, that OEA parses the source code (AST) - at least to build the outline view.

  • Doing it in code is probably going to have to wait for enhanced reflection (is that anything like polishing the mirror?). Of course, you could use the proparse.jar ...

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Is this now possible in 10.2B ??

  • Not any better than in previous releases.

  • Well, ain't that a pile of poo.

  • Unfortunately not.

    -- peter

  • Consider it a safety precaution to keep you from doing reflection and dynamic programming.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • Consider it a safety precaution to keep you from doing reflection and

    dynamic programming.

    That's too funny: no dynamic programming in the (our) 4GL? Um, yeah, OK.

    -- peter

  • It has its place, but is heavily abused, especially in terms of dynamic calls that make it impossible to create a callgraph for an application.  Clearly, dynamic queries are essential for some things and there is a place for some other things in frameworks, but I think too many people reach for it all too quickly and produce unreadable, unanalyzable code.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • I am trying to create a enum-type class where the valid values of the

    class can be loaded into a combo-box or selection list . I can do this

    by creating a method that adds all the property names into a string

    but wanted to do it automatically.

    Julian

    On 16 March 2010 21:13, Thomas Mercer-Hursh

  • So, this is internal to the class, not something accessible from outside?

    You really should look into code generators.  That would make this sort of thing automatic without requiring any dynamic features.

    I'm not sure what I think about each enum value being its own property.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com

  • >>So, this is internal to the class, not something accessible from outside

    Yes. It should be a single property that returns all possible values

    of the "enum"

    >>You really should look into code generators.

    I was

    >> I'm not sure what I think about each enum value being its own property.

    This ensures that if you refer to this value anywhere in code it is a

    valid value. I've been bitten many tomes my mispellign a value (e.g.

    ">Actoin" instead of ">Action"). Having Event:Action instead means

    that it won't compile if I misspell or mistype. I used to use

    preprocessors for this purpose.

    Julian

    On 16 March 2010 21:34, Thomas Mercer-Hursh

  • I'm not sure what I think about each enum value being its own property.

    What else (given the out of the box capabilities of 10.2B)?

  • Admittedly, I haven't thought a lot about this yet, but I suppose I was thinking of something more like IsValid(test value) and ToString(sample value) working against a list rather than each value being its own property.  I suppose that exposing it as a property means that you can do a type-safe assignment which is a plus, but if you have a possible value which has not been verified, it seems like you need something like IsValid() to test it.  Are you doing both?

    In any case, I would rather solve it with a generator than dynamic code.

    Consulting in Model-Based Development, Transformation, and Object-Oriented Best Practice  http://www.cintegrity.com