How to Code .NET, Apress
C# Online.NET Book Review
I am a big fan of the "tips & tricks" type of book. At their best, they represent the hard learned lessons of an experienced developer accumulated while creating real world applications. Anyone who has written an application which turned out to be buggy or to be difficult to maintain could learn a lot from this little volume about how to write bug free, maintainable code. The book is suitable for any C# programmer with at least a year's coding experience.
The book begins in a perfect way for eliminating bugs with a valuable chapter on testing your code using NUnit for Test-Driven Development (TDD). I have previous experience with JUnit and Java and found this chapter particularly useful.
Next come chapters offering solutions to specific problems loosely categorized into: Common Language Runtime (CLR), text related, and C# coding. Throughout, the author does a good job of describing the situations and justifying the solutions by examining the Microsoft Intermediate Language (MSIL) when necessary.
My favorite chapter is Chapter 4 Coding solutions: it is a great tutorial and knowledgeable anyalysis of some useful design patterns and functors, e.g. Bridge, Factory, Immutable, Proxy, etc.
The book does contain a number of typos; but, I did not find any which scrambled the message.
The author has written several technical books on various topics. His writing style is conversational and accessible making for a pleasureable and profitable read.
All of the source code examples are in the C# language. The book is full of source code and illustrations where needed.
How to Code .NET is a super collection of solutions aimed at preventing buggy .NET code.
What is good code? Writing good code is really a question about what the code is trying to solve. (And good code is not to be confused with patterns—because not all pieces of good code are patterns.) We debate about good code because there is not just a single piece of good code, but so many good pieces of code. And each good piece of code depends on the context in which it is used.
How to Code .NET: Tips and Tricks for Coding .NET 1.1 and .NET 2.0 Applications Effectively provides solutions to certain problems. That is, specific problems. This book provides detailed, authoritative explanations of good .NET coding techniques. It’s based on award-winning material that author Christian Gross has previously presented at conferences throughout the US and Europe. What’s more, the author is at the forefront of the .NET technology wave and an acknowledged expert on the subject of .NET coding style and techniques.
About the author(s)
Christian Gross is a consultant with vast experience in the client/server world. He has consulted for Microsoft on DNA solutions, and he has held consulting positions with Daimler Benz, Microsoft, NatWest, and other major corporations. Gross was a contributor to Professional Active Server Pages, Professional SQL Server 6.5 Administration, Professional NT Internet Information Server Administration, and Programming Microsoft Windows 2000 Unleashed. He is the author of A Programmer's Introduction to Windows DNA.
Table of Contents (abbreviated)
CHAPTER 1 Testing Your Code
Quick Notes About TDD
Getting Started with TDD and NUnit
Writing Tests Using Contexts and Results
Writing Tests for Code Pieces That Have No Tests or Few Tests
Writing Tests for Code Pieces That Don’t Give Information Back
Verifying the Correctness of an Object Instance
Without Having Access
CHAPTER 2 .NET Runtime- and Framework-Related Solutions
Keeping Value Types and Reference Types Straight
Loading and Unloading Assemblies Dynamically
Loading Assemblies Dynamically Loading and Unloading Assemblies Dynamically
Thinking of .NET Generics as Black Boxes
Figuring Out What Generic Methods Do
Using the new and class Keywords with .NET Generics
CHAPTER 3 Text-Related Solutions
Converting a String to an Array and Vice Versa
Parsing Numbers from Buffers
Processing Plain-Vanilla Numbers in Different Cultures
Managing the Culture Information
When to Use StringBuilder
Finding a Piece of Text Within a Text Buffer
Always Implement ToString
Using a Disposable Type to Find Multiple Text
Pieces and Iterate the Results
Making ToString Generate Structured Output
CHAPTER 4 C# Coding Solutions
What Does the Yield Keyword Really Generate?
Using Inheritance Effectively
Naming Conventions for a Namespace, a Class, and an Interface
Understanding the Overloaded Return Type and Property
- Class and Interface Identifiers
Nullable Types: A Null Is Not Always a Null
Abstract-Class Bridge-Pattern Variation
Nested Private-Class Bridge-Pattern Variation
Dealing with Marker Interfaces or Base Classes
Editing Text Using the Command Pattern
Marker Interfaces and Their Dependencies
How Marker Interfaces Dependencies Are Implemented
A Null Value Is Not Always a Null State
The Essentials of the Factory Pattern
The Classical Factory Pattern
More Sophisticated Factory Implementations
Don’t Expose a Class’s Internal State
Designing Consistent Classes
Immutable Types Are Scalable Types
Understanding and Using Functors
The Comparer Functor The Closure Functor
The Predicate FunctorThe Transformer Functor
Functors in Practice
Avoiding Parameters That Have No Identity