Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24569

Re: multiple inheritance in Java

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED.50-76-45-78-ip-static.hfc.comcastbusiness.net!not-for-mail
From markspace <markspace@nospam.nospam>
Newsgroups comp.lang.java.programmer
Subject Re: multiple inheritance in Java
Date Mon, 01 Jul 2013 18:59:38 -0700
Organization A noiseless patient Spider
Lines 33
Message-ID <kqtbs2$ou6$1@dont-email.me> (permalink)
References <multiple-inheritance-20130702024630@ram.dialup.fu-berlin.de>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 2 Jul 2013 01:54:10 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="50-76-45-78-ip-static.hfc.comcastbusiness.net:50.76.45.78"; logging-data="25542"; mail-complaints-to="abuse@eternal-september.org"; posting-account="markspace"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
In-Reply-To <multiple-inheritance-20130702024630@ram.dialup.fu-berlin.de>
Xref csiph.com comp.lang.java.programmer:24569

Show key headers only | View raw


On 7/1/2013 5:47 PM, Stefan Ram wrote:
> Supersedes: <multiple-inheritance-20130702021857@ram.dialup.fu-berlin.de>

>    . Would it be so bad to implement this using public fields
>    instead of classical delegation? Public fields:

>
>    . I only ask, because public fields usually are frowned upon
>    in OOP, but what would be the drawback here, especially when
>    those fields are final?
>

With private fields, you can enforce some constraint on color and 
position.  Without it, you'll constantly have to check in every method 
if those constrains are still valid or not.

There's other reasons.  Public final fields aren't thread safe, for 
example, so you're encouraging bad style, imo.

You also allow any arbitrary changes to your class this way, and forgo 
encapsulation.  This also seems bad style.

You can forgo inheritance if you like, ColorPosition does not have to be 
a type of Position (or Color), but encapsulation seems too basic and 
desirable to give up.  You might be able to make the case for some 
simple examples, but I think problems with this idea would become 
apparent quickly in even a modest sized project.

What's your goal here?



Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: multiple inheritance in Java markspace <markspace@nospam.nospam> - 2013-07-01 18:59 -0700
  Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 00:30 -0400
    Re: multiple inheritance in Java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-07-02 08:17 -0400
    Re: multiple inheritance in Java Arne Vajhøj <arne@vajhoej.dk> - 2013-07-04 16:31 -0400

csiph-web