Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm undecided on a design decision. Now for my game I was thinking on splitting components into separate dlls. This would allow for a more modular approach, especially when in need of updates. On launch it [the game] could swap out newer versions of the dll coming from a centralized server. This would allow us to provide updates to each component separately and also allow us to quickly swap dll's for different implementation.

Now is this design used, and how effective is it?

I started implementing it, and loading a dll through run-time ads a lot of complexity (unless i'm doing it wrong). Another problem that could arise is some components are optional. So it would ad additional complexity.

So what i'm trying to get to is: Is splitting separate components and subsystems in dll's?

This would allow the exe to be a lot smaller, and possibly make the whole system a little more organized.

share|improve this question
1  
Instead of doing all the run-time loading, why not just use dll's and provide an updater that will replace the required dlls when an update is available? –  cli_hlt Jul 13 '12 at 11:32
    
Generally its a good idea to seperate stuff and put them into different libraries. However, DLLs can be a real pain when it comes to static template member variables and resource managing. For instance, you will not be able to write to a file using a FILE* pointer that was created in the DLL and used in the client-exe or another DLL. The same is true for instance for memory allocations, you cannot allocate in one DLL and free it in the exe or another DLL. I'd go for static libs. –  Maik Semder Jul 13 '12 at 15:28
    
@cli_hlt Yes that was also the plan. When the game first loads we would make a simple tcp connection to the server and check an xml file to see if any dll's require updating. Maik Semder Ahhh. With that statement I think i'll choose a different option rather than dlls. Maybe put your response as an answer so I can accept it? –  Daniel Jul 13 '12 at 22:45
add comment

1 Answer

up vote 2 down vote accepted

It is not used by any game engine I've ever heard of, and I would strongly recommend against it.

All of the theoretical advantages of the model are red herrings. Smaller executables don't matter, the whole size of the loaded game matters, and an exe+dlls is larger than the same code all compiled into the same exe.

Libraries dont organize code. Your file structure (naming, folders, namespaces, etc) organizes your code. Use libraries for technical purposes, not to get around a lack of knowledge on how to use Visual Studio filters properly. One good reason to use separate static libs in Visual Studio is to use different sets of precomputed headers, for instance.

Updating via DLLs is also not a good use of time. The DLLs are going to be tightly tied to the specific version of the EXE being run an probably to the other DLLs as well (components have dependencies on othe components).

Reloading DLLs is not a good idea, either, for similar reasons to the previous point. Plus, reloading the DLL means you have tO unload all data it's using, serialize it somehow, reload the DLL, then unserialize the old data.

As others pointed out, there are many complexities and limitations of using separate DLLs. Given all those costs and a complete lack of any real benefit, there's just no reason to go that route.

As a final note, remember that the compiler can't optimize across DLL boundaries. Your game will be much slower than if you compile everything into a single EXE with link-time code generation turned on.

share|improve this answer
    
That makes a lot of sense. Even starting to split into dlls was starting to add a huge level of complexity. So I think i'll stick to regular folders, namespaces, etc... Thanks. –  Daniel Jul 13 '12 at 22:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.