.net - Scanning un-referenced assemblies with StuctureMap -


i using structuremap di in asp.net mvc project. have divided libraries following 3 dlls.

  1. core
  2. services
  3. data (contains repositories)

the core contain interfaces , services , data contain implementation.

now when setup structuremap in website need tell scan services , data assemblies contain implementation of core interfaces mean have reference them both in web project although depends on service project depends on data project.

to me referencing these 2 dlls in web project not make sense spoils benefit of abstraction?

can 1 please explain me if need reference these assemblies or not , advantage of using separate interfaces in first place?

the web project composition root of application. composition root 1 single place in application composes object graph application. don't have reference assemblies composition root, can scan assemblies using convention, it's not worth effort imo.

by having composition root reference dependencies flatten out dependency hierarchy allowing looser coupling; see mark seeman's excellent explanation here.

dividing application different projects (assemblies) allow reuse functionality in assemblies between different applications , load parts of application on demand (using plug in architecture). don't overdo it. think of why split solution up. other programmers can violate intended architecture though split solution multiple projects prevent references in "wrong direction".

you're asking point of using separate interfaces is. interfaces provide 1 way make abstractions in code allow loose coupling , composability. programming towards interface , not concrete implementation, can change implementation without changing depending code. allow change , adapt application easier.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -