• Post Reply Bookmark Topic Watch Topic
  • New Topic

What are the best practice to write a good java program  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am asking a general question.
What are the criteria that one should consider while writing a Java Program that it should be good in perfomance,efficient,maintainable and all.


I want answar from all java programmer based on their experience.


Waiting

Thanks
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are my rules to live by:

  • Is it simple?
  • Is it clear?
  • Is it fast? (CPU efficient)
  • Is it small? (Memory efficient)

  •  
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    can you explain simple and clear?
     
    Joe Harry
    Ranch Hand
    Posts: 10128
    3
    Eclipse IDE Mac PPC Ubuntu
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Kishor Joshi wrote:can you explain simple and clear?


    Your program should be readable and understandable at the first glance.
     
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ok
     
    Knute Snortum
    Sheriff
    Posts: 4279
    127
    Chrome Eclipse IDE Java Postgres Database VI Editor
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Simple means if there's a complex way to do it and a simpler way to do it, all else being equal, pick the simple way. Use a complex way only if it has big advantages and then comment well.

    Clear means that a programmer of average experience should immediately know what you're doing. Break this rule only if you get big performance or space improvements, and then comment well.
     
    J. Kevin Robbins
    Bartender
    Posts: 1801
    28
    Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I suggest you start by reading the style guide. To me, simple and clear means each method should do just one thing and do it well. All variable names and method names should clearly state what what the method is doing or what the variable represents. Don't use a method name like getData() when you can use getUserMailingAddress(). Ditto for variable names.

    Don't worry about performance until very late in the development cycle. Premature optimization is the root of all evil.
     
    Campbell Ritchie
    Marshal
    Posts: 56546
    172
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You need to write code which fulfils these requirements
  • 1: Correct code
  • 2: Legible code (to people)
  • 3: Simple code
  • 4: Maintainable code
  • 5: Stylish code
  • 6: Very definitely your last priority: fast code
  • Nos 2 3 4 and 5 are related; if you get one of them it is likely you will get the other three too.

    As you have been told we have some style suggestions here on the Ranch. They are suggestions and many people use different styles of programming.

    It takes a long time to learn programming anything worthwhile. Programming requires a certain mindset and some people never seem to understand it.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 66306
    152
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Likes 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!