about class for customer

Posted by Vicente Izquierdo on 07-May-2012 16:16

USING Progress.Lang.*.

CLASS Customers:

DEFINE PUBLIC PROPERTY p_CustName AS CHARACTER NO-UNDO

GET:

IF AVAILABLE customer THEN

RETURN customer.custname.

RETURN "".

END GET.

PRIVATE SET.

/* .... more properties for each field what I need, same syntax */

METHOD PUBLIC VOID Find_Customer(INPUT codCustom AS INTEGER):

FIND customer WHERE

customer.custnum = codCustom

NO-LOCK NO-ERROR.

END METHOD.

END CLASS.

What you thnk about this aproach for class of customer or another table??

Im beginning in OOP.

TIA.

All Replies

Posted by Thomas Mercer-Hursh on 07-May-2012 16:49

One would certainly expect a lot more behavior in a Customer object than just getting values and selecting which customer it was.

I would question whether the name of a non-existent customer should be a mere blank.

What about setting properties of Customer ... or is this intended to be a read-only version?

Generally, Customer would be a Business Logic class and should therefore not be touching the database directly.  Instead, one would have a CustomerFactory object where someone who wanted a Customer object would request one of the CustomerFactory.  The factory would then send a message to the Data Access layer which would do the find and return a value object containing the properties of the Customer.  The factory would then used that message to build a Customer object and hand it off to the requestor.

Sounds like you have a little reading to do ...

Posted by Vicente Izquierdo on 08-May-2012 09:46

I understand that this is not the best way to control whether a client is valid or not. Is one of the advice I expected.
The use of the class is read-only and some other simple process of calculation to the customer fields.
On the other hand, I do not follow the oera's specifications and need maximum speed in the processes. I do not need to separate the data access.

Having 2 or 3 layers is not possible in my environment.

I wanted to know if anyone has used these types of classes and properties to access the fields in this way, or have encountered any problems.

Thanks anyway.

Posted by Thomas Mercer-Hursh on 08-May-2012 11:14

"It is not possible" is a questionable position about layering.  This is just good architecture.  I suppose you want to have 20 different customer classes, each of which does its own find?

One of the consequences of separate is that BL objects should not have database connections, therefore no buffers, therefore the properties are not references to buffers.

Sounds, though, like you don't really want advice on OO, but just want to do it your way.

Posted by Vicente Izquierdo on 10-May-2012 14:00

my way, I like Sinatra. Its a joke!.

Not all systems programming can be applied to all situations.

The key is knowing how to apply in every situation the best system.

Posted by Thomas Mercer-Hursh on 10-May-2012 14:24

Like I said ... don't know why you bothered to ask since you have your mind made up in advance.

I recommend the book reviewed here.  http://cintegrity.com/Lahman

You might find other useful things in the vicinity, if you are actually interested in learning.

This thread is closed