Zurück zu Willert.de

How to avoid breaking the encapsulation rule

Rhapsody Model or Codegeneration topics

How to avoid breaking the encapsulation rule

Beitragvon Ursanio » März 12th, 2014, 9:53 am

Hi guys,

I have general question regarding classes and encapsulation when using Rhapsody in C.

Every class can have methods (operations) and attributes. So far so good :).
Nevertheless If I have two classes and want them to communicate via events, then I have to
link them with association (so that FIRE or CGEN knows whom to send event).

------- association -------
C1 ------------------ C2
------- -------
Now I can pass events between C1 and C2 but unfortunatelly, C1 and C2 can access
each other's attributes (and someone with bad practice can access those attributes
directly instead of using interface functions of respective class).

Since I am using Rhapsody in C, private and public visibility property does not change the
generated code.

Is there a way to solve this problem within Rhapsody for C itself?

best regards,

uros
Ursanio
 
Beiträge: 9
Registriert: Oktober 2nd, 2013, 9:40 am

Re: How to avoid breaking the encapsulation rule

Beitragvon wvdheiden » März 12th, 2014, 12:07 pm

Good question. Frankly I don't know any method to accomplish that other than self-discipline.

Walter
===============================================
Who is General Failure and why is he reading my drive?
Benutzeravatar
wvdheiden
 
Beiträge: 52
Registriert: Oktober 5th, 2007, 10:31 am
Wohnort: Hellendoorn, the Netherlands
Firma: Willert Software Tools GmbH

Re: How to avoid breaking the encapsulation rule

Beitragvon Ursanio » März 12th, 2014, 12:21 pm

Hi walter, all,

What comes to my mind is Publish Subscribe pattern, where you could mutually exchange only pointers to
WST_FSM structure.
Why I do not like this is because visually you lose information (not able to use object_model_diagram to full extent) and
you have to do a bit of C programming.

I was wondering if there is a solution with interfaces (ports are not an option for me)?

I am interested in such solution, if there is any.

best regards

uros
Ursanio
 
Beiträge: 9
Registriert: Oktober 2nd, 2013, 9:40 am


Zurück zu Modelling with Rhapsody

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 5 Gäste

cron