Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37161
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Is this a correct implementation of an abstract class and implementation class |
| Date | 2017-08-13 07:33 +0200 |
| Organization | Decebal Computing |
| Message-ID | <87378wxca7.fsf@munus.decebal.nl> (permalink) |
| References | <87r2wgxz2p.fsf@munus.decebal.nl> <wrapper-20170812225442@ram.dialup.fu-berlin.de> |
ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Cecil Westerhof <Cecil@decebal.nl> 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
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
Is this a correct implementation of an abstract class and implementation class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-12 23:20 +0200
Re: Is this a correct implementation of an abstract class and implementation class Arne Vajhøj <arne@vajhoej.dk> - 2017-08-12 22:00 -0400
Re: Is this a correct implementation of an abstract class and implementation class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 07:14 +0200
Re: Is this a correct implementation of an abstract class and implementation class Andreas Leitgeb <avl@logic.at> - 2017-08-13 09:37 +0000
Re: Is this a correct implementation of an abstract class and implementation class Andreas Leitgeb <avl@logic.at> - 2017-08-13 10:13 +0000
Re: Is this a correct implementation of an abstract class and implementation class Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:27 -0400
Re: Is this a correct implementation of an abstract class and implementation class lewbloch@gmail.com - 2017-08-13 09:49 -0700
Re: Is this a correct implementation of an abstract class and implementation class Arne Vajhøj <arne@vajhoej.dk> - 2017-08-13 16:25 -0400
Re: Is this a correct implementation of an abstract class and implementation class Cecil Westerhof <Cecil@decebal.nl> - 2017-08-13 07:33 +0200
csiph-web