Archive for September, 2009

What Kind Of Developer Are You?

5 commentsWritten on September 27th, 2009 by
Categories: Software Development

It occurred to me recently how much i've changed as a developer in the past few years. When i first started working as a developer, i was pretty quick at adding new features to projects and fixing bugs. I was almost fully focused on adding functionality but i didn't really spend a lot of time thinking about how i was adding the functionality. In some cases, i complained when i felt that some of our approaches could be better and in other cases i came up with alternative approaches but generally speaking, i was in full "i'm new at this, i'm learning and i'm just trying to do the best i can"-mode. For me, that meant trying to complete your assignments within (or ahead of) time, and with as few issues/bugs as possible.

This worked pretty well for the first 2 years or so of my career, but a lot of that changed when i started working on our own little ORM in VB6 together with a more experienced coworker. For some reason, writing code that made the job of developers easier somehow was more appealing to me than writing code that made the job of our users easier. From that point on, my focus gradually shifted from being a developer who tries to add value through functionality to being a developer who tries to add value by reducing complexity. With that i mean that i spent less time working on actual features that our users would benefit from, and more time on writing code that other developers would benefit from. And that, in turn, would (should?) offer more benefit to our users on a larger scale because my code was supposed to make it easier for other developers to add new functionality.

Just to be clear on this: i think we need both 'kinds' (yes, i know there are more 'kinds' of developers but bear with me on this) of developers. If a team of developers consists solely of people like me, you're never going to deliver anything of value to your users because we would spend all of our time trying to improve whatever it is that we're doing. Just like you need people who are willing to think a bit further about how you're doing things, you need people who manage to actually get things done in a manner that is good from both the technical as well as the end-user point of view.

Sadly, i'm no longer one of those people. I used to be, but i don't really think i'm capable of going back to that. To me, providing a good User Experience means coming up with a good API. So i spend most of my time working on architectural and framework stuff. One of my biggest fears is that i'll some day end up as the typical non-coding architect so i try to stay very involved with how people are actually writing code to deliver real functionality. I may not write that kind of code anymore, but i do keep looking at a lot of that code so i can keep coming up with possible improvements.

So what about you? What are the things you focus most on, as a developer, and why? What are the things that get you the most satisfaction (keep this technical, i don't wanna know about your personal life) and are you able to focus most of your energy on this?

7 Years As A Professional Software Developer

4 commentsWritten on September 27th, 2009 by
Categories: Off Topic

It's that time of the year again! I have now been working as a software developer for the past 7 years. I don't know why that means something to me, but it does. Last year, i gave an overview of my short career which people seemed to find interesting, so i figured i might as well add this to my list of 'blogging traditions'.

So what have i done in the past year? Well, as i mentioned in last year's post, i finally started working at my company's home office instead of working at client locations, and it has definitely been the best year of my career so far.

When i made the switch, i thought that we (as a development company) were already pretty good, but i had some very clear changes/improvements in mind that i wanted us to achieve in the first year. More specifically, i wanted to see big improvements in the following areas:

  • Increase the efficiency of our automated testing practices.
  • Get people to write loosely coupled code.
  • Increase overall performance and scalability of the code we write.
  • Get people to truly care about code quality and proper software development practices

My coworkers started writing automated tests way before i did. But before i came aboard, none of our automated tests would ever substitute the implementation of a component during tests. No mocks, no stubs, just the real thing all the time. If we had tests for code that was somewhat dependent on data access components, then those tests would effectively be dependent on a real database. If we had tests for code that was somewhat dependent on processing files, then those tests would effectively be dependent on real files.

We had thousands and thousands of tests which took a long time to run, were rather fragile, and required a lot of maintenance effort to keep them running at all times. These days, our tests only use the database when we are testing our queries and our NHibernate mappings. We use mocks to substitute the data layer when we are testing our business code, and we also moved to using MVP patterns in the UI layer so we could start writing automated tests for a lot of our UI code as well. Obviously, all of that required us to write our code in loosely coupled manner, which we now all do with Dependency Injection and using an Inversion Of Control container. So i am pretty happy with the results of the first two goals.

The third goal (performance and scalability) is also coming along nicely. The architecture that we use (and if you've been reading this blog for a while, you'll probably have a pretty good view on what our architecture typically looks like), in combination with the libraries that we use, gives us plenty of possibilities to write scalable and performant code. One of our clients made us perform extensive stress testing for one of the projects we did for them, and the results were good. I'm pretty confident that our usage of the Request/Response WCF Service Layer plays a very large part in getting those results. Of course, we still have performance problems every now and then, but we now do a pretty good job of proactively keeping an eye on it (in most cases), and when performance problems do show up, we can usually fix them pretty easily.

So far so good, right? Then comes the final goal... getting people to truly care about code quality and proper software development practices. I am very happy with the progress that some people have made, but i am pretty disappointed that i can count them on one hand. Some people improved tremendously in the past year, while some only seem to care when they know their code is going to be reviewed. I was very disappointed when i noticed that some people didn't mind resorting to technical shortcuts or not properly testing things when nobody was watching them. As a result, i'm now actually monitoring the commits for most of the projects that we have going and whenever i see something that doesn't look right, i talk to the author of the particular piece of code about it.

I really don't like the fact that i feel the necessity of doing that, but i'm gonna try this approach for a month or two to see if things improve. I hope to see more people actively reviewing other people's changes in the upcoming months because this is a task that should always be shared instead of having only one person who does this. I hope that in a year, we'll have enough peer-pressure to make sure everyone keeps playing it straight. Anyways, i'll let you guys know about it next year ;)

So all in all, it's been a very interesting year. I've worked on some cool things, i get enough variety in my work, i get to see (some) people grow continuously in their capabilities, and the amount of time i had to spend on doing things i'd rather not do was very low. Much lower than i can imagine in any other company anyways. Oh, and according to some of my coworkers i'm also responsible (to some extent) for an increase in our after-hours-beer-consumption as well as pizza deliveries. It has been a good year indeed :)

Must Everything Be Virtual With NHibernate, Part III

12 commentsWritten on September 27th, 2009 by
Categories: NHibernate

In the previous post i showed a piece of code which suffers from 2 problems and asked you guys to spot both problems. One of the problems was pointed out in the comments, but nobody mentioned the other one.

Once again, this is the code example:

transitive_persistence41

Instead of making everything virtual, only properties that are eligible for lazy-loading have been made virtual. Now, the line of code that is problematic is obviously the one where the DiscountPercentage of the customer backing field is accessed. I will address using the field instead of the property later on in this post so bear with me for now.

There are 2 situations in which this code will fail badly. The first situation is when you're dealing with a proxy of an Order. If you have an uninitialized proxy of Order, and you call the non-virtual CreateOrderLine method then you will get a NullReferenceException because the proxy can't intercept the call to CreateOrderLine, and because it also can't intercept accessing the customer field, which will be null at that time. This problem was correctly spotted by one of the people who left a comment.

The other problem is far worse, IMO. Suppose you have a genuine instance of an Order object, but its reference properties haven't been loaded yet and are uninitialized proxies. If there is no requirement for every public member of a proxy-able type to be virtual, then we can pretty much assume that the DiscountPercentage of the Customer class is also non-virtual. Which means that with this code, we have no possible way of intercepting the call to the Customer's proxy's DiscountPercentage property. Unfortunately, DiscountPercentage will have its default value of 0, so you won't get an exception... instead, the customer gets no discount even though its record in the database might have a discount set.

The possibility of running into one of these problems due to usage of an ORM and depending on how an object is loaded is simply unacceptable. Some people commented on the usage of the customer backing field instead of the Customer property with a "then simply don't do that" response. That's not an acceptable solution to this problem, it's a lame workaround at best. There are plenty of reasons why people would use the backing field in their code instead of the property and if they run into this problem, they definitely will blame the ORM. And rightfully so, i might add.

Must Everything Be Virtual With NHibernate, Part II

10 commentsWritten on September 23rd, 2009 by
Categories: NHibernate

I already tried to explain this before, but here's a simple example from a presentation i recently did on NHibernate:

transitive_persistence4

As you can see, only the properties of associations that are eligible for lazy-loading are virtual in this piece of code, because that is what many people seem to want. There are actually 2 different ways in which this can cause problems... can you spot both problems?

Trying MonoDevelop On OS X

15 commentsWritten on September 15th, 2009 by
Categories: Mono

As some of you already know, i'm a long-time Mac user. At work i obviously use Windows, but at home i only use Windows (through VMWare) when i want to code in Visual Studio. Other than that, i stay away from Windows as much as possible because i simply don't like it. The recent MonoDevelop 2.2 beta release promises OS X support so i wanted to try it out.

Unfortunately, there is no integrated installer for both Mono and MonoDevelop, so you'll need to download and install Mono separately. I used the stable 2.4.2 version which i downloaded here. After that, i downloaded and installed the 2.2 beta1 release of MonoDevelop here.

Installation is extremely quick and easy, so after a couple of minutes you have this on your screen:

01

Doesn't really look like a typical OS X application due to the GTK+ usage, but we can live with that :)

I then wanted to create a new project:

02

There are some interesting project templates there (notice the iPhone and Moonlight options) but i just selected a regular console project. After doing so, you get some interesting packaging options for your project:

03

After that you can start working on your project:

04

I wanted to run it first to make sure everything was working:

05

I also wanted to try the integrated debugging so i put a breakpoint in the code:

06

Unfortunately, running it with the debugger (that icon isn't shown in the screenshot because it's not visible when you reduce the size of the window to the size shown in the picture) didn't make it break on the breakpoint... it just showed the output as it does when not running with the debugger. I then looked in the solution options to see if i had to enable debugging or anything like that. Didn't really find any debugging related settings (i was hoping for a 'make it work' checkbox or something like that) but i did see this:

07

You can set a few formatting options (obviously not as many as a Resharper user is used to) for your C# code, which is definitely a nice and important touch. Unfortunately i got the following exception when saving my changes:

08

A very nice addition here would be a button which allows you to automatically report the bug with its stackstrace to the MonoDevelop team. It would benefit both the developers and the users so i hope they will add this soon.

I also looked into some project specific settings and you'll find plenty of familiar options there:

09

Alright, enough with the settings... let's start coding! Once i added the new file, i was slightly disappointed with the unnecessary whitespace in the file:

10

Most people will just delete this every time anyway, so it would be better if empty classes were created with as little excessive whitespace as possible.

And then i started coding. Well, i tried to. The editor was unbearably slow on my Macbook. Ok, it's not the fastest machine (Macbook 2.1, 2.16Gh Core 2 Duo and 3GB RAM) but it should definitely be capable enough to write and edit code in a usable manner. The editor would lag so much behind my typing that it was just completely unusable. It's not because i type fast or anything, because it was unusable when typing slowly as well. After a couple of lines of code, i simply gave up. From what i did saw, it has simple code completion and intellisense support so that's nice. But i really hope they can seriously speed up the editor soon.

All in all, i am hopeful that MonoDevelop on OS X will become a reasonably viable solution in the near future. It's a simple IDE, nowhere near as powerful as Visual Studio (let alone one with Resharper) but it does have most of the important basics that you'll need. At this point, i don't consider it usable (after all, writing and editing code is fairly important) but i really hope that the MonoDevelop team will fix this soon. It would be very nice to be able to use this successfully on OS X.