I'm basically new to OOP and besides a few programming basics in C++ have no experience whatsoever. For a college project I'm working on a physical simulation of the magnetic interactions of multiple protons.
My goal is to learn as many concepts and aspects to programming and apply those to my system. So what Ive been doing so far is reading into different design patterns and generally on how to approach such a project. Which only expanded my list of questions :D
I'm currently working of my class diagram. Basically my idea was to create a physObject
class that implements different behaviour
-interfaces. So in my case, all the Protons
will implement MagneticBehaviour
. I wanna try to create my design as loosely coupled as possible because I wanna provide reusability and flexibility. Later on it should be possible adding i. e. GravitationalBehaviour
to simulate the gravitational behaviour of physical objects.
This is my scetch of a class diagram. As I said I've tried to encapsulate the different variables needed into objects and applied the strategy pattern to make the calculations flexible based on the context of the simulation.
What I dont get is how to connect the classes. I.e. for the caclulation of the ActingBField
, however that will be implemented, you'll need information of the distances to other physObjects
. Also each time i.e. the location of a physObject
changes, the ActingBField
has to be calculated on every phsyObject
that exists.
So it seems like I'll need to have a system, that automatically passes information within objects, if the value of an object changes. Which will kind of be a recursive pattern. So my first approach was to make physObject
an Observable
and every Behaviour
-interface will be an Observer
observing the variables needed. Then I've read into event-/ case-/ state-driven programming (not sure about the difference), which seems like a nice approach. I have no idea though how I would even visualize that kind of system in an uml diagram tbh.
Last but not least, all I've been doing so far is focus on the physical model of the simulation. However I figured I'll need to find a way to connect this model with some kind of user, that i.e. sets the time period of the simulation or selects which data to look at. How would that connection look like?
I'm really happy for any help, even a concept to look at would help tremendously since I'm really struggling to find any information.
Thanks for reading :)
Aucun commentaire:
Enregistrer un commentaire