Week 2 – Adventure Games

This week, we learned about Java servlets and their implementations. Servlets are programs that reside on the side of the server, that typically respond to user input and extend the capabilities of a server. We were taught about servlets from the very basics, from how to get input parameters from the user to how to log errors if they came up in the program (log4j, I learned, is an absolute blessing). Chip and Connor even showed us how the servlets in StockCharts.com‘s code interacted with DynamoDB, which is the database that AWS uses, and how it interacts with SQL as well. We got to learn a lot about cloud functionality through this as well, though indirectly.

Learning about servlets, though initially quite simple, soon became a daunting task. Once we understood how servlets worked, we moved on to making them ourselves. Our task for the week was to take an adventure game that we had built the previous week, and make it work on servlets. To this end, we learned about state machines as well, which are basically programs that are able to be in one state at a time, depending on it’s previous state and the inputs. We used state machines to identify all the possible states the character could be in, and then we were told to build on it ourselves from that point on.

I chose to make different states for the character depending on what it was doing at that time, e.g. changing locations, fighting, making decisions, etc. This proved to be much harder to implement than I thought it would, so after spending some time trying to unsuccessfully map all the different states to my character, I decided to backtrack and start over from a certain point, and I implemented only one state, and made all the different actions that the character could perform into variations of that state. Ultimately, I managed to produce a very basic model of my adventure game, but it worked. Chip keeps telling us to first make it work, then make it work better, which is a feature of iterative development – I followed this, and managed to produce a game that worked, though it wasn’t very pretty. Chip assured me that this was better than the alternative, which was to make it pretty, but not be able to make it work, and I agreed.

It was a good week at work, and we learned a lot about how server side Java works, and how it interacts with all the other parts of the system to be able to produce results that the users are able to view and understand.

Next week, I am about to work on a team with an employee of StockCharts.com, and we will be going through all the special requests that the site receives and try and implement a better filter so that the efficiency of the blades that run all the requests is increased, and we’re able to handle the special cases better. Stay tuned for more updates!

Peace, Love and Algorithms

Rajesh Narayan.

Leave a Reply

Your email address will not be published. Required fields are marked *