Object-Oriented philosophy problem

  • Thread starter Thread starter Sojourner01
  • Start date Start date
  • Tags Tags
    Philosophy
Click For Summary
SUMMARY

The discussion centers on a Monte Carlo simulation tool constructed using object-oriented techniques in Visual C#. The user has developed a Lattice class containing a 3D array of Site objects, which in turn reference their neighbors. The user recognizes that the current object hierarchy is inefficient and seeks to restructure it to facilitate Monte Carlo transformation methods. A suggested solution involves either having the Site class reference the parent Lattice or using a Factory model to instantiate Sites with their neighbors correctly linked.

PREREQUISITES
  • Understanding of object-oriented programming principles
  • Familiarity with Visual C# programming language
  • Knowledge of Monte Carlo simulation techniques
  • Experience with 3D array data structures
NEXT STEPS
  • Research object-oriented design patterns, particularly the Factory pattern
  • Learn about Monte Carlo simulation implementation in C#
  • Explore data structure optimization techniques for 3D arrays
  • Study reference vs. value assignment in C# to clarify object linking
USEFUL FOR

Software developers, particularly those working with simulations, object-oriented design, and C# programming, will benefit from this discussion.

Sojourner01
Messages
371
Reaction score
0
I have a problem in constructing a program. The principle is a monte carlo simulation tool using object-oriented (or, strictly I suppose, object-based) techniques written in Visual C#.

So far my object hierarchy is constructed as follows:

A Lattice class, which contains:
A 3-dimensional array of Site objects

A Site class, instances of which have:
two booleans to define whether they're i) valid in an FCC lattice ii) occupied by anything
A 3-dimensional array of other Site objects defining its neighbours

A Polymer class, which contains:
An array of Monomer objects

A Monomer class, instances of which have:
A Site object defining where they are

I have come to the conclusion that this system is a mess and doesn't define things in a way that can be acted on by Monte Carlo transformation methods I plan to implement. I've walled myself in here, and it's going to take a considerable amount of work to restructure this program to get it to work.

At the very least, I want to get the 'neighbours' array of each monomer to point to Site objects in the Lattice's array of sites. I'm not sure how to do this. I don't want to use lookup tables, since they're arbitrary and not very portable.

I appreciate that this topic is a bit of a mouthful, so please do inquire if - which will almost certainly be the case - my explanation is unclear or lacking.
 
Technology news on Phys.org
Can you explain a little bit better why you're having difficulties with setting the neighbours array to point to the neighbour sites on the Lattice? You can either have the Site class keep a reference to the parent Lattice, in which case it can use something likemyLattice.GetSite(mySite.X+1, mySite.Y+1, mySite.Z+1) to get neighbors, or you can have the Site constructor take in the array of neighbours as a parameter - and use a Factory model to instantiate Sites - the Lattice class would have a method GetSite(x, y, z) which instantiates a Site instance, populates the neighbours array and returns it.
 
Apologies for my blind ignorance; I've realized in the last 24 hours how staggeringly simple my error was. There isn't a problem with saying array2[n] = array1[not necessarily n], when they're both arrays of references to the same object type. For some reason I conceptualise the = operator as assignment by value when it's really stating a link between reference and object.

My programming still a maze, s i may have to check back here for some more pearls of wisdom in tidying it up.
 

Similar threads

  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 25 ·
Replies
25
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 7 ·
Replies
7
Views
12K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K