Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » use of OCL: implement functionality or validate implementation against specifications (GMF)
use of OCL: implement functionality or validate implementation against specifications (GMF) [message #57217] Thu, 29 May 2008 18:52 Go to next message
Eclipse User
Originally posted by: birar01.ca.com

Hi', I'm an ocl newbie using it in the context of GMF and had a basic
question.

I've seen how ocl can be used as link constraints in GMF and that is a form
of functionality.

But it looks like the main purpose of OCL is to validate your java
implemenattion against the specifications. Sort of an assisted design by
contract.

A colleague has "implemented functionality" by using a
TransactionValidationListener:
* we don't check precoditions for an operation in java
* we evaluate the constraints in the transaction listener and if there are
problems we allow the user to cancel or change the values which were
modified.

What should be done in java what is better left for OCL?
I think character by charcter validation or field pattern validation is best
left to java esp with regular expressions. OCL can be used for
relationships/dependencies between objects and the state of objects.

thanks,

Arvinder
Re: use of OCL: implement functionality or validate implementation against specifications (GMF) [message #57242 is a reply to message #57217] Fri, 30 May 2008 02:52 Go to previous message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

--=-mB6xtvhqVBG0S4nxGeAd
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Arvinder,

OCL is well suited for specification of constraints in models, but if
you're talking about problems like validating the inputs into fields in
a form-based application, then it probably doesn't make sense. As far
as the Transaction and Validation components of EMF are concerned, OCL
is a convenient solution because it serves both as a *specification* of
constraints (in the model) and as a more-or-less practical
*implementation* of the constraints when it is interpreted at run-time.

The practicality of using OCL for constraints can be very much
influenced by the model design. A model that is richly provided with
operations, derived attributes, etc. that allow OCL constraints to be
concisely specified is helpful. OCL expressions can easily become too
complex to be easily managed or verified. Of course, it isn't
necessarily appropriate to make a model more complex just to simplify
the definition of OCL constraints.

GMF's usage of OCL in link constraints is great, but it has the
potential to be over-used. Barring the user from completing a gesture
in the diagram editor isn't always the right thing to do. Sometimes, it
is better to leave validation to an ad-hoc model-checking operation
rather than preventing a user gesture, if the the constraint that would
be violated by a gesture can be resolved in a number of different ways.
A classic example that I use is the circular generalization of
classifiers in UML or Ecore models. Preventing the user drawing a
generalization that completes a cycle may not be appropriate, if the
user actually wants to create that particular generalization
relationship and needs to resolve the circularity problem by removing
some other generalization that is not immediately accessible in the
current context.

I hope this somehow answers your question.

Christian

On Thu, 2008-05-29 at 13:52 -0500, arvinder birdi wrote:

> Hi', I'm an ocl newbie using it in the context of GMF and had a basic
> question.
>
> I've seen how ocl can be used as link constraints in GMF and that is a form
> of functionality.
>
> But it looks like the main purpose of OCL is to validate your java
> implemenattion against the specifications. Sort of an assisted design by
> contract.
>
> A colleague has "implemented functionality" by using a
> TransactionValidationListener:
> * we don't check precoditions for an operation in java
> * we evaluate the constraints in the transaction listener and if there are
> problems we allow the user to cancel or change the values which were
> modified.
>
> What should be done in java what is better left for OCL?
> I think character by charcter validation or field pattern validation is best
> left to java esp with regular expressions. OCL can be used for
> relationships/dependencies between objects and the state of objects.
>
> thanks,
>
> Arvinder
>
>

--=-mB6xtvhqVBG0S4nxGeAd
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Arvinder,<BR>
<BR>
OCL is well suited for specification of constraints in models, but if you're talking about problems like validating the inputs into fields in a form-based application, then it probably doesn't make sense.&nbsp; As far as the Transaction and Validation components of EMF are concerned, OCL is a convenient solution because it serves both as a *specification* of constraints (in the model) and as a more-or-less practical *implementation* of the constraints when it is interpreted at run-time.<BR>
<BR>
The practicality of using OCL for constraints can be very much influenced by the model design.&nbsp; A model that is richly provided with operations, derived attributes, etc. that allow OCL constraints to be concisely specified is helpful.&nbsp; OCL expressions can easily become too complex to be easily managed or verified.&nbsp; Of course, it isn't necessarily appropriate to make a model more complex just to simplify the definition of OCL constraints.<BR>
<BR>
GMF's usage of OCL in link constraints is great, but it has the potential to be over-used.&nbsp; Barring the user from completing a gesture in the diagram editor isn't always the right thing to do.&nbsp; Sometimes, it is better to leave validation to an ad-hoc model-checking operation rather than preventing a user gesture, if the the constraint that would be violated by a gesture can be resolved in a number of different ways.&nbsp; A classic example that I use is the circular generalization of classifiers in UML or Ecore models.&nbsp; Preventing the user drawing a generalization that completes a cycle may not be appropriate, if the user actually wants to create that particular generalization relationship and needs to resolve the circularity problem by removing some other generalization that is not immediately accessible in the current context.<BR>
<BR>
I hope this somehow answers your question.<BR>
<BR>
Christian<BR>
<BR>
On Thu, 2008-05-29 at 13:52 -0500, arvinder birdi wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi', I'm an ocl newbie using it in the context of GMF and had a basic </FONT>
<FONT COLOR="#000000">question.</FONT>

<FONT COLOR="#000000">I've seen how ocl can be used as link constraints in GMF and that is a form </FONT>
<FONT COLOR="#000000">of functionality.</FONT>

<FONT COLOR="#000000">But it looks like the main purpose of OCL is to validate your java </FONT>
<FONT COLOR="#000000">implemenattion against the specifications. Sort of an assisted design by </FONT>
<FONT COLOR="#000000">contract.</FONT>

<FONT COLOR="#000000">A colleague has &quot;implemented functionality&quot; by using a </FONT>
<FONT COLOR="#000000">TransactionValidationListener:</FONT>
<FONT COLOR="#000000">* we don't check precoditions for an operation in java</FONT>
<FONT COLOR="#000000">* we evaluate the constraints in the transaction listener and if there are </FONT>
<FONT COLOR="#000000">problems we allow the user to cancel or change the values which were </FONT>
<FONT COLOR="#000000">modified.</FONT>

<FONT COLOR="#000000">What should be done in java what is better left for OCL?</FONT>
<FONT COLOR="#000000">I think character by charcter validation or field pattern validation is best </FONT>
<FONT COLOR="#000000">left to java esp with regular expressions. OCL can be used for </FONT>
<FONT COLOR="#000000">relationships/dependencies between objects and the state of objects.</FONT>

<FONT COLOR="#000000">thanks,</FONT>

<FONT COLOR="#000000">Arvinder</FONT>


</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-mB6xtvhqVBG0S4nxGeAd--
Previous Topic:Re: Getting tha value of an enumeration attribute (eGet())
Next Topic:OCL context for an attribute?
Goto Forum:
  


Current Time: Thu Sep 18 11:57:57 GMT 2014

Powered by FUDForum. Page generated in 0.01950 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software