Skip to content

expose dynamical_system's module names#16

Open
leavesandlemmas wants to merge 2 commits intobiocro:mainfrom
leavesandlemmas:update-api
Open

expose dynamical_system's module names#16
leavesandlemmas wants to merge 2 commits intobiocro:mainfrom
leavesandlemmas:update-api

Conversation

@leavesandlemmas
Copy link
Copy Markdown

Added API methods to dynamical_system. I am doing a pull request because I can't publish branches on framework and I have a branch on biocro/biocro that doesn't compile unless these methods are added.

@eloch216
Copy link
Copy Markdown
Contributor

Back in the olden days, the BioCro development team had some discussions about methods like these.

Justin and Scott R. were of the opinion that a class shouldn't have a getter method that simply returns argument values that were passed to the class constructor. They are unnecessary because in principle, the user should already know these values. I used to think otherwise, but I was convinced by this line of reasoning.

In this particular case, the user must already know the names of the direct and differential modules, since they must have passed these to the dynamical system constructor.

Just wondering -- what's the reason for adding these getter functions?

@leavesandlemmas
Copy link
Copy Markdown
Author

The reason is to serve as an example of what I talk about it #15 The getter functions are simple to implement.

I don't think that this particular getter function is particularly useful. But I am not sold on the general principle you describe. Consider an counterexample: the std::vector has a method size which returns the size of the vector. Isn't this method unnecessary since if you create a vector and add elements to it, then you would already know its size, at least in principle?

But clearly it is useful because a function that accepts a vector might need to know its size, even though the function didn't create it. Internally, std::vector keeps track of its size as part of its own state, so it makes sense to allow users access to that information, without being able to modify it (while std::vector has to modify its internal size). Otherwise, a user would always have to pass the vector and the vector's size, while making sure these remained consistent.

So getter functions for BioCro dynamical_system don't make sense if run_biocro is the only way to create a dynamical_system, but if any code that operates on the dynamical_system needs to know the names of the modules or whatever, then the user would have to pass the information that was used to create dynamical_system with an instance of (or pointer /reference to) dynamical_system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants