Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit3.readnews.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Abstract Class versus an Interface, when no Members in Common Date: Thu, 3 Nov 2011 18:10:08 -0700 (PDT) Organization: http://groups.google.com Lines: 22 Message-ID: <21089688.186.1320369008216.JavaMail.geo-discussion-forums@prev11> References: <22857359-211e-443e-9c5d-6cc2f5bd971b@m19g2000vbm.googlegroups.com> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 2620:0:1000:2404:224:d7ff:fe69:5838 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1320369085 27002 127.0.0.1 (4 Nov 2011 01:11:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 4 Nov 2011 01:11:25 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:1000:2404:224:d7ff:fe69:5838; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:9489 markspace wrote: > KevinSimonson wrote: > > So I created an abstract class called that has no > > In the real world, when there's a class like this, there's usually some > meta data that can decode which type is being returned. As Arne points > out, there's usually also a "getAsType" method. For example, the JDBC > object has various "getBoolean()" and "getBlob()" methods for accessing > database columns, as well as metadata describing the object. > > While not the best over all (JPA is better, generally, than JDBC), it's > more structured that just an abstract class with no methods. > > I might say that no methods = interface (called a mixin), but I think > the potential to add common methods here is high. So, use a base class > so that you don't get tripped up by Java's single inheritance. It's the > most conservative approach in this case. The OP's approach seems somewhat hackish, based on the paucity of information provided so maybe it isn't. Would it work to make the varying type a generic parameter? -- Lew