Best Practices To Cite Your Jounce File Inwards Java
If y'all are an writer of an internal, proprietary Java library or an external opened upward rootage library, or y'all are ane of those lucky developers who shipping Java application past times yourself together with thus y'all should follow these best practices acre naming your JAR files. These best practices are a effect of the practical sense of using hundreds of Java library together with application. Following these best practices volition assist in meliorate administration of JAR files. It's utilization of my other best practices articles e.g. best practices acre naming variable, writing comments, overriding methods, muli-threading, JDBC, together with best practices acre dealing amongst passwords. If y'all are interested inwards learning to a greater extent than best practices, y'all tin flame ever search those articles on this blog.
You tin flame likewise possess got a hold back at Effective Java, woman raise of all best practices inwards Java Blue Planet together with ane of the must read books for whatsoever Java developer. Joshua Bloch, writer of this mass has likewise authored several key classes inwards JDK e.g. Java Collection Framework together with other of import classes inwards java.lang together with java.util packages.
Now let's run across to a greater extent than or less best practices acre naming your JAR file:
1) Give them specific name, prefer concrete over abstract
For example, util.jar is the worst jounce file mention I tin flame mean value of. All I know is it contains to a greater extent than or less utility/helper classes. But it is unclear if they belong to an application server, or a framework, or whatsoever application sub-systems. You volition involve to inquire mortal or refer docs to know what it is. It's utilization of the DataDirect JDBC Driver distribution. On the other hand, expert jounce file names are ever self-explanatory, for example, struts.jar or spring-mvc.jar
2) Use hyphen (-) instead of underscore (_) every bit give-and-take separator
There are 2 reasons I propose to prefer hyphen(-) over underscore(_). First, it's easier to type hyphen than underscore; secondly, when the file mention is underlined (e.g., inwards a hyperlink), the _ is invisible. Hyphen has been shunned inwards file names partly because it is an illegal graphic symbol inwards coffee identifier. But this work organisation is unwarranted. One of the examples of this best practise is spring-mvc.jar which uses a hyphen to bring together 2 words.
3) Append version pose out if distributed standalone
If your JAR file is distributed standalone together with thus y'all must append version pose out on the mention of JAR file because they tin flame survive dropped into whatsoever applications, which may involve specific versions. We don't desire users to possess got to compare file size or extract to a greater extent than or less META-INF files to know its version. Some examples of this best practise are hibernate3.jar, commons-logging-1.0.3.jar, together with log4j-1.2.8.jar.
4) Always utilization extension ".jar", non ".zip"
Theoretically, jounce files tin flame possess got whatsoever extension or no extension at all. If y'all specify it inwards the organisation classpath, it should survive loadable. The work is amongst automatic library detection together with loading past times containers together with frameworks. It's expensive to scan all files thus to a greater extent than or less form of extension restriction is needed. For this reason, J2EE/JavaEE platform spec requires all library jounce files utilization ".jar" extension, such every bit WEB-INF/lib/mybeans.jar.
Here is summary of to a higher house four best practices Java developer should follow acre naming their JAR files:
That's all on best practices to mention your JAR file inwards Java. Let me know what are your thoughts close these practices, produce y'all already follow them? Do they brand sense? If y'all are next whatsoever other best practices together with thus permit us know every bit well.
Further Reading
Further Learning
Complete Java Masterclass
Java Fundamentals: The Java Language
Java In-Depth: Become a Complete Java Engineer!
You tin flame likewise possess got a hold back at Effective Java, woman raise of all best practices inwards Java Blue Planet together with ane of the must read books for whatsoever Java developer. Joshua Bloch, writer of this mass has likewise authored several key classes inwards JDK e.g. Java Collection Framework together with other of import classes inwards java.lang together with java.util packages.
Now let's run across to a greater extent than or less best practices acre naming your JAR file:
1) Give them specific name, prefer concrete over abstract
For example, util.jar is the worst jounce file mention I tin flame mean value of. All I know is it contains to a greater extent than or less utility/helper classes. But it is unclear if they belong to an application server, or a framework, or whatsoever application sub-systems. You volition involve to inquire mortal or refer docs to know what it is. It's utilization of the DataDirect JDBC Driver distribution. On the other hand, expert jounce file names are ever self-explanatory, for example, struts.jar or spring-mvc.jar
2) Use hyphen (-) instead of underscore (_) every bit give-and-take separator
There are 2 reasons I propose to prefer hyphen(-) over underscore(_). First, it's easier to type hyphen than underscore; secondly, when the file mention is underlined (e.g., inwards a hyperlink), the _ is invisible. Hyphen has been shunned inwards file names partly because it is an illegal graphic symbol inwards coffee identifier. But this work organisation is unwarranted. One of the examples of this best practise is spring-mvc.jar which uses a hyphen to bring together 2 words.
3) Append version pose out if distributed standalone
If your JAR file is distributed standalone together with thus y'all must append version pose out on the mention of JAR file because they tin flame survive dropped into whatsoever applications, which may involve specific versions. We don't desire users to possess got to compare file size or extract to a greater extent than or less META-INF files to know its version. Some examples of this best practise are hibernate3.jar, commons-logging-1.0.3.jar, together with log4j-1.2.8.jar.
4) Always utilization extension ".jar", non ".zip"
Theoretically, jounce files tin flame possess got whatsoever extension or no extension at all. If y'all specify it inwards the organisation classpath, it should survive loadable. The work is amongst automatic library detection together with loading past times containers together with frameworks. It's expensive to scan all files thus to a greater extent than or less form of extension restriction is needed. For this reason, J2EE/JavaEE platform spec requires all library jounce files utilization ".jar" extension, such every bit WEB-INF/lib/mybeans.jar.
Here is summary of to a higher house four best practices Java developer should follow acre naming their JAR files:
That's all on best practices to mention your JAR file inwards Java. Let me know what are your thoughts close these practices, produce y'all already follow them? Do they brand sense? If y'all are next whatsoever other best practices together with thus permit us know every bit well.
Further Reading
- Best Practices to mention your variable, class, together with methods (see here)
- Best Practices to follow acre overriding methods inwards Java (see here)
- Top 10 Multithreading together with Concurrency Best Practices inwards Java (see here)
- Top 10 JDBC Best Practices for Java Programmer (see here)
- Best Practices acre dealing amongst passwords inwards Java (see here)
- 10 Best Practices to follow acre writing code comments (see here)
- 10 Exception treatment Best Practices inwards Java (see here)
- Best Practices acre writing JUnit tests inwards Java (see here)
- Best Practices to avoid NullPointerException inwards Java (see here)
- Effective Java - Mother of All Best Practices inwards Java (see here)
Further Learning
Complete Java Masterclass
Java Fundamentals: The Java Language
Java In-Depth: Become a Complete Java Engineer!
0 Response to "Best Practices To Cite Your Jounce File Inwards Java"
Post a Comment