Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ClassActivity1 Word Layout References Mailings Review View Design Layout Tell me

ID: 3874505 • Letter: C

Question

ClassActivity1 Word Layout References Mailings Review View Design Layout Tell me what you want to do Rules tMatch Fields Finish & Merge Preview OFind Recipient Highlight Address Greeting Insert Merge Merge Fields Block Line Field Update Labels Results Check for Erors Wirite & Insert Fields Preview Results 0 What does the code do? public class SortMyData Linkedlist-Stringe myList int minSize int status int dataType publik SortMyDataLint status, int dataType)l 0 What changes would you have to make to add new sorting routines? myList- new LinkedListcString-) this. staturs status this dataType - dataType readDatalmyList) if (dataType1 O What changes would you have to make to remove a sorting routine? status .. 1){ sortmoust else if (status2H l else if (status3 O Sketch the UML diagram for the existing code. (it is going to be simple!) else f public void readData(LinkedList string> // Read in data here public void sortx[LinkedList myList)f 0 Now refactor the solution to use the Strategy Pattern. Show your new UML Class diagram here.

Explanation / Answer

The code calls different different sorting function based on some class variables:

If dataType is 1 AND status is 1 it calls sortX

If dataType is 1 AND status is 2 it calls sortY

If dataType is 1 AND status is 3 it calls sortZ

If dataType is NOT 1 it calls sortX

No major changes is required to implement a new shorting routine. We just have to define the new method and if required we define within the main method the condition when the new sorting routine should be called

Before removing a shorting routine we must ensure that the victim routine is being called anywhere. All dependency must be removed prior to deletion