Work and... Checkers?
By: Negafox On: 09/01/2007 09:57:08 In: Programming
My department at work last week required several employees including myself to take a pseudo-programming test. Our task was to write a checkers application in under four hours in any language of our choice to be reviewed by the senior programmers. Sounds like fun, no? Some more senior programmers on the team surprisingly went some inefficient routes with their computer AI and system checks (i.e. brute force methods). I wrote mine in C# without the use of the ArrayList class to create somewhat of a challenge.

A few notes about my design:
  • Most employees, if not all, wrote theirs as a command-line application. I decided to write mine as a Windows application with a click-to-move interface.
  • The players and checker pieces were given their own classes to contain the data.
  • A two-dimensional pointer array for the checker pieces to act as a quick lookup table for player locations, as well as the location as within the checker class itself. This helps to improve performance for some validation functions.


Unfortunately, some features were abandoned in the final product due to time constraints. With only four hours to plan, write, and debug the application, a few features were pulled such as menus to customize the board size, rules, and toggle click-to-move or computer AI for each player, plus DirectX support was abandoned as well.
Database Optimization - Data Types
By: Negafox On: 05/08/2007 19:41:13 In: Programming
The trend with database design has been to use generic data types such as date, float, or int in tables.  For the sake of this discussion, I will use Microsoft SQL as an example for database optimization.

Unfortunately, the design approach to use generic data types despite the original intention leads to larger column widths than necessary.  For example, many modern applications use the int (Integer) type for many columns to store numerical values with only a few to a hundred possibilities.  A database administrator or developer should consider using the tinyint data type for columns that will rely on enumerated values and shortint for dynamic values that will marginally increment over time.  The int (Integer) type is 4-bytes wide when tinyint or smallint data types can be used instead which are only 1 or 2 bytes wide and can contain values up to 255 or 32,767.  Reducing the number of bytes read or written to or from the database will marginally improve performance – particularly noticeable for large database queries.  Additionally, for columns containing dates and/or times with limited precision to the minute, the smalldatetime data type is only 4 bytes instead of 8 bytes, which would reduce the column width by half.  The smalldatetime data type is useful for columns such as hire dates or creation dates for blogs.

When designing tables for a database, one should consider using the smallest data type possible while leaving enough slack space for future growth.  Such database design will optimization query performance while still considering future expansion.