Readability is the ease of which programs can be read and understood. Readabilit
ID: 3884269 • Letter: R
Question
Readability is the ease of which programs can be read and understood. Readability can be directly related to:
- The overall simplicity, which can be determined by number of basic components and whether it has one or more ways to accomplish a particular operation
- The orthogonality, which is the degree to which a set of primitive constructs can be combined to build the control and data structures of the language
- The number of control statements in a language
- The number of data types and structures
- The syntax or form of the elements of a language. Three types of syntax affect readability: identifier forms, special words, and form and meaning
https://7chan.org/pr/src/OReilly_JavaScript_The_Good_Parts_May_2008.pdf (book to reference)
Critique the JavaScript below as Crockford would (the first four chapters in his book can guide you). In regards to simplicity & readability, Does it meet the basic goals of readability (the ease with which programs can be read and understood)?
Readability is the ease of which programs can be read and understood. Readability can be directly related to:
- The overall simplicity, which can be determined by number of basic components and whether it has one or more ways to accomplish a particular operation
- The orthogonality, which is the degree to which a set of primitive constructs can be combined to build the control and data structures of the language
- The number of control statements in a language
- The number of data types and structures
- The syntax or form of the elements of a language. Three types of syntax affect readability: identifier forms, special words, and form and meaning
https://7chan.org/pr/src/OReilly_JavaScript_The_Good_Parts_May_2008.pdf (book to reference)
Critique the JavaScript below as Crockford would (the first four chapters in his book can guide you). In regards to simplicity & readability, Does it meet the basic goals of readability (the ease with which programs can be read and understood)?
<!DOCTYPE html> <!--example.html Input: An integer, listLen, where listLen is less than 100, followed by listLen-numeric values Output: The number of input values that are greater than the average of all input values --> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>CSI311 JS example</title> </head> <body> <script type ="text/javascript"> <!-- var intList = new Array(99); var listLen, counter, sum = 0, result = 0; listLen = prompt ( "Please type the length of the input list", "1"); if ((listLen > 0) && (listLen < 100)) { // Get the input and compute its sum for (counter = 0; counter < listLen; counter++) { intList[counter] = prompt ( "Please type the next number", "0"); sum += parseInt(intList[counter]); } // Compute the average average = sum / listLen; // Count the input values that are > average for (counter = 0; counter < listLen; counter++) if (intList[counter] > average) result++; // Display the results document.write("Number of values > average is: ", result, "<br />"); } else document.write( "Error - input list length is not legal <br />"); //--> </script> </body> </html>Explanation / Answer
The javasccript code that you have written is readable , as it provide proper comments for each part that is in the code, every every part of the code must include some comments about it's functioning . The code is simple to understand , sensible variable names are used to store the data . Proper promt messages are used for better interaction with user. This type of practice help the user of the program to understand the basic functionality of the program
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.