I need some feedback on a proposed change to StructureMapConfiguration

4 views
Skip to first unread message

Jeremy Miller

unread,
Sep 14, 2008, 3:34:41 PM9/14/08
to structuremap-users
I've come to the conclusion that StructureMapConfiguration is an
abomination and I'm seriously considering eliminating it, but before I
do anything radical, I want some feedback from you, the users.

Proposal:

* Eliminate StructureMapConfiguration in favor of:

ObjectFactory.Initialize( x => {
x.PullConfigurationFromAppConfig = true;
x.IncludeConfigurationFromFile("some file name");
x.AddRegistry( new WebRegistry() );
});

ObjectFactory.Configure(r => {
// where "r" is a Registry object and you have the whole range of
ForRequestedType() stuff for configuration
});

WHY?

* People are getting confused about StructureMapConfiguration v.
ObjectFactory. StructureMapConfiguration stuff only takes effect
before the very first call to ObjectFactory, then it's quietly
ignored. It's a mess.

* I'm having to duplicate some code between Registry and
StructureMapConfiguration that is smelly

* I think the Registry approach is smarter anyway

* Stuff like
"StructureMapConfiguration.ForRequestedType<IFoo>().TheDefaultIsConcreteType<Foo>()"
should ONLY be done in Registry objects.


I KNOW THAT THIS WOULD BE A BREAKING CHANGE, BUT AT LEAST YOU'D BE
ABLE TO DO A LOT OF IT WITH A SWEEP OF FIND AND REPLACE

I might keep
StructureMapConfiguration.ForRequestedType<T>().TheDefaultIsConcreteType<U>()
and kill the rest

Colin Jack

unread,
Sep 14, 2008, 4:17:10 PM9/14/08
to structuremap-users
Only been using SM for a couple of months but seems sensible to me.

Actually while you're making breaking changes I thought I should bring
up the fact that I've found is that the fluent interface(s) can be a
bit inconsistent in places. I'm guessing this is because different
parts of it have evolved separately but because they look different
I've gotten lost a few times which is a pity because once you find the
correct path through the fluent interface you get beautiful results. I
could probably provide some examples (didn't think to note them when I
noticed them), but if its just me who thinks it then it can't be a
real issue.

On Sep 14, 8:34 pm, Jeremy Miller <jeremydmil...@yahoo.com> wrote:
> I've come to the conclusion that StructureMapConfiguration is an
> abomination and I'm seriously considering eliminating it, but before I
> do anything radical, I want some feedback from you, the users.
>
> Proposal:
>
> * Eliminate StructureMapConfiguration in favor of:
>
> ObjectFactory.Initialize( x => {
>     x.PullConfigurationFromAppConfig = true;
>     x.IncludeConfigurationFromFile("some file name");
>     x.AddRegistry( new WebRegistry() );
>
> });
>
> ObjectFactory.Configure(r => {
>     // where "r" is a Registry object and you have the whole range of
> ForRequestedType() stuff for configuration
>
> });
>
> WHY?
>
> * People are getting confused about StructureMapConfiguration v.
> ObjectFactory.  StructureMapConfiguration stuff only takes effect
> before the very first call to ObjectFactory, then it's quietly
> ignored.  It's a mess.
>
> * I'm having to duplicate some code between Registry and
> StructureMapConfiguration that is smelly
>
> * I think the Registry approach is smarter anyway
>
> * Stuff like
> "StructureMapConfiguration.ForRequestedType<IFoo>().TheDefaultIsConcreteTyp e<Foo>()"

Michael Shapiro

unread,
Sep 14, 2008, 4:32:59 PM9/14/08
to structure...@googlegroups.com
This is an excellent idea: I did spend quite some time trying to get
StructureMapConfiguration to work. Your proposal would simplify a lot of
stuff for my project.

Thanks!
Michael Shapiro

Jeremy D. Miller

unread,
Sep 14, 2008, 4:34:41 PM9/14/08
to structure...@googlegroups.com
A.)  Need more documentation
B.)  Yep, it's the evolution over time.  I'm hoping to have spiffy new FI for everything with minimum confusion soon.  The old stuff will get the [Obsolete] tag
 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com


----- Original Message ----
From: Colin Jack <colin...@gmail.com>
To: structuremap-users <structure...@googlegroups.com>
Sent: Sunday, September 14, 2008 3:17:10 PM
Subject: [sm-users] Re: I need some feedback on a proposed change to StructureMapConfiguration


Only been using SM for a couple of months but seems sensible to me.

Actually while you're making breaking changes I thought I should bring
up the fact that I've found is that the fluent interface(s) can be a
bit inconsistent in places. I'm guessing this is because different
parts of it have evolved separately but because they look different
I've gotten lost a few times which is a pity because once you find the
correct path through the fluent interface you get beautiful results. I
could probably provide some examples (didn't think to note them when I
noticed them), but if its just me who thinks it then it can't be a
real issue.

On Sep 14, 8:34 pm, Jeremy Miller <jeremydmil...@yahoo.com> wrote:
> I've come to the conclusion that StructureMapConfiguration is an
> abomination and I'm seriously considering eliminating it, but before I
> do anything radical, I want some feedback from you, the users.
>
> Proposal:
>
> * Eliminate StructureMapConfiguration in favor of:
>
> ObjectFactory.Initialize( x => {
>     x.PullConfigurationFromAppConfig = true;
>     x.IncludeConfigurationFromFile("some file name");
>     x.AddRegistry( new WebRegistry() );
>
> });
>
> ObjectFactory.Configure(r => {
>     // where "r" is a Registry object and you have the whole range of
> ForRequestedType() stuff for configuration
>
> });
>
> WHY?
>
> * People are getting confused about StructureMapConfiguration v.
> ObjectFactory.  StructureMapConfiguration stuff only takes effect
> before the very first call to ObjectFactory, then it's quietly
> ignored.  It's a mess.
>
> * I'm having to duplicate some code between Registry and
> StructureMapConfiguration that is smelly
>
> * I think the Registry approach is smarter anyway
>
> * Stuff like
> "StructureMapConfiguration.ForRequestedType<IFoo>().TheDefaultIsConcreteTyp e<Foo>()"

Scott Reynolds

unread,
Sep 14, 2008, 8:12:59 PM9/14/08
to structure...@googlegroups.com
I didn't have a usage problem with StructureMapConfiguration, but I could see where you are coming from here, and if it's starting to get smelly anyway, I say better to axe it now since it's so new.

Jeremy D. Miller

unread,
Sep 14, 2008, 8:31:29 PM9/14/08
to structure...@googlegroups.com
Well, it's been in SM 2.0 since April '07, so it's not that new.  I'm going to mark it all as [Obsolete].

The new, recommended approach is:

            ObjectFactory.Initialize(x =>
            {
                x.UseDefaultStructureMapConfigFile = false;
                x.PullConfigurationFromAppConfig = true;

                x.AddConfigurationFromXmlFile("rules.xml");

                x.DefaultProfileName = "Stubbed";

                x.AddRegistry(new CoreRegistry());
                x.AddRegistry(new WebRegistry());

                // or

                x.AddRegistry<CoreRegistry>();
            });

Scott Reynolds

unread,
Sep 14, 2008, 8:45:21 PM9/14/08
to structure...@googlegroups.com
oh wow didn't realize it had been that long.

I do like this new approach

Jimmy Bogard

unread,
Sep 14, 2008, 8:57:52 PM9/14/08
to structure...@googlegroups.com
Meh, get rid of it.  It was a little strange having the duplicate interfaces, and it looked like the SMC class used a registry underneath anyway.

Jeremy D. Miller

unread,
Sep 14, 2008, 9:13:43 PM9/14/08
to structure...@googlegroups.com
The only reason I created SMC was to keep ObjectFactory simpler and keep its interface from being too cluttered.  The lambda thing does a better job all the way around.
----- Original Message ----
From: Jimmy Bogard <jimmy....@gmail.com>
To: structure...@googlegroups.com
Sent: Sunday, September 14, 2008 7:57:52 PM
Subject: [sm-users] Re: I need some feedback on a proposed change to StructureMapConfiguration

Josh Flanagan

unread,
Sep 14, 2008, 10:45:41 PM9/14/08
to structure...@googlegroups.com
Kill it, don't bother with annoying obsolete tags. Make all breaking
changes now. Advertise prominently on the 2.5 download page that it
contains breaking changes. Continue to offer downloads for previous
releases for those that do not want to adapt to the breaking changes.
For others that do want to adopt the latest, but struggle with the
breaking changes, direct them to the mailing list. We can help
developers on an individual basis - if we discover enough repeated
questions we'll publish a FAQ on the website.

ill it

Paul Batum

unread,
Sep 15, 2008, 6:45:34 AM9/15/08
to structuremap-users
For what its worth, I agree with Josh, just kill it. Prune that code
base!

On Sep 15, 3:45 am, "Josh Flanagan" <joshuaflana...@gmail.com> wrote:
> Kill it, don't bother with annoying obsolete tags. Make all breaking
> changes now. Advertise prominently on the 2.5 download page that it
> contains breaking changes. Continue to offer downloads for  previous
> releases for those that do not want to adapt to the breaking changes.
> For others that do want to adopt the latest, but struggle with the
> breaking changes, direct them to the mailing list. We can help
> developers on an individual basis - if we discover enough repeated
> questions we'll publish a FAQ on the website.
>
> On Sun, Sep 14, 2008 at 8:13 PM, Jeremy D. Miller
>
>
>
> <jeremydmil...@yahoo.com> wrote:
> > The only reason I created SMC was to keep ObjectFactory simpler and keep its
> > interface from being too cluttered.  The lambda thing does a better job all
> > the way around.
>
> > Jeremy D. Miller
> > The Shade Tree Developer
> > jeremydmil...@yahoo.com
>
> > ----- Original Message ----
> > From: Jimmy Bogard <jimmy.bog...@gmail.com>
> > To: structure...@googlegroups.com
> > Sent: Sunday, September 14, 2008 7:57:52 PM
> > Subject: [sm-users] Re: I need some feedback on a proposed change to
> > StructureMapConfiguration
>
> > Meh, get rid of it.  It was a little strange having the duplicate
> > interfaces, and it looked like the SMC class used a registry underneath
> > anyway.
>
> > On Sun, Sep 14, 2008 at 2:34 PM, Jeremy Miller <jeremydmil...@yahoo.com>

Jimmy Bogard

unread,
Sep 15, 2008, 9:15:35 AM9/15/08
to structure...@googlegroups.com
Well, except it's already in a released version.  You can still make obsolete tags cause compile errors, and provide a nice compile-time message on what to use instead.

Paul Batum

unread,
Sep 16, 2008, 7:36:17 AM9/16/08
to structuremap-users
Isn't 2.5 as of yet unreleased and contains many breaking changes?

On Sep 15, 2:15 pm, "Jimmy Bogard" <jimmy.bog...@gmail.com> wrote:
> Well, except it's already in a released version.  You can still make
> obsolete tags cause compile errors, and provide a nice compile-time message
> on what to use instead.
>
> On Sun, Sep 14, 2008 at 9:45 PM, Josh Flanagan <joshuaflana...@gmail.com>wrote:
>
>
>
> > Kill it, don't bother with annoying obsolete tags. Make all breaking
> > changes now. Advertise prominently on the 2.5 download page that it
> > contains breaking changes. Continue to offer downloads for  previous
> > releases for those that do not want to adapt to the breaking changes.
> > For others that do want to adopt the latest, but struggle with the
> > breaking changes, direct them to the mailing list. We can help
> > developers on an individual basis - if we discover enough repeated
> > questions we'll publish a FAQ on the website.
>
> > On Sun, Sep 14, 2008 at 8:13 PM, Jeremy D. Miller
> > <jeremydmil...@yahoo.com> wrote:
> > > The only reason I created SMC was to keep ObjectFactory simpler and keep
> > its
> > > interface from being too cluttered.  The lambda thing does a better job
> > all
> > > the way around.
>
> > > Jeremy D. Miller
> > > The Shade Tree Developer
> > > jeremydmil...@yahoo.com
>
> > > ----- Original Message ----
> > > From: Jimmy Bogard <jimmy.bog...@gmail.com>
> > > To: structure...@googlegroups.com
> > > Sent: Sunday, September 14, 2008 7:57:52 PM
> > > Subject: [sm-users] Re: I need some feedback on a proposed change to
> > > StructureMapConfiguration
>
> > > Meh, get rid of it.  It was a little strange having the duplicate
> > > interfaces, and it looked like the SMC class used a registry underneath
> > > anyway.
>
> > > On Sun, Sep 14, 2008 at 2:34 PM, Jeremy Miller <jeremydmil...@yahoo.com>
Reply all
Reply to author
Forward
0 new messages