Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How project a good interface?
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Web Services
Titre:
How project a good interface?
Divers
Thread ID:
00864565
Message ID:
00864565
Vues:
50
Hi friends,

My message is a little bit longer! :-)

I've been studying how change my applications for n-tier, but I always stop in some complex point.
I read a lot of articles from internet, but no one could explain me some doubts.

Lets define a little database for my example:

Customers.DBF -> Id I, Name C (30)
Products.DBF -> Id I, Description C (30)
Orders.DBF -> Id I, Date D, Customer I, Discount N (9,2)
OrdersDetail.DBF -> Id I, Order I, Product I, Quantity I, Price N (9,2)

I think I have to create some objects... I will use XML to pass and receive data between tiers, ok?

Lets talk a little about Custormes... I've created one object with some methods:
oCustomer.ReadCustomer(iId) -> I pass an ID and receive a XML with all data about ONE customer.
oCustomer.SaveCustomer(cXML) -> I pass a string XML and receive an empty string if all data would stored in my database or a list of error if any problem happens.
oCustomer.DeleteCustomer(iId) -> I pass an ID and receive an empty string if the customer would erased correctly or a list of error if any problem happens.

I think, until here, I have no problems. My first doubt is how define my interface to get a list of customers. Some examples:

FIRST OPTION - Use a generic method.
oCustomers.ListCustomers(cSQL) -> I pass a Select SQL statement and receive a XML string with all records resultant for this SQL statement. For example:
oCustomers.ListCustomers("Select * From Customers Where Name Like '%TEST%' Order By Name")
oCustomers.ListCustomers("Select * From Customers Where Id between 100, 200 Order By Name")
oCustomers.ListCustomers("Select * From Customers Where Id between 100, 200 Order By Id")

SECOND OPTION - Use various specifics methods.
oCustomers.ListCustomersByName(cName, cOrder) -> I pass a String to be used in Where statment (cName) and other to be used in Order statment (cOrder). For Example:
oCustomers.ListCustomersByName("%TEST%","Name")
oCustomers.ListCustomersByName("%TEST%","Id")

oCustomers.ListCustomersByIdRange(iId1, iId2, cOrder) -> I pass two integers to be used in Where statment (iId1 and iId2) and other to be used in Order statment (cOrder). For Example:
oCustomers.ListCustomersByName(100,200,"Name")
oCustomers.ListCustomersByName(100,200,"Id")

If our Customers table have some fields more, like City, State, Country.... I think I will have a lot of methods like ListCustomersByCity, ByState, etc...

THIRD OPTION - Use one method with a lot of parameters.
oCustomers.ListCustomers(iId1, iId2, cName, cCity, cState, cCountry, cOrder) - and I pass a lot of parameters to construct my sql expression.

Ok... I thought about this three possibilities, and I'd like to know your oppinion about it. You know, maybe we define something and when we implement it somethings doesn't works like we have imagined.

At this point, we just discuss about one simple table... But if we talk about the orders table we have an infinity of possibilities, like the best sales customer, the best sales product, etc... In this case, I will have to create one SQL statement for each case. Am I correctly? Example:

oSales.BestCustomer(iDate1, iDate2)
oSales.BestProduct(iDate1, iDate2)
oSales.Etc.....

Nowadays, in my applications, I have nothing that seem with this example... I just write my SQL statement like I need. If I have to add some filter, I just put an object in my form and update my SQL expression. DONE! ...

My main doubt is if I get the right concept. Any comments are very appreciated!

Thanks in advanced.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Rodolfo Duarte
Répondre
Fil
Voir

Click here to load this message in the networking platform