File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes What means Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What means "best practice"?" Watch "What means "best practice"?" New topic
Author

What means "best practice"?

George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Hello everyone,


I have always seen some methods are described as "best practice". I am wondering what means "best practice", an algorithm?


Thanks in advance,
George
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Best practice is simply a term for a standard way of doing things that many people find to be optimal for various reasons (good performance, good design, high maintainability, good readability, etc). There is no one best practice for any given design decision as varying situations and goals affect which is "best."

An example of a best practice is coding to interfaces (as parameters and local variables) rather than implementations. If your method requires an indexed Collection, declare that it takes a List rather than a LinkedList. Unless you have a specific reason for requiring a LinkedList instead of an ArrayList or MyCoolList, sticking to the List interface makes your code more flexible while still maintaining correctness.
George Lin
Ranch Hand

Joined: Jan 11, 2005
Posts: 125
Thanks David,


Originally posted by David Harkness:
Best practice is simply a term for a standard way of doing things that many people find to be optimal for various reasons (good performance, good design, high maintainability, good readability, etc). There is no one best practice for any given design decision as varying situations and goals affect which is "best."

An example of a best practice is coding to interfaces (as parameters and local variables) rather than implementations. If your method requires an indexed Collection, declare that it takes a List rather than a LinkedList. Unless you have a specific reason for requiring a LinkedList instead of an ArrayList or MyCoolList, sticking to the List interface makes your code more flexible while still maintaining correctness.


So, it is a general concept (means a good method) and not specific to any topic or any technologies. Am I correct?


regards,
George
[ February 22, 2005: Message edited by: George Lin ]
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by George Lin:
So, it is a general concept (means a good method) and not specific to any topic or any technologies.
Yup, that's correct.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What means "best practice"?