DEV Community

Jason Oh
Jason Oh

Posted on

Shorten URL Reflections

In getting my hands dirty with backend development, I had tasked myself with engineering a Java based URL shortening service akin to TinyUrl. Here are some of my reflections regarding the experience. https://github.com/Jason0h/shorten-url

Part I: Deciphering the Magic of Spring

Trying to understand Java code built on top of Spring can initially be a deeply frustrating experience. That's because there's no control flow to be traced. There're definitions of classes but no evidence of their instantiation to be found. It's as if the application developer has written themself a library but has forgotten to take the final step to use said library. But the code works, so what sorcery is going on here...

The key to understand what's going on is Spring's principle of Inversion of Control. Simply put, you write the "template" code that defines business logic (e.g. mapping http requests to responses) but nothing much afterwards. Instead, Spring handles the instantiation of your templates ("Beans" in Spring terminology), piecing them together, and dynamically calling them when appropriate. In other words, Spring abstracts away control flow from being the responsibility of the programmer, making it magic that happens in the background. This concept was quite strange at first, much like driving a Tesla in autopilot, handing over control from the human to the machine. Accepting its strangeness, however, accelerated my understanding of Spring.

Part II: Navigating Deployment on AWS

A Spring app on its own can only persist and serve data locally. Thus, I had to familiarize myself with AWS for the purpose of deployment. After creating an administrative account on AWS, I was bombarded with 100+ services and had little clue as to which was appropriate. Thus, what I anticipated as being a quick process ended up being a weeklong rabbit hole into learning about the AWS ecosystem. Notably, I had found the concept of serverless Lambda functions to be especially fascinating (my next project will most likely be using it). Nevertheless, I reasoned that deploying a Docker container of my app to AWS AppRunner and porting my SQL schema to AWS RDS would be the most appropriate. While I had thought deployment would be a minor part towards the end my project, exploring the AWS ecosystem and online console was itself an important journey.

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.