Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

rate my code so that i can correct myself

 
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.


 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • 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: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • 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!
     
    Don't get me started about those stupid light bulbs.
      Bookmark Topic Watch Topic
    • New Topic