Posted: Thu Apr 10, 2008 7:37 am
Doug,
>No. But PATIENTLIST has the object of type DATAFILE that opened the PT_PATIENT datafile as a property so whilst it isn't a subclass it has many of the benefits. This was a deliberate choice partly to ease data back end migration.
>xDATAFILE Class follows. You probably need to see some of the other objects to see how it fits together.
While I applaud your efforts in creating your own class, I think you are making it more difficult than it needs to be.
Probably 98% of the cabability of your class already exists in FW's TDatabase class. You are also dealing with lots of SELECTs and in so doing you are changing the selected workarea and not returning it to where you found it. This is a problem waiting to happen.
If you use alias referencing, e.g. (::cAlias)->(dbgobottom()) in your class, then you don't need to change the selected workarea.
You have:
METHOD GoBottom() CLASS xDATAFILE
SELECT ( ::WorkArea )
GOTO BOTTOM
RETURN
This could be simplified to:
method GoBottom() class xDatafile
return (::cAlias)->(dbgobottom())
And the workarea never gets changed.
But you already get this in TDatabase AND you get the very useful buffering and all the fieldnames are defined automatically. So where is the advantage to your class? How do you handle creating temporary variables to hold data that is being edited (so the user can either cancel or save)? Hand coding?
You could have subclassed TDatabase to add your lastUpdated() method and any other new ones you wanted. This would have only taken you 10 minutes.
Once you start using TDatabase or TData, you never have to deal with workareas again.
oPatient:= TPatient():new()
msgInfo( oPatient:name )
oDoctor:= TDoctor():new()
msgInfo( oDoctor:name )
No more workareas!
As far a backend migration, a subclass is the way to go. If you subclass TDatabase to make your patient class, and later want to use recordset objects, you can create and use a TRecordset class the has all the same methods as TDatabase, and then you can switch to using recordsets by just changing the class definition of TPatientList--you just change one word.
class TPatientList from TDatabase // to use DBFs
class TPatientList from TRecordset // to use recordsets
It doesn't get much easier than that!
James
>No. But PATIENTLIST has the object of type DATAFILE that opened the PT_PATIENT datafile as a property so whilst it isn't a subclass it has many of the benefits. This was a deliberate choice partly to ease data back end migration.
>xDATAFILE Class follows. You probably need to see some of the other objects to see how it fits together.
While I applaud your efforts in creating your own class, I think you are making it more difficult than it needs to be.
Probably 98% of the cabability of your class already exists in FW's TDatabase class. You are also dealing with lots of SELECTs and in so doing you are changing the selected workarea and not returning it to where you found it. This is a problem waiting to happen.
If you use alias referencing, e.g. (::cAlias)->(dbgobottom()) in your class, then you don't need to change the selected workarea.
You have:
METHOD GoBottom() CLASS xDATAFILE
SELECT ( ::WorkArea )
GOTO BOTTOM
RETURN
This could be simplified to:
method GoBottom() class xDatafile
return (::cAlias)->(dbgobottom())
And the workarea never gets changed.
But you already get this in TDatabase AND you get the very useful buffering and all the fieldnames are defined automatically. So where is the advantage to your class? How do you handle creating temporary variables to hold data that is being edited (so the user can either cancel or save)? Hand coding?
You could have subclassed TDatabase to add your lastUpdated() method and any other new ones you wanted. This would have only taken you 10 minutes.
Once you start using TDatabase or TData, you never have to deal with workareas again.
oPatient:= TPatient():new()
msgInfo( oPatient:name )
oDoctor:= TDoctor():new()
msgInfo( oDoctor:name )
No more workareas!
As far a backend migration, a subclass is the way to go. If you subclass TDatabase to make your patient class, and later want to use recordset objects, you can create and use a TRecordset class the has all the same methods as TDatabase, and then you can switch to using recordsets by just changing the class definition of TPatientList--you just change one word.
class TPatientList from TDatabase // to use DBFs
class TPatientList from TRecordset // to use recordsets
It doesn't get much easier than that!
James