Hackathon Java Tools for Developers
Useful tools and practices for Java Hackathons.
Join the DZone community and get the full member experience.
Join For FreeHackathon competitions might be one of the most efficient methods to motivate developers to create their own solutions. Meanwhile, now not many developers are not familiar with such events and how to prepare for them. In this article, I'll explain what tools can simplify your development process as well as increase your chance to win.
What's A Hackathon?
The idea of a hackathon is to deliver an application that has to solve one of the problems in a given field within 24/48h. Often competition organizers notify participants about the hackathon subject. So in most of the cases process has the next steps:
- 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.
To Be Prepared Is Half the Victory
Quite often the winners of the hackathon are much better prepared than anyone else. Some dishonest participants even write applications before they come. But in this article, we review "legal" preparations.
Most Classical Enterprise Java App Structure
The easiest way to save a lot of time during the competition is to make a skeleton of the classical Java Enterprise app. Quite often an enormous amount of time is wasted on configuration, etc. So let's construct the most common Java EE application 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 Java Frameworks
As a good alternative, you can use frameworks that generate create Javascript UI from Java. The most popular are: Vaadin, ZK, GWT
HTTP API or Way to Communicate With UI
HTTP communication is not the only one, for some projects we have to use websockets to arrange quick communication. Here we can review useful tools for quick HTTP API building. There are many tools and solutions but I recommend using Spring Boot Web. It allows you easily convert/parse HTTP requests with many other useful features.
Business Logic
Well, it's a pretty vague definition. But in practice, the business layer is a layer that combines any other layers like services or database repositories. So the key tool here is Dependency Injection and Inversion of Control patterns. You might use different DI/IOC providers like Google Juice or even write your own but I would recommend Spring Framework once again.
Services
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 API
Clouds provide tons of different APIs from voice recognition to machine learning tools. I can't favorite any existent one, but I assume the most popular are: AWS, Google Cloud, Azure. They are powerful and paid, so pay attention anytime you use them. So to do not lose all your money, keep logic inside your app that limits API calls.
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.
Database Connectivity
The most straightforward but still verbose solution for connecting to your SQL database is JDBC wrappers like apache JDBC template or Spring template. But due to time limitations, they are not useful for Hackathons. The best way to design your DAO quickly is Spring Data. Spring Data has many adapters/solutions for many Data Sources 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!
public interface UserDao extends JpaRepository<User, Long> {
User findUserById(Long id);
}
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:
@RepositoryRestResource
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
List<User> findByName(@Param("id") Long id);
}
Provide HTTP API to read Users by ID. Once it's implemented next endpoints will be available:
{
"_links" : {
"users" : {
"href" : "http://localhost:8080/users{?page,size,sort}",
"templated" : true
}
}
Last But Not Least: A Tip About Database Preparation
In order to simplify the database design process, you can use the SqlYog application that allows you to generate schema. Once it's done you can use IntelliJ IDEA to generate entity classes. It might save you billion years. I strongly recommend using these tools!
JMS or Schedulers or Asynchronous Solutions
You might ask why this part stands separately from business logic or services. Well in general synchronous and asynchronous problems have their own implementations. In most of the cases, Java Messaging is represented by Topic and Queue Pattern and can be solved by RabbitMQ or Active MQ or Kafka, etc. The key problem for all of them is that they require additional configuration in order to run message broker and it's time-consuming. So they still can be used but only there aren't any other options.
Spring Quartz
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.
Instead of Conclusion
As Miguel de Cervantes once said — "To be prepared is half of the victory". So get prepared my friends and dare to win at hackathons.
Opinions expressed by DZone contributors are their own.
Comments