Life is a highway … or a roller coaster … or is it like a box of chocolates? In software development, metaphors can be very useful when trying to understand a new concept. I have been reading the excellent Code Complete 2 by Steve McConnell. In Chapter 2, he states the following: 

A software metaphor is more like a searchlight than a road map. It doesn’t tell you where to find the answer; it tells you how to look for it. ” 

 

I have had my first experience of the Model-View-Controller (MVC) recently and, having worked mainly with Windows Forms, I have found the shift in thinking to be challenging. Despite an excellent lesson from our in-house teacher, Andy, I found that MVC wasn’t as straight-forward as I’d hoped. Knowing the value of a good metaphor, I found a great post DEV.to that put MVC in terms that I might understand. “Explain MVC like I’m Five“. The title spoke to me.  

I found a series of great comments in this thread, but some jumped out at me more than others. This lead me to search online for other metaphors for MVC – the simpler the better. Below, I have shared some of my favourites.

  1. Imagine a shop with three workers. One is responsible for taking the customers’ requests, one is responsible for getting the item the customer wants, and the third one wraps the item in nice packaging and presents it to the customer.
  2. You walk in a McDonald and you order at the big interactive touchscreen. You place your order at the screen – this is the View. Your order is passed on to the worker who will go and fetch your order – this is the Controller. Finally, the type of order that you have placed is the responsibility of the Model.
  3. Mark understands the toys in the toy box.
    Vicky knows how to set out toys for certain games.
    Charlie tells Mark to get the toys for a certain game and tells Vicky to set them out. Vicky tells Charlie what new game the user would like to do.
    This continues for the entirety of play time.

As I gain greater understanding of MVC, I hope that I will be able to create my own metaphor that works best for me.

Over the past few weeks, I have been working with WordPress to create a new website for a client. As you may know, WordPress is an open-source Content Management System used to create and manage websites. Having a little experience with HTML and CSS, I was looking forward to getting my hands on the website.

One of the most attractive features of WordPress is the expansive library of plugins that are available to users. By using plugins, users can add impressive features to their website without having to write intensive code. In my short time working with WordPress, I have found a few plugins to be particularly helpful.

quaytech-systems-blog-shameless-plugin-2

Most websites will need to have simple contact forms at a minimum. When you add in memberships and donations, you can find yourself creating many forms. Luckily the popular Contact Form 7 came to the rescue. I was able to create a number of contact forms which could then be customised and placed on various pages. In conjunction with the Conditional Fields for Contact Form 7 plugin, I was able to add conditional fields to my forms. For example, a few fields would appear only if the contact was from a business.

 

quaytech-systems-blog-shameless-plugin-3

Slider Revolution allowed me to add a snazzy carousel to the home page. However, the plugin can also add sliders and hero pages, all by dragging and dropping images. Slider Revolution helped to create an eye-catching experience for visitors to the website without much effort. To create such an effect with my current web design knowledge would have been a stretch to say the least.

 

quaytech-systems-blog-shameless-plugin-4

As someone who wouldn’t consider themselves to be much of a writer, Yoast offers help when writing posts such as this. Yoast offers guidance for Search Engine Optimisation, i.e. how to improve the visibility of your posts on search engines. You may need to use more complex sentences, or you may need to stop repeating yourself! Yoast offers clear help on how to make your posts more attractive to search engine results. This post is over the recommended minimum word count of 300, but not by much!

 

quaytech-systems-blog-shameless-plugin-5

Default Featured Image is an excellent example of how a plugin can solve a specific problem that you need to solve. I had been asked to add a default image for every post that did not have an accompanying image. Without having to write code, I found the above plugin which did exactly that. While it may not offer many features, it does exactly what I need it to do.

 

quaytech-systems-blog-shameless-plugin-1

As helpful as all of the previous plugins have been, they did not offer a level of control that was necessary to meet our client’s specification. WP Add Custom CSS has been invaluable in creating the website. It allows users to add custom CSS across the entire site from one place. You can still use your CSS knowledge to create a consistent and responsive website.

With over 50,000 plugins out there, I’m looking forward to seeing what new feature I add use next.

 

 

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.

quaytech-systems-blog-totally-unclutchable-part-2-01

quaytech-systems-blog-totally-unclutchable-part-2-02

 

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.

quaytech-systems-blog-totally-unclutchable-part-2-03

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.

quaytech-systems-blog-totally-unclutchable-part-2-04

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.

quaytech-systems-blog-totally-unclutchable-part-2-05

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.  

quaytech-apprenticeship-totaly-unclutchable-part-one-main-menu

  • 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.

quaytech-apprenticeship-totaly-unclutchable-part-one-cars-list

  • 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.

quaytech-apprenticeship-totaly-unclutchable-part-one-visual-studio-project

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.