DPAT Assignment Felix
DPAT Assignment Felix
Abstract — This individual assignment report aims to effective Design Patterns, and its weaknesses thoroughly
justify and implement, as well as prove that the effective use of explained. Whereas only later a refined solution (RS) would
the Façade and Singleton design patterns leads to better come in and a solution to the design flaws in the SS would be
working software and ultimately enhances the Testability highlighted on and scrutinized, then compared against the
quality attribute of a software by first introducing a scenario, RS.
implementing a non-design pattern solution, then onwards
introducing a solution with design patterns embedded and Finally, a conclusion that closes this report will be written
analyzing the software’s code to draw a comparison between to provide a summary of what has been achieved and what
the two solutions. First off, an introduction to explain about the the outcome of the report is.
Testability Factor will be given, next, several research and
studies related to Testability will be drawn up to gather the II. LITERATURE REVIEW
reader’s attention on current achievements made in the field. Over the years, numerous studies and research have been
Moving on, a suitable methodology to measure and gauge the conducted when it comes to comprehending the importance
solutions’ testability will be conducted and will be later
of Design Patterns towards Testability. The vast amount of
debriefed. A case scenario where two forms of implementation:
simple and refined will be given where the former has design
research conducted has otherwise led to a period where
patterns absent while the latter has them present. The later software is more robust and testable as ever, meeting
section will compare these two solutions and evaluate the stakeholder requirements and being able to execute with
effectiveness of design patterns onto software. Finally, a minimal chance of failure or breakdown.
conclusion on what has been discovered will be placed at the A. Designs for Testability
end of this document.
c) Accessibility Concerns
Furthermore, other weaknesses in the simple solution are
detected in the improper use of access modifiers. In the
below code example, it is seen that a part of the code does
not hide its variables from other classes. This could lead to
poor obscurity practices and can let instantiations of other
classes gain too much data/visibility on the class itself.
IX. APPENDIX
BankDemo.java
try{
BankMenu bankMenu = new BankMenu();
bankMenu.displayLogin();
}catch(Exception e){
e.printStackTrace();
}
BankMenu.java
import java.util.Scanner;
if(choice == 1){
bacc.makeDeposit();
displayChoice();
}
if(choice == 2){
bacc.makeWithdrawal();
displayChoice();
}
if(choice == 3){
bacc.makeTransfer();
displayChoice();
}
if(choice == 4){
bacc.makeBalanceCheck();
displayChoice();
}
if(choice > 4)
System.out.println("Thank you for using Northland Bank");
break;
}
}
}
2
BankAccount.java
import java.util.Scanner;
BankSecurity.java
}
2
BankDemo.java
BankFacadeSingleton.java
bankMenu.displayLogin();
acctNum = bankMenu.getAcctNum();
secCode = bankMenu.getAcctCode();
acc.setAcctNum(acctNum);
acc.setSecCode(secCode);
if(bankVerifyAccount()){
bankDisplayMenu();
}else{
System.out.println("Incorrect account number or security code.");
System.exit(0);
}
}catch(Exception e){
e.printStackTrace();
}
}
//Singleton Implementation
public static BankFacadeSingleton getInstance(){
if(instance == null) {
instance = new BankFacadeSingleton();
}
else{
System.out.println("Instance already running!");
}
return instance;
}
2
public boolean bankVerifyAccount(){
return acc.acctExists(acctNum) && acc.secCodeConfirm(secCode);
}
//Withdraw Cash
case 2 -> makeWithdrawal();
//Funds Transfer
case 3 -> makeTransfer();
//Check Funds
case 4 -> makeBalanceCheck();
}
}
BankMenu.java
import java.util.*;
2
public class BankMenu {
BankSecurity.java
BankAccount.java
import java.util.*;
3) Download Apache Maven from: https://maven.apache.org/download.cgi - Select the Binary Zip Archive selection.
2
4) Create an environment variable called “MAVEN_HOME” under System Variables in Environment Variables
5) Edit the PATH environment variable under System variables and add the following paths:
NOTE: It is important to have JDK 8 or 11 set up as Apache Maven only supports those versions. Apache Maven is
required to run SonarQube and for it to perform its testing and analyzing features to its max.
F. Executing SonarQube
1) Execute the StartSonar.bat service by navigating through the bin folder of the SonarQube setup folder.
2
2) Once the service has started running, users can verify whether it is successful or not based on the command prompt’s
results.
3) Once SonarQube’s services are running, access any web browser and type in “localhost:9000” and click enter. Login
using the username and password “admin” and “admin” respectively. It is advised to change your password after the first
login.
4) Manually add a project. This option can be found in the top right hand section of the “Projects” page in the
SonarQube dashboard.
2
5) Type in the Project Title you wish to set up. Click “Set Up” when finalizing.
6) Generate an access token. Access tokens are unique and can be used to access the project. Click on “Generate” once
changes are finalized and click on the “Continue” button.
2
8) Open the command prompt and navigate to the project folder. Use the commands cd or .. in order to navigate through
folders and subfolders (above and below). For this case, we are going to navigate to the simple solution’s directory.
9) Run this command in the command prompt. Ensure that you are at the target directory.
10) Once no errors are detected, run the second command in the command prompt.
Replace the myAuthenticationToken variable from the token that was generated in Step 6
2
11) Select the “Projects” tab on SonarQube, and the Solution should appear. Under this solution section, several
analyses, charts and graphs will be shown. Click on “Measures” to gain an overall insight of the project build. Exact details
about variables concerning the formula for Testability is seen under the “Size” and “Complexity” section of this menu.
It is important to ensure that Maven is running on the Java Project that is going to be analyzed with SonarQube, otherwise an
error stating that a “pom.xml” file will not be found. In order to solve this, Maven integration would be required towards the
project. This is accessible through configuring the project and adding framework support for Maven.
The user must have a pom.xml file available in their project for Apache Maven and SonarQube to work.