OO programs

A

artem

hi all,
i am trying to learn object oriented programing, and i am having a hard
time on desiding how to to break up my java program in to classes and
on what each class should contain. Does any one know of a good java
open source program that is designed this way and would be a good
example to learn from. i would prefer if it would be around 10-20
classes?
tnx
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

artem said:
i am trying to learn object oriented programing, and i am having a hard
time on desiding how to to break up my java program in to classes and
on what each class should contain. Does any one know of a good java
open source program that is designed this way and would be a good
example to learn from. i would prefer if it would be around 10-20
classes?

One of your problems may be that:

problem => non OO code => OO design => OO code

does not work very well.

problem => OO design => OO code

will be much easier.

The classes and their functionality should be driven by
the reality your are trying to model.

Arne
 
A

artem

ow yes i am trying to right in OO code right away
problem => OO design => OO code
in the begining of the program i do it just like that, but as the
program gets biger and you have to pass arguments from here to there i
get lost where things go, and i am not sure if i should create a new
class and put it in there or use an already existing class.
Artem
 
L

Lionel

artem said:
ow yes i am trying to right in OO code right away
problem => OO design => OO code
in the begining of the program i do it just like that, but as the
program gets biger and you have to pass arguments from here to there i
get lost where things go, and i am not sure if i should create a new
class and put it in there or use an already existing class.
Artem


Please don't top post!

Perhaps you should give us some examples of what you are trying to do
and we might be able to make suggestions.

It should be obvious when to make classes. A class represents some
thing, an Object. For example, an Apple, Orange or a Book. A class can
also represent something less physical such as a database. You don't
make a class to put a method in it.

Lionel.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

artem said:
ow yes i am trying to right in OO code right away
problem => OO design => OO code
in the begining of the program i do it just like that, but as the
program gets biger and you have to pass arguments from here to there i
get lost where things go, and i am not sure if i should create a new
class and put it in there or use an already existing class.

You create classes based on the types of objects in the real world.

And you add methods to those based on something that makes sense
in the real world.

If two different ways both make sense in the real world, then
you should not worry about it in the code.

Maybe you should try and post a specific example that
is puzzling you, then we can try and explain what the above
means in that case.

Arne
 
M

Manish Pandit

Before beginning to code, try to get a feel of what the paradigm of
object oriented programming is. Once you are familiar with the
methodolody of encapsulation, data abstraction, inheritance and
polymorphism, you will be able to look at problems a lot differently
than the traditional procedural way. If you skip this step, even though
you'd be programming in an object oriented language, the code will
still end up being procedural.

-cheers,
Manish
 
C

Chris Uppal

Arne said:
The classes and their functionality should be driven by
the reality your are trying to model.

I don't think that's particularly true. That may be a reasonable /starting/
point for someone completely new to OO, so wouldn't I necessarily call it /bad/
advice, although it is certainly incomplete, and misleading if taken too
literally.

-- chris
 

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

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,102
Members
48,773
Latest member
Kaybee

Latest Threads

Top