Marc,
I see you are using Harbour and I use xHarbour. Try putting double colons in front of super.
::super():New(...
James
Marc,
I see you are using Harbour and I use xHarbour. Try putting double colons in front of super.
::super():New(...
James
1) What are the important features of TData which we can not get with TDataBase?
2) What is that TRecord can do what TDataRow can not do?
We would be very much glad if you can show some illustrations of using TRecord to create single objects.
cCustNo:= "400"
oInvoice:= TInvoice():New( cCustNo )
cItemNo:="1000"
oItem:= TItem():New( cItemNo )
oInvoice:addItem( oItem )
oItem:end()
cItemNo:="1007"
oItem:= TItem():New( cItemNo )
oInvoice:addItem( oItem )
oItem:end()
oInvoice:save()
oInvoice:preview()
oInvoice:finalize()
oInvoice:end()METHOD Finalize() CLASS TInvoice
::Final:= .t.
::save()
::oCustomer:balance = ::oCustomer:balance + ::total
::oCustomer:save()
RETURN nilI understand and like it.
Can you please give a small sample one class deriving from TRecord. Then I like to see if I can do the same thing using TDataRow.
Marc,
Were you able to get the Customer class example to compile after changing SELF to ::SELF?
James
Were you able to get the Customer class example to compile after changing SELF to ::SELF?
Marc Venken wrote:1. Why do you use the :: and what does it stand for.
2. Every class you make has to be a single prg right ? or do you do this for better maintenance options ?
3. They have to linked in into the program (have to look where and how)
Enrico Maria Giordano wrote:Marc Venken wrote:1. Why do you use the :: and what does it stand for.
2. Every class you make has to be a single prg right ? or do you do this for better maintenance options ?
3. They have to linked in into the program (have to look where and how)
1. :: stands for "self" that is the current object.
2. No, you can put any class you want in a single PRG.
3. I didn't understand the question, sorry.
EMG
Marc,
At James urging, I took a huge project and converted it to OOP ... and the code reduction was about 35-40%. I also found that when I had everything as functions, I often wrote new functions for specific tasks, and in doing so, I sometimes had 5 or 6 ways ( functions ) to handle essentially the same tasks. That was hard to keep debugged.
I started with a chart. I looked at all of the major processes I would have, then set a .prg for each. Each file may have several classes. I would create a class for each database ( inheriting from tData, and using tRecord also ), and would have the methods for the database, ie. add, edit, delete, browse, and saving the records. Then I created a class for processing the records with associated methods. These, of course, called the database classes as appropriate.
In the end, everything was organized in easy to track .prg files, it was easy to document, and using meaningful names, the code was easy to view and understand.
The reason you use this instead of Functions is simple. A class can inherit from another class which gives it all the capability in the original class plus what you wish to add. You eliminate a lot of redundant code.
Tim
I suppose that I have to look into the source of Tdatabase to see what actions (like seek..) are possible? Or is there a manual for this?
CLASS TCustomers from TDatabase
Meaning that I create a new class Tcustomer and ALL actions inside Tdatabase will become available.
Then you create your own methods.Yes, but not with that type of name. One of the great features of objects is that you can pass them around. Since they are encapsulated you only have to pass one item (the object) to get access to all the data and methods of the object. Encapsulation is one of the doctrines of OOP.
METHOD printCustList()
I just miss the point of using this instead of a function.
Function printCustlist(cNum)
Code for printing report
Return NIL
I also can say : printcustlist(Cust->CNo)
I agree that with OOp everything is located in the class Tcustomer, and maintaining the code is better, since It stays together. I confess, that in a larger project with many functions, we loose time because we don't always know where they are ....
Marc,
If you post a small section of your code that uses the customer table, I will show how you can do the same with a customer table object. Or, any other table if you prefer.
James