Browsing Posts in Presentations

Just realized that I never announced it, but I will be giving a double-header presentation at the Regina .NET User Group tomorrow night – Wednesday, October 8, 2008 from 5:30 to 8:30 pm. You can find directions and registration here.

Session 1: Taming Software Dependencies with Dependency Injection (DI) and Inversion of Control (IoC)
Software inevitably contains dependencies. Dependencies between classes. Dependencies between layers. Dependencies with third-party libraries. How can concepts like dependency inversion, dependency injection, and inversion of control help you tame your software dependencies? Where does an inversion of control container, such as Castle Windsor, come into the picture and do you need one? Can Binsor help you achieve convention over configuration? This session answers all these questions and more…
Session 2: Achieving Persistence Ignorance with NHibernate
Object-relational persistence can be very complex and middle-tier code is often dominated by persistence concerns. Your Customer class probably contains more code related to loading and saving customers to the database than it does actual business rules about customers. Wouldn’t it be nice if you could remove all this persistence-related noise? This session examines why the concept of persistence ignorance is important and how to use NHibernate to build persistence ignorant domain models.

I have a busy calendar of events in the next few months. I’ll post my other appearances in the next few days…

Thanks to everyone for coming out to see Achieving Persistence Ignorance with NHibernate at the Calgary .NET User Group this past Wednesday. You can download the slidedeck and code here. The following are some good resources on NHibernate and the importance of persistence ignorance.

I also mentioned during the presentation the trick of modifying Configuration before constructing your SessionFactory to turn immutable entities into mutable ones for testing or data loading. You can find the details in my blog post:

Lastly I will be putting up a registration page for Object-Relational Mapping with NHibernate course in the next few days. If you’re interested or have any questions, don’t hesitate to email me.

I’ll be speaking about Achieving Persistence Ignorance with NHibernate at the Calgary .NET User Group next Wednesday.

Achieving Persistence Ignorance with NHibernate

Object-relational persistence can be very complex and middle-tier code is often dominated by persistence concerns. Your Customer class probably contains more code related to loading and saving customers to the database than it does actual business rules about customers. Wouldn’t it be nice if you could remove all this persistence-related noise? This session examines why the concept of persistence ignorance is important and how to use NHibernate to build persistence ignorant domain models.

You can register here.

Date: 25-June-2008
Location: Nexen Conference Centre (801 – 7th Avenue SW, Calgary)
Registration: 4:45 pm to 5:15 pm
Presentation: 5:15 pm until everyone’s brain is full

Food and beverages will be provided.

Thanks to everyone for coming out to my presentation last week on new C# 3.0 features and what we can learn from other languages. You can download the slidedeck and demos here.

I’ll be one of the speakers at the Calgary .NET User Group this Thursday. First up is Daryl Rasmussem…

Building ASP.NET/AJAX with Visual Studio 2008 by Daryl Rasmussem

AJAX is now built into ASP.NET with Visual Studio 2008 – and because there’s no separate download to install, the fully integrated nature of AJAX gives you better separation of the code from the design, and the generated Javascript and HTML is cross browser compatible, including support for both FireFox and Opera.

In this presentation, we will use a real world development scenario to explore the following AJAX techniques in Visual Studio 2008:

· Partial Page Rendering and the use of Update Panels

· Using the UpdateProgress control

· Using Control Extenders from the AJAX Toolkit

· Creating a new Extender Control

· Working with web services – from both server and client side code

To C# 3.0… and Beyond by James Kovacs

C# 3.0 introduces lambda expressions, extension methods, automatic properties, and a host of other features. We will look at where C# is today, where it is going tomorrow, and what ideas we can borrow from languages like F# and Ruby to improve our C# code. Plus find out the real reason for the new “var” keyword.

Date/time: Thursday, May 29, 2008 from 5-8pm

Location: Nexen Conference Centre (801 – 7th Avenue SW, Calgary)

Registration: Calgary .NET User Group Events Calendar (N.B. You must be logged in to see the registration link.)

Another DevTeach has come and gone. I had an awesome time. I enjoyed hanging out with old friends and meeting some new ones. I saw a lot of great sessions, but the best part, as always, is the hallway and bar conversations. (No, I still haven’t quite figured out Metastones, even after playing for hours.) I wanted to especially thank everyone involved in the agile track – both presenters and attendees. I have received a lot of positive feedback on the track. Given that I organized the track, I am immensely pleased with its success.

You can download my slides and demos from here or the DevTeach site.

Achieving Persistence Ignorance with NHibernate (2.6 MB)

Taming Software Dependencies with DI and IoC (20.9 MB)

I have started keeping my latest presentations online in Google Code’s Subversion repository.

svn checkout http://jameskovacs.googlecode.com/svn/Presentations/

Take a look in the tags to get the slide deck and demos for a particular event. For example, you’ll find tags/DevTeachToronto2008 contains the version from – surprise, surprise – DevTeach Toronto 2008. If you have any questions or comments on slides, demos, or techniques, please don’t hesitate to email me.

DevTeach is returning to Montreal on December 1 to 5, 2008. I’ll be the Agile Track Tech Chair again. Jean-Rene will be putting out a call for sessions in the near future and you should find the announcement here. If you are interested in speaking in the Agile Track, feel free to email me. If you attended any sessions in the Agile Track and have suggestions for things that you’d like to see again or suggestions for improvement, email me!

During my geekSpeak screencast last week, one of the attendees asked:

Any recommendations for refactoring existing code to insert interfaces? (e.g., what’s the best dependency to break first, the database?)

Excellent question! Most of us do not have the luxury of working on greenfield projects, but instead work on brownfield projects – existing applications that could use some tender loving care. Brownfield projects are often inflicted with legacy code. What do I mean by legacy code? I agree with Michael Feathers’ definition:

Legacy code is simple code without tests.

Michael elaborates further saying:

Code without tests is bad code. It doesn’t matter how well written it is; it doesn’t matter how pretty or object-oriented or well-encapsulated it is. With tests, we can change the behavior of our code quickly and verifiably. Without them, we really don’t know if our code is getting better or worse.

If you haven’t read Michael’s book, Working Effectively with Legacy Code, you really must. It is on my short list of must-read development books. Michael provides excellent strategies and patterns for safely implementing tests around untested code, which is crucial in order to make non-breaking changes to an existing application AKA refactoring. If you can refactor your code, you can improve your code.

Now back to the question at hand… Which dependency to break first? Let me turn the question around. Which dependency is causing you the most pain?

In my experience, it is typically the database as round-tripping to a database on each test to fetch or save data dramatically slows the tests down. If you have slow tests, you’ll be unlikely to run them as often and then the tests start to lose their value as a safety net. (N.B. You still want integration tests that access the database. You just don’t want each and every unit test to do so.) As well it requires a lot of effort to keep consistent data for tests, often using test data setup scripts or rolling back transactions at the end of tests.

Other areas that often cause pain are integration points – web services, DCOM/Enterprise Services, external text files, … Anywhere your application is relying on an external application. Integration points are problems for tests because if you’re relying on them, your tests will fail when the external applications are unavailable due to crashes, service outages, integration point upgrades, external network failures, behaviour changes, … Imagine that your e-commerce website integrates with 6 external systems (credit card processor, credit check, inventory, sales, address verification, and shipping). Your development environment integrates with DEV/QA versions of each of these services. Each service has 95% uptime, which translates into 1.5 days of downtime a month for maintenance, upgrades, and unexpected outages. The chance of all systems being available is the product of their availabilities or 95%*95%*95%*95%*95%*95%=73.5% uptime for all 6 integration points. If your tests directly use these test systems, your test suite will fail over 25% of the time for reasons beyond your control. Now is that because you introduced a breaking change or because one of your integration points is temporarily unavailable or misbehaving? Life gets worse when you integrate with more systems or when the availability of those systems is lower. Imagine you have to integrate with 12 integration points with 95% availability – your test suite will only pass 54% of the time. Or if your 6 test systems only have 90% availability, your test suite only passes 53% of the time. In each case, it’s a coin toss whether you know for certain whether the change you just made broke the application. When you start getting a lot of false negatives (failing tests when the problem is in an integration point), you stop trusting your tests and you’re essentially flying without a parachute.
By decoupling yourself from your integration points by using interfaces for the majority of your tests, you know that the code base is healthy and you can separately test the interactions with your integration points.

To figure out which dependency to break first, take a critical look at your codebase. What is causing you the most pain? Pain can manifest itself as long debug sessions, waiting for external services to be available, high bug counts, … Solve the pain by decoupling yourself from that dependency. Then look at what is now causing you the most pain and solve that. Lather, rinse, repeat. It might take a few weeks or months, but eventually you’ll have a codebase that is a pleasure to work with. If you don’t believe me, read this email that I received from Karl (originally posted here):

Hi James,

I’m writing you because I just wanted to thank you!

It was about two months ago and I attended TechEd/Orlando. I have to say that it was the first time for me and it really was an honor to be the one and only chosen from approximately 300 software developers working in my company to go to Orlando. I was very impressed about the good quality of the sessions, especially on the architecture track, but your tiny little discussion on Tuesday evening really opened my mind. At that time I had been working as a software developer for 7 years with about 5 years experience in software design and project management and 5 years of .NET experience. I was fighting with a 400,000 LOC .NET legacy monster that’s used by public safety agencies around the world in security related areas. I have a team of 12 developers and we were trying really hard to keep this beast up and running and extend it with new features. I think you can imagine that most of the time we were using the trial and error approach to get new features in (just hack it in and prepare for long debugging sessions hunting weird bugs in parts of the application you never expected to be affected by the new feature…). The main problem was – guess what – the dependencies. There were about 50 classes (all singleton “Managers”), and every single manager was tied to at least 10 other managers – no interfaces at all – and that’s just one of several layers of the app… We knew that dependencies were our problem, but we had no clue how to solve it – there was this chicken/egg problem – I want to decouple my system, which needs a lot of refactoring. To ensure that I don’t break anything I’d need unit tests but I can’t use them because my system is so highly coupled ;-) We have tried TypeMock, but my feeling was that this went in the wrong direction. Needless to say that this attempt failed.

During the discussion after your session you gave me some quite useful hints:

1. Read Applying Domain Driven Design and Patterns by Jimmy Nilsson
2. Read Working Effectively with Legacy Code by Michael Feathers
3. Use ReSharper (especially for Refactoring)
4. Use a Mock-Framework (preferably RhinoMocks)
5. Use a Dependency Injection Framework like Spring.NET

I bought Jimmy Nilsson’s book in the conference store and read it cover to cover on my flight back to Vienna. Then I bought the second book and read it within one week. I started to use ReSharper more extensively to apply some of the patterns from Michael Feathers’ book to get some unit tests in place. I extracted a lot of interfaces, brought Spring.NET into action and used RhinoMocks and the VS2005 built in UnitTest-Framework to write some useful unit tests. I also used the built in code coverage functionality in combination with the unit tests. In addition we already started Design for a messaging based service application that we want to develop in a very TDDish style.

As you can see there’s a lot going on since I attended your session. It was really this discussion about agile principles that gave me sort of a boost.

So again – thanks for opening my mind and keep on doing this great work!

Regards,
Karl

In my opinion, Karl and his team are the real heroes here. You can be a hero too by taming your software dependencies!

Today at lunch* I’ll be joining Glen Gordon and Lynn Langit on geekSpeak to talk about Taming Your Software Dependencies. Specifically I’ll be talking about moving from tightly-coupled to loosely-coupled architectures using dependency inversion, dependency injection, and inversion of control containers. geekSpeak is an interactive LiveMeeting driven by audience questions with no PowerPoint and lots of code. Come and geek out with me on geekSpeak! Register here.

* Today at lunch == Wednesday, March 26, 2008 from 12-1pm PST or 1-2pm MST or 2-3pm CST or 3-4pm EST or …

Thanks to everyone who came to my presentations during DevTeach. I’m going to try something different than zip files for distributing code samples. I’ve set up a public Subversion repository on Google Code here. If you’ve got a Subversion client (such as TortoiseSVN) installed, you can point it to:

http://jameskovacs.googlecode.com/svn/Presentations/

The slidedecks are available in the repository, but I’ll provide them here for those that don’t want to go spelunking through the repository…

The Persistence Ignorant Domain Model – PI and, more generally, anti-corruption layers between your code and frameworks, are incredibly important in creating maintainable software. I’ll definitely be talking about these issues in the future. Slidedeck can be found here. Demos can be found in the SVN repository.

Agile Panel with David Laribee and Friends – I qualified in the “Friends” category. The discussion panel was a lot of fun and David did a great job moving the topics along. No slides or demos to see here. Move it along…

Enterprise Version Control – Bil Simser and I did a presentation on best practices in version control. We discussed both Subversion and TFS, though all of our demos were done with Subversion. (The reason… Setup time for a Subversion server – 5 minutes. Setup time for TFS – longer than we cared to take. Yes, both Bil and I have set up TFS before. It’s just a lot more complex than Subversion, though it offers more out of the box.) Slidedeck can be found here (SVN) or here.

Queuing and Caching to Scalability – Other than the technical difficulties in getting my laptop to talk to the projector, I had a fun time with this presentation. (Thanks to the attendee who lent me his laptop so I wasn’t just talking in front of a blank backdrop.) After spending so much time making sure the demos ran flawlessly, I was disappointed that I didn’t get to show them. Slidedeck can be found here. Demos can be found in the SVN repository. The code should be fairly self-explanatory. To run the demos, you need to install MSMQ and create two private queues called messageboardqueue and newbabblesqueue. If you have any questions or problems with the demos, please email me. I’ll try to put together a screencast in the next few weeks for those who are interested, but don’t want to go to the trouble of installing MSMQ.

I appreciate all the feedback I received, both the positive and negative. As a speaker, the best way to improve one’s craft is to critically examine the past presentations by accepting attendee feedback. I think about what went well (and should continue doing) as well as what didn’t go so well and how to improve. Very much like an iteration retrospective in agile development. So keep the feedback coming!

Thanks to everyone who attended my Ignite Your Coding webcast. I enjoyed sharing a small sampling of the wealth of tools available for the Windows and .NET developer. For those of you who missed the webcast (or would like to watch it again), it’s available on-demand here.

Below you will find a list of links that I mentioned during the webcast as well as a few attendee-contributed suggestions:

Resources

Community-Contributed Resources (During the Webcast)

Be sure to check out the rest of the Ignite Your Coding webcast series as there are some other great sessions there.