Create a read-only child?

Create a read-only child?

Old forum URL: forums.lhotka.net/forums/t/1308.aspx


Michael Hildner posted on Friday, September 22, 2006

Hi,

I'm sure I have a design issue, but I can't figure out the best way to accomplish without hacking things up quite a bit. Looking for advice.

Here's the use case. A Slot Machine Technician needs to record access information on a Slot Machine, for example, when they open it up to change the software. The Technician needs to be able to scan a barcode on the Slot Machine. When they do this, the system should display information about the Slot Machine, such as manufacturer, installed software etc.

The objects of interest are:
SlotMachineAccessEditableRoot - has properties about why a Slot Machine was accessed
SlotMachineReadOnlyChild - a property of the above object

In the database, there's a foreign key relationship between SlotMachineAccess.SlotMachineFK and SlotMachine.SlotMachinePK.

My issue is when I'm creating a new SlotMachineAccessEditableRoot. I need to have an new, empty SlotMachineReadOnlyChild just so some properties can be displayed on the form. I can't just create a ReadOnlyChild, so I've hacked it up so I could, and when the bar code number gets scanned, the system fetches a SlotMachineReadOnlyRoot, then uses that object to populate the properties of the SlotMacineReadOnlyChild.

While I've got something working, it feels wrong to create a read-only child, but that's what it is, at least in my mind. Any thoughts are appreciated.

Thanks,
Mike

RockfordLhotka replied on Saturday, September 23, 2006

I don't see where this is a problem - other than that I'm not sure you have an actual "parent-child" relationship as much as a "using" relationship. But that's more a matter of semantics than implementation.

If it would make you feel better (Smile [:)]) you could use a seperate factory object to go get your EditableRoot (SlotMachineER) and a ReadOnlyRoot (SlotMachineRO) in a single fetch call:

Dim factory As MyFactory = MyFactory.GetObjects(...)
Dim er As SlotMachineER = factory.ER
Dim ro As SlotMachineRO = factory.RO

SlotMachineER would, of course, be savable like any normal editable root, but it wouldn't have a public Get___() method - forcing the use of the factory. The same for the read only root.

Copyright (c) Marimer LLC