Is a Static Class Possible in OOABL? - Forum - OpenEdge Development - Progress Community

Is a Static Class Possible in OOABL?

 Forum

Is a Static Class Possible in OOABL?

This question is answered

Is it possible to define a STATIC CLASS using OOABL? 

Separate question: is there a point to having a DESTRUCTOR in a CLASS with only STATIC METHODs?

Verified Answer
  • Well, members (methods, variables, properties etc) are static, classes aren't. You can prevent instantiation by giving a class just a private constructor. This way it cannot be inherited either. If you make the class abstract as well, it cannot be instantiated by itself, leaving only static methods as an option to do something useful.

    So if your class is abstract and has only a private constructor (ie it's a "static class") and only static methods there's no point in having a destructor since the destructor is only called when an instance is deleted.

All Replies
  • Well, members (methods, variables, properties etc) are static, classes aren't. You can prevent instantiation by giving a class just a private constructor. This way it cannot be inherited either. If you make the class abstract as well, it cannot be instantiated by itself, leaving only static methods as an option to do something useful.

    So if your class is abstract and has only a private constructor (ie it's a "static class") and only static methods there's no point in having a destructor since the destructor is only called when an instance is deleted.

  • Thanks @Bronco. I think this answers my questions.