• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rate my code so that i can correct myself

 
ssiva raman
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

is this code good? i just tried to pass an object as an argument.


 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some remarks:
  • which naming conventions do apply for classes, methods and variables?
  • what's the purpose of creating a dog object in cat? And why is this statement squeezed in between a constructor and a method?
  • Both cat and dog classes have a data member name, so ...
  •  
    ssiva raman
    Ranch Hand
    Posts: 43
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Roel De Nijs wrote:Some remarks:
  • which naming conventions do apply for classes, methods and variables?
  • what's the purpose of creating a dog object in cat? And why is this statement squeezed in between a constructor and a method?
  • Both cat and dog classes have a data member name, so ...



  • 1/ i thought i used a valid names for all these?did you find anything wrong?can you be more specific?
    2/ to let cat object to access dog object's name field.
    3/ you mean inheritance?
     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ssiva raman wrote:1/ i thought i used a valid names for all these?did you find anything wrong?can you be more specific?
    2/ to let cat object to access dog object's name field.
    3/ you mean inheritance?


    1/ Yes, otherwise I would not have mentioned it. An extra tip: classes (methods and variables are ok).
    2/ A cat HAS-A name, I never knew of a cat having a dog, so dog should not be a data member. If a cat can provoke a dog, you provide a dog parameter to the provokeDog-method (as you already did in your code snippet).
    3/ Exactly!
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic