It’s been a while since my last blog post on building a basic trivia app using React with Redux-less global state — quarantine has been weird and time for personal projects ebbs and flows, but I’m back at it. When I last left off, I had set up global state using just React hooks and the Context API, and tested basic functionality by making an external API call and saving the result to my store. My next step is to set up some basic app usage with this store data available. …


Image for post
Image for post
Photo by Anne Nygård on Unsplash

When I learned React, the bootcamp curriculum featured a blend of class and functional components, hooks were covered in just a single afternoon lecture, and we used Redux for global state management. Ever since starting my post-bootcamp career, I’ve been working pretty minimally in JavaScript, and all in either vanilla JS or jQuery. The React world has also had a lot of exciting changes and certain norms have been codified in the meantime. Everything is functional components now and hooks are the way of the future, but my interest was really piqued by hearing that global state is now possible to implement purely in React — no Redux needed. I love React and want to keep up my skills, so I’ve started building a pretty basic front-end app to get a solid grounding in some more contemporary practices that I didn’t get a chance to dive into in bootcamp. …


Image for post
Image for post

Let’s start at the end, a very good place to start.

As I suspect a lot of people feel at some point, writing recursive functions seemed dense and counterintuitive to me for a while. You call a function, inside that function itself? How does that even work? Why would you do it? What’s the actual design pattern of making it properly?

While working through a coding challenge, I finally had a breakthrough that helped me answer all those questions, as well as identify the source of my previous hang-ups. I realized that I’d been approaching recursion problems backwards, because I’d been approaching them forwards. When you’re starting to write a recursive problem, it’s a good idea to start it from the end and work backwards from there. Because that’s the path forwards. Confusing? Yeah, recursion is. But I’ll explain. …


Image for post
Image for post

With the release of MacOS Catalina, Apple has abandoned the bash shell in favor of zsh. After adjusting, I actually prefer zsh. It’s user friendly, even more so with the virtually-essential oh-my-zsh plugin, and I really like the file navigation and autocomplete features.

Much to my dismay, however, I found that my older Rails projects were not playing nicely with zsh. Trying to bundle i or rails s especially seemed to be leading me around through an Ouroboros of error messages. Missing gems, wrong permissions to install said gems, and the Terminal insisting “Your Ruby version is X.X.X, but your Gemfile specified X.X.Y” …


Image for post
Image for post

Programmers are lazy. But, like, the good kind of lazy. When you’re trying to piece together a particularly tricky project, why make life difficult for yourself with nuts and bolts? Most major editors come with a wide array of plugins explicitly intended to move mental effort away from coding basics so you can focus on making your actual product the best it can be.

My favorite editor hands-down is Atom, made by the team from GitHub. Although Flatiron recommends VSCode officially, I’ve really enjoyed Atom due to the customizability that‘s so core to its design philosophy. …


*(neither fun nor profit guaranteed)

Image for post
Image for post

Let’s say, hypothetically, that we’re building a mini-RPG battle game. You know, like my partner German and I were for our Flatiron Mod 4 project. We want users to be able to select various items like weapons, armor, etc. and battle against other users with their selected loadout. When selecting their equipment, we want users’ options to be laid out in a nice little grid like the above. We’re working in React and have installed Semantic UI React in our project. …


Image for post
Image for post

As developers, we often need to gather data from external sources for use in our own programs. Doing this in JavaScript used to require clunky code or the use of outside libraries, but fortunately the Fetch API has in recent years made retrieving, adding, editing, and removing data from external databases easier than ever before. This API works by providing and resolving a series of promises. Let’s break down this process with a few examples.

A basic fetch

At its core, fetch only requires one argument: the location where it should send its request (which by default is a GET request). So if we wanted to access the Star Wars API (SWAPI) and find the fourth character in the database, we could use the following JavaScript…


Image for post
Image for post
Beware! Read on to find out why.

As an object-oriented language, Ruby (and by extension, Rails) supports the use of classes to give context and functionality to the various object instances used throughout the program. These classes are all inter-related to each other in some way or another, and while many exist to model real-world objects, many exist only to store the relationship between those other classes. Rails, with its goal of making our programming lives as easy as possible, has provided an out-of-the-box way to create these model-linking models (called join tables) quickly and easily. …


Image for post
Image for post

When I started learning Ruby, I started noticing code snippets like the following:

name_array.map { |name| name.upcase }

or:

name_array.find_all do |name|
name.length > 5
end

What are those little pipes for? Where did the word inside the pipes come from? What’s that second part inside the curly braces or do-end statement? It kind of looks like a conditional, but I don’t see any if-else statements so it’s just sitting there on its own? What is going on here???

Image for post
Image for post

Okay, so I quickly found out that those are examples of enumerables — one of Ruby’s handiest features, and worth an entire separate discussion. But underneath the hood, what’s really at play is the yield keyword: deceptively simple in appearance, but very powerful, and possibly even handier than enumerables — after all, without yield, enumerables wouldn’t even exist. …

About

Pete Hanner

Former paralegal gladly opting for programming instead of law school. Engaged in a years-long, steady migration northward.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store