The Artima Developer Community
Sponsored Link

Agile Buzz Forum
Private/Public/Protected explained

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
Private/Public/Protected explained Posted: Oct 20, 2003 5:10 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: Private/Public/Protected explained
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement
Martin Fowler explains what private/protected/public mean in terms of Smalltalk, Java, C++, and C#. The following was useful to me:

Smalltalk is often considered to be the purest OO language, and predates C++, Java, and C#. It didn't use keywords to control access, but used a basic policy. Smalltalkers would say that fields were private and methods were public.

However the private fields don't really mean the same as what they mean in C++ based languages. In C++ et al aaccess is thought of as textual scope. Consider an example with a class Programmer which is a subclass of class Person with two instances: Martin and Kent. In C++ since both instances are of the same class then Martin has access to the private features of Kent. In Smalltalk's world view access is based on objects, so since Martin and Kent are different objects Martin has no business getting at Kent's fields. But again, since everything is object based Martin can get at all his fields even if they were declared in the Person class. So data in Smalltalk is closer to protected than private, although the object scope makes things different in any case.

Lots more good stuff, especially for those of you working in a mixed language paradigm - I expect that it would be very easy to have misunderstandings based on simple misconceptions of these terms across languages

Read: Private/Public/Protected explained

Topic: Learn something new every day Previous Topic   Next Topic Topic: The grass is... what color?... on the other side?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use