Home » Design Patterns

Tag Archives: Design Patterns

Design patterns in game development: parsing OBJ files

Today we will take a look at a common task in game development: parsing asset files – from a code design standpoint. Using the example of Wavefront OBJ files, we will explore the usefulness of thinking about our code using design patterns. Our goal will not be to use design patterns to create code. Instead, I would like to highlight ...

Read More »

The Ugly Truth about Emergent Design

If the 2nd D in TDD is design, then we’re talking about emergent design. The tests drive the design, which emerges from thin air, and step by step reveals itself in all its glory. Emergent design has got to be superior to upfront design, right? Well, it depends. If we’re doing a design up-front, we need to take into account ...

Read More »

Documentation regarding TAP – Task-based Asynchronous Pattern

Last week we saw the TAP – Task-based Asynchronous Pattern, which is the recommended new approach for asynchronous programming in the Microsoft .NET Framework. This week I want to show you some sophisticated MSDN topics about asynchronous programming in general and the TAP in particular. Custom Partitioners for PLINQ and TPL – Learn: How data is divided into partitions or chunks ...

Read More »

Your DI framework is killing your code

I read a really interesting post recently looking at the difference between typical OO code and a more functional style. There’s a lot to be said for the functional style of coding, even in OO languages like Java and C#. The biggest downside I find is always one of code organisation: OO gives you a discoverable way of organising large amounts of ...

Read More »

Documentation regarding the Asynchronous Programming Model (APM) and the Event-based Asynchronous Pattern (EAP)

The Asynchronous Programming Model (APM) and the Event-based Asynchronous Pattern (EAP) are marked as legacy by Microsoft. The new pattern is called TAP – Task-based Asynchronous Pattern. So there is a lot to learn again. In this weekly MSDN Dive I want to show you some very interesting documentation and resources regarding parallel programming in the Microsoft .NET Framework. Parallel ...

Read More »

How to fake a singleton in C++

When unit testing legacy code I find several (anti) patterns which prevent getting code under test. The most recurring pattern I see is the Singleton pattern – a useful pattern when not abused and overused. In the object oriented world Singleton’s are slightly better than their evil cousin – the static method. Unfortunately I’ve seen them used to break encapsulation ...

Read More »

Buffer Allocation Strategies – Explaining the solution

In my previous post, I threw a bunch a code at you, with no explanation, and asked you to discuss it. Here is the code, with full discussion below. [ThreadStatic] private static Stack<byte[]>[] _buffersBySize; private static byte[] GetBuffer(int requestedSize) { if(_buffersBySize == null) _buffersBySize = new Stack<byte[]>[32]; var actualSize = PowerOfTwo(requestedSize); var pos = MostSignificantBit(actualSize); if(_buffersBySize[pos] == null) _buffersBySize[pos] = ...

Read More »

User experience on the main path–get it or get lost

The background for this post: Recently I got an email from a startup founder about a service that they are offering. It so happened that this service matched something that I was actually considering doing, so I was very happy to try it out. I registered, and on two separate occasions I attempted to use the service for its intended ...

Read More »

Detailed frame-time performance measurement

Performance has always been an important aspect of game development. From the early days, where the processing power of hardware was extremely limited, to this day, where we may want to simulate hundreds of thousands of particles at once. There are many ways to achieve good performance – and thus providing a better experience to the player. From following best ...

Read More »

Foolproofing code, and incentives

After my post on accessing game objects by unique ids last week, I was asked whether it was not potentially harmful to allow objects to create their own identifiers. With this follow-up post I would like to discuss that question in more detail. Limiting identifier construction As was pointed out, my solution in last week’s post did not circumvent the ...

Read More »