Hanalei, Hawaii 9/2/2010
438 Posts and Counting

Using IoC TDD To Design Tomorrow's Car

Monday, February 18, 2008 -

I spent Saturday with my buddy Eric, in his garage, drinking really bad Coors Light and talking about cars. He was rebuilding this Jetta of his, swapping out the gas tank to add in a Bio Diesel system. As he was working, I was asking him about car design, and what he would do if he built one from scratch...*

 

I Can Be Manly Too
I took Auto Shop during my senior year of high school, and it was one of the funnest things I've done. I got to use words like "machining the cams on the crank" as well as "using the crush test to make sure I torqued the pistons". Yah - Guy Stuff.

My friend Eric is pretty much a master mechanic. He understands cars more than anyone really should, and when he's bored he coats his hands and arms in grease to feel like he's worth something. Given that he knows as much as he does, I was shocked when we started talking about car design. While watching him yank out the tank in his Jetta, I asked him:

If you could design a car from the ground up - how would you do it?

Eric scratched his head for a second and says "cars are an art form really. Beatiful pieces of machinery. I've always liked the European cars that were built by hand - Ferrari for instance. Every single Ferrari is built completely by hand - no machinery."

"So you like the high-end stuff?" I ask, trying to prod him a little.

"Yah - for sure. I'd probably build a car that had a built in solar array, ran on renewable fuels, was lightweight, and easy to work on".

"Ahhh yes - it's the same in my line of work. Build using current technology like Ajax for sex appeal and make it maintainable. So you'd make sure to Loosely Couple your engine and drive train right?".

"Do what?"

"You know, Loosely Couple - the transmission should know nothing about the engine correct?"

"Well - not really. If you have a 289 Small Block in there, you can't use just any transmission - you have to use one for the engine".

"Sounds like a maintenance nightmare to me. Well I'm sure the Rear Differential and brakes are Loosely Coupled right? You'd want to make sure they implement IDriveTrain I would imagine..."

"Umm ... no dude. Didn't you say you took Auto Shop? The differential needs to be strong enough to handle the torque from the engine - so no - you can't just use any old parts in the drive train. They work together in a ... Gestalt way. You know - the sum is greater than it's parts?"

"Yah whatever Shakti... I have to say I'm really surprised at this. In my industry we strive to make sure that everything we make is swappable and testable. So, for instance, I'd design a car that you could easily swap out the engine for an IEngine, a transmission for an ITranmission, and use Inversion of Control so that if the tires sensed a better road condition, the engine and tranny could be swapped out on the fly and you could kick in to 6th gear with a Bored Our 350 Big Block (which implements IEngine)."

"Interesting. Does the driver know anything about what's happening?"

"No way. The user shouldn't have to know about the internals of the application."

"Great - so when they floor it and the tires loose traction, what happens."

"RTFM."

"Oh ... right. You know that Nissan and Toyota build cars that are so precisely manufactured that each part is independently made for each model? In fact it's why those cars are the longest lasting cars on the road".

"Yah, but the design sucks. You ever tried working on one? It's Spaghetti Engineering in there. I can't tell WTF is going on in there."

"You're not supposed to - it's supposed to work. And it does."

"Yah but I have to pay a mechanic any time I need anything. That's not scalable."

"The cars are built to run based on periodic maintenance. You spend an order of magnitude less over 20 years in maintenance that way. Are you telling me you build your applications so that the main parts are swappable?"

"Of course."

"Do you swap them out a lot?"

"No. But I can if I want to. And that's the point isn't it?"

"If you build a car that has an easily swappable engine and drive train, you'd be spending a whole lot of money in parts my friend. You'd also need a lot of room and extra weight. ANSI standards compliance put the US car companies behind the Eight Ball when foreign cars came out and ignored our standards in favor of more purpose-driven design and extended lifetime. To them that was more important than the making the mechanic's life easier."

"OK fine. What about testing. How would you test your design? I assume you'd draft up a plan and make sure each part is testable, build that part first, make sure it fails, then build it according to your Test Plan right?"

"Well yah - it has to be testable for sure. But I can't afford to take the time to build a part and make it fail, and then rebuild it. That's lame and is a waste of time."

"No, You're lame."

"You never change. Anyway - testing each part is taken very seriously. That's why cars are built on proven technology and each new thing you add to a car is tested independently (according to standards) and then road tested thoroughly. The road test is the most important thing though. You can test something all you want in an isolated lab environment, but it doesn't mean a thing if you don't test it twice as much on the road. Road tests last years you know."

"You mean Test After Development - that doesn't scale Eric. If all of the Units in your car are tested for the things they need to do, then logic says that your car will do what it needs to do. If you wait until you're done, how do you know each of the Units in your car is bug free?"

"You can't be serious."

"I am, and stop calling me Shirly."

"I didn't. The car is much more than it's parts. As I said before - it's a work of art and as such exists as a whole in and of itself that is far greater than it's 'Units'. There's the whole rush of taking a smooth curve, the smell of the new leather, the way the wheel feels in your hand, the way the accelerator, brake, and wheel all work with the same degree of resistance which makes the car feel alive. You can't test this stuff in Units. It's either there, or it isn't and you tweak it until it is."

"But you can test for all that! You just need to have a good testing plan!"

"Did your parents have a good 'Testing Plan' for you when you were growing up? Doubt it - you just grew and became ... you. A car's design evolution is the same. You build a prototype, test it on the track in a series of tests, refactor it a bit, retest, etc. It's all about evolving."

"Whatever. Your car sucks. I wouldn't drive it without Unit Tests and Loose Coupling."

"Go get me a Coors Light and stop talking would ya..."

 

And here I thought Eric knew something about Good Design. He was a geek at one time too. Poor guy - his car is going to be a wreck!

*This never happened, of course, but a version of it did and it was pretty funny :).

Related


Gravatar
Bill Pierce - Monday, February 18, 2008 - Is there such a thing as good Coors Light?
Gravatar
Evan - Monday, February 18, 2008 - @Bill,

If only Coors would have tested it before they produced it..they would have made something else..
Gravatar
Joe Chung - Monday, February 18, 2008 - I don't know jack about cars, but it seems weird that a guy would talk about how silly it was to replace the main parts of a car while at the same time be rebuilding one with an entirely different fuel system.
Gravatar
Rob Conery - Monday, February 18, 2008 - @Joe: It's not really an entirely different system - his Jetta is a diesel and is still a diesel. The converter he installed just takes cooking oil, filters it, and does some magic to make it work in a diesel engine. But your point is taken :).
Gravatar
Shawn Oster - Monday, February 18, 2008 - There are even more little nuggets that can be drawn from your analogy, such as what makes a great luxury car isn't just that it can go fast and do it well but that attention has been paid to aesthetics such as the trim, leather seats, the styling of the headlights (well used high quality icons and consistent use of UI elements). Also the stiffness of the clutch, throw of the gearshift and the layout of the gauges all allows the driver to get the most from the experience (well thought out default options, usability, discoverable interface).

Glad to see a Jetta live on, my wife keeps trying to get of my '97.
Gravatar
Elmar - Tuesday, February 19, 2008 - This inspired me to write down some of the things I´ve learned about BMW´s production line and how that would relate to building software. Check it out here, if you like -> http://aerobis.wordpress.com/2008/02/19/if-cars-were-software/
Gravatar
alberto - Tuesday, February 19, 2008 - LOL. You always make my day with this kind of posts. Nice reading. Being serious there are a couple important differences between cars and software. - Cars depend on physics, software doesn't (The differential needs to be strong enough to handle the torque from the engine) - Software needs way much more maintenance than cars do. - Software is a lot much more evolutive than cars are.
Gravatar
Rob Conery - Tuesday, February 19, 2008 - @Alberto - good points :). In terms of physics... static thread locks anyone? If, by maintenance, you mean feature revs then yes - true enough. If you mean bug fixes - yep; much less tolerance for faults in car design - that's for sure but that's because we can - isn't it? I really like the word "Evolutive" - I think you just invented something good! If you mean that it evolves quicker - I'd say you're correct in a big way. I don't think it evolves differently - just faster.
Gravatar
adminjew - Tuesday, February 19, 2008 - What about trying this on an Airplane (physics are not as complicated :-) see - http://channel9.msdn.com/ShowPost.aspx?PageIndex=1&PostID=314874#314874&d=0
Gravatar
Dave Savage - Wednesday, February 20, 2008 - It seems like a lot of developers or computer majors in general tend to be big gear heads. I know it doesn't fit everyone but nothing ever does. Just found it ironic.
Gravatar
Haacked - Wednesday, February 20, 2008 - This only highlights just how different car building is to software dev. Much like bridge building: http://www.codinghorror.com/blog/archives/000298.html

;)
Gravatar
Ayende Rahien - Thursday, February 21, 2008 - Rob, Well, given that I had a very specific task, well defined input/output (I get gas and I move the car, basically), have strict design constraints in terms of output (pollution, mileage per gallon, etc), have tight requirements around security, and in general not have much surprises along the way (we decided that we really need to be able to drive sideway), be able to build on top of well proven technologies, make relatively minor modifications per model, have multi year test plans that no sane management would try to cut, build with the assurances that physics doesn't change and that I am not going to have to live with my decisions for all times (versioning, frex). Yes, then maybe I would go with this approach. I am not in that industry, however.
Gravatar
Ben - Tuesday, February 26, 2008 - Given that roads are a little more consistent in general and laws of physics remain the same regardless of where you are on Earth, the analogy would be more fitting of embedded systems development vs. generalized user applications, etc. Web and desktop applications are being designed to run and execute in chaotic environments in comparison with a much larger set of unknowns, especially with all the legacy support in most systems today. Simple, independently testable components on this kind of architecture makes more sense, since one component may not fit or work correctly when run on a specific platform, but these components are being designed to be run in an application hosted on some unknown machine. A car part will be run in a known machine within a relatively known universe, making it easier to make a tailored component that is more dependable, similar to developing components for an embedded environment.
Gravatar
Rob Conery - Sunday, March 23, 2008 - "Would you drive a Vista ?" I'm still laughing :). Classic...!