Question: For each problem, study the supplied code, and list the code smells you see. For this exercise the code smells should be one of these:

For each problem, study the supplied code, and list the code smells you see. For this exercise the code smells should be one of these:

  • long method,
  • large class,
  • duplicate code (aka cut and paste code),
  • long parameter list,
  • primitive obsession, and
  • magic numbers.

For each code smell,

  • list the line numbers of the code where the smell is focused,
  • identify the design principle(s) that are violated, and
  • identify some program change that the smell would complicate.
  1. Code fragment For each problem, study the supplied code, and list the code smellsyou see. For this exercise the code smells should be one of

    Smells and locations?

    Design principles?

    Maintenance Consequences?

static WarehouseWorker workerLogin() throws Exception { System.out.println(":: WORKER LOGIN ::"); Scanner sc = new Scanner(System.in); System.out.println("Enter username:"); String username = sc.next(); int input; if (Service.userAndPasswords.containsKey(username) == false) { System.out.println("Username doesn't exist, try again or sign up"); System.out.println("(1) Try again"); System.out.println("(2) Sign Up"); input = sc.nextInt(); if(input == 1) { Service. loginHelper(); }else if (input == 2) { Service. signup(); }else { throw new Exception("Bad User Input"); String check = Service.userAndPasswords.get(username); while(true) { System.out.println("Enter password:"); String password = sc.next(); if (check.equals(password)) { System.out.println("Welcome Back!"); break; } else { System.out.println("Wrong password!"); System.out.println("(1) Try with different username"); System.out.println("(2) Retry password"); input = sc.nextInt(); if(input == 1) { Service. loginHelper(); return getWarehouseWorkerByUsername (username); static Customer customerLogin() throws Exception{ //just a placeholder to look like login page System.out.println(":: CUSTOMER LOGIN : :"); Scanner sc = new Scanner(System.in); System.out.println("Enter username:"); String username = sc.next(); int input; if(Service.userAndPasswords. containsKey (username) == false) { System.out.println("Username doesn't exist, try again or sign up"); System.out.println("(1) Try again"); System.out.println("(2) Sign Up"); input = sc.nextInt(); if(input == 1) { Service. loginHelper(); }else if (input == 2) { Service.signup(); }else { throw new Exception ("Bad User Input"); String check = Service.userAndPasswords.get(username); while(true) { System.out.println("Enter password:"); String password = sc.next(); if (check.equals(password)) { System.out.println("Welcome Back!"); break; } else { System.out.println("Wrong password!"); System.out.println("(1) Try with different username"); System.out.println("(2) Retry password"); input = sc.nextInt(); if(input == 1) { Service. loginHelper(); Customer cust = findCustomerByUsername (username); return cust

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!