Class / subClass- howTo - Forum - OpenEdge General - Progress Community
 Forum

Class / subClass- howTo

This question is not answered

I have a class consent.cls that has some Methods that I use for checking data. If the consent is of one kind, I need to prefill a temp-table (ttConsent) With data from an SQL Connection. Stuff regarding the Connection and how to retrieve data from the SQL I have put in a class consentSQL.cls. 

consent.cls inherits consentSQL.

When I Call fillConsent() that is a Method in consentSQL.cls, it fills the ttConsent. And here comes my question:

if I want to use the temp-table as a static temp-table in consent.cls, I believe I need to have a static copy of the temp-table in each class? and I need to do a copy-temp-table from consentSQL.cls to consent.cls? Or would it be better to use a handle from consentSQL.cls (tthConsent) and just use dynamically?

Or is there a better way doing it?

All Replies
  • Not sure about why there are two classes, this mostly only makes sense when the base class is used by other child classes as well.
     
    But you _can_ define a temp-table in the base class as PROTECTED which makes it available to the child classes with no further definition.

    Architect of the SmartComponent Library and WinKit

    Consultingwerk Ltd.

  • Forgot to say that consentSQL.cls, is also used in other classes/procedures, not only within consent.cls.

    But to be honest, I am not sure if I should use INHERITS. Mybe I should refer to that class using New …. ?

  • You have come to the right conclusion, you shouldn't be using inheritance for this. Delegation will do fine.

  • But then I can’t use the ttConsent that is in the consentSQL  as a static temp-table in the consent class ….
     
  • Correct. And you don't want to interfere with the inners of another object. If you want information, ask it. If that must come in the form of a temp-table, define an include file with the definition of that tt and use it in both objects. Or use an intermediate DTO for the data.

  • Thanks, it probably make sense, but to be honest, I found it pretty easy INHERITS contentSQL… probably my mind that is not familiar With the class consept of class - subClass…

    I kind of sees it like

    content inherits contentA contentB contentC

    Here I will have everything avail

    but I should thing contentA inherits content, contentB intherits content …. etc.

    here I will have everything of content, but only the part of what I ask for.

    In a way I wanted to extract the SQL part since I also uses that somewhere else, but it is importent for the baseclass of content.

    hmmmmm I will have to start Reading ….

  • One of the main challenges in OO is the is-a vs has-a relationship. In many situations the has-a solution is the better.

    next to is-a vs has-a you can google for inheritance vs composition.

    There's to much to be found about that to put in here since it's a very important part of understanding OO.

  • Thanks Rutger, I will dig into it.
     
  • You definitely don't want to be using inheritance here.  That will be a nightmare downstream when some maintenance programmer looks at this expecting it to look like inheritance when there is no inheritance happening here at all.  And Patrick is bang on here.  That the implementation of consentSQL.cls (which name I would also change since SQL is about implementation) involves a TT is a PRIVATE matter for the class.  Provide methods to manipulate the data.  E.g., you should design the interface of the class such that you could change the implementation to something else altogether and the interface would remain the same.

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

  • Thanks :-) i will do that

    Sendt fra min iPhone

    26. sep. 2018 kl. 16:22 skrev Thomas Mercer-Hursh <bounce-tamhas@community.progress.com>:

    Update from Progress Community
    <4TQ25PAWRNBO-png_2D00_70x70x2-png>
    Thomas Mercer-Hursh

    You definitely don't want to be using inheritance here.  That will be a nightmare downstream when some maintenance programmer looks at this expecting it to look like inheritance when there is no inheritance happening here at all.  And Patrick is bang on here.  That the implementation of consentSQL.cls (which name I would also change since SQL is about implementation) involves a TT is a PRIVATE matter for the class.  Provide methods to manipulate the data.  E.g., you should design the interface of the class such that you could change the implementation to something else altogether and the interface would remain the same.

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.

  • I mean change IT from inherits 

    Sendt fra min iPhone

    26. sep. 2018 kl. 16:22 skrev Thomas Mercer-Hursh <bounce-tamhas@community.progress.com>:

    Update from Progress Community
    Thomas Mercer-Hursh

    You definitely don't want to be using inheritance here.  That will be a nightmare downstream when some maintenance programmer looks at this expecting it to look like inheritance when there is no inheritance happening here at all.  And Patrick is bang on here.  That the implementation of consentSQL.cls (which name I would also change since SQL is about implementation) involves a TT is a PRIVATE matter for the class.  Provide methods to manipulate the data.  E.g., you should design the interface of the class such that you could change the implementation to something else altogether and the interface would remain the same.

    View online

     

    You received this notification because you subscribed to the forum.  To unsubscribe from only this thread, go here.

    Flag this post as spam/abuse.