Reflections on Testing and Templates

When I was a kid, my mom sewed all of our shorts. I remember looking at the patterns that she cut out from McCall’s pattern books and laid them out on the fabric. I used to enjoy going to the fabric shop and running my fingers over the different swaths of fabric. I could close my eyes and from the feel of the fabric on my finger tips I could almost tell what it was made from: cotton, rayon, etc.

Metaphors work really well for me. They help me relate the concepts in computer science to real world, tangible things. Once I can map a concept in computer science to a real thing that I can feel and touch I can create a complete mental model in my head.

If I can see a Scala template as a McCall’s pattern for making clothes, I can see it and understand it and get more fluidity with the material.

I would like to get as good at knowing the feel of Play Framework Templates. So much that I am able to write out things and know how the process goes from parts to a full whole.

I took a different approach this week. I am noticing a common thread in my WODs. That I get caught up in understanding all the small details and why things are the way they are and that keeps me from finishing things.

I understand that I can work on things and I have to get over my procrastination. That is a new thing to learn this week. I got into it and just dove straight into the WOD videos. Then once I had completed the WOD with the instructor I circled back and watched the videos over. I looped them in my apartment to study up on the concepts.

Digits Test

During this WOD I learned how to automate testing of my pages. In the past when I’ve coded up pages and put them online I’ve had to click through the forms myself and see if the forms submitted or if there were errors in the processing. With integration testing in play, I can actually code the behaviors that the user would do and have the computer automate the test and actually perform a significant function. I wish there were something like this for PHP.

  • First try: AV in 30 min 20 seconds.

Digits Text Template

In computer science there is a concept called DRY. DRY stands for Don’t Repeat Yourself. Another great feature of Play is the ability to swap out components by creating templates. These reusable pieces of code can be created once and used all over the application an infinite number of times.

The best part of reusable code is that if it needs to be updated you just need to update that single instance of code and it will be updated across the entire web application.

The specific thing I learned in this WOD was how to update the variable at the top of the Scala page to map it to a specific Play component. When I compiled my project the first time I got a ton of errors and did not know why. Then I looked at the top of the time and realized I had not imported the bootstrap3 library.

  • First try: 14 min 30 seconds.

Digits Selection

It was good to finally start working with different types of form variables. In this WOD I added a play template form drop down box. This WOD taught me how to specifically target a form field and inspect it with firebug in Firefox. This allowed me to figure out exactly which class/id pertained to this form field so I could call it programmatically.

  • First try: DNF 1 hour 23 min 40 seconds.

Digits Custom Template

The purpose of this WOD was to combine a series of templates into a single template to display a text input and a drop down on a single row in a form. The best thing about this WOD was the ability to set form attributes inside of a row without having to specify the number of characters the form would accept so that the form would extend itself in a visually appealing manner. The combination of Play and Bootstrap makes forms look beautiful.

  • First try: 15 min 30 seconds.

Digits Init

This WOD taught me how to seed the in-memory database with content. I liked this WOD because it set up a very easy way to set global variables in the application. Although the WOD did not instruct us to do specific routines upon the end of the application, I was glad to see that there were programmatic hooks to enable behaviors to be triggered at the start and end of the application. Play seems extremely robust. I am excited to use the features I learned this week in our PlayWithMagic application.

  • First try: 9 min 32 seconds.

Lessons Learned

Two times already, I have merged my changes into the master branch without setting a commit on my branch in the code and when I merged it back into master, the updates have been lost. This happened when I finished the last WOD and the custom Scala template I create to contain both the telephone number and the telephone type in one Scala template were wiped out by the merge.

This is good to learn because I would hate to see this affecting the work done by my project peers. I like that I have an open source project that I can point to. I have open source experience now!

Github network graph of this week’s WODs

Screen Shot 2015-03-31 at 11.36.47 AM

Author: David Neely

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