🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.objective-c
Article #84

Re: instance variable declarations..

#84
From: Bill Shirley [CSC]
Date: Thu, 03 Sep 1992 14:16
67 lines
3343 bytes
In article <1992Sep3.020352.1872@almserv.uucp>, bnixon@fnma.com (Bill Nixon) writes:
> Just my two cents:
> 
> It seems to me that declaring instance variables in an object's
> interface file somewhat breaks the idea of encapsulation and

/breaks/ is much to harsh a word.  I can't just include Class.h and
go about modifying it's IVs.

> abstraction that object-oriented languages should provide.
> 
> What I have seen done in other language specifications, most recently
> OS/2 SOM, is to provide three interface files (.h) for an object:

I think you meant 3 files - 2 interface files.

> 
> + public - which has all public instance variables and methods.
> Everything defined in this file is directly accessible, even instance
> variables.  This and the "compiled" code for the object is all an
> object user needs to have.
> 
> + private - which has all private instance variables and methods.
> All instance variables and methods declared in this file are limited
> in scope and cannot be directly accessed.  (Normally this is also
> the source file which contains all the code for the methods).

this is basically the source file, correct?  (.c/.m)

> 
> + class - which has all instance variables and methods which can
> be modified via inheritance.  An object subclasser would require
> this file along with the "compiled" code in order to write a subclass of
> the object.
> 
> I am more comfortable living in a private and public environment.
> Basically only put "need to know" data (methods and maybe a few
> instance variables) in the public interface file.  Since most instance
> variables should be private to provide true data abstraction, they would
> not be exposed and this may provide a simplier and "safer" view of the
> object.

I agree that most IVs should be treated as private by subclassers, but
I don't favor enforcing this via extra files, this could be more of a
bookkeeping hassle.  Use of the @public, @private, etc.. would be just
as affective and let you see it (and write it) all in one eyeshot.
(I also don't know for sure whether these are still supported, but I
 suspect they are.)

I don't think the code not knowing of the implementation should necessarily
imply that the programmer isn't knowledgeable of the implementation.

> 
> Bill
> -- 
> email: bnixon@fnma.com (NeXT Mail Okay)
> Bill Nixon, Senior Programmer Analyst, Advanced Technology
> FannieMae, 3900 Wisconsin Ave NW, Washington, DC 22016     (202) 752-5468

-- 
Bill Shirley		|  ``Computer Science is not about computers any 
shirley@fdr.jsc.nasa.gov|	more than astronomy is about telescopes.''

-- 
Bill Shirley		|  ``Computer Science is not about computers any 
shirley@fdr.jsc.nasa.gov|	more than astronomy is about telescopes.''
Technical Details
Message-ID: <1992Sep3.091617@fdr.jsc.nasa.gov>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!bcm!aio!shirley
References: <MAS.92Aug30121306@csa.bu.edu> <19385@ector.cs.purdue.edu> <1992Sep2.045715.5803@panix.com> <1992Sep3.020352.1872@almserv.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!bcm!aio!shirley
From: shirley@fdr.jsc.nasa.gov (Bill Shirley [CSC])
Newsgroups: comp.lang.objective-c
Subject: Re: instance variable declarations..
Message-ID: <1992Sep3.091617@fdr.jsc.nasa.gov>
Date: 3 Sep 1992 14:16:17 GMT
References: <MAS.92Aug30121306@csa.bu.edu> <19385@ector.cs.purdue.edu> <1992Sep2.045715.5803@panix.com> <1992Sep3.020352.1872@almserv.uucp>
Sender: shirley@fdr (Bill Shirley [CSC])
Organization: Software Technology Branch - NASA/JSC
Lines: 67
Originator: shirley@fdr