9 Tips and Tricks We Learned From The Java Community

tarihinde gönderildi - Son değiştirilme

Every day in the design industry is a learning curve. Beginning a new project is not only challenging, it requires individuals to conduct substantial research to identify long term solutions. This is applicable to well-established code bases, basic websites, and new coding tasks.

More often than not, relevant questions, approaches and strategies come from new sources. Going through blogs is likely to provide service providers with insight, perspective, and value.

Discussions about Java Code Styles are never ending

The comparison between iOS and Android, Nintendo and Sega, or tabs and spaces are likely to result in endless discussions.  First, let us understand some of the most intriguing highlights that Java code has in common:

Indentation: spaces vs tabs

Many people prefer using spaces as compared to tabs on the style guidelines. Take a look at the following findings.

  • Twitter has between 2 and 4 spaces (for line wraps)

  • Android has 4 spaces with 8 for line wraps

  • Mozilla has 4 spaces

  • Google has 2 spaces

  • Java has 4 spaces. Tabs here should be set at 8 spaces, but both can be used.

The developers who utilize tabs are not fond of writing style guides. According to data collected from GitHub, between 10-33% of Java repositories favor tabs. In addition, many of them utilize spaces in various formations, favoring 4 spaces as compared to 2. This module comes in handy for comparing various languages. Looking at other JVM languages such as Clojure and Scala, one is likely to notice a consistent use of 2 spaces. 

Line length, breaks, and wrapping

Java code lines can sometimes become long. The style guide is categorical when it comes to defining when it is necessary to wrap or break. The common norm is approximately 80-100 maximum length. Take a look below

  • Twitter: Preference towards 100 columns

  • Google: 100 columns

  • Java: 80 columns

  • Mozilla: Appropriate judgment

Aside from inherent breaks after semicolons, line breaks are used for logic separation and when lines become too long. Breaking before operators, commas, and when it is logical is the common practice among developers. This separates statements and enables them to make sense of where every line of code is representative of a contained atomic operation. This is something on which style guidelines are in agreement. Blank lines play the role of separating logical blocks. The Java style guidelines have a citation to dual line breaks, implementation, and separating interface.

Variable Names

Variable names in the C++ language are known as identifiers. The ideal naming custom is to pick a variable name that is able to let the reader know what it constitutes. Basically, variable names create a vast agreement with all style guidelines. For instance camel Case for method and variable names, FirstLetterUpperCase for class names, all lower case for package names and ALL_CAPS for concluding static constants.

ℜ∙•Catch Clause Exceptions

A recent study carried out on Source forge and GitHub analysed over 600,000 projects. The results of this research indicate many users are utilizing non-standard exceptions. The style guidelines on Twitter and Google cite the empty catch blocks:

  • On Google there are no empty catch blocks

  • Twitter does not allow exceptions

  • Mozilla does not have a reference

  • There is no reference in Java

Ensuring that exceptions can be tried, as well as preventing control flow exceptions, is recommended.

Parentheses and curly braces

Parentheses play an important role in enhancing readability. It is common practice to utilize parentheses for clarity using compound predicates. The following is an indication of style guideline's citation for parenthesis:

  • Twitter: “Be explicit” (even when it’s obvious)

  • Google: “Recommended”

  • Mozilla: Following the Java standard

  • Java: “Generally a good idea”

When using curly braces, Style guidelines recommend breaking after the brace has been opened. The above java code styles form the chronicle of major debates on social networks. Among those raging debates are massive lessons to learn. Below are crucial tips we picked from the Java community.

1. Some of the most crucial elements are learned from experience

The development industry is experiencing a massive makeover. With thousands of features, tools, and workflows, professionals working in this industry face many challenges. Developers rarely prepare themselves for these, but dealing with these features regularly  gives them enough experience to handle them accordingly.

This is especially true when doing freelancing work. Freelancer.com is a good site that offers great experience for coders who get all kinds of projects to handle.

2. It is a learning curve

The operations of Java are wide. Learning about one concept cannot be done in one day, because it keeps evolving. It is therefore important for developers to keep themselves abreast of new Java terminologies and systems.

3. Familiarize yourself with Java codes

Many comments from the community seem to be in agreement that understanding Java codes is paramount. Through familiarizing themselves with these codes, they can articulate commands and understand the system better. The codes include Review Your Code, ANT, learn shell/batch, and use profilers.

4. Inclusion of more features

There seemed to be mixed reactions on scrapping old features when a new series is released. While some individuals appreciate the new features, some are sad that features such as native support for JSON could not be found in the new series. However, many of these individuals adapted with time.

5. Most features people crave are small and insignificant

One of the biggest features has to be the Jigsaw. Hopefully, the developers will make it convenient so it will be able to benefit Scala. Native REPL has also been said to be quite good.

6. The high-performance of Project Valhalla

The community appreciated Project Valhalla's high-performance. Hopefully it will be included in JDK 10.

7. There is an ideal tool for every situation

Regardless of whether they are old, new, or even startup oriented, if it can benefit developers it is useful. There are numerous tools that can control how individuals develop software from the handling of errors, logging, and monitoring. The list keeps growing with the advancement of features. This explains why it is important to focus on a small number of tools for each post, as well as from one product to another.

To be able to get the most from diverse tools, one can hire the services of an experienced freelancer to help out in projects.

8.     Open source APM enhances the performance of applications

Individuals who are looking to improve the performance of their applications can use open source APM tools. Some important APM tools include Pinpoint, Stagemonitor, and Kamon.

9.     Different people find some features important while others don't

Every device user has different preferences. While some users may find tools and features useful, others cannot decipher how to operate them. However, it is important to get a basic understanding of fundamental Java features. This helps users get the best out of their applications.

Conclusion

The Java community has been quite helpful in enhancing the growth and improvement of Java. Every user has different tips we can learn from, and use the same to tailor the system into something that meets the needs of customers. As Java aims at providing users with the best experience, it is on the developers to monitor the reactions of consumers. Taking heed of the questions the community comes up with is paramount to helping the developers expand their territory. Engaging the community allows developers to identify the areas in which they need to improve. Every user has their own expectations. While developers may not be in a position to satisfy them all, they can incorporate their ideas to ensure they are comfortable when using applications.

Any tips & tricks we may have missed? Let us know in the comments below.

İlan Edilmiş 11 Ağustos, 2017

LucyKarinsky

Software Developer

Lucy is the Development & Programming Correspondent for Freelancer.com. She is currently based in Sydney.

Sonraki Makale

Top 16 C# Programming Tips & Tricks