Data Design: Modeling and ERDs

This week we were lucky to have a relatively simple set of WODs which focused on data design and generating Entity Relationship Diagrams. Although simple, this topic is extremely important and necessary for next weeks lesson, Data Design Implementation. Since I’ve studied this material in the past, this was a great (and very much needed) review.

WOD 1: Library Data Model
In our first WOD, we were tasked with designing a data model for the typical library system. In this system, the library holds multiple copies of books. Patrons, who are either students or faculty members, can borrow and reserve up to 5 books. This system must be designed to meet the following requirements:

  • Check whether a recently returned book has been reserved
  • Check which borrower has a specific book on loan
  • Check which books are currently with a specific borrower
  • Check the status of a particular book (borrowed/not borrowed)
  • Check which reservation should receive a recently returned book
  • Retrieve the loan and reservation history for a book

Since I’ve studied data design in previous classes and I’ve worked with Lucid Charts before, I found this WOD fairly easy to accomplish. I finished my first and only attempt in Av time of 15 minutes and 38 seconds. Here is the Entity-Relationship Diagram I drafted for this problem which, I believe, meets the required specifications:

ERD-Library

WOD 2: Car Rental Data Model
The Second WOD was similar to the first but a bit more challenging. We were instructed to create an ERD for a car rental company. The company has a number of offices in various cities and locations. Each location has a set of vehicles, each vehicle can be categorized into one of five vehicle types (i.e. Economy, Standard, Van, Box Truck, Cargo Van). Customers can reserve a vehicle at a specific location for a set date and time. When the vehicle is returned, the car rental clerk records the date, time, odometer reading and gas level.

Like the previous WOD, I was able to finish my first and only attempt in AV time of 14 minutes and 35 seconds. While my solution varies slightly from that presented by the professor, I believe that it provides a satisfactory design for this data model. Here is my ERD:

ERD-CarRental

Conclusion
The exercises this week were fairly simple to accomplish but we can easily see how models can quickly get complicated as the data and relationships become more complex. In the application that I am building for the final project, I already know that I am going to have at least 4 different entities: Users; News subscriptions; Commute subscriptions; and Blog subscriptions, however, this number may change. Representing my data model as an ERD will undoubtedly be helpful and provide direction when I eventually take on the task of implementing the backend database.

Notify Hawai’i – Milestone 1

NotifyHawaii
Development of the Notify Hawai’i web application is progressing at a steady rate. Here I will describe the current state of the system, what I am working on for the next milestone release, and discuss my experience with project management.

Current State
There is an in-memory database to store user information (i.e. first name, last name, email address, telephone number, and cell phone provider). This information will be gathered and validated when users register for an account with the application, however, this function is not yet implemented. User information is edited from the ‘My Account’ page.

There is a second in memory repository to store News Service subscriptions for each user. These subscriptions are added and updated from the News Services webpage. Currently, user and subscription information is added to the database during the initialization of the application on start up.

The application is able to retrieve news articles from a specific set of online newspaper sites. These sites include the Honolulu Star Advertiser, the Maui News, and Civil Beat. The articles that can be retrieved are grouped into the following categories:

Honolulu Star Advertiser: Breaking News, Popular News, and Sports.

Maui News: Breaking News, Business News, Hawaii News, and Local News.

Civil Beat: Most Popular Stories, Honolulu News, Honolulu News, Education, Politics, Energy and Environment, and Development.

Articles are retrieved using the Jaunt Web Scraping API. Once articles have been harvested from the applicable websites, they are sent to users via email or text message. We use the Apache Commons Email API which includes the JavaMail API as well.

The future of Notify Hawai’i
There is still much work to be done on this application. While implementing the News Services module, I realized that sending a list of articles via SMS text message may not be a worthy endeavor. Depending on the number of subscriptions held by the user and the number of articles published by the site, these lists can be quite lengthy. Since HTML cannot be displayed in SMS text messages, there is no efficient way to present article titles and links. Therefore, I will most likely remove the text message option and only issue News notifications by e-mail.

For the next milestone release, I plan on implementing the Commute Services module. This service will allow users to request notifications when commute related events occur. By using the Google Maps API and Honolulu’s ‘TheBus’ Web Services API, I hope to be able to inform users on estimated commute times and bus services. I also plan on putting the finishing touches on the News Services and Account pages and bring them to a completed, fully functional state.

Project Management
I’ve had both good and bad experiences working alone on this project. It is nice to have complete control over the implementation but I often think another developers opinion would be a valuable and welcomed resource. Also, building the entire project by myself has required a huge amount of effort. It would have been nice to partner with someone to share that load. However, since the majority of the documentation has been written (i.e. the user and developer guides), maintaining them by incrementally adding updated information pertinent to the newly implemented functionality should be easy.

Going forward, I would like to be better about creating and closing Github issues. The issue management system is a great tool to guide software development and I should be utilizing it more. I am also going to start working off of branches from the master repo instead of doing all of the work in the master repo itself.

Overall, I feel that this project is progressing along at a reasonable rate and is actually useful in its current state. I’m excited and looking forward to building out the next few modules!

View the project on Github here.
View the deployed application on Heroku here.

Application Design: Tests and Templates

This week we endured one of the longest sequence of WODs to date. The majority of the exercises focused on the important task of implementing tests to challenge the application and ensure quality. We also studied the use and creation of template code to increase efficiency. Although these exercises were not particularly difficult, there were several little “gotchas” that resulted in my failing of a few of the exercises.

E47: Digits Test
The goal of the first WOD was to implement two simple tests to ensure basic functions of the application worked correctly. The first test checked that the index page could be successfully retrieved. The second test checked that a new contact could be added to the database and correctly displayed in the table of contacts.

Although I watched the introductory screencasts and studied the example applications, I struggled during my initial attempt at this WOD. Within 30 minutes, I had written the two test cases and created the applicable Page classes (following the page object pattern) but was unable to compile the code. In my application, the two test methods were passed the TestBrowser object which was then used to navigate through the application. This approach, however, is not valid in the Play framework as test methods cannot be passed parameters. After approximately 20 minutes, I managed to debug my way out of this predicament and successfully run the tests. In all, I spent over 50 minutes attempting to complete this WOD resulting in a DNF. After watching Dr. Johnson’s solution, I immediately repeated the exercise and completed my second attempt in Rx time of 17 minutes and 30 seconds.

E48: Digits Text Template
The second WOD was much easier than the first. The goal of this exercise was to use Scala templates to recreate the Bootstrap text fields in the New Contact form. By utilizing templates, not only do we ensure controls have a uniform appearance but we also reduce redundancy making the code cleaner and easier to read. Since the templates were given to us and are simple and easy to use, I was able to complete my first attempt at this WOD in Av time of 10 minutes and 39 seconds. After watching the solution, I repeated the WOD and managed to shave off over 5 minutes from my time finishing in just 5 minutes and 15 seconds.

E49: Digits Selection
The third WOD continued with the use of templates but this time we added a selection control to the New Contact form which is a much more complicated task than adding the textbox control. Utilizing selection boxes requires the creation of a backing class that maintains a list of valid options which must be passed to each View that uses that selection box control. The actual implementation is not very difficult but but ensuring that all the pieces fit together can be challenging. This slowed me down a bit during my first attempt at this WOD. I also experienced an import conflict since both the form helper and Bootstrap templates have a “select” method. In the end, I was able to finish this WOD in Av time of just under 38 minutes. Like the previous WODs, I made a second attempt at this exercise after watching the solution and was able to achieve Rx time of 21 minutes and 42 seconds.

E50: Digits Custom Template
In WODs 2 and 3, we used preexisting controls in the Bootstrap template. In the fourth WOD, we created our own control template that consisted of a textbox and selection box. Creating custom templates can be useful if the same form or set of controls is displayed in multiple places throughout your application. However, as a classmate pointed out, there is a drawback – error messages are displayed for all controls in the group if any control contains a validation error. This WOD was not too difficult and I was able to complete my first attempt in Sd time of just under 16 minutes and my second in Rx time of 6 minutes and 17 seconds.

E51: Digits Init
In the fifth and final WOD, we learned how to override the onStartup method of the Global class that allows us to initialize the application to a specified initial state. This was not a difficult WOD, however, I DNF on my initial attempt due to the fact that I imported the wrong application package. This error did not throw an exception – the code compiled but the onStartup method was not invoked. After over 16 minutes, I gave up and watched the solution screencast. I immediately repeated the WOD and finished my second attempt in Rx time of 7 minutes and 26 seconds.

Knowing the State of the Repo
Before beginning each WOD, we were instructed to create a new branch off of the master repo and do the exercise in that branch. At the end of a successful WOD, the branch was to be merged into the master repo. After several WODs, and several series of branching and merging, it can be difficult to know the state of the master repository. Fortunately, Github provides a network diagram tool that visually represents the branching and merging activity of the repository.

Git Network Diagram

This is an extremely useful tool that allows one to quickly get a sense of the current state of the master repo.

Conclusion
Although this weeks WODs were significantly more involved and required more time and effort than any previous WOD, the skills we acquired are necessary for producing a quality application.

Hackaday

Fresh hacks every day

Slashdot

Professional Portfolio