DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Configuring SSO Using WSO2 Identity Server
  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline
  • 4 Email Validation and Verification Techniques for App Developers
  • Boosting Efficiency With Cross-Platform Code-Sharing Techniques

Trending

  • Supercharge Your Software Development Journey With DevOps, CI/CD, and Containers
  • Understanding Git
  • DevSecOps: Integrating Security Into Your DevOps Workflow
  • Creating a Deep vs. Shallow Copy of an Object in Java

Review: Microsoft N Layer App Sample, Part IV-IoC FTW

Oren Eini user avatar by
Oren Eini
·
Jul. 05, 11 · News
Like (0)
Save
Tweet
Share
4.15K Views

Join the DZone community and get the full member experience.

Join For Free

continuing my review of http://microsoftnlayerapp.codeplex.com/ , an official guidance (shows up at: http://msdn.microsoft.com/es-es/architecture/en ) which people are expected to read and follow.

while investigating how they are implementing ioc, i found:

/// <summary>
/// configure root container.register types and life time managers for unity builder process
/// </summary>
/// <param name="container">container to configure</param>
void configurerootcontainer(iunitycontainer container)
{
    // take into account that types and mappings registration could be also done using the unity xml configuration
    //but we prefer doing it here (c# code) because we'll catch errors at compiling time instead execution time, 
    //if any type has been written wrong.

    //register repositories mappings
    container.registertype<iproductrepository, productrepository>(new transientlifetimemanager());
    container.registertype<iorderrepository, orderrepository>(new transientlifetimemanager());
    container.registertype<ibankaccountrepository, bankaccountrepository>(new transientlifetimemanager());
    container.registertype<icustomerrepository, customerrepository>(new transientlifetimemanager());
    container.registertype<icountryrepository, countryrepository>(new transientlifetimemanager());

    //register application services mappings

    container.registertype<isalesmanagementservice, salesmanagementservice>(new transientlifetimemanager());
    container.registertype<icustomermanagementservice, customermanagementservice>(new transientlifetimemanager());
    container.registertype<ibankingmanagementservice, bankingmanagementservice>(new transientlifetimemanager());
    
    //register domain services mappings
    container.registertype<ibanktransferdomainservice, banktransferdomainservice>(new transientlifetimemanager());
    

    //register crosscuting mappings
    container.registertype<itracemanager, tracemanager>(new transientlifetimemanager());

}

just to figure out how ridiculous this is, let me show you the entire infrastructure required to support ioc in this application:

image

yes, they abstracted the inversion of control container . i think that if you need to do that, it is pretty clear that you don’t really get what ioc is all about.

maybe , if you are a framework, you need to abstract the container, but you don't need to do that if you are an application (which this is supposed to be) and you certainly don't write your own, that is why commonservicelocator is here.

then again, the code is absolutely littered with things like:

image

so i guess that it is not really a surprise.

what is a surprise is that they are catching nullreferenceexception. you are not supposed to catch this exception . this is an indication that you have some problem with your code, not that you have some invalid argument issue.

app

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Configuring SSO Using WSO2 Identity Server
  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline
  • 4 Email Validation and Verification Techniques for App Developers
  • Boosting Efficiency With Cross-Platform Code-Sharing Techniques

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: