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.c-24-60-169-94.hsd1.ma.comcast.net!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: multiple inheritance in Java Date: Mon, 01 Jul 2013 21:52:11 -0400 Organization: A noiseless patient Spider Lines: 45 Message-ID: References: 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:46:47 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="c-24-60-169-94.hsd1.ma.comcast.net:24.60.169.94"; logging-data="23473"; mail-complaints-to="abuse@eternal-september.org"; posting-account="esosman" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:24568 On 7/1/2013 8:31 PM, Stefan Ram wrote: > Assume you needed a class ColorPoint in Java: > > class ColorPoint extends Position, Color; > > . Would it be so bad to implement this using public fields > instead of classical delegation? Public fields: > > class ColorPoint > { public final Color color; > public final Position position; ... } > > , usage: > > point.color.r = 72; > point.color.b = 65; > point.color.c = 41; > point.position.x = 212; > point.position.y = 117; > > . Classical delegation style: > > point.setR( 72 ); > point.setB( 65 ); > point.setC( 41 ); > point.setX( 212 ); > point.setY( 117 ); > > . 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? Sorry, but I can't make head or tail of your question. I haven't been following the prognostications for future Java versions, and the only versions I know forbid multiple inheritance. Besides, I don't see where M.I. comes into the picture: You seem to be asking about public fields and final fields, not about how to merge multiple implementations and resolve their potential conflicts. Also, what are Position and Color? It doesn't seem to me that javax.swing.text.Position or java.awt.Color are candidates. -- Eric Sosman esosman@comcast-dot-net.invalid