Skip to main content

Introduction to Java Programming

  What is Java? Java is a programming language and a platform. Java is a high-level, robust, object-oriented and secure programming language. Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Firstly, it was called  Greentalk  and the file extension was  .gt . After that, it was called  Oak . Initially Java was designed for small, embedded systems in electronic appliances like set-top boxes. Platform:  Any hardware or software environment in which a program runs, is known as a platform. Since Java has a runtime environment (JRE) and API(Application Programming Interface), it is called a platform. The principles for creating Java programming were "Simple, Robust, Portable, Platform-independent, Secured, High performance, Multithreaded, Architecture neutral, Object-oriented, Interpreted, and Dynamic". Currently, Java is used in internet programming, mobile devices, games, e-business so

3. Dynamic Modeling

 

Dynamic Modeling

The dynamic model represents the time-dependent aspects of a system. It is a way of describing how an individual object responds to events, either internal events triggered by other objects or external events triggered by the outside world. The main concepts are:

  • State: It is a situation at a particular condition during the lifetime of an object.
  • Transition: It is a change in the state.
  • Event: It is an occurrence that triggers transitions. Events are generally associated with some actions.
  • Action: It is an uninterrupted and atomic computation that occurs due to some event. The execution of some specific task due to some event.
  • Concurrency of transitions: It is the parallel changes in the states or simply involves selecting multiple transitions simultaneously.

A state machine models the behavior of an object as it passes through a number of states in its lifetime due to some events as well as the actions occurring due to the events. A state machine is graphically represented through a state transition diagram.

States

State is a situation occurring for a finite time period in the lifetime of an object, in which it fulfils certain conditions, perform certain activities, or waits for certain events to occur. In state transition diagrams, a state is represented by rounded rectangles.

Parts of a State

  1. Name: A string differentiate one state from another. A state may or may not have any name.
  2. Entry/Exit Actions: It denotes the activities performed on entering and on exiting the state.
  3. Internal Transitions: The change within a state that do not cause a change in the state. Ex. If you are in a running state, and suddenly increases your speed but you are in running state.
  4. Sub-States: State within state.

Internal and Final States

The default starting state of an object is called its initial state. The final state indicates the completion of execution of the state machine. The initial and final states are pseudo-states, and may not have the parts of a regular state expect name. In state transition diagrams, the initial state is represented by a filled black circle. The final state is represented by a filled black circle encircled within another unfilled black circle.

State Transition

A transition denotes a change in the state of an object. If an object is in a certain state when an event occurs, the object may perform certain activities subject to specified conditions and changes the state. In this case, a state-transition is said to have occurred.

The transition gives the relationship between the first state and the new state. A transition is graphically represented by a solid directed arc from the source state to the destination state.

Parts of a Transition

  1. Source State: The state affected by the transition or simply the state before the transition occurs.
  2. Event Trigger: The occurrence due to which an object in the source state undergoes a transition if the guard condition is satisfied.
  3. Guard Condition: A Boolean expression which if true causes a transition on receiving the event trigger. A transition may or may not have a guard condition.
  4. Action: An uninterrupted and atomic computation that occurs on the source object due to some event.
  5. Target State: The destination state after completion of transition or simply the state after the transition has occurred.

Events

Events are some occurrences that can trigger state transition of an object or a group of objects. Events have a location in time and space but do not have a time period associated with it.

Events that trigger transitions are written alongside the arc of transition in state diagram.

External and Internal Events

External events are those events that are passed by a user of the system to the objects within the system.

Internal events are those events that can be passed from one object to another object within a system.

Concurrency of Events

Concurrency allows more than one objects to receive events at the same time and more than one activity to be executed simultaneously. Concurrency is identified and represented in the dynamic model.

State Transition Diagram

State transition diagrams or state machines describes the dynamic behavior of a single object. It illustrates the sequences of states that an object goes through in its lifetime, the transitions of the states, the events and condition causing the transition and the responses due to the events.

Example :

Suppose a person is taking a taxi from place X to place Y. The states of the person may be waiting, riding and reached.


Previous

Next

Comments