Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. For each of the following refactorings, a. state the primary design principle that is being improved in the code that is shown: abstraction, encapsulation,

image text in transcribedimage text in transcribedimage text in transcribed

2. For each of the following refactorings, a. state the primary design principle that is being improved in the code that is shown: abstraction, encapsulation, modularity, hierarchy, separation of concerns, or none (no design improvement made) and b. provide a 1 to 2 sentence explanation how the code was improved regarding that design principle. E. boolean withinPlan = plan.withinRange (range); int low = range.getLow(); int high range.getHigh(); boolean withinPlan = plan.withinRange (low, high); = F. public class Sum public static void main(String[] args) { int a = 0; int b = 0; try { a = Integer.parseInt (args[0]); b = Integer.parseInt (args [1]); } catch (NumberFormatException ex) { } int sum = a + b; System.out.println("Sum + sum); } public class Sum { public static void main(String[] args) { int a = 0; int b = 0; try { a = Integer.parseInt (args[0]); b = Integer.parseInt (args[1]); } catch (Number FormatException ex) { System.out.println("One of the arguments are not number." + "Program exits."); return; } int sum = a + b; System.out.println("Sum = + sum); } G. class Toolkit { public CPU createCPU() { } public MMU createMMU () { } class Emulator { private CPU cpu; private MMU mmu; public Emulator() { cpu = new CPU(); mmu = new MMU (); } void start() { 11 ... } 1/ ... class Emulator { private CPU cpu; private mmu MMU; public Emulator (Toolkit toolkit) { cpu = toolkit.createCPU(); mmu = toolkit.createMMU(); } void start() { 11 ... } 2. For each of the following refactorings, a. state the primary design principle that is being improved in the code that is shown: abstraction, encapsulation, modularity, hierarchy, separation of concerns, or none (no design improvement made) and b. provide a 1 to 2 sentence explanation how the code was improved regarding that design principle. E. boolean withinPlan = plan.withinRange (range); int low = range.getLow(); int high range.getHigh(); boolean withinPlan = plan.withinRange (low, high); = F. public class Sum public static void main(String[] args) { int a = 0; int b = 0; try { a = Integer.parseInt (args[0]); b = Integer.parseInt (args [1]); } catch (NumberFormatException ex) { } int sum = a + b; System.out.println("Sum + sum); } public class Sum { public static void main(String[] args) { int a = 0; int b = 0; try { a = Integer.parseInt (args[0]); b = Integer.parseInt (args[1]); } catch (Number FormatException ex) { System.out.println("One of the arguments are not number." + "Program exits."); return; } int sum = a + b; System.out.println("Sum = + sum); } G. class Toolkit { public CPU createCPU() { } public MMU createMMU () { } class Emulator { private CPU cpu; private MMU mmu; public Emulator() { cpu = new CPU(); mmu = new MMU (); } void start() { 11 ... } 1/ ... class Emulator { private CPU cpu; private mmu MMU; public Emulator (Toolkit toolkit) { cpu = toolkit.createCPU(); mmu = toolkit.createMMU(); } void start() { 11 ... }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is the purpose of recruitment and selection?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago