• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

BASSOFeeSH

How far do you really go with OO techniques?

4 posts in this topic

For instance, lets say I have the following: class CSound{ public: LPDIRECTSOUND lpds; int rate; ..... ..... }; Now if you were to follow OO standards, lpds and rate should be private members and you would have to include getRate() and getLPDS() functions. I am just curious if anybody really does this in games, or if you just leave members public to save on more function calls. I would think that in this context, the overhead would not be justified for just returning a member. Just curious how the masses get things done. "Why am I the only one on the away team with a red shirt!?" BASSOFeeSH ><>
0

Share this post


Link to post
Share on other sites
Normally, I wouldn''t expose a class to the global program. I would have an abstract interface, and then have the class implementation derived from there.

When i implement such an class, I have to consider, is it a class that can and will operate on its own? Are there any other classes needing it? If there is, are they similar in logical functionality?

Meaning, if I have a SoundManager, that loads and even duplicates the sound, I would consider them as one logical package. Thus, it is ok to have these member as public, because this is a developer implementation detail. However, take care not to have too many classes or over bloated classes in the package, or maintance would be nasty and encapsulation is definately needed
0

Share this post


Link to post
Share on other sites
One small thing to add: GetWhatever() calls don''t impose any overhead if you inline them. Generally though, you should design your classes to be good enough that you''d rarely need to get to the inside.

--TheGoop
0

Share this post


Link to post
Share on other sites
If you want to be strict to OO, but the data members are frequently used by other functions and class and you want to make them all public just make it a regular struct, or if it makes since based on what the object is to make it all public, use a struct. structs in c++ are almost the exact same thing as classes except in structs, the default is public.

Usually, when I encapsulate things in classes, I make all the data members private.

Edited by - Domini on 2/2/00 5:23:25 PM
0

Share this post


Link to post
Share on other sites
Get and Set functions != good OOP design. What you want to hide is data that is private to a class (that the user doesn't care about). Providing get/set functions for everything can actually break encapsulation and OO design by allowing the end user (programmer) access to stuff they shouldn't have.

Using get/set for LPDIRECTSOUND lpds actually breaks encapsulation. The idea is to seperate the interface (what the programmer uses) from the implementation (how it gets done). The end user (programmer) doesn't care that you're using directsound.

What you should do is make LPDIRECTSOUND lpds a private: member, and then have public functions like initSystem(), loadSound(), playSound(), setVolume(). There's really no reason that anything using the class should have direct access to the direct sound context. That way if you switch to a different sound library or a different platform, you rewrite the internal stuff and the code that calls it will work the same on Mac Linux or whatever else doesn't have directSound.

I'm going to get flamed for this, but you don't even need get/set functions for the rate, depending on how you use it.[Please refer to the get/set sections on the C++ FAQs before flaming] For some reason people think that if it's a public variable and not a class you NEED to use get/set functions. But on a purely abstract level, there's no such thing as a variable in C++. They're just predefined system classes. There's no difference between int myInt and class myClass. C++ went out of its way to allow operator overloading so you don't have to do things like myClass.setValue(), myClass.addOtherClass(), myClass.divide().

People who say you need to use get/set are already saying to themselves that when you overload a sign you don't have to just add, subtract, etc (like you would for a var). That's exactly the reason JAVA got rid of operator overloading. Imagine a situation where a programmer using your stuff calls up and asks "Why did my screen just turn red?" and you replay "You must have set CSound->rate.set(11232)".

You want to set up your classes so that even though the implementation is black-boxed, the interface isn't. An end user should be able to guess what effects setting the rate, volume, whatever has on the class. So if it doesn't matter at what point how or why you set a variable, you don't need to use get/set functions.

As a beginner, it's hard to tell what variables need get/set functions and what ones don't, so you probably want to do it anyway, but as you gain experience, you should get a better idea of how everythings going to work before you start coding.

Hope I wasn't too confusing and didn't rant too much.


Edited by - logistix on 2/2/00 5:24:17 PM
0

Share this post


Link to post
Share on other sites