In this simple example I would like to show you how to build an application using a few technologies like Spring Boot with FreeMarker Java Template engine for rendering the view, Java Persistence API for storing our objects into the database and simple REST API for application’s data manipulation. We will add some Groovy integration tests using Spock testing and specification framework. Our application functionality will be very simple. We will be able to add users using both rendered HTML page and REST API and store them into in-memory Java SQL database called H2. The list of users will be displayed on the main page.
Since Java 8 we have a new way of finding files in a file tree using
find() method from
Files class. This class contains a set of static methods used for operating on files, directories, or other types of files. In this post we will implement functionality of finding files which were modified given number days ago.
Imagine yourself in a situation when you need to add a new functionality to an old and badly written code. What do you think first? “I need to refactor it all!”. Then second thought is coming: “better not to touch it too much” or “I will use a copy-paste pattern” or even “I need to change the job”. The first idea you have of course depends on your experience. In this article I would like to share my thoughts with developers who are struggling against themselves in such a situation.