A lot has happened with Totally Unclutchable since my last blog entry. After weeks of work, I thought that I had created a fairly robust application. How naive I was.

Our resident testing expert, Andy, was let loose on the app and proceeded to break it at every turn. I realised that I hadn’t done enough to control the data being input into the system.  Andy entered strings where there should be integers. He entered characters designed to break my SQL queries. He found errors with the sequencing of steps when adding Cars. He was relentless. This was my introduction to validation. I clearly had a lot of work left to do to remove the Garbage data I was allowing to be used in my application.


What is Validation?

Validating data is when an application makes sure the data being input is of the correct type and is useful. There are several types of validation, but I concentrated on a few areas in particular:

  • Presence Check
  • Range Check
  • Format Check
  • Type Check


Presence Check

In order to add a new Car to the database, every field must be filled. For example, I needed to ensure that every car had a Daily Hire rate. I used the Validating and Validated events of a textbox to do this. I wrote the following method to check if the textbox wasn’t empty as well as checking if the content was a positive number. The user is unable to move onto the next textbox until an entry is made.




Range Check

It is often necessary to only accept values in a certain range. For example, ages must be between 18 and 75 to be accepted. This can be done by setting an upper and lower limit or by using comparative operators to make the checks. I have also gained some experience recently with ASP.NET Web Forms. The built-in validation tools make such a check much easier.  RangeValidator simply checks if the input is in between two fixed values.


Format Check 

Totally Unclutchable asks users for email addresses, phone numbers and postcodes. I found it quite complicated to create checks that allowed the correct formats. However, once I was introduced to Regular Expressions (Regex) it made the process much more accurate. Regex allows the programmer to decide which characters can be used and the format they can be used in. As an apprentice developer, I found it daunting to have to write my only expressions. Fortunately, Regular Expressions can easily be found online for the most common formats.


Type Check

As mentioned in Totally Unclutchable – Part 1, I designed the tables in my database to accept certain data types. For example, the Minimum Age for a Car is an integer; the Daily Hire Rate is a decimal. If my program fails to pass in valid data, it will crash. Therefore, checks for data types need to be done before calling to the database. I found that I needed to convert the text from textboxes to integers, decimals or valid dates. As you can see below, the DateRegistered required a timestamp to be appended for SQL to accept it.


Stopping the problem at its source

As I learned more of the properties of each control, I was able to be more sophisticated with my design. For example, in the Add Booking section, a user needs to select the start and end date of their car rental. I limited the dates available by using the MinDate and MaxDate properties of a DateTimePicker. I had prevented incorrect data from being input through improved design. If possible, it’s worth eliminating the need for validation checks.


The best way to learn to code is to actually code. I have read this in many places in recent months and now, over two months into my apprenticeship, it is making more and more sense. Until recently, I had  written mainly to the console. It was time to try something new. Introducing Totally Unclutchable, a fictional car rental company with an interesting name. This is my first experience of windows forms.  


  • Specifications

To begin, I was given very clear specifications for the windows form. In brief, it needed to have a Cars Module, a Customers Module and a Booking Module. A user can add, edit and delete cars and customers. The Bookings Module allows the user to assign available cars to customers in order to create a booking. At this stage of my apprenticeship, I require a lot of scaffolding with the instructions. In time, I will to design a program more independently.


  • Steps involved

To get the ball rolling, I learned about how to connect my windows app to a SQL database of customers, cars and bookings. To do so, I needed to use a connection string and make use of the SqlConnection class. It is good practice to close any connections before proceeding.  Over the course of the project, I needed to make various calls to the database. I learned a great deal about the format of a query. I learned the hard way that SQL and C# have different formats for dates. This was important in the AddCar and AddCustomer forms, where I needed to validate the information that is input by the user.

Using Object-Orientated Design has been a challenge for me in this project. I’ve had to understand the how classes and objects can interact with each other. Prior to beginning, I had a shaky understanding of constructors and methods, but I feel that I have made progress in these areas. I recognise the importance in planning the design and layout of a program in advance. Totally Unclutchable features a series of forms and manager classes.


I had no idea how much time I would spend on debugging when I started Totally Unclutchable. Debugging has helped me to find syntax errors, to correct data types, and to correct SQL queries. As I progress as a developer, I am aware that I will spend more and more time debugging.


  • What I’ve learned so far

While initially daunting, this project has helped me better understand Object Orientated Design. I had done quite a bit of reading, but nothing beats actually writing code. I have found it quite rewarding to work with windows forms as there is something to show for my efforts; there will be a working product by the end of the project. I have gained experience in using Visual Studio. Its tools for debugging have been particularly helpful.


  • Next steps

The Bookings module of my program remains. I will have to calculate whether a car is available, assign customers to available cars and check that they qualify for the rental. I have a great deal of work left to do. Join me next time to see if I can get Totally Unclutchable on the road!

Friends is back on Netflix and what better way to celebrate than to start a blog on being an Apprentice, and complete one of my first IT exercises to create a database of the friends characters and write some queries!

This past month, I have begun my apprenticeship with Quaytech Systems. Over the next year or so, I will be learning about Object Orientated Programming with the long-term aim of becoming a software developer.

Here at Quaytech, we are all big fans of Friends so, as an introduction to database management, I it made sense to create a database for the characters with SQL. This was a great way to introduce me to relational database management. I spent a few days creating tables of employees, managers, departments and salaries while making links between them using foreign keys. Once everything was set up, I started experimenting with writing queries. For example, I was able to write a query to find out which employees were in the finance sector (hint: it was Chandler).

Sub-queries were an early stumbling block but with a plethora of online resources to help (as well as very helpful co-workers, ) I was able to further my understanding of SQL.  All of this practice came in handy, as I recently wrote my first query which was implemented to answer a support ticket; the first of many, I am sure.

The next step was to access my Friends database through C#. I was introduced to Connection Strings and SqlCommand. I found this difficult at first; however, after a bit of debugging, I successfully accessed the SQL database through C# and even wrote some methods.

In my short time at Quaytech, I have already learned so much. I am looking forward to continuing my learning journey.