Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

son of magic code in initAndValidate #25

Open
tgvaughan opened this issue Jan 19, 2014 · 2 comments
Open

son of magic code in initAndValidate #25

tgvaughan opened this issue Jan 19, 2014 · 2 comments

Comments

@tgvaughan
Copy link
Member

I see this code in ClusterTree.java

public void initAndValidate() throws Exception {

    if (Boolean.valueOf(System.getProperty("beast.resume")) &&
                (isEstimatedInput.get() || (m_initial.get() != null && m_initial.get().isEstimatedInput.get()))) {
   ...
}

Is that the best we can do for beast2 implementers?
If so, it should be prominently documented (I was not aware of this issue until now).
It would be nice if the code knew not to call the initAndValidate on resume, or maybe just the parts that matter? Perhaps we can separate the init into two parts (first-time and resume)? or at least pass a flag in?

@rbouckaert
Copy link
Member

There are a number of states in which initAndValidate can be called that may require different actions:

  • from BEAUti, some times there is just not enough info to initialise. A flag to indicate that we are running in BEAUti could be checked.
  • from BEAST, starting a chain,
  • from BEAST, resuming a chain when not all initialisation may be desirable, since the stored state should be used.

A global variable -- perhaps in BeastVersion? -- might do. The System.property is an less explicit alternative.

@alexeid
Copy link
Member

alexeid commented Aug 5, 2014

If there are a number of states in which initAndValidate can be called then there are two options:

(1) Separate behaviour into different methods
(2) Add an argument to initAndValidate to explicitly signal which state it is being called in.

An argument is better than global variable, since its clear to the programmer that they haven't used it when they are implementing a method. A global variable can easily be overlooked or not known about when implementing a method.

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

No branches or pull requests

3 participants