Book a Demo

Author Topic: reuse  (Read 5521 times)

rescobar

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
  • Viva Bolivia
    • View Profile
reuse
« on: August 26, 2005, 01:18:38 pm »
Hi, what do you think about the OO reuse? Let's suppose I have a interesting class in applicacion "A". If I need the same class in application "B":

- Copy the class file and import it to app B?
- Make a framework that contains the interesting class available to all applications?
- Copy/Paste the interesting methods only?

I'm confusing about reuse in OOD. Any idea will be appreciated.

Regards
Ramiro
Sergio Escobar
[email protected]

thomaskilian

  • Guest
Re: reuse
« Reply #1 on: August 26, 2005, 03:35:52 pm »
Do you think copy/paste is reuse? Probably not really. It depends on what you need to do.

If at a certain point in time you decide to use a class a second time, you have to tell yourself: this is something "global"; I'll put it somewhere on another "level". If you do so, you have to pull the class out of the previos scope and make it available to both applications. This decision will impose some additional work for a) correction the previous model and b) making the class available from a higher level to others.

Doing it this way is quite unlikely, because the normal path would be: "Ah- something I did already in three or more similar ways. Why not deriving something more abstract?" I guess that only in a few cases you will do the step to make a general interface, because it's an awfull lot of work.

So in the end, software reuse will be the *IX way. Copy existing stuff and don't care about the past :-X

rescobar

  • EA User
  • **
  • Posts: 69
  • Karma: +0/-0
  • Viva Bolivia
    • View Profile
Re: reuse
« Reply #2 on: August 26, 2005, 03:48:03 pm »
Thank you Thomas. I hope that when my OOD knlowledge progress, I'll be more confident what abstraction level is the right one.
Sergio Escobar
[email protected]

thomaskilian

  • Guest
Re: reuse
« Reply #3 on: August 26, 2005, 03:58:50 pm »
I always recommend Occams Razor. It cuts in the very beginning, but (if the cut was right) in the end your model is easier to maintain. You need the experience or good luck, though. :)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Ockham's Razor
« Reply #4 on: August 26, 2005, 04:49:18 pm »
Quote
I always recommend Ockham's Razor. It cuts in the very beginning, but (if the cut was right) in the end your model is easier to maintain. You need the experience or good luck, though. :)
If you have strong discipline, AND are prepared to continuously refactor, then you need a only a very small amount of luck and somewhat less experience.

The best kind of reuse is the reuse of concepts.  Recognizing that this is something you've done before (or very similar) is important.  This allows re-use to proceed top-down:  If I refactor or slightly amend, can I re-use this whole subsystem?  If I refactor or sightly amend, can I reuse this component? if I refactor or slightly amend can I re-use this class nest?  etc.

Thomas is spot on about Ockham's Razor, but the way to get it to cut in early and well, is every time you do something ask yourself: "Is this a particular instance of something I will need a lot".  Then as Thomas says, abstract some, refactor all existing to the new abstraction and continue.

It requires great Discipline, Discipline, Discipline! TM as progress appears initially slow and managers and users typically want visible action!  But ultimately you will obtain great leverage because of the Consistency, Consistency, Consistency! TM and Orthogonality, Orthogonality, Orthogonality! TM of the design...

A well formed Model, Model, Model! TM is the ONLY way to fly!

HTH,
Paolo

BTW, here in OZ we have a weekly Science radio program called Ockham's Razor!
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

thomaskilian

  • Guest
Re: Ockham's Razor
« Reply #5 on: August 27, 2005, 12:22:20 pm »
Quote
...Ockham...

I've been (badly) influenced by something that is called Neue Deutsche Rechtschreibung (New German Spelling). Hope he doesn't turn over in his grave. :-[
« Last Edit: August 27, 2005, 12:22:44 pm by thomaskilian »

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: reuse
« Reply #6 on: August 28, 2005, 03:59:36 pm »
AFAIK Occam (poss, Occamm) is a philosopher, Ockham is an Australian  science commentator.

b
« Last Edit: August 28, 2005, 04:00:08 pm by sargasso »
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Will the real Ockham please stand up?
« Reply #7 on: August 28, 2005, 04:34:18 pm »
Quote
AFAIK Occam (poss, Occamm) is a philosopher, Ockham is an Australian  science commentator.

b
Let's put this one to bed...  ;D

Ock·ham also Oc·cam, William of. 1285?-1349?.
English scholastic philosopher who rejected the reality of universal concepts and argued that mental and linguistic signs are the only genuinely universal features of reality.

Ockham's Razor is named after William of Ockham. There's an explanation on our website what Ockham is about.

regards,
Brigitte Seega
Producer
Science Unit


BTW: Ockham's Razor is available on MP3 and iPod.
« Last Edit: August 28, 2005, 06:34:08 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

TrtnJohn

  • EA User
  • **
  • Posts: 176
  • Karma: +0/-0
    • View Profile
Re: reuse
« Reply #8 on: August 29, 2005, 06:21:16 pm »
This next comment is probably obvious to most here but it is often overlooked by novices:  It is always best to make sure your abstractions correspond to real-word objects in the problem domain.  They do NOT exist as just an implementation convenience tool.  This is why your model is so important.  Through modeling you transform your uses into logical classes that represent the objects of the system.  They become re-useable because they are not tied to any specific application requirement.  Instead they describe a real-world object.  If you build them for impementation convenience of a certain set of requirements they will not easily be re-used.  If you try, they usually become overly complex and burdensome to use.  Like a Swiss-army knife.

thomaskilian

  • Guest
Re: reuse
« Reply #9 on: August 30, 2005, 05:40:04 am »
Quote
...  Like a Swiss-army knife.

Which will raise the question whether this knife is in contrast to Ockham's Knife (aka Razor).