Okay, so the next stage, I’m going to need some data in order to do stuff. I’m going to create three DLLs, all class libraries. They are:
- OscarsNight.Interfaces – The interfaces for the services and the business objects.
- OscarsNight – The actual implementation DLL, with some data access stuff. I think I’ll use Entity Framework for that.
- OscarsNight.Tests – A testing DLL that tests the implementation.
Business Objects
For the business objects, I’m going to create two sub-namespaces, one each for Game and Hollywood types.
Data Types
For the most of the data types, I’m trying to stick to primitives. This is hard when it comes to the images. The image fields need a data type, but what to use? ImageSource would work great in general, but that presumes WPF or Silverlight. I might want to use it elsewhere. I could use an System.Drawing.Image, but that’s hard to use in WPF sometimes. So I think I’m going to aim for something more … agnostic. My leading choice at the moment is a Stream. Easy to load into any of display systems and non-preferential between them.
Game Types
I added a player type that’s similar to that defined in the data. For guesses, I’m a little dubious. You can guess either a movie or a person, depending on what category it is. I could create a couple different methods to take the different type of things you can guess, but then I’m toggling in code. I could have them pick a Nominee, but I’d really like to not expose that table if at all possible. The best initial thought I have is to create an interface for things you can guess and so, we now have an IGuessable.
Hollywood Types
There’s not much of a way I can get away without creating Category, Movie and Person types. Actor and Nominee tables I don’t really want to expose. I can just use the Person type for Actor table. For the Nominee table, I can use either Movie or Person, since I now have the IGuessable interface.
So it’s at this time that I realized that I was missing a type. One silly category, Music (Song), is different. It has songs instead people attached to it. I thought about being a cheese-monkey and just using the picture, but two of the three songs are in one movie, so I have to have a new type. I considered for a brief second putting them in the Person table with a flag, but decided against it.
Services
So for the services, I’m going to generate two, one to return game information and the other to retrieve movie data.
IGameService
The game service should let them add and remove players, and to have them guess or clear a guess.
public interface IGameService {
IEnumerable<Game.Player> Players { get; }
void AddPlayer(Game.Player player);
void RemovePlayer(Game.Player player);
void UpdatePlayer(Game.Player player);
void ClearPlayers();
void Guess(Game.Player player,
Hollywood.Category category, Game.IGuessable guess);
void Guess(Game.Player player,
Hollywood.Category category, Game.IGuessable guess, double multiplier);
void ClearGuess(Game.Player player, Hollywood.Category category);
void ClearGuesses(Game.Player player);
}
IHollywoodService
The Hollywood service is very basic, it just exposes data. Since the objects are interconnected, its very easy in its interface.
public interface IHollywoodService {
IEnumerable<Hollywood.Category> Categories { get; }
IEnumerable<Hollywood.Movie> Movies { get; }
IEnumerable<Hollywood.Person> People { get; }
IEnumerable<Hollywood.Song> Songs { get; }
}