home bbs files messages ]

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,466 of 10,840   
   Iain Bishop to Steve Gerrard   
   Re: Object Model Problem   
   03 May 05 21:57:54   
   
   From: iebishop@yahoo.co.uk   
      
   Thanks a lot Dikkie and Steve for your responses. Its very much appreciated.   
   I'm beginning to get an idea of what I need to do now.   
      
   Steve, you mentioned interfaces. I know of them but have never used them, so   
   am not familiar with them or how they could help. Would you mind explaining   
   how I could use them?   
      
   Thanks   
   Iain   
      
      
   "Steve Gerrard"  wrote in message   
   news:bIydndr-47elFerfRVn-1Q@comcast.com...   
   > Some general comments and ideas to consider:   
   > ---   
   > Something like TotalPriceOfAllMaterials should probably be a method, not a   
   > variable. Unless you have a serious performance problem, it will be   
   cleaner to   
   > actually add up all the material costs each time, rather than storing it   
   and   
   > trying to make sure it stays updated.   
   > ---   
   > If you are familiar with Interfaces, or willing to become so, they could   
   make   
   > your model easier. If you had an interface called IMaterial, for instance,   
   then   
   > the Assembly class and Material class could both implement it. This would   
   allow   
   > you to have a single collection that was a mixture of Assembly and   
   Material   
   > objects. I can explain more about it if you are interested - it is not   
   difficult   
   > to do.   
   > ---   
   > Your Site class does not need to repeat the structure of an Asssembly - it   
   can   
   > simply contain one. So you could have   
   >   
   >  'Contents of Site   
   > Public SiteAsm As clsAssembly   
   >   
   > which would give you   
   >     SiteAsm.AssemblyAssemblies   
   > and   
   >     SiteAsm.AssemblyMaterials   
   >   
   > and avoid duplication of code.   
   >   
   > Remember that your user does not have to know that the entire material   
   structure   
   > of a site is being treated as a single assembly; it is just a programming   
   > convenience. Object design should serve the programmer's purposes, not the   
   end   
   > user's. You could then put TotalPriceOfAllMaterials in the Assembly class,   
   as   
   > described in the post from Dikkie Dik.   
   > ---   
   > There is nothing wrong with adding an object reference to two collections   
   (you   
   > only need to make sure that you don't create a cross reference, where two   
   > objects have references to each other).   
   >   
   > So, if you are adding a clsMaterial object to some assembly, you can also   
   add it   
   > to a separate MasterList:   
   >     Dim MasterList As clsMaterials   
   >     Dim Site As clsSite   
   >     Dim Mat As clsMaterial   
   >   
   >     Set Mat = New clsMaterial   
   >     Site.SiteAssemblies(2).AssemblyAssemblies(4).AssemblyMaterials.Add Mat   
   >     MasterList.Add Mat   
   >   
   > This means you can find a material by drilling down through the Site   
   structure,   
   > or by looking in the MasterList. Both collections contain a reference to   
   the   
   > same object, so any changes to it would be seen from either vantage point.   
   You   
   > could even make MasterList a property of the Site class.   
   > ---   
   >   
   > "Iain Bishop"  wrote in message   
   > news:lKyde.956$31.558@news-server.bigpond.net.au...   
   > > 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