Java Bootcamp Companion Project
Introduction - Read Me
The bootcamp project is a basic java webapp, Using SpringMVC, AngularJS, managed by Maven, and run with a Jetty plugin. Persistence mocked by a static collection.
A full introduction on standing up a project like this can be found here: Spring MVC 4 RESTFul Web Services CRUD Example
This architecture was chosen for its simplicity to introduce those new to Java web applications to a very simple web app and was built by someone completely new to Java.
The 'review' branch is a solution branch, which provides a more standards-compliant view of the same project.
As bootcampers progress through the bootcamp they:
- Fork the Project - https://github.com/ATC-Custom-Bootcamp/java-companion-project
- Clean the code of non-conforming Java
- Implement a DAO by moving the static list out of the Service, and finishing CRUD methods either with loops or streams to interact with the list.
- Add the view the ability to update and delete existing records.
It's important to note that bootcampers are going to have wide experiences with the project. Those learning Java, HTML/CSS, and JavaScript from scratch should spend more time drilling the languages, and use this as an aspirational example to guide their learning, while experienced bootcampers could completely reform the project to demonstrate what they are ready to do.
Day 1 - Project Group Workspace Setup
In order to help troubleshoot and collaborate as a team during the bootcamp, after our first meeting, we standup a common Java web application local developer environment together. Walking through a common setup using the Eclipse IDE will allow us to expedite introductory modules common to many online Java courses, and introduce some common environment technologies like Maven.
Wait To Install
Java JDK 8 (Wait to Install) jdk-8u29x-windowsx64.exe |
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html |
Eclipse IDE Installer (Wait to Install) |
https://www.eclipse.org/downloads/ |
Project Tasks
With the Environment that we setup together on your local machine you are going to perform “Project Tasks” alongside select Pluralsight modules which provide opportunities to demonstrate your current skill and progression throughout of the bootcamp.
Task 1.0 - Learning Naming Conventions
As an easy first task, and as an exploration of the the codebase of the project, refactor the Object, Package, and Variable names in the project to match standard Java conventions.For an introduction to the different types of files in the project, go to the project structure section.
Java Conventions Reference Java Naming ConventionsAcceptance Criteria:
- Java project should still successfully compile, and the server launches, after refactoring all name references to match Java conventions.
Task 2.0 - Create a MockDAO, Separate Concerns, and Repair Web Components
The Service layer of our application also contains our data, making our business-logic layer tightly coupled with our data. This isn't good as it reduces flexibility and creates complexity.
The web application at the moment can only Read and Create games, but we want it to be able to update and delete as well.
Uh Oh! By refactoring the objects and variables in our Java application, we changed the key names of the properties of our JavaScript objects (JSON).
- Create a new Class called MockDAO, and lift the static List declaration of our data from the Service(GameServiceImpl or Game_Service_Impl) into the MockDAO. The main functionality for our create, read, update, and delete (CRUD) methods should also be in the MockDAO.
- Since we need to Update and Delete games, add update and delete methods to the Service and connect those to corresponding methods in the MockDAO:
Use loops, accessor methods, and boolean "if" statements to perform the CRUD updates to the static list. If you're familiar with Java already, implement CRUD methods using the the Java Streams API. - Repair what we broke in our webapp by updating the JavaScript variables in our views.
Acceptance Criteria:
- The project should compile, launch, AND you should be able to add a game (again) to the list in the UI of the running application
- Pass a code review of methods implemented in your DAO
Task 2.1 - Discover Interfaces as an introduction to APIs
Application Programming Interfaces, or API's are software intermediaries that allows two applications to talk to each other. Within Java itself, Interface objects, function similarly to an API by exploiting Object's inheritance of interface methods. For an example of this concept look at the GameService and GameServiceImpl files in your project.
Create Interfaces for the Model, DAO, and Service objects in the Java Application.
- Create Interfaces for the Model, DAO, and Service objects in the Java Application.
- Make a new package for the DAO called com.organization.bootcamp.mvcproject.dao
- Make new packages for the DAO, model and service packages with the format: com.organization.bootcamp.mvcproject.api.XYZ
In these newly created .api packages, you will create interfaces for the Java classes in the corresponding packages
For example:
com.organization.bootcamp.mvcproject.api.dao
- contains the interface for MockDAO
com.organization.mvcproject.dao
- contains the implementation of that interface and would be called MockDAOImpl
The rest of the packages follow the same pattern.
What is the point of this?
The purpose of doing this is to decouple the implementation from the interfaces. If you call an interface, things only need to be changed in one place, the implentation pointing to the interface. This article goes into detail on why this kind of separation is necessary for enterprise development.
The Pluralsight tutorial on the Spring framework also discusses the decoupling process and explains why it is important.
Task 3.0 - Complete the Feature
Now that we have prepared the service and DAO with our CRUD methods, we need to complete the feature.
Add to the view the ability to update and delete an existing record.
If you have time, add an select control that allows you to filter the records list by genre.
Acceptance Criteria:
- Successfully demo the CRUD feature of the running application.
Concepts Expedited from Setup
Eclipse for Java Developers | 2:17:23 |
Setting up a Java Maven Development Environment with Eclipse | 0:41:17 |
Setting up a Java SE Development Environment with Eclipse | 0:52:46 |
Using Git for a Java Project in Eclipse | 0:43:20 |
Getting Started With Git* | 0:42:22 |
Course Overview | 0:01:54 |
Get Up and Running with Git | 0:40:28 |
Java Fundamentals: The Java Language | 0:51:38 |
Course Overview | 0:01:24 |
Creating a Simple App | 0:35:27 |
Introduction and Setting up Your Environment | 0:14:47 |
Lean Software Development Fundamentals | 0:23:54 |
Waterfall and Agile | 0:23:54 |
Maven Fundamentals | 0:24:17 |
IDE Integration | 0:24:17 |
Setting up a Java Development Environment | 0:31:40 |
Course Overview | 0:01:29 |
Installing and Running Java | 0:18:56 |
Packaging Java Applications | 0:11:15 |
Spring Framework: Spring Fundamentals | 0:26:23 |
Architecture and Project Setup | 0:26:23 |
Additional Setup Helpful Links
Quick Info | Helpful Link | Notes |
---|---|---|
Using egit interact with GitHub in Eclipse | https://developpaper.com/using-egit-plug-ins-to-interact-with-github-in-eclipse/ | Refer to this step-by-step guide for setting up a Personal Access Token in Github, to Push commits in Eclipse to Github to your project fork. Test your configuration and connection to github in a terminal:
|
Technology Stack Reference
Helful Links on Java, HTML, JavasScript, Spring MVC4, Maven, AngularJS
AngularJs App
Quick Info | Helpful Link | Notes |
---|---|---|
1.0 Just need a console fast? | https://www.tutorialspoint.com/compile_java_online.php | Compile and Execute Java Online (JDK 1.8.0), use a browser page to quickly compile and run Java console, for syntax testing. |
1.1 W3Schools, a foundational reference for HTML/CSS/JavaScript and more. | https://www.w3schools.com/ | W3Schools is the best no-frills interactive references for learning HTML tag/attribute libraries. They have a wide range of tutorials on other languages that are great introductions, particularly to JavasScript frameworks. |
1.2 Trouble Getting a Spring MVC Project Launched? | https://www.pegaxchange.com/2018/02/12/spring-web-mvc-project-maven-archetype/ | Follow this guide to get a legacy Spring MVC boilerplate with @annotated configuration booted and running using a working maven archetype project. |
1.5 Angualr JS + SpringMVC Tutorial | https://websystique.com/springmvc/spring-mvc-4-angularjs-example/ | Use @RestController and ResponseEntity type controllers for your AngularJS dataservice to “consume” (GET,POST,PUT,DELETE) resources on asynchronous submits.
User normal Spring “ModelAndView” or “String” type controllers to handle classic spring synchronous submits. |
Project Structure - The "Stack"
Edit Infographic Source- *.jsp (html) - The view that contains the structured HTML markup for the UI.
- *.module.js - The AngularJS App declaration
- *.controller.js - An AngularJS controller, which provides two-way model binding for displaying and interacting with JavaScript models.
- *.service.js - An AngularJS, which “consumes” the Java Server endpoints for RESTful data.
- *Controller.java - contains the entry-point definitions URLs serving RESTful Objects and/or java pages containing syncronous Java Model and View pages.
- *Service.java - The business logic layer, communicates with other services, and prepares and processes objects to be persisted and returned
- *DAO.java - An object that implements the persistence layer, handling access, and queries to the data.