Wednesday, November 28, 2012

Why use Interfaces in Object-Oriented Programming (OOP)?

Previously, we looked at what interfaces are, and how some languages provide an Interface type, allowing you to formalize the exposed parts of your classes. Today we're going to consider the problems that an Interface type is designed to solve.

So, why would you want to use an Interface?

Interfaces give you polymorphism that's unshackled from any inheritance hierarchy.

Now, polymorphism is one of those

Tuesday, November 13, 2012

Leeds' Reads - Game Coding Complete

You know you wanna make a game.

Like all good kids, I loved playing video games when I was growing up. Mario, Link, and Mega Man all have a special place in my heart. But being a bit of a dreamer, simply playing video games wasn't good enough for me. I wanted to make them. And that's what got me into this whole computer programming business to begin with. I probably programmed dozens of homemade video games in GW-Basic and QuickBasic growing up, and, of course, gave up on many of them before they were done.

Although I'm not a professional game developer, I'm fascinated by the art, because it solves unique problems and pushes technological bounds as far as they can go. But most of the game programming books out there are introductory level only, and don't explain anything about the full architecture of "real" games. And that's where Game Coding Complete comes in!

Wednesday, November 7, 2012

What are Interfaces in Object-Oriented Programming (OOP)?

Interfaces in the Real World

Before we dive into OOP, let's think about interfaces in the real world.

This is an interface:

Light Switch

This is also an interface:

Manual Transmission

And, so is this:

Door Knob with Keyhole

These are all interfaces that allow me, an external consumer, to interact with the system behind it.

  • The light switch is the interface that allows me to turn a light on or off.
  • The gear shift in my car is the interface that allows me to interact with the transmission. (Yes, I’m a manual transmission guy!)
  • The keyhole is my interface to the locking system of my door. It's what I interact with in order to lock or unlock my door.

It's important to notice that,

Profile Picture
Dave Leeds
My Hobbies:
  • Programming
  • Cartooning
  • Music Writing
Full Profile