Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,464 of 10,840    |
|    Dikkie Dik to Iain Bishop    |
|    Re: Object Model Problem    |
|    03 May 05 13:22:08    |
      From: nospam@nospam.org              You did quite well, I think. The fact that assemblies contain       assemblies, and therefore do not have a defined ending level is true,       and not a problem.       Do not search. Let the object model itself do the search for you. For       instance: the TotalPriceOfAllMaterials could easily be a property of       both the materials collection and the assemblies collection. As an       assembly is only made up of subassemblies and materials, You just add       the totals form both collections. The collections are then responsible       to get the totals from all their members. This "drills down" to every       level automatically (this technique is called the Propagation Pattern).       If you are searching for something, just pass down an empty results list       and let the collections fill it.       This may seem a bit performance-heavy, but it isn't. Especially if the       number of possible hits is limited (like searching for an ID), a       collection can stop searching when the limit is reached, thereby       preventing other collections to start an unnecessary search.              There is no risk for an infinite number of assemblies, unless a       subassembly can have a "parent" assembly as one of its own subassemblies       (or even itself as a subassembly). Like a tree, it can grow as many       twigs as it has the chance to, but it will remain finite.               > 4. I'm also having problems imagining how I would go and find a        > material if its 'Quantity Requested' has changed, given that it        > could be any number of levels down.              Good question. I think the answer does not lie in your object model yet,       but in the real world. Who changes the 'Quantity Requested' property?       And how does he know about it? Materials may be part of the       assembly-structure, but also part of, say, a bill of materials. If the       same instances are used, updating them in the bill of materials       automatically updates them in the assembly structure.              This may also be an alternative answer to the update question; if the       materials are also in a list, it may be easier to update them there.              Do not be afraid to start with an object model that is not perfect. You       can always refine as you work on it. Speaking from my own experience, it       is better to improve a simple scheme than to try to do a "Big Design       Upfront". Just keep asking what responsibility should lie in what class       and you can solve most questions.              Best regards                     Iain Bishop wrote:       > I'm trying to model objects for the following problem:       >       > A building site contains assemblies, each of which can contain other       > assemblies and/or materials.       >       > I have modelled this using a Site class, Assembly class, and Material class       > as follows...       >       > Site Class (clsSite):       > Option Explicit       > 'General Details       > Public ProjectNumber As String       > Public SiteWBSCode As String       > Public SiteType As String       > Public LastUpdateFirstName As String       > Public LastUpdateSurname As String       > Public LastUpdateDate As Date       > Public TotalPriceOfAllMaterials As Double       > Public GeneralNotes As String       > 'Contents of Site       > Public SiteAssemblies As clsAssemblies 'a collection class of clsAssembly       > Public SiteMaterials As clsMaterials 'a collection class of clsMaterial       >       > Assembly Class (clsAssembly):       > Option Explicit       > 'General Details       > Public ID As Long       > Public QuantityRequested As Integer       > Public QuantityIssued As Integer       > 'Contents       > Public AssemblyAssemblies As clsAssemblies 'a collection class of       > clsAssembly       > Public AssemblyMaterials As clsMaterials 'a collection class of clsMaterial       >       > Material Class (clsMaterial)       > Option Explicit       > 'General Details       > Public InventoryCode As String       > Public Rate As Double       > Public QuantityRequested As Integer       > Public QuantityIssued As Integer       > Public TotalPrice As Double       > Public DateAmended As Date       >       > My questions are:       > 1. Have I modelled the problem correctly?       > 2. There is the potential for an infinite hierarchy of Assemblies - is this       > ok?       > 3. If so, I am having problems imagining how I would iterate through say all       > the materials to update their 'Rate' for example.       > 4. I'm also having problems imagining how I would go and find a material if       > its 'Quantity Requested' has changed, given that it could be any number of       > levels down.       >       > I've spent hours without making much progress. Please help if you know the       > answer to any of these questions.       >       > Many Thanks       > Iain       >       >              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca