ebook img

Refactoring with Microsoft Visual Studio 2010 PDF

372 Pages·2010·18.161 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Refactoring with Microsoft Visual Studio 2010

Refactoring with Microsoft Visual Studio 2010 Evolve your software system to support new and ever-changing requirements by updating your C# code base with patterns and principles Peter Ritchie professional expertise distilled P U B L I S H I N G BIRMINGHAM - MUMBAI Refactoring with Microsoft Visual Studio 2010 Copyright © 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: July 2010 Production Reference: 1190710 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-849680-10-3 www.packtpub.com Cover Image by Sandeep Babu ([email protected]) Credits Author Editorial Team Leader Peter Ritchie Gagandeep Singh Reviewers Project Team Leader Atul Gupta Lata Basantani Anand Narayanaswamy Project Coordinator Vivek Thangaswamy Shubhanjan Chatterjee Hima Bindu Vejella Proofreaders Acquisition Editor Lesley Harrison Rashmi Phadnis Claire Cresswell-Lane Aaron Nash Development Editors Neha Patwari Graphics Ved Prakash Jha Nilesh Mohite Technical Editor Production Coordinator Neha Damle Adline Swetha Jesuthas Indexer Cover Work Monica Ajmera Mehta Adline Swetha Jesuthas About the Author Peter Ritchie is a software development consultant. Peter is president of Peter Ritchie Inc. Software Consulting Co., a software consulting company in Canada's National Capital Region specializing in Windows-based software development management, process, and implementation consulting. Peter has worked with such clients as Mitel, Nortel, Passport Canada, and Innovapost, from mentoring to architecture to implementation. Peter's range of experience ranges from designing and implementing simple stand-alone applications to architecting n-tier applications spanning dozens of computers; from C++ to C#. Acknowledgement Any sort of body of work is like a child: it takes a village raise a body of work. This body of work is no different; it could not have existed without a huge village of software development constituents. Many people from this village have influenced me directly and many more have influenced me indirectly. There are too many to faithfully acknowledge in a single place. Any sort of book on Refactoring is based on the work of Martin Fowler and William Opedyke. This book could not have existed in the state it has without their work. Refactoring itself is based on the techniques and methodologies developed or promoted by Ward Cunningham and Kent Beck. Some of the refactorings use design techniques right out of Domain Driven Design. Eric Evens organized and systematicized patterns and practices on good object-oriented design. I have to acknowledge the early years of the ALT.NET movement and the people involved in it. ALT.NET promoted a more scientific view of software development, promoting generally accepted principles, methodologies, and community over not-invented-here, cowboy development, and working in a vacuum. I can't possibly list all the people who have been involved with ALT.NET, but some of those people that I've had the pleasure of being involved with or influenced by include (in no particular order): David Laribee, Scott Bellware, Jeremy Miller, Greg Young, Donald Belcham, James Kovacs, Jean-Paul Boodhoo, Kyle Baley, Karl Seguin, Oren Eini, Steven List, Adam Dymitruk, Udi Dahan, Glenn Block, Derek Whittaker, Justice Gray, Roy Osherove, Scott Allen, Scott Koon, Brad Wilson, and many, many others. Much thanks to the people at Packt and the technical reviewers that provided many other points of view to what I had written. Thanks to Bill Wagner for his feedback and advice. Also, many thanks to Charlie Calvert, Mark Michaelis, and Bill Wagner for our collaborations on community. It promoted and facilitated my views on being involved with and giving back to the software development community. Finally, I have to acknowledge my wife Sherry, who's had the patience and support that allows me to follow my software development interests that take up so much of my spare time, like writing this book. About the Reviewers Atul Gupta is the Principal Technology Architect at the Microsoft Technology Center, Infosys Technologies. With close to 15 years of experience working on Microsoft technologies, Atul is currently a Principal Technology Architect at Infosys' Microsoft Technology Center. His expertise spans User Interface technologies, and he currently focuses on Windows Presentation Foundation (WPF) and Silverlight technologies. Other technologies of interest to him are Touch (Windows 7), Deepzoom, Pivot, Surface, and Windows Phone 7. His prior interest areas were COM, DCOM, C, VC++, ADO.NET, ASP.NET, and AJAX. He has authored papers for industry publications and websites, some of which are available on Infosys' Technology Showcase. Along with colleagues from Infosys, Atul is also an active blogger. Being actively involved in professional Microsoft online communities and developer forums, Atul has received Microsoft's Most Valuable Professional award for multiple years in a row. Anand Narayanaswamy, Microsoft MVP, is the author of Community Server Quickly (www.packtpub.com/community-server/book) published by Packt Publishing. He works as a freelance writer based in Trivandrum, India besides devoting time for blogging and tweeting. He also works as a technical editor for ASPAlliance.com. He had worked as a technical editor/reviewer for various publishers such as Sams, Addison-Wesley, Mc Graw Hill, and Packt. He runs www.learnxpress.com and www.dotnetalbum.com. First, I would like to thank the almighty for giving me the strength and energy to work every day. I specially thank my father, mother, and brother for providing valuable help, support and encouragement. I also thank Shubhanjan Chatterjee, Neha Patwari, and Peter Ritchie for their assistance, co-operation, and understanding throughout the review process of this book. Vivek Thangaswamy has been working as a solution developer in Software Technologies for more than six years now. He has worked for many top notch clients across the globe. Vivek started programming in a DOS world, moved to C, C++, VC++, J2EE, SAP B1, LegaSuite GUI, WinJa, JSP, ColdFusion, VB 6, eventually to .NET in both VB.NET and C# worlds and also in ASP.NET / MS SQL Server and more into Windows Mobile platforms. He also worked in Microsoft's latest trendsetter in Enterprise Collaboration Microsoft Office SharePoint Server accompanied with VSTO and .NET 3.0 frameworks. He started working in SharePoint from the version 2003 to up to date version. Now he is more into Mobile platform Research and Development. Different domains and industries knowledge and experience eCommerce, ERP, CRM, Transportation, Enterprise Content Management, Web 2.0 and Portal. Expert in SAP B1, and SugarCRM consulting. Focusing on Java ME, Windows Mobile, JavaFX Mobile and Android, basically, what Vivek does is answer more out in the newsgroups over and over, plus adds to its blogging about Microsoft Technologies, wraps it in a very readable and interesting format and more in technical writing. For his good technical knowledge, passion about the Microsoft Technologies, community involvement and contribution, he has also been awarded the Microsoft Most Valuable Professional award for ASP. NET (once) and SharePoint (twice). He is the lead technology consulting advisor for Arimaan Global Consulting (www.arimaan.com). Vivek completed is Bachelor Degree in Information Technology (B.Tech), from one of the oldest and finest universities in the world, University of Madras and has an MBA (Master of Business Administration) in Finance from one of the largest Open universities in the world, IGNOU. Writing is a passion for Vivek, and he has written many technical articles and whitepaper based on different technologies and domains. He also authored a technical book on Microsoft technology VSTO 3.0 for Office 2007 Programming by Packt Publishing and has been a reviewer for Microsoft Office Live Small Business: Beginner's Guide by Packt Publishing. I dedicate this book to my Arimaan Global Consulting technical team members, for their excellence and support. Hima Bindu Vejella, a B.Tech graduate, Microsoft MVP since 2006, .NET Rock Star, working as Team Manager at Prokarma Softech Hyderabad, has eight years of experience in software development using Microsoft Technologies. Hima Bindu Vejella, Active community leader, all time winner in Community-Credit since 2006, author at aspalliance, dotnetslackers, and simpletalk. She is also speaker and book-reviewer at DotnetUserGroupHyderabad India Lead and Moderator at syntaxhelp, Technical Member at dotnetspider. She has spoken at more than 200 sessions at various colleges and events online and offline. She has taken sessions on MVP awareness, VS 2010, VS2010 at MNCs, UG Meets, Events and at corporate companies. Visit her blog at http://himabinduvejella.blogspot.com. She is regular columnist as international author for Mundo.NET, Portugal magazine, author at ASP Alliance and dotnetslackers. Her recent series of articles for VS2010 are like a white paper on VS2010 features are published in MSDN blog. She is founder and moderator of MUGH (Microsoft User Group Hyderabad), and most active UG community leader in India. She is contributed to syntaxhelp, submitted more than 500 code snippets on various technologies like ASP.NET, C#, VB, SharePoint, WP, LINQ, and so on. She is not only active in Indian MVPs but also internationally doing a lot for the community. She is associated with many online technical communities and has helped lot of people in finding solutions to their problems. She can be reached at [email protected]. She believes in "Aim to go where you have never been before and strive to achieve it". I would like to thank my beloved husband Mr. Vamshi, parents, in-laws, and Sai, a wonder kid, for being supportive all the time while I was spending my personal time working on the laptop on weekends. Table of Contents Preface 1 Chapter 1: Introduction to Refactoring 7 What is refactoring? 8 Why the term refactoring? 10 Unit testing—the second half of the equation 11 Simple refactoring 12 Technical debt 15 In the software development trenches 15 The option of rewriting 16 Working refactoring into the process 20 What to refactor 21 Refactoring to patterns 22 Refactoring to principles 22 Code smells 23 Complexity 23 Performance 24 Kernel 24 Design methodologies 25 Unused and highly-used code 25 Refactoring in Visual Studio® 2010 26 Static code analysis 26 Code metrics 27 Summary 28 Chapter 2: Improving Code Readability 31 Built-in Visual Studio® refactorings 32 Rename identifier refactoring 33 Rename field 33 Rename property 35

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.