50 likes | 179 Views
example. business contracts. Object-Oriented Problem Analysis. customer of each contract is a person or a company. Object-Oriented Implementation. the attribute „totalPrice“ will be implemented as a method.
E N D
example business contracts
Object-Oriented Problem Analysis customer of each contract is a person or a company
Object-Oriented Implementation the attribute „totalPrice“ will be implemented as a method there is no need to inherit Person and Company from some common superclass. In pure object-oriented database, they will be polymorphic only because of the same attributes they have.
The Database Code doit UserGlobals at: #Customers put: Set new. UserGlobals at: #Contracts put: Set new. UserGlobals at: #Products put: Set new. % doit | pc1 pc2 pc3 cc1 cc2 x1 x2 x3 x4 x5 x6 x7 p1 p2 p3 p4 c1 c2 c3 c4 | pc2 := Person new. pc2 name: 'Peter'; surname: 'Green'; address: 'Easton'. … x1 customer: pc1; product: p1. x2 customer: pc1; product: p1. … p1 producer: c1. p2 producer: c2. … Customers add: pc1; add: pc2; add: pc3; add: cc1; add: cc2. Contracts add: x1; add: x2; add: x3; add: x4; add: x5; add: x6; add: x7. Products add: p1; add: p2; add: p3; add: p4. % commit
Some Queries select all customers from Prague Customers select: {:c | c.address = 'Prague'} select all contracts with total price > 100 Contracts select: [:c | c totalPrice > 100] select all product producers of contracts with total price > 100 (Contracts select: [:c | c totalPrice > 100]) collect: [:c | c product producer] select all contracts related to product from Boston Contracts select: {:c | c.product.producer.address = 'Boston'}