Dr. Michael L. Collard (Schedule)
collard@uakron.edu
TA: Mr. Andrew Murphy alm282@uakron.edu
Week 4 Class 8 Thu Feb 02 Posted: Feb 02
After Class
Crosswords
Crossword Labs had an update in the past couple of days. Printing is much more standard. So now you can
Project 1 v1d
General principles that I carefully went over and emphasized, but are being overlooked.
make
make run
, and verify the result.Announcements
Project 1 Pull Request
I created a pull request for Project 1 to create the (empty) files, xml_parser.hpp
and xml_parser.cpp
for part v1d. The easiest way to merge this into your code is the Merge pull request at GitHub. Once you merge, then remember to do a git pull
in all of your cloned repositories.
Note that xml_parser.{hpp,cpp}
expands to xml_parser.hpp
and xml_parser.cpp
in a shell.
Class
Exercise 16: srcFacts Concerns- Handout in class, due by the end of the class meeting
Unless noted otherwise, all exercises are due by 4:30 pm on Monday, Feb 6.
One approach to understanding the source code of a system is to count things, e.g., the number of statements, functions, classes, expressions, LOC (Lines Of Code), etc. The program srcFacts produces a report of these counts.
It is very difficult for a program to directly parse C++ source code, i.e., identify the syntactic parts of the code. So the srcFacts program does not parse the C++ source code. It uses another tool, srcML, to convert the C++ source code into an XML format. The srcFacts program inputs this XML format, parses the XML collecting counts, and produces the report.
The srcFacts program is one large, main() function using almost no design features. It does have high scalability and performance as it is extremely fast and, for example, can produce a report on the entire Linux kernel in under 6 seconds. However, it is not easy in its current form to debug the XML parsing, add additional program element counts, or even understand what is going on. It includes code for parsing all parts of XML, but it would not be easy to adapt the XML parsing code for another purpose, e.g., another report. The only way to reuse this code is by copy/paste reuse. It has no modularity, extensibility, reusability, and specifically no maintainability.
Your task is to take the srcFacts code, improve the overall design, and extract the XML parsing part of the code. When completed, a set of functions in the files xml_parser.hpp
and xml_parser.cpp
will handle as much XML parsing as possible, while the main program, srcFacts.cpp
, generates the report using the XML parser functions for parsing.
The steps (in order) with the associated (git) tag are:
Tag v1a
Without changing the design, add the code necessary for the report to include the number of return statements. The heading in the table must be "Returns". Due Jan 24
Tag v1b
Move the refillContent()
function into the separate refillContent.hpp and refillContent.cpp files. Due Jan 26 27
Tag v1c
Apply the specific design changes from the Coding Practices Task List (to appear). As you verify that the code follows the practices given, check them off. Once you have completed all of them, close the issue. Due Jan 29 31 Feb 1
Tag v1d
Extract a set of (free) functions to handle the low-level details of the XML parsing. Extract one function at a time, i.e., each commit can only include a single extracted function. These function declarations and definitions belong in the files xml_parser.hpp
and xml_parser.cpp
, as described above. Due Feb 2 6 9
Tag v1e
Add the necessary code to count the number of line comments and the number of literal strings. The headings in the table must be "Line Comments" and "Strings". Due Feb 6 7 10
Your repository for this project is through GitHub Classroom with a link on the Brightspace course page.
return 1;
so the program exits with the status of 1
. To exit the program from within any function, use exit(1);
which requires the include file stdlib.h
.git clone
and git checkout
.