Re-Use is hard
Bloody hard.
Well, at least it seems to be. So why?
We’re better off than most at work. We hire really smart people, we’ve got good tools and we keep our working practices under review so we can get better all the time. We’ve solved many of the problems that seem to plague software companies (and have a whole new set all of our own ;-)
So why, with a whole bunch of really smart people working close together on similar projects using the same technologies do we not have near perfect re-use?
By re-use I mean proper re-use – of packaged libraries of code – not simply copying and pasting code someone else wrote already. Copying and pasting is easy, you don’t have to think about dependancies, or clashes or what they might change about it in future. You can alter it in subtle ways that make it ‘neater’ and ‘more understandable’. I put those in quotes because they’re subjective measures, what’s more understandable for you may not be for me.
And there lies the nub of the problem. If we’re writing code that others can take and re-use we have to write in a way that matches the problems they’re trying to solve as well as the one we’re solving. And that’s the hard bit.
The reason it’s so hard is that we have to put all the modeling we have in mind for the current problem to one side and start modeling from scratch in a different, more abstract and generic way.
Thinking about it from an OO perspective, books such as Domain-Driven Design by Eric Evans and Object Thinking by David West lead us down the path of using nouns from the domain to name our classes, but when we do that we have to decide which domain we’re currently in. If you want to build re-usable UI controls then your domain is the UI, so nouns like ‘TextBox’ make sense while nouns like ‘Author’ do not – if you want the components to be reusable that is.
In essence that’s where the hard bit lies; in identifying the different domains and how they should be cut so that they can then be recombined in different ways.
So how to get better at that? The obvious thing to do is go look for places where people already solved the problem – that turns out to be class libraries like MFC, the .Net libraries and the swathes of small, open-source libraries that do just one thing well.
When we look at these we find they’re broken into modules, components, namespaces or some other unit of packaging. Within each module the vocabulary is consistent, complete and, to a great extent, independent. This means that a library for parsing RSS may depend on one for parsing XML, but is unlikely to require other packages. This sounds obvious when written down, or as you read a book on it, but when writing the code itself it’s hard.
So, knowing it’s hard, the next most important thing is to support the evolution of the components, otherwise we have to get them right first-time which seems unlikely. This requires forgiveness and respect. The thing you want to re-use won’t have been written as you would have written it yourself; and at that realization you have a choice of two paths.
The first and most common route would be to get a bit ranty, copy & paste the code into your own world (where you have absolute control, so don’t need to be considerate) and start hacking it into the shape you want for the problem you’re solving. The second is to take a deep-breath, put on your reading glasses and start to try and make your head think the way the original author was thinking – if you can achieve that then you can go on to improve the code, extend it sympathetically and contribute that work back. The second route is harder, much harder, than the first.
But even knowing that, it still looks hard to me.
Technorati Tags: code reuse, software engineering
2 Comments to Re-Use is hard
Nice article. We’ve hit this issue also, but slightly less hard as reuse is happening amongst the same team, writing side-by-side applications. The approach we’ve taken is to make an assembly “reusable” only when a second application requires the same functionality. So far the only challenge we hit here was dependancies – two apps were using different log4net versions, with differing strong names, so both apps and the component had to be rebuilt to take the lowest denominator. Components that are small and focussed have worked well so far, e.g. EmailNotifier, FileConverter (strange how they’re more verb like than nouns eh – probably still too procedural :-)
November 4, 2007
Lyndsay,
Interesting that you rebuilt to the lowest version. .Net, unlike pretty much any other environment, has the ability to load different versions of strong-named assemblies side-by-side at runtime. They have to be registered in the GAC (Global Assembly Cache) for that to happen, but it works extremely well.
‘Notification’ may make a better class than EmailNotifier…
rob
Leave a comment
Additional comments powered by BackType
Search
What I'm Doing...
- @JingyeL I don't know yet, someone from here will be. in reply to JingyeL 1 week ago
- @JingyeL are you going to ISWC 2010 in November, Shanghai ? 1 week ago
- Back from work to find 666 unread emails waiting for me — must be a sign... 1 week ago
- More updates...
Recent Comments
- Charles Cox on Distributed, Linked Data has significant implications for Intellectual Property Rights in Data.
- Puia on ISBN 10/13 Converter in Excel
- tee on Fixing a plasma TV
- computer doctor on Fixing a plasma TV
- Mars on left wondering…
- neeli on Pranav Mistry: The thrilling potential of SixthSense technology | Video on TED.com
- infopeep on You’re not the one and only…
- talisians on You’re not the one and only…
- olyerickson on Semtech 2010, San Francisco
- PaulMiller on Semtech 2010, San Francisco
Categories
- .Net Technical (8)
- Blog on Blog (6)
- commands I have issued (10)
- Enterprise Architecture (19)
- event (4)
- Fiction Book Review (2)
- Food (2)
- Intellectual Property (9)
- Interaction Design (27)
- Internet Social Impact (43)
- Internet Technical (16)
- IP Law (10)
- Library Tech (19)
- Linked Data (1)
- Music (2)
- New Toy (4)
- Non-Fiction Book Review (7)
- Ontologies (6)
- Open Data (7)
- Other Technical (20)
- Personal (36)
- Random Thought (16)
- Resourcing (4)
- Review (1)
- Security And Privacy (11)
- Semantic Web (32)
- Software Business (11)
- Software Engineering (37)
- Talis Technical (9)
- Uncategorized (44)
- Working at Talis (26)
- [grid::blogpaper] (8)
- [grid::fatherhood] (4)
Archives
- July 2010 (1)
- June 2010 (2)
- February 2010 (1)
- January 2010 (4)
- November 2009 (10)
- October 2009 (4)
- September 2009 (2)
- August 2009 (9)
- July 2009 (12)
- June 2009 (5)
- May 2009 (6)
- April 2009 (7)
- March 2009 (3)
- February 2009 (6)
- January 2009 (10)
- December 2008 (4)
- November 2008 (4)
- October 2008 (9)
- September 2008 (23)
- August 2008 (8)
- July 2008 (1)
- June 2008 (1)
- May 2008 (6)
- April 2008 (14)
- March 2008 (3)
- January 2008 (5)
- December 2007 (6)
- November 2007 (13)
- October 2007 (9)
- July 2007 (2)
- June 2007 (1)
- May 2007 (10)
- April 2007 (5)
- March 2007 (11)
- February 2007 (10)
- January 2007 (13)
- December 2006 (8)
- November 2006 (8)
- September 2006 (2)
- August 2006 (1)
- June 2006 (2)
- February 2006 (2)
- January 2006 (3)
- December 2005 (3)
- November 2005 (2)
- September 2005 (2)
- August 2005 (5)
- July 2005 (8)
- June 2005 (3)
- May 2005 (2)
- February 2005 (1)
- January 2005 (4)
- December 2004 (3)
- November 2004 (6)
- October 2004 (2)
- September 2004 (2)
- August 2004 (5)
- July 2004 (1)
- June 2004 (4)
- May 2004 (4)
- April 2004 (3)
- March 2004 (13)
- February 2004 (6)
- December 2003 (3)
- November 2003 (1)
- August 2003 (2)
- July 2003 (1)
- June 2003 (2)
- May 2003 (1)
- March 2003 (1)
- January 2003 (1)
- October 2002 (1)
- May 2002 (1)
- March 2002 (1)
- August 2001 (1)
- May 2001 (1)
- April 2001 (1)
- January 2001 (1)
- December 2000 (1)
- November 2000 (1)
- December 1999 (1)
- November 1999 (1)
- July 1999 (1)
October 17, 2007