Results 1 to 3 of 3
  1. #1
    twiggy62's Avatar
    twiggy62 is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default Are my comments correct?

    Below I am going to post some code, I just want a confirmation from someone as to whether my comments in the code are correct,
    so that I know if I am understanding inner class correctly. Items in Magenta are what I want my classes to do.

    Java Code:
     /**
     * MusicCollection class = outer class for: Artist, and Recording classes
     * @author twiggy62
     */
    [COLOR="Blue"]public class[/COLOR] MusicCollection {
    
    [COLOR="Magenta"]// must have an array of Artist objects and an array of Recording objects[/COLOR]
    
        /**
         * Artist class = member inner class of MusicCollection class
         */
        [COLOR="blue"]private class[/COLOR] Artist {
            
        }
    
        /**
         * Recording class = member inner class of MusicCollection class
         * and, outer class for: Track class
         */
        [COLOR="blue"]private class[/COLOR] Recording {
    
            [COLOR="Magenta"]// must have a single Artist object and an array of Track objects[/COLOR]
            
            /**
             * Track class = inner class of Recording class
             */
            [COLOR="blue"]private class[/COLOR] Track {
                [COLOR="Magenta"]// Track objects represent a single piece of music within a Recording object[/COLOR]
            }
        }
    
        /**
         * Test method
         * @param args the command line arguments
         */
        [COLOR="blue"]public static void[/COLOR] main(String[] args) {
            
            [COLOR="Magenta"]// test the creation of all these objects[/COLOR]
            
        }
    }
    The biggest room in the world, is room for improvement.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Just a nit-pick: mostly your (magenta) comments are about what you want the classes to be rather than what they should do. Ie implementation rather than behaviour.

    Anyway... You have declared the classes (and that looks OK), but you haven't actually created the arrays.

    Also, why are these things inner classes? If that's some sort of assignment condition then fair enough. But it seems to me that later you might also want to have ConcertProgramCollection class which would refer to instance of Artist. But you have made Artist a private inner class so there's no way both collections could "speak the same language".

  3. #3
    twiggy62's Avatar
    twiggy62 is offline Member
    Join Date
    Feb 2010
    Posts
    26
    Rep Power
    0

    Default

    Thank you for looking at my code.

    Yeah, the magenta code will be filled in by me later, I was just questioning the
    structure of my classes.

    You were right in saying: "Just a nit-pick: mostly your (magenta) comments
    are about what you want the classes to be rather than what they should
    do. Ie implementation rather than behavior."

    As far as them being inner classes, and being private, is because I do not want
    other classes to be able to access them, the only class I want to have access
    to them would be the MusicCollection class.
    The biggest room in the world, is room for improvement.

Similar Threads

  1. Any comments, can anyone simplify it further?
    By PeterFeng in forum New To Java
    Replies: 3
    Last Post: 01-15-2009, 05:45 PM
  2. Javadoc Comments Demo
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:07 PM
  3. How to write code comments
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:06 PM
  4. Comments
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-19-2007, 08:43 AM
  5. Eclipse - comments
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-07-2007, 02:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •