23
My Personal Guide to Building a JavaScript Frontend and a Rails API backend
The inspiration for my application comes from my personal experience. I create and use checklists everyday to document what I want to accomplish or to remind myself of what needs to be done. While a pen and paper has never failed me, I concluded to build an application that houses my succinct need to make lists; I call it “UPFRONT”. Within UPFRONT, I implemented some features that I found to be helpful to the modern, on-the-go person who likes to visualize their goals and tasks.
This is my first project utilizing the separation of concerns regarding frontend and backend. It is interesting to see how the frontend and backend merge and diverge at certain points within my application. And yet, they continue to act upon their own responsibilities. I can value this need to differentiate between responsibilities and to portray such within the structure and flow of my code.
Both the implementation and display of the "Three Pillars of JS" has been rewarding for my coding ability. The three pillars nicely break down how abstracted, DRY code returns an useful web application.
Recognizing JS Events: In UPFRONT, there are many buttons awaiting an action. The action, a "click", is a JavaScript event. This event results in JavaScript doing "work", most accurately in the form of a callback action.
Manipulating the DOM: The Document Object Model, or the DOM, is often changed or updated through events in JavaScript. In UPFRONT, a "clicked" button (the event) may return a change in color, the addition of a new instance on the page, or the rendering of an edit form.
Communicating with the server: After doing the work and manipulating the DOM, the JavaScript application communicates with the server to report the changes made from the event and to the DOM. This finalizes the effect of user-made actions to application's frontend (the browser) and backend (the database).
showTasksButton().addEventListener("click", handleClick)
const handleClick = () => {...}
Functions have been the biggest surprise for me in learning and applying JavaScript. While they resemble methods commonly seen in RoR, they are much more complex and powerful. Functions in JavaScript are first-class data.
This means that a function can be an argument to another function, a function can be the return value of another function, and a function can be set as the value of a variable, to name a few aspects. The extended functionality of JavaScript functions allows for abstraction, DRY code, and overall, a more sophisticated application.
To learn more about my project, click the link!
23