Categories
Technology Writing

Creating C# Applications: Chapter 1

Introduction

There’s been considerable material on programming C# within the Visual Studio .NET environment, but not as much on C# as the first programming language based on the Common Language Infrastructure (CLI).

This online C# book provides an introduction to C#, the programming language. In addition, the book also takes a look at the CLI as well as the Common Language Runtime (CLR), using C# to demonstrate the various aspects of this standards-based development environment.

We’ll explore CLI/CLR in more depth in other chapters, but for now, to get you started, we’ll take a look at the basics necessary to get you up and running with C#.

The Basics

You can’t work with a programming language without learning the basics of creating an application in that language. Some languages, such the version of Basic found in Visual Basic, are a language and development environment tightly bound into one tool. Others, such as C++, can be bound to a development environment (ala Visual C++), or can be worked with using command line compilers and standard text editors, such as C++ within a Unix environment.

Fundamentally, you need to learn how to create the simplest form of an application in the language, compile it, and then run it. Once you have this information, you can then vary your program as you learn new and different aspects of the language.

This chapter provides an overview of how to create and compile a C# application using the minimum environment — in this case, using the .NET Framework SDK that’s downloadable, for free, from the Microsoft web site.

The Structure of a C# Application

Before installing the C# support environment, let’s take a look at a minimal C# application.

A C# application can consist of one or more modules — separately compiled functional units that don’t have a main entry point — libraries (comparable to COM components), and at least one application entry point. A C# file has an extension of .cs, and may, or may not, contain a Main application method.

A minimal C# application can have the following format:

using System;

class someClass
{
   public static void Main() 
   {
   }
}

As you can see, a minimal application doesn’t require a lot of code, requiring only the following:

  • A reference to the System namespace
  • A class
  • A main function within the class, that’s called when the application’s run

Applications written in C# access external functionality through the use of namespaces — a container for classes, structs, types, and other useful programming goodies (namespaces are described in greater detail in a later chapter, “C# Scoping and Namespaces”).

C# files contain one or more class definitions. In addition, the files can also contain other C# elements such as interface definitions, delegates, and enumerations. A stand-alone application also has a Main function, called when the application is run. However, to create and run the application, you first have to install the environment.

The C# Environment

As with Java, C# is dependent on a runtime environment being present in order to support the language. Java depends on the Java Virtual Machine (VM) and C# is dependent on the Common Language Runtime (CLR), a set of services providing security, type safety, cross-language exception handling, garbage collection, and other features. An application that contains code meant to be managed by the CLR is known as managed code; code outside of the CLR control is know, appropriately enough, as unmanaged code.

There are five different CLR hosts that support managed code:

  • ASP.NET (for server-side Web access)
  • Internet Explorer (for code implemented within the boundaries of the browser)
  • VBA (for script executed within the confines of Outlook or Office or other VBA enabled applications)
  • Windows Form Designer
  • Windows Shell EXE (for applications launched by a command line)

The last CLR runtime host is the one we’ll be using throughout this online book, primarily because this host allows us to focus on C# as a language, rather than C# as being part of ASP.NET or Web Services, and so on. Once you have a command of the language, then you can explore the other more complex uses of the language, such as those just mentioned.

In addition, you’ll be using the command line compiler when creating each of the test applications rather than creating the examples within Visual Studio. Again, this puts the focus on the language rather than the development environment. However, to run the application, you first have to compile it, which means you have to have both the infrastructure and compiler installed on your machine.

Categories
Just Shelley

X-Objects Introduction

Copy found on Wayback Machine.

Since Dynamic HTML was first introduced in 1997, I’ve always provided code that allows DHTML to be used with the two most popular browsers: Netscape’s Navigator and Microsoft’s Internet Explorer. To make cross-browser DHTML easier to work with, I created a set of cross-browser objects, which I’ve used for all of my DHTML effects.

These objects have now been updated to work with IE 6.0, Netscape 6.x, and the DHTML that should be supported with Mozilla 1.0 when it releases in 2002.

Cross-Browser out…cross-DOM in

Netscape 6.x is a complete re-architecture of the older 4.x browser. Originally the Netscape folks were incorporating new technologies such as CSS and XML into the existing Navigator, and were planning on rolling this out as Navigator 5.0. However, last year these same folks decided not to try and hold onto an architecture that just wasn’t compatible with new Web standards. Instead, they, and the Mozilla Group, started fresh, re-building the browser layout engine from the ground up.

Because Netscape 6.x is built from the ground up, and based on current and upcoming standards, you’re going to find that many of the features supported in Navigator 4.x are no longer supported. This includes the use of layers as well as JavaScript styles (JSS). Instead, Netscape 6.x embraces CSS (both CSS1 and CSS2), as well as XML, and the DOM Levels 0 and 1 (and partially DOM 2 from what I can see) releases from the W3C.

As you can imagine, this is going to have an impact of your Navigator-only or cross-browser DHTML effects. How much so could surprise you.

Changes…

The implementations for DHTML for the new DOM-compliant browsers (Mozilla/Netscape 6.x) is the same as that for IE 4.x and up — for most of the functionality. This includes hiding and showing an element using the visibility CSS attribute, as well as moving an element and changing the element’s width, using the respective CSS2 attributes. In fact, Netscape 6.x is going to be closer in functionality to IE than it will be to Navigator 4.x. Read more on shared functionality in the sections “Movement and Visibility”, “Element Height and Width”, and “Layering and Z-Order”, found at the bottom of this page.

One nice surprise is that event handling with Mozilla/Navigator 6.x is quite easy to incorporate into your DHTML effects, thanks to the new Event-based objects in the DOM Level 2. Very little code had to change in my DHTML applications based on event handling, though each DHTML page did have to change (event handling is not part of the X-Object implementation — See the article section titled “Events”).

We’ll explore the changes between Navigator 4.x and 6.x, as well as the new DOM functionality, as we convert my existing cross-browser objects to the new, improved X-Objects.

Categories
Just Shelley

51,000+ DotCom Layoffs…

Recovered from the Wayback Machine.

Being one of those that are part of a steeply growing curve, a layed off dot comer, I found the article Silicon Valley Workers Head Home in the Australian IT to be very interesting.

According to a source quoted in the article, there have been over 51,564 people laid off from DotComs…to date.

I bucked the trend and actually moved to San Francisco from Boston — and I found a new contract within a couple of weeks. Note, though, that I do have a number of years of experience, and with some fairly significant technologies. Still, before we attend a wake for the Internet, time for a reality check folks. The Internet and technology businesses are down, but they ain’t dead.

Categories
Just Shelley

New City, New Servers

The Burning Bird Corporation is now open for business in beautiful San Francisco. What can I say folks, but I love this city!

In addition, I’ve aggregated all of my web sites on to one server. Hopefully the move will go smoothly, but if you find pages missing or out of synch, most likely they didn’t survive the move. Please send me an email with the missing reference.

The Burning Bird (formerly known as YASD) is being joined by other web sites on the Burning Bird Network. Among the new Webs to be posted will sites focusing on travel and art. Man does not live by technology alone…and neither does Woman.

If you’re in the San Francisco area, drop me an email, say Hi, let me know the good restaurants, walks, etc. I would be appreciative.

Categories
Writing

Bits of prose

A long time ago in a place far, far away, and long before I started writing articles and books on computer technology, I used to write poems. Well, I called them poems.

Recently, I found a folder of poems and decided to put my three favorite online. I’m aware that this could result in a mass exodus from Books & Bytes, but what the hey, we all have to live on the edge sometimes.

One poem is about breaking up; one was written in protest of war and conflict; and one is about the Holocaust. Three different subjects with one common theme of loss — from the personal to the profound.

Letting Go

This poem is about breaking up and landing on your feet.

Love Lost. Letting Go. We hold on with clutching, grasping hands.
Desperation. It really does hurt.
     Grasp a rose, and let the thorns sink deep.
     We choke the flower through fear of the release.
        As if...
            we can stop....
                 the pain...
     By not letting go.

Letting Go. It means loss and loneliness. 
What will I do without this person? 
I can't imagine life without him. It's really 
hard to smile and laugh and to enjoy just 
getting up each day.
     Hello sunshine and good-bye and 
     please go away.
     I would rather have clouds right now,
     okay?
        As if...
            we can stop...
                the pain...
     by enjoying it.

Enjoying it? Yes! We throw ourselves into the loss and live within it.
That will show him! Look at what he has done to me! 
But guilt is an odd sort of weapon.
     With guilt as the hook and 
     self-pity as the line,
     the fisherman may catch a fish,
     that bites back. 
        As if...
            we can stop...
                the pain...
     by using tricks.

Tricks belong in magic shows, not in love. 
If you use tricks to keep a love alive, eventually it 
will turn ugly.
And then what will you have?
    The beauty of the dreaming is in the 
    waking.
    Then you have something to carry 
    with you all day.
        As if...
           we can stop...
               the pain...
    by remembering the joy.

You can hold love within a memory. Tuck a little away 
somewhere in your mind. Bring it out to give yourself a smile
sometimes. 
It's hard now, but it will get easier. 
Sometimes the true test of love is not the having,
but the loosing. 
Choose to walk away a better person.
    Walking away.
            You can...
               You can stop...
                  the pain...
     by just letting go.

Tommy Joe is Dead

I wrote this poem a long time ago, and it included references to violence in Tel Aviv and Rhodesia — hot spots at the time. I’ve modernized the references, but unfortunately, the sentiment is still fresh.

Tommy Joe is Dead.

Some would call it fate,
he died that day, that way,
that year.
Others would call it bad luck.
Those who loved him can only cry,
shake their heads and wonder why.

Tommy Joe is Dead.

Mom and Dad had high hopes, 
their boy would be the best.
All their frustrated dreams 
would be lived by him, through him.
He would be what they wanted to be,
and never dared.

Tommy Joe is dead.

Carrie was his love, his hope,
his future mate.
Together they would change the world,
make the world;
high hopes only youth can feel,
high dreams only youth can dream

Tommy Joe is Dead.

He could be your lover, your brother,
son or friend.
He could have been your father 
if fate, or luck, had been different.
He is a memory now, perhaps forgotten,
that most noble soul -- 
a person who died for a cause.

Tommy Joe is Dead.

He died in the jungles of Nam,
the streets of Ulster;
a young boy shot down in Uganda.
A nameless face, a faceless name,
all for a cause.
How sad, a young life wasted.

Tommy Joe is Dead.

The Burnt Offering

The television mini-series “The Holocaust” was first telecast when I was going to college. A history teacher at the school had a three day class on the Holocaust that I attended.

On the last day of the class, the teacher had us go to an auditorium where he showed film after film of the atrocities committed by the Nazis.

I attended the showing with a close friend who was Jewish, and she broke down in sobs during the films but wouldn’t leave. None of us could leave. Aside from the people crying, there wasn’t a sound in that auditorium — not a sound.

The poem “Burnt Offering” was a result of this day. I’ll never forget. Will you?

My eyes have been opened.
I can no longer plead ignorance 
because I know, and that knowledge 
will not leave me!

A thousand voices cry out, 
"Do not forget us, Remember!"
A million faces haunt my dreams.
The responsibility is mine -- 
not to forget, the Curse of Man.

We turn from the ugliness,
not in disbelief but in recognition.
We fear our inner animal.
To see ugliness in others,
is to see it within ourselves.

We fear that which is different.
We fear ourselves, and what 
we can do.
And we fear these fears, 
and hate steps in.

We turn from knowledge; the 
price of knowledge is responsibility.
We don't know if we have the strength
to accept, so we turn.

I will turn no more!
I will learn, though 
learning is pain.
And I will not forget the warning,
of the Burnt Offering.