Java bank - Requirements Analysis

The first step in creating a program is to share a clear understanding of what program to make. This step is called Requirements Analysis. Requirements Analysis involves writing the following scenario:


A bank registers an account.
A bank searches for an account by account number.
A bank can find an account by the owner's name.
A bank can view a list of all accounts.
An account consists of the owner's name, account number, and balance.
An account has deposit and withdrawal functions and a balance check function. Whenever there is a change in balance, An account stores it in a transaction. A transaction consist of transaction date, transaction time, deposit/withdrawal, transaction amount, balance.

Class Diagram

You need to extract the classes, fields, and methods from the scenario.
Nouns become classes or variables. Verbs become methods.
JavaBank Class Diagram

I have omitted all methods of the Transaction class and the getter and setter methods from Bank and Account.

In addition to Class Diagrams, there are Use Case Diagrams and Sequence Diagrams. Depending on the project, it may need these, but the java bank project is enough for a class diagram.

In a class diagram, private is represented simply as -, public as + and protected as #.

A class diagram represents not only the structure of a class, but also the relationship between objects and objects. When one connects the other by one line in a class diagram, two instances created from both are related.

A diamond represents a relationship in which an object has other objects as parts.

0 or * is the maximum number of instances to use as a part, meaning zero or more.

An arrow is a direction in which an object calls the methods of another one.

"has a" relationship is a relationship in which an object has an object as a part. Bank and Account classes are "has a" relationship because a bank has multiple accounts.

The Composition is "has a" relationship, which has a high degree of coupling and is represented by a diamond filled. In a high degree of coupling, parts disappear as the body disappears.

The Aggregation is "has a" relationship, which has a low degree of coupling and is represented by a hollow diamond. In a low degree of coupling, the parts do not disappear even if the body disappears.

In Java, you can implement Composition and Aggregation by creating variables that store references to the part objects in the body object.