Home > Store

Reengineering .NET: Injecting Quality, Testability, and Architecture into Existing Systems

Register your product to gain access to bonus material or receive a coupon.

Reengineering .NET: Injecting Quality, Testability, and Architecture into Existing Systems

Book

  • Sorry, this book is no longer in print.
Not for Sale

eBook (Watermarked)

  • Your Price: $31.99
  • List Price: $39.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.

Description

  • Copyright 2013
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-82145-9
  • ISBN-13: 978-0-321-82145-4

Reengineer .NET Code to Improve Quality, Update Architecture, Access New Tools, and Accelerate Delivery of New Features

As software ages, it becomes brittle: difficult to understand, fix, manage, use, and improve. Developers working with  many platforms have encountered this problem; now, developers working with Microsoft’s .NET are facing it as well.  In Reengineering .NET, leading .NET architect Bradley Irby introduces proven best practices for revitalizing older .NET code and integrating new architectural and development advances into business-critical systems that can’t go offline.  Using a step-by-step approach, .NET professionals can make legacy enterprise software more reliable, maintainable,  attractive, and usable—and make it easier to upgrade for years to come.

Through real-world case studies and extensive downloadable sample code, Irby shows how to carefully plan a .NET  reengineering project, understand the true current state of your code, introduce unit testing and other agile methods, refactor to services and controllers, and leverage powerful .NET reengineering tools built into Microsoft Visual Studio 2012.

This book is an indispensable resource for all developers, architects, and project managers responsible for existing .NET code bases and for a wide audience of non-technical managers and CTOs who want to understand the unique  challenges faced by .NET teams involved in application or system reengineering projects.

Coverage includes
• Migrating legacy .NET software to more flexible, extensible, and maintainable architectures—without breaking it
• Reengineering web applications with the MVC pattern, Winforms software with MVP, and WPF/Silverlight  systems with MVVM
• Asking the right questions to predict refactoring problems before they happen
• Planning and organizing reengineering projects to apply the right expertise to each task at the right time
• Using innovative Test Doubling to make unit testing even more effective
• Applying Dependency Inversion to break tight coupling and promote easier development and testing
• Leveraging source control, defect tracking, and continuous integration
• “Cleaning up” legacy solutions to improve them before you even touch business logic
• Establishing solid development infrastructure to support your reengineering project
• Refactoring to services—including advanced techniques using Repositories, Domain Models,  and the Command Dispatcher
• Refactoring to controller/view or ViewModel/View pairs

Downloads

Downloads

Download free code files here and here

Sample Content

Online Sample Chapter

Reengineering .NET: Understanding Application Architecture

Sample Pages

Download the sample pages (includes Chapter 3 and Index)

Table of Contents

Preface     xiii
Acknowledgments     xix
About the Author     xxi
PART I Target Architecture
1  Implementing a Service-Oriented Architecture     3
An Overview of the Service-Oriented Architecture     4
Understanding Standardized Service Contracts     6
  Interfaces     6
Understanding Coupling     12
Understanding Service Abstraction     15
Designing Reusable Services     18
Understanding Service Autonomy and Service Composability     18
Understanding Service Statelessness     19
A Service Example     24
Summary     26
2  Understanding Application Architecture     27
Working with Architectural Patterns     27
An Overview of Architectural Patterns     28
Differences Among MVP, MVC, and MVVM     29
  Model Access     30
  View Models     31
Handling UI Events     38
How Do the Patterns Work?     43
Which Pattern Should You Choose?     45
Summary     45
3  Unit Testing     47
An Example of Unit Testing     48
Creating Unit Tests     49
Writing a Test     52
Detecting Exceptions     58
Understanding the Power of Assert     61
Comparing Unit Tests to Integration Tests     61
Using the InternalsVisibleTo Attribute     62
Understanding Test Driven Development     65
Learning More About Unit Testing     65
Summary     66
4  Understanding the Dependency Inversion Principle     67
Understanding Tight Coupling     67
Implementing the Abstract Factory Pattern     74
Introducing Interfaces     79
Creating Unit Tests     82
Understanding Service Location     84
  Inversion of Control Containers     84
  Service Locator     88
  A Real World Example     90
  OnDemand Service Properties     96
  Unit Testing Advantages     99
  Final Tweaks     100
Using Dependency Injection     103
Why Is Service Location Better for Reengineering?     108
Summary     113
5  Using Test Doubles with Unit Tests     115
How Do Test Doubles Work?     115
What Need Do Test Doubles Satisfy?     116
Creating a Stub     119
  Distinguishing Between Mocks and Stubs     123
Creating a Mock     124
  A Second Mocking Example     128
  A Third Mocking Example     129
Using Mocking System Services     130
Learning More About Test Doubles     133
Summary     133
PART II Reengineering
6  Initial Solution Review     137
Analyzing the Code     138
  Basic Architecture     138
  Code Structure     139
  Database Access     140
  Data Structures     140
  External Interfaces     141
  Application Controls Versus Form Controls     142
Analyzing the General Code Structure     142
Managing Language Migration     144
Removing Dead Code     145
Using Global Variables     145
Converting Code: It’s Not All or Nothing     149
Using an Automated Code Conversion Utility     150
Using Data Access Technologies     152
  Detecting the Data Model     152
  Detecting the Data Access Pattern     154
Summary     155
7  Planning the Project     157
Managing Expectations     157
Creating the Reengineering Team     158
Identifying Development Tools and the Build Process     159
  Introducing Source Control     160
  Introducing Defect Tracking     161
  Installing and Using a Continuous Integration (CI) Server     161
Cleaning Up Legacy Solutions     162
Establishing the Foundation      163
Refactoring to Use Basic Services     164
Refactoring to Use Advanced Services     166
Reporting Progress to Stakeholders     166
Managing Communication and Training     167
Summary     168
8  Identifying Development Tools and the Build Process     169
Using Source Control     169
  Types of Source Control     170
  A Process Example: Using a Distributed System     171
  A Second Process Example: Using a Distributed System     172
  A Third Process Example: Using a Centralized System     173
Understanding the Pros and Cons of Centralized Systems and Distributed Systems     173
  Consuming Shared Code from Others     173
  Sharing Code with Others and Reviewing Changes     174
  Backing up the Code     174
  Managing Check-in Frequency     175
  Managing Merge Conflicts     175
  Managing Control     176
  A Final Word About Pros and Cons     176
Evaluating a Hosting Service     176
  Using Apache Subversion (SVN)     177
  Using Microsoft Team Foundation Server (TFS)     177
  Using Git     179
Managing Features and Defects     179
  Managing Custom Workflow     180
  Managing Agile Development     180
  Managing Reporting     180
Using a Continuous Integration (CI) Build Server     181
Using Visual Studio 2010 Developer Tools     181
  Refactoring Tools in Visual Studio      182
  Third-Party Refactoring Tools     183
Summary     185
9  Cleaning Up Legacy Solutions     187
Organizing the File System     187
Structuring the Project      189
Working with Project Categories     190
Understanding Project Types     191
  Application-Agnostic Projects     192
  Generic UI Projects     192
  Model-agnostic Projects     193
  Model-specific Projects      193
Reengineering Project Recommendations     193
  Constants     194
  Data Transfer Objects (DTO) Projects      195 
  Interfaces     196
  Services     197
  Domain Model Projects     198
  Repository Projects     199
  Controllers, View Models, and Presenters     199
Refactoring to the Solution Structure     200
  Remove Unnecessary Using Clauses     200
  Separate Unit Tests and Integration Tests     201
  Move Classes to Appropriate Projects     202
  Move Shortcuts to Libraries     202
Refactorings that Affect Logic     203
  Move Initialization Logic into the Constructor     204
  Replace Nested IF Statements with Guards     205
  Removing Access to Entity Class Constructors     210
Summary     211
10  Establishing the Foundation     213
Adding New Projects     213
Using Prism, Unity, and Enterprise Library Versions     214
Adapting the Shell     216
  Creating the IBaseView     217
  Adapting the Current Shell     218
  Adding a Shell Controller     220
Creating the Service Locator     220
Setting Up the BootStrapper Class     223
  Creating the Winforms BootStrapper     223
  Updating the Winforms Program Class      226
  Creating a WPF Application and Bootstrapper     228
  Using Alternative Bootstrapper Configurations     232
Summary     236
11  Basic Refactoring to Services     237
Using DialogService     238
  Unit Testing     242
  Refactoring for DialogService     249
  Adding Unit Tests     250
Using LogWriterService     251
  Refactoring for LogWriterService     254
Tracking Session Information     257
  Refactoring for Session Information     258
Accessing Resources the SOA Way     260
  Refactoring for ResourceProvider     264
Using a Message Aggregator     265
  Refactoring for MessageAggregator     266
Converting Static Classes     271
Refactoring Static Classes     272
Summary     273
12  Advanced Refactoring to Services    275
Using a Repository Pattern     275
  Creating a Repository with a Domain Model     283
  Reengineering Methods to a Repository     288
  Converting Existing Code to Use a Domain Model     289
  Adding Data Validations to the Domain Model     291
  Reengineering Domain Models to Use Validations     296
Using a Generic Object Manager     296
Simplifying Complex Code with a Command Dispatcher Service     303
  Refactoring for CommandLineInterpreter     313
Summary     314
13 Refactoring to a Controller     315
Using the Legacy Approach to Form Creation     316
Preparing the View     319
Introducing the Controller     320
Enhancing the Controller     322
Summary     325
Appendix Reengineering .NET Projects with Visual Studio 2012     327
Examining Source Control with Visual Studio 2012     327
Managing Parallel Development     330
Making Changes in Isolation     334
Unit Testing with Visual Studio 2012     337
Writing a Unit Test Method     338
Running the Unit Test     339
Using the Edit-and-Continue Feature     341
Using Continuous Test Runner     344
Using Fakes to Write Unit Tests for “Untestable” Code     346
Looking for Hard-to-Maintain Code Using Code Metrics     348
Looking for Code Duplicates     350
Summary     353
Index     355

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020