tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Armstrong <a...@tagish.com>
Subject Re: [J-T-C] struct defs
Date Thu, 05 Jul 2001 09:19:07 GMT
GOMEZ Henri wrote:
> 
> >The reason would be to keep the implementation details of the structure
> >private so that people aren't tempted to access the fields
> >directly. All
> >the caller gets is an opaque handle. Think of it as 'objects lite' for
> >C.
> 
> I could understand the OO construction if we were using C++
> but in strict K&R when you need to have access elements in
> a struct you need to know about them ?)
> 
> The goal is to have functions defs in .c and data defs in .h
> preparing scandoc task
> 
> So what about that repartition ?

No, I think it's right as it stands. Just because we're working in C
doesn't mean we can't do encapsulation. This is a perfectly valid idiom
to express the concept of some.c and some.h working together to
implement a 'class' which is only accessed through a functional
interface. The encapsulation benefits are the same as for Java or C++.
For one thing it means that the implementation in some.c can change
without impacting client code.

I haven't looked at any of the specific cases you're talking about, but
in general I would say that this is good programming style. 

-- 
Andy Armstrong, Tagish

Mime
View raw message