Mathematica: Webel ADT pseudo classes: The ADT⊙get method may be used to access the '$$' wrapped primary. This is intended for development and testing purposes only (not for regular use by clients) since it BREAKS ENCAPSULATION!

Webel IT Australia promotes the amazing Mathematica tool and the powerful Wolfram Language and offers professional Mathematica services for computational computing and data analysis. Our Mathematica tips, issue tracking, and wishlist is offered here most constructively to help improve the tool and language and support the Mathematica user community.
DISCLAIMER: Wolfram Research does not officially endorse analysis by Webel IT Australia.
Icon class
icon_class
far fa-sticky-note
icon_class_computed
far fa-sticky-note
Note kind
Policy level
Webel Mathematica keywords
Keywords

This recommendation is intended to encourage more robust OO encapsulation practices, but is not enforceable with a Webel ADT anyway, since given an ADT "instance" variable any client can of course still access any wrapped content. For example, for a base ADT wrapping a single expression the wrapped expression can still be accessed as the 1st Part:

adt1 = ADT["anything"]
ADT["anything"]

adt1[[1]]
"anything"

Compare with, say, a Java class with a private field populated by construction but with no public accessor. By language design clients can't access the field value.

In principle, a well designed ADT will offer value-adding methods that use the wrapped primary '$$' expression (and any other wrapped expressions); if a client is accessing the wrapped '$$' it may be side-stepping the entire reason for having the ADT in the first place (breaking the "The Law of Demeter" if '$$' is an ADT).

Where a client is to be permitted access to the wrapped primary '$$' anyway, it's best to use an additional method that just delegates to the get method but has a name that makes its purpose in exposing the wrapped primary '$$' clear.

Closely related "friend" ADT classes within a single Package may freely access get.

Relates to:

Relates to
Related notes
Related notes (backlinks)
Related snippets (extracts)
Visit also
Visit also (backlinks)
External links