Examining the Calculator in Windows 7

Almost every book I write on programming has some element of application design in it. If you don’t create applications with a great design, users are less likely to use them. I examine general design issues in C# Design and Development. However, books like C++ All-In-One Desk Reference For Dummies, LINQ for Dummies, Professional IronPython, Start Here! Learn Microsoft Visual C# 2010 Programming, and Web Matrix Developer’s Guide all have design elements in them because I feel application design is extremely important. Even RibbonX for Dummies and VBA for Dummies have design discussions in them because they both talk about user interfaces. The most specialized book I’ve created about application design is Accessibility for Everybody: Understanding the Section 508 Accessibility Requirements, which discusses user interface requirements for those with special needs. All of these books have one thing in common, they all try to quantify what makes for good user design. They all ask the question, “How can you as a developer write an application that users will enjoy using and use efficiently?” Unfortunately, examples of poor design abound and seem to be more common as time goes on, which is the point of this post.

The Calculator application in Windows 7 is a perfect example of an application that has gone the wrong direction when it comes to the user interface. Sure, the Standard view is the same in both cases as shown here.

Calculator02 Calculator01

The Windows 95 version of Calculator is on the left and the Windows 7 version is on the right. As you can see, the buttons are the same, but someone at Microsoft felt obliged to rearrange them, just to make things difficult for anyone used to using the old version of Calculator. There isn’t a good reason for the change except to change for change’s sake. The Windows 7 version does have larger numbers, but at the expense of providing room for larger calculations. Personally, I’d prefer the Windows 95 version because sometimes I do need to perform really large calculations. Both versions of Calculator offer features such as digit grouping, so there isn’t any change here either. In short, Windows 7 offers less capability in a rearranged format that makes it hard for people who are used to the old version of Calculator to use it-breaking the rules of good design.

The problems get worse, unfortunately. I never used the Standard view of Calculator because I need to perform programmer math and scientific calculations relatively often. I did look into getting a calculator from somewhere similar to bestcalculators.net, however, I found that using the computer’s calculator a little easier for me while I worked. Switching to Scientific view in the Windows 95 version of Calculator, you see the perfect interface as shown here.


During the time I worked with Windows 95, I never switched out of this view. All I did was start Calculator whenever I needed it and did the math that I needed to do. Never once did the view I was in enter my mind. That’s great design! Users shouldn’t have to think about how your application works-the user’s only thought should be how to get work done.

The Windows 7 version of Calculator now has four modes: Standard, Scientific, Programmer, and Statistics. Every time I use Calculator now, I must first figure out what I want to do and change the view appropriately-wasting time and effort in the process. The views unnecessarily limit my options. For example, look at the Programmer view.


I do gain access to the RoL (rotate left) and RoR (rotate right) buttons, but I can’t think of when I’ll need them. The modern languages that most developers use don’t actually require these buttons. If I were using assembler, they could see some use, but I don’t remember ever using rotate left or rotate right with C#, Visual Basic (any version), Python, or even C++. So, these buttons are extraneous and only serve to complicate the interface. In addition, I do gain a bit display, which could prove helpful at some point, but I found that the Bin view on the old version of Calculator worked just fine and served my needs well. However, notice that the decimal point button is disabled. The loss of this button means that every time I have to perform any sort of math with a decimal point, I have to switch to another view. Programmers do use floating point numbers! So, a capable programmer calculator has been replaced with something less useful-something that makes me irritable and work harder.

Now let’s switch to Scientific view. Remember, I used to be able to do everything in one view. If I want to raise a value to a power now as part of checking application output, I have to switch to the Scientific view shown here.


As usual, someone felt that it was absolutely required to move the buttons around so that it takes a while to relearn how to use this view. For the most part, I don’t use any of the new features provided by this view. The few times I needed to use this feature with the old Calculator required a switch to Standard view, but the switches were seldom indeed. The Scientific view does include a number of additional features, all of which are likely helpful to someone, but the cost is one of having to switch views when you need to do something else.

Before someone writes to tell me that the new calculator has square root, cubed root, and root to any power buttons, the Windows 95 Calculator has these features as well. You just had to know how to use a calculator to understand them. Let’s say you want to find the cubed root of 27 using the Windows 95 Calculator. Simply type 27, check Inv, and click the x^3 button. You’ll see the cubed root answer of 3. Not convinced? OK, let’s try a quad root. Type 16, check Inv, and click the x^y button. Now, type 4 (the quad root) and press the = button. You’ll see the quad root of 16 is 2, which is the correct answer. The Windows 7 calculator adds nothing new in this regard-just more buttons to hunt and peck!

In short, the new Calculator is an example of a failed interface update. Most people will find that they have to constantly switch between views to get anything done. When you force people to think too much about the interface, they tend to get grumpy, less productive, and end up tossing out the application at some point. Personally, every since I found the Windows 95 version of Calculator runs just fine on my Windows 7 system, I’ve been using it instead of the broken product Microsoft has offered. The Windows 95 version truly is the superior application. Let me know your thoughts on Calculator and on application design in general at John@JohnMuellerBooks.com.


Creating Useful Comments

A major problem with most applications today is that they lack useful comments. It’s impossible for anyone to truly understand how an application works unless the developer provides comments at the time the code is written. In fact, this issue extends to the developer. A month after someone writes an application, it’s possible to forget the important details about it. In fact, for some of us, the interval between writing and forgetting is even shorter. Writing good comments is a main topic in C# Design and Development as part of Chapter 13, but I make the topic part of every application development book I write. Despite my best efforts and those of many other authors, many online examples lack any comments whatsoever, making them nearly useless to anyone who lacks time to run the application through a debugger to discover how it works.

Good application code comments help developers of all stripes in a number of ways. As a minimum, the comments you provide as part of your application code provides these benefits.


  • Debugging: It’s easier to debug an application that has good comments because the comments help the person performing the debugging understand how the developer envisioned the application working.
  • Updating: Anyone who has tried to update an application that lacks comments knows the pain of trying to figure out the best way to do it. Often, an update introduces new bugs because the person performing the update doesn’t understand how to interact with the original code.
  • Documentation: Modern IDEs often provide a means of automatically generating application documentation based on the developer comments. Good comments significantly reduce the work required to create documentation and sometimes eliminate it altogether.
  • Technique Description: You get a brainstorm in the middle of the night and try it in your code the next day. It works! Comments help you preserve the brainstorm that you won’t get back later no matter how hard you try. The technique you use today could also solve problems in future applications, but the technique may become unavailable unless you document it.
  • Problem Resolution: Code often takes a circuitous route to accomplish a task because the direct path will result in failure. Unless you document your reasons for using a less direct route, an update could cause problems by removing the safeguards you’ve provided.
  • Performance Tuning: Good comments help anyone tuning the application understand where performance changes could end up causing the application to run more slowly or not at all. A lot of performance improvements end up hurting the user, the data, or the application because the person tuning the application didn’t have proper comments for making the adjustments.

I had previously mentioned the need for good comments. Some developers write comments that are nearly useless. Although it’s hard to encapsulate the substance of a good comment, developers who answer these sorts of questions are well on their way to writing good comments.


  • Who is affected by the code?
  • What is the code supposed to do?
  • When is the code supposed to perform this task?
  • Where does the code obtain resources needed to perform the task?
  • Why did the developer use a particular technique to write the code?
  • How does the code accomplish the task without causing problems with other applications or system resources?

There are many other questions you could ask yourself, but these six questions are a good start. You won’t answer every question for every last piece of code in the application because sometimes a question isn’t pertinent. As you work through your code and gain experience, start writing down questions you find yourself asking. Good answers to aggravating questions produce superior comments. Whenever you pull your hair out trying to figure out someone’s code, especially your own, remember that a comment could have saved you time, frustration, and effort. What is your take on comments? Let me know at John@JohnMuellerBooks.com.


Contact Me, Please!

I ran across an online review of one of my books the other day. The author was mainly complimentary, but said he couldn’t contact me using e-mail and found that he felt alone in using my book. He obviously had unsolved questions and felt that he had been left alone to solve them by himself. Of all of the complaints I receive about my books, not being able to contact me for help is the one that hurts worst.

I want you to be able to contact me. In fact, I check several times a day, five days a week (Monday through Friday) for reader e-mail and try my best to provide same day support. The only exception is when I’m out of the office on vacation (I’m striving to provide an automated message to let you know when I expect to return to answer your question). Even then, the first day back from vacation is spent answering reader e-mail. Your comments, questions, and general observations are incredibly important to me. Just in case you haven’t seen it in the book, my e-mail address is:


If you purchase one of my books, you’ll see my e-mail address in at least two places: About the Author and the last chapter of the book as a bare minimum. I try to make it a point to mention my e-mail address five or six times in the book. In at least some cases, you’ll also find my e-mail address on the back cover.

Despite my best efforts, you may find it hard to reach me. If you can’t reach me for whatever reason, contact the publisher. Every publisher I work with has a Web site with a contact page. Normally, the publisher supports a forum in addition to an e-mail address (plus other contact methods that vary by publisher). If you contact the publisher, you can be sure that the publisher will contact me. The publisher knows it’s in its best interest to send any reader queries my way as quickly as possible.

At this point in time, I want to wipe out the “I couldn’t contact the author” complaint from the face of the earth. If you have anything to say about one of my books, don’t be afraid to contact me and say whatever is on your mind. You may be surprised to find that I care deeply about your needs and want to be sure you get the best possible use from my books.

That said, there are some people who try to take advantage of me. I won’t provide free consulting and no, I really am not a marriage prospect (I’ve been happily married for 31 years now). I truly don’t have time to debug your personal project, no matter how much it might interest me (and believe me, you readers have come up with some truly amazing projects over the years). However, if you have any question about my book, the source code, additional materials, or anything of that sort, please contact me, rather than assume I won’t treat you right.

Now, here’s an opportunity to tell me how to improve my books. If there is some other place that you’d like to see my e-mail address, tell me about it. I truly want to hear from you. Let me know where it would help to see my e-mail address so that you can contact me about my books whenever you want. I’ll be waiting to hear from you at John@JohnMuellerBooks.com.


The Release of Start Here! Learn Microsoft Visual C# 2010 Programming

It’s always exciting to see a new book released. I had previously told you about my new book, “Start Here! Learn Microsoft Visual C# 2010 Programming” in my post entitled, “New Book Announcement: Start Here! Learn Microsoft Visual C# 2010 Programming.” That post provides some basic information about the book, including a list of the chapters and what you should expect as content. Today this book is finally in print, so you can see it for yourself. Interestingly enough, I’ve already received a few queries about this book. I’ll answer the most commonly asked question in this post, which is what prompted me to write it.

Every time I receive an e-mail, see a review of one of my books online, or obtain information about a book in some other way, I try to see if I can use the feedback to improve later editions or to write a better book. In fact, I maintain statistics about each of my books because I really value your input and want to make the best use of it. The statistics I obtain from all of these forms of input help me understand how you use books better.

One of the comments I receive fairly often is that most books feel like college courses. They’re highly structured and seem most interested in teaching how to write applications using a stilted, old fashioned approach that doesn’t fit the reader’s needs very well. At least one reader has associated this approach with learning how to play piano using textbooks—you spend hours performing boring exercises to learn how to play something relatively simple. In the reader’s words, “Such an approach sucks every bit of joy out of the process of learning to play piano.” Yes, many people do learn to play piano using textbooks, but others learn to “play by ear” (simply by doing it without learning any basics first). These readers wonder why computer books can’t be written in a way that let’s you learn how to program using the “play by ear” approach.

I agree that not everyone learns in the same way. All other things being equal, one person may require a completely different book from someone else in order to get anything out of it because the two people learn differently. So, even if I wrote the most error free and comprehensive book ever written about C# application development, some people would love it and others would hate it simply because of the approach I took. Trying to solve this problem of writing a book that uses the “play by ear” approach has proven difficult.

To solve this problem, I needed to come up with a technique that would allow the reader to write code and then “hear” what the code does by running it. However, simply seeing the output isn’t sufficient in this case. In order to understand the code, the reader has to trace through itessentially “hearing” the individual tasks performed by each line of code. I tried a tracing technique for the first time in LINQ for Dummies and received quite a few positive responses about it. Now, LINQ for Dummies does use the college approach for the most part, but some sections use this new “play by ear” approach and it seems to work well for readers who require that approach.

It was with great excitement then, that I took on a book that would approach C# development from a completely different perspective after Russell Jones asked me about it. Start Here! Learn Microsoft Visual C# 2010 Programming is the result of my efforts. This book uses the tracing technique I started to develop in LINQ for Dummies extensively. Instead of spending hours learning about basic programming constructs and then writing tiny programs to put the theory into practice, you begin writing code immediately.

The main plus I see in using this approach is that nearly anyone should be able to learn to write useful (but basic) applications in a fraction of the time normally required and without devoting nearly as much time to the activity. The learning process should also be significantly less boring because you’re always doing something that has real world results. Of course, I’m extremely interested in seeing how this approach works for you, the reader. The only way I’ll get that information is if you write me at John@JohnMuellerBooks.com and tell me what you think of the book.

Source Code Download Issues

Most of my books include source code. The source code is made available on the publisher’s Web site and you download it from there. I always recommend downloading the source code to reduce the potential for errors. Typos are the number one source of problems for readers who work with the source code in my books. A single mistyped word will cause the application to fail in some way. If the reader is lucky, the compiler will catch the error and provide a clear message saying what’s wrong (such as the fact that the .ResX file is missing), but often that isn’t the case and then the reader becomes frustrated with the unworkable code. Sometimes the error isn’t even the reader’s fault—errors do creep into books (see my Errors in Writing post for details). The point is to use the fully tested downloadable source code whenever possible to save yourself time and effort.


There is another good incentive to download the source code. The reason to work through the source code in your debugger is to discover how it works through actual tracing. To help accomplish this task, the source code examples are carefully crafted to provide an optimal learning experience and they include features such as additional comments to help enhance the learning experience (see my Handling Source Code in Books post for details).

However, what happens when the downloaded source doesn’t appear to work either? Some readers have complained that the downloaded example won’t compile. Normally, the problem is one of a missing file. Firewalls and other network security features can strip out files and some organizations are proactive about stripping out anything that even looks binary. Consequently, the downloaded ZIP containing the source code is missing solution (.SLN), project (.CSProj or .VBProj), resource (.ResX), or other files. The project won’t compile with missing files. The best course of action is to try to download the source code from another systemone that isn’t inhibited by the network security features that stripped out the files.


Missing .DLL files aren’t normally an indication of a failed download. In most cases, missing .DLL files are part of a library or third party product you must install. The book will always include instructions on where to obtain these required add-ons and how to install them. Make sure you install any required additions as part of your system setup.

Sometimes a reader doesn’t have another way to download the file. Asking me to send the source code to you won’t help because the same features that strip out the files from the publisher site will also strip them out of the e-mail I send containing the files. In most cases, the firewall still downloads the actual source code. Create the project using the instructions from the book, and then copy and paste the source from the downloaded files into this new project. It’s not a perfect solution, but it should still work better (and faster) than typing all of the source code by hand.

A few readers have asked that I create a disk containing the source code and mail it to them. I’m not set up to perform this kind of support and the costs would be prohibitive. Unfortunately, if all else fails, you may have to try typing the source in by hand, but it should be your last option because typos really can ruin the learning experience. I’m always open to suggestions for making your reading experience better. If someone has a magic bullet solution that will help others get the downloaded source code in one piece, please let me know at John@JohnMuellerBooks.com.


LINQ for Dummies Examples and Older Versions of C# Express

A number of people have written me about the examples in LINQ for Dummies not working with older versions of Visual C# Express. I’ve tried to become more proactive about telling people precisely which version of language products I use to write a book so there are fewer surprises, but this isn’t one of those books. In this case, I used Visual Studio 2008 Professional edition and Visual Studio Team System 2008 edition for testing purposesI definitely didn’t test it using Visual C# 2008 Express edition. In every case that I know of, when the reader upgraded to at least Visual Studio 2008 Standard edition and read through Chapter 1 to understand the LINQ usage requirements, the examples began to work.

Of course, many people don’t have the funds to buy Visual Studio 2008 (or any other version of Visual Studio for that matter). So, I’ve decided to check whether the problem example that most people write me about (Listing 2-1 on page 30) will work with Visual C# 2010 Express edition, which is a free download. Before you begin then, download and install Visual C# 2010 Express edition on your system using Microsoft’s directions. I’m assuming that you’re performing a default installationaccepting all of the default settings and not installing SQL Server.

Once you have Visual C# 2010 Express edition installed, download the source code (if necessary) and locate the \Chapter 02\SimpleFromQuery\SimpleFromQuery folder. In this folder you’ll find a file named SimpleFromQuery.csproj. Right click this file and choose Open With > Microsoft Visual C# 2010 Express from the context menu. You’ll see the Visual Studio Conversion Wizard start up as shown here.


Follow the steps to convert the example to Visual Studio 2010 format. Use all of the default answers, including creating a backup of the original example, just in case you need it later. After you complete the conversion, press F5 or click Start Debugging. The example should compile and run. Click Test and you’ll see the results shown here.


In short, if you’re having trouble getting the examples to run using an older version of Visual C# Express, try the latest version. It does appear to work fine. I’ll check the remaining book examples just to be certain. If you do encounter problems with any of the examples working with Visual C# Express 2010, please let me know at John@JohnMuellerBooks.com.


Adding a Web Reference in Visual Studio 2010

There is a new wrinkle in working with Web services in Visual Studio 2010. In previous versions of the product, you could access a Web service by creating a Web Reference to it. All you did was right click the project and choose to add a Web Reference from the context menu. After entering a few bits of information, the IDE created a class you could use to access the Web Service for you. The process was quite simple because all you needed to do then is create an instance of the class and use the methods it provided to access the Web service as if the information was local to the machine.

The default operation for newer versions of Visual Studio is to create a Service Reference, which works differently from the Web Reference you used in the past. Service references are actually quite flexible, but they require a different technique to use. For example, I show how to use a Service Reference to access a Web Service using LINQ in Chapter 13 (page 278) of LINQ for Dummies. LINQ for Dummies is unique, however. Most of my books, including C# Design and Development, rely on the older Web Reference technique, as do all of my articles. This post provides a quick overview of the differences between the two techniques and examines how to create a Web Reference in Visual Studio 2010 (including all of the Express products).


Even though the source code in this post relies on C#, the same principles hold for Visual Basic.NET. In fact, the process for adding and using the Web Reference is almost precisely the same. If you’d like a Visual Basic.NET version of this example, please contact me at John@JohnMuellerBooks.com and I’ll provide another post.

Let’s examine the Service Reference technique first. For this example, I use an extremely simple Web service that’s free and works equally well using either technique. You can find the description of this Web service at http://www.deeptraining.com/webservices/weather.asmx. To begin, you right click the project entry in Solution Explorer and choose Add Service Reference from the context menu. After you type http://www.deeptraining.com/webservices/weather.asmx?WSDL in the Address field and click Go, you’ll see the information shown here (expanded so you can see everything).


Notice that I’ve also typed WeatherService in the Namespace field to give the Service Reference an easy name to remember. The Web Service offers a single method, GetWeather(), that requires a String containing the name of the city as input. The output is a String containing a single word weather forecast for the city in question. This example also has two textboxes, txtCity (contains the input string) and txtWeather (contains the output string), and a button, btnTest. Given this setup, here’s the code you’ll use to access the Web service using a Service Reference:

private void btnTest_Click(object sender, EventArgs e)
    // Create an instance of the Web service.
    WeatherService.WeatherSoapClient Client =
        new WeatherService.WeatherSoapClient();
    // Query the weather information.
    var Output = from ThisData
                 in Client.GetWeather(txtCity.Text)
                 select ThisData;
    // Clear the current information and output the
    // new information.
    txtWeather.Text = "";
    foreach (Char Letter in Output)
        txtWeather.Text = txtWeather.Text + Letter;

As you can see, the example begins by creating an instance of the Web service client. It uses this instance, Client, in a LINQ statement that calls on GetWeather() to obtain the weather for the city specified by txtCity.Text. The odd thing is that the Output actually receives a Char array that contains the weather information, so you have to use some method for turning that array into a string. The example shows just one method for performing this task.

Now, let’s say you need to use a Web Reference instead of a Service Reference. For example, a lot of people are encountering problems using this approach due to encoding problems. A number of Web sites use ISO-8859-1, which won’t work with this technique unless you build a custom encoder (see the article at WCF: Text Message Encoding and ISO-8859-1 Encoding for a discussion of this solution).

In this case, you start by right clicking the project entry in Solution Explorer and choosing Add Service Reference as you did before. However, this time you click Advanced at the bottom of the dialog box, which displays the Service Reference Settings dialog box shown here.


Notice the Add Web Reference button in the lower left corner. Click this button and you’ll see the Add Web Reference dialog box shown here. (I’ve already included the WSDL file URL and provided the name of the Web reference that you should use if you’re following along.)


Click Add Reference and Visual Studio will add the new reference for you. However, this reference appears in the Web References folder, not the Service References folder, as shown here.


I added another button to the application to test this Web Reference, btnTest2. The code is quite a bit different from the LINQ technique used for a Web Service as shown here:

private void btnTest2_Click(object sender, EventArgs e)
    // Create an instance of the Web service.
    WeatherService2.Weather Client =
        new WeatherService2.Weather();
    // Call the Web service method required to obtain the data.
    txtWeather.Text = Client.GetWeather(txtCity.Text);

Both event handlers produce the same result, using the same essential call, Client.GetWeather(txtCity.Text). The difference is that one uses a Service Reference with LINQ and the other uses a Web Reference with procedural code. So far I haven’t found a decided speed advantage for either approach. In this particular example, you type less by using the second approach, but that might not always be the case, especially as the Web service gains in complexity. The point is that both methods are available.

If you’re working with one of my books, you’ll probably need to use this second approach in most cases because it’s the approach that Visual Studio relied upon until recently. As always, let me know if you have any questions about this post or my books at John@JohnMuellerBooks.com.