Effective C++ 3/e or 2/e ?

A

arnuld

Hi all,
I have come to a point where I can comprehend C++ code much better.
I will finish C++ Primer 4/e within next few days. Right now I am
feeling the need to have have coding standards when I write programs and
I feel I must apply some better ways to design my code e.g. all of my
the programmers at my college use to write this code:


for( int i=0; i <= 10; ++i )
{
add elements to array;
}


while I used this code from C++ Primer (the book recommended by you
people)


for( std::vector<int>::const_iterator iter = ivec.begin();
iter != ivec.end(); ++iter )
{
ivec.push_back;
}


and comp.lang.c++ totally pushed the things to the practical-level. One
of the best examples I have is this:

std::copy( std::istream_iterator<int>( std::cin ),
std::istream_iterator<int>(),
back_inserter( ivec ) );


no use of while-loop here while all of Post-Graduates of my college use
while, arrays an pointers and have no idea about map & istream
iterators.

what I am trying to say that std::copy is a good coding-standard. Now as
I will start writing code for real-life projects I want have a larger
look at coding standards so except hanging around comp.lang.c++ I want to
have an offline source. I have 2 choices:

1.) Effective C++ 3/e

2.) Effective C++ 2/e , Coding Standards (Herb Sutter et al.)

Effective C++ 3/e is twice as much expansive as 2/e. With limited
bud what you people advise ?

or you think I need something else to do and you have some other plans
for me :), after all you are my teachers. I will be writing real-life
code within next week.
 
D

Daniel T.

arnuld said:
I have come to a point where I can comprehend C++ code much better.
I will finish C++ Primer 4/e within next few days. Right now I am
feeling the need to have have coding standards when I write programs and
I feel I must apply some better ways to design my code e.g. all of my
the programmers at my college use to write this code:


for( int i=0; i <= 10; ++i )
{
add elements to array;
}


while I used this code from C++ Primer (the book recommended by you
people)


for( std::vector<int>::const_iterator iter = ivec.begin();
iter != ivec.end(); ++iter )
{
ivec.push_back;
}

Note: the above loop may not work. Modifying the size of a vector while
iterating through it is dangerious.
and comp.lang.c++ totally pushed the things to the practical-level. One
of the best examples I have is this:

std::copy( std::istream_iterator<int>( std::cin ),
std::istream_iterator<int>(),
back_inserter( ivec ) );

The three loops above do completely different things. :-( But I think I
understand what you are getting at.
no use of while-loop here while all of Post-Graduates of my college use
while, arrays an pointers and have no idea about map & istream
iterators.

what I am trying to say that std::copy is a good coding-standard. Now as
I will start writing code for real-life projects I want have a larger
look at coding standards so except hanging around comp.lang.c++ I want to
have an offline source. I have 2 choices:

1.) Effective C++ 3/e

2.) Effective C++ 2/e , Coding Standards (Herb Sutter et al.)

Effective C++ 3/e is twice as much expansive as 2/e. With limited
bud what you people advise ?

I thing the C++ Coding Standards book is an excellent all around
reference. I haven't read Effective C++ 3/e so I really can't help you
here.

What does Stroustrup say?
http://www.research.att.com/~bs/bs_faq2.html#coding-standard
 
A

arnuld

The three loops above do completely different things. :-( But I think I
understand what you are getting at.

:)

I thing the C++ Coding Standards book is an excellent all around
reference. I haven't read Effective C++ 3/e so I really can't help you
here.

thanks. I have searched the bookpool and found that 2/e was published in
SEP 1997, a year before ISO C++ standard was released and 3/e was
published in 2005.

THNKS A LOT for that link. Stroustrup says this:

-- C++ of 1990s
-- C++ as of ISO standard (1998)
-- C++ in 2005

he says these are 3 totally different approaches to C++ programming,
hence I will go with 3/e :)
 
A

arnuld

I thing the C++ Coding Standards book is an excellent all around
reference. I haven't read Effective C++ 3/e so I really can't help you
here.

What does Stroustrup say?
http://www.research.att.com/~bs/bs_faq2.html#coding-standard


thanks, now the only problem is of some OO book. I do not want any
theoretical foundations of OOA/M/D. I want a book where i can understand
OO ideas in terms of C++ where I can get down fast enough to do C++ coding
in an OO way.

any advise will be helpful.
 
E

Erik Wikström

thanks, now the only problem is of some OO book. I do not want any
theoretical foundations of OOA/M/D. I want a book where i can understand
OO ideas in terms of C++ where I can get down fast enough to do C++ coding
in an OO way.

any advise will be helpful.

If you do not already have it Design Patterns by Gamma et al. is often
recommended, and there are many (all?) examples in C++, but if you
understand the concepts they will be applicable in most OO languages.
 
A

arnuld

If you do not already have it Design Patterns by Gamma et al. is often
recommended, and there are many (all?) examples in C++, but if you
understand the concepts they will be applicable in most OO languages.

thanks and that book is also recommended by C++ FAQs. I think that will be
too dense for a beginner (like Booch is too confusing to me)
 
D

Daniel T.

arnuld said:
thanks, now the only problem is of some OO book. I do not want any
theoretical foundations of OOA/M/D. I want a book where i can understand
OO ideas in terms of C++ where I can get down fast enough to do C++ coding
in an OO way.

any advise will be helpful.

"Object-Oriented Design Heuristics" by Arthur J Riel.
"C++ FAQs" by Marshall P. Cline, & al.
 
D

Daniel T.

arnuld said:
thanks and that book is also recommended by C++ FAQs. I think that will be
too dense for a beginner (like Booch is too confusing to me)

Design Patterns is a great book. The problem with it (from a beginner's
perspective) is that it's a bunch of solutions looking for problems. A
beginner still needs to learn when to apply which solution and DP
doesn't go into much depth about that.

That's why I recommended "Object-Oriented Design Heuristics". It gives
motivation as to why a particular pattern is good so you can more easily
see when to use it. The book also covers some patterns, how to transform
code from one pattern to another and why you might want to.
 
V

Victor Bazarov

arnuld said:
changed the title to reflect the discussion.

What discussion? I can only see the post (with the allegedly
changed title "Learning OO in C++ way (was: ...") and the only
line inside is your announcement about changing the title.

Please consider that not some newsreader software is quite
unsophisticated and only keeps the messages threaded by the
_exact_ title. Changing titles means introducing new thread
in such software.

V
 
A

arnuld

What discussion? I can only see the post (with the allegedly
changed title "Learning OO in C++ way (was: ...") and the only
line inside is your announcement about changing the title.

yes. right. If you say it is bad way, then I will not do it again.

Please consider that not some newsreader software is quite
unsophisticated and only keeps the messages threaded by the
_exact_ title. Changing titles means introducing new thread
in such software.


I didn't know that. I use PAN and it is quite sophisticated. but that
is not my point. My point was I do not want OOA/M/D book. I want to
know some list of good books which do OOP in C++. I will try to figure
out OOA/M/D later because OOA -> D -> P doe snot work for me and
hence I am going the opposite way OOP > D -> A
 
V

Victor Bazarov

arnuld said:
[..] My point was I do not want OOA/M/D book. I want to
know some list of good books which do OOP in C++. I will try to figure
out OOA/M/D later because OOA -> D -> P doe snot work for me and
hence I am going the opposite way OOP > D -> A

You probably prefer to learn by example. You might want to see some
C++ code first, then explanation of what it models, and then what
principles that model implements. AFAICS it doe snot mean it's bad
or impossible to learn that way. It's just backwards. By seeing the
result and then the explanation of the principles that led to that
design you don't learn why the principles produce that result. What
is worse, you only learn that a certain principle produces a certain
result, IOW one-to-one relationship between them.

Here is an analogy: in middle ages alchemists didn't have a system.
They knew properties of some materials, they knew the results of
some combinations, but had no idea why it was so. The progress in
such case is very very very slow. Once the system was developed,
it was possible to predict how elements would respond to each other
and there was no need to use the "poke-and-see" method. What is
better that now people know that there is more than one way to get
what they want.

You need to learn the system, and that's why you need to start from
OOD and OOA. OOP is a mere derivative from that. You need to find
a good OOD book with plenty of good examples instead of trying to
understand what OOD is from the result it leads to. Trying to come
up with OOD principles from C++ code is akin to trying to come up
with C++ code from an watching the application [written in C++] do
its thing.

V
 

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
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top