Hi all

 Re the naming of classes:

 Prefixing class names with a T I think originates with Borland
products.  The main reason I adopted it was that at one point in time at
least Harbour treated it as an error if your source file and class had the
same name.  That is you couldn't have a file named patient.prg containing
a class patient.  One solution was to name the source file
patient_class.prg but in the end I adopted the T prefix for the class name
instead.  It's probably not still an issue with Harbour - I just haven't
checked - but the habit has stuck.

 As for readability I personally find MedicalPractice easier to "read"
than medicalpractice so thats how I name them (actually I use a prefix so
an object would be obj_MedicalPractice.  Of course xBase folds everything
to upper case anyhow so people can share classes and adopt their own
conventions.

 I know my prefixes are longer ( I use obj_ whereas I guess "the norm" -
if there is one - would be just o.  So I would have obj_Person rather
than oPerson or if you don't like capitalisation I guess operson or drop
the prefix and just have person.  Again the latter might be a tad
confusing if that is also the name of your class.  I like to use a wide
range of prefixes - for example I will usr fh_ for a file handle (a
specilaised form of int_), dlg_ for a dialog (a specialised form of obj_)
etc

 I'm not tyrying to push my way of doing things (which has changed over
the years so my older code doesn't match the new style) but rather just
explain the reasons I have reached the style I use now. 

 Re the structure of my client-server data base back end (presumably much
in common with a client server ORM)

 Will take a number of posts to explain.  Data (for a single item) is
transmitted as a two dimensional array contained in a wrapper array.

 Looking at the inner two dimensional array first.

 Assume I have a class as follows:

 CLASS Person

   DATA FamilyName
   DATA GivenName
   DATA Gender
   DATA DOB

 ENDCLASS

 Now if I have an array as follows:

 arr_MyData := { { "FamilyName", "Citizen" }, { "GivenName", "Joe" }, {
"Gender", "M" },  { "DOB", "19601231" } }

 I can set all the properties of an object of class Person  with

 __ObjSetValueList( self, arr_MyData )

 [I have assumed that code is in a member function of class Person if not
then assuming we have obj_ThisPerson you would have

 __ObjSetValueList( obj_ThisPerson, arr_MyData ) ]

 That is the basic mechanism my code uses.

 However we have to allow for the back end encountering a problem so I
wrap this array up  as the second element of an array, the first element
of which is an array containing success and / or failure information.  So
the back end can flag success, a problem that might make retrying
worthwhile or one that is unrecoverable.  And I allow for a series of
error messages / warnings.

 This wrapper array is built on the back end, then the function
HB_Serialize() is used to convert to a binary string which is then
transmitted to the client using IP sockets where assuming success is
indicated the data array is recreated using HB_Deserialize() and used to
update the properties of the object as per the above discussion.

 This approach has proved to be robust and can be used with front and back
end on a single machine or a cross a network or VPN.

 My back end "knows" that the contents of field PN_SURNAME should be
returned paired with the expected property name "FamilyName" .

 I can share how that works in a further post if anyone is interested.

 Regards to all
 xProgrammer
 
_______________________________________________
Harbour-users mailing list (attachment size limit: 40KB)
Harbour-users@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour-users

Reply via email to