I was assigned the task of reorganizing an obsolete database application, and I'm trying to create objects that encapsulate old code. This is the first time I'm using real OODesign, now I just used OO to encapsulate some legacy logins and refactor a subset of the functions from the application. (Now this is a classic client server application with all the business logic in the user interface, the idea is to make it layered, to use clients against the application server and ultimately write a web interface.)
I will make a simplified example to explain what I want to do:
I have many instances of this class:
type TCustomer = class(TObject) private FOrders: TList<TOrder>;
How can I request orders from all customers? Imagine that I want to request all orders from September 2007.
If I have 10,000 TCustomer objects, I donβt want everyone to create them (this means that they extract everything from the database: I would get too much information that I donβt need).
In current software, of course, this is done with a simple query on the order table.
But how is this done in the OO world?
What approach do you offer me?
In addition: when refactoring such database applications, do you suggest using ORM (this means creating a new database and transferring all the data) or just using an existing database (which is bad in my case)?
source share