Microsoft .NET
Architecting Applications for the Enterprise, Second Edition
Dino Esposito
Andrea Saltarello
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 .
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 fictitious. 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 authors 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 its such a thin kind of sand that even when Im full, without you, I just feel empty.
DINO
To Laura, mum, and Depeche Mode. Moved, lifted higher. Moved, by a higher love.
ANDREA
Introduction
Good judgment comes from experience, and experience comes from bad judgment.
Fred Brooks
We find that the preceding quote contains the essence of software architecture and the gist of the architects role. Software architecture requires judgment because not all scenarios are the same. To exercise sound judgment, you need experience, and in this imperfect world, experience mostly comes from making some mistakes and bad choicesfrom bad judgment.
However, the world we live in often doesnt give you the opportunity (or even the time) to form your own experience-based knowledge from which good judgment is developed. More often than not, all that executives want from architects is the right architecture right away.
Weve written this book primarily to endow you with a solid, reusable, and easily accessible base of knowledge about software architecture. In past years, weve completed projects using technologies like Microsoft Windows DNA, Distributed COM, multitier CRUD, SOA, DDD, CQRS, and event sourcing. Weve used Microsoft Visual Basic 6 as well as C#, C++, Java, and JavaScript. Weve seen technical solutions change frequently and perspectives about these approaches also evolve.
In the end, we came to the same conclusion as Fred Brooks. We dont wear white coats, were not doctors, and were not writing prescriptions. Our purpose here is to aggregate various positions, add our own annotations and comments to those positions, and generate an honest summary of facts and perspectives.
In these times in which developers and architects are asked to do it right and right away, we offer a snapshot of knowledgea readymade software architects digest for you to use as the starting point for further investigation and to use to build up your own judgment. If software architecture were a theorem, this book (we hope) would provide a collection of necessary lemmas.
Organization of this book
Software architecture has some preconditions (design principles) and one post-condition (an implemented system that produces expected results). , lays the foundation of software architecture and focuses on the role of the architect, the inherent mechanics of software projects, and aspectslike testability and readabilitythat turn software into top-quality software.
. In a nutshell, the chapter makes the point that only a deep understanding of the domain can lead to discovering an appropriate architecture. And, maybe more importantly, the resulting architecture doesnt have to be a single, top-level architecture for the entire application. As you recognize subdomains, you can model each to subapplications and give each the most effective architecture. As weird as it might sound, this is the core lesson of Domain-Driven Design (DDD).
, covers three supporting architectures you can use to build the various subdomains you recognized. For each architecture, we have a couple of chaptersan introduction and an implementation. The first supporting architecture we consider is the Domain Model. Next we head to Command/Query Responsibility Segregation (CQRS) and event sourcing.
Finally, , contains a single chapterit deals with infrastructure and the persistence layer. This is interesting because its not simply a chapter about SQL, Entity Framework, and relational databases. We primarily talk polyglot persistence, NoSQL data stores, and services used to hide storage details.
So, in the end, whats this book about?
Its about what you need to do and know to serve your customers in the best possible way as far as the .NET platform is concerned. The patterns, principles, and techniques we describe are valid in general and are not specific to complex line-of-business applications. A good software architecture helps control the complexity of the project. And controlling complexity and favoring maintainability are the best strategies we have for fighting the canonical Murphys Law of technology: Nothing ever gets built on schedule or within budget. To get there, theres just one thing youre not allowed to fail on: understanding (deeply) the business domain.
Who should read this book
Software architects are the ideal audience for this book, but lead developers and developers of any type of .NET applications will find this book beneficial. Everyone who wants to be an architect should find this book helpful and worth the cost.
Is this book only for .NET professionals? Although all chapters have a .NET flavor, most of the content is readable by any software professional.
Assumptions
Strong object-oriented programming skills are a requirement for using this book. A good foundation in using the .NET platform and knowledge of some data-access techniques will also help. We put great effort into making this book read well. Its not a book about abstract design concepts, and its not a classic architecture book either, full of cross-references and fancy strings in square brackets that hyperlink to some old paper listed in a bibliography at the end of the book.
This book might not be for you if...
This book might not be for you if youre seeking a reference book to pick up to find out how to use a given pattern. Instead, our goal is sharing and transferring knowledge so that you know what to do at any point. Or, at least, you know what two other guysDino and Andreawould do in an analogous situation. This is (hopefully) a book to read from cover to cover and maybe more than once. Its not a book to keep on the desk for random reference only.