05.08.2014 Views

here - Stefan-Marr.de

here - Stefan-Marr.de

here - Stefan-Marr.de

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.3. The OMOP By Example<br />

current :<br />

Domain<br />

initialDomainForNewObjects<br />

main()<br />

new<br />

set: #foo<br />

cell:<br />

Cell<br />

ImmutableDomain<br />

evaluateEnforced: [cell set: #bar]<br />

enforced<br />

adopt: cell<br />

set: #bar<br />

→ reqExecOf: #set on: cell with: #bar<br />

set: #bar<br />

write: #bar toField: 1 of: cell<br />

ImmutabilityError<br />

Figure 5.3.: Enforcing Immutability with the OMOP. This sequence diagram <strong>de</strong>picts<br />

a typical interaction between the application and a domain. The main program<br />

starts in unenforced execution mo<strong>de</strong> and creates a cell object. Since it has not<br />

specified any domain as yet, it executes in the context of the standard, i. e., uncustomized<br />

domain. During the creation of the cell object the current domain is<br />

used to <strong>de</strong>termine its initial owner. The main program continues to set an initial<br />

value for the cell (#foo) and then requests the immutable domain to adopt the<br />

cell object. This completes the initialization of the program and it enables the enforced<br />

execution mo<strong>de</strong>. When the main program now attempts to execute the setter<br />

method on the cell, the immutable domain will reify the execution. However,<br />

immutability does not interfere with method execution and thus, the request is<br />

granted and the setter is executed. Eventually, the setter will attempt to write the<br />

object field of the cell, which the immutable domain specifies a custom policies<br />

for. Thus, the write attempt results in an invocation of the #write:toField:of:<br />

intercession handler, which signals a violation of immutability and does not perform<br />

the state change.<br />

119

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!