On Programming

J

JoeC

I am a self taught programmer and I am starting to get better and
create larger and more complex projects. Mostly I write games because
they keep me interested. I have done some reading with directX but
mostly I am more comfortable with win32. I only use win32 as a way to
show something on the screen. I am more interested in design patterns
and trying to find the best tool for a problem. I don't have a
specific question but like the abstract discussions on how others
approach programming and what kind of tips I can gain from other
people. What is the best way to create an object because I have
objects that tend to get very big is that OK? I don't use pointers
very much and try to use standard libraries as much as I can. I tend
to use pointers if I have objects that hold other objects. For
example if I have a player object then I will have weapons class
pointer. The player might have a spear or a club and they will act
differently or there may not be any weapon at all. I tend not to use
dynamic binding very much never have the right problem although for
one of my games I did create a handle for units. I was planning to
have land air and sea units but only actually created the land units
but the handle worked great if I had wanted to create more kinds of
units.

I am just writing some Ideas of how I program and if you like and have
something to say I would be interested in your thoughts if not that is
OK too feel no need to respond unless you want to get into the more
abstract way you approach programming.
 
V

Victor Bazarov

JoeC said:
I am a self taught programmer and I am starting to get better and
create larger and more complex projects. Mostly I write games because
they keep me interested. I have done some reading with directX but
mostly I am more comfortable with win32. I only use win32 as a way to
show something on the screen. I am more interested in design patterns
and trying to find the best tool for a problem. I don't have a
specific question but like the abstract discussions on how others
approach programming and what kind of tips I can gain from other
people. What is the best way to create an object because I have
objects that tend to get very big is that OK?

Depends. Usually a large class without enough base classes from which
it inherits all the stuff means that you may have not identified all
the abstractions, which would otherwise help narrowing down their
functionality. Abstraction helps subdivide the problem domain into
manageable pieces, implement them better, test them better, reuse them
better.
I don't use pointers
very much and try to use standard libraries as much as I can. I tend
to use pointers if I have objects that hold other objects.

By itself it doesn't necessarily sound like a bad idea.
For
example if I have a player object then I will have weapons class
pointer. The player might have a spear or a club and they will act
differently or there may not be any weapon at all. I tend not to use
dynamic binding very much never have the right problem although for
one of my games I did create a handle for units. I was planning to
have land air and sea units but only actually created the land units
but the handle worked great if I had wanted to create more kinds of
units.

I am just writing some Ideas of how I program and if you like and have
something to say I would be interested in your thoughts if not that is
OK too feel no need to respond unless you want to get into the more
abstract way you approach programming.

If you're interested in exploring OO side of C++, I'd recommend the
old and still valid "Advanced C++ : Programming Styles and Idioms" by
James Coplien.

V
 
J

JoeC

Depends. Usually a large class without enough base classes from which
it inherits all the stuff means that you may have not identified all
the abstractions, which would otherwise help narrowing down their
functionality. Abstraction helps subdivide the problem domain into
manageable pieces, implement them better, test them better, reuse them
better.


By itself it doesn't necessarily sound like a bad idea.



If you're interested in exploring OO side of C++, I'd recommend the
old and still valid "Advanced C++ : Programming Styles and Idioms" by
James Coplien.

V

Thanks for the recommendations. I will look for them.
 
D

Daniel T.

JoeC said:
I don't have a specific question but like the abstract discussions
on how others approach programming and what kind of tips I can gain
from other people.

You might want to start following the comp.object newsgroup.
What is the best way to create an object because I have objects that
tend to get very big is that OK?

My personal rule is, "most of the methods must use most of the fields
most of the time."
 
J

James Kanze

If you're interested in exploring OO side of C++, I'd recommend the
old and still valid "Advanced C++ : Programming Styles and Idioms" by
James Coplien.

A very useful book, but the title doesn't lie. Many of the
idioms rate as very advanced. I'd recommend a general OO text.
(I learned using Booch, but I don't know if it is still
considered up to date.) I'd also recommand The GoF book on
patterns, and the Barton and Nackman (which has some very good
discussion on the trade offs between templates and inheritance,
as well as when to use the different types of inheritance).
 
J

JoeC

You might want to start following the comp.object newsgroup.


My personal rule is, "most of the methods must use most of the fields
most of the time."

Thanks, I will look in other places. I was hoping to try to see how
other programmers approach programming. I am writing programs that
are too big and complicated to post and I wouldn't expect anyone to
weed through all the code I write. Not having gone to school or have
a job where I can meed other programmers I would like to have
discussions on the topic. I want to get better and I learn from my
experiences but I would also like to see if I can find other ideas or
some approach I might have overlooked.

So far I have written several games lately using win32. I have
written a maze game, I use bitmap graphics as well as a binary library
that I have created myself. I finished two map games. One was very
simple the next one a bit more complicated. I create a map and have
four kinds of units. The goal of the second game is to capture all
the cities. You get point from the cities you control to buy more
units. I created a dialog box to buy the units and they randomly get
placed in controlled cities. I have no idea how to do a computer
player so I created an email system where after each turn the game is
saved and you can send it to the person you are playing.

Now I am working on something much more complicated; a civilization
type of game. I have created a random map with water land hills and
mountains. I can save the map in a binary file. Right now I am
trying to create a way to create random rivers but I have having
trouble getting that to work. Also I am challenged on how the game
will actually be played. That is a challenge I am still trying to
figure out with pencil and paper.

This is where I am. I am trying to use more inheritance and objected
oriented techniques I have read about. I try to break my programs
down into logical objects. It seems that big objects like my map and
spaces do grow large because they do quite a bit. My units in my last
game were large and held other objects. A unit for example had
attack, defense, graphics, colors, movement, how much moved as well as
other status variables. I try to understand what I know and try to
create something just beyond what I think I can do. I keep learning
lessons and try to implement those lessons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top