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.
The basic required operations are
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
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.
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 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 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...
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...
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...
Create a Bitbucket private repository. Name it “CUS1156_Lab2”. Clone it in your local java Eclipse workspace. You will add the java files after you have completed them in Part 1 and Part 2 to this location. Part 1: Abstract classes From class, an abstract class represents some generic concept. Subclasses then provide their own specific implementations of any abstract methods of the abstract class. 1. Implement an abstract class called Shape it was discussed in the lecture. Include an abstract...
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...
INSTRUCTIONS #6. Your science teacher has asked you to create an application that displays how much a person would weigh on the following planets: Venus, Mars, and Jupiter. The application's interface should allow the user to enter the person's weight on Earth. Perform the steps involved in creating an OO application. (See the Note at the beginning of the Exercises section.) Include a button for clearing the screen. . Create an application, using the following names for the solution and...
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 100 accounts. Use an array of pointers to objects for this. However, your...
Create an Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and Savings), this includes a GUI user interface that allows user to login, and deposit or withdraw, and application to display the transaction and final balance. All the bank customers can: - Create a new account - Deposit (Credit) money into their account and/or withdraw (debit) money from their account. - Application should expect user to login to their account using login/password Create necessary classes...