midnight
midnight

Reputation: 3412

Packages and naming conventions

I have a class structure for handset and tablet elements: ProfileFragment(handset) and ProfileFragment(tablet) are derived from ProfileFragment(abstract). Packages go like:

I'm not sure if I'm doing right with those potentially misleading duplicate class names. What would you recommend ?

Upvotes: 1

Views: 122

Answers (1)

Lukas Knuth
Lukas Knuth

Reputation: 25755

You should always avoid naming multiple classes (which differ in their implementation) the same. Even though you can (using different packages).

You could go with putting the your device-type in the class name. E.g.

  • AbstractProfileFragment
  • TabletProfileFragment
  • HandsetProfileFragment

Those classes can (and should) still be split up into multiple packages.

Upvotes: 1

Related Questions