Question

You were asked by a bank to create a system for them. Your code has one main abstract class: ACCOUNT. Knowing that, disc...

You were asked by a bank to create a system for them. Your code has one main abstract class: ACCOUNT. Knowing that, discuss the SOLID code principles. Discuss the definition, uses, advantages, and disadvantages of each principle. Finally, explain how you would apply each principle to your ACCOUNT (and other classes if you need) project.

Please be as specific as possible. Provide as much detail as possible.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The basic required operations are

  1. Create new account
  2. Deposit transaction
  3. With drawl transaction
  4. Printing of statements(transactions)
  5. Balance Inquiry.

Background:

Many years ago monolithic approach was used for software development.

Monolithic approach means that a single large program, there was no modularity.

So , fixing bugs, maintenance was difficult.

Solution came in the form of code modularity. it means that develop separate modules and finally combine them to build a complete project.

Modular approach offers following benefits.

a)errors can be found easily.

b)new functionality(module) can be added easily in the existing system.

c)maintenance is easy.

As stated in the problem, the main abstract class is ACCOUNT

This class can have both type of methods(abstract and non abstract methods).

Object of abstract class can not be created. Abstract class can not be instantiated.

It’s child class can be instantiated.

It means there will be a need of inheritance. There may be child classes of ACCOUNT abstract class.

SOLID code principles are

S is single responsibility principle (SRP)

O open closed principle (OCP)

L Liskov substitution principle (LSP)

I interface segregation principle (ISP)

D Dependency inversion principle (DIP)

single responsibility principle (SRP):- says that one class should take only one responsibility.

It gives modular approach of development and makes code maintenance easy.

Hence there should be separate classes for

  1. Create new account
  2. Deposit transaction
  3. With drawl transaction
  4. Printing of statements(transactions)
  5. Balance enquiry

open closed principle (OCP) A class should be open for extension but closed for modification.

It means, if there is a need to full fill new requirement, then derive a new class from the existing class for the new requirement and do not modify the existing class(old class) to full fill the new requirement.

Other wise every time whenever there is a new requirement, the existing class will be modified, and it makes very difficult to manage the code.

So,In the given problem, apart from the anticipated operations, if new operation is required, then instead of modifying the existing class, new child class should be derived from the suitable class(base class).

Liskov substitution principle (LSP)

sub classes must be substitutable for the super class.

if X is a subtype of Y, then objects of type Y may be replaced with objects of type X without altering any of the desirable properties of the program .

it means there should be upcasting.

Code that follows LSP is loosely dependent to each other and offers code reusability.

As per the given problem, new operations(such as transfer of money from one account to another account ) can be easily implemented.

interface segregation principle (ISP):-

client should not be forced to depend on methods it does not use.

Client which has relevant methods should follow the particular interface, because in case of interface,

The implementing class is forced to follow the signature of abstract method along with return type.

There are so many restrictions.

So, why put unnecessary restrictions?

interface segregation principle allows flexibility in the code maintenance and addition of new functionalities.

Dependency inversion principle (DIP)

Software modules should not be dependent on each other.

If required, then good programming practice is to minimize the dependency between modules.

Because, if there is strong dependency among modules, then modification in one module causes the modification in other module, and it makes program maintenance difficult.

As per the given problem there may be various types account holders, such as saving account, current account and so on. And both types of account may have different types of requirements. these operations should not dependent on each other.

Add a comment
Know the answer?
Add Answer to:
You were asked by a bank to create a system for them. Your code has one main abstract class: ACCOUNT. Knowing that, disc...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You were asked by a bank to create a system for them. Your code has one...

    You were asked by a bank to create a system for them. Your code has one main abstract class: ACCOUNT. Knowing that, discuss the SOLID code principles. Discuss the definition, uses, advantages, and disadvantages of each principle. Finally, explain how you would apply each principle to your ACCOUNT (and other classes if you need) project. Please be as specific as possible. Provide as much detail as possible.

  • In this, you will create a bank account management system according to the following specifications: BankAccount...

    In this, you will create a bank account management system according to the following specifications: BankAccount Abstract Class contains the following constructors and functions: BankAccount(name, balance): a constructor that creates a new account with a name and starting balance. getBalance(): a function that returns the balance of a specific account. deposit(amount): abstract function to be implemented in both Checking and SavingAccount classes. withdraw(amount): abstract function to be implemented in both Checking and SavingAccount classes. messageTo Client (message): used to print...

  • In this assignment, you are asked to create a class called Account, which models a bank...

    In this assignment, you are asked to create a class called Account, which models a bank account. The requirement of the account class is as follows, (1) It contains two data members: accountNumber and balance, which maintains the current account name and balance, respectively. (1) It contains three functions: functions credit() and debit(), which adds or subtracts the given amount from the balance, respectively. The debit() function shall print ”amount withdrawn exceeds the current balance!” if amount is more than...

  • Bank Accounts Look at the Account class Account.java and write a main method in a different...

    Bank Accounts Look at the Account class Account.java and write a main method in a different class to briefly experiment with some instances of the Account class. • Using the Account class as a base class, write two derived classes called SavingsAccount and CheckingAccount. A SavingsAccount object, in addition to the attributes of an Account object, should have an interest variable and a method which adds interest to the account. A CheckingAccount object, in addition to the attributes of an...

  • 1-Suppose you write an application in which one class contains code that keeps track of the...

    1-Suppose you write an application in which one class contains code that keeps track of the state of a board game, a separate class sets up a GUI to display the board, and a CSS is used to control the stylistic details of the GUI (for example, the color of the board.) This is an example of a.Duck Typing b.Separation of Concerns c.Functional Programming d.Polymorphism e.Enumerated Values 2-JUnit assertions should be designed so that they a.Fail (ie, are false) if...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • Java Painter Class This is the class that will contain main. Main will create a new...

    Java Painter Class This is the class that will contain main. Main will create a new Painter object - and this is the only thing it will do. Most of the work is done in Painter’s constructor. The Painter class should extend JFrame in its constructor.  Recall that you will want to set its size and the default close operation. You will also want to create an overall holder JPanel to add the various components to. It is this JPanel that...

  • Project 1. Dog Door You are asked to create a dog door for a client. You...

    Project 1. Dog Door You are asked to create a dog door for a client. You are programming the remote that will do things such as open and close, etc. You must create both the program and write a white paper explaining your design • It should open (saying "The dog door is open.") and close (saying "The dog door is closed.). • It should take into account a dog going outside and coming back in; it should open when...

  • The current code I have is the following: package uml; public class uml {        public...

    The current code I have is the following: package uml; public class uml {        public static void main(String[] args) {              // TODO Auto-generated method stub        } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT