[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

What is the best practice for naming my classes and packages in the given situation?

I have a project for my object-oriented software development class where I am required to create a PassengerShip for a space fight simulator.

I was planning on having the PassengerShip use the PassengerShip interface along with the PassengerShipImpl and PassengerShipFactory, in case in the future I need to make more than one type of PassengerShip.

I was going to put the PassengerShip in the package "domain", and the PassengerShip interface and PassengerShipImpl in the "passengership" package", and lastly have the "PassengerShipFactory" in the package named "common".

 Is this the best way of naming the packages? I got the idea for the common, passengership, and domain based on some same code my instructor posted pertaining to something else, but it was something he quickly whipped together for a different topic.

And now for my PassengerShip, I want to have the ability to vary the implementation of the PassengerShip later so I decided to create an impl and factory class but the problem is I don't know what to name my interface. Right now they have the same name which doesn't work and based on the project guidelines I have to call the domain class PassengerShip, so what do I call the interface?
0
Eindoofus
Asked:
Eindoofus
  • 4
5 Solutions
 
for_yanCommented:

 >PassengerShip use the PassengerShip interface

Do yyou mean you have a class and interface of the same name?

Don't think it is the best idea.
0
 
for_yanCommented:
Maybe you can have abstract class PassengerShip and its implementatin non-abstract class PassengerShipImpl - that makes sense
0
 
for_yanCommented:
Call your interface
PassengerShipInterface

And why do you need to have them in separate packages ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
EindoofusAuthor Commented:
I thought that it might be good practice to do so since I saw that my instructors code was doing that.
0
 
for_yanCommented:
Read this discussion - I think it is related to your thoughts:

http://c2.com/cgi/wiki?UseFactoriesToBuildObjects

But I don't think there is one and only one way - all depends on many circumstances of how it will all be used
0
 
Hugh McCurdyCommented:
I agree that you should mimic your professor's style.  I agree with for_yan that giving the interface and the class the same name is just asking for trouble.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now