Who uses IoC, MEF, DI, Decorator Classes?

R

RayLopez99

I must say I have to eat my words when I said a while ago that the Gang of Four patterns are by-and-by useless, except for the Composite Class template. I am using Decorator Classes more and more. Further, on the advice of a friend I studied "Dependency Injection in .NET", MARK SEEMANN, and some articles on the MEF framework in C#, and am using this framework now, to my benefit.

Who here knows or uses IoC, MEF, DI? The way I see it, as a tyro, MEF is asort of way of using interfaces as a sort of polymorphism. Sort of. Right now I am only "Exporting" and "Importing" stuff, using [attributes], and am not simultaneously importing and exporting out of the same class (which I believe you can do, but it gets too confusing to me).

Further, I tested a MEF demo program I wrote and found it is just as fast as a "hardwired" program that does not use MEF. In fact, for some strange reason (related to the Intermediate Language of C#), MEF is actually slightly faster, which is completely counter-intuitive. It's like what I found out when using "new"--you would think that in a loop, using 'new' every time would be hideously slow, but that is not the case often. This is not to beconfused with the immutable String vs Stringbuilder argument however (the latter is much faster in a loop).

RL
 
R

RayLopez99

On Friday, October 18, 2013 10:42:10 AM UTC+8, RayLopez99 wrote:
"The way I see it, as a tyro, MEF is a sort of way of using interfaces as a sort of polymorphism. Sort of. "

By this I mean: compile time polymorphism, like you get with <Templates>, as opposed to run-time polymorphism. Or so it seems to my mind. Anyway, I am very happy with MEF so far, and it's easy to learn.

RL
 
A

Arne Vajhøj

I must say I have to eat my words when I said a while ago that the
Gang of Four patterns are by-and-by useless, except for the Composite
Class template. I am using Decorator Classes more and more.
Further, on the advice of a friend I studied "Dependency Injection in
.NET", MARK SEEMANN, and some articles on the MEF framework in C#,
and am using this framework now, to my benefit.

Who here knows or uses IoC, MEF, DI?

I would expect >90% of professional development to use IoC/DI
to some extent.

MEF is one framework, but it is more an extension/plugin
framework based on DI than a pure DI framework.

But there are many other DI frameworks: Spring.NET, Castle,
NInject, StructureMap, Unity etc..
The way I see it, as a tyro,
MEF is a sort of way of using interfaces as a sort of polymorphism.
Sort of. Right now I am only "Exporting" and "Importing" stuff,
using [attributes], and am not simultaneously importing and exporting
out of the same class (which I believe you can do, but it gets too
confusing to me).

Further, I tested a MEF demo program I wrote and found it is just as
fast as a "hardwired" program that does not use MEF. In fact, for
some strange reason (related to the Intermediate Language of C#), MEF
is actually slightly faster, which is completely counter-intuitive.
It's like what I found out when using "new"--you would think that in
a loop, using 'new' every time would be hideously slow, but that is
not the case often. This is not to be confused with the immutable
String vs Stringbuilder argument however (the latter is much faster
in a loop).

There must be some overhead. But it is usually completely
insignificant for overall application performance.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top