Your SlideShare is downloading. ×
Lean Enterprise Architecture
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Lean Enterprise Architecture


Published on

This presentation by Excella Consulting's Shahed Chowdhuri and Sahil Talwar covers EF Code First Migrations and Lean Enterprise Architecture Design. …

This presentation by Excella Consulting's Shahed Chowdhuri and Sahil Talwar covers EF Code First Migrations and Lean Enterprise Architecture Design.

- How we use EF Code First Migrations to keep our developers' databases in sync, automatically deploy updates using TeamCity and work with DB Architects who utilize tools like ER/Studio.
- Real world examples to explain how to combat over engineering in an enterprise application through lean startup principles.

Published in: Technology, Business

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • Lean Enterprise Architecture (title page)A lean, testable enterprise architecture with a modern client stack
  • Sponsors
  • Introduction* We are building an enterprise web application with ASP.NET MVC, following best practices for design, development, testability and deployment.* We were looking for ways to improve and modernize* The motivation behind this design was our desire to do TDD, BDD, CI, CD.
  • Are you familiar with:ASP.NET MVC?Entity Framework?Code First development?Code First Migrations?(slow-reveal diagram + ask the audience)
  • Options and AlternativesDatabase-First (EDMX)Model-First (visual designer)Code-First with automatic migrationsCode-First with manual migrations
  • AgendaAdd models and mapping in codeConnection StringEnable MigrationsUpdate DatabasePush code + Migrate server DBProcess Workflow
  • 1. Models & Mapping
  • 2. Connection StringsConnection StringWeb.configconfigSourceMachine config
  • 3. Enable MigrationsEnable MigrationsConfiguration.csAdd Seed data
  • 4. Update DatabaseUpdate DatabaseRun Seed DataVerify SQLVerify DB
  • 5. Push Code + Migrate Server DBPush code to source controlOther developers pull and Update DatabaseMigrate server DB via migrate.exeUse TeamCity to automate this
  • 6. Process WorkflowProcess WorkflowHandle existing databaseComply with enterprise requirements
  • Code Walkthrough
  • Code First Migrations allows:Continuous developmentSynchronization among team membersDatabase versioningServer deployment(diagram with star pattern)
  • Resources
  • IntroShahed showed DAL, so I’ll run through DomainFair warning, though…
  • This is not like the other two parts of the presentation!I won’t show you code…Or specific technologies…at all.Instead, war stories and lesson learned
  • Using Scrum,
  • CI, CD…TDD, BDD, and DDD…
  • But at the same time, some people involved with the project are proponents of…
  • HEAVYWEIGHT enterprise architecture.To see what I mean, compare layersJokes aside, 1 story of over-engineering causing problems:
  • When using DDD…blogsDev tried to use best practicesDidn’t check if we had the problems
  • 3 problems: Use of UoW optionalRedundant, as I saidTo top it off: buggy, slow, redundant
  • Now that’s what I call gold plating!
  • The second story of the day is about premature optimization. Knuth: “premature optimization is the root of all evil”Optimizing for unproven use case because app is complex, expensive, many dev teamsAutomapper both waysWhat does Bogard know? Wrote != knows domain!
  • Eventually realized it was gold plating as much as the Repositories were
  • After unreasonable time, came to our sensesPulled out model into cross cutting layerNo more automapper!!Api has Data Contracts that look nothing like models, so that is a valid exception.
  • Re: sharing a database context across objects.
  • Service for every complex objectInjected new DbContext into every serviceProblem with shared sub-objects being accessible in several contexts
  • Looked to SRP for guidance  one per objectNot only does not solve issue, makes it worse by making nearly all db objects sharedAlso creates Repo explosion
  • Made a store to manage # of servicesRealized shared context problem, this fixes it# of Services = pain to manage and test!Came to realizetoo many services & shared context problemsStore was messy, painful hack
  • Basically, realized that this is a step beyond gold plating.This is solid gold.
  • Solved problem by splitting up into non-overlapping domains. Practically, this means 1 service per project team, & no overlapping objects.Anyone heard of bounded contexts…?Original solution proposed by DDD to begin with.Anyway,
  • We fought against over-engineering and gold plating by using lean startup principles:BuiltMeasured pain; demonstrated to EA proponentsLearned from mistakes, built a solution closer to what we believed would alleviate the problemsRinse & Repeat
  • Transcript

    • 1. Lean Enterprise ArchitectureBy Shahed Chowdhuri, Sahil Talwar, Doguhan UlucaA lean, testable enterprise architecture with a modern client stack
    • 2. Thanks to our Sponsorsfor keeping the fires lit
    • 3. TDD (Test Driven Development)BDD (Behavior Driven Development)CI (Continuous Integration)CD (Continuous Delivery)IntroductionASP.NETMVCDBEnterpriseWebApplication Looking for Ways to Improve & Modernize Motivation behind this design? Our desire to do the following:
    • 4. Data Access Layer ShahedChowdhuriUsing Code-First Migrations
    • 5. Tech CheckASP.NETMVCEntityFrameworkEFCode-FirstDevelopmentEFCode-FirstMigrationsAre you familiar with…?
    • 6. Options and AlternativesDatabase-First(EDMX)Model-First(VisualDesigner)Code-First(automaticmigrations)Code-First(manualmigrations)
    • 7. What are we trying to solve?
    • 8. DAL: Agenda1. Models &Mapping2. ConnectionStrings3. EnableMigrations4. UpdateDatabase5. Push Code+ MigrateServer DB6. ProcessWorkflow
    • 9. 1. Models & MappingDBContext.OnModelCreating()
    • 10. 2. Connection Strings
    • 11. 3. Enable Migrations
    • 12. migrationcode4. Update Databasemodelcodemigrationcode+ seeddevDB(sql)
    • 13. 5. Push Code + Migrate Server DBcode push codeCIcode pull codemigrate.exeServerDB
    • 14. 6. Process Workflowdev team DB architectscommunicationDB
    • 15. Code Walkthrough
    • 16. DAL: ConclusionCode-FirstMigrationsDev TeamSynchronizedServerDeploymentDatabaseVersioningContinuousDevelopment
    • 17. Resources• EF Code First Migrations on MSDN:–• Web.config & configSource:–• PluralSight EF Migrations video tutorial:–
    • 18. The Domain Sahil TalwarSimpler is better
    • 19. Versus…
    • 20. HeavyweightEnterprise Architecture
    • 21. Round
    • 22. Best PracticesRepositoriesUnit of WorkEntity Framework
    • 23. DomainIUnitOfWorkIRepository IRepository IRepositoryDalDbContextDbSet DbSet DbSetWeb Api
    • 24. Round
    • 25. Web ModelsDomain ModelsDal ModelsApi Models
    • 26. WebDomainDalCore(Models)…Except Api-Domain.
    • 27. Round
    • 28. StudentContextUniversitiesDepartmentsProfessors ClassesAdvisorsStudentsContext Per Complex ObjectUniversityContext
    • 29. Professors Classes StudentsDepartments Advisors UniversitiesSingle Responsibility: Context Per ObjectUniversitiesDepartmentsProfessors ClassesAdvisorsStudents
    • 30. ServiceStoreServiceStoreService Service ServiceSharedContextService Service Service
    • 31. Solid gold.
    • 32. ServicesDomain 1Web ApiDomain 2 Domain 4 Domain 5Dal ModelsDomain 3 Domain 6
    • 33. Image Credits••••••••••••••••