On Tue, Jun 6, 2017 at 9:11 PM, Vitor Medina Cruz <vitormc...@gmail.com>
wrote:

> Thanks for the detailed answer ben :)
>
> I will try to clarify a little: the question is how to loosely wire
> objects, such as MovieLister to MovieFinder, so that changes in the wiring
> can be made without effort. In Java, people use DI containers and xml files
> or annotations to provide the wiring configuration, which is easy to switch
> entirely. For example, I could have a xml file for production code and
> another for testing purposes.
>
> Also, another advantage is that the container takes care of ordering
> object creation for me. For example, if the object A, B and C needed to be
> injected on the object Y, I just have to declare each one of those objects
> on the configuration file, the container arranges the creation order for
> me.
>

I don't see what is special about this.  You can easily arrange instance
creation order with methods on the class-side of your domain classes.
Indeed, the GTTools are set up to work with in-Image sample data.  Look at
implementors of #sample and #example.
There was quite some bike-shedding over the naming convention (and I forget
the final result), but hopefully it provide the general idea...

http://forum.world.st/a-request-to-change-the-meaning-of-lt-example-gt-pragma-td4927360.html
http://forum.world.st/lt-example-gt-lt-examplar-gt-td4911728i20.html
http://forum.world.st/Existing-lt-script-gt-lt-example-gt-pragmas-and-new-GT-needs-td4814903i20.html



>
> I started, however, to question DI as a valid mechanisms because of it's
> complexities and other problems. The article from Fowler provides the
> service locator as an alternative which seems to me much simpler and
> completely fine solution for the problem.
>

If it seems suitable, then to quote Nike, just do it ;)



> So, to answer you question "Is it any more complicated than that?": In
> the DI approach, yes it can be, but I don't think so in the service locator
> approach.
>
> I am asking here because I wanted to know how people from Smalltalk deal
> with this problem. As it seems there is no standard approach, nor this is
> perceived as a problem...
>


DI or Service Locator are both "implementations" of your need.  Can we take
step backward to see what is your need?  To kick off, I hazard a guess at
some possible needs...

1.  To switch between configurations to use production data and test data ?
2.  To make this switch during CI testing and production deployment ?
3.  To switch from the command line ?
4.  Want the configuration to editable remotely? e.g. from a text editor?
?
...



> You think it is enough to do the wiring by hand?
>

I'm having trouble understanding this "by hand" concept.
Don't you create the xml configuration file by hand?
You can just as easily



> It is ok to use a service locator approach?  Or wouldn't you care about
> that?
>

If it works, its okay.

So very generally, I'd avoid starting with any external test data, so as to
not distract myself by that implementation.
I'd copy-paste some test data into the class-side-methods of the domain
classes and hack some instance creation code around them.
Build your first tests around those. Then later, consolidate them via an
InImageTestData object that you'll later replace with ExternalTestData



>
>
> but I'll add, it was so much simpler to understand without all that Java
>> typing boiler plate.
>
>
> Yeah, that's for sure! I am just used to read Java code.
>
> []s,
> Vitor
>
>
>
As an aside, try evaluting "Smalltalk tools inspect"
and debugging "Smalltalk tools browser open"

cheers -ben

Reply via email to