Reflections on MVC

images.duckduckgo.comMVC is a design pattern that allows coders to keep unrelated portions of their code separated into logical chunks so that the implementation remains as loosely coupled as possible. We use MVC to make our designs scalable, reusable, and clean.

This week was really rough.

There were so many things to incorporate into my understanding of the Play Framework. The CRUD update WOD was by far the most difficult. Toward the end of the week I was kind of wondering what I was doing as I was doing it.

I understand, on a very basic level, how MVC works, but getting good with doing it by default and in some kind of flow state seems impossible at this point.

I understand the concepts we covered this week but the break-neck speed of the material is daunting. I need to plan for more time to focus on redoing the final two WODs. Adding a model that allows for persistent data across the application is encouraging. I’m proud of myself for sticking with a persistent bug I encountered. I checked my code line by line 3 times and still my application would not retain form data. Only after restarting my computer, taking a walk around campus, and running ‘activator clean’ did my form data finally start working.

The concepts at this point are falling into place extremely slowly.

I’m anticipating more time with the material will make the concepts much clearer. Surprisingly, I am not daunted by Scala expressions intermixed with HTML and Java code. Maybe it’s because I’ve been using Objective-C for 5 years and I’m used to the overabundance of brackets.

This slideshow requires JavaScript.

Digits Mockup

I am consistently amazed by how beautiful my web applications are now that I am using Twitter Bootstrap.

The integration of fonts, and solidly positioned (don’t forget responsive) divs makes me happy. During this WOD I quickly set up a bootstrap application and added a ‘zebra type’ form. Just last year, I remember coding my web forms in PHP and having to check the modulus of the returned content from the database to determine which row to shade off-color. I love Twitter Bootstrap.

I did not finish this WOD the first time through because I spent a lot of time with Bootswatch picking out my favorite theme. I did learn how to include my theme dynamically with a relative stylesheet. I have that code saved for later when I want to swap out the standard twitter bootstrap CSS with a customized theme from Bootswatch.

  • First try: DNF at 39 min 35 sec
  • Second try: AV at 21 min 16 sec

Digits Form

For the process of updating forms to use the Play Framework I created a list for myself in TextEdit on my desktop. The four steps to update web forms from HTML to the Play Framework are as follows:

  1. Create a backing class for form.
  2. Make view dynamic.
  3. Handle form in controller.
  4. Add POST request to routes.

I’m not quite at the point of translating this list to code but it helps to know the list or have a crib sheet to make the updates faster and faster. I will continue working to commit these words to memory. Even more to work through this process and immediately be able to code it up fast.

I did not finish this WOD within the time allotted. Before I attempted the WOD again, I reviewed the Play Form Screencast and took notes on exactly what was updated and in what order. I am learning that the order of the updates matters. Not only do I get code completion in IntelliJ if I do the updates in a particular order, but wear grooves where my feet have gone before. I can code faster if I code in the same manner over and over.

  • First try: DNF at 43 min 55 sec
  • Second try: AV at 23 min 14 sec

Digits Form Validation

The form validation WOD was my favorite this week. Everything with form validation is straightforward. I understand it and I was able to complete this WOD on the first try. As with the first WOD this week, I am just amazed by Twitter Bootstrap. The ability to style up the forms themselves to show the status of the input is beautiful in its simplicity and calm presentation.

  • First try: Rx in 17 min 33 sec

Digits Model

I did not feel as prepared for this module as I did for the previous WODs this week. I did not feel that the screencasts that led up to this WOD made the application possible. Perhaps I missed some of the supplemental information in the readings.

I had a very hard time conceptualizing the updates I was making in this WOD. I will have to redo this WOD many more times to first get the understanding of the material, then many more times to get the fluidity needed to complete it in under 18 minutes.

  • First try: DNF in 28 min 50 sec
  • Second try: DNF in 32 min 14 sec (Could not complete this WOD on my own. Had to rely on the screencast.)

Digits CRUD

I tried my best to do this WOD on my own the first time but I did not feel prepared for the material. I believe that I need to devote more time to reading the supplemental material. Rather than rely on the screencasts leading up to the WODs I should have devoted more time to finding supplemental material.

This practice WOD had me going all over the application to update the Contact.java file with a ContactDB.java file. I understood the updates we were making but the dependencies within the code to sustain the updates was jarring. I feel very off balance with the material in this practice WOD. I am planning to get up early tomorrow and get in as many redos with this practice WOD as possible before class.

  • First try: DNF in 1 hour 15 min 7 seconds

Lingering Questions

What’s the best way to handle authentication inside of a Play Framework application? Patrick found a third-party framework called SecureSocial that handles authentication. I haven’t had a chance to look into it deeply. But from my research online, there are a number of simple tweaks we can do the application to require simple page-based authentication.

I want to find something that has as few dependencies as possible. I also want to find something that is easy to upgrade. I feel that the PlayWithMagic code we are working on will be used in the future by Mark and I want to be sure that it ages well.

Author: David Neely

Professional Software Developer. Technology and Web Coordinator at the University of Hawaii's Manoa Career Center.