From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=AWL,UNPARSEABLE_RELAY autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 04C96BB84 for ; Fri, 16 Jan 2009 17:29:10 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkwDAGFEcEmTIFAHgWdsb2JhbACUBAEBFiJPuTuFcg X-IronPort-AV: E=Sophos;i="4.37,277,1231110000"; d="scan'208";a="21599327" Received: from relay.felk.cvut.cz ([147.32.80.7]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 16 Jan 2009 17:29:09 +0100 X-FELK-MailScanner-Watermark: 1232728144.38243@ZZhYzaOcSdofzlfL4voE4A Received: from k333.felk.cvut.cz (k333.felk.cvut.cz [147.32.87.5]) by relay.felk.cvut.cz (8.14.2/8.14.2) with ESMTP id n0GGT3sh056752 for ; Fri, 16 Jan 2009 17:29:03 +0100 (CET) (envelope-from kybic@fel.cvut.cz) Received: from K333/SpoolDir by k333.felk.cvut.cz (Mercury 1.48); 16 Jan 09 17:29:03 +0100 Received: from SpoolDir by K333 (Mercury 1.48); 16 Jan 09 17:28:50 +0100 Received: from localhost (147.32.84.20) by k333.felk.cvut.cz (Mercury 1.48) with ESMTP; 16 Jan 09 17:28:48 +0100 To: caml-list@yquem.inria.fr Subject: On the benefits of OO, Was: [Caml-list] C++/C# inheritance is bad? Reply-To: Jan Kybic From: Jan Kybic In-Reply-To: <20090116155805.GA8664@annexia.org> (Richard Jones's message of "Fri, 16 Jan 2009 15:58:06 +0000") References: <20090116155805.GA8664@annexia.org> Date: Fri, 16 Jan 2009 17:28:48 +0100 Message-ID: <87d4enfc5b.fsf_-_@fel.cvut.cz> User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0.1 (relay.felk.cvut.cz [147.32.80.7]); Fri, 16 Jan 2009 17:29:03 +0100 (CET) X-FELK-MailScanner-Information: X-MailScanner-ID: n0GGT3sh056752 X-FELK-MailScanner: Found to be clean X-FELK-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-2.599, required 5, autolearn=not spam, BAYES_00 -2.60) X-FELK-MailScanner-From: kybic@fel.cvut.cz X-FELK-MailScanner-To: caml-list@yquem.inria.fr X-Spam: no; 0.00; elegantly:01 variants:01 swapped:01 ocaml:01 avoids:01 caml-list:01 reuse:01 reuse:01 hierarchies:03 algorithms:03 inheritance:03 inheritance:03 subclass:03 solved:04 complex:05 > I have a more fundamental question: Is inheritence actually useful for > anything? By which I mean, are there real world problems which are > solved elegantly with inheritence which are otherwise difficult to > solve? I'm not sure I've seen many. I have seen many very tortuous > class hierarchies though. > Some personal thoughts: I think the OO methodology is good for creating reusable components and maintaining a clean interface between them. I develop complex algorithms which consist of many building blocks. Often, I need to try many variants before settling on a final solution, sometimes there is not even any final solution - for each subclass of a problem a different sub blocks might be appropriate. It is a great time-saver if the building blocks can be swapped with as little change in the code as possible. The inheritance is then a convenient way of code reuse. Code reuse is important because it avoids code duplication. And code duplication is bad because it makes maintenance hard. However, I am not using the OO features of Ocaml much, mainly because of the speed penalty. Jan -- ------------------------------------------------------------------------- Jan Kybic tel. +420 2 2435 5721 http://cmp.felk.cvut.cz/~kybic ICQ 200569450