<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/01/c69523eaafbcbe2312b568706d7a7c98"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2009-01-17T12:40:24"
  subject="Re: On the benefits of OO, Was: [Caml-list] C++/C# inheritance is bad?"
  prev="2009/01/4274d9a042cd64c80ff97c7575ccf3cb"
  next="2009/01/bf9090ae9b10f70576fe56884cc0bb1d"
  prev-in-thread="2009/01/62a2d4cfa48d2f7cdc9e412c097ea6e8"
  next-in-thread="2009/01/6cca6c9feefd88566702defdd9eb4640"
  prev-thread="2009/01/7d9ffe8f9682d9fa8b4a85b38c339f33"
  next-thread="2009/01/000cddff1b409b39cd14cc392083ce8a"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="C++/C# inheritance is bad?">
<msg 
  url="2009/01/f038b8a453e89bfa6350495a826080fe"
  from="Kuba Ober &lt;ober.14@o...&gt;"
  author="Kuba Ober"
  date="2009-01-16T15:18:51"
  subject="C++/C# inheritance is bad?">
<msg 
  url="2009/01/7f3ed02f83caca6c67c43c70d569e674"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2009-01-16T15:58:08"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/62a2d4cfa48d2f7cdc9e412c097ea6e8"
  from="Jan Kybic &lt;kybic@f...&gt;"
  author="Jan Kybic"
  date="2009-01-16T16:29:10"
  subject="On the benefits of OO, Was: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/c69523eaafbcbe2312b568706d7a7c98"
  from="Oliver Bandel &lt;oliver@f...&gt;"
  author="Oliver Bandel"
  date="2009-01-17T12:40:24"
  subject="Re: On the benefits of OO, Was: [Caml-list] C++/C# inheritance is bad?">
</msg>
</msg>
</msg>
<msg 
  url="2009/01/6cca6c9feefd88566702defdd9eb4640"
  from="Raoul Duke &lt;raould@g...&gt;"
  author="Raoul Duke"
  date="2009-01-16T18:27:41"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/5977e5c50685f9511c2a7aaeb88f2aaa"
  from="Kuba Ober &lt;ober.14@o...&gt;"
  author="Kuba Ober"
  date="2009-01-16T21:42:40"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/1688f5de4636fc2a074a556bdd4e13c5"
  from="Sashan Govender &lt;sashang@g...&gt;"
  author="Sashan Govender"
  date="2009-01-17T03:14:40"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/3da7c22bc8951acf11dc387c75d70ce3"
  from="Kuba Ober &lt;ober.14@o...&gt;"
  author="Kuba Ober"
  date="2009-01-17T14:07:23"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/0d0df2a5f73e6806a082ed1385428205"
  from="Stefano Zacchiroli &lt;zack@u...&gt;"
  author="Stefano Zacchiroli"
  date="2009-01-18T06:24:43"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
</msg>
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2009/01/bf9090ae9b10f70576fe56884cc0bb1d"
  from="Jon Harrop &lt;jon@f...&gt;"
  author="Jon Harrop"
  date="2009-01-17T13:23:25"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/9830bc229413613d2df787f6c4190432"
  from="Kuba Ober &lt;ober.14@o...&gt;"
  author="Kuba Ober"
  date="2009-01-17T14:35:25"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/484729b8c91b7ed08f7a809ef4800784"
  from="Jon Harrop &lt;jon@f...&gt;"
  author="Jon Harrop"
  date="2009-01-17T16:55:53"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/bc0b728019ecc0ed06c6c620d4829306"
  from="Kuba Ober &lt;ober.14@o...&gt;"
  author="Kuba Ober"
  date="2009-01-17T21:22:22"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/b83f81eef8ccb535ebb9797ff38dee68"
  from="Jon Harrop &lt;jon@f...&gt;"
  author="Jon Harrop"
  date="2009-01-17T22:14:04"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/e6aec16698cc330e90186b9637b316b6"
  from="David Teller &lt;David.Teller@u...&gt;"
  author="David Teller"
  date="2009-01-17T23:29:08"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
<msg 
  url="2009/01/81422a330b59f6967afaba609aa0aa1c"
  from="Jon Harrop &lt;jon@f...&gt;"
  author="Jon Harrop"
  date="2009-01-17T23:46:02"
  subject="Re: [Caml-list] C++/C# inheritance is bad?">
</msg>
</msg>
</msg>
</msg>
<msg 
  url="2009/01/9d3495098b6736864d7a911f80eacf02"
  from="Yoann Padioleau &lt;padator@w...&gt;"
  author="Yoann Padioleau"
  date="2009-01-19T16:22:12"
  subject="Visitor in OCaml [was Re: [Caml-list] C++/C# inheritance is bad?]">
<msg 
  url="2009/01/15619ef0d6556c727c807856c0540121"
  from="blue storm &lt;bluestorm.dylc@g...&gt;"
  author="blue storm"
  date="2009-01-19T16:41:37"
  subject="Re: Visitor in OCaml [was Re: [Caml-list] C++/C# inheritance is bad?]">
<msg 
  url="2009/01/982cca226b947ab9e2f9f544aa708026"
  from="Richard Jones &lt;rich@a...&gt;"
  author="Richard Jones"
  date="2009-01-19T17:49:27"
  subject="Re: Visitor in OCaml [was Re: [Caml-list] C++/C# inheritance is bad?]">
</msg>
<msg 
  url="2009/01/0eb7ca2a446affb91a9277e3c12af881"
  from="Christophe TROESTLER &lt;Christophe.Troestler+ocaml@u...&gt;"
  author="Christophe TROESTLER"
  date="2009-01-19T17:52:12"
  subject="Re: Visitor in OCaml">
</msg>
<msg 
  url="2009/01/bbed03c4ad81907e983814572437326f"
  from="Yoann Padioleau &lt;padator@w...&gt;"
  author="Yoann Padioleau"
  date="2009-01-21T20:09:07"
  subject="Re: Visitor in OCaml">
<msg 
  url="2009/01/9828bde42f61b10aa9f08a2126773cd0"
  from="Yaron Minsky &lt;yminsky@g...&gt;"
  author="Yaron Minsky"
  date="2009-01-22T04:03:22"
  subject="Re: [Caml-list] Re: Visitor in OCaml">
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Zitat von Jan Kybic &lt;kybic@fel.cvut.cz&gt;:

&gt; &gt; I have a more fundamental question: Is inheritence actually useful
&gt; for
&gt; &gt; anything?  By which I mean, are there real world problems which are
&gt; &gt; solved elegantly with inheritence which are otherwise difficult to
&gt; &gt; solve?  I'm not sure I've seen many.  I have seen many very
&gt; tortuous
&gt; &gt; class hierarchies though.
&gt; &gt;
&gt;
&gt; Some personal thoughts:
&gt;
&gt; I think the OO methodology is good for creating reusable components
&gt; and maintaining a clean interface between them.
[...]

This also can be done with module system.
Functors for example can help a lot here.



&gt;
&gt; I develop complex algorithms which consist of many building blocks.
&gt; Often, I need to try many variants before settling on a final
&gt; solution, sometimes there is not even any final solution - for each
&gt; subclass of a problem a different sub blocks might be appropriate.
&gt; It is a great time-saver if the building blocks can be swapped with
&gt; as little
&gt; change in the code as possible.
[...]

Modules and Functors are very good for this task.
Just change the used module.

If you need a certain flexibility that modules can not offer,
for example, selecting certain implementations by user input,
both paradigms can be combined: use OO-style for the selection
of the seperate modules.


&gt;
&gt; The inheritance is then a convenient way of code reuse.

But it's very overrated.
Inheritance is the most obvious OO technique,
and the way, how people tries to convince
non-OO-programmers from the advantage of OO.
But there are many other OO mechanisms,
and ofteh it turns out that inheritance is used, where
other OO-technics would be much better.
With setting OO equal to inheritance, code will become
weid and clumsy. So the advantages of OO can't be turned
into advantages for the code.



&gt; Code reuse is important because it avoids code duplication.
&gt; And code duplication is bad because it makes maintenance hard.

Yes, and modules and functors are very good here.

&gt;
&gt; However, I am not using the OO features of Ocaml much, mainly because
&gt; of the speed penalty.

If you don't use them, it looks to me that you don't need them.

If there really would be a need for OO in your code,
you would use it, otherwise your program could not run as intended.

So: you use OO for your own convenience (because you seem to be used to
it), even other techniques are sufficient for gaibning the goal.

I would use OO , when it is necessary, and not, if not.

OO paradigm does solve some problems of non-OO code.
But most of them can be done with modules and functional programming
techniques (higher order functions) also.

For many tasks OO is used like Bells-and-Whistles, and inheritance as an
addiction. This makes code not better. Using that techinques that help,
and not those, that are hype, will make code better.


Ciao,
   Oliver

</contents>

</message>

