I was just aiming to simplify the idea, but I failed to elaborate more into the example, as I just wanted it to be simple. My bad.

... ?

No one is arguing that you didn't go into enough detail. We just pointed out some fundamental flaws in what you posted.

By the way: You should never, ever typedef a pointer. That's an unnecessary level of indirection, and it's something that has no place in your example, because you're not even using it anywhere.

posting bad code as a recommended solution isn't the best idea

Well, yes, but on the other hand, you can't really blame people for not knowing any better.

They think they're posting code that is appropriate from one perspective or another, so they post it, because they want to help. I think that's fine, as long as there are other GameDev members who can point out the flaws, and keep everyone informed.

Actually, typedef'ing pointers is common in game industry, smart pointers that is.

I would still argue against it: It's something that carries certain benefits, I'm sure, but it makes code more difficult to read, because now I have to look for what opaqueDataType actually represents.

Actually, typedef'ing pointers is common in game industry, smart pointers that is.

I would still argue against it: It's something that carries certain benefits, I'm sure, but it makes code more difficult to read, because now I have to look for what opaqueDataType actually represents.

If I just have SDL_Surface*, it's immediately clear.

I think it's only a matter of getting used to it. There is no apparent reason for typedefing SDL_Surface* but if your pointer declaration looks like "shared_ptr<SDL_Surface>" or something longer, then it can be a bit frustrating to rewrite it every time, so why not just typedefing it to "SDL_Surface"? Then, as a matter of good practice, you can add a "p" before the pointer declaration (for example "pSurface"), so there is really little room for mistake.

To end my misfortunate and bad example code of a game engine, I'll go back and edit to better suit a problem.

As for type defining an SDL_Surface *, I always do it because it's easier and faster to write out

LOAD SDL_LoadBMP("image.bmp")

than it is to write

SDL_Surface* LOAD = SDL_LoadBMP("image.bmp")

.

I would hope others see the time-saving benefits of using a typedef at times, aside from other use.

Now I'll go and fix what I poorly wrote out.

Your comparison is flawed. It should be:

SDL_Surface* image = ...
// vs
LOAD image = ...

It's a virtually inconsequential difference, in terms of length. But even if it wasn't, SDL_Surface* is far more descriptive, and should therefore be preferred.

Anyway, I wouldn't recommend changing your previous posts; they're supposed to serve as examples of what others are not supposed to do, so just leave them as they are. If you want to show some more code for us to review, make a new post/thread, and we can take it from there.

There is no apparent reason for typedefing SDL_Surface* but if your pointer declaration looks like "shared_ptr<SDL_Surface>" or something longer, then it can be a bit frustrating to rewrite it every time, so why not just typedefing it to "SDL_Surface"?

I would ask if a shared_ptr is truly necessary? Maybe that part of the system could be written in a higher-level language (one that comes with a GC).

In either case, I think that "typdefing a pointer to save a few keystrokes" is fundamentally wrong. Unless you have really good architectural reasons for doing that, you should find a better text editor that can automate those "too long to type" situations.

In either case, I think that "typdefing a pointer to save a few keystrokes" is fundamentally wrong. Unless you have really good architectural reasons for doing that, you should find a better text editor that can automate those "too long to type" situations.

It's a matter of aesthetics. The code is also more readable, which can save you some time when debugging - that's what typedef was made for.

Ugh. The amount of time spent typing in a program is less than 1% of a product's cost. Don't risk the incredible added cost of debugging or patching code errors caused by useless typedef garbage that saved you a few seconds.