click below
click below
Normal Size Small Size show me how
OOP - L9
Formal Models of Java OOP System
| Question | Answer |
|---|---|
| models of Java OOP systems are structured ways of representing and analyzing object-oriented programs written in Java. | Formal Models |
| UML | Unified Modelling Languages |
| Two main approaches of Formal Models | Unified Modeling Language (UML) Formal Specification Languages |
| visual diagrams. | Unified Modeling Language (UML) |
| mathematical contracts. | Formal Specification Languages |
| is a visual modeling language used to design object-oriented systems. | Unified Modeling Language |
| Common diagrams: | Class Diagram Sequence Diagram |
| shows attributes, methods, and relationships. | Class Diagram |
| This is the name of the class. | Class Name |
| Attributes Data / Variables) | Attributes Data / Variables) |
| means it is private which is only accessible inside the class. | The minus sign (-) |
| is the variable that stores the amount of money in the account. | balance |
| means it can hold decimal values | double |
| Methods (Functions/Behaviors) | Methods (Functions/Behaviors) |
| The plus sign (+) means it is public and is accessible from outside the class. This method allows money to be added to the account. | + deposit(amount) |
| Public method to remove money from the account. Usually includes rules | + withdraw(amount) |
| Public method that returns the current balance. Allows other parts of the program to check how much money is in the account. | + getBalance() |
| shows object interactions over time. | Sequence Diagram |
| calls the deposit(1000) method on the BankAccount object. This adds 1000 to the account balance. | Customer object |
| updates its internal balance attribute. | The BankAccount object |
| then calls getBalance() to check the current balance. | The Customer object |
| shows system functions from the user’s perspective. | Case Diagram |
| External entities that interact with the system. Can be people (e.g., Customer, Student) or other systems. | Actors |
| Represented by a rectangle that defines what is inside the system. Inside are the use cases (functions the system provides) | System Boundary |
| Represented by ovals. Each oval describes a functionality or service the system offers (e.g., Deposit Money, Withdraw Money). | Use Cases |
| Lines connect actors to use cases, showing which actor can perform which action. | Relationships |
| Provide mathematical precision to describe system behavior | Formal Specification Languages |
| what must be true before a method runs. | Preconditions |
| what must be true after a method runs. | Postconditions |
| conditions that must always hold true. | Invariants |
| Formal Specification languages code | public void deposit (double amount) { balance+= amount; } |
| help us design and verify Java OOP systems. | Formal models |
| best for visualization and communication | UML |
| best for correctness and verification | Formal Specification Languages |