Skip to main content
Log in

Empirically evaluating OCL and Java for specifying constraints on UML models

  • Regular Paper
  • Published:
Software & Systems Modeling Aims and scope Submit manuscript

Abstract

The Object Constraint Language (OCL) has been applied, along with UML models, for various purposes such as supporting model-based testing, code generation, and automated consistency checking of UML models. However, a lot of challenges have been raised in the literature regarding its applicability in industry such as extensive training, slow learning curve, and significant effort to use OCL due to lack of familiarity of practitioners. To confirm these challenges, empirical evidence is needed, which is severely lacking in the literature. To build such preliminary evidence, we report a controlled experiment that was designed to evaluate OCL by comparing it with Java; a programming language that has also been used to specify constraints on UML models. Results show that the participants using OCL perform as good as the participants working with Java in terms of three objective quality metrics (i.e., completeness, conformance and redundancy) and two subjective metrics (i.e., applicability and confidence level). In addition, the participants using OCL performed consistently well for all the constraints of varying complexity, while fluctuating results were obtained for the participants using Java for the same constraints. Based on the empirical evidence, we can conclude that it does not make much difference to use OCL or Java for specifying constraints on UML models. However, the participants working with OCL performed consistently well on specifying constraints of varying complexity suggesting that OCL can be used to model complicated constraints (commonly observed in industrial applications) with the same quality as for simpler constraints. Moreover, additional analyses on the constraints when using Java and OCL tools revealed that tools are needed to specify fully correct constraints that can be used to support automation.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Institutional subscriptions

Fig. 1
Fig. 2

Similar content being viewed by others

Notes

  1. A within-subjects design offers two main advantages. First, we can reduce the error variance due to individual differences in human performance, which is quite common in software engineering tasks. This is due to the fact that the same group of students is exposed to all OCL specification approaches across the different case studies. Second, within-subjects designs provide more statistical power as it leads to more observations for each treatment Wohlin et al. [36].

References

  1. Object Management Group (OMG), http://www.omg.org/spec/OCL/2.2/

  2. Lefticaru, R., Ipate, F.: Functional search-based testing from state machines. In: Proceedings of the 2008 International Conference on Software Testing, Verification, and Validation. IEEE Computer Society (2008)

  3. Binder, R.V.: Testing Object-oriented Systems: Models, Patterns, and Tools. Addison-Wesley, Reading (1999)

    Google Scholar 

  4. Iqbal, M.Z., Ali, S., Yue, T., Briand, L.: Experiences of applying UML/MARTE on three industrial projects. In: France, R.B., Kazmeier, J., Breu, R., Atkinson, C. (eds.) ACM/IEEE International Conference on Model Driven Engineering Languages and Systems (MODELS), vol. 7590, pp. 642–658. Springer, Berlin (2012)

    Chapter  Google Scholar 

  5. Ali, S., Briand, L.C., Hemmati, H.: Modeling robustness behavior using aspect-oriented modeling to support robustness testing of industrial systems. Softw. Syst. Model. 11, 633–670 (2012)

    Article  Google Scholar 

  6. Ali, S., Briand, L., Arcuri, A., Walawege, S.: An industrial application of robustness testing using aspect-oriented modeling, UML/MARTE, and search algorithms. In: ACM/IEEE 14th International Conference on Model Driven Engineering Languages and Systems (Models 2011) (2011)

  7. Drusinsky, D.: Modeling and Verification Using UML Statecharts: A Working Guide to Reactive System Design, Runtime Monitoring and Execution-based Model Checking, Newnes (2006)

  8. http://www.eclipse.org/modeling/mdt/?project=ocl

  9. Chiorean, D., Bortes, M., Corutiu, D., Botiza, C., Cârcu, A.: OCLE (2010)

  10. http://www.dresden-ocl.org/index.php/DresdenOCL

  11. http://sourceforge.net/apps/mediawiki/useocl/index.php?title=The_UML-base_Specification_Environment

  12. Egea, M.: EyeOCL Software (2010)

  13. Smarttesting, http://www.smartesting.com/

  14. Bordbar, B., Anastasakis, K.: UML2Alloy: a tool for lightweight modelling of discrete event systems. In: IADIS International Conference in Applied Computing (2005)

  15. Aertryck, L.v., Jensen, T.: UML-Casting: Test synthesis from UML models using constraint resolution. Approches Formelles dans l’Assistance au Développement de Logiciels (AFADL ’2003) (2003)

  16. Distefano, D., Katoen, J.-P., Rensink, A.: Towards model checking OCL. ECOOP-Workshop on Defining Precise Semantics for UML (2000)

  17. Clavel, M., Dios, M.A.G.d.: Checking unsatisfiability for OCL constraints. In: The Proceedings of the 9th OCL 2009 Workshop at the UML/MoDELS Conferences (2009)

  18. Bao-Lin, L., Zhi-shu, L., Qing, L., Hong, C.Y.: Test case automate generation from uml sequence diagram and ocl expression. In: International Conference on Computational Intelligence and Security, pp. 1048–1052 (2007)

  19. Benattou, M., Bruel, J., Hameurlain, N.: Generating Test Data from OCL Specification. Citeseer, Princeton (2002)

    Google Scholar 

  20. Aichernig, B.K., Salas, P.A.P.: Test case generation by OCL mutation and constraint solving. In: Proceedings of the Fifth International Conference on Quality Software. IEEE Computer Society (2005)

  21. Cabot, J., Claris, R., Riera, D.: Verification of UML/OCL class diagrams using constraint programming. In: Proceedings of the 2008 IEEE International Conference on Software Testing Verification and Validation Workshop. IEEE Computer Society (2008)

  22. Berardi, D., Calvanese, D., Giacomo, G.D.: Reasoning on UML class diagrams. Artif. Intell. 168, 70–118 (2005)

  23. Winkelmann, J., Taentzer, G., Ehrig, K., Ster, J.M.: Translation of restricted OCL constraints into graph constraints for generating meta model instances by graph grammars. Electron. Notes Theor. Comput. Sci. 211, 159–170 (2008)

    Article  MATH  Google Scholar 

  24. Kyas, M., Fecher, H., Boer, F.S.D., Jacob, J., Hooman, J., Zwaag, M.V.D., Arons, T., Kugler, H.: Formalizing UML models and OCL constraints in PVS. Electron. Notes Theor. Comput. Sci. 115, 39–47 (2005)

    Article  Google Scholar 

  25. Krieger, M.P., Knapp, A., Wolff, B.: Automatic and efficient simulation of operation contracts. In: 9th International Conference on Generative Programming and Component Engineering, (2010)

  26. Weißleder, S., Schlingloff, B.-H.: Deriving Input Partitions from UML Models for Automatic Test Generation. Models in Software Engineering, pp. 151–163. Springer, Berlin (2008)

  27. Gogolla, M., Bttner, F., Richters, M.: USE: a UML-based specification environment for validating UML and OCL. Sci. Comput. Program. 69, 27–34 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  28. Brucker, A.D., Krieger, M.P., Longuet, D., Wolff, B.: A specification-based test case generation method for UML/OCL. In: Proceedings of the 2010 International Conference on Models in Software Engineering, pp. 334–348. Springer, Oslo, Norway (2011)

  29. Ahrendt, W., Baar, T., Beckert, B., Giese, M., Habermalz, E., H, R., #228, hnle, Menzel, W., Schmitt, P.H.: The KeY approach: integrating object oriented design and formal verification. Proceedings of the European Workshop on Logics in Artificial Intelligence, pp. 21–36. Springer (2000)

  30. Ali, S., Iqbal, M.Z., Arcuri, A., Briand, L.: A Search-based OCL constraint solver for model-based test data generation. In: Proceedings of the 11th International Conference On Quality Software (QSIC 2011). IEEE Computer Society, pp. 41–50 (2011)

  31. http://www.nomagic.com/products/magicdraw.html

  32. http://www.eclipse.org/modeling/mdt/papyrus/

  33. IBM Rational Software Architect. http://www-03.ibm.com/software/products/en/ratisoftarch

  34. Arcuri, A., Fraser, G.: On parameter tuning in search based software engineering. In: International Symposium on Search Based Software Engineering (SSBSE). Springer’s Lecture Notes in Computer Science (LNCS) (2011)

  35. IBM, http://www-01.ibm.com/software/awdtools/library/standards/ocl-download.html

  36. Wohlin, C., Runeson, P., Höst, M.: Experimentation in Software Engineering: An Introduction. Springer, Berlin (1999)

    MATH  Google Scholar 

  37. http://www.jmp.com/

  38. Sheskin, D.J.: Handbook of Parametric and Nonparametric Statistical Procedures. Chapman and Hall/CRC, Boca Raton (2007)

    MATH  Google Scholar 

  39. Höst, M., Regnell, B., Wohlin, C.: Using students as subjects—a comparative study of students and professionals in lead-time impact assessment. Empir. Softw. Eng 5, 201–214 (2000)

    Article  MATH  Google Scholar 

  40. Arisholm, E., Sjoberg, D.I.K.: Evaluating the effect of a delegated versus centralized control style on the maintainability of object-oriented software. IEEE Trans. Softw. Eng. 30, 521–534 (2004)

    Article  Google Scholar 

  41. Holt, R.W., Boehm-Davis, D.A., Shultz, A.C.: Mental representations of programs for student and professional programmers. In: Gary, M.O., Sylvia, S., Elliot, S. (eds.) Empirical Studies of Programmers: Second Workshop, pp. 33–46. Ablex Publishing Corp, New York (1987)

    Google Scholar 

  42. CONFORMIQ, http://www.conformiq.com/qtronic.php

  43. Hesari, S., Behjati, R., Yue, T.: Towards a systematic requirement-based test generation framework: industrial challenges and needs. In: 21st IEEE Requirements Engineering Conference, pp. 261–266 (2013)

  44. Nie, K., Yue, T., Ali, S., Zhang, L., Fan, Z.: Constraints: the core of supporting automated product configuration of cyber-physical systems. In: Moreira, A., Schätz, B., Gray, J., Vallecillo, A., Clarke, P. (eds.) Proceedings of 16th international conference on model driven engineering languages and systems, vol 8107, pp. 370–387 (2013)

  45. http://www.onewind.de/OneModelica.html

  46. Strach, R., Mareike, S.: Static validation of modelica models for language compliance and structural integrity. In: Proceedings of the 5th International Workshop on Equation-Based Object-Oriented Modeling Languages and Tools, Linköping University Electronic Press, Linköpings universitet, University of Nottingham, Nottingham, UK (2013)

  47. http://www.sparxsystems.com/

  48. http://argouml.tigris.org/

  49. Briand, L., Labiche, Y., Yan, H., Di Penta, M.: A controlled experiment on the impact of the object constraint language in UML-based maintenance. In: Software Maintenance, 2004, Proceedings. 20th IEEE International Conference on, pp. 380–389. IEEE (2004)

  50. Briand, L.C., Labiche, Y., Di Penta, M., Yan-Bondoc, H.: An experimental investigation of formality in UML-based development. IEEE Trans. Softw. Eng. 31, 833–849 (2005)

    Article  Google Scholar 

  51. Correa, A., Werner, C., Barros, M.: An empirical study of the impact of OCL smells and refactorings on the understandability of OCL specifications. In: Model Driven Engineering Languages and Systems, pp. 76–90 (2007)

  52. Störrle, H.: Improving the usability of OCL as an ad-hoc model querying language. In: 13th International Workshop on OCL, Model Constraint and Query Languages (OCL 2013), pp. 83–92 (2013)

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Tao Yue.

Additional information

Communicated by Prof. Antonio Vallecillo.

Appendices

Appendix A: Answer sheet of the Banking System case study

In this Appendix, we present the answer sheet that was provided to the students during the controlled experiment for Banking System, including the instruction, the system description, the class diagram that OCL constraints should be applied on, and the 10 constraints written in English.

1.1 A.1 Instruction for specifying constraints using OCL

Check the provided system description and the class diagram, and specify the given constraints using OCL with the following format:

\(\mathtt{\textit{context Bank} }\)

            \(\mathtt{\textit{inv:} }\)

1.2 A.2 Instruction for specifying constraints using Java

Check the provided system description and the class diagram, and specify the given constraints using Java. All the attributes in the class diagram are public, which means that they can be directly accessed with objects. Please provide the specification of each constraint as the body of the following function:

\(\mathtt{\textit{public boolean constraint (Bank b)} }\) {

}

1.3 A.3 System description

This case study is an extended version of Banking System case study from the OCL 2.2 specification. A bank has several employees and customers. Each customer can have at most two accounts in a bank: One is saving account and the other is current account. A customer must be employed in a company or owns a company in order to have a bank account. An employee of a bank can also be its customer having accounts in the bank.

1.4 A.4 Class diagram

Figure 3 shows a class diagram modeling the Banking System. Table 13 provides the description of each attribute of a class in the class diagram.

Fig. 3
figure 3

Class diagram for Banking System

Table 13 Description of each attribute

1.5 A.5 Constraints

  1. 1.

    All customers of the bank must be employed.

  2. 2.

    All customers and employees of the bank must be 18 years or older.

  3. 3.

    If all the accounts of a customer have balance less than or equal to 0, then these accounts should be all closed.

  4. 4.

    A customer is either employed in a company or owns his/her company.

  5. 5.

    All accounts in the bank must have unique account numbers and each account must be linked to exactly one customer.

  6. 6.

    Each customer of the bank either owns at least a company or work in a company that has more than one employee.

  7. 7.

    The bank does not allow their customers to withdraw money from their saving accounts.

  8. 8.

    In the bank, there should be gender equality in its employees, i.e., the number of male employees should be equal to the number of female employees.

  9. 9.

    An employee of the bank must not work in another company, but may own a company with exact one employee.

  10. 10.

    A customer of the bank can only have a saving account when he/she has a current account but not vice versa.

Appendix B: Answer sheet of the Video Conferencing System (VCS) case study

In this Appendix, we present the answer sheet that was provided to the students during the controlled experiment for Video Conferencing System, including the instruction, the system description, the class diagram that OCL constraints should be applied on, and the 10 constraints written in English.

1.1 B.1 Instruction for specifying constraints using OCL

Check the provided system description and the class diagram, and specify the given constraints using OCL with the following format:

\(\mathtt{\textit{context Bank} }\)

            \(\mathtt{\textit{inv:} }\)

1.2 B.2 Instruction for specifying constraints using Java

Check the provided system description and the class diagram, and specify the given constraints using Java. All the attributes in the class diagram are public, which means that they can be directly accessed with objects. Please provide the specification of each constraint as the body of the following function:

\(\mathtt{\textit{public boolean constraint (Saturn s)} }\) {

}

1.3 B.3 System description

Our case study is part of a project aiming at supporting automated, model-based testing of a core subsystem of a video conferencing system (VCS) called Saturn. The core functionality to be modeled manages the sending and receiving of multimedia streams. Audio and video signals are sent through separate channels, and there is also a possibility of transmitting presentations in parallel with audio and video. Only one conference participant can send presentations at a time and all others receive it.

1.4 B.4 Class diagram

The functional behavior of Saturn consists of a set of class diagrams and a set of UML state machines. An excerpt of class diagram for Saturn is provided in Fig. 4. The UML class diagram is meant to capture information about APIs and system (state) variables, which are required to generate executable test cases in our application context. In this figure, however, we do not show APIs, since we do not need them in this context. Figure 5 is also a class diagram for Saturn capturing various configuration parameters. The Saturn class in Figs. 4 and 5 is the same, and we present two separate class diagrams for the purpose of clarity. Table 14 shows the description of each attribute.

Fig. 4
figure 4

Class diagram for Saturn (Part I)

Fig. 5
figure 5

Class diagram for Saturn (Part II)

Table 14 Description of each attribute

1.5 B.5 Constraints

  1. 1.

    Saturn should be either in SIP mode or H323, but not in both modes at the same time.

  2. 2.

    Number of active calls for Saturn ranges from 0 to 3.

  3. 3.

    When Saturn is presenting, the presenter’s ID should be a non-negative integer.

  4. 4.

    For each call, call item should be a non-negative integer and call number shouldn’t be an empty string (“”).

  5. 5.

    For each call, call item and number should be unique.

  6. 6.

    In H323 mode, rate adaption and forward error correct mode should be enabled at the same time.

  7. 7.

    When Saturn is in SIP mode then all the information related to SIP protocol shouldn’t be empty.

  8. 8.

    When Saturn is presenting, protocols of all the outgoing presentation channels should not be off.

  9. 9.

    When Saturn is receiving presentation, exactly one of input presentation channels should have protocol not equal to off.

  10. 10.

    When Saturn’s presenting or receiving presentation, exactly one of the presentation channels should have protocol not equal to “Off”.

Appendix C: Post-questionnaire

Please put a \((\surd )\) in the corresponding column. You are strongly encouraged to refer to the list of constraints you were provided with. (The constraint numbers in the following tables match the numbers provided in the list of restriction specifications).

A: Completely agree; B: Generally agree; C: Generally disagree; D: Completely disagree

figure c

Appendix D: Pre-questionnaire

Levels of agreement: Strongly agree, Agree, Neither agree nor disagree, Disagree, and Strongly disagree

Likert Scale Questions:

  1. 1.

    I have good knowledge on UML class diagram modeling.

  2. 2.

    I have good knowledge on writing OCL expressions.

  3. 3.

    I have good knowledge on programming using Java.

Open Questions:

  1. 4.

    How many courses have you taken that taught UML? What are these courses?

  2. 5.

    How many courses have you taken that taught OCL? What are these courses?

  3. 6.

    How many Java-programming projects have you conducted in the past? What are they?

  4. 7.

    How many OCL and UML related courses have you conducted in the past? What are they?

  5. 8.

    What other kinds training on UML, OCL, or Java have you received in the past?

Appendix E: Examples of OCL and Java constraints

In this Appendix, we provide some examples of OCL and Java constraints taken from the answer sheets submitted by the students during the controlled experiment. We also provide the evaluation results based on the metrics defined in Sect. 2.4.1.

1.1 E.1 OCL, Banking System

Banking System:

Constraint A: All customers of the bank must be employed.

Student A:

Context Bank

inv: self.customer-\(>\) iterate(c:Customer \({\vert }\)

c.isEmployed = true)

Completeness = 1, Conformance = 1, and Redundancy = 0

Student B:

Context Bank

inv: for each self.employee.isEmployed = true

Completeness = 1, Conformance = 0.67, and Redundancy = 0

Constraint B: All accounts in the bank must have unique account numbers and each account must be linked to exactly one customer.

Student A:

Context Bank

inv: self.amount-\(>\) isUnique(account Number) and self.account.customer-\(>\) size() =1

Completeness = 1, Conformance = 0.83, and Redundancy = 0

Student B:

Context Bank

inv: if for all self.account.account Number is unique and for each self. account.account

Completeness = 0.5, Conformance = 0.25, and Redundancy = 0

Constraint C: A customer of the bank can only have a saving account when he/she has a current account but not vice versa.

Student A:

Context Customer::Saving:Saving

inv: self.current-\(>\) size() \(>\) =1

Completeness = 0.25, Conformance = 0.097, and Redundancy = 0

Student B:

Context Customer

inv: if self.current.size() \(>\) 0 then self.saving.size() \(>\) 0

Completeness = 0.5, Conformance = 0.11, and Redundancy = 0

1.2 E.2 OCL, Video Conferencing Systems

Constraint D: Saturn should be either in SIP model or H323, but not in both modes at the same time.

Student C:

Context Saturn

inv: (self.networkService.SIP_Mode = On and self.networkService.H323_Mode = Off) or (self.networkService.SIP_mode = Off and self.networkService.H323_Mode = On)

Completeness = 1, Conformance = 0.75, and Redundancy = 0

Student D:

Context Saturn

inv: self.h323-\(>\) size() + self.sip-\(>\) size() =1

Completeness = 1, Conformance = 1, and Redundancy = 0

Constraint E: For each call, call item and number should be unique.

Student C:

Context Saturn

inv: self.conference.calls-\(>\) isUnique (callItem) and self.conference.calls-\(>\) isUnique(number)

Completeness = 1, Conformance = 0.33, and Redundancy = 0

Student D:

Context Saturn

inv: self.conference.calls-\(>\) isUnique (CallItem) and self.conference.calls-\(>\) isUnique(number)

Completeness = 1, Conformance = 0.33, and Redundancy = 0

Constraint F: When Saturn’s presenting or receiving presentation, exactly one of the presentation channels should have protocol not equal to “Off”.

Student C:

Context Saturn

inv: OutgoingPresentationChannel:: Protocol \(\qquad <> \qquad \) Off or Incoming PresentationChannel::Protocol \(<>\) Off

Completeness = 0.5, Conformance = 0.28, and Redundancy = 0

Student D:

figure d

Completeness = 1, Conformance = 1, and Redundancy = 0

1.3 E.3 Java, Banking System

Constraint A: All customers of the bank must be employed.

Student C:

figure e

Completeness = 1, Conformance = 1, and Redundancy = 0

Student D:

figure f

Completeness = 1, Conformance = 0.67, and Redundancy = 0

Student D:

figure g

Completeness = 1, Conformance = 1, and Redundancy = 0

1.4 E.4 Java, Video Conferencing System

Constraint D: Saturn should be either in SIP model or H323, but not in both modes at the same time.

Student A:

figure h

Completeness = 1, Conformance = 1, and Redundancy = 0.5

Student B:

figure i

Completeness = 1, Conformance = 1, and Redundancy = 0

Constraint E: For each call, call item and number should be unique.

Student A:

figure j

Completeness = 1, Conformance = 0.83, and Redundancy = 0

Student B:

figure k

Completeness = 1, Conformance = 0.83, and Redundancy = 0

Constraint F: When Saturn’s presenting or receiving presentation, exactly one of the presentation channels should have protocol not equal to “Off”.

Student A:

figure l

Completeness = 0.5, Conformance = 0.5, and Redundancy = 0.5

Student B:

figure m

Completeness = 1, Conformance = 1, and Redundancy = 0.5

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Yue, T., Ali, S. Empirically evaluating OCL and Java for specifying constraints on UML models. Softw Syst Model 15, 757–781 (2016). https://doi.org/10.1007/s10270-014-0438-9

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10270-014-0438-9

Keywords

Navigation