NET Domain-Driven Design with C# Problem – Design – Solution
Total Page:16
File Type:pdf, Size:1020Kb
.NET Domain-Driven Design with C# Problem – Design – Solution Tim McCarthy Wiley Publishing, Inc. ffirs.indd iii 4/14/08 10:39:48 AM ffirs.indd ii 4/14/08 10:39:48 AM .NET Domain-Driven Design with C# Acknowledgments ................................................................ xv Introduction ....................................................................... xvii Chapter 1: Introducing the Project: The SmartCA Application ...1 Chapter 2: Designing the Layered Architecture ......................13 Chapter 3: Managing Projects ...............................................55 Chapter 4: Companies and Contacts ...................................109 Chapter 5: Submittal Transmittals .......................................157 Chapter 6: Requests for Information ....................................199 Chapter 7: Proposal Requests .............................................233 Chapter 8: Change Orders ...................................................265 Chapter 9: Construction Change Directives .........................295 Chapter 10: Synchronizing With the Server ..........................327 Chapter 11: The Client Membership System ........................357 Index .................................................................................391 ffirs.indd i 4/14/08 10:39:48 AM ffirs.indd ii 4/14/08 10:39:48 AM .NET Domain-Driven Design with C# Problem – Design – Solution Tim McCarthy Wiley Publishing, Inc. ffirs.indd iii 4/14/08 10:39:48 AM .NET Domain-Driven Design with C# Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978–0–470–14756–6 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services or to obtain technical support, please contact our Customer Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002. Library of Congress Cataloging-in-Publication Data is available from the publisher. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. ffirs.indd iv 4/14/08 10:39:49 AM About the Author Tim McCarthy is a freelance consultant who architects, designs and builds highly scalable layered web and smart client applications utilizing the latest Microsoft platforms and technologies. Tim is a Microsoft MVP in Solutions Architecture, and his expertise covers a wide range of Microsoft technologies, including, but not limited to, the following: .NET Framework (ASP.NET/Smart Clients/VSTO/ Workflow/Web Services, Windows Presentation Foundation), SQL Server, Active Directory, MS Exchange development, UDDI, SharePoint, and Service Oriented Architecture (SOA) applications. Tim has worked as both a project technical lead/member as well as being in a technical consulting role for several Fortune 500 companies. He has held the Microsoft Certified Solution Developer (MCSD) and Microsoft Certified Trainer (MCT) certifications for several years, and was one of the first wave of developers to earn the Microsoft Certified Application Developer (MCAD) for .NET and MCSD for .NET certifications. He also holds the Microsoft Certified Database Administrator certification for SQL Server 2000. Tim is also certified as an IEEE Certified Software Development Professional, and he is one of only 550 people to hold this certification in the world. Tim has been an author and technical reviewer for several books from Wrox Press. His other books include being a lead author on Professional VB 2005 , several editions of Professional VB.NET , Professional Commerce Server 2000 , and Professional ADO 2.5 Programming . He also has written and presented a DVD titled SharePoint Portal Services Programming 2003 . Tim has written numerous articles for the Developer .NET Update newsletter, developed packaged presentations for the Microsoft Developer Network (MSDN), and wrote a whitepaper for Microsoft on using COM+ services in .NET. He has also written articles for SQL Server Magazine and Windows & .NET Magazine . Tim has spoken at technical conferences around the world and several San Diego area user groups (including both .NET and SQL Server groups, and several Code Camps), and he has been a regular speaker at the Microsoft Developer Days conference in San Diego for the last several years. Tim has also delivered various MSDN webcasts, many of which were repeat requests from Microsoft. He also teaches custom .NET classes to companies in need of expert .NET mentoring and training. Tim holds a B.B.A. in Marketing from the Illinois Institute of Technology as well as an M.B.A. in Marketing from National University. Before becoming an application developer, Tim was an officer in the United States Marine Corps. Tim ’ s passion for .NET is only surpassed by his passion for Notre Dame Athletics. Tim can be reached via email at [email protected] . ffirs.indd v 4/14/08 10:39:49 AM ffirs.indd vi 4/14/08 10:39:49 AM Credits Acquisitions Editor Vice President and Executive Group Publisher Katie Mohr Richard Swadley Development Editor Vice President and Executive Publisher Christopher J. Rivera Joseph B. Wikert Technical Editor Project Coordinator, Cover Doug Holland Lynsey Standford Production Editor Proofreader Rachel McConlogue Jen Larsen, Word One Copy Editor Indexer Foxxe Editorial Services Jack Lewis Editorial Manager Cover Image Mary Beth Wakefield Leandra Hosier Production Manager Tim Tate ffirs.indd vii 4/14/08 10:39:49 AM ffirs.indd viii 4/14/08 10:39:49 AM Contents Acknowledgments xv Introduction xvii Chapter 1: Introducing the Project: The SmartCA Application 1 The Problem 1 The Design 4 Reliability and Availability 4 Scalability 5 Maintainability 5 Rich Client Application Functionality 5 Offline Capable 5 Web Access 5 Intelligent Installation and Auto-Update Functionality 5 Additional Client Device Support 5 The Solution 6 Fulfilling the Reliability, Availability, Scalability, Offline Capable, and Additional Client Device Support Requirements 6 Fulfilling the Maintainability Requirement 7 Fulfilling the Rich Client Application Functionality Requirement 9 Fulfilling the Web Access Requirement 11 Fulfilling the Intelligent Installation and Auto-Update Functionality Requirement 11 Summary 11 Chapter 2: Designing the Layered Architecture 13 The Problem 13 The Design 13 Designing the Visual Studio Solution 13 Designing the Architectural Layers 14 The Solution 18 Implementing the Visual Studio Solution 19 Implementing the Architectural Layers 19 Summary 53 ftoc.indd ix 3/20/08 2:05:43 PM Contents Chapter 3: Managing Projects 55 The Problem 55 The Design 55 Designing the Domain Model 56 Defining the Project Aggregate 56 Defining the Aggregate Boundaries 57 Designing the Repositories 58 Writing the Unit Tests 60 The Solution 65 The Project Class 65 The Repository Implementations 77 The Service Class Implementations 90 The Project Information ViewModel Implementation 92 The Project Information View Implementation