2

I have a conceptual problem here. When i query my database, i often do so with joins. So a result set row might look like

+------------+--------------+------------+-------+----------+----------+---------+
| CustomerId | CustomerName | MaterialId | Sales | Quantity | Salesman | Manager |
+------------+--------------+------------+-------+----------+----------+---------+

This result contains properties that would appear in certain objects, like Customer, Material, Invoice, and Salesman. It wouldn't make sense to put all these properties into any one of the above objects. For example, having a sales property in an Material object breaks object cohesion in my opinion. A material's (in this context it's a mechanical/plastic part) properties should list its id, its manufacturer, which machine it's applicable to, etc. To have a sales property is unrelated, because sales only makes sense when you're talking about a customer.

Another caveat of my data is that I never work with individual invoices, but rather aggregated invoices over some period of time, grouping the invoices by customer and material. So even the keyword Invoice seems incorrect, because an invoice represents a specific point in time where a sale was made.

My problem is that I would like to have 1 object that has all these properties, but don't know how to give it an accurate name. What then, should this object be called? Something generic like AggregateInvoice? How do i accurately represent all these different properties as a noun?

closed as primarily opinion-based by gnat, Erik Eidt, Jon Raynor, JeffO, Robert Harvey Oct 4 '16 at 1:36

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    If you don't mind long names, InvoiceDataGroupedByCustomerAndMaterial comes into mind (or sensible abbreviations). – Eiko Oct 3 '16 at 18:57
  • MaterialSoldToCustomer? Or actually you seem to be grouping by the salesman and the manager as well so maybe MaterialSoldByPeopleInvolved? – kamilk Oct 3 '16 at 19:06
  • InvoiceSummaryByCustomerAndMaterial? Or just InvocieSummary. Not sure of Summary or Resume can replace here (in meaning) the concept Aggregate. – Laiv Oct 3 '16 at 19:21
  • What's the name of the query? Usually the query gives an idea of what object(s) are returned. GetCustomers(), GetCustomer(customerId). That might help decide what the name of this is. – Jon Raynor Oct 3 '16 at 19:25
  • Is this another case for CQS? I'd name it sort of MaterialSalesQueryResult; i also think i'd be a good idea to make these classes immutable (since changes to instances of it would be impossbile to reflect in the DB); Basically point your OR/M to a ready-only view. – marstato Oct 3 '16 at 23:24