Este artículo también está disponible en español aquí

So this is my first non-technical, opinion post or shall we say essay. I’d like this to be an open space for debate so feel free to post comments as they’ll be greatly appreciated.

Preface

From a pragmatic standpoint we as an industry, Information Technology (IT), have the single purpose of creating tools to increase the production and efficiency of other client industries. This lays great power upon us as the potential to shift how a business performs, both operative and economically, is enormous. But let’s not forget “with great power comes great responsibility”, Stan Lee. So I want to argue that, in order to fulfill our purpose, we have the responsibility to first understand the business of those who we intend to support. However, this does not seem to be the main drive to what we do.

Common Ground

The easiest way to get started is probably through a metaphor, that illustrates how us programmers traditionally interact with the business:

A man in a hot air balloon is lost. He sees a man on the ground and reduces height to speak to him.

"Excuse me, can you tell me where I am?"

"You're in a hot air balloon hovering thirty feet above this field," comes the reply.

"You must be programmer," says the balloonist.

"I am," says the man, "How did you know?"

"Well," says the balloonist, "Everything you told me is technically correct, but it's no use to anyone."

"You must be in business," says the man.

"I am," says the balloonist, "How did you know?"

"Well," says the man, "You don't know where you are, you don't know where you're going, but you expect me to be able to help. You're in the same position you were before we met, but now, somehow, it's my fault."

This is how most interactions between us and the business take place: absolutely disrupted, unbeneficial for everybody involved, and completely wasting an enormous potential for innovation and value creation.

The story is about two men making several mistakes in how they relate: not being able to understand each others positions, neglecting to explain what they expect from each other, and missing the opportunity to collaborate into a common goal.  We’ll call this the miscommunication symptom.

Over time miscommunication reduces the business’s confidence to trust us with their needs and erodes our credibility as solution enablers. We’ll call this the credibility erosion symptom.

These two symptoms are the main factors that prevent successful collaborations from happening. Of course there are other external factors, but we’ll limit the scope of our analysis to these two, diagnose them, and hopefully come up with a practical solution.

The Diagnosis

We directly contribute to the miscommunication symptom with the language we use, technical and precise to us, but confusing and without significance to the business. The cause of this symptom is the tendency to use precision instead of significance in our language.

I believe that language represents our perception of the world, how we see and understand it. Consequently, our understanding of the world models the way we think. And the way we think defines us, in both how we behave, and how we shape the things we do. After all “we are what we think”, Gautama Buddha.

Courtesy of MathWorks.com

It seems these two men see the world in different ways and they would behave very differently in that situation. Precision is very important for a great deal of things, but it’s not useful when relating to others. This is where precision becomes an obstacle because it conveys nothing, it isolates us, and it smothers communication with our audience. When relating to others “significance” is the key, is what people find useful, what has meaning, what is relevant, what has value, what solves a problem, what has a practical use in the real world, and what conveys something to our target audience.

However, significance is a very subjective concept, because it can dramatically vary between different audiences. The same concrete fact can be interpreted very differently, depending on how you relate to that fact and how it affects you. From the example, for a man standing under the falling heavy object, significance would be something like: “LOOK OUT!!”. On the other hand, to a man operating the crane that holds the heavy object, significance could be something more relevant like “PULL THAT BLUE LEVER!!”. Actually I’m not sure what colors are the levers on a crane but you get the point: Different actions need to be taken depending on how you relate to the fact, and “significance” considers that.

What this means is that significance is not spontaneous, it requires the skill to interpret the facts considering your target audience. This is called perspective, and by definition, perspective is about “the subjective evaluation of relative significance”, and “the relationship of aspects of a subject to each other and to a whole”. Each of this nuances of the term will help us address a symptom of the problem.

Perspective will helps us address the miscommunication symptom as it will allow us to translate precision into significance, relevant and adapted to our target audience so that it is easy to understand and most useful.

Perspective will also help us address the credibility erosion symptom as it will allow us to visualize our position and the business’s position as a whole, not disparate environments, but to understand it as a complete, complementary, collaborative, and organic whole. And in that broad vision of our role we can be more proactive and helpful, not becoming an obstacle but a part of the solution.

Perspective: A Personal Choice

et2et5Courtesy of German graphic designer Axel Peemöller

The previous pictures are from a very interesting project by a German graphic designer at the Eureka Carpark in Melbourne, Australia. The idea is to present a visual navigational system that teases with perspective, creating the effect that directional signs appear to be floating in the middle of space. The relevant thing about it is that from up close you only see loose, skewed and inconsistent color lines with no apparent coherence. But it’s only from a certain distance and in the right angle, hence introducing perspective, that you understand what it’s all about.

I find it fascinating how art can present so accurately such a complex phenomenon, and use it as an argument to reveal a weakness of human perception. Oscar Wilde said it best: “Life imitates art far more than art imitates Life”. So in a way, our whole dilemma is exactly represented and explained by this art piece. Or is it the other way around? I don’t know, go ask Oscar.

So why I don’t call myself a programmer anymore? I’m not. Programming is just a very specific task within everything I do, it’s a very important task but not the only one. I also have to send emails but I don’t call myself “The Post Office” or something, you get the point. The problem with programming is that it gets too close to the detail, and at that level we fail to see the big picture. We just don’t get it. So naturally, the solutions and ideas that we have at that level of detail are not the best possible ones, and most certainly don’t apply to the other pieces of the whole. We fail to provide an integral solution.

Once I understood the potential benefits to be gained by introducing perspective into the equation and made that personal choice to change, I shifted to something else, something more broad in concept and understanding, I began to see the architecture.

But “Software Architect” is hardly a position you get promoted to, it’s a personal choice to assume a role, a mindset, a broader and more ambitious way of looking at things, that carries bigger responsibilities and compromises, but can also lead to great accomplishments. This is why we should all strive to be software architects. So follow my advice and do what I did, zoom out of detail and see the big picture, don’t be a programmer anymore, it’s up to you.

Take website offline for upgrade and display maintenance screen in ASP.NET 2.0 (and above)

Lately I’ve been doing a lot of research about Continuous Integration and Continuous Deployment practices, the latter being most relevant to this post. Basically the objective is to automate all manual labor of deploying code to production, with the obvious benefit of minimizing time and effort involved, but more importantly to reduce risk. As explained very eloquently in this book.

One important aspect of any deployment scenario is downtime. The first thing to consider about downtime is “opportunity”, that is the appropriate time for the upgrade process to take place. This is usually when we know site traffic is at it’s lowest so the impact is minimal. But even then we need to be prepared to greet users with a friendly message explaining the reasons for the downtime, especially to point out that it’s a programmed upgrade and not some catastrophic incident.

So this is where ScottGu has a great tip for us in this great post, which is really old (like 2006) but I honestly had never heard of this. Basically you place a file named “App_Offline.htm” (larger than 512 bytes, read the post) in the root folder an it will cause the application domain to shut-down, release all resources, and respond to all traffic with that static file. When you’re done just delete the file or rename it and it will magically bring the site up again. I prefer renaming the file because it’s always useful to have a quick way to bring down the site and display a maintenance screen.

This is really nice because the “.htm” file can contain any markup you wish to display to users during the downtime. One thing to notice here is that even though requests are being responded, for all intents and purposes the site is down. That means you can’t reference any css or images within the same site. So if you want to display an elaborate screen with images and styles you need reference them from another site.

Of course there are other more advanced alternatives to avoid the users from ever noticing downtime, but this works pretty well for more humble deployment strategies.

Quick Tip: Validate email address in C#.NET with Regular Expressions

Ok so this is no biggie, but sure comes useful at some point when dealing with any kind of form input validation. Actually I just found myself in the needs of such validation snippet but didn’t have any at hand, so after a while putting it together I figured what better place to store for future references than my blog!

The pattern for the regular expression I borrowed from this cheat sheet. It works very nice except for some extreme cases like one-character domain, although it does reject one-character top-level domain, but I’m sure it’d be pretty easy to adjust to specific needs.

So here’s the snippet code:

private Boolean isValidEmail(String email)
{
	Regex reg = new Regex(@"(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6})");
	return reg.IsMatch(email);
}

Quick Tip: Differences between Culture and UICulture

I’m currently studying to take the WebApp MCTS certification exam, this will be my first certification so I’m a little nervous and don’t know what to expect from it.  So I purchased the corresponding practice test from UCertify and been taking a couple of simulation test to discover any weak spots.

I recently discovered one of this weak spots and it’s the difference between Culture and UICulture. I’m sure a lot of people have the concept crystal clear but I’m going to allow myself a post about it so I don’t ever forget again, or have a place to look in case I DO forget xD.

Basically when you set the Culture property you specify the language to use in objects with no UI, so we’re talking about things like dates, time, time zones, numbers, etc.

On the other hand, when setting the UICulture your telling the runtime to load specific resource file to compile with the current page and to replace localized values accordingly.

A very important detail about these two properties, and a very uncommonly stated fact, is that they are tied to the system’s control panel regional configuration, even if it’s misconfigured.  The Culture property is tied to the default regional settings and the UICulture is bound to the “keyboard and other input” settings. This is actually very important because it means that the defined formats for each culture or language will be used by the .NET runtime when parsing values.

I remember having a very tedious bug a while ago, when I had recently purchased my previous laptop, which would throw an exception when parsing perfectly valid datetime strings.  After a LOT of head-banging against the keyboard I discovered that the source of the problem was the regional configuration for my OS. You see the laptop came with built-in Windows 7 in English from the manufacturer, but me being a Spanish speaking fellow am used to dates in this format ‘dd-mm-yyyy’ and would often get confuse with the English date format ‘mm-dd-yyyy’. So I messed with the configuration of the English formats in control panel to have it displayed the way I wanted it, instead of installing a different language or whatever. I assumed that configuration was used for displaying purposes only but it turns out that it was affecting the way in which the .NET framework was handling the parsing of strings to date in the English culture. So I advice you not to do that, and when receiving an exception parsing a perfectly formed date string that’s the place to look.

Quickly Execute Database Queries in an ASP.NET Website

Very often we find ourselves dealing with a bug or investigating a problem in a scenario where we don’t have direct access to the database to execute a query. Whether it’s because the application is in a production environment and the database is not accessible remotely, or because we need to quickly collect some piece of data through a query but can’t afford to waste time requesting temporary access through a some bureaucratic hierarchy in your company.

Whatever the case may be, one solution could be to create a temporary page in our website that executes the query we’re interested in and displays it in a tabular fashion, much like the query analyzer would.

Of course there is a security dimension to this approach which needs to be carefully considered. The database user that the application authenticates with should NOT be allowed to execute CRUD operations on critical tables. In some cases the website database user shouldn’t even query tables directly, in that case the example provided in this post needs a little tweaking, maybe I’ll implemented it later.  Also this code snippet should not be publicly accessible, on the contrary it should be stored behind a password protected folder at least, and should not be permanently kept in a production project. Just use it to diagnose and resolve the problem you’re facing and immediately delete it.

Ok so that little word of caution being said, I here present you the snippet.  It’s split into two parts, the markup and code-behind, but for ease of use I would recommend to create a single .aspx file with code embedded. Additionally there is a sample file available for download.

protected void Page_Load(object sender, EventArgs e)
    {
        if (Ctrl_Query.Text == "") return;
        
        string connStr = ConfigurationManager.ConnectionStrings["SqlConnection"].ConnectionString;
        DbConnection conn = new SqlConnection(connStr);
        DbCommand cmd = new SqlCommand();

        cmd.Connection = conn;
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = Ctrl_Query.Text;

        try
        {
            conn.Open();
            DataTable dt = new DataTable();
            DbDataAdapter adapter = new SqlDataAdapter(cmd as SqlCommand);
            
            adapter.Fill(dt);
            Ctrl_Table.DataSource = dt;
            this.DataBind();
        }
        catch
        {
            throw;
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }   
    }
    

Assign a SQL Server Login to an Existing Db User

I was very concern about what the first post would be on my shiny new blog, actually second post because the first one was kind of a preamble and self justification, but that doesn’t really count as a post… but any who… I was under the impression that this post had to be something really profound and meaningful… until I realized that probably nobody else is going to read it but me xD. So that took off a lot of pressure and I started to think about what was the most common piece of code that I always find myself looking over and over again because I just couldn’t remember it.
Undoubtedly it was the assign login to user thing. This very simple line of code keeps slipping my mind every time I need it. The first time I encountered this problem I came across this great post that had a solution right away, but the post is quite long and has a couple of different ways to use the command but I always need just this one, so I would store the link in delicious with a little comment on the title like: (remember to use 3rd option). Not very stylish but it did the job, up until now. Maybe later I’ll post a more detail guide about the error.
So here we go, the following command will solve all your problems. Both the login and user must already exist in the server and database respectively.

USE [YourDB]
EXEC sp_change_users_login 'update_one', '[user]', '[login]'
The most common scenario where I find myself needing this is when migrating a very large database update from a development server to a quality server, where the easiest way of synch all the modifications is to manually detach/attach the .mdb file to the quality server, where the logins are already created but the association breaks with the migration.

My First Post, of my Reasons and Merits for this Blog

I’m a complete newbie to this whole blogging experience, I’m hoping this would help me exercise my communication skills and also function as a personal library for storing every piece of knowledge that you produce every day through research, analysis, development, or just plain and simple head-banging against the keyword for hours while solving an impossible problem xD.

Basically what happens to me all the time is that after solving a problem I’d try to store the solution with a brief description on my pc in an easy to find location, and a reasonable place where I would start looking in case I forgot (which I always did).  But after finding it, the instructions for the solution were not very clear, and even if I did understand them it would be useless to anyone else.  The same happened for commonly used blocks of code, and also when storing results of research on a certain topic, I’d store relevant links in delicious, which is really good, but what I really needed was to write down my own ideas and have a way of easily searching through them afterwards.

So despite this really inefficient way of working the thing that made me realize I needed to make a change was a co-worker one day in a middle of a conversation said to me: You need to open a blog! and exposed all of these reasons the I know were true but never really did anything about it, it was the little push that needed to happened to get me started. So I’ll take a moment here to give her proper merits… so Yubisay thank you!!

I hope this can be of any help to anyone else who is seriously considering opening a blog but are having second thoughts for whatever reason, my advice is “Go for it!… what’s the worse that could happen”.

Don’t mind the following code snippet, I was just trying out this syntax highlighting plug-in.  Totally recommended although I need to upgrade to the newer version.

function test(){ 
   alert("hello world!!"); 
}