Is IT Culpable in the Decline of the United States?

December 14, 2009 just3ws 1 comment

Think about the application you are working on right now. What does it do? I don’t mean whether you’re writing some fancy bit of technological wonder. I mean what does your application *do*? Does it automate monitoring a factory production line to monitor for a mechanical failure or maybe you’re working on an application to allow people to work through an expert system to self-diagnose some issue they are having with their washer-dryer. Both of those are interesting and useful applications of technology. They make the business owner happy and they make the customer happy that they were able to figure out what the flashing H7 on their dryer means.

Making the business owners and system users happy is traditionally the primary goal of any IT initiative. We make them happy through improved automation, reduced manual intervention, and streamlined business processes. Investors money is saved, profits for owners are increased and users have a better experience. Those are what I care about as a developer, making my employer and users happy. So my action is to streamline processes and increase automation thereby making my customers happy.

Lex III: Actioni contrariam semper et æqualem esse reactionem: sive corporum duorum actiones in se mutuo semper esse æquales et in partes contrarias dirigi.
”To every action there is always an equal and opposite reaction: or the forces of two bodies on each other are always equal and are directed in opposite directions”.
– Newton’s 3rd Law of Motion (wikipedia)

If you were to apply the 3rd Law in this context you may see that there is an inverse to my actions. The energy of my actions isn’t being applied to an immovable force there is a reciprocal force being felt on the other side of my efforts.

If by increasing automation I am making my employer happy on the other side of the equation there is someone who was previously doing that automation that is no longer happy. She is no longer needed to do that work and has become redundant. Maybe not exactly that person, but maybe a chain of effects that reverberates down a hierarchy that ultimately ends up with someone not getting a job because it was eliminated by my automation. Action eventually leads to reaction.

If by streamlining a process there may have been a manual step that would have required a human interaction for the customer. That probably would have been by a phone call or a visit to a store. That means that somewhere down the line that salesperson or call-center representative would be eliminated due to increased efficiencies in the process. Again, eventually the action leads to a reaction.

For years my father has been pointing out this fact to the very workers who’s jobs are at risk. If a store implemented self-checkout counters he would go up to the cashier, point to the automated counter and say “There goes your job.” He also felt compelled to say this to the bank clerks with regards to ATM’s. The truth of these observations appear to be coming more and more apparent each day. As we see more stores adopting self-checkout counter and ATM’s have become ubiquitous.

This brings us to the question of whether the has been sufficient impact caused by IT initiatives of the past 10-20 years that has helped put the United States economy at risk? Has the reduction of the manual work force been sufficient to facilitate the current economic decline? I don’t know, but I believe it is an important question that needs to be asked. And if there has been an impact what can we do as IT professionals to responsibly continue in our careers? How can we achieve a balance between maintaining social integrity and advancing our industry?

I believe that it is possible. Individually we must respect our role in our industry and approach our day to day job with as much professionalism as possible. Learn your trade inside and out so that you can work as correctly and efficiently as possible. By focusing on professionalism, quality and correctness we will help our employers save money on failed projects and redundant systems. I believe that saving money on failed projects will help companies to continue to employ as many people as possible while still achieving higher efficiencies. As an industry we need to emphasize methods to augment the manual labor forces efforts versus replacing them. I would even call for our government to completely review our H1-B system to ensure that employers are correctly using and applying the system to only hire non-citizens for specialized work where there is a shortage.

Categories: professional, thoughts Tags: ,

The Trouble with Titles

December 9, 2009 just3ws 11 comments

Chief Principal Senior Enterprise Solutions Architect Manager

Somewhere in the world there is someone with a title just like that. In my previous employer I ended up with the title “Director of Information Systems and Technology.” Which was partly my fault because I didn’t really know how to describe a title for “The Person Responsible for Pretty Much All Technical Decisions and Implementation.” It wasn’t an ego title, just an unfortunate one. And that title made me less likely to hand out my business card because I felt awkward handing out something with that string of words next to my name. Later I changed my title to “Principal Developer” which I felt was more accurate and less of a mouthful.

Now that I’m starting to move down the path of being a contractor and an independent business owner what is an appropriate title? “President” or “CEO” seems pretentious unless it’s on a form for the government or simply a statement of my role in my company. Generic titles also seem to distance me from how I perceive myself as being a software developer first and foremost. “Software Developer” seems accurate but might be limiting to people who don’t share similar views as to what being a software developer means. I like the title used for independent truck drivers, “Owner Operator.” It’s a title in the trucking industry that implies you are both the owner of the business and that you are also a driver on the road. Why don’t we have something like that in the software development field? “Owner Developer”, I think that has a nice ring to it.

[edit: Apparently I don't know the difference between 'principle' and 'principal'. Thanks to Sergio Pereira for pointing that out. :)]

Categories: thoughts Tags: , ,

The Poor Developer’s Object DataStore: Iteration 000

December 2, 2009 just3ws Leave a comment

This is part zero of a multi-part series. Jump to The Poor Developer’s Object DataStore: Iteration 001 for the first code drop.

What is an object datastore? For an object-oriented developer it’s as easy to use as a typed collection. No need to build and maintain a complex relational model to simulate the native object functionality. Just create your object, modify it, store it, query for it and delete it. All the complicated work is handled by the object database engine. But let’s consider a situation where you may want to “roll your own” light-weight object datastore. And depending on your situation, it might make sense. CAVEAT: Rule #1 of Software Engineering: If You Can Use A Proven Product Don’t Write Your Own. They Did It First And They Did It Better. But for the sake of exercise and trying something new let’s just ignore that rule and keep on going.

Consider the following scenario. You’re a .NET developer and you’ve been tasked with creating an archiving system. The system needs to take a snapshot of the data and store it to be queried against and reported on later.

How would you implement this? Would you copy the data structure you’re looking to archive and pull the data state into there? How do you manage foreign keys? Do you squish the data into a single table? Do you recreate all the tables with annotations to identify the archived records? Now, it’s a few months later and the original data structure has changed. How do you handle that change in your archiving?

Do you really want to recreate that complex data structure and try to wrangle the data into it and manage it over time? No, neither did I and I think there is a better way. Let’s consider a new way: an object datastore.

Let’s get this out of the way. Object databases aren’t just for ninjas although they are often wielded by ninjas. An object database is exactly what it sounds like, a database for your objects. No sql, no tables, no object-relational impedance. Just objects persisted similar to how a relational database allows you to store and persist tabular information offline without all the grief of mapping your object-oriented structure onto a relational model. Instead you create your objects and using the database’s API you can save and query for your data without worrying about sql or any of that mess. My personal favorite OODBMS (object-oriented database management system) is db4o. I recommend downloading and playing around with it to get a feel for how simple it is to use. (If you want to learn more about various types of *DBMS check out the great presentation by Ben Scoffield at WindyCityRails 2009 – “Comics” is Hard.)

There’s one catch to using db4o in a closed source or proprietary project. You can either pay to license the product. It’s not too expensive for bringing into a medium sized project. Or you can release your project under GPL. For the project I was working on, neither option was palatable for our client. Also, I didn’t want to introduce yet another external dependency that our client would have to manage. Instead I created the simplest possible implementation of an object datastore I could using only native .NET and Microsoft Sql Server functionality.

Continued in The Poor Developer’s Object DataStore: Iteration 001.

The Poor Developer’s Object DataStore : Iteration 001

November 28, 2009 just3ws Leave a comment

In The Poor Developer’s Object DataStore : Iteration 000 we proposed a possible motivation for wanting to store complex objects in a database without resorting to creating a complicated relational model.

For our first iteration we need only to be able to create and read the object from the database. It’s not going to be necessary to update or delete the data at this point. Only store and read. So why bother recreating the original data structure? Why not just query for the data with your ORM of choice and then serialize that result to Xml and store that? If you’re already using Microsoft Sql Server 2005 or later you’re already in a very good position as MSSQL provides the Xml datatype which makes storing, querying and retrieving Xml data very
easy and efficient.

If you are using an ORM for your data-access (you *ARE* using an ORM aren’t you?) then you’re already halfway there. My original implementation utilized custom objects that implemented an IStorable interface. Basically, I used Linq to Sql to query the data I wanted to archive and mapped the query result to an object that implemented the interface. Using that I could save the object into the datastore in a similar manner to Active Record. This was very easy to do.

public interface IStorable<T>
{
  string ConnectionString { get; set; }
  string Serialize();
  T Deserialize(string xml);
  XmlSerializer CreateSerializer();
  int Save();
}

So I could load up my data into a custom object, set the connectionstring and then automatically save it into the database.

//a sample unit test demonstrating usage of the IStorable object.
public void TestStoreFoo()
{
  var foo = new Foo();
  foo.Id = 100;
  foo.Name = "Penelope";
  foo.ConnectionString = "__YourConnectionString__"
  var objectId = foo.Save();
  Assert.That(objectId == 1);
}

So here’s the implementation. If you wish to grab the source code don’t try to cut and paste it from here. All the source code for this blog post can be browsed and downloaded from GitHub.

Source Code for Iteration 001

First we must implement the IStorable interface. The interface must take the implementing type as it’s generic argument. This is because we’re providing functionality for the object to serialize and store itself.

public class Foo : IStorable<Foo>
{

The Foo.Id and Foo.Name are our data. They are not part of the IStorable implementation.

  public int Id { get; set; }
  public string Name { get; set; }

We need to provide the connectionstring to the database where the objects are going to be stored.

  public string ConnectionString { get; set; }

Now we’re getting to the fun part. We will use an in-memory stream to serialize this instance of the Foo object and then write it to a string.

  public string Serialize()
  {
    string output;
    using(var buffer = new MemoryStream())
    {
      new XmlSerializer(typeof(Foo)).Serialize(buffer, this);
      buffer.Position = 0;
      output = new StreamReader(buffer).ReadToEnd();
    }
    return output;
  }

The deserialize method takes the xml as a string from a previous serialization and will attempt to convert it back into a Foo instance.

  public Foo Deserialize(string xml)
  {
    return (Foo)new XmlSerializer(typeof(Foo)).Deserialize(new StringReader(xml));
  }

In order to serialize a type we must create a typed instance of a serializer object. Here we’re just creating a Foo serializer and setting the error event handlers to output it’s errors to standard output.

  public XmlSerializer CreateSerializer()
  {
    var serializer = new XmlSerializer(typeof(Foo));
    //simply output error messages for types that we don't know how to serialize.
    serializer.UnknownAttribute += ((sender, e)=>Console.Out.WriteLine(e));
    serializer.UnknownElement += ((sender, e)=>Console.Out.WriteLine(e));
    return serializer;
  }

The save method is where we will kick off the work. We take this current instance and apply the Serialize() method to itself which converts the instance to a xml string. We also capture the fully-qualified name of the object type, both the namespace and the type name. This will be important when we are ready to pull the object back out of the datastore.

Here I’m using a Linq to Sql context, you may use any ORM as long as it supports the Microsoft Sql Server Xml datatype.

  public int Save()
  {
    using(var context = new Example001DataContext(this.ConnectionString))
    {
      var entity = new Example001ObjectDataStore {
        Serialized = XElement.Parse(this.Serialize()),
        FullyQualifiedTypeName = this.GetType().FullName
      };
      context.Example001ObjectDataStores.InsertOnSubmit(entity);
      context.SubmitChanges();
      return entity.Id;
    }
  }
}

The underlying data table is very simple. Only a single table with a field for storing the serialized xml data and a field for storing the fully qualified name of the object.

The Poor Developer's Object DataStore: Iteration 001, diagram

The Iteration 001 Object DataStore Table Definition

In this post we’ve got the ball rolling for storing objects into some some table. We can create an object that knows how to write itself into a database without requiring the creation of an elaborate data structure in order to just to simulate the object structure.

Next post we’ll cover how to retrieve the data from the table and convert it back into an instance of the persisted type. Next post we’ll look at how we can really test the functionality and behavior of the system. And begin to explore how to abstract the datastore to support arbitrary objects (with some minor restrictions.)

The source code for this project is hosted on GitHub and can be downloaded from here.

Look out for lame default IMAP configuration setting in Outlook.

November 23, 2009 just3ws Leave a comment

IMAP is awesome. If your email provider supports IMAP then you should already be using it. Basically, IMAP is the best way to keep your email in-sync between different computers and even installs. It’s even handy for transferring files between multiple computers very easily. (new mail->add attachment->save to drafts->walk over to other computer->open email->wait a few secs depending on size->open draft->voila!)

Brace yourself for this. But despite IMAP being a very standard protocol Outlook seems to have some emotional issues when dealing with IMAP-based accounts. Particularly how it wants to set up the default Sent folder for outbound messages. By default when you set up a new account Outlook will automatically store your outbound emails inside your Personal Folder.Sent directory. Which is a pain for two reasons…

  1. Removing the email from your IMAP account directory is equivalent to deleting the email. It just doesn’t exist anymore from the servers perspective.
  2. The email is no longer stored within your IMAP accounts PST file.

The problem now is, that the sent items are no longer synchronized between the server and the client. So that’s strike #1. And to make matters worse the email is not stored in your uses PST file, so even if you back that up the email is essentially gone. This is a very, very, VERY bad default configuration.

How to fix this problem? Aside from stop using Outlook and change to Thunderbird. Change the folder that Outlook stores it’s sent items from to a Sent folder within your IMAP account directory.

Categories: Uncategorized

The .Net dynamic keyword is evil!

November 20, 2009 just3ws Leave a comment

No, not really. Or is it?

Categories: Uncategorized Tags: , ,

McHenry Cloud Developers Group

November 19, 2009 just3ws Leave a comment

Azure. EC2. App Engine.

Do any of those names sound familiar? If so then join us for the first meeting of the McHenry Cloud Developers Group in Crystal Lake, Illinois!

Our first meeting will be an informal discussion of the goal of the group, ideas for projects and presentations. Also, we want to know what you are looking to get out of the group.

The meeting is Monday, December 14th from 7:00 PM until 8:00 PM. We’ll be meeting in the downstairs Ames-1 meeting room.

Please join us in Crystal Lake and join the projects or hang back and soak up some info!

Our first meeting will be held at the Crystal Lake Public Library.

Register here!

Directions:
Crystal Lake Public Library
126 W Paddock St
Crystal Lake, IL 60014-6194


View Larger Map

Also, we have a brand new site up. http://www.clouddevelopersgroup.com. It’s a very early draft but feel free to check it out.

String Formatting In JavaScript

November 7, 2009 just3ws Leave a comment

A few years ago I posted a small snippet of JavaScript from a library I created way back in the bad-old days of “Classic” ASP. The post generated a handful of comments between the different blog hosts I’ve tried but only two mentioned anything about how to do it better. The rest were the standard Internet-protocol messages reminding me of how much I suck (thank you *so* much).

A couple a guys posted something more useful than just a reminder of my own total failure as a developer and a human being. Daniel Schaeffer and the code-name “R.” posted alternative solutions. Unfortunately, Mr. “R.” didn’t post a link for me to find him, but I do think I tracked him down (Google will find you).

A little history first, back when .NET 1.0 was the new hotness one of the first things I fell in love with was the String.Format() method. Simply put, given a string literal decorated with some tokens you could create template strings without having to muss about with concatenation. I know, I know, C/C++ had something like this and other languages have too. Whippty-do. I was reared on the BASIC product-line, whatever.

C#’s string template functionality was a godsend in my eyes. I had (have) an intrinsic hatred of concatenation, mostly built up from creating dynamic sites in ASP that had to work in NN4 and IE4 (hate). All the HTML, JavaScript and CSS was built on the server and spit out to the client in whole. It was a nightmare to look at because of dynamic nature of the application as almost all the output was built programmatically on the server. Let’s just say there was a lot of string concatenation. Unfortunately, moving to .NET wasn’t an option. Yet string concatenation made me so itchy, so I scratched it as is the nature of an itchy developer.

String.format("Hello, {0}.", "World");

Very simple, obviously, it didn’t contain the full sophistication of the full-blown String.Format() in .NET but it did mean I didn’t have to do this anymore.

var myContrivedExample = "<a href=\"" + protocol + "://" + url + "\">" + text+ "\"</a>";

Now I could do…

var myContrivedExample = String.format("<a href=\"{0}://{1}\">{2}\"</a>", protocol, url, text);

Yeah, just take a second and try to follow the first one and spot the mistake. Then find the mistake in the second one. Yeah, much easier, huh.

Here’s the original code snippet.

String.format = function(text) {
 //check if there are two arguments in the arguments list
 if (arguments.length <= 1) {
 //if there are not 2 or more arguments there's nothing to replace
 //just return the just3ws text
 return text;
 }
 //decrement to move to the second argument in the array
 var tokenCount = arguments.length - 2;
 for (var token = 0; token <= tokenCount; ++token) {
 //iterate through the tokens and replace their placeholders from the just3ws text in order
 text = text.replace(new RegExp("\\{" + token + "\\}", "gi"), arguments[token + 1]);
 }
 return text;
};

Basically, it dynamically appends a static method to the String object. By default it expects a single argument, which can be any string. If there’s only one argument it just passes that string through unmodified. Although, if a second argument is provided the method will attempt to locate a token in the string and replace all instances of that token with the passed in string. Repeat the replacement for each following argument. Pretty straight-forward, probably a naive implementation but it got the job done.

A few years pass and I post the method on a blog.

Time churns on and the events of history progress, eventually someone reads the post.

More time churning more historical events, then someone replies to it. Neat.

Another one, wait. I know I suck.

Okay, here’s another one.

Now I’m looking back on the sad legacy of my blogging efforts till now and trying to gleam something useful from it and this is the best I can do.

Daniel Schaeffer was the first to oblige me with a response. I like what he did, it was clean and simple. Although, it wasn’t *exactly* the same.

All the comments that begin with //JUST3WS: were added by myself for the sake of the posting. And please forgive my taking some liberties with the code formatting, I’m a bit fussy.

String.prototype.format = function() {
 var pattern = /\{\d+\}/g;
 var args = arguments; //JUST3WS: Referencing the JavaScript 'arguments' object that is available inside all methods.
 //JUST3WS: 'this' refers to the current instance of the String object.
 // and the Lambda function is called for every match of the pattern.
 return this.replace(pattern, function(capture) {
 return args[capture.match(/\d+/)];
 });
};

We can turn Mr. Schaeffer’s method into a static method relatively easily.

String.format = function() {
 var pattern = /\{\d+\}/g;
 var args = arguments; //JUST3WS: This stays as is.
 if (args == null || args.Length == 0) {
 return “”;
 } //JUST3WS: The arguments might be null or empty because the
 // method signature doesn't require at least one.
 // JavaScript is permissive in it's parameter checks
 // and will just use the closest match. So if there are
 // no overloads which match better this method will still
 // be invoked regardless of how many arguments are passed in.
 //JUST3WS: 'this' refers to the current instance of the String object.
 // and the Lambda function is called for every match of the pattern.
 return this.replace(pattern, function(capture) {
 //JUST3WS: This is where Lambda's can be tricky. The calling scope (caller) is visible to the executing method (callee).
 // We can't use the local 'arguments' object because it would refer to the callee's arguments, not the callers. :-P
 //
 return args[capture.match(/\d+/)];
 });
};

What’s cool about his method was actually adding an instance method to the String object. Meaning, you couldn’t just call the method in an imperative manner like my static method. But it did mean you write some really neat looking syntax. Also, he used a Lambda function to handle the token replacement. You know Lambda’s; used to be feared and respected and known only to the Lisp/Scheme necromancers but now all the cool kids are running about like it’s Dad’s old Army overcoat.

var myContrivedExample = "<a href=\"{0}://{1}\">{2}\"</a>".format(protocol, url, text);

Because the string literal is actually an implicit instance of the String object in JavaScript, you can invoke methods on it. Very, very cool and clean.

Later on secret-agent known only as “R.” left me cryptic message to check out his implementation. But he didn’t leave a clue as how to find him, so once I mustered up the car and realized I needed few hundred more words in this post to make it seem “literate” I did a little research (Google) for “R.+String.format()” and think I found him. His post on a String.format() implementation provided both methods, a static and an instance version.

String.format = function() {
 if (arguments.length == 0) {
 return null;
 }
 var str = arguments[0];
 for (var i = 1; i < arguments.length; ++i) {
 var re = new RegExp('\\{' + (i - 1) + '\\}', 'gm');
 str = str.replace(re, arguments[i]);
 }
 return str;
};

Great minds think alike. Sorry about that mate.

String.prototype.format = function() {
 var str = this;
 for (var i = 0; i < arguments.length; ++i) {
 var re = new RegExp('\\{' + i + '\\}', 'gm');
 str = str.replace(re, arguments[i]);
 }
 return str;
};

Thanks for posting guys.

What’s interesting to me is the variety of ways that string formatting can be implemented. I don’t know why most JavaScript frameworks don’t offer some kind of string formatting functionality out of the box. The only one that I’ve seen thus far is the Microsoft Ajax framework, but they have a whole different methodology. But that’s for a different article.

Categories: javascript Tags:

Iowa Code Camp

November 7, 2009 just3ws 4 comments

Presented this morning with my Introduction to AOP with PostSharp.

I may have done the same topic multiple times each presentation was almost completely rewritten based on feedback from the previous times. Which is good and bad. Good because I feel like the information is clearer and better. Bad because it’s like I’m giving the presentation for the first time each time.

Slides and source code are available on GitHub.

http://github.com/just3ws/Introduction-to-AOP-with-PostSharp

Slides

http://github.com/just3ws/Introduction-to-AOP-with-PostSharp/blob/master/Introduction%20to%20AOP%20with%20PostSharp%20Redux.pptx

Source

http://github.com/just3ws/Introduction-to-AOP-with-PostSharp/tree/master/src/

Categories: Uncategorized

Warnings, Errors and Exceptions

October 26, 2009 just3ws 1 comment

My wife asked what the difference was between the list of Warnings, Errors and Exceptions in a batch results report.

I used our car as analogy.

  • Warnings are supposed to be the little dinging you hear when you leave the lights on and turn the ignition off. Something might be wrong. Did you really mean to leave the lights on?
  • Errors are like when the car won’t start because you have the wrong key. Something is definitely wrong.
  • Exceptions are like when you start the car but you can’t go anywhere because you’ve got a flat tire. Some thing is broken.

Except most software developers seem to mix the meanings around. Like when a developer uses an exception to mark the end of a list. Similar to driving without any sign of warning then the car explodes when it should have just shown a “low fuel” light.

Categories: Uncategorized