From: Hakusa on
On Jun 28, 4:51 pm, Olve Maudal <olve.mau...(a)gmail.com> wrote:
> At the NDC2010 conference, I gave a presentation where I demonstrated
> Solid C++ code by example:
>
> http://www.slideshare.net/olvemaudal/solid-c-by-example
>
> It would be great to have your opinion about the examples I present.
> Is this solid code, or can it be improved even further?

Why should the public interface be before the private? Even if it
should, why use classes instead of structs?

I disagree with your classification of magic numbers. By what i see in
your slide:
f(60); // using magic number
but:
const int x = 60;
f(x); // Suddenly OK.
In my mind, 60 does not stop being magic just because it's named. The
question of where this number came from is still unanswered.

Slide 171; you complain about messing with "borrowed" things. Why not
just save the flags, then reset them?


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: bf on
On Jun 28, 10:51 pm, Olve Maudal <olve.mau...(a)gmail.com> wrote:
> At the NDC2010 conference, I gave a presentation where I demonstrated
> Solid C++ code by example:
>
> http://www.slideshare.net/olvemaudal/solid-c-by-example
>
> It would be great to have your opinion about the examples I present.
> Is this solid code, or can it be improved even further?

The examples are OK, I think, but I miss motivations for why you think
the suggested changes are improvements. What problems are there with
the originals that you improve? Perhaps you talked about this in your
presentation, but it's not there to read. This is especially worth
pointing out since many rules are such that there are situations where
the right thing is to violate them, but to know when to do that you
must understand the rule and its reasons for existing.
_
/Bjorn

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Leigh Johnston on
"Johannes Schaub (litb)" <schaub-johannes(a)web.de> wrote in message news:i0b3be$g4a$00$1(a)news.t-online.com...
> Olve Maudal wrote:
>
>> At the NDC2010 conference, I gave a presentation where I demonstrated
>> Solid C++ code by example:
>>
>> http://www.slideshare.net/olvemaudal/solid-c-by-example
>>
>> It would be great to have your opinion about the examples I present.
>> Is this solid code, or can it be improved even further?
>>
>
> One thing i really don't agree with is depending on things included by
> other
> 3rd party headers.
>
> I would also not recommend using a "size_t" to store an offset containing
> "12" - i think it's bad to use "unsigned" just to signify a quantity is
> unsigned.
>
> I personally like the other stuff in it :)

I disagree, there is nothing wrong with using unsigned integral types such
as std::size_t when dealing with quantities that are only ever positive (or
zero).

I don't agree that default arguments should be avoided, the alternative is
overloading which I think is sometimes overkill.

/Leigh

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: CornedBee on
On Jun 28, 10:51 pm, Olve Maudal <olve.mau...(a)gmail.com> wrote:
> At the NDC2010 conference, I gave a presentation where I demonstrated
> Solid C++ code by example:
>
> http://www.slideshare.net/olvemaudal/solid-c-by-example
>
> It would be great to have your opinion about the examples I present.
> Is this solid code, or can it be improved even further?

Pretty nice. Unlike Johannes, I like the size_t. What I don't like is
removing the parentheses from sizeof. The fact that sizeof can be used
without parentheses for expressions is not useful IMO; sizeof should
be treated like a built-in function. The creators of C++, at least,
seem to think so too, since typeid and decltype require parentheses.
(So does alignof, but it doesn't accept an expression.)
On your side, on the other hand, you have the delete operator. Still,
my preference is parentheses for sizeof.

Sebastian


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Chris Uzdavinis on
{ Can we all please avoid top-posting and quoting the banner?
Thanks for your cooperation. -mod }


Overall I liked the presentation and most of the ideas too. I agree
with a previous post, that depending on headers being indirectly
included is not really programming virtue.

You might consider a severity or priority to some of them too. While
it's serious to omit a virtual destructor in polymorphic base classes,
and it's error-prone to omit the explicit keyword, and inefficient
(and sometimes incorrect) to initialize members in the body of the
constructor instead of the initializer list... things like extraneous
parenthesis just don't seem to be in the same league. Similarly,
header ordering shouldn't matter, or else the headers have serious
flaws in them to begin with (and if you're using seriously flawed
headers, then your code is suddenly seriously flawed too.)

The way you go on about the parens was a bit funny, but seemed to
emphasize it more than other points that actually have more
importance.
I was almost expecting to see an example with "improperly formatted"
code next, or the "right number" of spaces.

Maybe in response to one of the more egregious mistakes you need a
photoshopped picture of your head totally bald with a painful look
and a hand holding a clump of just-ripped-out hair. :)

Overall, I like it though.

Chris



On Jun 28, 3:51 pm, Olve Maudal <olve.mau...(a)gmail.com> wrote:
> At the NDC2010 conference, I gave a presentation where I demonstrated
> Solid C++ code by example:
>
> http://www.slideshare.net/olvemaudal/solid-c-by-example
>
> It would be great to have your opinion about the examples I present.
> Is this solid code, or can it be improved even further?
>
> Thanks,
> - olve
>
> --
> [ Seehttp://www.gotw.ca/resources/clcm.htmfor info about ]
> [ comp.lang.c++.moderated. First time posters: Do this! ]



--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]