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

Posted on 2011-10-07
Last Modified: 2012-05-12
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?
Question by:Eindoofus
    LVL 47

    Assisted Solution


     >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.
    LVL 47

    Assisted Solution

    Maybe you can have abstract class PassengerShip and its implementatin non-abstract class PassengerShipImpl - that makes sense
    LVL 47

    Accepted Solution

    Call your interface

    And why do you need to have them in separate packages ?

    Author Comment

    I thought that it might be good practice to do so since I saw that my instructors code was doing that.
    LVL 47

    Assisted Solution

    Read this discussion - I think it is related to your thoughts:

    But I don't think there is one and only one way - all depends on many circumstances of how it will all be used
    LVL 13

    Assisted Solution

    by:Hugh McCurdy
    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Title # Comments Views Activity
    Specific format 21 105
    array11 challenge 16 40
    countAbc challenge 9 35
    wordappend challenge 8 45
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now