Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/valentinnsoare/bookslibrarywithcrudinmind

A small library with CRUD operations in mind using OOP, genercis, lambda functions, streams, anonymous classes...you can find more info if you will clone the repo :P
https://github.com/valentinnsoare/bookslibrarywithcrudinmind

anonymousclass crud-application docker docker-compose generics lambdas mysql prepared-statements singleton-pattern sql state-management streams template-method-pattern

Last synced: 22 days ago
JSON representation

A small library with CRUD operations in mind using OOP, genercis, lambda functions, streams, anonymous classes...you can find more info if you will clone the repo :P

Awesome Lists containing this project

README

        

# :books: BooksLibraryWithCRUDInMind

## _with create, read, update, delete operations and several flavors of them_


:arrow_forward: Small library applications interacting with a MysQL application within a docker
container on port 3306 using only JDBC driver, no framework, from the Java standard point of view.

:arrow_forward: When developing these methods around CRUD principles I followed the Data Access Object Generic Interface (where I defined
the methods) and the template method pattern from the Gang of Four design patterns.
and SOLID design principles. Also there is a way in the code when I extend a generic class using anonymous classes
in order to be able to define an object which in the class is a generic one T.

:arrow_forward: In the source code you can see that there are two ways of writing a method,
the naive way without design patterns implemented and the one with all things necessary in order to be able to test the code
and function properly.

:arrow_forward: More information will be down bellow.

![personal_branding][1]

## Technologies and concepts:
1. [X] OOP Principles (composition, inheritance, polymorphism, abstraction);
2. [X] Data Structures - Array, Deque, ArrayList, LinkedList;
3. [X] Third Party Libraries - Lombok and JDBC;
4. [X] Generic, anonymous classes. An anonymous class was made to extend a generic one;
5. [X] Optional class and Comparable in order to be able to avoid null pointer and to compare objects, Book object;
6. [X] SOLID design principles and template method pattern;
7. [X] Docker and MySQL 8.0;
8. [X] Fedora 38;


> Project is :100: completed!


:point_right: Here are the CRUD methods defined in the Data Access Object generic interface.

![DataAccessObjectGenericInterfaceMethods][2]


:point_right: This is the generic abstract class QueryTemplate that extends the ConnectionToDb
to easily access the open/close connection and getConnection methods.

![QueryTemplateClass][3]


:point_right: For the link with DB we have an abstract class that is extended by various classes
where we need the connection.

![ConnectionToDB][4]


:point_right: With BookDAO we implement those CRUD operations, naive way is the first version which it's difficult to make tests for and the second one where I followed design pattern and SOLID principles in order to have a better build.
With this class we extend the generic QueryTemplate one with an anonymous class.

![BookDAO][5]


## :technologist: How To Set Up:

1. Clone the repo:
`git clone https://github.com/valentinsoare/LibraryWithCRUDInMind.git`

2. Ensure that you have Docker and Docker-compose installed/

4. Make sure that you have the YML file called docker-compose.yml, and it is written to deploy the Mysql Server.
* Docker file:
```yml
version: '3.8'

networks:
default:

services:
db:
image: mysql:8.0
container_name: library
ports:
- 3306:3306
volumes:
- "./.data/db:/var/lib/mysql"
environment:
MYSQL_ROOT_PASSWORD: "XXXXX"
MYSQL_DATABASE: "library_db"
```

4. Then please run `docker-compose up -d` in order to fetch the Mysql Server and deploy it. Then you can connect to it.

> [!NOTE]
> It is recommended you modify the docker-compose.yml file but only the user and password for DB.

### :computer: Dependencies and plugins for Maven

:white_check_mark: For the pom.xml file we only have two dependencies (Lombok and JDBC) and
the necessary plugins for build (jar make) and download dependencies sources and documentation automatically.

1. Dependencies
```xml



org.projectlombok
lombok
1.18.28
provided



com.mysql
mysql-connector-j
8.1.0


```

2. Plugins
```xml



org.apache.maven.plugins
maven-assembly-plugin



true
org.clibankinjava.App



jar-with-dependencies




make-my-jar-with-dependencies
package

single





org.apache.maven.plugins
maven-dependency-plugin
3.1.2



sources
resolve


javadoc



```