Welcome

Welcome.

This site serves as the portfolio of Carl Mitchell.

Here is a contents list specifying the name of the projects and the languages/technologies used for your convenience:

If you have obtained my C.V and wish to know more about any of the projects, feel free to contact me via the details specified on my C.V.

Database Front-end App (SQL, ADO.net, WPF, C#)

In short — a database for a game called “Best Game” that I made up on the spot, it doesn’t actually exist so you’ll just have to take my word for it that it’s a game that needed a database, although many games do nowadays.

There were multiple parts to this project

  • The SQL database itself, created and managed via SQL Server and contained the important data the game needed to store such as player records and high scores
  • A class library dll that interacted with the above database via C# and ADO.net
  • A WPF window application that would use the above class library to interact with the database, such as bringing up the high scores for a specific level

Going through each part in more detail:

The SQL database:

  • All tables in 3rd normal form, the most commonly used form
  • All tables have appropriate constraints such as default constraints, unique constraints and check constraints
  • Views for the seeing the high scores for specific levels, as this required multiple joins thus you’d want to hide that complexity behind a view which is for all intents and purposes a saved query
    • However, views have the annoying constraint that you cannot use ORDER BY clauses in them. SQL management studio this would be ok if I had a TOP statement in the SELECT clause so this hints that using TOP 100 PERCENT would mean I get to order the whole lot which is what I want…but it doesn’t work.
  • Stored procedure for getting the high scores for a specific level, with a parameter of type int that is the level id you want the high scores for. You can use ORDER BY here so it’s definitely an improvement over the views!
    • Also tried it with a multi table valued function but it has the same problem as views, ORDER BY won’t work although strangely enough SQL won’t warn you about it not working with user-defined functions
  • Joins – appropriate types used when needed
  • After-triggers for adding sales to an audit log whenever something is added to the orders table
  • Instead-of-triggers for disabling the updating, inserting and deleting of data from the above views. The views are based on multiple tables so updating the view itself rather than the base tables can cause issues. These triggers stop that.
  • Indexes to speed up some queries

The class library:

  • Encapsulates the setup and teardown of connections as needed as well as the calls required to send data back and forth between the database and the application.
  • Actually uses both the connected layer and disconnected layer, though note that this was only so I had practice using both. In a real application, only one layer would be chosen.
  • Wraps the connected and disconnected layer into one class so you don’t need to know which layer you are using
  • Is a reusable dll so it can be used as a library for any other application, such as a console application (seen below in pictures)

The WPF application:

  • Uses a Data grid to show the contents of the latest result sent back from the database.
  • Can update, delete and insert field data via the data grid directly
  • A button to push forward the new data from the application to the database
  • A button to revert the table back to the state it is currently in in the database (i.e. remove any changes you’ve made that haven’t been pushed yet)
  • A drop down combo box to select which table you want to view/edit
  • Another drop down combo boxes that appears only when the “specific level” option in the prev list is chosen, so you can pick a level id to view

As always, I’m no artist so it won’t look pretty.

The starting screen. By default the customers table is shown

The starting screen. By default the customers table is shown

You can add new data just by clicking on a row, alter current data by clicking on the row you want to alter or deleting it altogether

You can add new data just by clicking on a row, alter current data by clicking on the row you want to alter or deleting it altogether

Clicking revert will undo any unpushed changes

Clicking revert will undo any unpushed changes

Can select other tables via the drop down list

Can select other tables via the drop down list

Another label and drop down list appear if you want the high scores for a specific level, selecting a number will then run a stored procedure

Another label and drop down list appear if you want the high scores for a specific level, selecting a number will then run a stored procedure

and up come the results of that SP

and up come the results of that SP

It doesn't actually matter what the front end is, the class library isn't tied to one, so here's a console application using it

It doesn’t actually matter what the front end is, the class library isn’t tied to one, so here’s a console application using it

If you want the original source code, please email via the address on my C.V.

Basic Messenger (WCF, WPF, C#)

By messenger, I mean an application where you can enter a chat room and talk with people online. So more popular examples include Skype and the good old Msn Messenger (Rip). So for this I used the Windows Communication Foundation to create a networked service, hosted by another application that runs on the “server” as well as a WPF application used as the client application that communicates with the server via a proxy class.

Summary of key features of the code and client:

  • TCP binding used for the endpoint so it’s fast and also reliable
  • There is an HTTP-based endpoint available too but this is only for the metadata-exchange so the clients can create proxy classes when attaching a service reference
  • Service is hosted on a console application on the server side. This would be done with IIS (w/WAS) usually but a console application is much easier to debug. Though I do know how to set it up to be hosted with IIS/WAS if needed.
  • Use of request-reply and one-way operation contract configurations
  • Use of callback contracts for duplex messaging
  • Multi-threaded concurrency mode
  • Single instance context mode
  • Interface allows clients to login, logout, send messages and change their username
  • Server alerts all other clients to new login & logout notifications, new username notifications and new messages
  • Client holds the bare essentials, the ability to login with a desired username (denied entry if there is already someone using that username), enter the chat room, exit the chat room, change user name and most importantly, post new message to other clients.

As with all my projects – please judge them on functionality and not looks as I am no artist, as you can clearly see with the exit button image I drew. Trust me, it looked nice at full size.

serverstartup

Here’s what the server looks like when it is started up. Nothing special. If someone enters the chat room, sends a message, changes their username or leaves the chat room, it is logged here.

clientstartup

And here’s what the client looks like when started up. It’s very basic as the name suggests but also means it’s likely to be easy to use!

logintime

Let’s try logging in

loginsuccessful

Success! the exit button is now enabled, list of users is populated (only one at the moment!) and the login button is now a send button. You don’t have to use the button though, you can also press enter when the textbox is focused

morepeopleinchat

Now let’s startup more instances of the application get more people into the chat room. Also notice the server making the logs as well as the earlier clients getting a message that someone else has entered

chatlogfillsup

Some test messages to fill the chat log up and show that all clients are receiving the messages

namechange

Now let’s try a name change

namechangecomplete

And there we go, the chat room is told about the name change and the user list is updated for everyone and the servers log acknowledges it.

personleaves

When someone leaves, they go back to the login screen (unless the left via the X in the corner, though the server still knows they’ve left and can tell everyone!). As you can see, the other clients see that the user has left and their user list is updated accordingly

everyoneisleft

Eventually, everyone leaves and alls you have is a server console full of the entire chat log!

Improvements that can be made are to allow each user to pick font options such as type face, colour, emphasis options such as bold, italics, underlined, etc. Another improvement would be to include emoticons of some sort.

If you want the source code to this, please email me at the address specified on my C.V.

Pizzeria (WPF, C#, Design Patterns)

Another WPF C# .NET project but for this one, the focus isn’t on WPF but rather the use of design patterns.

I had learned about them at University but only ever found myself applying a few of them. Now obviously you should only use a design pattern when the occasion would benefit from it but still, I didn’t like the fact that useful design patterns were fading from my memory because you never know, I might need them one day!

So I revised the common ones – specifically the ones in the Head First Design Patterns book. No offence to the “Gang of Four” but their design patterns book isn’t all too exciting to read as it’s not meant to be but it does mean that it can be a little more difficult to follow at times.

Going through the Head First book I couldn’t help but really enjoy the decorator pattern and it gave me an idea of a small simple project that uses it. The usual examples of decorator usage are a Starbucks-like cafe or Subway-like restaurant where you can really customize your order but I figured I’d go with a Pizzeria where you can choose a base pizza and add any number of toppings you want…yes…this is something that all Pizzerias do (well, at least most of them) but still, it’s the decorator design pattern in use!

One problem that the decorator design pattern introduces is that there’s a large number of small classes which means that some central class (where a lot of instantiation occurs) will be coupled to a large number of classes so I also decided to employ another design pattern – the factory method pattern. So instantiation is encapsulated elsewhere and my Pizzeria class only needs to know that it’s something of base type Pizza or PizzaDecorator abstract classes, it doesn’t need to know anything about any of the concrete classes.

As with all my projects, I am no artist and so please judge my work on its functionality as opposed to looks! Because for this project…my inability to draw is really showing! as you’ll see with the amazing pictures soon. Yes, the ham is just a pink diamond. Yes, it took me about 10 mins to draw it all. No! it wasn’t done in ms paint…it was done in paint.NET!

The whole decorating and factory-based instantiation is done from a class library dll so this can be used in any other application too, as shown in one of the pictures (the WPF application is just the front end). From the class library, you can create pizzas, decorate them with as many extras as you want in any order and you’ll be able to get a string description of the entire decorated object as well as its full cost by just calling two simple functions: GetDescription() and GetCost().

Also, as you add decorations to your pizza, you can also choose to remove them if you wish, in any order and the decorated pizza will be reconstructed properly. I think this is a nice addition as “undo” actions are typically a pain to do with the decorator pattern, specifically undo-actions that can occur in any order — one of the patterns disadvantages.

startScreen

The initial starting screen. Notice how the extras are not selectable yet as you need to choose a base pizza first. The new order button resets the app back to its initial state and the order button finalizes it all, as long as you’ve selected at least a base pizza (in which case you’ll get a warning!)

selectedBasePizza

Once you’ve selected the base pizza, the undo-able list on the side starts to fill and the total cost starts being calculated

SelectedFirstExtra

After selecting a base pizza you can start to add extras. Whereas you can have only 1 base pizza, you can have as many extras as you want

SelectedTooManyExtras

However, I think this is too much bacon so let’s try clicking on the X button to some of the bacon extras in the list

RemovedSomeBacon

Better! notice how in this pic and the previous ones that when we added (or removed) extras, the total cost was all re-calculated correctly, but just note – the app in the background is only seeing a single instance of an abstract base type and nothing more.

PressedOrderButton

Clicking on order unfortunately doesn’t actually order a pizza for us, it does however utilize the GetDescription() method that each decorator instance can cascade down to the base pizza instance. There’s only one item, a decorated one, yet we get the full description and price of all the decorations and base pizza added together.

consoleVersion

The WPF application is actually just the front end, it uses a class library I made which can be used in any .NET application type, shown here is the code working in a console application

One improvement I would make is that currently you can only order 1 pizza at a time. In a more realistic application you would be able to order and customize many pizzas that are added to a “basket”. However, this is just a case of making the functionality of this app into some inner functionality of another app that repeatedly uses this app’s methods and data structures, alongside a list structure for the “basket”. So it wouldn’t be too difficult but it also wouldn’t be showing off design patterns which was the intent of this project.

If you wish to have the source code for the project, please email me via the address listed on my C.V.

Flickr App (Android, JSON)

The second Android app, following the Quiz app post a few days ago and this time it’s an app that uses the Flickr API.

Here’s an overview of which features of Android were used in making it:

  • Use of AsyncTask and HttpConnections and in/out streams to do the initial networking and using the Flickr API to get the most up to date JSON data of the search results
  • Use of background threads with Threads, Thread Loopers, Message Queues and ThreadHandlers to, alongside the information downloaded from the AsyncTask, download the actual photo information needed. And response handlers to send messages back
  • Data needed to download via the above stuff is parsed via the JSON classes
  • Background Services to run a polling service to see if there are new photos, specifically an IntentService
  • Notifications to tell the user there are more photos to see
  • The service uses the AlarmManager to set an inexact-repeated firing of the service method
  • Uses a recycler view to display the results along with corresponding holders and adapter and uses the grid layout manager
  • Reacts to differing screen sizes, using the ViewTreeObserver, it sees how much space there is available and decides on the number of columns that the grid recycler view uses
  • Uses a LRU (least recently used) cache to store 100 of the last image thumbnails downloaded so when you scroll through the list, it isn’t continually re-downloading the images
  • Uses shared preferences to store and help pass certain information around the app such as the persistence of the search query
    • Uses a class to encapsulate all communication to/from the shared preferences
  • Uses a standalone “startup” broadcast receiver that listens out for the boot completed broadcast intent so that if the service was running when the device was switched off, it will automatically be restarted when the device is switched back on
  • Uses dynamic broadcast receivers and a custom private broadcast intent in order to filter out the notification of new images if the app is already running
  • Clicking on one of the pictures will load the picture’s page on the flickr site itself so you can see a larger version of it and see other information
  • Uses menu items and actionbar
    • uses a switch for toggling the polling on/off although annoyingly, Android have designed it so that the text won’t show for this widget even with the “always” showAsAction, although using that value isn’t recommended either
  • Uses a swipe refresh layout for the fragment so pulling down when already at the top will reveal a refresh icon and if you let go, the results will be refreshed and new pictures (if any) will be shown alongside the old ones. For reasons of accessibility, there is also a refresh menu item that does the same job in case the user has trouble with gestures
  • Action bar contains a spinner drop-down list of presets with the default being kittens, I just randomly chose a list of tags that return cute pictures but they could have been anything really. Spinner uses an array adapter and contents are loaded from a string-array resource

There are some things that Android can do that appear on neither the above list or the one in the Quiz app post but I feel I should mention that although not everything was used, there are still many aspects of Android I am capable of and just simply didn’t see a good enough reason to use them in the two apps. These includes Toasts, XML drawables, Property Animations, the Transitions framework, Custom view and many other simple features.

Now for the pictures, as always remember that I’m no artist so please judge them based on functionality, not appearance. Click on the images for larger versions.

What the starting screen might look like for you. Default option is kittens!

What the starting screen might look like for you. Default option is kittens! The spinner is a drop down list of preset search terms, the search view is for searching for anything you want to, the switch is for polling for new items matching your current search term (either the selected one from the drop down list or your own typed search)

As you scroll down, the images will be downloaded on the fly, showing a placeholder image until the download is complete. Once downloaded, the image is placed into an LRU cache so scrolling back up will not incur another download

As you scroll down, the images will be downloaded on the fly, showing a placeholder image until the download is complete. Once downloaded, the image is placed into an LRU cache so scrolling back up will not incur another download

Each page holds 100 results so eventually you'll reach the bottom of the list where you can select the prev/next buttons to switch between pages

Each page holds 100 results so eventually you’ll reach the bottom of the list where you can select the prev/next buttons to switch between pages. If you’re on the first or last available page, one of the buttons will be greyed out and unusable

There are other presets too in a drop-down list ("spinner" in Android parlance). Selecting one of these will change the search query to something new.

There are other presets too in a drop-down list (“spinner” in Android parlance). Selecting one of these will change the search query to something new.

Just like so!

Just like so!

You can also search manually by clicking the search view button, you can actually search for anything on Flickr with this, it doesn't have to be something cutesy

You can also search manually by clicking the search view button, you can actually search for anything on Flickr with this, it doesn’t have to be something cutesy

One thing I've learned with Flickr though is that you don't always get what you asked for! Searching for chinchilla will bring up pictures that people have tagged as chinchilla and as I learned today, "chinchilla" isn't *just* the name of an animal

One thing I’ve learned with Flickr though is that you don’t always get what you asked for! Searching for chinchilla will bring up pictures that people have tagged as chinchilla and as I learned today, “chinchilla” isn’t *just* the name of an animal

There are extra options, they do as they say on the tin. One thing I forgot to take a picture of though is the swipe refresh and in the picture above is the alternative way of refreshing - via menu item

There are extra options, they do as they say on the tin. One thing I forgot to take a picture of though is the swipe refresh and in the picture above is the alternative way of refreshing – via menu item

Clearing the search completely is the same as searching for all pictures on Flickr so it's a way of seeing the latest pictures

Clearing the search completely is the same as searching for all pictures on Flickr so it’s a way of seeing the latest pictures

Switching polling on in the app and turning the app off will send notifications to your phone when your last search query has new results. Clicking the notification then opens the app and shows these results.

Switching polling on in the app and turning the app off will send notifications to your phone when your last search query has new results. Clicking the notification then opens the app and shows these results.

As always, code is available by contacting me via the email address on my C.V. and/or application.

Quiz App (Android, SQLite, JSON)

I started learning Android a short while ago and have decided to showcase two apps that show a large amount of Android features. The first is a simple quiz app that doesn’t look like much but does in fact utilize many of Android’s capabilities and demonstrates the following:

  • The use of fragments hosted by activities and the FragmentManager to make for a more modular, flexible UI
  • The use of the support library to allow for backwards compatibility
  • The use of assets and the AssetManager
  • The use of the SoundPool to efficiently load, store and play short sound effects
  • The use of the MediaPlayer to play background music
  • The use of Dialogs (specifically AlertDialogs) to display certain information to the user
    • The text shown in the dialog is also formatted so the keywords are shown in bold
  • The use of the JSON classes to load in the questions that have been stored in .json format
  • The use of the SQLite classes to store player records in a database
    • SQLiteOpenHelper for creating the database
    • CursorWrappers for iterating over query result sets and extracting the relevant information
    • ContentValues for changing the relevant information from the in-package PlayerRecord type to a type that the SQLite database can use
    • A schema class to hold the outline/description of the tables
    • And of course, the SQLiteDatabase class itself
  • The use of the BitmapFactory class to load in and efficiently rescale images to be shown in the ImageViews
  • Fragment Arguments to pass data to and from the fragments
  • Intents to launch any camera apps found on the device
    • Implicit intent sent with a result code as I expect a result back, meaning I also use onActivityResult(…)
  • The use of RecyclerView to efficiently show a list of items
    • And in turn, ViewHolders and a RecyclerView Adapter
  • Fragment callback interfaces
  • And other simple stuff such as using resources properly (e.g. string resources), inflation of views from layout files, use of relevant views such as EditText, ImageButton, ImageView, TextView, use of relevant listeners, use of relevant life-cycle methods, saving state correctly during a device configuration change (such as rotating the screen) and so on and so forth.

In the next project, I’ll show an app that utilizes many of the other features available in Android such as services and broadcast receivers.

As for a quick overview of the app itself, the questions are made to throw you off but the more you get right, the higher you score will be. 1 point for each correct question plus your current combo bonus will in turn will also go up by 1 for each question you get correct in a row. I ask just 10 questions as it’s simply a prototype but a real app like this would have 100’s if not 1000’s of questions.

Music in played in the background and if you get a question correct, you’ll hear a ding noise, if not then you’ll hear an audience groan noise followed by a dialog explaining why you were wrong. After the 10 questions are asked, you’re whipped away to the score submission screen where you will be shown your score, the date you finished the quiz and the option to enter your name and optionally take a photo which will all be then submitted to the database (only the string path of the photo is stored in the database). You’re then shown the high score list screen which is a list of all the other player’s info (name entered, score, date, optional photo).

A real version of this app would have more features such as a main menu for one thing! But it’d simply be a screen with a small number of buttons, one to start the game, one to view the highscores and one to quit the game. It would be very trivial to implement compared to some of the features in this prototype so there’s simply no reason to actually implement it here.

Last but not least, as I’ve mentioned in many of my other projects – I am definitely not an artist and it will likely forever be that way! so please, judge the app based on it’s functionality and not its appearance :) In a real production, I would handle the functionality but someone a lot more creative than me would take that functionality and make it look better.

Click on the pictures to see larger versions

What the app looks like at the start - except you may have a different first question of course!

What the app looks like at the start – except you may have a different first question of course!

The second question after getting a correct answer, notice the combo score increasing so if you get the next answer correct too...

The second question after getting a correct answer, notice the combo score increasing so if you get the next answer correct too…

The combo score goes even higher!

The combo score goes even higher!

Get a question wrong and you'll lose your combo bonus and be told why you were wrong. Pictured here is one of the more pedantic answers

Get a question wrong and you’ll lose your combo bonus and be told why you were wrong. Pictured here is one of the more pedantic answers

After all questions are asked, you are taken to this screen where you can submit your data to the high score list

After all questions are asked, you are taken to this screen where you can submit your data to the high score list

Even take an optional picture if you want. If you run the app on a device that doesn't have a camera, the option will be automatically greyed out.

Even take an optional picture if you want. If you run the app on a device that doesn’t have a camera, the option will be automatically greyed out.

The high score list, using a recycler view

The high score list, using a recycler view

As with all my work, if you want the code then send me an email to the address on my C.V.

Also, since this used other people’s work (the sound files) then I will give credit here

Connect 4 (WPF, C#, XAML)

Next on the todo list was yet another board game! This time it’s Connect 4. In terms of features I guess it’s very similar to the other posts; the board game logic itself was separated out into a class library .dll file so it can be used for whichever frontend, it uses styles, bindings and the other usual good XAML features to keep it all clean and simple. Also like all my other projects…I’m still not an artist, although I am quite proud of the little complex shape of the coin + slot combo made using geometry groups and a mixture of combined geometries with differing combine modes.

One thing I will be honest about is that I originally planned to just have it 2 player and then near the end I decided to implement some AI. A quick bit of research later and I found that to implement what I wanted (an AI that tries for the optimal game) would require the backend to be represented as a tree/graph which makes sense since negamax and alpha-beta pruning are the techniques and they work on trees & graphs. At this point it was too late to change the backend representation without a lot of reworking so I had to ditch the idea in favour of an “easy” AI that picks a random free column.

So the lesson I learned here was to plan the entire thing beforehand! and definitely don’t make any large last minute decisions!

Edit: Bah, and once again I’ve forgotten to set up an icon for the application! curse you .ico files!

Truly a face only a mother could love

Truly a face only a mother could love

connect4_2

As with all my projects, I’ll gladly send the source code to you if you are a company I have applied for, just send an email to the one listed on my CV.

Tic-Tac-Toe (WPF, C#, XAML)

To go along with the other WPF projects I wrote about recently, I’m going to do a few simple games starting off with TacTacToe.

You can play versus a friend or versus the computer which has two difficulty settings; easy where it chooses a random spot and hard where it will mostly follow the “perfect game” rules. I say mostly because my original implementation followed all the rules exactly and it made it almost impossible to win. If the AI went first, it would win unless you were good at blocking potential forks and if you went first you would always end up with a draw. So I loosened up the difficulty a bit but it’s still difficult! :)

So I guess the features of it are:

  • AI
  • Customer converter – because I wanted something to be disabled when something else was enabled and you can’t do expressions in binding statements! so I create a custom converter to flip the boolean values in a binding
  • Board and AI logic separated into external dlls so they arent coupled with the WPF code (and in turn was used to make a console version of the game)
  • An actual menubar with menu items instead of a billion buttons – a world first for me

As with many of my projects, it really shows that I am no artist so I definitely won’t be winning any awards for looks (both the program and me the person :( ) so ignore how ugly it looks! (both the program and me the person :( )

One thing to point out though is that for some reason my screen recorder (OBS) doesn’t capture menus…so you can’t even see them so below the video will be pictures of them.

tictactoeOptions1 tictactoeOptions2