Wednesday, January 12, 2011

Visual C# .NET Programming





Harold Davis

The Structure of This Book: About the Musical Part Names

Since C# is a programming language named after a musical note, I thought it appropriate to involve musical concepts when structuring this book. In keeping with this, I've named each of the four parts of the book after movements in a classical composition. These movements prelude, allemande, courante, and gigue-primarily are found in Baroque music. Musical scholars should note that I have not been compulsive about the accuracy or consistency of the musical metaphor. The point really is the metaphor and how it relates to the structure of this book and to programming in C#.

The structure of the book is essentially spiral, like a chambered nautilus shell or the pattern in this volume's cover photograph of a Zen garden. By the end of the book, readers will be able to comprehend and accomplish things that seemed shadowy and mysterious when they plunged in at the beginning. Each of the four parts represents a different stage in this quest for skills and understanding.

Part 1: Prelude-Service with a Smile
In classical music, the prelude introduces the work. Often composed in a free-flowing style, it sets the mood and mode for the rest of the work and is designed to pique the interest of the audience. It can contain references to ideas that are delivered later-foreshadowings, a taste of things to come. The themes in the prelude are not whole ideas but snippets, motifs-just enough to whet the appetite and make the listener want more. These motifs are pre-echoesnot déjà vu, which are vague memories of things already seen, but rather premonitions of things to come. If you listen to the composition more than once, then in the prelude you should be able to begin to hear the pattern of the entire piece.

At the same time that a prelude introduces the larger work; it is an organic unit in and of itself, with a beginning, middle, and end. This cohesive mini-composition exists within the larger whole and has its own sense of narrative conflict and resolution, point and counterpoint, all reconciling in a conclusion that serves as an introduction.

Our prelude introduces the theme of the web service. Web services have been hailed by some as revolutionary: a brand new kind of unit of executable code, fit for the distributed environments of the Internet age.

A web service is not an end in and of itself. To actually do anything as a part of a program, it must be used-or, put another way, 'consumed.'

It is also the case that this book is not 'about' web services; it is about programming in the C# language and the .NET Framework.

Our prelude explores creating a web service, in Chapter 1, 'Creating a Web Service,' and coding ASP.NET web applications to consume the web service, in Chapter 2, 'Consuming the Service on the Web,' as a dramatic way to jump into the topics that will form the pattern of the composition that is this book. Keep your eyes and ears open for premonitions that reveal this book's real themes: the best way to write C# code for clarity, and patterns and practice of communication between objects.

Part II: Allemande-Striding Forward

The allemande is a movement of great substance that directly follows the prelude of a musical suite and picks up where the prelude leaves off. It is stately in manner and can be highly stylized. The allemande carries forward the mood prefigured in the prelude and introduces gravity into the suite; but the prelude's free style gives way to the processional-like regularity of the allemande.

The sentiments casually introduced in the prelude have become a stepping dance with reality and the allemande keeps it all moving. The meter is steady and so is the progress. The allemande is striding forward without hesitation into the future, and the future is now.

Early allemandes come in three sections, or strains, that are related but not the same. The second strain contrasts with the first strain. They resolve in the third and final section, which paves the way for the next movement in the composition.

You can't have an application without a user interface. Chapter 3, 'Windows Uses Web
Services, Too!,' is an introduction to programming the Windows user interface-while carrying
on the web services motif explicitly introduced in the first part of the book. The allemande
also keeps one of the underlying themes of this book moving, with an explanation of the
asynchronous communication design pattern.

Chapter 4, 'Building a Better Windows Interface,' is about the hard-core plumbing of a
Windows interface. Services have been left behind. This is the territory of displaying lists of
items, menus, common dialogs, and such. This strain of the allemande may be concerned with
conventional Windows development, and it may be a little dissonant, but it has a sense of
humor. For example, you'll start this chapter by making round buttons dance.

The allemande is complete with Chapter 5, 'Reflecting on Classes.' We've taken strides
forward and are now past Windows, in the realm of objects and classes. This chapter fits C#
code in with the .NET Framework. Once again, it's about communication. Classes are not
islands, and they must be instantiated to be used. It is a time for reflection, for understanding
of ourselves and our environment, and also to soar the peaks of what is possible-knowing that
soon we must return to the humble arenas of language and syntax that make it all possible.

Part III: Courante-The Dance of the Language

The courante is a dance movement of vigor and complexity. It is rhythmically interesting and exciting, but capable of hard work. A courante combines playfulness and movement with heart, soul, and substance.

Courantes were used for dancing in court and in theater, and later as stylized movements in instrumental music. The form combines rhythmic and metrical fluidity with a complicated texture.

This part, the courante, is in many ways the heart and soul of this book.
We start with Chapter 6, 'Zen and Now: The C# Language.' What could be more iportant
than a good understanding and grasp of syntax of the beautiful C# language?

Moving on, Chapter 7, 'Arrays, Indexers, and Collections,' shows you how to work with
groups of objects-and make them dance. Chapter 8, 'The Life of the Object in C#,' is all about classes and object-oriented programming. Since all programming in C# is class-based and object-oriented-the only question is whether the programming is good object-oriented code or bad object-oriented code-the material in that chapter is iportant. I think the running example in

Chapter 8 is quite a bit of fun. This program is a simulation based on the ideas of Pulitzer Prize-winning author Jared Diamond. As you'll see, the program allows users to track the rise (and fall) of tribes and civilizations.

Strings are everything, and everything is string. If you know how to manipulate strings, you know lots of things-and you'll find out how in Chapter 9, 'Everything Is String Manipulation.'

Our courante has proceeded from language and syntax, and onward through arrays,
collections, objects, and classes. Coming back to the beginning, it has explained the sophisticated manipulation of language elements. This is a complex dance, a spiral within a spiral. As the courante winds down, we're ready to move onward-by looking outwards instead of inwards.

Part IV: Gigue-Leaping to Success

The gigue-which became a popular Baroque movement-probably originated in Great Britain as the 'jig' or 'jigg' (although note that the Old French verb giguer means 'to leap' or 'to gambol'). Whatever the derivation of the word, it's clear that in Elizabethan times a jig was a dance-notably performed by Scottish lairds-that involved a great deal of jumping (or, as one contemporary put it, the dance is 'full of leapings').

In the context of our gigue, this remains true: the movement is full of leapings. It is happy, exuberant, full of life, and extroverted.

It's time to turn the knowledge we've learned in the early movements outwards-and use the gigue to interact with the world.

Chapter 10, 'Working with Streams and Files,' shows you how to work with files-and,
generally, how to serialize objects.

Chapter 11, 'Messaging,' explains how to program messaging applications. Using message queues, as you'll see in Chapter 11, it's possible to build families of applications that divide workloads and start and stop each other.

Chapter 12, 'Working with XML and ADO.NET,' covers interacting with XML and databases.

Chapter 13, 'Web Services as Architecture,' wraps it all up. Coming back to the beginning after all, Chapter 1 started with a web service-we can use the sophisticated tools and techniques that we've learned in order to build web services that are truly exciting! The chapter concludes with an example showing how to use the TerraServer web service and display aerial photos or topographic maps of almost anywhere in the U.S. at a variety of magnifications.

And, finally, the gigue is up! Now programming in C# is up to you…


Another C# Book
Another .NET Books
Another Programming Language Books
Download

No comments:

Post a Comment

Related Posts with Thumbnails

Put Your Ads Here!