Microsoft .NET: Architecting Applications for the Enterprise
Total Page:16
File Type:pdf, Size:1020Kb
User Developmentexperience first and . design. vectors. .. .. .. 138 64 Table ofFocusSOLID onContents interactions principles .. .. .. .. .. .. .. .. .. .. .. .138 64 UX isPatterns not UI . for . handling . dependencies. .. .. .. .. 140 69 HowCoding to create vectors an effective . .experience . .. .. .. .. .. .. 143 72 Realistic scenariosUse of patterns . .. .. .. .. .. .. .. .. 147 75 ASP .NETRefactoring websites . .. .. .. .. .. .. .. .. .. .. 147 77 Introduction xiiiDefensiveWeb Forms programming vs . ASP .NET .MVC . .. .. .. .. 152 78 Errata,Adding updates,The device If-Then-Throw & booksupport support topattern websites . .. .. .. .. .. .. .. .. 155xviii78 FreeSingle-page ebooksSoftware from applications contractsMicrosoft . Press . .. .. .. .. ... 160xix79 Desktop rich client . 164 WeSummary want to hear. from . you . .. .. .. .. .. .. xix . .83 Summary . .166 StayFinishing in touch with . .a . smile . .. .. .. .. .. .. .. .. .. xix84 Finishing with a smile . 166 FoundationWriting software 1 of quality 85 The mythical businessThe art of layer writing testable code . 167 86 Architects Patternsand architecture forWhat organizing is testability, today the business anyway? logic . .. .. .. .. 167 386 What’sThe softwarefairytaleTesting your architecture,of CRUD software and anyway? an . architecture . .. .. .. .Prince. .. .. .. .Charming .. 168 488 Microsoft .NET: TheApplying TransactionCommon architectural practices Script pattern of principles software .. to. testing. software. .. .. 169 496 TheThe Acknowledgingpractice Domain of Model code requirements extensibilitypattern . .. .. .. .. .. .. .. .. .. .. 172 1017 Architecting Applications TheWhat’s AnemicInterface-based architecture Domain designModel and what’s (anti-)pattern. not . .. .. .. .. .. 17411102 Moving theThePlugin focusarchitecture architecturefrom data process to . .tasks . .. .. .. .. .. .. 17614103 for the Enterprise, Who’sTask the Stateorchestration architect, machines anyway? in .ASP . .NET. MVC. .. .. .. .. .. .. .. 17717103 WritingOrchestratingAn architect’s code that tasks responsibilitiesothers within can the read domain . .. .. .. .. .. .. 18018104 Second Edition Moving dataTheReadability roleacross of the as architectboundaries a software . attribute .. .. .. .. .. .. .. .. ... .. .. 18220105 DataCommonSome flow inpractical misconceptions layered rules architecture for aboutimproving . architects . readability . .. .. .. 182 . 21 .107 SummarySummarySharing . the . .. .. Domain .. .. .Model. .. entities. .. .. .. .. .. .. .. .. .. .. 184. 24 .109 Using data-transfer objects . 185 FinishingFinishing with with a smilea smile . .. 25110 Summary . .187 DesigningDevising Finishingforthe successarchitecture with a smile . 18827111 Supporting architecturesThe “Big Ball of Mud” . .. 28 Discovering theCauses domain of the architecture “Big Ball of Mud” . 11328 Dino Esposito Introducing DomainThe Symptomsreal Model added of value the “Bigof domain-driven Ball of Mud” design. .. .. .. 19132114 Andrea Saltarello The data-to-behaviorUsingWhat’s metrics in DDD shiftto detectfor . me?. a. BBM.. .. .. .. .. .. .. .. .. .. .. .. .. .. 19134114 Rationale behind models and domains . 192 MechanicsConducting of software analysis projects using . DDD . .. 35115 Database is infrastructure . 195 OrganizationalStrategic model culture design. .. .. .. .. .. .. .. .. .. .. 35116 InsideThe the Helpingubiquitous domain the layer language team . write . .better .. .. .code . .. .. .. .. .. 19638118 Domain model . 196 Getting Purposeout of the of mess the ubiquitous . language. .. 43118 Aggregates . 199 ThatStructure odd thing of the called ubiquitous “legacy languagecode” . .. .. .. .. .44119 Domain services . 205 CheckmateHow to define in three the moves ubiquitous . language . .. 45119 Domain events . 209 DecidingKeeping whether language or andnot tomodel add manpowerin sync . .. .. .. .. 49121 Cross-cutting concerns . 212 SummaryBounded . contexts. .. .. .. .. .. .. .. .. .. .. .. .. .50122 Summary . Discovering . contexts. .. .. .. .. .. .. .. .. .215 122 Finishing with a smile . .. 51 Finishing withContext a smile mapping . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. 215 125 Principles of softwareGiving design each context its own architecture . 53127 Implementing DomainThe layered Model architecture . 217 129 Universal principles of software design . 54 The online Originsstore sample of the projectlayered . architecture . .. .. 218 129 From spaghetti code to lasagna code . 54 SelectedPresentation use-cases layer . .. .. .. .. .. .. .. 218 131 Separation of concerns . 57 SelectedApplication approach layer . .. .. .. .. .. .. 219 132 Isolation . 57 StructureDomain of the layer I-Buy-Stuff . .project . .. .. 220 134 Object-oriented design . 57 SelectedInfrastructure technologies layer .. .. .. .. .. .. .. .. .. .. .. .. .. 222 134 Pertinent classes . 58 SummaryBounded . contexts . for . an . online . store . .. .. .. .. 222. .135 Program to an interface . .59 Context map of the I-Buy-Stuff application . .. 224 FinishingComposition with a smile vs . inheritance . .. .. .. 61135 A second pass at object-orientation . 63 The presentation layer 137 PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2014 by Dino Esposito and Andrea Saltarello All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Library of Congress Control Number: 2014940680 ISBN: 978-0-7356-8535-2 Printed and bound in the United States of America. Second Printing: January 2015 Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to this book, email Microsoft Press Book Support at [email protected]. Please tell us what you think of this book at http://aka.ms/tellpress. Microsoft and the trademarks listed at http://www.microsoft.com/en-us/legal/intellectualproperty/Trademarks/ EN-US.aspx are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fi ctitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred. This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Acquisitions and Developmental Editor: Devon Musgrave Project Editor: Carol Dilllingham Editorial Production: Waypoint Press, www.waypointpress.com Peer Reviewer: Cesar De la Torre Llorente Copyeditor: Roger LeBlanc Indexer: Christina Yeager Cover: Twist Creative • Seattle and Joel Panchot To my wife Silvia. You make me feel sandy like a clepsydra. I get empty and filled all the time; but it’s such a thin kind of sand that even when I’m full, without you, I just feel empty. —DINO To Laura, mum, and Depeche Mode. Moved, lifted higher. Moved, by a higher love. —ANDREA This page intentionally left blank Contents at a glance PART I FOUNDATION CHAPTER 1 Architects and architecture today 3 CHAPTER 2 Designing for success 27 CHAPTER 3 Principles of software design 53 CHAPTER 4 Writing software of quality 85 PART II DEVISING THE ARCHITECTURE CHAPTER 5 Discovering the domain architecture 113 CHAPTER 6 The presentation layer 137 CHAPTER 7 The mythical business layer 167 PART III SUPPORTING ARCHITECTURES CHAPTER 8 Introducing Domain Model 191 CHAPTER 9 Implementing Domain Model 217 CHAPTER 10 Introducing CQRS 255 CHAPTER 11 Implementing CQRS 291 CHAPTER 12 Introducing event sourcing 311 CHAPTER 13 Implementing event sourcing 325 PART IV INFRASTRUCTURE CHAPTER 14 The persistence layer 353 This page intentionally left blank Contents Introduction . xiii PART I FOUNDATION 1 Chapter 1 Architects and architecture today 3 What’s software architecture, anyway?. 4 Applying architectural principles to software . 4 Acknowledging requirements . 7 What’s architecture and what’s not . .11 The architecture process . 14 Who’s the architect, anyway? . 17 An architect’s responsibilities . 18 The role of the architect . .20 Common misconceptions about architects . 21 Summary . 24 Finishing with a smile . 25 Chapter 2 Designing for success 27 The “Big Ball of Mud” . 28 Causes of the “Big Ball of Mud” . 28 Symptoms of the “Big Ball of Mud” . .32 Using metrics to detect a BBM . .34 Mechanics of software projects . ..