Re: Too much encapsulation?
- From: rpbg123@xxxxxxxxx (Roland Pibinger)
- Date: Fri, 15 Jun 2007 10:29:49 GMT
On Fri, 15 Jun 2007 13:06:01 +1200, Ian Collins wrote:
copx wrote:[...]
If the type of "object" is incomplete, you could not write object->colour or
something like that, because accessing data of incomplete type is not
possible.
So do you consider that proper C style?
Yes, and it's a very common idiom (have you ever manipulated a FILE
object?).
Unfortunately you frequently see generous 'un-encapsulation' in C
code. Structs are defined completely in the header file but only
pointers to functions are used in the function declarations (other
'private' elements (defines, macros, enums) are also unnecessarily
placed into the header). Many programmers seem to be unaware of gratis
encapsulation.
Personally, I am not sure what to think of this. It seems to scream "Why doNothing to do with C++, unless you are using a similar idiom with opaque
you not use C++ already?!".
types, C++ classes lay their innards bare for all to see.
but not for all to access. Encapsulation is independent of language
and paradigm (it's not an original OO feature).
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
.
- Follow-Ups:
- Re: Too much encapsulation?
- From: Malcolm McLean
- Re: Too much encapsulation?
- References:
- Too much encapsulation?
- From: copx
- Re: Too much encapsulation?
- From: Ian Collins
- Too much encapsulation?
- Prev by Date: Re: More elegant UTF-8 encoder
- Next by Date: Regarding the sizeof a function
- Previous by thread: Re: Too much encapsulation?
- Next by thread: Re: Too much encapsulation?
- Index(es):