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

Discussion in 'C++' started by arnuld, Dec 27, 2007.

  1. arnuld

    arnuld Guest

    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.
    arnuld, Dec 27, 2007
    #1
    1. Advertising

  2. arnuld

    Daniel T. Guest

    arnuld <> wrote:

    > 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
    Daniel T., Dec 27, 2007
    #2
    1. Advertising

  3. arnuld

    arnuld Guest

    > On Thu, 27 Dec 2007 08:55:13 -0500, Daniel T. wrote:

    > 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.

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


    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 :)
    arnuld, Dec 28, 2007
    #3
  4. arnuld

    arnuld Guest

    > On Thu, 27 Dec 2007 08:55:13 -0500, Daniel T. wrote:

    > 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.
    arnuld, Dec 28, 2007
    #4
  5. arnuld

    arnuld Guest

    Learning OO in C++ way (was: Effective C++ 3/e or 2/e )

    changed the title to reflect the discussion.
    arnuld, Dec 28, 2007
    #5
  6. On 2007-12-28 14:22, arnuld wrote:
    >> On Thu, 27 Dec 2007 08:55:13 -0500, Daniel T. wrote:

    >
    >> 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.


    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.

    --
    Erik Wikström
    Erik Wikström, Dec 28, 2007
    #6
  7. arnuld

    arnuld Guest

    Learning OO in C++ way

    > On Fri, 28 Dec 2007 13:33:02 +0000, Erik Wikström wrote:

    > 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)
    arnuld, Dec 28, 2007
    #7
  8. arnuld

    Daniel T. Guest

    arnuld <> wrote:
    > > Daniel T. wrote:

    >
    > > 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.


    "Object-Oriented Design Heuristics" by Arthur J Riel.
    "C++ FAQs" by Marshall P. Cline, & al.
    Daniel T., Dec 28, 2007
    #8
  9. arnuld

    Daniel T. Guest

    Re: Learning OO in C++ way

    arnuld <> wrote:
    > > Erik Wikström wrote:
    > >
    > > 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)


    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.
    Daniel T., Dec 28, 2007
    #9
  10. Re: Learning OO in C++ way (was: Effective C++ 3/e or 2/e )

    arnuld wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Dec 28, 2007
    #10
  11. arnuld

    arnuld Guest

    Re: Learning OO in C++ way (was: Effective C++ 3/e or 2/e )

    > On Fri, 28 Dec 2007 10:18:03 -0500, Victor Bazarov wrote:

    > 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
    arnuld, Dec 28, 2007
    #11
  12. Re: Learning OO in C++ way (was: Effective C++ 3/e or 2/e )

    arnuld wrote:
    > [..] 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Dec 28, 2007
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Buick

    Effective Email Marketing

    Joe Buick, Nov 29, 2004, in forum: VHDL
    Replies:
    0
    Views:
    464
    Joe Buick
    Nov 29, 2004
  2. Andrew FPGA
    Replies:
    14
    Views:
    1,146
    Jim Lewis
    Oct 5, 2005
  3. Mazen
    Replies:
    0
    Views:
    376
    Mazen
    Jul 11, 2003
  4. Yan-Hong Huang[MSFT]
    Replies:
    0
    Views:
    413
    Yan-Hong Huang[MSFT]
    Oct 15, 2003
  5. Harry
    Replies:
    1
    Views:
    412
    Joe Fallon
    Apr 13, 2004
Loading...

Share This Page