Showing posts with label Soft skills. Show all posts
Showing posts with label Soft skills. Show all posts

Friday, October 12, 2012

Time for a change

I've been considering this for several months and now got an opportunity to make a change. This post describes my next career move and why I decided to do this.

The history

The past four years I've been working for a software company that builds a product suite around Human Resources and Salary. The suite contains anything from salary calculation and HR registration to Employee and Manager Self Service systems. I was hired to help bring innovation and new technology to the existing team and work on the next version of the product.

As you might know we started with Silverlight 2 beta shortly after I joined the company. We worked on this product and upgraded it all the way to Silverlight 4 in two years time, until we decided that we needed to move away from Silverlight. For the past months our team has been working on delivering an ASP.NET solution.

My role has been to lead the team from a technical standpoint and architect the framework underlying the application. I've been happy to do this, however I still decided to change.

The Why

There are several reasons, some of which I'm not comfortable to discuss online, however the most important ones I can discuss.

The first reason, to me, is inherent to the assignment I had. If you complete the assignment, in this case developing a framework and getting a team up to speed on using it, you can't help but ask "What's next?". Unfortunately the answer was, "Finish the rest of the product." To me, this didn't (and still doesn't) sound very appealing. If you've been working on highly technical generic code and all of a sudden you're expected to do repetitive development, somethings got to give.

The second reason is more personal. I find it important to keep improving myself and I didn't see myself being challenged enough to improve on the skills I think are important to improve on as a senior developer, mainly soft skills. At some point you can get to comfortable in a certain situation.

The What

 So the final question is, what am I going to do? I've though about this and figured that in order to improve on soft skills a more customer facing role would suit my ambitions better. As I still wanted to be doing technical work as well a consultant role was the obvious choice. However I didn't want to be working with just another 'hour-factory' where you're just expected to bill as many hours to a customer as possible and I didn't feel much for being just another SharePoint 'specialist'.

I've been looking around and thinking about different routes to get what I'd like until an opportunity came along that I really liked. As of October 15th, I am working as a Senior Consultant in Enterprise Search. I've been working with enterprise search technology between 2004 and 2008 and I enjoyed it very much and always did want to go back to it and now I got the chance!

So what does a consultant in Enterprise Search do? I'll be working for customers that want to use Autonomy technology within their organization. Assignments can range from a simple advice all the way to a complete one off implementation for the customer. I'll be working multiple projects at a time and I'll be working with different programming languages and platforms a long the way.

So what about Developers 42?

What does all this mean for Developers 42? I will try to continue writing posts as time passes. However it does mean a change in direction for the topics I'll discuss. As I'll be using multiple programming languages, chances are I'll be writing more about my experiences with those.

Further more, as I explore more of the world of Enterprise Search and it's surroundings, I might be able to give some insight into what goes on in this field of expertise I'll be a part of once more.

I do hope you'll still be following this blog and to learn and teach together with you.


Follow me on twitter as well.

Friday, August 10, 2012

To Tweet or not to Tweet. That’s the question.

In this post I’d like to give an explanation of why I decided to start using Twitter and how it has worked out so far.

“Why on earth do you think you need to write a post explaining why you started using Twitter?”, you might ask.

I don’t like social networks

Well, people who now me, may have learned that I’m not a great fan of social media. I tried using several and most of them still don’t seem to add value for me.

Especially a network like Facebook appears like a serious waste of my, and others, time. I do have a Facebook profile, but I mostly use it to promote my blog posts.

The main reason I don’t like social networks is because I think most of us don’t have such an interesting live that you need to post updates about it every five minutes. Does anyone really care that I get up in the morning, go to work, when I drink coffee and when I go back home? Another question is, do I want others to know when I go to work and when I get home? To me it’s all a lot of noise and I don’t feel like spending time creating that noise for others to listen to.

Why Twitter might be different

So why go and use Twitter then? It seems like a lot of noise. Two things occurred to me. First of all, not a lot of people in my personal network actually use Twitter, so I don’t feel obligated to actually follow tweets by people that are close to me. The other thing is, and that applies to all Twitter users, Twitter is unique in the sense that it’s not automatically two way traffic. I can follow someone, but that doesn’t mean that someone will follow me.

This means that I can follow people who I think might have something interesting to say without me worrying about being intrusive and it also allows me to not follow a follower who I think is unlikely to tell me something interesting.

Besides the advantages of the platform I saw, I was looking for a platform to get some more interesting information about what others are doing in the field of software engineering.

I was also looking for a platform to promote this blog a bit better and a platform that allows me to post short updates appeared to me as a good way to do that and a challenge in the process. As some of you may know, I’m not blogging at a preset frequency. This does mean you may not hear anything from me for months. The reason for that can vary from being to busy to write something worth reading up to just not having a topic worth writing an entire post about (then again, maybe writing a post about why I joined Twitter might not qualify as a topic worth writing a post about Smile). With Twitter I can just write a one liner, share a link or a thought and it’s done.

Experience so far

So what has been my experience up to now? Well, I don’t have any real followers, so I don’t know about noise to others. I did tweet about ten times now of which two were retweets. I did find several Twitter accounts to follow that provided me with interesting Tweets. I got to some information I wouldn’t have got if I wasn’t on Twitter. I also stopped following some accounts as they provided me with to much noise. All in all that makes it meet my expectations.

This is another thing that struck me on Twitter. It seems more natural that people stop following other people. I had a follower and she stopped following me after about a day. I don’t know why and to be honest it doesn’t really matter. I see it more as a long running conversation. Once it stops being interesting for one of the parties involved, they leave the conversation. It makes sense to me.

Conclusion

So I have joined Twitter and up to now it has been a reasonable experience. I will continue to use Twitter for the upcoming months. If you think I might tweet something interesting, or if you want a tweeted update whenever I post something here, please join me on Twitter: @jvandeveen.

Feel free to share your experience with Twitter or other social media in the comments section below.

Tuesday, July 31, 2012

A TED video I think you should watch

In this post I would like to share a video from TED, that I think anyone even remotely interested in computers should watch.

Every now and then I like to watch videos that teach me something and/or inspire me when it comes to innovation. I used to limit myself to Channel 9, which is a great source for anything even remotely (and sometimes not) related to Microsoft. It has been inspiring and educational. Remember this post I wrote back in 2009?

Last year I was pointed to TED. As TED says on their website, they are a ‘nonprofit organization devoted to Ideas Worth Spreading’. Find out more about TED here. You should note that most videos on TED are presentations or talks. Sometimes there are interviews and sometimes there is a video with some kind of performing art.

The video I’d like to share with you is this one. It is a talk by John Graham-Cumming and it’s about the first ever design for a computer by Charles Babbage. I don’t want to give you to much information on the details, but you should definitely watch it. It’s only twelve minutes long, which is a common thing about these talks, they usually are not very long, which makes it easier to find the time to watch some of them.

One thing I took away from this is that although it is ok to doodle around with a whole bunch of different ideas, we should every now and then execute one of them.

If you have other great places where you find inspiring and/or educational videos, feel free to share them with us in the comment section.

Tuesday, May 29, 2012

Innovation can't be planned

The profession of software developer is a relative young one. As such we learn new things about it that other professions already have figured out. This post is about one of those things that managers who need to manage developers rarely seem to get: innovation.

Software development is devided in two different types of work, the standard projects for which you can simply apply well known en documented methods that lead to a predictable result, and the innovative projects where features and requirements can change based on the technical possibilities and impossibilities.

For example, implementing a corporate intranet in a CMS is well understood and tends to be predictable. On the other end, building a new product where the UI has to be available on a wide range of platforms and devices is not only new, but also has numerous variables that make it different every step along the way. Sure, there are methods to execute a project like that in a structured way.

Most agile methods appear to be suited to do highly innovative projects. However, they do have a single flaw, which I've recently experienced. Although they do allow for great flexibility in the big picture, once it comes down to the detailed work, they don't allow that same flexibility because at some point there still has to be some predictability so it can be sold to managers and executives alike.

In practice, when using an agile method, developers are still required to commit to delivering a certain amount of work within a certain amount of time. The only thing that has changed is the amount of work they are asked to make an estimate for. It's like instead of asking to design and build a spacecraft you're now asking for only the propulsion system. Sure, it's less work, but it's still highly unpredictable, especially when you find out the maximum speed in the specification is not nearly enough to get the craft to the destination within a reasonable amount of time and the fuel consumption needs to be cut in half.

Obviously the example above is exaggerated, but the point is that with innovation things can only become apparent once you're working on it. You encounter problems you could not have thought of and you have to solve them in order to deliver a product that's up to standard.

So how do you go about building an innovative software product? The first thing is to make sure you have the right people leading the team and trust them. Also make sure there is a clear set of boundaries that the team needs to operate within. Then support them and facilitate their work as much as possible.

This doesn't mean you can not put a timeconstraint on a project. However if you do, you should be prepared to compensate for that in functionality (some would argue that you can also assign more resources to a project, but why I think that has great limitations is a topic for another post).
So please, stop trying to plan your innovative development as you will only be disappointed.

Friday, May 18, 2012

Writing code != developing software

There has been some fuzz online about whether or not should everybody learn how to write code. In this post I’d like to add my point of view and take into account what the profession of developer involves (or should involve).

If you have not followed this discussion, you might want to read up on some other posts firsts:

Please Don't Learn To Code - Jeff Atwood

Please Learn To Think About Abstractions - Scott Hanselman

In a nutshell the fuzz is caused by public figures announcing they are going to learn how to write code.

The car mechanic

There has been several comparisons with other professionals already. However I think they are not really suited for what is happening here. I like to explain why learning how to write code doesn’t mean anything by projecting this to the profession of the car mechanic.

Let’s say I announce I’m going to learn how to work on an old car engine. If you analyze the skills I need to work on a car engine it almost becomes laughable:

  • I need to be able to open the bonnet of the car
  • I need a basic understanding of tools in the toolbox (a spanner, a screwdriver, etc.)
  • I need to be able to start the car and drive it in order to test my work

Anyone can see that it I work on a car engine with only the above skills, I’m very likely to ruin the engine. At the very least we can conclude that being able to work on an old car engine doesn’t make me a car mechanic.

Let’s project this example back to the software developers profession. If you want to write code you need the following skills:

  • I need to be able to install and run an IDE
  • I need to be able to type code in the syntax for the language I’m using
  • I need to be able to use the IDE to compile and/or run my code

If you are going to use only the above skills to write a program, changes are you are not going to achieve the results you want. In any case the above skills are not nearly enough to become a software developer.

The software developers profession

Jeff Atwood makes an excellent point in his post when he states that being a software developer is not about writing code, but about solving problems. I completely agree with Jeff on this point. If you read the post he refers to when making this point (here), you’ll see he paints a very bleak picture about developers being extremely disconnected from the users they are building software for. I personally do not have that experience, but then I’ve always worked in relatively small teams (six developers being the max).

In my career I’ve coached several developers and I’ve always been an advocate of what to me is the single most important skill any developer should have is the analytical skill. I’ve even given short trainings in analysis. When another developer asks for my help solving some problem, I always try to be very verbose on how I get to my analysis.

And as Jeff Atwood also states in his post, writing less code is better. In order to do that, being analytical about what you’re trying to achieve is crucial.

Obviously you can have all the analytical ability in the world, but if you don’t have a proper understanding about what you’re dealing with, it being the inner workings of an operating system, or the politics around some customers feature request, you can not make a proper analysis. This means you do need knowledge.

This brings me to a problem that is fairly unique to the software developers profession. Code is not knowledge, however it is transferred and documented online in vast quantities. This has created a whole breed of so called developers who simply go online and copy code for what they think solves a particular problem they’re having, without actually understanding what the code does, nor why they are having a certain problem. The term Lamer comes to mind.

The danger with that is that someone who does that might think that they solved a problem, however they might very well have not. And because of the lack of understanding they are unable to verify if the code solves the problem, nor are they able to troubleshoot the code if needed.

The software developer needs to analyze the users problems, then come up with a solution that fits the users needs. Again it’s not about the code. It’s about the solution. It requires a deep understanding of computers and the users needs and it requires analytical skills and a creative mind to come up with a fitting solution.

This is just my two cents. Please leave any comments, questions or rants below. I’d love to hear how others perceive this.

Monday, October 31, 2011

Parsing CSS for analysis

This time we’ll look into parsing CSS so we can use the result for analysis.

The story

As we are starting a new project using ASP.NET MVC3 one of the things I was thinking about was how to better manage our CSS and JavaScript. The first thing that I figured would be great was if you could to some static analysis on all of your CSS files to see if certain situations arise.

The issue with multiple people working on the same HTML based UI is that it can be hard to find out what CSS class to use. Because of that you might end up with classes doing the same thing, classes being defined more then once with different definitions, etc..

All this leads up to a less then ideal situation. Removing the cause of the problem, not knowing what CSS class to use, proves difficult. Helping counter the symptoms of the problem is proving a lot easier, so that’s the path I chose for, right now.

A two part solution

In order to do static analysis on something that is only available to me in plain text, I first need to parse the plain text into something that is easier to analyze. Then I can use the result to do the actual analysis on and communicate the result.

Analyzing how to parse CSS

To write a parser for any language requires a deep understanding of its syntax. Fortunately for me CSS is not a very complex language. W3Schools.com proves to be very helpful in providing us with an explanation on the CSS syntax. It comes down to this:

  • A CSS document consists of CSS rules
  • A CSS rule consists of a Selector and a set of Declarations
  • Each declaration consists of a property and a value
  • Comments can exist at the top level of the CSS document (outside of the CSS rules) or in between declarations

In order to do static analysis on this I came up with some interface definitions that allow me to query the structure of a CSS document:

   1: public enum SelectorType
   2: {
   3:     Tag,
   4:     Id,
   5:     Class
   6: }
   7:  
   8: public interface ICSSDocument
   9: {
  10:     string FilePath { get; set; }
  11:     IEnumerable<IRule> Rules { get; }
  12:     void AddRule(IRule rule);
  13: }
  14:  
  15: public interface IRule
  16: {
  17:     ISelector Selector { get; set; }
  18:     IEnumerable<IDeclaration> Declarations { get; }
  19:     void AddDeclaration(IDeclaration declaration);
  20: }
  21:  
  22: public interface ISelector
  23: {
  24:     string Name { get; set; }
  25:     SelectorType SelectorType { get; set; }
  26: }
  27:  
  28: public interface IDeclaration
  29: {
  30:     string Name { get; set; }
  31:     string Value { get; set; }
  32: }


Note that this might not be final as I might come up with requirements implementing the static analysis.



For parsing text like this there are always several approaches. In this case I decided that using plain and simple text parsing would be the most flexible, as I might want to add features to the parser in the future. Here is what I came up with for the main parse loop:




   1: public void Parse()
   2: {
   3:     string data = File.ReadAllText(FilePath);
   4:  
   5:     _position = 0;
   6:     _isInComment = false;
   7:     while (_position < data.Length)
   8:     {
   9:         if (IsEndOfFile(data))
  10:         {
  11:             break;
  12:         }
  13:         HandleBeginOfComment(data);
  14:         HandleEndOfComment(data);
  15:         if (!_isInComment)
  16:         {
  17:             HandleRule(data);
  18:         }
  19:         else
  20:         {
  21:             _position++;
  22:         }
  23:     }
  24: }


As you can see I have a (private) field to keep track of the position within the CSS document and another field to keep track of comments.



You might find the IsEndOfFile method weird as I have a condition within the while loop that should do the same thing. However I need to check ahead one position in case I’m still checking for comments (or are in a comment for that matter). The definition of the method is quite simple:





   1: private bool IsEndOfFile(string data)
   2: {
   3:     return _position == data.Length - 1;
   4: }



The HandleBeginOfComment method checks for the start of a comment:





   1: private void HandleBeginOfComment(string data)
   2: {
   3:     if (data[_position] == '/' && data[_position + 1] == '*')
   4:     {
   5:         _position += 2;
   6:         _isInComment = true;
   7:     }
   8: }



Basically it checks for the string /* and if it finds that string at the current position it moves the cursor by two characters and sets the _isInComment flag. HandleEndOfComment does the same thing for */ and sets the _isInComment flag to false again. Any comments are currently ignored, but it is easy to extend the main parse loop to allow for parsing comments as well.



The HandleRule method takes care of all the parsing magic, which makes sense as the Rule is the main component of a CSS document.





   1: private void HandleRule(string data)
   2: {
   3:     while (_position < data.Length && !StartOfRule(data[_position]))
   4:     {
   5:         HandleBeginOfComment(data);
   6:         if (_isInComment)
   7:         {
   8:             return;
   9:         }
  10:         _position++;
  11:     }
  12:     string selectorData = GetSelector(data);
  13:     string declarationsData = GetDeclarations(data);
  14:  
  15:     IRule rule = _kernel.Get<IRule>();
  16:     
  17:     ISelector selector = _kernel.Get<ISelector>();
  18:     selector.Name = selectorData;
  19:     selector.SelectorType = GetSelectorTypeFromName(selectorData);
  20:     rule.Selector = selector;
  21:  
  22:     HandleDeclarations(rule, declarationsData);
  23:  
  24:     AddRule(rule);
  25: }



The first loop deals with running into a comment later on in the document. If we do run into a comment we simply return to the main loop, which will then deal with finding the end of the comment. In the same loop it checks for the start of a Rule.



If we are still in the method after this loop, we have reached the start of a Rule. As we’ve noted earlier a Rule consists of a Selector and a set of Declarations. The methods GetSelector and GetDeclarations take care of parsing those portions of the CSS document. Once we have that data we can use it to create a rule. We use a Ninject Kernel to create instances of both the IRule and ISelector implementations.



Note that right now we handle the Selector like it’s a single entity. A future improvement might be to split up the Selector into parts and assign types to them individually.



The HandleDeclarations method takes the declarations text, parses it into IDeclaration implementations and adds them to the given IRule:





   1: private void HandleDeclarations(IRule rule, string declarationsData)
   2: {
   3:     string[] declarations = declarationsData.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
   4:     foreach (string declaration in declarations)
   5:     {
   6:         if (string.IsNullOrWhiteSpace(declaration))
   7:         {
   8:             continue;
   9:         }
  10:         int splitterIndex = declaration.IndexOf(":");
  11:         string declarationName = declaration.Substring(0, splitterIndex).Trim();
  12:         string declarationValue = declaration.Substring(splitterIndex + 1).Trim();
  13:  
  14:         IDeclaration declarationInstance = _kernel.Get<IDeclaration>();
  15:         declarationInstance.Name = declarationName;
  16:         declarationInstance.Value = declarationValue;
  17:         rule.AddDeclaration(declarationInstance);
  18:     }
  19: }



Note that I use String.Trim to make sure we don’t end up with white space in our declaration data, which could get in the way of our analysis (and is of no value any way in CSS).



So far so good. We can now parse CSS into an object model, which allows us to analyze the CSS in a structured way. I plan on writing a next post that shows the analysis based on this model.



No complete source included: Unfortunately, as this project is owned by my employer, I can not include full source code, however the parts I included should provide you with a good insight into parsing CSS.

Tuesday, September 20, 2011

Moving from Silverlight to MVC3

In this post I’d like to explain why we felt the need to abandon our Silverlight development in favor of MVC3.

As some of you may very well know, I’ve been pushing Silverlight within our company from as early as Silverlight 2 Beta 1, back in 2008. Still, this last summer I felt I had to raise the question: Is this still the right technology for our company?

Technology choices are about requirements

When we first chose Silverlight as our UI technology, we came up with a set of requirements. Our application should have a (near) zero footprint on client systems. It should be accessible through the web. Deployment on clients should be effortless or none existent. It should look great without a whole lot of effort. Silverlight checks all these boxes (it still does).

We write summer of 2010. The iPad has been around for several months now and it has been a great success. Smartphones are widely adopted to the point that we predict our customers will get interested in support for platforms like these when using our software.

Another thing we see is people working on more different platforms than before. Was it ok to ask for a certain browser in 2009, in 2010 our customers began to ask for a browser independent UI, not only on Windows, but also on a lot of other platforms.

To see what exactly would be the response of our customers we decided to build a native iPhone application with a limited set of functionality. We started the project early 2011 and published the first Dutch HRM app for any smartphone platform in may. It was a hit, not only because of responses by our clients, but also because of responses by our competitors.

Requirements shift, the world changes

This lead us to conclude that we needed to do something to support a new requirement. Our application, at least in part, should be available on mobile devices and tablets. And we should make sure we could drop the browser requirement we had active, even with our Silverlight 4 UI*.

That is why, during one of our meetings about what to build next, I felt the need to ask “Shouldn’t we move away from Silverlight and adopt ASP.NET MVC3 with HTML5?” It sure was painful, after investing over two and a half years in Silverlight to even suggest dropping it. However I felt then, and I still do, that a change had to be made. After some more debate on the consequences and some research, we are now putting in the effort to build the first parts of an MVC3 UI with the first steps into HTML 5 and CSS 3.

Luckily not all our efforts with Silverlight where in vain. We did deliver a good working product and we are committed to using, expanding and improving the middleware we developed for it. (Do you see the power of a Service Oriented Architecture?).

So is Silverlight really dead now?

Some of you may remember this post. In that post I state that Silverlight is actually the better technology for writing Line Of Business Applications. Even after researching ASP.NET MVC3 and HTML 5 further, I do still believe that, however because of the changes in how people use computers it simply fails to check one box for our customers.

Silverlight is no where near dead. It will still be used in many ways, including new platforms like Windows 8 and, for example Microsoft CRM 2011. Microsoft is integrating Silverlight in more and more of their own platforms. Also with the introduction of Silverlight 5 there will be many cool new features coming to the browser. Therefor I doubt Microsoft will drop Silverlight any time soon.

Consequences for Developers 42

Unfortunately our move away from Silverlight does have some consequences for this blog. First of all, my long running series of posts “Adventures while building a Silverlight Enterprise application has ended with part 41 (which is slightly painful for an obvious reason).

It also means I will no longer be writing posts for SilverlightShow.net. I’d like to use this opportunity to thank Svetla for supporting me for the past years.

And finally, it will also mean a lot less content on Silverlight, but hopefully a lot more content on MVC3, HTML 5, CSS 3, jQuery, etc..

It’s the end of another interesting period in my professional live and the start of a new one. I hope you have enjoyed my articles on Silverlight and I hope to see you around.

 

 

* The IE dependency was not actually caused by Silverlight, but by the integration with the Microsoft Report Viewer we used.

Thursday, August 4, 2011

Bigger is not always better: Communication breakdown

Using Excel 2010 on Windows 7 to make an estimate for a new project, I ran into this problem that I think is both funny and a bit frustrating.

As we all know, Microsoft is a huge software company, with many developers and lots of QA people. Where they used to suffer from a reputation of poor quality, recent years have shown us Microsoft can make decent quality software with great features. Part of that ability comes from having lots of people working on projects. However, it can work against you as well, as Microsoft demonstrates in the following bug.

I’ve been a keen user of Excel for the past decade for a lot of different tasks. From simple estimations to long-list and complete data conversions, I’ve done it all with Excel. One of the long used features is the ability to block indent inside a cell. You know, these two buttons:

IndentButtons

I use this feature frequently, so I figured a keyboard shortcut would make me more productive. Fortunately for us Microsoft makes finding out shortcuts very easy. Just hover over the button:

ShortcutToolTip

Mm, something is not smelling right, but hey, maybe the Office developers did a great job on implementing these shortcut keys. So let’s just try it…

…No. That’s not what I wanted to happen. Instead of indenting the contents of my cell, it showed the Windows 7 process switching dialog thingy or whatever it’s called. You know, the preview of your open windows?

Turns out both the Windows 7 team and the Excel team are using the same shortcut here. Excel has been using it for a while (since before Excel 97!), but in Windows this was only introduced in Windows 7 for the first time! Didn’t anyone figure “hey, we wanted to use this keyboard shortcut in Windows 7, but it’s already used in Excel 2010 so let’s have a meeting to discuss this”? In fact, shouldn’t a company like Microsoft have some sort of registration on what keyboard shortcuts are used where?

Even worse, Microsoft knows about the problem right now and has it published on their website. Is it really that hard to get a patch out for Excel to assign a different shortcut key to this function?

There is a lesson to be learned here. If you work at a small software company (with say, under 20 developers), make sure you utilize this advantage of a small team and communicate! It can make sure that your next product / project will be great.

Thursday, June 30, 2011

Code generation is a basic developer skill

“Give a good developer a 40 hour task and he’ll spend 39 hours writing a program that can do the task in 1 hour.” – unknown

Really? This seems risky!

It can look risky, can’t it. You might end up with a half working program and not enough time to do the job. There are approaches that reduce this risk, but more on that later.

Why should you even bother? Simple math tells us it’s not faster to do so (at least not in the above example). However, experience tells us that in general most jobs will be repeated. Now, with the above example, if it’s only repeated once, you have a 39 hour profit, as you can now do the job in 1 hour.

Obviously, things don’t work like that in the real world. Automating a process usually takes longer than actually manually doing the work. In fact, when you want to automate something, that usually means you first have to do it by hand at least once, so you know what you’re automating.

But it’s also unlikely that you will only repeat a process just once. Often tasks are done many times and then it becomes worth the effort of automation. Let’s look at a current example.

A common case

As some of you may know, I’m working on a line of business application with a Silverlight UI and a WCF service layer (although the used technology doesn’t really matter for this case). Part of writing most line of business applications is writing business objects that represent your model and writing logic to retrieve data from the database, either directly or through some ORM.

Another part is writing lot’s of “forms” if you will, to input data into. Usually these forms follow a common pattern. Both of these parts, the business objects and the forms, contain a lot of repetitive work to do manually. Some of the code can be moved into generic super classes, but most of the code is of a nature that doesn’t allow for generalization. This is where automation comes into play. In this case, why write all that code yourself if you can also generate it?

When we first started out with this application, we did set out to build some code generation. Unfortunately most of us didn’t have a lot of experience with code generation as such, so wrong choices were made (C# generation with a StringBuilder is not the way to go and the same goes for Code DOM). After the initial versions of our code generation engine, we were forced to spend all our time on getting a first release out to our customers and no more work on automation in any form was a predictable result.

So, are you a good developer?

We all fall into this trap at some point. I know I have several times. You let a deadline pressure you to much, or you go back to your old naïve thinking saying that this will just be some demo code and it won’t end up in production anyway. Whatever the reason, we all end up breaking our own rules from time to time.

Don’t get me wrong, that doesn’t make you a bad developer. In fact it means you are focusing on how to providing value to your customers, which is key for a good developer. Also, breaking these rules from time to time keeps us alert on why they are rules in the first place.

However, we should also take time every now and then to take a step back and have a look at what we are doing. In my case I found we should put a lot more effort in making our development process more efficient. This means making more code generic, refactoring existing generic code to fit our needs better, and generating more code.

Generating code, a daunting task?

To some developers generating code may seem like a daunting task. Don’t worry. That’s a good thing, because you won’t just dive in without giving it some thought. As you can see from our example, having a developer that things “Oh, this is easy. I’ll just take a StringBuilder and push out lots of .cs files" is far from ideal.

Actually the first step in code generation is not writing a code generation process. It all starts with meta data. If you don’t have something to base your code generation process on, then how are you going to generate code in the first place?

In case of a line of business application, often your data model can provide you with some meta data. In fact we started out with a stored procedure that would take meta data from our data model in SQL Server and put it in another database. Then we would generate source from that data.

Another source for meta data may actually come from people entering that data into an application. We use that too, to allow our functional specialists to provide us with information to generate the forms in the GUI.

Once you have your meta data in some form or the other, you can write your generation process. Actually, that part doesn’t have to be hard. In the end it’s just creating text from data, which most web developers have been doing for years. The main problem is integrating your process with your IDE. That is where T4 comes in.

As some of you may know T4 is already used in Visual Studio to generate source code. It also provides you with a simple button to trigger the execution of all T4 templates within your solution. This is obviously a lot easier than adding files generated by some external program.

As for editing these templates, Visual Studio doesn’t come with standard support for this (it’s treated as text by default, so no IntelliSense). If you are serious about T4, you should check out Tangible. They have an editor for T4, integrated in Visual Studio, both in a free edition as well as a pro edition with more features. Both features do come with IntelliSense and Highlighting, but the free edition only supports limited namespaces and assemblies. You can find them here.

But what about those risks?

I hear you. Starting with this it can be scary. The trick is to start small and then keep on growing your code generation process to support more and more scenario’s. This way you can work on your code generation in iterations and have a working end result often. This reduces the risk, because you can, at any point, decide that you will no longer extend the code generation process, but extend the generated code by hand.

Also, before generating any code, you should have at least written and tested it once, to make sure you know the structure of your code and what meta data is needed in order to generate it. This way you also know you will end up with code that works.

Conclusion

I hope you realize the potential of code generation and how this can really make you more productive. I can tell you from experience that it also makes software development more fun, even if you have to build a lot of the same. With the right tools I’m confident that any development team could benefit from automating their work.