Sie sind auf Seite 1von 2

Alex Lyons CIS 350 Homework 1 Analysis Implementing the program is the easy part of this assignment.

What we're more interested in is getting you to think about the way in which you develop software, and your own notions of what is "good" software. In order for you to get full credit on this assignment, you must create a PDF document in which you answer all of the following questions. There are no "right" answers (yet), but you should answer these honestly and show that you have thought about what makes your code "good. 1. How did you design your application? That is, how did you choose what classes to create, and what fields and methods each of them would have? I designed my application in two major functional parts. I chose to break up the program into two pieces for simplicitys sake. I understood the requirements for each piece, and I knew that I would be able to successfully create, debug, and test each piece. Thus, I felt like it didnt make sense to break the task into smaller pieces. For a more complex project or for a project involving more people, I may have chosen a different breakdown of the overall program. I did not create member functions because there are very few places in which code is repeated sections of code that are repeated are very short, so creating more functions would not enhance readability. The first part of the program was designed to parse the records from the Oscars.csv file and store them in some data structures. In order to accomplish this, I created a Reader class that takes in a file name and generates three static HashMaps that correspond to each of the users three possible requests. The code accomplishes this task by opening the file, parsing the contents by separating each line into tokens (ignoring invalid lines), storing each record into the appropriate HashMap, and finally closing the file. The second part of the program was designed to create a user interface so that the user could access the records from the aforementioned data structures. This part of the program also indicates what input (csv) and output (log) files should be used when running the program. My main method, as designated in the specification, hence needed to contain two fields corresponding to the input and output files. 2. Describe three specific and distinct ways in which the design of your classes is "good". 1) Division of the program into classes. I believe that my division was a good one because each class is relatively simple. This is evidenced by the fact that each class can have its functionality described in a one-line comment a must, when considering readability. Furthermore, I think that any further divisions of the program into more sub-classes would have overcomplicated the code. In retrospect, it may have been appropriate to populate each HashMap with an individual function, as that would make it easy to segment the code and possibly add another HashMap if the user wanted additional functionality. 2) Choice of data structure for fast access and readability. HashMaps were the ideal data structure in this case since both the records in the csv file and the users search parameters fit the key-value model. For each record, I could divide it into tokens and use one of them as a key. I could also store multiple values for each key by storing them in a list of values, circumventing the fact that HashMaps only allow one mapping for each key. Then, for each possible search, I simply searched through the keys using built-in functions HashMap already offers functions for searching through keys, quickly accessing specific keys, and checking whether any given key exists. 3) Use of multiple data structures for expandability. I chose to use three HashMaps (instead of a MultiMap or other data structure) because I think it provides the natural ability to expand the users search options simply by adding another data structure existing data structures do not have to be

modified. Although this was a memory-inefficient implementation, I felt that the total amount of memory used (and the total amount that would be used in the foreseeable future) was low enough in comparison to the capacity of modern computers that I could ignore this issue. If I wanted to run this on mobile devices, however, I would have to reconsider the memory usage of the program and seek to optimize it more effectively. 3. Describe three specific and distinct ways (not related to design) in which the style of your code is "good" in terms of its appearance, identifier names, ease of reading/understanding, etc. 1) Extensive comments. Comments are one of the most important style elements of any program. I have written comments for most lines of code so that a reader can easily follow the code. Comments are kept to one line each to enhance readability, and they are lined up on the right-hand side of the page for appearances sake. 2) Meaningful naming convention. Each variable and method name has been selected for readability and simplicity. Variables are conjunctions of 1-3 words that begin with a lowercase letter, while class names begin with an uppercase letter. 3) Use of line breaks and tabs. Line breaks are used between major functional sections of code to enhance readability. Tabs are used both in the comments as well as the code itself to indicate layers of code text that is tabbed farther to the left indicates a higher level of code or comment. 4. How do you know your code works correctly? Describe in detail the steps you took to ensure the correctness of your implementation. I tested my overall program by writing and testing my code in steps. I chose to develop the parsing piece of my program first because I knew that I would be able to test it without the user interface. I first created the Reader class and implemented a HashMap for Search #1, the process of searching nominees by year. To test this code, I used the input file as an argument in the main function using a custom run configuration and printed results to the console (since I had not developed a user interface). I made the program print every record in the file, which also ensured that the file was being opened and read properly. Once I was satisfied with the functionality of this piece, I repeated the same process for Search #2 and Search #3. Next, I wrote the user interface. To test the UI, I ran the program to see what would appear for the user and adjusted spacing and line breaks accordingly. Then, I integrated the UI with the Reader class HashMaps one at a time, beginning with Search #1. I ran numerous tests by hand using the UI, using both valid and invalid years (1999, 199, hello, etc.) to see how the program would respond. Once satisfied, I moved onto Search #2 and Search #3, following a similar strategy for each one. For Search #3, I identified and fixed a bug wherein entering a name fragment in the form of a year yielded the results for those years. Finally, I wrote and tested the log file feature. I ran the program and checked the log file to see what appeared. I also ran, quit, and re-ran the program a few times to ensure that the log file would append new lines rather than overwriting the old lines. After adding the log file feature, I re-tested Searches #1-3 to ensure that their functionality had not been broken. I chose to test my code by hand because I wanted to ensure that the user interface was properly connected with the code underneath. I was also concerned with the running speed I didnt want automated tests to return positive results if each search took 15 seconds to complete, and I was not sure how to run automated UI tests. I also felt like running tests by hand would be just as efficient than writing code to run automated tests.

Das könnte Ihnen auch gefallen