Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #10361

Re: C++ design/over desiging : stl style vs OOPS, OOAD

From Nobody <nobody@nowhere.com>
Subject Re: C++ design/over desiging : stl style vs OOPS, OOAD
Date 2011-09-21 21:13 +0100
Message-Id <pan.2011.09.21.20.12.59.795000@nowhere.com>
Newsgroups comp.lang.c++
References <abab1ddd-c3ce-451b-b417-17b783cebb66@u19g2000vbm.googlegroups.com>
Organization Zen Internet

Show all headers | View raw


On Tue, 20 Sep 2011 09:09:42 -0700, persres@googlemail.com wrote:

> 1. The new generic programming way. All this stl algorithms, range
> functions, transforms, generates and function objects etc.  (This is
> my favourite for fun).
> 
> 2. The object oriented, polymorphic, way. Say the trolltech QT
> framework. You really wouldn;t be approaching with style1 if you were
> to design something like QT. I guess.
> 
> When do you do what.

With #1, you write one chunk of source code, and the compiler generates a
new chunk of object code for each set of template parameters which occurs.

With #2, you write one chunk of source code, and the compiler generates a
single chunk of object code which works with any combination of actual
parameters, provided that they are derived from the declared type.

#1 offers more potential for optimisation at the risk of code bloat. #2
eliminates the code bloat but also eliminates some potential for
optimisation.

In cases where either approach will work, the choice depends upon how much
you gain (i.e. how much the optimisation potential actually matters) and
how much you lose (i.e. how much code bloat will result). In general,
lower-level code results in #1 providing more gain for less cost, while
higher-level code reduces the gain and/or increases the cost.

#1 requires that the type is known at compile time, while #2 allows
the type to be determined at run time.

#1 works with primitive types, while #2 only works with
classes, so you would have to take the Java approach of creating class
wrappers for primitive types if you wanted to use #2.

#1 selects a template instance based upon all of the parameters,
while #2 dispatches solely upon the type of the "this" parameter.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C++ design/over desiging : stl style vs OOPS, OOAD "persres@googlemail.com" <persres@gmail.com> - 2011-09-20 09:09 -0700
  Re: C++ design/over desiging : stl style vs OOPS, OOAD Victor Bazarov <v.bazarov@comcast.invalid> - 2011-09-20 13:01 -0400
  Re: C++ design/over desiging : stl style vs OOPS, OOAD Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-20 19:40 +0000
  Re: C++ design/over desiging : stl style vs OOPS, OOAD Nobody <nobody@nowhere.com> - 2011-09-21 21:13 +0100
  Re: C++ design/over desiging : stl style vs OOPS, OOAD Stuart Redmann <DerTopper@web.de> - 2011-09-21 23:45 -0700
    Re: C++ design/over desiging : stl style vs OOPS, OOAD Juha Nieminen <nospam@thanks.invalid> - 2011-09-22 07:16 +0000
      Re: C++ design/over desiging : stl style vs OOPS, OOAD Stuart Redmann <DerTopper@web.de> - 2011-09-22 04:28 -0700
        Re: C++ design/over desiging : stl style vs OOPS, OOAD Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-22 13:12 +0000
          Re: C++ design/over desiging : stl style vs OOPS, OOAD Stuart Redmann <DerTopper@web.de> - 2011-09-22 09:08 -0700
            Re: C++ design/over desiging : stl style vs OOPS, OOAD "vincent.L" <vinceworld@gmail.com> - 2011-09-22 09:41 -0700
            Re: C++ design/over desiging : stl style vs OOPS, OOAD Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-23 14:17 +0000
        Re: C++ design/over desiging : stl style vs OOPS, OOAD Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-09-22 09:44 -0400
    Re: C++ design/over desiging : stl style vs OOPS, OOAD Werner <werasm@gmail.com> - 2011-09-26 00:14 -0700
  Re: C++ design/over desiging : stl style vs OOPS, OOAD Keith H Duggar <duggar@alum.mit.edu> - 2011-09-22 12:47 -0700
  Re: C++ design/over desiging : stl style vs OOPS, OOAD Erik Engheim <ordovician.cenozoic@mac.com> - 2011-09-25 21:00 +0200
    Re: C++ design/over desiging : stl style vs OOPS, OOAD Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-09-27 18:47 +0000
      Re: C++ design/over desiging : stl style vs OOPS, OOAD "persres@googlemail.com" <persres@gmail.com> - 2011-10-21 04:28 -0700

csiph-web