• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

which one is recommended ?

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
which one is good practice & recommended for projects :


Thanks .
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has got nothing to do with the performance. I would prefer the 2nd option to avoid simple mistakes. Both are okay to use.
[ April 08, 2005: Message edited by: Pradeep Bhat ]
 
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is more a matter of style, and errors usually occur when mixing styles. Therefore, no matter what you choose, whether
  • A(int a) { this.a = a; }
  • A(int arg) { this.a = arg; }
  • A(int arg) { a = arg; }
  • A(int _a) { this.a = _a; }
  • A(int _a) { a = _a; }

  • or something else, be consistent, and if you're editing someone else's code, follow their style or change all constructors to match the project's style if that's appropriate.
     
    author
    Posts: 14112
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Moving to Java in General (beginners)...
     
    Ilja Preuss
    author
    Posts: 14112
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Pradeep Bhat:
    I would prefer the 2nd option to avoid simple mistakes.[/QB]



    I prefer the 1st, partly because I use an IDE with color highlights fields differently from local variables and warns me about the most common mistake (assigning the field to itself).

    I agree with David, though: Most important is that you do it consistently (throughout the whole team, if you are not working alone).
     
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Which IDE do you use?
     
    Greenhorn
    Posts: 24
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I preffer the first one ,because I don't need to think the new parameter's name!
     
    ankur rathi
    Ranch Hand
    Posts: 3852
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for inputs ,
    Can any body tell me , which is the forum , where I can post best practice ( what is recommended & what is not ) type of questions ...

    Thanks .
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8944
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by magic zha:
    I preffer the first one ,because I don't need to think the new parameter's name!



     
    Pradeep bhatt
    Ranch Hand
    Posts: 8944
    Firefox Browser Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Ilja Preuss:


    I prefer the 1st, partly because I use an IDE with color highlights fields differently from local variables and warns me about the most common mistake (assigning the field to itself).

    I agree with David, though: Most important is that you do it consistently (throughout the whole team, if you are not working alone).



    I agree but I rarely use an IDE I prefer Textpad.
     
    Ilja Preuss
    author
    Posts: 14112
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Richard Munde:
    Which IDE do you use?



    Eclipse.
     
    Ilja Preuss
    author
    Posts: 14112
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Pradeep Bhat:


    I agree but I rarely use an IDE I prefer Textpad.



    When I started, I used Textpad, too. But once I got the hang of how the basics work, switching to an IDE made me way more productive.
     
    Your mother was a hamster and your father was a tiny ad:
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic