Re: attack of silly coding standard?
?? Tiib <ootiib@hot.ee> wrote:
"Daniel T." <danie...@earthlink.net> wrote:
Tiib <oot...@hot.ee> wrote:
"Daniel T." <danie...@earthlink.net> wrote:
Leigh Johnston <le...@i42.co.uk> wrote:
Daniel T. wrote:
Student<n...@amitrader.com> wrote:
mojmir wrote:
I'd like to know you professional opinion on following
coding rule freshly imposed by my beloved employer:
"Thou shalt not have multiple returns from function"
Personally i hardly understand that one, apart from
"readability" argument which i would hardly qualify as
sufficent to impose such rule. When i think about it i
found the exact opposite true, that multiple returns
improve readability :)
Those idiots who enforce such stupid rules have no idea of
OOP.
FYI, OOP has no bearing on the rule in question whatsoever.
It does if you consider RAII as part of C++'s OOP.
It does if you consider the rule itself as part of C++'s OOP
too. But why would you would consider either the single exit
rule, or RAII to be an OOP concept?
You consider idiom only as a way to achieve some concept. RAII is
useful idiom of encapsulation. Resources are always bound to
(automatic) lifetime management of some object. Encapsulation is
one of most fundamental concepts of object oriented programming.
Lifetime management and encapsulation are orthogonal issues (the
lifetimes of objects need to be managed whether they are
encapsulated or not,) so RAII, as a concept of lifetime management,
has nothing to do with encapsulation; even if it did, encapsulation
is the essence of modular programming which came long before OOP.
With each resource acquisition some object is initialized. That way
the acquired resources are always encapsulated in objects. All
resources, like locks or file handles or dynamically allocated
objects. I am not sure why you say it is not encapsulation?
Most programming paradigms have some common concepts with other
paradigms. That is natural. Why it matters what was long before and
what was after?
Most programming paradigms build on what came before and OO is no
exception. I think that some people tend to forget that we were
programming successfully long before OO existed, and that not all
programming concepts are OO concepts. By the comment that Student made,
I thought that he could use a reminder that OO is not the beginning and
end of programming.
As such, I stand by my position that the rule in question has
nothing to do with OOP.
The idiom is only used by programmers of some object-oriented
languages. C++, Ada and D. It has something to do with ways how OOP
concepts are supported by these languages.
Above you asked why it matters, yet you continue to argue the point as
if it does matter. Now it's my turn, why is it so important to you that
'single exit,' and RAII be considered related to OOP?
The reason my FYI above was so terse was precisely because I didn't
think the subject deserved more than a quick reminder to Student.
Looking at the responses to that comment, I'm beginning to wonder why
several others want to insist that a "single exit vs multiple exit"
discussion relates to the object-oriented paradigm.