Elye - A One Eye Dev By His Grace
2 min readAug 26, 2020

--

Thanks for your further inputs. Appreciate your understanding.

What I wrote is not what I invented and think of. But it was what I once struggled to get into. The modern coder (those using languages like Scala, Swift, Kotlin) is already practicing these.

I hold dearly to some approach like the Hungarian Notation for naming convention but surprised to find out that Google is even discouraging it. There’s this entire new generation is heading it that way. Maybe the newer generation is just slacking away, and code will be less and less maintainable, etc. Or I’m loosing out some gist that perhaps I’m blinded with my past belief?

It took me a while to rationalize it. I agree some of the rationale is not the best, but what I state is indeed the practice today, where newer languages are adopting it. Even some older language is adopting some of it (e.g. C++11 is having type inferencing).

I don’t think anyone who reads my blog will then say, aha, I can be lazier now. There are 2 groups of people… the seasoned developers who will feel annoyed by what I state, as it’s not adhering to the golden rules (that I was also following once), or the newer generation of coders will just see that as something that’s already happened.

Another simple example is where the { should be. Someone debated with me over this state it should continue to be in the same column as it’s } as that’s what makes it legible. I agree if one printed out in a paper, that helps.

So I did a bit of research, only C# is following. However, all other languages since then have differed. Even C++ coding standard those states that, but in the standard reference, many of the examples no longer follow the example.

C++ standard reference which has a mixture of them, e.g. the convention is usually as below

https://isocpp.org/wiki/faq/coding-standards#coding-std-wars

void f(const std::vector<double>& v)
{
using std::cout;
cout << "Values:";
for (auto value : v)
cout << ' ' << value;
cout << '\n';
}

But you see the counter way of writing from

From https://isocpp.org/wiki/faq/coding-standards

class Foo {
// ...
static int xyz; // ...
// ...
}

and

namespace {
// ...
int xyz; // See the ...
// ...
}

and

void mycode()
{
// do_something_with(xyz);
↑↑ // The leading "//" improves ...
}

Their if-else doesn’t follow the C# approach

https://isocpp.org/files/papers/p0305r0.html

if (auto p = m.try_emplace(key, value); !p.second) {
FATAL("Element already registered");
} else {
process(p.second);
}

--

--

Elye - A One Eye Dev By His Grace
Elye - A One Eye Dev By His Grace

Written by Elye - A One Eye Dev By His Grace

Sharing Software Learning, Life and Faith Journey

No responses yet