From: Orrin on
I came across the terms Semantic and Syntactic encapsulation today,
but have not been able to find a good explanation of them on the web?
Could anyone help out?

From: Phlip on
Orrin wrote:

> I came across the terms Semantic and Syntactic encapsulation today,
> but have not been able to find a good explanation of them on the web?
> Could anyone help out?

Syntactical encapsulation is just the 'private' stuff. The compiler catches
attempts to abuse it. The C++ 'const' keyword also applies there.

A good example of semantic encapsulation is the Liskov Substitution
Principle. Client code breaks encapsulation when it changes its own behavior
due to accidental detection of its servant code's concrete type. The
compiler probably wouldn't detect that. Google up some LSP explanations to
see what I mean.

--
Phlip
http://www.oreilly.com/catalog/9780596510657/
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax


From: S Perryman on
Orrin wrote:

> I came across the terms Semantic and Syntactic encapsulation today,

Where did you come across them ??


> but have not been able to find a good explanation of them on the web?
> Could anyone help out?

I did a net search for the terms and found some definitions/explanations.
They may not have been brilliant, but they all seemed to relate to the
same subject area.

So what did you find during your info search ??


Regards,
Steven Perryman
From: Mark Nicholls on
On 9 May, 19:58, Orrin <ofiand...(a)gmail.com> wrote:
> I came across the terms Semantic and Syntactic encapsulation today,
> but have not been able to find a good explanation of them on the web?
> Could anyone help out?

I've never come across the terms before and the only recognised
reference I can find is from 'code complete'.....

Basically syntactical encapsulation is making methods only used by a
the internal workings of a class 'private'.

The signature (a syntactical entity) is encapsulated.

class CFoo
{
public void DoSomethingPublic()
{
...
this.DoSomethingPrivate();
....
}

// this is syntactically encapsulated.
private void DoSomethingPrivate()
{
.....
}
}

Semantic encapsulation is the notion about knowing how a specific
implementation works...and then (not) using that externally.


class CBar
{
public void DoSomethingPublicStart()
{
File file = CreateFile("abc");
}

public void DoSomethingPublicFinish()
{
DeleteFile("abc");
}
}

knowing that CBar creates a file (and this is not part of the contract
on the methods), and using that information externally, is breaking
the semantic encapsulation of the class.

They are not really terms I would personally use.

From: Orrin on
Steven, these terms were used in an online programming course offered
through my company. The terms were used without any proper
definition. In looking on the web, I found a few brief mentions, but
nothing that I cleared it all up for me.


On May 10, 1:30 am, S Perryman <q...(a)q.net> wrote:
> Orrin wrote:
> > I came across the terms Semantic and Syntactic encapsulation today,
>
> Where did you come across them ??
>
> > but have not been able to find a good explanation of them on the web?
> > Could anyone help out?
>
> I did a net search for the terms and found some definitions/explanations.
> They may not have been brilliant, but they all seemed to relate to the
> same subject area.
>
> So what did you find during your info search ??
>
> Regards,
> Steven Perryman