Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114234 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 34009 invoked from network); 28 Apr 2021 13:25:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Apr 2021 13:25:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B1BDD1804DB for ; Wed, 28 Apr 2021 06:30:26 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 28 Apr 2021 06:30:26 -0700 (PDT) Received: by mail-lf1-f46.google.com with SMTP id 12so98944274lfq.13 for ; Wed, 28 Apr 2021 06:30:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=UHScOOtdtf84td0s3y3QFGN0Je56fWWwUxVtEW4oCEU=; b=nZYywzqENyRSzU/lPLvZu1EcV27j3DBA7xBDego2bSlm5CXFfeXGLE4TaLSobEqgaf 1mT0pBCXm8IUndQMZDkWZ+93wK/jZMPi2DVi5XzJ0FbslSwVWxupT3WZVcNfBlIF2O6X Nvr5Uqsq02qvAylaDgDsjASvT1GijslnYvHyr9oNV/X+/aFA50CBWLujC3guRAJw+2kT eznEgU9wi9JxM+EcHLTnhyXxHSJO1SgrBUDtCAMvjGRM8IZvtpSrBE+5oFnMjLoN4wSP 7c7w/hrvHHkZWlhio3QkVHYJxfnK4PFN8xryJMAkSxpeEBqCj5gcnjsEGAfk9ETF3qrT 2NOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UHScOOtdtf84td0s3y3QFGN0Je56fWWwUxVtEW4oCEU=; b=ZzWZVuTSolU4zWEBW+jtpwOrluexe4OgJRolrZBooILOzuKQ/R8jB3zsFVeN/lJ2mn kjSh3vkQh5a4ERNu3XP0h/e/OKTMxY2i7OOy5eDeqmqre0QDleaW5LigoPSFGcYxG3BG prYZCmk4SVrc8MCaEuXGRtcjrQG7zA1CDTHpJI5nevW4wYihbPrRByliAYgVVkRKXbA0 D0PTT34UhdgRqS/Y1uKq6SZtD6EvozhzG9ZxB59dWRbEsWOsuM5AlyMwFHGqTT91ZElC e8c9wmbtfuoE8hp1P8APwpUmWnOJUiOQPnqVhLRQAEc0KDFVdIjRSH0dywVay3/U6ALN ZeOA== X-Gm-Message-State: AOAM531mWVLfPz9hqRcx3ouWgTXqaBhgCmqKyET7kKIefbdALfildS4t 5A6F/F+UrimdyOzjL/WJCWwdely2+kWFdQl2OQ== X-Google-Smtp-Source: ABdhPJw3+LtnHhOve4omC2CuPwQ+f9FjrlAoCylng2StcmyYOGrlHFFBkg4GdObCbLPKuMQMquNeMYNOtD8EsX+IgNA= X-Received: by 2002:a05:6512:31cc:: with SMTP id j12mr13264454lfe.335.1619616623276; Wed, 28 Apr 2021 06:30:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 28 Apr 2021 15:30:13 +0200 Message-ID: To: Tony Marston Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000080b78105c10861c2" Subject: Re: [PHP-DEV] [RFC][Draft] Sealed Classes From: guilliam.xavier@gmail.com (Guilliam Xavier) --00000000000080b78105c10861c2 Content-Type: text/plain; charset="UTF-8" Forwarding to the list, and answering: On Wed, Apr 28, 2021 at 9:51 AM Tony Marston wrote: > On 27/04/2021 17:22, Guilliam Xavier wrote: > > On Sat, Apr 24, 2021 at 12:55 PM Saif Eddin Gmati > > > wrote: > > > > > > To me the first sentence of the RFC is debatable: > > > >> The purpose of inheritance is code reuse, for when you have a class that > >> shares common functionality, and you want others to be able to extend it > >> and make use of this functionality in their own class. > > > > That sounds like [abstract] base classes, which certainly permit that, > but > > I wouldn't state that "the purpose" of [designing] class hierarchies is > > "code reuse", which can also (better?) be achieved with traits or even > > simply composition > > I completely disagree that the first sentence of that RFC is debatable > as I consider it to be totally accurate. When you use inheritance via > the 'extends' keyword then every method in the superclass is shared by > the subclass. In the subclass you have the option to override the > implementation of any method in the superclass, or you can add new > methods of your own. But does that necessarily mean that "The purpose of inheritance is code reuse"? This superclass may be abstract, but it need not > be. The methods it contains may be abstract, but they need not be. > I didn't say that they need (the brackets meant "optionally"). And does it really matter actually? > According to the Gang of Four the way to avoid the problems caused by > the overuse of inheritance is to only inherit from an abstract class, > which is precise what I do. I am famous for having an abstract table > class in my framework which contains hundreds of methods and thousands > of lines of code, and because each of my 400 concrete table classes > inherits from the same abstract table class that is a LOT of code which > is shared. This abstract table class also allows me to use the Template > Method Pattern (which is mentioned in the Gang of Four book) so that all > the invariant methods are defined in the abstract class which means that > each subclass need only contain the variable "hook" methods for which it > needs to provide an implementation. > Well, PHP is flexible. I have seen many combinations of (one or several of) interface, [abstract] class, trait, composition... depending on the context. > When you say that code reuse can be better achieved with traits or > object composition I have to disagree. I said "also (better?)", not just "better". But one can think "no" to "better?" ;) Object composition is used only > by those idiots who overuse inheritance, :/ and there is no evidence that > traits are "better" than inheritance. > By the way, is there evidence to the contrary? (genuine question) > Inheritance, when used sensibly, is still the best way to share code. > Your opinion, maybe not unanimity (nor absolute truth). > Regards, > > Tony Marston > > Regards, -- Guilliam Xavier --00000000000080b78105c10861c2--