matthiasbock / BooleSim

Systems biology tool: Boolean network simulator
http://matthiasbock.github.io/BooleSim
11 stars 6 forks source link

Object oriented design #8

Open chaitan3 opened 11 years ago

chaitan3 commented 11 years ago

The current design of the code is messy, make it more object oriented, taking cues from biographer-ui.

@matthiasbock, I would like to know the reasons for abandoning the simulator object. I agree it was quite big and needed to be broken down into parts, but this should be done gracefully and not the way it is now.

matthiasbock commented 11 years ago

I had problems with object links, so as we currently only have one simulator running at a time anyway, I worked around these by calling plain functions and removed the object. There also were functions in it, that didn't belong inside the object. I don't remember what the problem was right now, I think I had trouble with the window.setTimeout() function, which wouldn't call object child functions or so, have to look at the code history what it was ...

I believe though, that it only makes sense to make the Simulator an object, if we gain the ability to run an arbitrary number of simulators at once, without them colliding on "shared" global variables.

But generally I think you are right, it would be better getting it to work in an object oriented way.

chaitan3 commented 11 years ago

The reason for making the code object oriented is not because we want multiple simulator objects, it's for code clarity and easier debugging. For example I had used the network variable as a global variable to store the bui.Graph object and the network rules were stored in a private variable called net of the simulator object. Now when you dismantled the object to individual function/variables and renamed net to network, this resulted a clash between the two variables and it took a bit of time to debug the problem. I just wanted to show that as softwares grow complex OOP design is imperative and we should not delay adopting it.

Also window.setTimeout should be able to call public functions of objects, I had already done this in the code in other places. Now, reconstructing the code to OOP design will take time and effort, but I still think that it should be done for the paper as our software will look more professional.

matthiasbock commented 11 years ago

I see. I guess I messed up your code concept there. Sorry, didn't mean to do so. We can still go for OOP for the paper, if you prefer.