http://wiki.eclipse.org/Introduction_to_Data_Access_(ELUG)#Database_Platforms.
I don’t understand the point of ensuring that unqualified names are
distinct. Isn’t that defeating the purpose of using qualification in the
first place?
Good question. I should point out that these database-specific classes
rarely get imported explicitly in Java code by an end user; rather, they
are specified through a JPA persistence.xml file. In this model it would
be essential for the names to be different.
I'm absolutely not going to say that your proposed use of packages is
wrong. We know that Java packages are used to provide a namespace
mechanism - that's the primary purpose - and as an obvious corollary
programmers then often use packages to group their classes by
functionality. But I don't believe that it follows from this primary
purpose of packages - unique namespaces - that your proposed use is a
_recommendation_. I don't think it's an _incorrect_ use, and if it makes
your APIs and implementations easier to design, implement and use, so
much the better.
In this particular problem domain I think you could make a decent
opposing argument that rather than have
org.ahs.database.platforms.oracle.Platform
org.ahs.database.platforms.mysql.Platform
it still makes more sense to have
org.ahs.database.platforms.OraclePlatform
org.ahs.database.platforms.MySqlPlatform
because the _classes_ are _not_ the same. One is customized for Oracle,
one for MySQL. Assuming that both inherit from a
org.ahs.database.platforms.Platform class, say, it's not like I'll have
explicit references to MySqlPlatform all over the place; in most cases
I'll be referring to Platform anyway.
Like I say, I don't doubt that there are situations where your proposed
package structure makes more sense. A lot of different factors would
come into it. Main thing is, I don't believe that the purpose of Java
packages dictates or recommends either approach.
AHS