Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24569
| From | markspace <markspace@nospam.nospam> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: multiple inheritance in Java |
| Date | 2013-07-01 18:59 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <kqtbs2$ou6$1@dont-email.me> (permalink) |
| References | <multiple-inheritance-20130702024630@ram.dialup.fu-berlin.de> |
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
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