• entries
    205
  • comments
    228
  • views
    112808

Time for a patterns book

Sign in to follow this  
Mike Bossy

63 views

So I've been diving back into my unit testing when I realized that I have a bunch of platform specific classes that really don't need to be.

I have a bunch of manager classes that essentially act as a loop. I have the physics manager that processes physics updates for a scene, an animation manager, etc. Since they are all working in parallel in my multithreaded engine I needed to protect certain assets from getting trampled so I used a few mutexes to do it. It's really simple, straight forward and works great. The only real problem is that mutexes are platform specific. I tried to work around this problem by creating a wrapper class which gives me a level of abstraction that my managers don't need to know anything platform specific. They just have a member which is a pointer to a mutex that they can use

Where I was asleep at the wheel was in how I gave the manager a mutex object to use. I ended up have a platform specific manager class that was derived from the base manager class and created the mutexes in the constructor when all I really had to do was pass the mutex into the contructor of the base class. This saves a level of inheritance and more importantly managing another couple files in my source tree.

How did I miss something so simple? Well I know I get heads down into work sometimes and need to take a step gack to see if my great ideas are just complex ways to solve a simple problem. I'm getting better at doing that on a regular basis. The other thing is that I really have never done any real reading on patterns.

When I went to school we learned C++ but OO design was still pretty much a pipe dream. Everyone still approached things from a functional perspective. There were no classes on patterns and refactoring wasn't in the comp sci vocabulary yet. So maybe it's time to invest in some reading around refactoring and patterns. Might save me some wasted time.

JasonZ: I'll do a post this weekend on how I implement my unit tests and the tools I use for it. It's totally worth the effort once you get it up and running.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now