Object-Oriented programming. The C# book I’m reading has an excellent definition; it says “… object-oriented programming encapsulates the characteristics and capabilities of an entity in a single, self-contained and self-sustaining unit of code.” Pretty obvious stuff. So my purely theoretical question for the late night: given an object oriented system with classes that describe entities … where in the system do you put the retrieval of objects? For instance, let’s say I have an ecommerce system that has classes ‘Order’, ‘Product’, and ‘Consumer’. Order will have methods like return(), commit(), cancel(), Product will have methods like getPrice(), updateStock() and so on… The bottom line is that methods are the way we access (getting) an objects properties and also the way that we manipulate an objects properties (setting). So lets say that somewhere in this system, I want to be able to query all the orders in system, returning open orders, closed orders, orders over $500.. It doesn’t feel right to write a method like this:
[java]
public static Resultset getOpenOrders()
[c#]
public static DataTable getOpenOrders()
for the Order object. Where does a method like this fit in the system?