ICTPRG503 DEBUG AND MONITOR APPLICATIONS

ASSESSMENT GUIDE:

Assessment requirements

elements and performaNce criteria
1. Implement a framework for logging and error handling                          1.1 Determine the logging framework for writing text messages at a certain level or priority to log files, or for sending data to monitoring applications 1.2 Create a custom event log for an application 1.3 Analyse the logs to check the state of the running application  
2. Debug and trace an application                            2.1 Apply basic debugging techniques such as breakpoints, stepping through and over code, and stack trace 2.2 Identify and use the tools to debug software applications 2.3 Write the code for debugging (print, assert and stop statements)  
3. Monitor the application’s performance              3.1 Identify and use profiling tools to verify the parts of the system that consume the most resources, such as random access memory (RAM), central processing unit (CPU) and time 3.2 Analyse performance issues, and apply any changes to improve the performance of the application
performance evidence
Evidence of the ability to: ·          use a logging framework to create an event log for an application ·          use tools and techniques to trace and debug an application use profiling tools to collect data about an application’s performance, identify and analyse identified issues and implement changes to improve performance.
knowledge evidence
To complete the unit requirements safely and effectively, the individual must: provide examples of common logging frameworks. logging and tracing tools, and profiling toolsexplain the functions of profiling tools, and logging and tracing toolsexplain the basic principles of:computer hardware, networking and componentsdatabase-management systemsobject-oriented programmingopen-source development toolsdescribe procedures for developing small-size applicationsoutline the software development life cycle (SDLC).  

Special Needs

Remember to allow reasonable adjustment for any particular needs of the student in line with your organisational policies. If a student believes they have special needs they must talk to their trainer.

assessment conditions    

Students must gather evidence to demonstrate consistent performance in conditions that replicate the workplace. Access to the following:

  • Sufficient privileges to use performance monitoring tools on client and server systems
  • Specific debugging tools and licenses

Assessment MarkING Guide

Included in this assessor guide is a marking guide with suggested model answers for each task.

Assessment Task A

Short written questions

Purpose:

Written questions assess the required knowledge needed to undertake the tasks as outlined in the performance criteria and elements.

Student instructions: 

  • You must answer the following theoretical knowledge-based questions correctly.
  • All questions must be answered.
  • You may refer to your learning materials and conduct any research necessary when completing answers.
  1. Identify the computer components in the table below and provide one function of each component.
ComponentNameFunction
  
  
  
  
  • Describe what a database-management system (DBMS) is in your own words. (25 – 30 words)
   
   
   
  • Discuss the six stages of the Software Development Life Cycle (SDLC). (350 words)
   
   
   
   
   
   
   
   
   
  • Describe the concept Object-Oriented Programming (OOP). (80 – 85 words)
   
   
   
   
   
   
   
   
  • What is open source software? (70 – 75 words)
   
   
   
   
   
  • Discuss the methodology favoured by developers wanting to provide rapid prototypes.   (375 – 400 words)
   
   
   
   
   
   
   
   
   
   
   
   
  • Apache Log4j is commonly used by developers to assist them with three important functions? Name the three important functions. (20 – 25 words)
   
   
  • Complete the table by explaining the function of each term.
TermFunction
  Tracing
  Profiling
  Logging
  • Explain how profiling tools can help to improve the performance of an application. 
   
   
   
   

Explain how to perform the following processes using the Eclipse Java debugger.

  • Look up the value of a variable
   
  • Change the value of a variable in the debugger
   
  • Set breakpoints and stepping into in a program
   

Assessment Task B

Project

Purpose:

The purpose of this assessment is to provide students with a documented project or assignment that requires them to undertake research or produce evidence of their knowledge and skills by performing relevant real-world tasks and activities to demonstrate competency.

Student instructions: 

  • You must complete all questions in this task. Read the instructions for each task first. If you do not understand a question, ask your assessor to explain the question and instructions.
  • You will need to perform practical tasks in a simulated environment with access to the following equipment and software:
    • A suitable IDE such as Java
    • Eclipse software for debugging
    • A suitable logging framework such as Apache Log4J or Logback
    • A suitable profiling tool such as JVisualVM or similar
  • You must ensure that all software is downloaded and correctly installed prior to commencement of your tasks. If you are unsure of any equipment or software, please ask your assessor for assistance.
  • You must take screenshots to support your answers and as evidence of your practical competency.

Logging and error handling

  1.  You are responsible for implementing a framework for logging and error handling using specified software and tools for a Java application. You must:
    1. Identify one suitable logging framework and explain the features and benefits of your selected logging framework.
   
   
   
   
   
   
  • Using your chosen logging framework, use the following code to log a message with the priority level set to DEBUG. You must submit a screenshot of your answer.

package com.mkyong;

import org.apache.log4j.Logger;

public class HelloExample{

      final static Logger logger = Logger.getLogger(HelloExample.class);

      public static void main(String[] args) {

                  HelloExample obj = new HelloExample();

      }

}

Insert screenshot here                







                             
  • Using your logging framework, write the code to send logging information to a console. Place the file in your project root folder or resources folder and run the application. Provide a screenshot of your console log message as your answer.
Insert screenshot here      








                     

Profiling program or application performance

  • For this task, you can choose a Java program or application of your choice. Using a suitable profiling tool such as JVisualVM, verify the parts of the program that consume the most resources by performing CPU and Memory profiling.

After the profiling has been executed, provide a screenshot of your CPU and Memory profiling results below.

Insert screenshot here                          








                                             

Analysing program or application performance

  • For this task, you must review the profiling results below for a given application. Analyse each issue and suggest ways to improve the performance of the application.
    • The results below show Heap Memory Usage results. Suggest a method to improve the heap memory usage of this application.
   
   
   
   
  • The results below show Memory profiling. Suggest a method to improve the memory performance of this application. 
   
   
   
   

Assessment Task C

Practical

Purpose: The purpose of this assessment is for students to complete an assigned real-world work activity or task to show skills and performance in accordance with the competency standards as per the unit requirements.

Student instructions:

  • You will need to perform practical tasks in a simulated environment with access to the following equipment and software:
    • A suitable IDE such as Java
    • Eclipse software for debugging
    • A suitable logging framework such as Apache Log4J or Logback
    • A suitable profiling tool such as JVisualVM or similar
  • You must ensure that all software is downloaded and correctly installed prior to commencement of your tasks. If you are unsure of any equipment or software, please ask your assessor for assistance.
  • Your assessor will observe you performing this task and will complete an observation checklist. Your assessor may ask your further questions during your demonstration to clarify your understanding and competency.
  1. Your task is to use the Eclipse debugger to find each of the four bugs in the given code below. Using Eclipse, perform a debug on the given program using debugging techniques such as breakpoints, stepping through and over code and stack trace. 
  2. After you have successfully debugged the program, correct the given code and show your answers to your assessor. This activity must be observed by your assessor.

BuggySearchAndSort defines a search subroutine that is supposed to check whether or not a given integer occurs in a given array of integers. It also contains three different sorting subroutines that are supposed to be able to sort an array of integers into non-decreasing order. There is also a main program that tests the four subroutines (along with a sorting subroutine from one of Java’s standard classes that is there to remind you that you don’t necessarily need to write your own subroutines to perform common tasks).

If all the subroutines that are defined in BuggySearchAndSort were correct, then running the program would produce output that looks something like this:

The array is: 4 3 6 9 3 9 5 4 1 9

This array DOES contain 5.

Sorted by Arrays.sort(): 1 3 3 4 4 5 6 9 9 9

Sorted by Sweep Sort: 1 3 3 4 4 5 6 9 9 9

Sorted by Selection Sort: 1 3 3 4 4 5 6 9 9 9

Sorted by Insertion Sort: 1 3 3 4 4 5 6 9 9 9

Unfortunately, each of the four subroutines in BuggySearchAndSort has a bug that can either produce incorrect results or an infinite loop. If you run the buggy program without modifying it, it will go into an infinite loop.

HERE is the provided code:

import java.util.Arrays;

/**

* This class looks like it’s meant to provide a few public static methods

* for searching and sorting arrays. It also has a main method that tests

* the searching and sorting methods.

*

* TODO: The search and sort methods in this class contain bugs that can

* cause incorrect output or infinite loops. Use the Eclipse debugger to

* find the bugs and fix them

*/

public class BuggySearchAndSort {

public static void main(String[] args) {

                              int[] A = new int[10]; // Create an array and fill it with small random ints.

                              for (int i = 0; i< 10; i++)

                                             A[i] = 1 + (int)(10 * Math.random());

                              int[] B = A.clone();   // Make copies of the array.

                              int[] C = A.clone();

                              int[] D = A.clone();

                              System.out.print(“The array is:”);

                              printArray(A);

                              if (contains(A,5))

                                             System.out.println(“This array DOES contain 5.”);

                              else

                                             System.out.println(“This array DOES NOT contain 5.”);

                              Arrays.sort(A); // Sort using Java’s built-in sort method!

                              System.out.print(“Sorted by Arrays.sort(): “);

                              printArray(A);   // (Prints a correctly sorted array.)

                              bubbleSort(B);

                              System.out.print(“Sorted by Bubble Sort:    “);

                              printArray(B);

                              selectionSort(C);

                              System.out.print(“Sorted by Selection Sort: “);

                              printArray(C);

                              insertionSort(D);

                              System.out.print(“Sorted by Insertion Sort: “);

                              printArray(D);

               }

               /**

               * Tests whether an array of ints contains a given value.

               * @param array a non-null array that is to be searched

               * @param val the value for which the method will search

               * @return true if val is one of the items in the array, false if not

               */

               public static boolean contains(int[] array, int val) {

                              for (int i = 0; i<array.length; i++) {

                                             if (array[i] == val)

                                                            return true;

                                             else

                                                            return false;

                              }

                              return false;

               }

               /**

               * Sorts an array into non-decreasing order. This inefficient sorting

               * method simply sweeps through the array, exchanging neighboring elements

               * that are out of order. The number of times that it does this is equal

               * to the length of the array.

               */

               public static void bubbleSort(int[] array) {

                              for (int i = 0; i<array.length; i++) {

                                             for (int j = 0; j <array.length-1; i++) {

                                                            if (array[j] > array[j+1]) { // swap elements j and j+1

                                                                           int temp = array[j];

                                                                           array[j] = array[j+1];

                                                                           array[j+1] = temp;

                                                            }

                                             }

                              }

               }

               /**

               * Sorts an array into non-decreasing order. This method uses a selection

               * sort algorithm, in which the largest item is found and placed at the end of

               * the list, then the second-largest in the next to last place, and so on.

               */

               public static void selectionSort(int[] array) {

                              for (int top = array.length – 1; top > 0; top–) {

                                             int positionOfMax = 0;

                                             for (int i = 1; i<= top; i++) {

                                                            if (array[1] > array[positionOfMax])

                                                                           positionOfMax = i;

                                             }

                                             int temp = array[top]; // swap top item with biggest item

                                             array[top] = array[positionOfMax];

                                             array[positionOfMax] = temp;

                              }

               }

               /**

               * Sorts an array into non-decreasing order. This method uses a standard

               * insertion sort algorithm, in which each element in turn is moved downwards

               * past any elements that are greater than it.

               */

               public static void insertionSort(int[] array) {

                              for (int top = 1; top <array.length; top++) {

                                             int temp = array[top]; // copy item that into temp variable

                                             int pos = top – 1;

                                             while (pos > 0 && array[pos] > temp) {

                                                               // move items that are bigger than temp up one position

                                                            array[pos+1] = array[pos];

                                                            pos–;

                                             }

                                             array[pos] = temp; // place temp into last vacated position

                              }

               }

               /**

               * Outputs the ints in an array on one line, separated by spaces,

               * with a line feed at the end.

               */

               private static void printArray(int[] array) {

                              for (int i = 0; i<array.length; i++) {

                                             System.out.print(” “);

                                             System.out.print(array[i]);

                              }

                              System.out.println();

               }

}

PRACTICAL OBSERVATION Checklist
Student’s name:   
Assessor’s name:   
Unit of competency:ICTPRG503 Debug and monitor applications  
Location:   
Date of assessment:   
Equipment or software used:   
Did the student:  YesNo
Use the Eclipse debugger to debug the application?  rr
Use various debugging techniques such as insert breakpoints, stepping through code and interpreting stack trace?  rr
Inspect variable values in the code?  rr
Use navigation commands to execute code in debug mode?  rr
Identify all bugs in the code?  rr
Identify potential fixes and correct code?   rr
Questions: Why are the advantages of using print statements for debugging?What is the purpose of tracing the stack?What is the purpose of using comments as an aid to debugging?  
The student’s performance was:Satisfactory rNot Yet Satisfactory r
Feedback to student:   …………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………… ………………………………………………………………………………………………………………………………………………………… …………………………………………………………………………………………………………………………………………………………
Assessor’s signature: 
Student’s signature: