IoC. A few questions ...

S

shapper

Hello,

I am starting with IoC and I am creating modules as follows:

private class DomainModule : NinjectModule
{
public override void Load()
{
Bind<IProductRepository>().To<ProductRepository>();
}
}

private class ApplicationModule : NinjectModule
{
public override void Load()
{
Bind<IEmailService>().To<EmailService>();
}
}

So when using IoC I suppose for all services and repositories I should
have an interface, right?
And should the interface be in the same namespace then the class
itself?
Should I separate maybe in two folders? I have no idea what do call
the folders ...

Should I call the modules differently like:
DataModule and MailModule, ...

My project has 4 levels:
Infrastructre (Basic code to all levels)
Domain (Repositories, Entities)
Application (Services to deal with Email, Flash, PDF and Image
manipulation, Google, Twitter, etc)
Presentation (Web Site)

In presentation I am injecting the repositories, services, etc on
presentation classes.

Well, I am just starting with IoC to hopefully solve some problems I
was having on my project.

Thank You,
Miguel
 
A

Arne Vajhøj

I am starting with IoC and I am creating modules as follows:

private class DomainModule : NinjectModule
{
public override void Load()
{
Bind<IProductRepository>().To<ProductRepository>();
}
}

private class ApplicationModule : NinjectModule
{
public override void Load()
{
Bind<IEmailService>().To<EmailService>();
}
}

So when using IoC I suppose for all services and repositories I should
have an interface, right?
And should the interface be in the same namespace then the class
itself?
Should I separate maybe in two folders? I have no idea what do call
the folders ...

Should I call the modules differently like:
DataModule and MailModule, ...

My project has 4 levels:
Infrastructre (Basic code to all levels)
Domain (Repositories, Entities)
Application (Services to deal with Email, Flash, PDF and Image
manipulation, Google, Twitter, etc)
Presentation (Web Site)

In presentation I am injecting the repositories, services, etc on
presentation classes.

Well, I am just starting with IoC to hopefully solve some problems I
was having on my project.

There are many IoC frameworks. And they are all slightly
different. I don't know the one that uses NinjectModule.

I general I would expect them to be used with an
interface. The point of IoC with only a concrete
class is limited.

The namespace structure depends on the context. Maybe
A.IFoobar + A.Foobar1, maybe A.IFoobar + A.One.Foobar1
or maybe A.IFoobar + B.Foobar1.

IoC is great, but do not overuse it. It is very good as
glue between layers.

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