views:

63

answers:

4

I plan to extend a JSF renderer. The package name is oracle.adfinternal.view.faces.renderkit.rich

Should the extended class be in the same package structure: oracle.adfinternal.view.faces.renderkit.rich or even oracle.adfinternal.view.faces.renderkit.rich.[subpackage]

or can/should I put it into my own package? com.company.renderkits.

I suppose package-private variables might be interfered with if I put this into my own package name?

Any thoughts?

+3  A: 

You should put the class into your own package. There shouldn't be any compilation/access problems. The superclass already sees what it needs to see.

mipadi
+1  A: 

I suppose package-private variables might be interfered with if I put this into my own package name?

This is true, but normally the extending class shouldn't worry about this. The to-be-extended class would have used the protected modifier for this otherwise.

BalusC
+2  A: 

In general, you should put your extended classes in your own package.

The package-private access level should be used by closely connected classes, possibly written by the same developer, who knows all the implementation details. This is not the case if you extend a class with some functionality.

All that said, there are a few occasions where you need to place your class in the package of the superclass as a workaround, but remember, this is an ugly hack, and try hard to avoid it.

candiru
A: 

You should not add things to other entities (companies, person) packages. They could make a class with the same name (and same package of course) at a later date. They could also choose to seal their JAR files as well which would prevent you from adding classes to their packages.

The purpose of packages is to give each entity their own unique namepsace in which to create types.

In your case I would name the package something like: com.foobar.oracle.adfinternal.view.faces.renderkit.rich where "com.foobar" is the reverse domain name of your entity (if you don't have one pick something that is unique).

TofuBeer