For Programmers: Free Programming Magazines  


Home > Archive > Software Engineering > January 2006 > Code with Character









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Code with Character
tester384@yahoo.com

2006-01-26, 3:59 am

Code with Character
by Tod Golding

When I'm writing code, I like my types to be straight shooters. I'm not
into types that are complicated or mysterious. It's simply too much
work to figure out who they are or what they might expect of me. That's
why some of my favorite data types are those that are willing to be
direct and honest with me.
Take my good buddy, Integer. An Integer data type doesn't pull any
punches. He tells you he will hold signed numeric data, and that's
exactly what he does. You try to give him a string or a date, and
he'll laugh in your face. You'll get nothing unusual past him at
compile time. He's purely a "what you see is what you get" type.
Integer is about as trustworthy as they come.

The String type is a little harder to read. He tells me he's simply a
handful of characters that are supposed to representany old literal
string and, for the most part, that is what he is. But he can be
deceiving. One time I discovered him in an application where he was
holding numbers and dates. It was very disappointing. You think you
know a type, and then you find out he's been playing games with you.
Still, String can be a reliable data type. I think he just strays from
the path once in a while.

Some time ago, back in the era of COM, I knew a data type named
Variant. This guy was unlike any other type I'd ever met. He was an
integer, a string, an array, and almost any other type you'd ever met
before. At first glance, you couldn't tell exactly what he was.
Despite his nature, Variant was always good about telling you
what mood he was in. If he was feeling like an Integer, he'd tell you
outright. You had to ask, but he'd be very quick to let you know. So,
even though you couldn't determine his state immediately, he gave you
very reliable means of finding out. And for that I was grateful.

It wasn't until this Object data type rolled into town that I really
started to question data types. Object was unlike any other type I had
met before. He was the chameleon data type that could somehow be
whatever he wanted to be. It was as if he had looked at all the other
data types and asked if he could be something more, something that
broke through all the type boundaries. This '60s, free-love spirit
gave him a mystique that was extremely enticing.

Naturally, this disposition also made Object a very popular data type.
Everyone seemed to want to have him around. Object was clearly the life
of the party, and pretty soon he became the "in vogue" data type that
developers just couldn't resist.

Object's appeal seemed rooted in something deeper than pure sex
appeal. He really seemed to be adding value to applications. If you
wanted to write a data container, for example, the Object data type
allowed you to create a general container that could manage any type
that could be represented as an object.

Imagine how different the .NET Base Class Library would look if there
were no Object data type. ArrayList, Hashtable, and the like--all
staples of the BCL--are made possible by the existence of this type.

Visit http://www.stickyminds.com/bettersoftware/magazine.asp for more
information.

Bradley K. Sherman

2006-01-26, 3:59 am

In article <1138206638.955978.161420@f14g2000cwb.googlegroups.com>,
tester384@yahoo.com <tester384@yahoo.com> wrote:
>Code with Character
>by Tod Golding
>
>Imagine how different the .NET Base Class Library would look if there
>were no Object data type. ArrayList, Hashtable, and the like--all
>staples of the BCL--are made possible by the existence of this type.


Or just imagine how much better the world would be without .NET.

--bks

Phlip

2006-01-26, 3:59 am

Bradley K. Sherman wrote:

>
> Or just imagine how much better the world would be without .NET.


As usual, a language without dynamic typing jumps through hoops to simulate
some of the benefits of dynamic tying...

--
Phlip
[url]http://www.greencheese.org/ZLand[/url] <-- NOT a blog!!!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com