TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

What is meant by “protection” in real OOP?

5 pointsby tresilienceabout 5 years ago
I read up on the history of Smalltalk and Object Oriented Programming, and one thing I have not quite grasped is the idea of &quot;protection.&quot;<p>I know you can protect methods from being accessed by making them private or protected in certain programming languages but something else must be meant here.<p>Do you protect objects from being changed? Do you protect them from being &quot;talked to&quot; &#x2F; responding with valuable returns to unauthorized requests &#x2F; initial-message-senders? To what purpose?<p>And how exactly are they being protected, by what mechanism so to speak? (particularly in Smalltalk)

2 comments

7373737373about 5 years ago
Encapsulation[0] might be the term you are looking for. Enforcing object boundaries makes it easier to reason about program behavior and enforce security guarantees.<p>If objects can only change their own data, then all change affecting the object is either caused by the object itself, or indirectly by another when information crosses the interface the boundary presents (e.g. a message was received).<p>Most languages use a memory model that doesn&#x27;t even have the concept of access rights, everything can potentially affect anything else. If your program has to be secure, this is a nightmare.<p>[0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Encapsulation_(computer_programming)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Encapsulation_(computer_progra...</a><p>Also interesting:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Message_passing" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Message_passing</a><p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Capability-based_security" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Capability-based_security</a><p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Agent-based_model" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Agent-based_model</a><p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Actor_model" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Actor_model</a>
评论 #22970124 未加载
xkriva11about 5 years ago
In Smalltalk, the only way how to communicate to objects is by sending messages. The way how they react on the messages is full the responsibility of objects, and they can refuse them. This decision is strictly late-bound because all message passing in Smalltalk is late-bound. You may say that all the methods in Smalltalk are &quot;public&quot;, but it is not the very same meaning as in other languages.<p>The objects store the state in instance variables. You cannot access the instance variables of objects from outside of the object. All instance variables are &quot;protected&quot; in the terminology of C++.
评论 #22966049 未加载