Hackathon Java Tools for Developers
Hackathons can be one of the most effective methods of motivating developers to create their own solutions. In this article, I will explain which Java tools can simplify your development and increase your chances of winning.
What’s A Hackathon?
The goal of a hackathon is to create an application that solves one of the problems in a specific industry in less than 24/48 hours. The hackathon topic is frequently announced by competition organizers. As a result, in the majority of cases, the procedure includes the following steps:
To Be Prepared Is Half the Victory
- Come to the event and assemble your team (or bring yours).
- Decide with the team what application to write.
- Deliver that application within the given time. Often it’s limited by 24/48h.
- Win or Lose.
Frequently, the hackathon champions are far better prepared than the rest of the participants. Some dishonest participants even prepare applications in advance of their arrival. However, in this essay, we will look at “legal” preparations.
Most Classical Enterprise Java App Structure
Making a skeleton of a traditional Java Enterprise app is the easiest method to save a lot of time throughout the competition. Frequently, a significant amount of time is lost on configuration, etc. So, here’s how to build a Java EE application with the most popular structure:
UI or User Interface
For the vast majority of projects, it’s a mandatory part. UI shouldn’t be fascinating but functional. Obviously, for quick prototyping, you need a framework or library with ready-to-go components. Personally, I would recommend React and quite a popular React library: material UI. Material UI library has the most popular components
UI from Java as a good option. Vaadin, ZK, and GWT are the most popular.
HTTP API or Way to Communicate With UI
HTTP communication isn’t the sole option; in some cases, we’ll need to employ websockets to keep things moving. Here we can look at several useful tools for quickly creating HTTP APIs. There are a variety of tools and solutions available, but Spring Boot Web is one that I recommend. It has a number of important capabilities, including the ability to easily transform and parse HTTP requests.
It’s a rather nebulous description, to be sure. In practice, however, the business layer is a layer that integrates all other layers, such as services and database repositories. In this case, Dependency Injection and Inversion of Control patterns are the most important tools. You can use various DI/IOC providers, such as Google Juice, or even develop your own, but Spring Framework is still my recommendation.
In the previous paragraph, we mentioned DI and IOC patterns allow us to inject/replace logic easily. But where to get services themselves? Well, these are a set of options:
Clouds offer a wide range of APIs, from voice recognition to machine learning. I can’t pick a favorite because there aren’t any, although I’m guessing the most popular are AWS, Google Cloud, and Azure. They’re powerful and paid, so pay attention whenever you use them. Keep logic inside your app that limits API calls to avoid losing all of your money.
Useful Tools and Libraries
During implementation in order to do not recreate the wheel, you can use different popular libraries like Apache Commons or Guava Collections. You can check this official list from Maven or just check the top 10 articles about that subject. It worth checking this GitHub repo.
JDBC wrappers, such as apache JDBC template or Spring template, are the most straightforward but still verbose method for connecting to your SQL database. However, because of time limitations, they are ineffective for Hackathons. Spring Data is the most efficient approach to construct your DAO rapidly. Spring Data offers a variety of adapters/solutions for a variety of Data Sources, ranging from SQL/NoSQL to more exotic.
In this example, we use Spring Data JPA that provides CRUD and query operations for classes — entities from the box! All that you need to do:
1. Generate class — Entity that matches your table.
2. Extend Spring Data interfaces and use them!
Spring REST Data
Spring Rest Data solution generates not only CRUD operation for Repository but also exposes it to UI by providing CRUD HTTP endpoints. For example:
Provide HTTP API to read Users by ID. Once it’s implemented next endpoints will be available:
Last But Not Least: A Tip About Database Preparation
The SqlYog application, which allows you to develop schema, can help you simplify the database design process. After that, you can construct entity classes with IntelliJ IDEA. It might potentially save you billions of years. I strongly advise you to use these resources!
Java Tools: JMS or Schedulers or Asynchronous Solutions
You might wonder why this section is distinct from business logic or services. In general, synchronous and asynchronous problems are implemented differently. In most cases, Java Messaging is represented by the Topic and Queue Pattern and can be solved using RabbitMQ, Active MQ, Kafka, and other similar technologies. The main issue with all of them is that running a message broker requires additional configuration, which is time-consuming. So they can still be used if no other solutions are available.
Fortunately, most of the async problems can be solved by simple scheduling/triggering patterns. And here Spring provides a nice Quartz solution.
Easy and Quick Deployment: Docker
Docker is a solution not only for quick application deployment but also a magic chest with tons ready to go frameworks. So having it you can easily run preconfigured solutions of any kind.