On Aug 15, 2014, at 10:12 AM, Ben Goodrich <
goodri...@gmail.com> wrote:
> On Friday, August 15, 2014 12:04:59 AM UTC-4, Bob Carpenter wrote:
> On Aug 14, 2014, at 5:50 PM, Ben Goodrich <
goodri...@gmail.com> wrote:
> > On Thursday, August 14, 2014 4:12:10 PM UTC-4, Bob Carpenter wrote:
> > See:
> >
> >
http://en.wikipedia.org/wiki/God_object
> >
> > - Bob
> >
> > I understand what you are saying, but to some extent, it is necessary to preserve the existing stan() behavior and the make-like behavior Andrew wants.
>
> > You can have the stanfit object that comes out of stan() consist of a stanmodel object, a config object, a data object, a coda-like object for the samples, vectors of names, etc. But stan() can't do all the make-like behavior and just output the coda-like object because the all the other objects would be local to stan().
>
> I thought the only "make-like" behavior on the table was not
> recompiling models if there's already a shared object/dll lying
> around. So I'm not seeing where a single big object through which
> every operation is carried out is needed in the design.
>
> Just having a stan() function that inputs a path, config, and data means those little objects would have to be instantiated and if they are not returned along with the coda-like object as part of a bigger object, then they get garbage collected.
I don't see any reason to save those things in memory.
There is the issue of which compiled models we save and which
we toss --- we don't want to clutter up someone's file system
every time they do a Stan run.
> > I don't think the omniscience of a God object is a big problem, but omnipotence could potentially be. So, you need to lock down the parts that should be changed, validate whatever might be mutable, flush output that was specific to the previous run, etc.
>
> The omniscience is a problem. If the big object returned by stan()
> needs to know about the insides of the components it holds onto
> and provide methods itself to configure them and reuse them, I think
> it's going to be a mess to document and maintain.
>
> It isn't going to be much worse that it is now. As Allan pointed out, log_prob and gradient should really be methods for a stanmodel not a stanfit.
I completely agree.
> But if we define log_prob and gradient methods for a stanfit that don't do anything but call the log_prob and gradient methods for a stanmodel, then we just have to change things in one place.
We don't need or want that higher-level method. If the stanfit just has a handle on the
stanmodel, then we don't have to write two functions, two sets of doc, two sets of tests,
or change things anywhere in the container when we change the stanmodel object.
> For documentation, I think the format of R documentation for S4 classes and methods is basically worthless,
You won't get any argument there.
> so being able to document reference class methods Python-style is a lot easier for the developer and a lot more useful for the user.
I think reference classes are the way to go --- I'd assumed that's
what S4 did.
For doc, I think it makes sense to have objects with methods (e.g., stanmodel
with log prob, gradient and Hessian methods), then document those methods on
the object. I'm not familiar with what you mean by Python style, but that's
what Javadoc (built in) does for Java and doxygen does for C++.
- Bob