Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Cecil Westerhof Newsgroups: comp.lang.java.programmer Subject: Re: Is this a correct implementation of an abstract class and implementation class Date: Sun, 13 Aug 2017 07:33:04 +0200 Organization: Decebal Computing Lines: 50 Message-ID: <87378wxca7.fsf@munus.decebal.nl> References: <87r2wgxz2p.fsf@munus.decebal.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: mx02.eternal-september.org; posting-host="1615173a1409002a85fbdd25ac4b9ead"; logging-data="19613"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZuvpXypdGjZ6ruGogrZKIgBENDUNYAac=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:90fuqA+1MDxfpQTH4Gm3Z/G6wOI= sha1:p3GDmUGlCIcTYzeS14AHElhk9ak= X-Homepage: http://www.decebal.nl/ Xref: csiph.com comp.lang.java.programmer:37161 ram@zedat.fu-berlin.de (Stefan Ram) writes: > Cecil Westerhof writes: >>public SQLite3 (String database) throws SQLException { >> super(database); >>} >>Is this the correct way to do this, or is there a better way? > > There is no »correct« in this case. There are different > possibilities. But the choice between them depends on the > use expected, and you know best how you expect the classes > to be used. In a way I do not. ;-) I am writing it as an exercise and to make live a little easier for myself. But I am thinking about sharing it, so it can be used in a lot of ways. For example: I will ‘always’ use the database connection for the whole run of my program, but I made the class AutoCloseable, so it can also be used in a try with resources, even if I do not use it that way. > You are using the Template Method pattern to provide > arguments to an abstract superclass, but you just fill in > string values, not operations with behavior, so you could > have a single class that takes the database, the package and > the driver path as arguments as well. Or, if you want to > factor out the package and driver: At the moment I only implemented SQLite3. But this has the methods: getSQLiteVersion isDBLocked And the fields: GET_SQLITE_VERS SQLITE_BUSY UNEXPECTED_ERROR Also I do not want have to give the driver path. So for the moment I stick with what I have got. I probably should rename getSQLiteVersion to getDBVersion, because probably other drivers will have the same functionality. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof