Establishing the Entity Relationship
In low-level design, establishing the entity relationship is an important step in defining the structure and interactions between objects. In our payment app, there are several main entities involved:
- PaymentApp: Represents the payment application itself. It contains the user, payment methods, and transaction history.
- User: Represents a user of the payment app. It contains the username and password.
- PaymentMethod: Represents a payment method, such as a credit card or digital wallet. It contains the type and details of the payment method.
- TransactionHistory: Represents the transaction history of a user. It contains a list of transactions.
- Transaction: Represents a single transaction. It contains the order ID, payment method ID, amount, and status.
To establish the entity relationship between these objects, we can define the following relationships:
- PaymentApp has a composition relationship with User, PaymentMethod, and TransactionHistory. This means that the existence of PaymentApp depends on these entities.
- User has an association relationship with PaymentApp. This represents the relationship between a user and the payment app.
- TransactionHistory has an aggregation relationship with Transaction. This means that a transaction history is made up of multiple transactions.
By establishing these entity relationships, we can better understand how the objects interact and collaborate within our payment app.
xxxxxxxxxx
38
}
// Establishing the entity relationship between the objects
public class PaymentApp {
private User user;
private List<PaymentMethod> paymentMethods;
private TransactionHistory transactionHistory;
// ... constructors, getters, and setters
}
public class User {
private String username;
private String password;
// ... constructors, getters, and setters
}
public class PaymentMethod {
private String type;
private String details;
// ... constructors, getters, and setters
}
public class TransactionHistory {
private List<Transaction> transactions;
// ... constructors, getters, and setters
}
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment