Use Case Diagrams

man-using-computerHi people, this blog is going to discuss about diagrams that we use for Data modeling. This first article will be helpful to draw a Use case diagram correctly. In this tutorial we will learn about:-

  • What is a use case diagram?
  • Rules that we use.
  • Relationships in a use case diagram.
  • Example diagram.

What is a use case diagram?

  • It is a graphical diagram that shows activities and interactions among elements of a system.
  • The use cases, which are the specific roles played by the actors within and around the system.
  • A use case diagram has set of components which are :
    • Use case (mostly functionalities of the system)
    • An actor (people or other systems)
    • System boundary
    • Associations (relationship types)

1

  • Simply we can get an idea about how is the system work, by looking at the use case diagram.

 Rules that we use

  • We use simple present tense for use case’s name.

Ex:- register student, transfer money

  • Actors must be nouns.

Ex:- client, supervisor

  • Actors are not always living things.

Relationships in a use case diagram

  1. Simple association

2

  • We use solid line in this type of relationships.
  1. Generalization & Specialization

3

  • Generalization:-
  • Specialization:-
  • We use solid line arrow with close empty arrow head in this type of relationships.
  1. Use case generalization

4

  • We use solid line arrow with close empty arrow head in this type of relationships.
  1. Include relationship

5

  • Every time when perform A, B must be performed.
  • We use dash line arrow with open arrow head in this type of relationships.
  1. Extend relationship

6

  • Every time when we perform A there is an option to perform B.
  • We use dash line arrow with open arrow head in this type of relationships.

Example diagram

Scenario 1

Click here to download the PDF file.

Use case

7

Scenario 2

Click here to download the PDF file.

Use case

8

JAVA Chapter III

man-using-computerHi people, this blog is going to discuss about very basic points and main concepts you must know before using JAVA language. This third article will be helpful to build the foundation of JAVA programming. In this tutorial we will learn about:-

  • Loops
  • Break & continue statements
  • Switch case

Loops

  1. For loop
  • for loop is a repetition block that needs to be executed a specific number of times.
  • This loop is useful when you know how many times a block should be repeated.

1

Code example

2

Console

4

  1. For each loop / Enhanced for loop
  • This loop uses to traverse collection of elements including arrays.

5

Code example

6

Console

7

  1. While loop
  • This is the very basic loop in java.
  • While loop repeatedly executes the block as long as the given condition is true.

Code example

8

Console

9

  1. Do while loop
  • This one similar to while
  • Only differentiation is do while loop is guaranteed to execute at least one time.
  • Do while loop check condition at last.

Code example

10

Console

11

Break & continue statements

Break

  • This uses to terminate the loop immediately.
  • After terminate next statement will be executed. (outside the loop)
  • Break statement also uses to terminate a case in the switch statement. (look at the next topic)

Code example

12

Console

13

Continue

  • From this statement loop will jump immediately to the next iteration of the loop.

Code example

14

Console

15

Switch case

  • The switch statement uses to check equality of set of values for one variable.
  • Each value is called a case.
  • The variable used in a switch can only be integers, convertible integers (byte, short, char) and strings.
  • Using break statement a switch can be terminated after execute a matched case.
  • If we not using break statement within cases then all cases will execute until a brake is reached.
  • switch statement can have an optional default case, which must appear at the end of the switch. The default case can be used for performing a task when none of the cases is true. No break is needed in the default case.

Code example

16

Console

17

Important

  • If we check equality we use == for primitive data types and .equals() for object data types.

Code example

HelloWorld .java

18

HumanBeing.java

19

Console

20

 

JAVA Chapter I               JAVA Chapter II

JAVA Chapter II

man-using-computerHi people, this blog is going to discuss about very basic points and main concepts you must know before using JAVA language. This second article will be helpful to build the foundation of JAVA programming. In this tutorial we will learn about:-

  • Classes & Objects.
  • Operators & concatenation.
  • IF statement.

Classes & Objects

  • Entire Java language is depends on classes and objects. Without the knowledge of classes and objects you can’t even think about coding.
  • To understand what are a class and an object I’m going to take a simple example.
  • A class is like a blueprint and an object is like a copy of that blueprint.
  • Ex: – If Human being is a class, one person is an object of the Human being class.

If Desk is a class, one desk is an object of Desk class.

Classes

  • A class has a set of attributes (instance variables) and set of operations. (methods)
  • Java has 4 access levels for protection purposes. Those are known as access specifies.
  1. public
  2. protected
  3. default
  4. private
  • Classes can use only two access specifies. Those are public & default.

Public class

1

Default class

2

  • Also a class can contain constructors and inner classes. (These will be discussed in future articles).
  • Java has 4 types of variables.
  1. Instance variables – outside the method and inside the class.
  2. Local variables – inside a method or a block.
  3. Static variables – variables that declare with static key word. (outside the method)
  4. Constant variables – variables that has constant value. (Mostly declare with final key word and definitely outside the method).

Objects

  • The keyword new uses for create an object.
  • Object class is the super most class in the java. (In future articles we will discuss about super class).
  • Ex: – If we take Human being is a class and one person is an object example,

HelloWorld class

3

HumamBeing class

4

5

Important

  • Static variables – one copy per class – share through all objects in the class.
  • Instance variables – one copy per object
  • If we take Circle as a class,

6  7

  • This is only basic knowledge. We will discuss furthermore about class, inner class, objects, constructors, and methods in future articles.

Operators & concatenation

Operators

10

  • There are few types of operators.
  • Unary operators.
  • Binary operators. (normal operators with 2 operands, ex:- 2+3 )
  • Ternary operators. (normal operators with 3 operands, ex:- 2+3-1 )
  • Arithmetic assignment operators.
  • Comparison operators.
  • Logic gates.

Unary operators

  • Only has one operand. (++1,–25 …)
  • Only has increment operator (++) and decrement operator (–).
  • There are two notations of unary operators.
  1. Prefix notation

Operator comes before the operand.

Ex 1:- int x = 1;  //create a integer variable x and assign value 1.

int y = ++x;  //create another integer variable y and assign ++x (prefix increment).

  • First x increase by 1.
  • After increased x (x=2) assign to the y.
  • Finally x=2, y=2

 

Ex 2:- int x = 1;  //create a integer variable x and assign value 1.

int y =x;  //create another integer variable y and assign –x (prefix decrement).

  • First x decrease by 1.
  • After decreased x (x=0) assign to the y.
  • Finally x=0, y=0

 

  1. Postfix notation

Operator comes after the operand.

Ex 1:- int x = 1;  //create a integer variable x and assign value 1.

int y = x++;  //create another integer variable y and assign x++ (postfix increment).

  • First value of x (x=1) assign to the y.
  • After x increase by 1.
  • Finally x=2, y=1

 

Ex 2:- int x = 1;  //create a integer variable x and assign value 1.

int y = x;  //create another integer variable y and assign x– (postfix decrement).

  • First value of x (x=1) assign to the y.
  • After x decrease by 1.
  • Finally x=0, y=1

(Scroll down for the example code)

Arithmetic assignment operators

  1. Assignment

X = 5;  //assigning value 5 to x using = operator

 

  1. Equality

(X == 5)   //check whether value of x is 5 or not using == operator

  1. Other

x += 5;  //this mean  is x = x+5

x *= 5; //this mean  is x = x*5

(Scroll down for the example code)

Copmparison operators

  • H.S – left hand side, R.S.H. – right hand side

L.H.S == R.S.H. (check equality)

L.H.S != R.S.H. (check not equality)

L.H.S > R.S.H. (check whether L.H.S is greater than R.S.H.)

L.H.S < R.S.H. (check whether L.H.S is less than R.S.H.)

L.H.S >= R.S.H. (check whether L.H.S is greater than and equal R.S.H.)

L.H.S <= R.S.H. (check whether L.H.S is less than equal R.S.H.)

(Scroll down for the example code)

Logic gates

  • We use two logic gates in java.

 

  1. AND

(x&& x >10) – It behave as normal AND logic gate.

 

  1. OR

(x|| x >10) – It behave as normal OR logic gate.

 

(Scroll down for the example code)

 

Important

  • Do not use >= as => and <= as =<, every time = sing comes after < > these two.

 

Concatenation

  • In java we use + sign to combine string with another string or variable for display purpose. It is known as concatenation.

(Scroll down for the example code)

If statement

  • The division box in flowchart is replaced with “if” statement in java.
  • In java we mostly use “if” statement to check some condition whether it is correct or wrong.

if(condition) {

True

} else {

False

}

(Scroll down for the example code)

Coding Example

8

  • I didn’t mention values of variable line by line. Try to do it. (Dry run).

Console

9

JAVA Chapter I               JAVA Chapter III