Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

My updated "C++ coding style" page now is also in English

68 views
Skip to first unread message

Szyk Cech

unread,
Jul 7, 2019, 12:51:04 AM7/7/19
to
Hi

I just finish update my web page about coding style under renamed title:
"C++ coding style". Now it is available also in English language.

In this document I cover all good solutions for one who wants write good
C++ code. I collect this rules from many books, over 22 years of
programming in C++ (home and commercial projects). Now I share this
notices with you.

Note: this site loads with Polish language at start, but you can switch
language to English by use combo in left uper corner of the page.

This page should be accessible from following sites:
http://szyk.jcom.pl/stylkodu.html
http://szyk.free.of.pl/stylkodu.html
http://szykcech.cba.pl/stylkodu.html
http://szyk.000webhostapp.com/stylkodu.html
http://www.geocities.ws/szyk/stylkodu.html
http://szyk.wex.pl/stylkodu.html

I encourage you to merit disscusion about C++ coding rules, document
style, and my English grammar mistakes (I am not native English speaker)
in order to improve this page content and form.

best regards
Szyk Cech

Juha Nieminen

unread,
Jul 7, 2019, 6:28:59 AM7/7/19
to
Szyk Cech <szyk...@spoko.pl> wrote:
> http://szyk.jcom.pl/stylkodu.html

This both is too simplistic, and at the same time goes too much into
nitpicking useless advice.

Any style guide that *recommends* "using namespace std;" is immediately
suspect (especially if it says "usning".)

Also any style guide that recommends things that the standard libraries
don't do is also suspect, such as demanding that all destructors be
virtual. (Basically no class in the standard library that has a
destructor has a virtual destructor, with only some exceptions.)

Limiting line length to 77 characters has been obsolete for decades.
There's nothing special about the number 80 in this respect in the
modern world, and hasn't been for decades. (And why exactly 77, and
not for example 78, or 76? What's so special about 77 in particular?)

I don't even understand what "No use private clause in function
declaration" is supposed to mean.

Szyk Cech

unread,
Jul 7, 2019, 7:39:26 AM7/7/19
to
W dniu 07.07.2019 o 12:28, Juha Nieminen pisze:

> Any style guide that *recommends* "using namespace std;" is immediately
> suspect (especially if it says "usning".)

Spieling fixed!

But why it "is immediately suspect" - what is wrong to use in *.cpp such
clause - if you don't have any conflicted code.
Use this clause in *.h can potentially broke your code, but in *.cpp
this usage looks safe.

> And why exactly 77, and
> not for example 78, or 76? What's so special about 77 in particular?

This is due to language sybolics. People differ from animals in many
ways. One of them is they should put importance about right symbolics.
This can be real (and controled) blesing.

One of most common sybolics is pseudo translation words from one meaning
to another. I show you this in your language:
Lets say we have name like: "Area 51". What aliens so much likes its
symbolics? I can tell you: This is translated to: "Area fifty (for)
one". Great deal! - isn't it?!?
The same is about "80 characters per line" in Polish translated means
some thing like this: "moose dozens fixed in line". And in Poland we
talk somebody is "moose" when we think it is not very cleaver or even is
stupid. "77 characters per line" in Polish means some thing like this:
"self dozens self fix in line" - and I suppose it means that with this
you will make your self stronger dozens times.

Symbolics is something does not work immediately, but after some time,
just like Karma algorithms (in true Greyer the sybolic executor can
write artifical algorithm to human Karma which is set of future
feelings). More about Karma here: http://totalizm.pl/karma.htm
Note about Karma explorer (prof. Jan Pająk): he was unaware that every
human has its own supervisor who patiently watch and judge your every
move. You can prove this to your self if you will notice when you
sneeze, sight, or cough (in the cases you are not sick). All of such
behaviour is artificial and connected with current your thought or speak
(typically when you think or talk nonsense). There are many more
evidences of such supervisors - stay tuned - then you will notice them.

So do you still think it is stupid? If so you must also claim you are
smarter than hyper-intelligent Greys which puts great attention to
execute sybolics made by humans.

> I don't even understand what "No use private clause in function
> declaration" is supposed to mean.

Fixed!


Thank for your reply. You help improve my "C++ coding style" page.
best regards
Szyk Cech

seeplus

unread,
Jul 7, 2019, 9:48:47 AM7/7/19
to
On Sunday, July 7, 2019 at 9:39:26 PM UTC+10, Szyk Cech wrote:

> Spieling fixed!
/Snips/

> Thank for your reply. You help improve my "C++ coding style" page.

A couple of years ago, many experts in writing C++ established best
(or recommended) practice in >> "C++ Core Guidelines".
The major software organisations and some of the best programmers
in the world have contributed, and generally agree on these rules.
In Visual Studio you can click a box to have your code checked against
the rules.
If you want to discuss or argue them, then then go to the site/s authors.
Please don't tell them that I sent you.

For a long time now "symbolic execution" is covered by "unit testing".
"Karma" has NOTHING to do with C++ and just exists in befuddled
superstitious minds.

Szyk Cech

unread,
Jul 7, 2019, 10:53:45 AM7/7/19
to
W dniu 07.07.2019 o 12:28, Juha Nieminen pisze:
> This both is too simplistic, and at the same time goes too much into
> nitpicking useless advice.

So:
1. Code with bad style does not exists?
2. Did you suppose programming manual instead "Coding style
recommendations"?

Manfred

unread,
Jul 7, 2019, 11:35:06 AM7/7/19
to
On 7/7/2019 1:39 PM, Szyk Cech wrote:
> W dniu 07.07.2019 o 12:28, Juha Nieminen pisze:
>
> > Any style guide that *recommends* "using namespace std;" is immediately
> > suspect (especially if it says "usning".)
>
> Spieling fixed!
>
> But why it "is immediately suspect" - what is wrong to use in *.cpp such
> clause - if you don't have any conflicted code.
> Use this clause in *.h can potentially broke your code, but in *.cpp
> this usage looks safe.

Namespaces have been introduced in C++ for a number of reasons. When you
write "using namespace std;" you throw away all of them for the standard
library.
This should ring a few bells.

<snip>

>> I don't even understand what "No use private clause in function
>> declaration" is supposed to mean.
>
> Fixed!

Fixed?

From your page:
===================================================
No use private sections in class declaration
This is wrong:


class MyClass
{
public:
MyClass(int aX, int aY, int aWidth, int aHeight);
void show();
private:
void paint();
private:
int mX = 0;
int mY = 0;
int mWidth = 0;
int mHeight = 0;
};


This is good:


class MyClass
{
public:
MyClass(int aX, int aY, int aWidth, int aHeight);
void show();
protected:
void paint();
protected:
int mX = 0;
int mY = 0;
int mWidth = 0;
int mHeight = 0;
};
======================================================

From Bjarne's book:
"Members declared protected are far more open to abuse than members
declared private. In particular, declaring data members protected is
usually a design error."
Which is exactly what you are recommending here...

Szyk Cech

unread,
Jul 7, 2019, 12:21:06 PM7/7/19
to
W dniu 07.07.2019 o 17:34, Manfred pisze:
> From Bjarne's book:
> "Members declared protected are far more open to abuse than members
> declared private. In particular, declaring data members protected is
> usually a design error."
> Which is exactly what you are recommending here...

Ok. I can explain why I hate private functions and private variables and
not virtual destructors:

I use Qt library for long time (10 years), before I program in C++
Builder for 10 years.
Over the years many times I try to do things not imagined by library
creators (Qt, VCL and others). I hate them much, because some times
they limited me from innovations in the way my apps work.

For example: I want to write user emulation tests - by emulate user
behaviour like mouse clicking and keyboard pressing, and I want to
emulate menu clicking by using standard function calls (not automated
mouse clicking because I can't be sure where is menu on the screen). But
I can't do it due to lack such functions exposed by QMenu. People makes
funny and very complicated solutions to this problem, but I want do it
in Qt way (mean: easy). The same problem cause I can't properly
show/hide menu when right alt is pressing - because I can't control menu
focus.
In this case subclass does nothing because Qt use other "modern trick":
it use internal object under private pointer called "d" (like data) with
not defined type. And this internal class stores all internals of the Qt
class. Most Qt classes are programmed in this way.

My last problem was: Qt does not use exceptions, but I want use them to
make sensible error handling. So I want to write my own Query class
subclass of QSqlQuery. But it is impossible due to non virtual
destructor in QSqlQuery (it will not close database connection when I
delete it).

I think this is not user friendly because library vendor have no
problems when you extend class in your way. I don't think library
vendors know better than user what is good for him/her.

best regards
Szyk Cech

Öö Tiib

unread,
Jul 7, 2019, 6:14:22 PM7/7/19
to
On Sunday, 7 July 2019 17:53:45 UTC+3, Szyk Cech wrote:
> W dniu 07.07.2019 o 12:28, Juha Nieminen pisze:
> > This both is too simplistic, and at the same time goes too much into
> > nitpicking useless advice.
>
> So:
> 1. Code with bad style does not exists?

It does and requiring couple questionable things does not help it.

> 2. Did you suppose programming manual instead "Coding style
> recommendations"?

Maybe read first what some others suggest?
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md
It contains piles of good advice how to program in C++.

Vir Campestris

unread,
Jul 8, 2019, 4:16:46 PM7/8/19
to
On 07/07/2019 11:28, Juha Nieminen wrote:
> Limiting line length to 77 characters has been obsolete for decades.

We've got that in our newly introduced standard. Apparently it came from
Google.

Andy

Alf P. Steinbach

unread,
Jul 8, 2019, 4:58:33 PM7/8/19
to
Some people noticed when Google dispensed with the "do no evil", and
wrote about it, but I think not more than a handful.

Corporate structures and bureaucracies are like that.

Mindless submission to arbitrary, outdated, often counter-productive rules.

My pet hypothesis is that the effect of knowledge is so strong and
positive that even when 95% of what one believes is bullshit, the 5%
mostly correct stuff more than makes up for the negative effects of the
rest.

So, these human organizations get by.


Cheers!,

- Alf

Öö Tiib

unread,
Jul 8, 2019, 5:18:13 PM7/8/19
to
On Monday, 8 July 2019 23:58:33 UTC+3, Alf P. Steinbach wrote:
>
> Some people noticed when Google dispensed with the "do no evil", and
> wrote about it, but I think not more than a handful.

It was "don't be evil" what they removed. Slogans like "do no evil"
or "do the right thing" are indicating stupidity (ignorance of our
almost total lack of foresight).


Heinz Müller

unread,
Jul 9, 2019, 4:39:32 AM7/9/19
to
Your styleguide is phantastic! Everyone should adhere to that!!!!

Juha Nieminen

unread,
Jul 10, 2019, 5:33:03 AM7/10/19
to
Szyk Cech <szyk...@spoko.pl> wrote:
>> And why exactly 77, and
>> not for example 78, or 76? What's so special about 77 in particular?
>
> This is due to language sybolics. People differ from animals in many
> ways. One of them is they should put importance about right symbolics.
> This can be real (and controled) blesing.
>
> One of most common sybolics is pseudo translation words from one meaning
> to another. I show you this in your language:
> Lets say we have name like: "Area 51". What aliens so much likes its
> symbolics? I can tell you: This is translated to: "Area fifty (for)
> one". Great deal! - isn't it?!?
> The same is about "80 characters per line" in Polish translated means
> some thing like this: "moose dozens fixed in line". And in Poland we
> talk somebody is "moose" when we think it is not very cleaver or even is
> stupid. "77 characters per line" in Polish means some thing like this:
> "self dozens self fix in line" - and I suppose it means that with this
> you will make your self stronger dozens times.

I almost feel like you are trolling right now. You can't be serious.

Juha Nieminen

unread,
Jul 10, 2019, 5:36:07 AM7/10/19
to
Szyk Cech <szyk...@spoko.pl> wrote:
> Ok. I can explain why I hate private functions and private variables and
> not virtual destructors:

Quite clearly you have no understanding of the principles of classical
object-oriented programming, and you are trying to pass your personal
preferences and distastes, which are based on your lack of understanding
of the principles of OOP, as if they were some kind of recommended
coding styles for C++.

Just because *you* don't like private member functions and variables
doesn't mean it's a good idea to recommend nobody use them.

Juha Nieminen

unread,
Jul 10, 2019, 5:42:12 AM7/10/19
to
Heinz Müller <Heinz.M...@gmail.com> wrote:
> Your styleguide is phantastic! Everyone should adhere to that!!!!

Examining the headers of this post makes me suspect that it's just
a sock puppet by the OP.

Heinz Müller

unread,
Jul 10, 2019, 8:25:56 AM7/10/19
to
>> Your styleguide is phantastic! Everyone should adhere to that!!!!

> Examining the headers of this post makes me suspect that it's just
> a sock puppet by the OP.

No, I'm just convinced of the quality of his work.

Öö Tiib

unread,
Jul 10, 2019, 8:35:57 AM7/10/19
to
But avoiding non-desirable hidden meanings is often quite good
idea.

The metaphors, bywords, double entendre and other "symbolics"
are common technique of ambiguity and hidden meanings in all
advanced human languages. The languages are literally full of
such. Perhaps because skill in flattering, joking, weaseling,
trolling, conspiring and bullshitting is major key of success.
People want to say (or to sing) something that isn't
unequivocally and clearly in the words, yet is there.

For example bullshitting: "flexibility" is often used
as byword to mean desire of diminution of standards or rights
of workers. So often that one who does not want to sound
like weasel will say "elasticity", "adaptability" or
"resilience". That until the weasels notice and switch also
over.

Strange ambiguity of word "dozen" (12 or 10) in Polish?
It is way larger than that of a word "kilo" in IT (1024 or 1000).
That indicates desire of being ambiguous in numbers, perhaps for
advantages in trade with gullible.

0 new messages