Home > Articles > Programming > Windows Programming

Bill Wagner on C#, LINQ, and Writing Books

Paul Kimmel interviews "More Effective C#" author Bill Wagner on changes in C#, why LINQ is cool, and why he writes books.
Like this article? We recommend

In 1992, I read an excellent book entitled Effective C++: 50 Specific Ways to Improve Your Programs and Design. I still have the book. It sits on the shelf right in front of my desk. Effective C++ was written by Scott Meyers and edited by Brian Kernighan (of C programming language fame, a professor at Princeton).

Bill Wagner is continuing the series for the C# language, and Scott Meyers is his editor. Bill wrote Effective C#: 50 Specific Ways to Improve Your C# and is presently working on the follow-up book, More Effective C#: 50 Specific Ways to Improve Your C#. I talked with Bill about his experiences with .NET 3.5, LINQ, and his experiences writing books.

Interview

Paul Kimmel: Folks in the Midwest see you at user group meetings and code camps all the time. For people who have read your first Effective book, tell us about your day job.

Bill Wagner: I started messing around with software in the early 1980s and have been developing software professionally since 1986. In 2000, Dianne Marsh and I founded SRT Solutions, a small consulting company in Ann Arbor, Michigan.

Paul: You're also a board member of the Ann Arbor Computing Society and active with many other user groups. Your many contributions to the technical community led you to a regional director designation at Microsoft. What is a regional director?

Bill: I'm the [Microsoft] regional director for Michigan. In some ways, a regional director is similar to a Microsoft Most Valuable Professional (MVP). The difference is that a regional director encompasses a broad range of products, in contrast to an MVP, who is more focused on one single product.

Paul: Like the MVP designation, this is an unpaid position, but is recognition for your levels of contributions and feedback to Microsoft. What do you do as a regional director?

Bill: Regional directors provide feedback to product teams on designs and early builds, hopefully to improve these products. Toward the community, we provide information about new and upcoming initiatives that are being developed at Microsoft.

Paul: At user groups and conferences, that is, like the Professional Developers Conference (PDC). Are you going to the PDC in October in Los Angeles, and will you be presenting?

Bill: I am going as an attendee. I may be involved in some of the Open Space discussions, but I'm not presenting anything. I like the Open Space discussions because they're more conversational, and you get much more information on what challenges developers are facing in the real world. In most cases, I'm much more engaged when I'm involved and discussing, rather than just sitting back and listening to an eyes-front talk.

Paul: That's the same way I got through seventh-grade biology. Maybe an Open Space forum would be a great idea for user group meetings, too. Other ways you contribute clearly include your books. What was your first book?

Bill: I wrote the C# Core Language Little Black Book in 2001.

Paul: Your book More Effective C#: 50 Specific Ways to Improve Your C# (available October 2008) is like a sequel to your book Effective C#: 50 Specific Ways to Improve Your C#.

Bill: The C# language has undergone some remarkable changes since 2005, when Effective C# came out. There were enough topics to create an entirely new manuscript. More Effective C# almost exclusively covers new additions to the language since C# 2.0. Generics get a lot of coverage, as do iterators, which are C# 2.0 features that enable LINQ and the supporting 3.0 features. I also wrote two entire chapters on LINQ and C# 3.0, as there are quite a few items to cover. The remainder of the book covers topics that weren't covered in Effective C#—topics like multithreading and some advanced resource management. More Effective C# adds to the recommendations in Effective C#; it doesn't invalidate those recommendations.

Paul: What made you want to write a book in the first place?

Bill: I think it was insanity. But, truthfully, it's a great exercise to understand a topic fully. You must have a deep and clear understanding of a topic in order to explain it to a roomful of people. I'm sure you have the same experience when you're speaking or writing your own books. If there are topics that continue to excite me, then I'll write another book.

Paul: What made you decide to write these two books, specifically?

Bill: I spent a good part of my career developing in C++, before C# came around. Scott Meyers' Effective books were constant resources I used in those days. The format is very useful. If you can just keep your mind on the table of contents, you'll manage to write great software. It was also a more natural format for me to write. It's a series of essays, each of which describes one technique or one practice you should follow. I can continue to grow notes and create topics based on the questions I get from customers and the practices we develop [at SRT Solutions] to create high-quality software.

Paul: How much feedback did Scott Meyers have on your first Effective C# book and the upcoming More Effective C# book?

Bill: Scott is a very hands-on series editor. He provides quite a bit of feedback on the structure, the content, and the way it's presented. Scott doesn't provide a lot of technical review on the C# books, as he's much more involved in the C++ language. However, he's a brilliant guy, and he's able to improve my explanations on almost any topic.

Paul: What was the reaction to your first Effective C# book?

Bill: Quite a few people said that it helped them to understand a number of fundamental concepts in the C# language. Different developers told me that it helped them to understand why certain practices were accepted and certain practices are considered dangerous.

Paul: Since the books' messages are similar, although you have all new tips, how would you describe the audience for your Effective books?

Bill: One of the first bits of advice from Scott is that I should think of an Effective book as the second book a developer will read on a topic. Effective books are for professional developers who already have some knowledge of and exposure to the subject. In this case, More Effective C# is for professional C# developers who want to know more about using C# wisely, especially the newer language features.

Paul: How does More Effective C# compare to other books, such as O'Reilly's Cookbook series?

Bill: Most of the other C# books are comprehensive reference material. They cover the entire language syntax. Many even try to cover the bulk of the .NET Framework. Both of my Effective books assume that the reader already knows the syntax and some of the semantics of the language. My goal is to help them understand when to pick which language feature for what purpose.

Paul: Have you thought about how your book will help the reader? Can you elaborate?

Bill: C# developers have been given quite a few new features with which to work. The challenge is where and when to apply those new features. When should you use the query syntax? How should you apply extension methods to your applications? There are quite a few new tools and techniques to use. They all will help developers when applied correctly. However, like anything else, they can be misused. C# developers now have many new ways to write incomprehensible code—that's not going to help anyone. My goal is to show developers a roadmap of uses for these language features, making it easier for them to pull the right tool out of the language toolbox for the current problem.

Paul: There's a lot of buzz around Language Integrated Query (LINQ). You said there was a lot of coverage of LINQ in your book; what are your impressions of LINQ?

Bill: Personally, I'm very impressed with LINQ. It takes a while to get your head around the different syntax, and the new ways of expressing concepts. I like that now a developer can write middle-tier logic without concern for the storage for that data. The same query can be executed against databases, XML storage mediums, and objects in memory. Other people have created providers for Amazon, and other data sources. I really like the fact that algorithms now don't have to be rewritten for different storage mediums.

Paul: Do you have a favorite feature related to LINQ?

Bill: I like the deferred execution paradigm used by LINQ. It enables a lot of interesting uses. You can create algorithms that appear to operate on infinite sequences. Because the sequence gets generated as needed, you don't need to worry that the entire sequence space is way too large to work with effectively.

Paul: Does LINQ have "gotchas" that should worry your audience?

Bill: You can really get strange behavior if you mix deferred execution and eager execution. You end up getting different results if you modify variables after defining a query, but before executing it. It can lead to bizarre behavior and bugs that are hard to track. Both eager and deferred execution work, but mixing them can be very dangerous.

Paul: Where do you think LINQ will fit into the grand scheme of software development?

Bill: It's a huge shift for most developers. Very few developers know functional programming constructs. The overwhelming majority have spent their entire programming lives in either procedural or object-oriented languages. Functional languages traditionally have been reserved for academic use. The language features added in C# 3.0, while added to support LINQ, also support functional paradigms. So for the first time we have a language with both functional and object-oriented techniques as first-class language elements. It's getting a whole new set of developers interested in and exploring these concepts. I think it's going to be very significant and change software development. It's going to be a radical change for the C# community and for the software development community in general.

Paul: What are the benefits to the programmer using LINQ? What things can I do with LINQ that I can't do otherwise?

Bill: You can do anything without LINQ that you could do with LINQ. It's not like C# 2 or even C# 1 was crippled; there weren't whole classes of problems that you couldn't solve. However, LINQ enables new ways to approach many different types of problems. Because the syntax for Lambda expressions is much easier to create and read than the syntax for anonymous delegates, it's more likely that you'll write routines that expect Lambdas or delegates as parameters. The C# type inference capabilities are much better in C# 3.0 than in previous versions. It's much easier for developers to write generic methods and classes; developers using those methods and classes will be insulated from specifying the types as often as before.

Paul: Any advice for budding book authors?

Bill: Writing a book is similar to shipping software. It's an incredible amount of work, but it's extremely satisfying when you complete it. As an economic activity, it's not a great decision. You won't make the amount of money to justify the work. However, if you really want to dive deeply into a particular subject, it's very rewarding.

With that disclaimer, if you're still interested, the next step is to decide what you want to write. You must be deeply interested in a subject to write a book about it. Finally, look at your bookshelf. Pick a publisher whose books you read. Every publisher has its own style, and you'll be much happier trying to emulate a style you already read and find useful. As I said earlier, my copies of Scott's Effective C++ books are very well worn, so writing in that style was easier for me than molding my style to some other series.

Paul Kimmel is an architect for EDS and the cofounder of the Greater Lansing Area .NET Users Group (glugnet.org, Flint and East Lansing). Look for his new book, LINQ Unleashed: for C#. If you have a programming question, you can contact Paul at pkimmel@softconcepts.com.

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