Building Mobile Games: Building a garage (DLL) for your stuff (classes)

Now that is a great title: Some more stuff.  Well that is what the blog is about: Stuff. 

Game stuff, to build a game, it is a good idea to understand the concept of DLL and classes.  DLL stands for Dynamic Linking Libraries, which is a library that contains classes that you can reuse.  DLLs are an important concept in object oriented programming, yet when I talk to students, there is often confusion about DLLs.  In this blog, we will create a simple DLL that works in both Windows 7, Vista and the like, as well as on a Microsoft mobile device.  What this blog entry won’t do is show the concept of interfaces, for that watch for a later blog in my random universe.  More on Interfaces can be found at Interfaces (C# Programming Guide) and MSDN Webcast: Architecting .NET Solutions with VB.NET

 

Think about DLLs as a storage place for your classes.  Other programs can call your DLL if you set up your DLL to be able to work with other programs.  This is the case for the many Windows DLL and for the system DLL.  You reference these programs in your program by setting references in the project IDE, there are other ways you can reference them as well.  image

In the past, DLL suffered from a problem when the contract was broken by another program.  In .NET this was overcome by the use of assemblies.

Why use DLLs?  In a game, whether you are running it on the XBox, Windows or a Mobile device, you can modularize your program.  For example you could use a DLL to provide a physics solution for an XBox game, then you could reuse it with a Silverlight based game, and you might reuse in a game that works on a Mobile device, although it will have to allow for certain constraints with the Compact Framework.

The concept of DLLs is used both in Windows programming as well as Linux, see Anatomy of Linux dynamic libraries.  In the next posting I will work through a simple creation of a DLL and then use of the same DLL in several different types of projects.

 

Technorati Tags: DLL,Dynamic Linking Libraries,Linux Dynamic Linked Shared Libraries