Forums Register Login

What are the best practice to write a good java program

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Here are my rules to live by:

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

  • +Pie Number of slices to send: Send
    can you explain simple and clear?
    +Pie Number of slices to send: Send
     

    Kishor Joshi wrote:can you explain simple and clear?



    Your program should be readable and understandable at the first glance.
    +Pie Number of slices to send: Send
    ok
    +Pie Number of slices to send: Send
    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.
    +Pie Number of slices to send: Send
    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.
    1
    +Pie Number of slices to send: Send
    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.
    2
    +Pie Number of slices to send: Send
    Water proof donuts! Eat them while reading this tiny ad:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 594 times.
    Similar Threads
    How to run a program with multiple classes in command prompt.
    LCD display program in java
    what to write on resume and what companies expect from a fresher??
    Runtime exceptions
    Best way for learning
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 13:59:48.