Unit Of Work in .Net

February 26, 2007

So one of the things David Woods (a fellow Edmontonian who also took the JP experience on head first) comments on is one of the things I was a bit disappointed not to see myself. Of course considering the amount of stuff we did learn this isn’t really a complaint (especially when you take into account the skill disparity that did exist which slowed down some of the higher level stuff) but it sure would be nice to see Unit Of Work in action. So does anyone have some good example .Net (heck Java would do) code? I’ve got some ideas myself on how this could be implemented that I’ll be working on but so far I don’t see how you can do this without a lot of stupid code. I’m sure there must be a smarter way.

Anyone got any ideas?


The JP Experience..

February 25, 2007

One of the goals for me going to Jean-Paul’s camp was to be able to bring back what I had learned to my team. I’ve been thinking about how I can do that the entire week and I still don’t know the best way to do it.

The problem is that the entire time JP is teaching you specific techniques and principles he’s also teaching you more. You’re learning a new way of looking at what we do. At looking at your own life and skills. I can without a doubt say that JP has started me on a new journey that will take years to complete but I feel will be well worth it. One of JP’s biggest skills as a teacher is understanding that it’s more valuable to help you along a path rather then show you the end. In a lot of the examples we did JP would look at what I had done and give small suggestions. Not on how to specifically fix the problem but in how to look at the problem.

So how do you take all that and try and share it with others? I think the answer is you can’t. You can repeat some of what JP said but at the end of the day the only way to be a part of the JP experience is to be there (or be square.. heh).


Performance hit of a List across threads

February 23, 2007

Well Trey Hutcheson brings us some interesting news regarding List across threads.

I’ve seen a lot of concern over performance during very premature stages of development. Worse I’ve actually seen code changes (very complicated ones) made to avoid that possible performance hit. So I find this discovery kind of funny because at the end of the day it came due to premature optimization. From what details Trey provides it dosen’t appear that the original code was causing any real issues (especially since he switched back to it). So by switching his implementation to an implementation that he thought would be faster for the sake of it he actually caused a big performance hit.

The good news is that Trey noticed the big hit the switch had made and did actual metrics to show there was a problem. As a smart man taught me.. show me the performance problem and I’ll fix it. Until then let me code with testing and maintainability as my primary focus.

And if you do happen to read this Trey don’t consider it a hit on you.. we all fall victim to the evil spirit of premature optimization at points.


And that’s all she wrote…

February 23, 2007

Well the Jean-Paul Boodhoo experience has come to an ending… I definitely need to collect a few thoughts before I comment but I will say that it was by far the most amazing experience I have ever had as a developer. I know JP is planning on doing this course again so whatever you have to do.. beg.. lie.. work extra hours.. ya know.. whatever it takes to go you should do it!

I’ll have further thoughts later on.


Another amazing User Group Night

February 22, 2007

Well the Edmonton .Net Users Group had Jean-Paul S. Boodhoo appear again and I was once again blown away. The original title for the night was Enterprise Patterns but it was so much more. The actual main patterns we were shown that I can think of right now were Passive View and Mappers. While that in of itself was a treat more important for me was being shown a full end to end refactoring of existing code. The original code that JP started with was something you would see on your average web site but by the end was a thing of single responsibility beauty.

At the end of the night it almost looked like JP wouldn’t be able to pull it off before security kicked us out but a little smooth talking from Don saved the night. JP was able to pull off a very interesting implementation that has definitely helped continue to open my eyes. Of course JP has been doing that all week for those of us lucky enough to be in his week long development course (of which I’ll be blogging on once it’s all over). But for those of you who have seen JP let me just say to you.. Yes it is as amazing and fun as you think it would be.

So my hat.. well if I had a hat it would be off to Don and JP (and everyone else who helps make the Edmug nights so successful). Thanks guys!


NDepends 2.0 and Managing Change

February 21, 2007

Scott Hanselman has posted a really interesting article on NDepends 2.0.

I think the main thing that actually interests me about this tool is the ability to find the really bad edge cases. I’m of school of thought that says our primary job as developers is to deliver business value. One of the things I’ve been guilty of within the last year is the mistaken belief that it is better to throw out working code then to properly refactor it (in my defense I had not yet read the Refactoring book.. or anything by Martin Fowler at this point). I now realize that instead it makes more sense to refactor things in pieces.

Of course this understanding is just the first step. At some point we have to decide what to actually refactor. There are a few ways to drive our refactoring. The most obvious is new functionality. Whenever you enter an area you should leave it better then when you arrived. Even if all you do is take a minute to clean up a method at least you’ve accomplished something. Next in line comes bug fixes. If you’re fixing a bug you should be improving the area (after you added a Unit Test that shows the bug).

But you may (or so it’s been rumored) get to a point where you have a few spare moments and no new functionality to add or bugs to fix. It’s at this moment that I think NDepends will really have value for me. Because now I can start using its functionality to find the code that is much too complex or components that are in the “Zone of Pain”. And I can take some time to improve things piece by piece.

I also gain the ability to get a higher level view of the interdependencies that may not be obvious at first. With this knowledge I can decide whether I want to start small with something that isn’t going to cause a potential cascading effect, or at least be forwarned about what I’m getting myself into if I decide to go after something heavier. Knowledge is power after all.


OO in an ASP.Net World..

February 20, 2007

Raymond Lewallen is trying to collect information regarding the usage of MVP in an ASP.Net world. I’m definitely looking forward to seeing where this takes him. As a windows developer I’ve always wondered how you bring concepts like OO and now TDD to ASP.Net. I’ve tried looking around for examples that show these concepts and there seems to be a huge blank spot information wise. It seems like 99% of ASP.Net development is being done using procedural code.

One of the arguments I’ve heard against bringing OO into the ASP.net world is the “cost” of creating an object. Not in terms of the development time but in terms of actual performance. My view is that creating an object is creating an object and I don’t know of a single application that doesn’t create at least a string. But the question does need to be answered. Does proper OO code cause performance issues in ASP.Net? I’m not at the point where I can answer this question but maybe someone out there can.


Adding VS 2005 solution file to the New menu

February 20, 2007

If you’re going to start something you should start it right, and that especially applies to a software development project. Depending on the length of your project you may have to live with things for years. One of the things I’ve really started to get attached to is the concept of working IDE free (where it makes sense). Which isn’t to say that I’m going to be coding in Notepad++ any time soon, but it does mean I’m going to setup my project outside of the IDE. Now if you haven’t read Mike Robert’s article entitled How To Setup a .Net Development Tree I definitely recommend starting there. But if you have read it one of the first things you are going to need to do after creating your folders is create the Visual Studio solution file. Now Mike recommends creating it using the IDE and moving it but personally I think it’d be much nicer if we could just create it from the filesystem. Well it turns out you can and it’s not actually that difficult as I found out from Jean-Paul Boodhoo during his amazing week long developer course.

So our end goal is to add the ability to create a new Visual Studio Solution file under the New right click option in Explorer. The first step is to create an actual bare bones Visual Studio Solution File. So to start create a file called Visual Studio Solutions.sln on your file system. Assuming you are using Visual Studio 2005 you will want this file to have the following content:


Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
EndProject
Global
   GlobalSection(SolutionProperties) = preSolution
      HideSolutionNode = FALSE
   EndGlobalSection
EndGlobal

The next step is to create a registry file to import this new type. I called mine vss.reg but you can name it whatever you want as long as it ends with the reg extension. The contents of this file (assuming Windows XP) are:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.sln\ShellNew]
"FileName"="Visual Studio Solution.sln"

The next step is to copy the skeleton solution file you created into the C:\Windows\ShellNew directory (note that you may have to create the ShellNew directory manually). After that is complete all you should have to do now is run the reg file you created. You should now be able to right click in Explorer and see Visual Studio Solution under your right click -> New menu (note that I’ve seen it where someone had to bring up the menu two times the first time to get it to show)


Finding Employees

February 19, 2007

One of the biggest problems I’ve seen in our industry is finding employees. Or as I like to put it “finding people who know how to get stuff done that you can be proud of”. While there are definitely quite a few people “developing software” quite a few of them.. hmm.. how to put it nicely… lets just say I’m glad their not on my project team :) So how do you go about dealing with this?

There are three solutions I can see to this issue.

The first is the easiest and the most damaging. Ignore the problem. Hire whoever you can and let them code the way they have been. If they’re the kind of person who learns new things on their own time then great. But if not don’t worry about providing any training. Obviously I am strongly against this as you end up having buggy hard to maintain software.

The second is the hardest and it seems like every company that tries it ends up losing their way at some point. Hire only the best. The problem of course being that there is a very limited pool of “the best” and they pretty much have choice of jobs. So at some point no matter how good your environment is you’re going to run out of talent. At this point you can either go the Joel route and hire globally or you give up and fall into solution #1.

The third is the hardest for a business to accept. Hire a few of the best to help train everyone else you hire to be better then they were. The reason that this is such a problem for businesses is because of the perceived and real risk involved.

The first risk which we’ll call “Nobody to get work done” is IMHO only a perceived risk. There is definitely a cost involved in training your employees but the gain in productivity over the long run more then pays for the cost. I would rather work with a team of 5 who understand OO/DDD/TDD/Agile then a team of 20 guys who picked up VB.Net in their spare time. And nobody said that you had to have everyone fully trained up before they start working. For most people a few weeks of initial training followed by pairing is going to result in huge advances in skills. And before you know it they’re training your new guy. Of course this assumes you hire the right people.. which is risk #2.

“Hiring the wrong people” is definitely a big risk. If you are going to be spending so many resources training someone you want to be sure they are a good fit for your team. This is also a hard risk to avoid because it’s a hard thing to avoid. You want someone who fits well with your team and who is good at learning new things quickly. This is a lot harder to test for then knowing a specific language or technology. There are plenty of good resources out there on hiring people so spend some time and invest in reading them. Come up with some real questions to ask, find out what they learnt last. And make sure you bring the person in for a day to let them see your process. After all you don’t want to hire someone who after a week working for you realizes he made a huge mistake and he hates it. Oh and just to cover your butt make sure you implement a 3 month review process. And don’t be afraid to let people go at 3 months if things just aren’t going to work. Though it is a good thing if you are honest with the person as soon as you see a problem. You can’t expect someone to remedy a problem they may not realize exists.

The other big risk is people leaving. It’s not much fun to spend time and resources training someone only to have them leave. My only advice for this is to get over it. People move on. Change is inevitable. Even in a utopian environment things happen and people need to leave for other pastures. All you can do is make your employees as happy as possible and let things work themselves out. The good news is that your employee is most likely going to be a cheerleader for your company if they had a good experience. One of the things I’ve learnt is that the developer community is alot smaller then we sometimes imagine with our world wide reach. If I want to know about any company in the city it wouldn’t take me long to get a few opinions about them (I actually decided against working for an unnamed company specifically because of this).

Of course all this is just theory. So if you’ve actually seen it implemented or decide to try it yourself let me know how it goes/went ;)

Shane


Customer Service

February 19, 2007

Say what you want about Joel but sometimes the guy can knock one out of the park and his latest article on customer service is such a beast.

I’ve personally worked as a developer for a company that had pretty much the same policies as Joel discusses, and in that time I don’t think I ever once had to work with a pissed off customer. I actually had a ton of customers who were amazed that they received such good customer service, and I know for a fact it resulted in more then a few sales. Part of the magic I think is making your customer feel like you and your company are treating their issue like it’s the most important issue in the world. Even if at the end of the day you can’t come up with a perfect solution they’ll still remember the effort you put in.

Another nice bonus that Joel doesn’t mention is the simple fact that in our industry nobody stays still. People are moving constantly from company to company and if they have a positive view of your company it’s alot more likely they’ll recommend you to their new employeers.