Modern Web Development: Understanding domains, technologies, and user experience Dino Esposito PUBLISHED BY Microsoft Press A division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2016 by Dino Esposito 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: 2015934865 ISBN: 978-1-5093-0001-3 Printed and bound in the United States of America. First Printing Microsoft Press books are available through booksellers and distributors worldwide. If you need support related to this book, email Microsoft Press Support at [email protected]. Please tell us what you think of this book at http://aka.ms/tellpress. This book is provided “as-is” and expresses the author’s views and opinions. The views, opinions and information expressed in this book, including URL and other Internet website references, may change without notice. Some examples depicted herein are provided for illustration only and are fictitious. No real association or connection is intended or should be inferred. Microsoft and the trademarks listed at http://www.microsoft.com on the “Trademarks” webpage are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. Acquisitions and Developmental Editor: Devon Musgrave Project Editor: Steve Sagman Editorial Production: Waypoint Press Technical Reviewer: Marc Young Copyeditor: Roger LeBlanc Indexer: Toni Culley 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 Contents at a glance PART I UNDERSTANDING THE DOMAIN CHAPTER 1 Conducting a thorough domain analysis CHAPTER 2 Selecting the supporting architecture CHAPTER 3 UX-driven design CHAPTER 4 Architectural options for a web solution CHAPTER 5 The layered architecture Part II DEVELOPMENT CHAPTER 6 ASP.NET state of the art CHAPTER 7 Whys, wherefores, and technical aspects of ASP.NET Core 1.0 CHAPTER 8 Core of ASP.NET MVC CHAPTER 9 Core of Bootstrap CHAPTER 10 Organizing the ASP.NET MVC project CHAPTER 11 Presenting data CHAPTER 12 Editing data CHAPTER 13 Persistence and modeling Part III USER EXPERIENCE CHAPTER 14 Creating more interactive views CHAPTER 15 Pros and cons of responsive design CHAPTER 16 Making websites mobile-friendly Contents Introduction PART I UNDERSTANDING THE DOMAIN Chapter 1 Conducting a thorough domain analysis Domain-driven design to the rescue Introducing design driven by the domain Clearing up common misconceptions about DDD Introducing the ubiquitous language Creating a vocabulary of domain-specific terms Keeping business and code in sync Introducing the bounded context Discovering bounded contexts Implementing bounded contexts Introducing context mapping Examining relationships between bounded contexts Introducing event storming Having unlimited modeling space Finding events in the domain Leading the discussion Summary Chapter 2 Selecting the supporting architecture It’s all about business logic Examining the application logic Examining the domain logic Exploring patterns for the business logic Using a single model Exploring the elements of an object-oriented domain model Putting business rules inside Discovering aggregates Exploring the role of domain services Implementing command and query separation Working with the Command and Query Separation principle Implementing CQRS Introducing message-based formulation Ad-hoc infrastructure Introducing event sourcing Summary Chapter 3 UX-driven design Why a top-down approach is better than a bottom-up one Foundation of the bottom-up approach Planning with a top-down approach Looking at user experience from an architectural perspective UX is not UI Explaining UXDD in three steps Why UXDD is beneficial to nearly everybody Summary Chapter 4 Architectural options for a web solution Assessing the available web solutions Deciding on the best framework Laying out a solution Examining the role of ASP.NET Core 1.0 Considering ASP.NET as the starting point Examining the architectural dependencies in ASP.NET Core 1.0 Exploring the reasons to choose ASP.NET Core 1.0 Determining if you should use ASP.NET Web Forms Examining a common scenario ASP.NET Web Forms at a glance What’s still good with Web Forms Why you should move away from Web Forms Determining if you should use ASP.NET MVC ASP.NET MVC at a glance What’s good with ASP.NET MVC Weak points of ASP.NET MVC Examining the role of ASP.NET Web API Moving from WCF to Web API Comparing ASP.NET Web API and ASP.NET MVC Talking about REST Using Web API in ASP.NET Core 1.0 Single-page applications Setting up a SPA Hybrid SPA Weak points of a SPA Summary Chapter 5 The layered architecture Beyond classic three-tier systems Working with a three-tier architecture today Fifty shades of gray areas The presentation layer The user experience The input model The view model The application layer Entry point in the system’s back end Orchestration of business processes The domain layer The mythical domain model The equally mythical concept of domain services A more pragmatic view of domain modeling The infrastructure layer Current state storage Event stores Caching layers External services Summary PART II DEVELOPMENT Chapter 6 ASP.NET state of the art Web flavors The web could have been different Classic web is the winner ASP.NET is feature-complete No more to add is no more to add Is it full potential or software obsolescence? ASP.NET Core 1.0 has no new functions It’s about the new runtime It’s about the business model It’s about the development model What is the state of ASP.NET? Chapter 7 Whys, wherefores, and technical aspects of ASP.NET Core 1.0 The background of ASP.NET Core The cost of a large memory footprint Reconsidering the cloud as the silver bullet Making the case for the necessity of a different programming model The impact on everyday work The ASP.NET Core runtime at a glance The DNX host Hosting web applications in DNX ASP.NET Core HTTP pipeline ASP.NET Core for ASP.NET developers Creating a new project Application startup Application settings Authentication Other aspects of web programming Summary Chapter 8 Core of ASP.NET MVC Routing incoming requests Simulating the ASP.NET MVC runtime Exploring the URL routing HTTP module Using application routes Exploring the controller class Looking at aspects of a controller Writing controller classes Processing input data Manual parameter binding Model binding Producing action results Wrapping results Returning HTML markup Returning JSON content Summary Chapter 9 Core of Bootstrap Bootstrap at a glance LESS and the foundation of Bootstrap Setting up Bootstrap Putting Bootstrap into perspective Responsive layouts The grid system Screen-based rendering Taxonomy of today’s web elements Restyling basic HTML elements Restyling list HTML elements A look at more advanced components Bootstrap extensions Autocompletion Date picking Custom components Summary Chapter 10 Organizing the ASP.NET MVC project Planning the project solution