Final/const keyword equivilant in Progress-4GL

Status
Not open for further replies.
C

corsiKa

Guest
If I had a class with immutable members in Java, I would do this:

class MyClass {
private final String name;
private final int id;
myClass(String name, int id) {
this.name = name;
this.id = id;
}
String getName() { return name; }
int getId() { return id; }
}


In Progress-4GL, you'd typically see something like this: (Please, no lectures on Hungarian Notation. I hate it too, but it's very common in the Progress community, so it's something I just live with.)

CLASS MyClass :

DEFINE VARIABLE mcName as CHARACTER NO-UNDO.
DEFINE VARIABLE miId as INTEGER NO-UNDO.

CONSTRUCTOR PUBLIC MyClass(INPUT ipcName AS CHARACTER,
INPUT ipiId AS INTEGER):
ASSIGN mcName = ipcName
miId = ipiID.
END. /* constructor(char,int)*/
END CLASS. /* MyClass */


I was told in that in Progress 10.2B, they added the ability to make constants/final variables. However, I am unable to find any reference to it anywhere. In my Architect (version 10.2A) I do see that FINAL is considered a keyword. But the documentation behind it simply eludes me.

And if you've ever tried to search for Progress documentation, you know my dilemma.

How can I do immutable variables in Progress 10.2B? Are there any gotchyas I need to be aware of?

Thanks!

EDIT 1 I found documentation on FINAL. It appears to only apply to classes and methods. My current approach is

CLASS ImmutableString :
DEFINE PRIVATE VARIABLE mcValue AS CHARACTER NO-UNDO.

CONSTRUCTOR PUBLIC ImmutableString(INPUT ipcValue AS CHARACTER) :
ASSIGN mcValue = ipcValue.
END.

METHOD PUBLIC CHARACTER getValue() :
RETURN mcValue. /* Is a defensive copy required? */
END METHOD.
END CLASS.

Continue reading...
 
Status
Not open for further replies.
Top