2008-01-27

An Introduction to Why IT is Hard

The following is a self-quote from a thread I replied to at Ars Technica:

IT projects deal with complexities far greater in magnitude than other professions. Many managers and executives have no idea how complex things can be and often trivialize IT projects because of it.

The world doesn't yet seem to respect the insurmountable problems and dependencies IT projects face.

We've only had ~50 years of professional history. Architecture has had at least 7000 years. Planes haven't changed much in their use of physics in decades, but computer programs seem to use new languages, libraries, and toolkits every few years.

The absurdly rapid change in the IT world guarantees a rate of failure higher than all other industries.

2008-01-22

Code Simplification -- Lambdas FTW

Rick Brewster posted a beautifully simple try/catch wrapper for C# 3.0. I've wanted something like this for a few months now, but lacked the insight to figure it out on my own.

Read the linked article above for the full. Here's a sample usage of it.

string[] files = Patterns.TryCatch(() => Directory.GetFiles(@"C:\"), ex => new string[0]);
files.ForEach(Console.WriteLine);


Please note that files.ForEach is an Extension Method I wrote for simpler loops.

2008-01-15

I should have thought of this sooner

I'm tired of getting crap calls on my cell phone. I just created a new contact called "Ignore These Clowns" and added a number to it. Since there is support for multiple numbers per contact, and they all show up as the alias you define, I'll continue to add numbers of people I don't want to talk to to this bogus contact.

Granted, it may have no returns if the party doesn't call me a 2nd time. However, it's worth the few seconds of effort to add a number to my ignore contact.

2008-01-12

Book Recommendation: The Devil's Cup

The Devil's Cup: A History of the World According to Coffee by Stewart Lee Allen is an enjoyable travelogue tracing through some of the routes the coffee bean took around the world.

If you enjoy the Anthony Bourdain style of travel or dialogue, then you'll thoroughly enjoy this read.

There's no reason to waste more of your time reading yet another stupid book review when you could just visit Amazon for more professional reviews.

Read this book; even if it is just to find out what the "Joffe Theory of Coffee Expansion'" is really about. Or, you could just snoop it online.

2008-01-09

No More File Crap, Please?

Never write this code again in C#:

FileStream fs = new FileStream(logName, FileMode.Create);
fs.Write(logBytes, 0, logBytes.Length);
fs.Flush();
fs.Close();

Do this instead:
File.WriteAllBytes(logName, logBytes);

2008-01-07

Mental Decoding

Before falling asleep last night, I had the idea that our "mind's eye" may work like this:

1. All memories we experience imprint some sub/atomic level encoded message in to our body's cells. The brain isn't the only place where we store data.
2. All 'visions' of things we haven't directly experienced are decoded messages where the data is stored remotely and accessed using what we're discovering to be quantum behaviors.
3. Therefore, if properly trained, there is no difference between #1 and #2. Everything is available to everyone at all times.

2008-01-02

Code Performance -- The Fastest Single Threaded Option

I previously posted a screenshot showing the magnitude of difference between execution times for various ways of computing some total value.

Here's the relevant source code for the fastest single threaded option, ListIntGenericsForEach

for (int i = 0; i < Max; i++)
{
li.ForEach(foo => { total += foo; });
}

2008-01-01

RSS Feed Update Required

Please update your RSS feed URL to the following:
http://www.e128.info/feeds/posts/default

Required C# Extension Methods

Every programmer should use these simple extension methods to make their loops easier to read.


///
/// ForEach extension method for strongly typed IEnumerables
///

public static void ForEach(this IEnumerable source, Action action)
{
foreach (T item in source) action(item);
}

///
/// ForEach extension method for IEnumerables
///

public static void ForEach(this IEnumerable source, Action action)
{
foreach (T item in source) action(item);
}