OOD and C++

A

arnuld

hello all,
i hope you folks must have recognised me. i posted here
some times & then disappear after i got answers (well, i disappear
only because of 2 reasons: 1st, i do not have any internet connection.
2nd i always apply the *things* you folks tell me and application of an
analysis takes a lot of time). anyway you people always helped me and
with *your* help, i am no longer a newbie, now i can read and
understand books which are written for programmers, with some
exceptions, of course. i have a problem in starting with c++ (yes, i
have decided to start c++). as usual, i searched the archives of
comp.lang.c++ for the answers to my question and that solved at least
50% of the problem,next, reading FAQS removed most of extra doubts i
had. now i have left with something i am not sure of.

i want to start a career in C++ . actually i looked at DICE.com and i
saw that for 60% of jobs in USA's major states c++ skills were wanted
and remaining 40% belonged to Java/.NET(as of MAY 2006). my main issue
is job and in the meantime i also want to become a good programmer. I
have been through the following books:

1.) "A gentle introduction to symbolic computation" - David S.Touretzky

2.) "Practical Common LISP" - Peter Seibel (upto chapter 22)

i stopped reading it because of job issue.

i am very sure about one thing, i do not need to learn C if all i want
is to learn C++. what i wan to ask is:

-- do i need to learn an OO langugae, like Ruby, before i dive into
C++. i read different posts and Stroustrup's FAQS too. but that left me
with ambiguity. i am not talking of smalltalk. i am talking of
paradigms and C++ is a multi-paradigm language. i dont know too much
about OOD. all i know is that in OOD we can structure our programme
into different data types and then we define operations on those data
types. a class can have any number of instances and i know about single
inheritance and multiple inheritance. except these i do not know
anything about OOD. --

will you people recommend me doing Ruby (it is OO) before i learn c++?

i want to follow this path: SICP -> C++ or

do i need to do Ruby -> SICP -> C++

any views?

(i am also learning Maths along the way so that i can understand
Knuth's algorithms.)

--arnuld
 
T

Tomás

arnuld posted:

i am very sure about one thing, i do not need to learn C if all i want
is to learn C++.


C++ is a superset of C. The "C Subset" which C++ contains only differs
from C in a handful of places. Here's a list of them:

http://david.tribble.com/text/cdiffs.htm

While you're correct in saying that you "don't need to learn C" in order
to program in C++, I would advocate reading C books, because C++ books
tend to focus too much on fancy features, rather than giving a solid
understanding of the core features like arrays, pointers, etc.

-- do i need to learn an OO langugae, like Ruby, before i dive into
C++.


No. I was about eleven or twelve when I started Visual Basic. A few years
later I got "C++ for Dummies" out of my local library. Another few years
later and I'm now an expert C++ programmer.

i read different posts and Stroustrup's FAQS too. but that left me
with ambiguity. i am not talking of smalltalk. i am talking of
paradigms and C++ is a multi-paradigm language. i dont know too much
about OOD. all i know is that in OOD we can structure our programme
into different data types and then we define operations on those data
types. a class can have any number of instances and i know about single
inheritance and multiple inheritance. except these i do not know
anything about OOD.


Object Orientated Design is just about keeping all the "complicatedness"
in one place, thus making it very easy for other parts of your
programming code to interact with these "complicated" parts of code. For
instance, if I'm a bank, I don't want to know about how an account works,
I just want to be able to do simple stuff with it:

void Bank::CloseAccount( unsigned long index )
{
holders[index].Close();
}

(Here, the bank doesn't know that "account" has to send a letter in the
post to the Tax Office.)

will you people recommend me doing Ruby (it is OO) before i learn c++?


If you want to learn C++, the just go and learn C++ -- you don't need any
stepping stones, you just need a good book.


-Tomás
 
M

mlimber

Tomás said:
arnuld posted:


C++ is a superset of C. The "C Subset" which C++ contains only differs
from C in a handful of places. Here's a list of them:

http://david.tribble.com/text/cdiffs.htm

While you're correct in saying that you "don't need to learn C" in order
to program in C++, I would advocate reading C books, because C++ books
tend to focus too much on fancy features, rather than giving a solid
understanding of the core features like arrays, pointers, etc.

Funny, I think the core features of arrays and pointers are the things
that should be avoided when possible in favor of "fancy" (i.e.,
exception-safe, automatically-deleting, optionally-bounds-checked,
less-error-prone) alternatives such as smart pointers and std::vectors.
It is of course necessary to understand raw pointers and arrays, but it
is also important to know how and when to use their alternatives. (As
to when to use them, the answer is, "Whenever you can. Use raw pointers
and arrays only when you must." See the FAQ:
http://www.parashift.com/c++-faq-lite/containers.html#faq-34.1.)
If you want to learn C++, the just go and learn C++ -- you don't need any
stepping stones, you just need a good book.

Agreed. See these FAQs on learning OO and C++:

http://www.parashift.com/c++-faq-lite/how-to-learn-cpp.html

As for a good book, _Accelerated C++_ by Koenig and Moo teaches C++ the
right way from the ground up. (BTW, it presents standard containers
well before pointers and arrays.)

Cheers! --M
 
T

Tomás

mlimber posted:
(As to when to use them, the answer is, "Whenever you
can. Use raw pointers and arrays only when you must." See the FAQ:
http://www.parashift.com/c++-faq-lite/containers.html#faq-34.1.)


One programmer trying to shove his doctrine down another programmer's
throat.

I have written reusable code for converting a monetary amount to text in
three different languages. It doesn't use any of the Standard C++ fancy
classes, just plain old char arrays and pointers.


-Tomás
 
A

arnuld

One programmer trying to shove his doctrine down another programmer's throat.

please, do not start any argument. I have seen things like these many
times and most often these turn into a flame-war & if that happens
then i will loose all the precious views of folks here.

i can only rquest.

thanks

-- arnuld
 
F

frankgerlach

If you want to learn Object Oriented Programming, it may be wiser to
learn a language like Smalltalk or Ruby first. Smalltalk has a rich
class library and supports the Object-oriented paradigm better than c++
does. (Actually it is one of the ealiest OOP languages) Also, the
code-compile-debug cycle is much shorter with "dynamic" languages of
the Smalltalk family (Ruby is often considered a member of that
family).
After you have a solid idea what OOP means, you can try to apply it to
c++ programming.
You will quickly find out that the static typing of c++ and the low
level features (pointers, manual memory management etc) reduce your
programming productivity compared to "dynamic" languages, but you will
also be amazed of the execution performance (if you use c++ wisely, of
course).
But be warned, c++ makes it very easy to shoot yourself into your feet
and chop off your hands simultaneously. If you want fewer headaches,
go with Smalltalk, Ruby or java - at least at the beginning.
Finally, I would suggest to get yourself some good books on the
programming languages you choose. As stated above, there are some quite
good books on OOP using Smalltalk. (for example: "Smalltalk-80: The
Language and its Implementation" by Adele Goldberg )
 
V

Victor Bazarov

Tomás said:
[..]
I have written reusable code for converting a monetary amount to text
in three different languages. It doesn't use any of the Standard C++
fancy classes, just plain old char arrays and pointers.

So? I've written assembly procedures for solving sets of linear equations
for more than one processor. Doesn't mean everybody should waste their
time doing that. Using a well-defined and thought-through library is
always a better choice, in the end.

V
 
T

Tomás

arnuld posted:
please, do not start any argument. I have seen things like these many
times and most often these turn into a flame-war & if that happens
then i will loose all the precious views of folks here.


I wasn't starting an argument -- I was just being blunt about how I feel
about programmers who adhere themselves to doctrine.

This is a newsgroup about computer programming -- in contrast to other
gatherings of people, you'll find that the posters here have:

1) Above average intelligence
2) Above average education
3) Above average ability to express themselves
4) Above average common sense

You'll find that it's quite easy to express your opinion here bluntly (even
abbrasively) without starting a flame war. It may require a bit of finesse
in places, but it can offer preeminence to one's argument.

-Tomás
 
M

mlimber

If you want to learn Object Oriented Programming, it may be wiser to
learn a language like Smalltalk or Ruby first. Smalltalk has a rich
class library and supports the Object-oriented paradigm better than c++
does. (Actually it is one of the ealiest OOP languages) Also, the
code-compile-debug cycle is much shorter with "dynamic" languages of
the Smalltalk family (Ruby is often considered a member of that
family).
After you have a solid idea what OOP means, you can try to apply it to
c++ programming.
You will quickly find out that the static typing of c++ and the low
level features (pointers, manual memory management etc) reduce your
programming productivity compared to "dynamic" languages, but you will
also be amazed of the execution performance (if you use c++ wisely, of
course).
But be warned, c++ makes it very easy to shoot yourself into your feet
and chop off your hands simultaneously. If you want fewer headaches,
go with Smalltalk, Ruby or java - at least at the beginning.
Finally, I would suggest to get yourself some good books on the
programming languages you choose. As stated above, there are some quite
good books on OOP using Smalltalk. (for example: "Smalltalk-80: The
Language and its Implementation" by Adele Goldberg )

First, please quote the message you are responding to. It makes it
easier for all to follow the conversation. (In Google Groups, click
"show options" and then "Reply" in the revealed header.)

Second, the aforementioned FAQs disagree with your perspective. A
relevant quote:

'Knowing a "pure" OO language doesn't make the transition to OO/C++ any
easier.... In fact, Smalltalk experience can make it harder for some
people: they need to unlearn some rather deep notions about typing and
inheritance in addition to needing to learn new syntax and idioms.

'If you want to learn OO/C++, learn OO/C++. Taking time out to learn
Smalltalk will waste your time and confuse you.'

On the other hand, if you're going to learn Ruby anyway in order to do
some work (no one I know does any real work in Smalltalk), there isn't
any harm in learning it first. Just be prepared to unlearn some things
and add a whole lot more for C++.

Cheers! --M
 
F

frankgerlach

Well, if you want to learn OOP, it is definitely easier to do that with
Smalltalk, where you have only objects that communicate with messages,
instead of classes, structs, typedefs, functions, methods, operators,
pointers, templates (and so on) in C++.
I agree that you need to learn quite a lot of things when learning C++,
but it is definitely helpful to have a solid understanding of OOP. How
do you get that in the easiest possible way ? Definitely not by going
the C++ route.
 
G

Gavin Deane

Tomás said:
arnuld posted:

While you're correct in saying that you "don't need to learn C" in order
to program in C++, I would advocate reading C books, because C++ books
tend to focus too much on fancy features, rather than giving a solid
understanding of the core features like arrays, pointers, etc.

That makes no sense. In C++, arrays and particularly pointers *are*
fancy features.

I think you missed a very important point. The OP said they want to
start a career in C++. With someone in that position, it is unfair to
give advice such as the above that will hinder their chances of
achieving their goal. Much better to give the sort of advice you gave
at the end of your post:
If you want to learn C++, the just go and learn C++ -- you don't need any
stepping stones, you just need a good book.

Best suggestion, as mentioned elsethread:
http://www.acceleratedcpp.com/

Gavin Deane
 
P

Phlip

Tomás said:
One programmer trying to shove his doctrine down another programmer's
throat.

Ayup. Teamwork at its finest.
I have written reusable code for converting a monetary amount to text in
three different languages. It doesn't use any of the Standard C++ fancy
classes, just plain old char arrays and pointers.

That's heroism. If you had teammates, they would not be amused.
 
P

Phlip

arnuld said:
please, do not start any argument. I have seen things like these many
times and most often these turn into a flame-war & if that happens
then i will loose all the precious views of folks here.

Don't worry - he's a minority of one on this.
 
M

mlimber

Tomás said:
arnuld posted:


I wasn't starting an argument -- I was just being blunt about how I feel
about programmers who adhere themselves to doctrine.

I think Arnuld's point was that your statement quoted above was
potentially, let us say, provocative.
You'll find that it's quite easy to express your opinion here bluntly (even
abbrasively) without starting a flame war. It may require a bit of finesse
in places, but it can offer preeminence to one's argument.

I'm confused. Are you claiming finesse or abrasiveness for your
previous response? (The one is readily apparent; the other is somewhat
lacking.)

In any case, the question at hand is whether or not the FAQ's doctrine
is the right doctrine. Obviously, I think it is for the reasons
mentioned previously. Indeed, most if not all of the C++ gurus (among
whom I certainly do not count myself) make the same point, so really I
don't see Tomás arguing with me so much as with the recognized
authorities on the subject who have more accumulated experience than
any one of us.

The good news is that C++ supports multiple programming paradigms and
styles, so you may freely choose whose doctrine you will follow.

Cheers! --M
 
P

Phlip

mlimber said:
In any case, the question at hand is whether or not the FAQ's doctrine
is the right doctrine.

In technology, advice that is short, simple, obvious, and which doesn't
force anything out of place is usually the right advice. For example: Use
C++ the way it's designed to be used.

Of course I can write a program that violates that advice, and I can brag
about that here. That's not repudiation so much as validation!
 
A

arnuld

This is a newsgroup about computer programming -- in contrast to other
gatherings of people, you'll find that the posters here have:
1) Above average intelligence
2) Above average education
3) Above average ability to express themselves
4) Above average common sense

wow! , never thought of that for comp.lang.c++,.
In technology, advice that is short, simple, obvious, and which doesn't
force anything out of place is usually the right advice. For example: Use
C++ the way it's designed to be used.

now, Philip is really good at communication.

anyway, same thing again, 50/50 responses for C++ or OOD first.

hey Philip what do you say?

-- arnuld
 
M

mlimber

Well, if you want to learn OOP, it is definitely easier to do that with
Smalltalk, where you have only objects that communicate with messages,
instead of classes, structs, typedefs, functions, methods, operators,
pointers, templates (and so on) in C++.
I agree that you need to learn quite a lot of things when learning C++,
but it is definitely helpful to have a solid understanding of OOP. How
do you get that in the easiest possible way ? Definitely not by going
the C++ route.

To reiterate: please quote the message you are responding to. It makes
it easier for all to follow the conversation. (In Google Groups, click
"show options" and then "Reply" in the revealed header to automatically
quote.)

I agree that it would be *helpful* to know OO before starting C++, but
your conclusion that learning Smalltalk is the best way to learn C++
does not follow. The OP wants to have a career in OO/C++, and so I
contend (along with the FAQ) that he should learn OO the C++ way rather
than learning "pure" OO and then trying to fit C++ into a Smalltalk (or
Java or Ruby or whatever) way of thinking.

I formerly advocated learning some simpler language first, but unless
there is some immediate value to learning that language also (e.g., you
need to maintain some Ruby programs), learning another language solely
for the purpose of learning C++ is, IMHO, an unnecessary detour. I'm
not suggesting someone just dive in and hope s/he doesn't drown.
Rather, I'm suggesting that s/he should rely on a trustworthy guide
(e.g. Koenig and Moo) to show the C++ way and thus go straight for the
goal.

Cheers! --M
 
A

arnuld

I agree that it would be *helpful* to know OO before starting C++, but
your conclusion that learning Smalltalk is the best way to learn C++
does not follow. The OP wants to have a career in OO/C++, and so I
contend (along with the FAQ) that he should learn OO the C++ way rather
than learning "pure" OO and then trying to fit C++ into a Smalltalk (or
Java or Ruby or whatever) way of thinking.
I formerly advocated learning some simpler language first, but unless
there is some immediate value to learning that language also (e.g., you
need to maintain some Ruby programs), learning another language solely
for the purpose of learning C++ is, IMHO, an unnecessary detour. I'm
not suggesting someone just dive in and hope s/he doesn't drown.
Rather, I'm suggesting that s/he should rely on a trustworthy guide
(e.g. Koenig and Moo) to show the C++ way and thus go straight for the
goal.
Cheers! --M

thanks, a lot, M. your advice really changed my point of view and you
altered my thinking for C++.

thanks

-- arnuld
 
N

Noah Roberts

arnuld said:
-- do i need to learn an OO langugae, like Ruby, before i dive into
C++. i read different posts and Stroustrup's FAQS too. but that left me
with ambiguity. i am not talking of smalltalk. i am talking of
paradigms and C++ is a multi-paradigm language. i dont know too much
about OOD. all i know is that in OOD we can structure our programme
into different data types and then we define operations on those data
types. a class can have any number of instances and i know about single
inheritance and multiple inheritance. except these i do not know
anything about OOD. --

No, learning a different language won't help you in this regard. OOD
takes experience to get a handle on just like programming in general.
Years of use and reading is the only thing that will help you become
good at OO development and design.

Learning a different language probably won't hurt you either though.
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top