Tumgik
ditzy-nerd · 7 months
Text
Zoo App
I wanted to create a "capstone" like project that brought together all my skills so far, both front-end React and back-end SpringBoot. I created a simple zoo app, where someone can create zoos, add animals to the zoo, and maintain the animals.
Tumblr media
Each animal starts at 0 days old, 0 hunger, and 5 happiness. Each day, the animal can be fed and pet, if they are not, their hunger increases and their happiness decreases the next day.
Tumblr media Tumblr media
Each day they get a day older. If an animal reaches 5 hunger, 0 happiness, or 10 days old, they die.
Tumblr media Tumblr media
repository: https://github.com/koscida/cap-crud
0 notes
ditzy-nerd · 10 months
Text
Completed the Full-Stack course on LinkedIn!
0 notes
ditzy-nerd · 10 months
Text
Writing Prompt App
In honor of National Novel Writing Month (NaNoWriMo), I made an app that helps users randomly select writing prompts.
Tumblr media Tumblr media
This month I was writing a series of short stories and wanted a way to pick from the different prompts that were possible. I also had other characters and tags that I wanted to randomize, so I created a Writing Prompt App. It let's users enter their own data and then generates random results. The results can be saved for future use.
It starts with the Prompts page:
Tumblr media
Here, the prompts can be added and organized. The prompts are categorized so they can be grouped by similar ideas. Each new line in the text field will create a new prompt, entering a comma will also create a new line. The prompts can be edited in-line and their order can be shifted.
Then we can start adding characters:
Tumblr media
Characters only have a name to start. Since writing can be unique to every story, I wanted full flexibility, so I didn't add any other required fields, a character only starts with a name.
The power and customization of this app is on the Tags page!
Tumblr media
Tags can be added to prompts, characters, or none (independent tags). The tags work like an option list for these elements. Each tag can be shown as a radio list (single select) or check boxes (multi-select), with the options specified in the text box. Similar to the prompt list, each line is an option, entering a comma will create a new line. Finally, the user selects how the tags will act. They can either be included in the random generator if possible (if they have multiple options selected, one will be picked), or they can hold static data that will be saved with the item.
When tags are added, the Prompts and Character pages will show their respective tag options
Tumblr media Tumblr media
If a tag is added after a prompt or character has been created, the tag will have blank data. In the prompt generator, the item will generate blank data for those tags. Any item can be edited with any new tags that have been added.
All saved results can seen as well:
Tumblr media
Once all prompts, characters, and tags are added, the user can run the prompt generator on the Home page. Once the user sees their results, they can either re-generate or save the results for future use. All the saved prompts can be seen in the Results page.
0 notes
ditzy-nerd · 11 months
Text
0 notes
ditzy-nerd · 11 months
Text
0 notes
ditzy-nerd · 1 year
Text
One-To-Many
This time was spent learning how to add a One-To-Many relationship. Most of my struggle came with using H2 and pre-loading data in the db.
First, setting up the One-To-Many and Many-To-One relationships were tricky, since I had to get the right properties set in the OneToMany annotation. I was tripped up by what to set the mappedBy value to, it's the variable name in the corresponding entity. I also needed to set fetch to EAGER instead of LAZY, to load the data first. The corresponding entity would need to switch the Column annotation to JoinColumn.
User Entity
Tumblr media
ToDoList Entity
Tumblr media
Item Entity
Tumblr media
The next problem was the infinite loop caused by returning the associated entities. This solution suggested using the @JsonManagedReference annotation for the first objects instantiated and the @JsonBackReference annotation for the second objects instantiated, which worked. I was able to test the users and lists endpoints. This leaves the item endpoint as the last generic endpoint left to create.
0 notes
ditzy-nerd · 1 year
Text
POST and Sequences
I spent the last 2 days trying to add my first post endpoint!
Tumblr media
I learned more about the frameworks I've been using and the conditions for building a database. The largest hurdle was determining how to add the id into the database.
I was working from two examples: (1) Learning Spring with Spring Boot Online Class and (2) Spring Boot, Spring Data JPA - Rest CRUD API example
The online class inserted data using GenerationType.AUTO for the ID in the table Entity and by not entering the ID in data.sql. The POST method, accepts the entire entity and calls the service to directly save it into the repository.
Tumblr media Tumblr media Tumblr media Tumblr media
The tutorial example I was following approached id generation using GenerationType.AUTO. In the POST method, it copies the entity and directly saves it to the repository.
Tumblr media Tumblr media
I was using H2 from the online class to pre-populate the database; however, two of the tables had one-to-many relationships with other tables. The online class got around this by writing select statements inside the query to get the ids. I could have used this method, but I wanted to use H2 in the SVD APP, so I needed a way to directly use IDs to pre-populate the database. I also needed a way to enter data without needing to know the ID
In the entity, I changed the strategy to GenerationType.SEQUENCE, which expects a sequence defined in the database. In the sql schema, AUTO_INCREMENT was added to the primary ID and I added the sql sequences. The sequences starts after the pre-populated IDs.
Tumblr media Tumblr media
0 notes
ditzy-nerd · 1 year
Text
Building Relationships: OneToOne
As I contuine to add endpoints, I want to learn different methods of representing data. When I was building the Skill and Profession endpoints, I took the route of creating each of their endpoints with just their data, then created a DTO to represent the SkillTree.
I added the Recipes entity next, which required a RecipeCategory entity as well. I made a custom recipes/categories for just the RecipeCategories, but wanted to include the RecipeCategory within the Recipe, which required a OneToOne relationship between the entities.
Tumblr media
Since I already had the RecipeCategory created, I just needed to store a RecipeCategory within Recipe. Using Spring Boot to build the database model in Java has been a breeze!
I still need to learn what is happening in a deeper level in each annotation I'm using. From my experience developing full-stack without a framework, there is so much heavy lifting being done by spring boot. (And I know that there is so much more to this framework that I haven't even touched on.) I never expected to be able to develop endpoints for a sql database this quickly, but I have my first one-to-one endpoint working:
Tumblr media
0 notes
ditzy-nerd · 1 year
Text
Objects within Objects!
I have a complex endpoint working! I first got the Skills and Professions endpoints working independently, then added a Skill Tree!
This was a test in learning Java and the SpringBoot framework and OOP principles. JavaScript makes data manipulation so much easier because they are not tied to OOP principles. This was a challenge in constructing the correct classes and understanding how the SpringBoot framework uses Controllers, Repositories, DTOs, and Entities.
Tumblr media
I added one more endpoint under the /skills endpoint. The logic that a skilltree would always live under the skills section and together they create the name 'skilltree'.
My construction of the data entities of Skill and Profession was unchanged; however I had to add two more DTOs to hold the skill tree and profession path:
Tumblr media Tumblr media
SkillService had an addition of a new getSkillTree() method. This method was responsible for constructing the SkillTree between the two repositories. In the context of the SpringBoot framework, I believe this is where this logic goes.
Tumblr media
One of the interesting things I learned was how to add additional methods within the Repository. In the ProfessionRepository I added three more methods to search by other attributes than id. This was useful for the new getSkillTree() method in SkillService where I needed to search for Professions by their starting Skill
Tumblr media
Now that I have an idea of how to return more complex data, I want to clean up these endpoints and add a few more svd entities.
0 notes
ditzy-nerd · 1 year
Text
SVD Database Beginning!
Now that I have my first endpoint working, I've been adding a few more entities. When designing the database schema, I've trying to "map" the more independent entities towards the top and the entity-reliant tables below. I still don't know how to fully represent a SQL database in Java or Spring Boot entity objects, but I'm taking it step by step and learning how to build relationships one-by-one.
Tumblr media
I am adding entities that are connected to a limited number of other tables. First was Villagers, then I added Skills and Professions. My first challenge was realizing I needed to use a wrapped data type (vs a primitive data type) to store a null value within the entity.
Professions will be a good challenge because they relate to a Skill and another Profession. Right now I have a GET endpoint that is just the Profession entity with ids for the relations.
0 notes
ditzy-nerd · 1 year
Text
First EndPoint
Tumblr media
I have the first endpoint of the SVD API working!
After a lot of thought, I decided to re-build how I was pulling data from within the SVD app. Initially I was storing the svd game data in JSON files within the app itself and was persisting the user data locally within the browser. I knew I had to find a more permanent solution for at lease the user data and wanted to challenge myself with building a back-end api that would feed in the game and user data.
In the back-end api I wanted to use an OOP-language instead of a JS framework, like the front-end is written in, and decided to go the Java Spring Boot framework because of the popularity of the Spring Boot framework and my past experience and likability of Java. I took Java class in college and have used it sporadically over the years, but when I used it last I was using Java applets, so the Spring Boot framework is a giant leap forward and a lot to take in at once. I've taken two LinkedIn Learning courses, the first to re-familiarize myself with Java and the second to get an introduction to the Spring Boot framework. I also wanted to re-familiarize myself with SQL, so I am working on building the database.
Today I was able to push my first endpoint, it returns a list of all the villagers in the game. Villagers are one of the simplest data entities in the game, since they can be fairly self-contained. As I've been developing the database, I've discovered a lot of the entities depend on each other, so they will not be as straightforward to add endpoints for.
0 notes
ditzy-nerd · 1 year
Text
Java Spring Boot
I completed the Learning Spring with Spring Boot course!
0 notes
ditzy-nerd · 1 year
Text
Databases
To continue with the development of the SVD app backend, I've started mapping out a database. This will be filled with the static game data that will feed the api.
Tumblr media
0 notes
ditzy-nerd · 1 year
Text
Java
The front-end of the SVD app is progressing nicely. I've shifted towards the backend and re-familiarizing myself with Java and SQL and learning to build a Spring Boot application.
I completed the Hands-On Introduction: Java course which was a good refresher.
0 notes
ditzy-nerd · 1 year
Text
// find unique values of an array
let unique = arr.filter( (value, i, arr) => arr.indexOf(value) === o );
0 notes
ditzy-nerd · 1 year
Text
num.toFixed(2);
0 notes
ditzy-nerd · 1 year
Text
// math functions
Math.abs(n)
parseInt(s)
// create an array from 0 to n
[...Array(n).keys()]
// create an array from 0 to n with 0 values
[...Array(n).keys()].map(n=>0)
// split string into characters
pathArr.split("")
// get the number of elements in an object
Object.keys(obj).length
0 notes