Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Applications with Spring 5 and Kotlin

You're reading from   Building Applications with Spring 5 and Kotlin Build scalable and reactive applications with Spring combined with the productivity of Kotlin

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788394802
Length 310 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Miloš Vasić Miloš Vasić
Author Profile Icon Miloš Vasić
Miloš Vasić
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Starting Up 2. Starting with Spring FREE CHAPTER 3. Building Your First Spring RESTful Service with Kotlin 4. Working with Spring Data JPA and MySQL 5. Securing Applications with Spring Security 6. Spring Cloud 7. Using Project Reactor 8. Development Practices 9. Testing 10. Project Deployment 11. Other Books You May Enjoy

Separating code into independent entities

Before we start with the implementation, we will separate our code into independent entities. Each entity will cover a single responsibility and therefore will be implemented when we cover a certain Spring functionality.

We will start with the main classes that will represent the data we will actually handle: Notes and TODOs. Then we will describe user-related stuff: the users themselves and the roles we plan to assign to them. Later, when we actually implement most of them, we will introduce some new entities to cover additional responsibilities. This will be explained in Chapter 3, Building Your First Spring RESTful Service with Kotlin.

Describing entities

The main entities that we will use and that will hold the data are Notes and TODOs. We can consider each of them as an entry that will be stored and that has common attributes:

  • ID: Universally Unique IDentifier (UUID) String
  • Title: String
  • Message: String
  • Location: String value that represents serialized Location class into JSON.

Here are all the entities that we use:

  • Note: The Note entity will represent Notes in the system with all common attributes.
  • TODO: The TODO entity will represent TODOs in the system with all common attributes and timestamps for a scheduled time.
  • User: The User entity will be completely independent of the main data entities. The user will represent the user and all the attributes that the user of the system can have, including assigned roles. The user will have the following attributes:
    • ID: UUID String
    • Email: String
    • Password: String
    • First name: String
    • Last name: String
    • Roles: String
  • Enabled: Boolean representing whether the user has activated the account or whether it has been activated by the user from a higher user hierarchy
  • Created on: Long representing UTC timestamp when the user was created
  • Updated on: Long representing UTC timestamp when the user was updated

In later stages, we can introduce additional attributes if there is a need. For now, we will stick to the most important ones we just described.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image