|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||
|
Good question......... I don't think there is a correct way to determine what to make an object. I would make anything an object that you plan on using more than once such as a wrapper.
Objects are classes, correct?
__________________
DirkFirst |
|
|||
|
Quote:
Lol to many objects? Ive made entire programs all in class's, ie the entire content of main on a mac space invaders game i made ( for fun ) was: Code:
void main( void )
{
WORLD world;
WindowPtr win;
int x=0,y=30;
world.init( &win );
for( int x=0;x<20;x++)
world.en_new( world.enemy , x+10 , y );
world.sp_spawn();
do
{
world.setworld( world.offscrn );
world.en_move();
world.en_update();
world.sp_checkkey();
world.setworld( world.window );
world.sp_draw();
world.en_draw();
world.speed();
}while(1);
}
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
Quote:
A simple method to get you started is to describe your system, and then pick out the nouns you used to describe your problem domain. Those nouns are usually good candidates for a class. Though I'd say it's difficult, it's not impossible to have "too many classes". But really, it's more likely that you (like I have a tendency to do) are complicating the subject matter. In your complex modeling of the reality, you've identified a lot more players than are actually needed to perform the job. So, your problem isn't really that you have too many classes, it's that your model is too complex. In general (excepting the case above - which is a modeling problem), the more classes the better. By having more classes, each class can have a well defined role (the Single Responsiblity Principle) and can be understood easily. By taking for granted that a class does its responsibility correctly, it's easier to understand a small part of the system without having to grasp all of the the code at once. |
|
|||||
|
Quote:
|
| Sponsored Links |
|
|
|
|||||
|
I'll give you an example: Let's say you want to make a chess game. Classes that come to mind for me are:
Game Board Piece (inherit down to individual types) Turn Player History Objects of these classes will interact for things such as attacks, pieces knowing how they move and where they are, checking for stalemate by repetition, etc. Think about what objects exist in the problem, and you get your classes.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
You should see me when I teach math!
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| G++ Error: cannot pass objects of non-POD type | Ronin | C and C++ | 4 | 10-01-2007 04:35 AM |
| [Query]TreeMap and TreeSet objects. How to use? | Musashibo | Java Help | 0 | 06-05-2007 09:18 AM |
| Objects.. | idgeitman | Java Help | 3 | 04-22-2007 10:42 PM |
| Java:Tutorial - Adding more objects to your window | John | Java Tutorials | 0 | 01-11-2007 02:09 PM |
| Classes, Methods, and Objects | Sionofdarkness | Java Help | 6 | 08-21-2006 12:55 PM |
| John | ........ | 223.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| LogicKills | ........ | 20.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 67%