JavaRush /Java Blog /Random EN /Coffee break #42. What to do if you don't know something....

Coffee break #42. What to do if you don't know something. 5 Best Java Libraries for Maximum Productivity

Published in the Random EN group

What to do if you don't know something

Source: Dev.to If you are a developer, sooner or later a situation has probably arisen when you do not know how to solve a problem. This is quite an unpleasant moment at any stage of your career. After all, you still have to complete the task, despite the fact that you don’t know something. In this article I will share my personal experience and tell you what will help in finding a solution to such a problem.Coffee break #42.  What to do if you don't know something.  5 Best Java Libraries for Maximum Performance - 1

Ask questions

When I was a beginner, I was afraid to ask questions, until the last minute I tried to solve everything on my own. I would spend enormous amounts of time solving a problem and remain silent until I eventually had to talk to my boss or clients. I understood why I did what I did. I avoided asking questions because I didn't want to look stupid in front of others. It seemed to me that everyone else, except me, quickly grasped the essence and understood what it was about. It was only thanks to my colleagues that I finally began to put my pride aside and ask about what I didn’t understand.

Google and YouTube are your best friends

I once watched a video of how Google answered absurd or funny questions. Even though the answers were also very funny, I realized that Google can definitely help if any questions arise. Therefore, if you are at a dead end, do not forget to look for the answer through this search engine. YouTube also helps me a lot in solving problems. Especially in cases where a deeper understanding of the subject is needed. Then I'm always looking for topical videos.

An extra pair of eyes wouldn't hurt

Don't let anger and frustration consume you if you can't solve a problem. A clear example of this situation would be cases where you need to maintain an outdated code base, where due to the lack of documentation you have to do reverse engineering. Of course, this takes a lot of effort. You will have to delve into the code base, understand the style of previous developers. In such cases, it is highly advisable to have someone other than yourself review the code. The other person may point out things you missed or didn't understand. This way you can speed up the solution to the problem.

Don't beat yourself up if you get stuck on something.

I want to draw special attention to this. Don't be angry with yourself if you get stuck somewhere. Yes, when you can’t solve a problem, it’s not very pleasant. Imposter syndrome may worsen, you may feel useless and lose confidence that you are a good developer. I am sure that if a person has never gotten stuck on something in his work, it is only because he acts in his comfort zone, without going beyond his usual actions. To be prepared for unexpected situations, communicate with people who can push you to raise your professional standards. Don't be upset if you encounter something you weren't prepared for. Such cases help to identify gaps in knowledge and, accordingly, fill them.

Take breaks

It may not seem very productive, but when you're working on something big and complex, taking short breaks is a huge help in relieving stress. Walk for 15 minutes, talk to someone, exercise, or even take a nap. Rest helps refresh the mind, and besides, all this time the brain is still working, and somewhere on a subconscious level it solves the task at hand. As a result, you may have a eureka moment while simply drinking your coffee.

Conclusion

The first thing to do when solving a problem is to make a list of what you know and what you don’t know. After this, you should ask clarifying questions to the person who assigned you this task. Perhaps at this stage something will become clearer, and you will be able to remove some of the questions from the “I don’t know” category. You should search for answers to other questions yourself on Google or YouTube. Give yourself some time to search. If you were unable to solve the problem on your own, do not hesitate to ask your colleagues for help.

5 Best Java Libraries for Maximum Productivity

Source: Medium You've probably ever written code in Java and thought, “There must be a better way...”. Java libraries can help solve such problems. I bring to your attention five of the best, in my opinion, libraries, the use of which will increase your productivity and work efficiency.Coffee break #42.  What to do if you don't know something.  5 Best Java Libraries for Maximum Performance - 2

1. Lombok

Project Lombok is a Java library that uses annotations to reduce boilerplate code. You can use annotations like @Getter to automatically generate getField() methods . Here are some supported annotations:
  • @Getter and @Setter, which generate getters and setters;
  • @EqualsAndHashCode automatically generates Equals and HashCode methods that conform to the Equals and HashCode contracts ;
  • @ToString generates a toString() method that follows the format ClassName(fieldName = value, fieldName2 = value...) ;
  • @Builder automatically implements the builder pattern to make creating your POJO easier;
  • @Data is shorthand for @Getter, @Setter, @EqualsAndHashCode, @ToString and @RequiredArgsConstructor!
There are many more supported and easily customizable annotations. Working with them will save you from writing boilerplate code.

2. Guava

Guava is a Java library created and maintained by Google. It contains many utilities that are widely used in working with code. Here are just a few of Guava's features:
  • Collections extensions, such as Multimap<k, v="">, where Map supports multiple values ​​for a given key, which is equivalent to Map <k, collection="" <v="">> with a cleaner API;</k, ></k,>
  • the Graphs package, which includes a number of utilities for modeling graphical data;
  • concurrency utilities such as MoreExecutors, Atomics and ListenableFuture.
There is a lot to be found in the Guava library. Google's support makes it quite popular, so you can rest assured that their APIs are thoroughly tested and supported. If you need to solve any common Java problem, you'll surely find a solution with Guava!

3. Hibernate

Hibernate is an object-relational mapping library that allows you to interact with a database without having to worry about translating between SQL tables and POJOs. The Hibernate website provides the following information about the library: “With Hibernate, you can create long-lived classes according to natural object-oriented principles, including inheritance, polymorphism, association, composition, and Java Collections. Hibernate does not require interfaces or base classes for long-lived classes and allows any class or data structure to be persistent.” Use Hibernate to improve persistent data storage and eliminate thousands of lines of database code.

4. Feign

OpenFeign is a library from Netflix that makes it easy to create RESTful HTTP clients in Java. To create a Feign client, you simply describe the interface with request and response details. This is best illustrated with an example:
@FeignClient(url = "https://github.com")
interface GitHubClient {
    @RequestLine("GET /users/{username}/repos?sort=full_name")
    List<repository> repos(@Param("username") String owner);

    @RequestLine("GET /repos/{owner}/{repo}/contributors")
    List<contributor> contributors(@Param("owner") String owner, @Param("repo") String repo);

    @RequestLine("POST /repos/{owner}/{repo}/issues")
    void createIssue(Issue issue, @Param("owner") String owner, @Param("repo") String repo);
}
</contributor></repository>
The GitHubClient interface mentioned above will perform the GET and POST requests described in the methods. This client will default to using JSON format for all requests. There are many settings for the Feign client:
  • encoders and decoders to select how POJOs are serialized and deserialized over the network;
  • Retryers to specify retry rules and logic;
  • RequestInterceptors for other pre-request tasks such as receiving cookies or authorization.
Using Feign, you can eliminate the need to manually write HTTP clients! Note: If you are using Spring, you should use Spring Cloud OpenFeign , whose integration with Spring is better than OpenFeign on its own.

5. Spring Boot

Last but not least, the library is Spring Boot . Spring Boot simplifies the process of creating production-ready Java applications. It allows:
  • create standalone Spring applications;
  • directly embed Tomcat, Jetty or Undertow (without the need to deploy WAR files);
  • provide “starter” dependencies to simplify the build configuration;
  • automatically configure Spring and third-party libraries;
  • Provides out-of-the-box features such as metrics, health checks, and external configuration.
There is a significant learning curve to using Spring Boot, but I assure you it is worth it. Spring Boot has reduced the development time of all my projects and continues to provide benefits due to its stability, extensibility, and readability.

Conclusion

Despite the fact that Java is considered by many to be an “old” language that lacks some of the features of newer languages, it has unique support in the form of a large number of libraries and a huge community of developers. Therefore, you will experience significantly fewer problems in your work. Using Java libraries, you can increase your productivity. Don't reinvent the wheel - focus on core competency!
Comments
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION