Re: Scope variable pattern
Re: Scope variable pattern
- Subject: Re: Scope variable pattern
- From: Yakov Zaytsev <email@hidden>
- Date: Fri, 11 May 2007 20:09:59 +0400
On May 11, 2007, at 7:54 PM, Erik Buck wrote:
I am a very accomplished C++ programmer with more than a decade of
experience writing and maintaining C++ code. I have to ask, why do
you want to replace two lines of code that are explicit and
intention revealing with the trick of relying on a side effect of
constructor/destructor semantics that conceals the intent of the
code ?
struct ScopedDoing {
ScopedDoing () { /* doing.. */ }
~ScopedDoing () { /* clean up.. */ }
};
..
<some function body>
{ ScopedDoing aScopedDoing; ...
}
..
The poor slob who has to figure out what your code does now
absolutely must go look up the implementation of the ScopedDoing
class in order to understand what <some function body> does.
It's a standard pattern... You should apply Intention Revealing Names
pattern to ensure understandable names etc..
<some ...body> is a client code which is surrounded with typical
thing like locking a mutex, opening/closing something etc.. logging
whatever..
In all seriousness, have you ever heard of the "obfuscated C
contest" ? http://en.wikipedia.org/wiki/
International_Obfuscated_C_Code_Contest
There is no reason to hold an obfuscated C++ contest. Have you
ever seen the logic of a program implemented in a constructor so
that the main function for the program looks like this:
int main(int argc, const char *argv[])
{
SomeClass anInstance;
return 0;
}
How is what you want different except in degree of obfuscation ?
I am not trying to start a language war. I use C++ daily, and I
have seen lots of fast elegant easily maintained C++ code. I am
just struck by the absurdity of this particular request. However,
I fully agree that my perception of absurdity may be different that
other people's.
What do you tell if you must write say 10..20 functions with same
beginning and endings?? Think about it ;)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40envionsoftware.com
This email sent to email@hidden
---
Yakov Zaytsev
Envion Software http://www.envionsoftware.com
<Talk Small and Carry a Big Class Library>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden