The Artima Developer Community
Sponsored Link

Weblogs Forum
When Reuse Goes Bad

56 replies on 4 pages. Most recent reply: Jul 30, 2006 12:29 PM by Mike Tocci

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 56 replies on 4 pages [ 1 2 3 4 | » ]
Bruce Eckel

Posts: 875
Nickname: beckel
Registered: Jun, 2003

When Reuse Goes Bad (View in Weblogs)
Posted: Jul 3, 2006 1:38 PM
Reply to this message Reply
Summary
In the fairly famous "Defense Science Board Task Force on Military Software" released in the late 1980s, recommedation 29 was to "...develop economic incentives...to allow contractors to profit from offering modules for reuse..."
Advertisement

(I found this in Software Conflict 2.0 by Robert L. Glass, d.* books, 2006)

Years ago I was called in to consult on a project that had gone bad. The customer had engaged a contractor to develop the software, which was supposed to take a year and was at the time I was called in, a year late.

The main design and technical problem (ignoring for the moment Weinberg's maxim that "No matter what they tell you, it's always a people problem") was that the contractor had decided that this was an opportunity to develop a reusable software system, and that they could develop this system on the customer's dime.

This resulted in classic framework-itis. The contractor was no longer just trying to solve the customer's problem, they were trying to solve all problems that looked like it. So for that reason alone the project would have required 10x the original time and money.

And of course we are unable to avoid the people problem for very long: The architecture had many fundamental flaws, and one very big one resulting from a misunderstanding and assumed overlap between OO objects and Windows messages. This happened because there was one technical lead who was the architect, and who ruled with an iron fist and fired anyone who disagreed with him (and so everyone left was willing to agree with him). And he didn't understand as much as he thought he did.

Framework-itis in general is one way, and probably the most highly-criticized way, that attempts to reuse code go bad.

I postulate that most of the corruption in code resue comes when someone decides ahead of time that we should reuse code. That is, when it is driven by perception rather than need. I have personally found reusable code at the point when I need it a second time, as a process of discovery. And usually it's something I can't anticipate, or at least don't anticipate it in exactly the way that I need it.

Another well-known, and incredibly expensive for the industry as a whole, example of bad code reuse and framework-itis gone awry is EJB1/2 (EJB3 appears to be a completely different beast, riding on the questionable preexisting marketing of EJB). This was designed for an imaginary development process that had never happened before and apparently never happened during the life of EJB1/2, so developers ended up fighting against the framework rather than being aided by it. And I've heard numerous stories of companies having to rip EJB out of their system. Talk about expensive.

I think libraries can also fall prey to bad reuse scenarios. Again, setting out to create reusable code seems to be the culprit, along with imagining how a library will be reused rather than discovering how a library is reused. The great majority of the Python library, in my opinion, has been included after components have been used successfully in practice, and have evolved into a stable state. One notable exception, as I understand it, is the xmllib which was discovered to be un-Pythonic and messy/noisy to use, and the much cleaner elementree is being substituted in Python 2.5.

What experiences have you had when attempts at reuse have gone bad? Do you agree with me that those experiences came primarily from driving the "reuse cart" before the "use horse?"


Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: When Reuse Goes Bad Posted: Jul 3, 2006 7:46 PM
Reply to this message Reply
I think that Don Roberts and Ralph Johnson nailed this in the 90s. Frameworks should happen after applications, not before them:

http://st-www.cs.uiuc.edu/~droberts/evolve.html

The "three examples" pattern, in particular, should be recognized by the industry as a core practice. Fortunately, I'm running into more people who've seen that paper these days. I think that the recent emphasis on evolutionary design in agile methodologies has helped to start to bring it to the forefront again.

I think it all comes down to this: Software has to be used before it can be reused.

Abhijit Nadgouda

Posts: 2
Nickname: anadgouda
Registered: Jul, 2006

Re: When Reuse Goes Bad Posted: Jul 3, 2006 11:34 PM
Reply to this message Reply
I agree that frameworks should be developed only if there is a need, which can provide the requirements. However, it cannot be completely reactive, there should be a proactive element to it. Most of the times I have seen following cases which have resulted in bad reuse:

- A framework is designed with incomplete requirements which results in bad design. It should also consider requirements in the near future if possible.
- A framework is created when certain code is required more than once. The result is a refactored code, rather than redesigned code.
- A framework designed without supporting the basics, like OO design principles, which leads to ineffective interfaces. Even if a violation is unavoidable, it has to be done consciously and sincerely documented and accounted for in future changes.
- A framework is not designed at all and the notorious copy-paste employed everywhere.

I think realisation for a framework should be part of the design. If it is postponed, then a redesign at later stages is too expensive, and refactoring is not always enough.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: When Reuse Goes Bad Posted: Jul 4, 2006 4:58 AM
Reply to this message Reply
Another way to approach the problem is to write small frameworks that are highly decoupled.

Reuse comes out of combining existing components; the higher components are coupled, the higher the difficulty to reuse them is.

(common knowledge stuff many times overlooked)

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: When Reuse Goes Bad Posted: Jul 4, 2006 4:59 AM
Reply to this message Reply
Another way to approach the problem is to write small frameworks that are highly decoupled.

Reuse comes out of combining existing components; the higher components are coupled, the higher the difficulty to reuse them is.

(common knowledge stuff many times overlooked)

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: When Reuse Goes Bad Posted: Jul 4, 2006 5:00 AM
Reply to this message Reply
Another way to approach the problem is to write small frameworks that are highly decoupled.

Reuse comes out of combining existing components; the higher components are coupled, the higher the difficulty to reuse them is.

(common knowledge stuff many times overlooked)

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: When Reuse Goes Bad Posted: Jul 4, 2006 5:35 AM
Reply to this message Reply
Oh, and avoid duplication. :)

Russ Freeman

Posts: 7
Nickname: freemanr
Registered: Jul, 2006

Re: When Reuse Goes Bad Posted: Jul 4, 2006 7:48 AM
Reply to this message Reply
Of course, it's the "Crystal-ball" like development that is going on here, trying to anticipate how someone will use your component in future. I assume Superman or Dr Who is probably better as reusable software development than us mere mortals ;)

Another danger word that often creeps in here is "generic". When someone says to me, "Hey, I'm developing this cool generic service". Nine times out of ten, it is harder to "configure" these reusable blobs than to write something specific in the first place.

Russ Freeman

Posts: 7
Nickname: freemanr
Registered: Jul, 2006

Re: When Reuse Goes Bad Posted: Jul 4, 2006 7:53 AM
Reply to this message Reply
> Another way to approach the problem is to write small
> frameworks that are highly decoupled.

The danger here is in overly decoupling the design. When do you know you have "decoupled" enough? It's easy to create a totally decoupled framework that is hard to use in context. This is why I think frameworks realistically fall out of existing code rather than created afresh.

Tharaka Abeywickrama

Posts: 5
Nickname: tharaka
Registered: Feb, 2006

Re: When Reuse Goes Bad Posted: Jul 4, 2006 8:41 AM
Reply to this message Reply
"EJB3 appears to be a completely different beast, riding on the questionable preexisting marketing of EJB"

Speaking of, what do you think about EJB3 in general? Is it the new savior of enterprise software as they say? Does it fix everything EJB1/2 messed up? Or does it still have issues to work out?

David Medlock

Posts: 11
Nickname: dmedlock
Registered: Jun, 2006

Re: When Reuse Goes Bad Posted: Jul 4, 2006 8:56 AM
Reply to this message Reply
I think this is exactly what is the advantage of Domain Specific languages.

Frameworks try to gather the whole range of possible uses, whereas good DSL design focuses on a specific uses/tasks and a defined range of parameters.

I would rather have reuse by my customers(typically domain experts) than developers in later projects.

Kay Schluehr

Posts: 302
Nickname: schluehk
Registered: Jan, 2005

Re: When Reuse Goes Bad Posted: Jul 4, 2006 9:20 AM
Reply to this message Reply
> I think this is exactly what is the advantage of Domain
> Specific languages.
>
> Frameworks try to gather the whole range of possible uses,
> whereas good DSL design focuses on a specific uses/tasks
> and a defined range of parameters.
>
> I would rather have reuse by my customers(typically domain
> experts) than developers in later projects.

That's a very good intervention. I would put it just slightly different.

A framework is an "application with holes". You can drill small and large holes and also many small holes where stuff has to be filled in a highly coupled manner to make everything work. The prototype of any framework is a language together with an interpreter. The language describes the interface between the interpreter and the application code. A small framework with few small holes will unlikely be identified as a language but a large one with many small holes is just a kind of domain specific language. If you are aware of this you can turn the viewpoint and think about designing a nice DSL in the first place. What was mentioned to be a framework becomes an interpreter. I would like to read more about the following refactoring move: "Replace framework by DSL" in future.

Alex Herz

Posts: 9
Nickname: softcore
Registered: Aug, 2005

Re: When Reuse Goes Bad Posted: Jul 4, 2006 9:31 AM
Reply to this message Reply
Hm..this is a nice example but it seams to be a bit misinterpreted, ihmo. The story doesn't tell whether it would have been a good decision for the contractor to create a framework to save money (because they often do very similar jobs and don't want to reinvent the wheel every time or so).
The contractor obviously abused the contract to produce something they (might) need but was not requested originally. If they had developed a decent framework in parallel (while producing the requested (specialized) application for the customer as agreed) there would be nothing wrong.
The rest is more of a design problem. Optimally you want your framework to cover all cases that fit the "design frame" but not more. As noted frameworks often mutate into the most generic service ever. On the other hand the framework will quickly become unusable if it is designed to narrow..as you never know what kind of new requirements pop up during devlopment.
The whole idea of the famework obviously is to impose restrictions on the user to simplify certain tasks. These restrictions cannot fit all problems (otherwise they wouldn't be restrictions). So if you decouple the framework's services as much as possible everyone can use the bits and pieces he likes and discard those that don't fit the problem. A simple pyramidal hierachy (with the most abstract components on top) where the user can choose the level he want's to operate in should suffice often.
Many frameworks appear to enforce a use all or nothing strategy..so they are forced to be super generic to fit many obscure problems. I say: Let the (framework's) user choose..he's not as stupid as you might think :)

Alex

Jamie McIlroy

Posts: 1
Nickname: jmcilroy
Registered: Jul, 2006

Re: When Reuse Goes Bad Posted: Jul 4, 2006 9:50 AM
Reply to this message Reply
I think this is where the entire SOA initiative is preparing to fail. Thousandsof developers are being instructed to develop their applications with reuse in mind.

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: When Reuse Goes Bad Posted: Jul 4, 2006 10:29 AM
Reply to this message Reply
> I think this is where the entire SOA initiative is
> preparing to fail. Thousandsof developers are being
> instructed to develop their applications with reuse in
> mind.


..and SOA will stand for 'same old architecture.'

Flat View: This topic has 56 replies on 4 pages [ 1  2  3  4 | » ]
Topic: When Reuse Goes Bad Previous Topic   Next Topic Topic: The Problem of Overspecification


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us