Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Good OOP?

Status
Not open for further replies.

timothy

Programmer
Mar 20, 2000
39
US
I'm just starting to develop using OOP. I have a project where I need to use an FTP class to pickup a file with an order, validate the structure and some field values, like part number, against a recordset the update another database. I thought this would be a good place to start my OOP training. I'm hoping I can get your ideas on the best way to design it. This is what I have so far...

class FTPControl - this has all of the methods and properties to FTP (actually already have this).

class Order - will contain all of the order information, properties and methods.

class Validate - will get the business rules for the customer (database conn) and check them against the Order class above.

class DBControl - will contain all properties a methods for connecting and manipulating the database.


One Question I already have on the Order class - How to store the line items? There could be more then one. Should I just use an array?

Any input would be appreciated.

Thanks
 
> There could be more then one. Should I just use an array?
I think I'd create an OrderItem class, and then say that Order has a list of OrderItems.


--
 
Thanks that's exactly what I ended up doing. I add each OrderItem to an ArrayList field in Order and I have a property that returns the ArrayList of OrderItems when needed. Very nice!
 
Don't use an array. If you have a better structure like collection use it.

What language are you modelling for?

Simon
 
Hi, I'm using an ArrayList (collection) in C#. I have an Order object that contains an ArrayList of OrderItem. Then when I what to use the Order's OrderItems I can reference them like so:
// order[0] is a ref to a text file
Order CurOrder = new Order(orders[0]);
foreach (OrderItem orderItem in CurOrder.OrderItems){
...
}

Let me know what you think.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top