Ask Me Anything

Malina Tran
Tech and the City
Published in
6 min readDec 23, 2016
Hello, that’s me.

I have not been writing as frequently as I’d like. To my (non-existent) fans and readers, my apologies. The truth is, I love writing. I relish reading books and learning how words get crafted and documented, how they can inspire or teach. My goal is to have 100 blog posts by the end of my apprenticeship. (Eep, I am not quite there).

Since I’m a fan of advice columns, even if the questions veer toward being quirky (see: Slate’s Dear Prudence), so I figured I’d write a blog post in this format. Without further ado, let’s start.

Dear Malina,
We haven’t seen any of your monthly retro blog posts. What are you currently working on during your apprenticeship?

Yikes, I haven’t written a retro blog post since August and not because I’m twiddling my thumbs, not doing anything. Quite the opposite! I’ve dipped into several projects since then, including pairing on a Scala/Play project, finishing my HTTP server (and incorporating reviews from my mini-review board), and working on a book inventory project built with Node/Express for a few days.

Currently, I’m writing middleware code — yoking two discrete projects together and making them work together. Using my Java server and Clojure tic-tac-toe, I am writing code (in Clojure) to allow my tic-tac-toe game to be hosted by the server and accessed via a web browser. Requests will be sent from the web interface to the server, which will send a response and update the game accordingly. Since Clojure runs on the JVM, two programs can be seamlessly interwoven together.

Dear Malina,
As a developer, is it common for you get perpetually stuck on tasks?

I get stuck all the damn time. I also (literally) get things stuck all the time, but that’s another story for another time. I’ll just demonstrate all the ways that I got stuck as I was working on this project.

The first is that I’m finally no longer using my dinosaur MBP for work and instead have a MacBook Air (fancy, but not really at all, since I’ve inherited it from Cat). I’ve been configuring my Vim settings with plugins that would make writing Clojure much more fun/bearable (mentioned here). This has not been easy or straightforward. In fact, I’ve switched over to neovim and that is a long-ass process that requires the following:

  • Installing neovim
  • Installing a plugin manager (I moved from Pathogen to Dein); also, aliasing vim commands to point to neovim (did this in .bashrc)

I got stuck here for awhile.

For my hosted TTT, I published the server and tic-tac-toe projects as libraries (Central Repository and Clojars, respectively) in order to pull them in as dependencies. This was fairly straightforward with Clojars. Literally, I just had to rename my project (apparently, “tic-tac-toe” is too generic), create a login, and deploy my project from the command line lein deploy clojars. This task generates everything necessary for a Maven artifact to be stored in a repository, including a POM file and a JAR file. Then it uploads them to Clojars.

I started the process of publishing to the Central Repository, which is pretty much the opposite of straightforward, and disregarded a simple question: “Do you own malinatran.com? If not, do this [blah blah].” That question sounded to me like this: “If you own the domain, all good. If not, you have to do something different.” Three days later and I’m trying to understand why I haven’t completed the process, until I finally comment on the question.

Can we say stuck?

(FYI, an interim fix is to have my server as a local JAR file, as opposed to publish it in the Central Repository. So for awhile, I opted for storing my server’s JAR file in a directory called maven_repository and ran the following command below (build success!) and then lein deps).

mvn deploy:deploy-file -Dfile=maven_repository/java-http-server-1.0-SNAPSHOT.jar -DartifactId=java-http-server -Dversion=1.0-SNAPSHOT -DgroupId=com.malinatran.java-http-server -Dpackaging=jar -DlocalRepositoryPath=maven_repository -DcreateChecksum=true -Durl=maven_repository/

👆🏽This took me awhile to figure out since people will set up their configurations differently.

But after making changes to my Java server, I wasn’t sure about the process to release an “update,” so I went back to using a local JAR file. I didn’t want to be stuck on that issue for too long, but that’s what I’m currently doing. As a result, Dave and Jayden who have cloned my repo have been reporting issues will accessing that JAR file.

Impending stuckness.

TFW you’re stuck.

The next step was to write Clojure code that would start the web server. To be honest, I was struggling with this longer than I expected because I was getting a misleading error. All I had to do was make sure I was passing in command-line arguments to my main function.

I was stuck here for awhile.

I have come to embrace that this is part of the process, especially for a junior developer. There is a certain beauty in being stuck and getting unstuck, or at least that’s what I tell myself.

Dear Malina,
What are some challenges that you are facing in your current project?

What a great question. The idea behind my current project is that I am writing code that complies with the open-closed principle (software being open for extension, but closed for modification). When I wrote my server, all I had in mind were:

  1. The fundamental necessities of sending requests from a client and sending responses from a server, and
  2. That it incorporates the Cob Spec acceptance criteria.

So, when I started thinking about how my two projects would interact, I knew there would be some changes that I had to make to my Java server.

Let me provide a high-level overview of my Java server works: it depends on a set of routes that correspond with a specific action, which I’ve modeled after routes in Rails. For example, a “GET /” will correspond to an IndexAction and a “POST /something” will correspond to a PostAction. Those actions are responsible for building a response — by sending a status code and message body. For my TTT game, I needed to create new endpoints/routes that would be responsible for playing the game. For instance, “GET /” would now need to read from and render an index.html file. I would also need to create new routes that can receive the user’s selected move and do something with it.

Here is what I had to change with my Java server:

  • Abstract my routes. I changed it so that I would pass in the routes and actions to the router in `Main`, thereby customizing those endpoints.
  • Make the methods of abstract class public. Given that I was adding new endpoints, I wanted to create new routes and actions. Action is an abstract class in which all of its concrete classes extend its methods. I needed access to the methods that are (in Clojure terms) a “proxy” of Action. I found that the methods were package-protected, since I neither stated whether it was public nor private.

While this “challenge” proved more enlightening and relatively easier to overcome, it was a temporary setback. I had to also re-consider the design choices of my Java server. There were some things I realized I had not equipped my server to do, which is to easily add acceptable file formats and automatically serve index.html files if they existed. I better understand how certain decisions can have a cascading effect on future implementations. And at any given point, it is important to consider the question, “Is this extensible?,” and refactor if necessary.

--

--