On 21/03/18 03:29, Alf P. Steinbach wrote:
> On 16.03.2018 05:27,
ujjwol....@gmail.com wrote:
>> Looking for some example of stellar code for educational purpose. Any
>> recommendations?
>
> I just released version 1.0 of my “Empty files as Unicode” Notepad++
> extension,
>
> <url:
>
https://github.com/alf-p-steinbach/NPP-plugin-Empty-files-as-Unicode>
>
> From the recent ISOCPP developer survey it seems that roughly 0% of C++
> developers use Notepad++. So it is perhaps sillyware, this. Still.
Notepad++ is often used as a programmers' editor on Windows by people
looking for something a bit lighter than Eclipse. Most C++ programmers
on Windows will, of course, be using MSVC or perhaps Borland, and these
have their own IDEs. People doing embedded development (especially when
the toolchain comes with a poor IDE) or working with other compilers
such as mingw64 gcc, however, will find more use it. So the percentage
of users is going to be a little higher than 0%, I think. (Remember the
percentage of C++ developers who would have seen or responded to an
ISOCPP survey is also roughly 0%.)
>
> It's mostly simple down to Earth code, but I use modern C++ trailing
> return type syntax for function declarations, while most C++ programmers
> still stick to the C style syntax wherever they can (they can't for
> lambdas and for some template stuff, so they unwillingly mix two
> syntaxes while muttering a stream of unspeakables about dang newfangled
> stuff). I.e. the modern C++ syntax in this code is still unconventional
> at this point. Also, I use `ptr_` and `ref_` type builders with uniform
> prefix `const` notation, instead of the old C declaration syntax with
> mixed or suffix `const`, and that's /really/ unconventional.
>
Your style is, shall we say, different from the mainstream. IMHO, it is
a less bad kind of different from some of the other regulars in this
newsgroup. But I doubt that using trailing return types when they are
not needed is likely to become popular.
> It's also perhaps unconventional in its general structure where I've
> relied on C++ mechanisms such as static initialization instead of the
> common C style Notepad++ “framework”.
>
That is a more questionable decision.
A key point about style - either coding style, or design style - is that
it should be consistent. When you are working on an existing project it
is usually more important to be consistent with the rest of the code,
than to use a "better" style.
> So, it's solid, clear code; it's not stellar, nothing fancy here; it's
> unconventional in the three aspects mentioned (function syntax, type
> builders, structure), namely that it's C++ oriented instead of C style.
>
It sounds like a fine example for the OP. Being unconventional, but
with a rational and consistent choice of conventions, should be good for
showing students that there are many ways to write code.