mktany2k / funcito

Automatically exported from code.google.com/p/funcito
0 stars 0 forks source link

commentary on architecture #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I find myself trying to write Funcito, fittingly, in a functional style. To me, 
this means as little state as possible and preferably immutable state.

This is manifested in constructions like this:

new InvocationManager().pushInvokable(i);

Interestingly, I'm reasonably certain that we can reduce the state of Funcito 
down to:

(a) lone Invokable pointer in InvokableState
(b) StubFactory instance
(c) cache maps in StubFactories

I find this elegant, to the point where I am questioning (c), but more on that 
in another note.

The main 'rub' right now is that I would like to have Funcito create 
FuncitoDelegate in the constructor style as shown above. Same thing with 
InvocationManager and InvokableState.

Note that a trivial constructor is super-fast. One NFJS speaker said it is 10 
bytecode operations.

Original issue reported on code.google.com by codeto...@gmail.com on 30 Nov 2011 at 1:54

GoogleCodeExporter commented 9 years ago
Ironically I just checked in changes to remove this style, *before* I noticed 
this Issue :-) Sorry.  I am open to considering it.  I just don't see the value 
at this point.  With re-entrant methods, I don't see the harm in reusing 
once-constructed stateless objects, and you do save the construction AND 
garbage collection thrashing.  You will have to do a little more convincing to 
me on this one.  I'll leave the issue open for now...

Original comment by kandpwel...@gmail.com on 30 Nov 2011 at 5:57

GoogleCodeExporter commented 9 years ago
Re: garbage-collection thrashing. This is wild speculation. We would have to 
profile to show evidence of that, and I bet that there will be no issues. 
Objects are inexpensive on modern JVMs.

My position is more objective: with respect to thread-safety, it is easier to 
reason about state if there is less state. This library could be reduced to the 
3 items listed above. (Admittedly, my sense of aesthetic and functional style 
is indeed subjective.)

Original comment by codeto...@gmail.com on 30 Nov 2011 at 12:00