Wiring objects, IoC and Service Locator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Wiring objects, IoC and Service Locator

Vitor Medina Cruz
I don't think it should. If you have a small cluster of objects where you
can manage the dependencies yourself, you can compose larger objects from
them and manage the dependencies the same way. By doing so, you'll get an
object that is simpler from the outside than it's parts in the inside, and
you'll need to solve the smaller problem again. In other words we shouldn't
write large software, but compose large software from smaller ones. But the
same can be done with objects (that's why I'm not a big fan of microservices
despite they solve this problem similarly).
If you have a flat structure (where objects don't form higher level
abstractions) and everything needs to know about everything else, then the
DI container will make it easier to work with this structure. But I don't
think this is the right way to organize a software.

Yes, that makes sense....


1. Blocks (i.e. anonymous functions) means that one needs not necessarily
implement a /Class/ (MovieFinder), in order to vary alternative behavior,
unlike Java (before 8).
 
2. If one does want a number of "finders" (as Classes), then one will
typically see one "injected" (constructor or method injection), where each
understands some common "find" message.
 
Is the real question for 2 above, "what (or who) decides" which will be
injected?


Finder is just an illustration of the problem, that finder class can have much more behavior in a real example, such as a DAO or a Repository would have, and blocks could't be used properly to deal with that. 

cheers,
Vitor





On Sat, Jun 10, 2017 at 8:59 AM, aryehof <[hidden email]> wrote:
In SmallTalk:-

1. Blocks (i.e. anonymous functions) means that one needs not necessarily
implement a /Class/ (MovieFinder), in order to vary alternative behavior,
unlike Java (before 8).

2. If one does want a number of "finders" (as Classes), then one will
typically see one "injected" (constructor or method injection), where each
understands some common "find" message.

Is the real question for 2 above, "what (or who) decides" which will be
injected?



--
View this message in context: http://forum.world.st/Wiring-objects-IoC-and-Service-Locator-tp4949280p4950768.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Wiring objects, IoC and Service Locator

aryehof
Consider that in Java, one can only achieve polymorphic behavior across objects by using interfaces or inheritance.  In Smalltalk one can achieve polymorphic behavior across objects just by having them understand the same message.

The need to have complex schemes for the wiring of objects in Java is a consequence of this.
Reply | Threaded
Open this post in threaded view
|

Re: Wiring objects, IoC and Service Locator

Vitor Medina Cruz
Yes, I  can understand that, but I will have to practice more with Smalltalk to comprehend better.

Still I think there are some objects used by large bits of the application that would benefit the design if they have it's creation decoupled and somehow organized, but I am convinced that a simple service locator would do the job :)

On Tue, Jun 13, 2017 at 3:29 AM, aryehof <[hidden email]> wrote:
Consider that in Java, one can /only /achieve polymorphic behavior across
objects by using /interfaces /or /inheritance/.  In Smalltalk one can
achieve polymorphic behavior across objects just by *having them understand
the same message*.

The need to have complex schemes for the wiring of objects in Java is a
consequence of this.



--
View this message in context: http://forum.world.st/Wiring-objects-IoC-and-Service-Locator-tp4949280p4951174.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Wiring objects, IoC and Service Locator

Ben Coman


On Wed, Jun 14, 2017 at 3:39 AM, Vitor Medina Cruz <[hidden email]> wrote:
Yes, I  can understand that, but I will have to practice more with Smalltalk to comprehend better.

Keep some notes.  When you get to the end and you've had a good soaking in Smalltalk, it would be good to read of how your thinking adapted on your journey from Java to Pharo.
It harder to think back to what you once didn't know.  

cheers -ben
 

Still I think there are some objects used by large bits of the application that would benefit the design if they have it's creation decoupled and somehow organized, but I am convinced that a simple service locator would do the job :)

On Tue, Jun 13, 2017 at 3:29 AM, aryehof <[hidden email]> wrote:
Consider that in Java, one can /only /achieve polymorphic behavior across
objects by using /interfaces /or /inheritance/.  In Smalltalk one can
achieve polymorphic behavior across objects just by *having them understand
the same message*.

The need to have complex schemes for the wiring of objects in Java is a
consequence of this.
12