Finals Week
Project 4 Scores and feedback posted:
Please review the feedback as it may relate to your UML.pdf part of the XMLFramework Project, and the material on implementing extension points for the Final Exam.
Your XMLParser reads from standard input, or file descriptor 0. If you want to read from a file, then you can redirect from the file to file descriptor 0. An example program, filein.cpp shows how to do this.
The number of @TODO
s which are optional/extra credit is 6. It doesn't matter which ones these are.
Week 15 Class 28 Thu Apr 27 Posted: Apr 27
Announcements
sudo
for some commands, including copying the library to /usr/local/lib and using ldconfig
.XMLFramework
Your XMLParser reads from standard input, or file descriptor 0. If you want to read from a file, then you can redirect from the file to file descriptor 0. An example program, filein.cpp shows how to do this.
Instead of posting which @TODO
s are optional, I will decide on the number that become optional. For now,
that number is 6, as in 6 of the @TODO
s count as Extra Credit. It doesn't matter which ones they are.
CheatSH A utility for shell command "cheat sheets". For the cheat sheet of ldd
:
Discovered this morning through the console weekly digest of developer tools.
Class
All exercises are due by 4:30 pm on Fri Apr 28
Week 15 Class 27 Tue Apr 25 Posted: Apr 25
After Class
sudo
for some commands, including copying the library to /usr/local/lib and using ldconfig
.XMLFramework
Your XMLParser reads from standard input, or file descriptor 0. If you want to read from a file, then you can redirect from the file to file descriptor 0. A example program, filein.cpp shows how to do this.
Announcements
Class
Exercise 76: XMLFramework @TODO
Make sure your XMLFramework has at least one @TODO completed.
Exercise 78: Library
This exercise is optional as I will drop the lowest Exercise score.
In an asciinema terminal session, perform the following on the Increment example in Linux using gcc.
All commands must be typed in (not copy and pasted). Be sure to remember to use tab completion for filenames.
incr
incr
increment()
incr
incr
increment()
incr
incr
showing that it cannot find the libraryincr
usesLD_LIBRARY_PATH
so that incr
can find the shared libraryincr
still cannot find the libraryldconfig
incr
showing that it can find the libraryincr
usesWhen completed, submit your asciinema URL
All exercises are due by 4:30 pm on Wed Apr 26
Week 14 Class 26 Thu Apr 20 Posted: Apr 20
Special Announcement
Class is in-person on Thursday, Apr 20. See you in our regular classroom.
Announcements
Class
Exercise 73: Build XMLFramework
Create your XMLFramework repository using the GitHub Classroom link on Brightspace.
Then do the following in an asciinema session:
Submit your resulting asciinema URL using the link in the title of the exercise.
Exercise 74: XMLFramework Quiz
Take the XMLFramework Quiz. You only have one chance to get the answers right.
Exercise 75: Visitor Design Pattern Crossword
All exercises are due by 4:30 pm on Fri Apr 21
The project is a critical part of your overall grade in the course, and parts of the project count toward 25% of the questions on the Final Exam. Consider this as a take-home part of the Final Exam. No matter how you performed on the previous projects, you need to work on this project.
The project is due by 11:59:59 pm on Friday, May 5. The project consists of the following:
The open-layered architecture framework, XMLFramework, supports all of this and includes:
There is a lot of code in the project already. The primary task is to finish the remaining @TODOs. Some examples are:
// @TODO Add to the factory method so that it generates the correct parser
// @TODO Apply encapsulation and information hiding
// @TODO Apply the const specifier to methods where applicable
// @TODO Create a Filter that outputs XML statistics
// @TODO Declare a XMLParserHandler for XMLParser to use
// @TODO Declare the class XMLParserDocumentHandler which inherits from XMLParserHandler
// @TODO Enforce that no one can inherit from XPathFilter
// @TODO Implement the XMLDocumentHandlerParser
// @TODO Integrate use of XMLDocumentHandlerParser into this method
// @TODO Make it so that there is only one parser object in the entire
// @TODO Remove any unused include files
// @TODO Remove need for destructor definition
// @TODO Remove unused include files
// @TODO Replace this code with a call to the action of the class MacroFilter
// @TODO Replace with an instance of a MacroFilter
// @TODO Use override where appropriate
The @TODO
s that involve integrating your XMLParser into the framework are not required and, if completed, will count as extra credit for the projects.
The work involved is:
@TODO
s@pattern
and @role
comments. A class can participate in multiple roles in multiple patterns.Notes:
git grep
works well. For all the lines of code that contain @TODO
, enter the command git grep "@TODO"
in the project's top directory. To see only the filenames, git grep -l "@TODO"
. The command depends on the directory where you issue the command, e.g., if in the directory framework; the results are for that directory and its subdirectories. A command for a comprehensive report of which @TODO
s are left:
More on this commandThe Final Exam is in our regular classroom Final Exam: May 4, 2:30 - 4:30 pm.
You are responsible for the following:
The exam has various problem types, including short answers, definitions, comparisons, drawing diagrams, and coding.
Questions are from what I covered in class, the book, the exercises, and the projects. If I did not cover it in class, it is not on the exam.
The following exam answers are taken from your work on the XMLFramework Project. You will not answer them on the Final Exam
Week 14 Class 25 Tue Apr 18 Posted: Apr 18
Special After Class
Return to in-person classes on Thursday, Apr 20. See you in our regular classroom.
Special Announcement
2023 CEPS Design Day on Tuesday, Apr 18 is cancelled, and UA switched to remote learning late Monday night.
In order to reserve time for a rescheduling of the 2023 CEPS Design Day, we will have class on Tuesday, Apr 18.
Class will be remote via Teams.
My Office Hours will remain the same as normal (1 - 2pm and 4:45 - 5:15pm) but will be via Teams.
Announcements
Class
Exercise 70: Software Architecture Crossword
Exercise 71: Facade Design Pattern Crossword
Exercise 72: Singleton Design Pattern Crossword
All exercises are due by 4:30 pm on Wed Apr 19
Week 13 Class 24 Thu Apr 13 Posted: Apr 13
Announcements
2023 CEPS Design Day on Tuesday, Apr 18
The Computer Science presentations are from 2 - 4 pm, and I encourage you to attend.
This time period conflicts with the afternoon CPSC 421-020 OOP and CPSC 480 SE sections, so we will not have a class meeting on Tuesday, Apr 18. However, I will post a short screencast for viewing.
During the morning CPSC 421-010 OOP class time, 10:45 - Noon, I will be in my office for Office Hours. So my Office Hours on Tuesday, Apr 18, are:
Project 3
Added issues for v3identity.
Note that Project 4, part v4a, is to fix XMLParser issues. So you do not have to fix any identity or xmlstats issues, and only fix the ones in XMLParser (which I already posted).
Inline member functions for abstract classes
At the design level in UML Class Diagrams, we often have abstract classes:
When we implement, we have a couple of choices in C++. We can use a pure virtual method
or an empty method:
In this case, it is preferred to have the definition in the include file, i.e., an inline member function, instead of a separate declaration and definition. The reason is that we want the class user to see that it is empty and that they should override it if they want it to do anything. We are not using an inline member function just because the method definition is short. So this is an exception to the rule.
Class
All exercises are due by 4:30 pm on Fri Apr 14
Week 13 Class 23 Tue Apr 11 Posted: Apr 11
Announcements
Class
All exercises are due by 4:30 pm on Wed Apr 12
Week 12 Class 22 Thu Apr 06 Posted: Apr 06
After Class
Announcements
CPSC 480 Software Engineering
The department is offering two sections of CPSC 480 SE in Fall, 2023.
There will be no sections of CPSC 480 SE in Spring, 2024. So if you need CPSC 480 SE to graduate in Spring 2024, you will have to take it in the Fall.
Class
All exercises are due by 4:30 pm on Fri Apr 07
Project 4 continues the work on srcFacts. It is due at 11:59:59 pm Tuesday, Apr 18 Wednesday, Apr 19, and involves the following stages:
Tag "template": Redesign XMLParser to use the Template Design Pattern. In this pattern, extension points are virtual methods. Create a new class srcFactsParser (in the new files srcFactsParser.hpp and srcFactsParser.cpp) that inherits from class XMLParser. Do the same thing for the new class IdentityParser (in the new files IdentityParser.hpp and IdentityParser.cpp) and the new class XMLStatsParser (in the new files XMLStatsParser.hpp and XMLStatsParser.cpp). Add these classes to the repository, e.g., git add srcFactsParser.hpp
, and update the CMakeLists.txt file so that they are part of the build (search for the term "sources"). Update your class and sequence diagrams to show this new design.
As before, your XML parser needs to provide access to all parts of XML via the following extension points (i.e., virtual methods) from XML notes slide 34
git mv srcFactsParser.hpp srcFactsParserHandler.hpp
. Update your class and sequence diagrams to show this new design.One prevalent issue in these conversions is that changing XMLParser and srcFacts will cause identity and xmlstats to break until they are converted. To avoid this, first, understand that make
is a synonym for make all
and builds all executable targets. So instead of building all executable targets, build them separately as needed, e.g., make srcfacts
, make xmlstats
, or make identity
.
Keep in mind:
Week 12 Class 21 Tue Apr 04 Posted: Apr 04
Announcements
Class
All exercises are due by 4:30 pm on Wed Apr 05
Week 11 Class 20 Thu Mar 30 Posted: Mar 30
Announcements
Class
Take the code for ExceptionsDemo.cpp and perform the following changes:
g()
to 200 in both the code and the output messageh()
in both the code and the output messagef()
to allow the negative value -1 (-2 and smaller is still not allowed)Run the program once for each exception, and show that the exception is thrown.
To demonstrate these changes, you will record a terminal session using asciinema. It records the commands that you enter and the output the command produces.
After you install asciinema on Linux/WSL/macOS, it is quite straightforward to use.
You can play, pause, skip, etc. You can also copy the commands as text. Note that the replay even includes the pauses that you made, and any delay as the command is run.
At the end of the terminal session, asciinema will show a URL. This URL can be used by anybody to view the session. This is what you will submit for the exercise to the link in the exercise title. The URL should not contain "connect" or be a local file. Incorrect URLs will receive a 0.
You can use GitHub Codespaces for this exercise. Since asciinema is not installed, take a look at asciinema Running from source.
To build the ExceptionsDemo:
Use the GitHub Classroom Exceptions invitation link in Brightspace.
Exercise 57: Constructor Exceptions
Upload an asciinema URL of the following session. As previous, the URL should not contain "connect" or be a local file. Incorrect URLs will receive a 0.
Perform the following: and run the RAIIDataMembers program (part of the GitHub Classroom Exceptions):
valgrind
on the program to show there is a memory leak. Since valgrind produces a large amount of output, filter the call using the following command:
std::vector<int>
for the field data
instead of a c-array.You can do all of this in one terminal session, or break it into two. The submission form (in the link of this exercise) has both.
All exercises are due by 4:30 pm on Monday, Apr 3
Week 11 Class 19 Tue Mar 28 Posted: Mar 28
Announcements
[&]
. Only do this if you are going to pass a high percentage of the variables in scope (see Stamp Coupling).Project 3 Pass std::string_view
as an IN parameter by value, not const reference:
std::string_view
consists of a pointer (to the actual memory) and a size and is equivalent to the following:
Since this is so small, passing by value is efficient. While it takes the same number of assembly operations, it requires an extra pointer dereference, and timings show they are equivalent. The general guide is to pass by value when the object is 16 bytes or less.
Class
Exercise 50: FileIO
The program ReadFile supports multiple ways to read from standard input. You run the program with the option on the command line. The options include get, read, and fileread:
All is well and good, but the program has memory leaks with some options. Use valgrind to determine what the problem is, fix it, and commit your fix. Do not make any other changes.
Valgrind performs dynamic analysis, which means it collects data during the execution of a program. For valgrind, running with one option (e.g., using the option get) may find an issue, but running with another option (e.g., using the option read) may not. To be sure, we have to run the program with all options.
The build command is:
To run with valgrind for option get:
That command is a single line displayed using the line continuation character ("\"). You can copy and paste the entire command.
You must run the command with each option, get, read, and fileread.
The fix consists of only one change to the code. Your code must pass with a clean valgrind report for all three options.
The GitHub Classroom link is in Brightspace.
All exercises are due by 4:30 pm on Wed Mar 29
Week 10 Class 18 Thu Mar 16 Posted: Mar 16
After Class
GitHub GitHub is experiencing "degraded performance" with Git Operations. You can check the status of GitHub via the GitHub Current Status.
In general, this should only effect git pull
or git push
. A git commit
is performed in the local repository (that you cloned). The timestamp on a commit is based on when you made the commit, not when it was pushed.
Other parts of the status that may be applicable are Pull Requests, Issues, and Codespaces. If you see problems with Pages that means that you can still access the course pages (course pages are hosted in GitHub Pages), but I may not be able to update the pages.
[&]
.Project 3 Pass std::string_view
as an IN parameter by value, not const reference:
std::string_view
consists of a pointer (to the actual memory) and a size and is equivalent to the following:
Since this is so small, passing by value is efficient. While it takes the same number of assembly operations, it requires an extra pointer dereference, and timings show they are equivalent. The general guide is to pass by value when the object is 16 bytes or less.
Announcements
Midterm
Midterm scores and feedback are posted in Brightspace:
@stereotype get
method for total bytes.Class
Exercise 49: Base
virtual
methods in C++ support dynamic polymorphism. Dynamic polymorphism only occurs with pointers and references to objects, passing by value is not polymorphic.
The classes in this exercise are Base, Derived which inherits from Base, and DerivedDerived which inherits from Derived. So Derived is a Base, and DerivedDerived is a Derived and therefore also is a Base.
The method m1()
is not virtual, so it does not provide for polymorphism.
The method m2()
is virtual, so it does provide for polymorphism.
Complete the assertions in the code that indicate (via a string) which method is called, e.g., for m1()
is it "Base::m1()"
,
"Derived::m1()"
, or "DerivedDerived::m1()"
?
Complete each assertion one at a time in order, compiling and running the program (i.e., make run
) after each assertion is completed. The assertion you edited should pass, and you should be onto the next assertion.
You are required to commit for each block of statements in the main program.
The GitHub Classroom link is in Brightspace.
All exercises are due by 4:30 pm on Monday, Mar 27
Week 10 Class 17 Tue Mar 14 Posted: Mar 14
After Class
int
to std::string
, use std::to_string()
.@stereotype get
method for total bytes.Announcements
IoC Fixed diagram comparison:
Class
Exercise 36: UML Class Relationships Crossword
Exercise number is out-of-sequence because I moved some of the notes around
All exercises are due by 4:30 pm on Wed Mar 15
Week 9 Class 16 Thu Mar 09 Posted: Mar 09
Announcements
Class
Exercise 40: Memory I
The file Memory.cpp in the repository Memory contains many memory resource problems described in the notes.
Compile and run the program on your platform (i.e., your compiler and operating system). You may or may not see a memory-related issue during the build and run.
Go to a system where you can run valgrind
. Following the instructions in the Guide: Valgrind, compile and run valgrind
on the program.
Fix the memory resource problems in Memory.cpp without using std::unique_ptr. Do this for each section one by one committing each section separately. Get the code to the point where it compiles and runs successfully, and you have a clean Valgrind run. Once done, tag this in Git as fixmemory
The Memory repository is available via GitHub Classroom with a link on the Brightspace course page.
Exercise 41: Memory II
Replace the raw pointers (e.g., int* p
) with std::unique_ptr<int>
. Ensure it runs successfully on all compilers and you have a clean Valgrind run. The include file for std::unique_ptr
is <memory>
. Once done, tag this in Git as smartpointer
Exercise 43: Lambda
Following my example in class, create a lambda function for each section.
The GitHub Classroom link is in Brightspace.
All exercises are due by 4:30 pm on Monday, Mar 13.
The main problem with the design for the srcFacts project is the complicated section of code (large while loop with nested-if) surrounding the srcFacts concerns. We have moved much of the low-level parsing details out of srcFacts.cpp (and into XMLParser), but that overall code structure remains.
Change the design of XMLParser to use full IoC (Inversion of Control). IoC lets you move the large while loop with nested-if entirely into an XMLParser method parse()
. The only things that srcFacts will have to do (and the only public methods of the new XMLParser) are the parse()
method and (depending on your implementation) methods to register handlers.
Your XML parser needs to provide access to all parts of XML, even if srcFacts does not use it, via the following extension points from XML notes slide 34
There is no explicit stage to fix the code from the Project 2 feedback. Fix any style issues in XMLParser, or any issues that will cause a problem with Project 3.
Tag v3a: Redesign XMLParser to use IoC with lambda handlers for the extension points. For srcFacts, this means that the lambda functions in srcFacts.cpp contains all the processing of the XML data results, e.g., tag names with none of the XML parsing. Update your Class Diagram and Sequence Diagram to reflect this new design. Rules apply:
Tag v3xmlstats: Create the application xmlstats that produces a markdown report (similar to what srcFacts does) that indicates the number of each part of XML. E.g., the number of start tags, end tags, attributes, character sections, etc.
Tag v3identity: Create the application identity which is an identity transformation. A transformation is a program that converts data in one format to data in a related format, typically the same format. In this case, it converts from XML to XML. It is an identity transformation because the output XML should be the same (as much as possible) as the input XML. The XMLParser will parse the input, and your callbacks will output the XML format. You can assume that there are no CDATA parts, but you must escape all >
, <
, and &
in Character and CDATA content.
Note: Any changes to XMLParser must work with srcFacts, xmlstats, and identity:
All tags for Project 3 are due Friday, Mar 31.
Keep in mind:
Midterm Exam Tue Mar 07 Posted: Mar 03
Midterm In our regular classroom
Week 8 Class 15 Thu Mar 02 Posted: Mar 02
After Class
xml_parser.hpp Not clear if there were issues not created or not completed, but in grading Project 2 (post v2a) I am finding a lot of things in xml_parser.hpp that are not for the user of the functions, but for the implementor.
Let me make this very clear. The only things allowed in the file xml_parser.hpp are:
#include <string_view>
#include <string>
(if used as a parameter or return type, leave out if std::string
is not used)#include <optional>
(if used as a parameter or return type, leave out if std::optional
is not used)Anything else does not belong in the .hpp file. The purpose of the .hpp file is not so you can compile the corresponding .cpp file. It is for the user of your functions, e.g., srcFacts.cpp. So cluttering it up with declarations and includes that are only needed in the .cpp file is extremely bad design. In the case of xml_parser, this includes any of the following:
Having any of these in your xml_parser.hpp file adds unnecessary dependencies and hurts comprehension.
Announcements
Exercise 24: DesignFun II Is graded with any feedback in Brightspace
Note that using both min()
and minimum()
together lack naming clarity. For example, which is which? Pick one and stick to it.
Class
Exercise 36: Declaration Cohesion
Follow along in class. The GitHub Classroom link is in Brightspace.
Exercise 37a: Convert II
Follow along with the design changes in class. This is part (a), with part (b) later in the class meeting.
Exercise 37b: Convert II
Follow along with the design changes in class as we apply lambda functions.
All exercises are due by 4:30 pm on Wednesday, Mar 8 (day after the Midterm)
Week 8 Class 14 Tue Feb 28 Posted: Feb 28
After Class
Project 2
I am not done grading v2a. In the meantime, I opened up Project 2 so I can give feedback to those with missing tags or broken builds.
Exercise 24: DesignFun II Is graded with any feedback in Brightspace
Note that using both min()
and minimum()
together lack naming clarity. For example, which is which? Pick one and stick to it.
Announcements
Exercise 31: Member Initialization List
Include File Guard Name
The convention we follow for include guard names, technically, a preprocessor macro, is to:
.
with _
E.g., xml_parser.hpp has the include guard name INCLUDED_XML_PARSER_HPP
.
Some have added extra _
s to separate words in the filename. Basically, this is replacing camelCase with
under_score. If these extra underscores are added, then the file XMLParser.hpp would have the include guard
name INCLUDED_XML_PARSER_HPP
, and xml_parser.hpp would have the identical include guard name. So the rule is to not add extra underscores, so the include guard name for XMLParser.hpp is INCLUDED_XMLPARSER_HPP
.
Do not use filenames with the same characters where the only difference is the case of a letter, e.g., XMLParser.hpp and xmlparser.hpp. Some UNIX filesystems are not case sensitive for filenames, e.g., macOS APFS.
Class
Exercise 33: Convert
Follow along in class. Be sure to mark and update concerns as we go along.
Make the first commit where you add the concerns.
The GitHub Classroom link is in Brightspace.
Exercise 35: Names
The UML Class Diagram shows Name with attributes that are single-value optionals.
Convert the source code class to use std::optional
The link for GitHub Classroom is in Brightspace
Note: The type String
in a UML Class Diagram does not necesarily map to a std::string
in a C++ program. It could map to a std::string_view
, or even a c-string. Which source-code type a UML type maps to is part of the code implementation, and not part of the model
All exercises are due by 4:30 pm on Wed Mar 01
The Midterm Exam is during class time in our regular classroom on Tuesday, Mar 7.
You are responsible for the following:
Software Design - Definition, the two types of design (so far), where they come from, what they are concerned with Software Design Characteristics - Know the list of characteristics Algorithmic Decomposition - Explain what it is and how it works Structure Diagram Given code or description, draw. Coding Style Given function declaration or definition, improve the code using the principles we discussed in class Generalizing Functions - Given an example, explain what we could do to generalize it Physical Organization - Include guards, header comments, function comments, separate function declaration, and definition, the contents of each type of file Naming & Method Naming Standards - Given a list of names, correct the poor names Iterator - Four basic operations in GoF terms and C/C++ operators Free-Function Stereotypes - Know the terms and be able to write a free function for each stereotype UML Sequence Diagram Given a scenario, be able to draw a sequence diagram XML Know what is and what is not an XML concern Concerns - Definition, separation of concerns, be able to identify concerns Cohesion - Definition UML Class Diagram - C++ code ⇨ diagram, diagram ⇨ C++ code, single class only (no relationships) Encapsulation and Information Hiding - Definition of each, the encapsulation rule and the information hiding rules. Member Initialization List - Order of field creation, proper use of member initialization list Note that method stereotypes and callbacks are not on the exam.
The exam has various problem types, including short answers, definitions, comparisons, drawing diagrams, and coding.
Questions are from what I covered in class, the book, the exercises, and the projects. If I did not cover it in class, it is not on the exam.
Week 7 Class 13 Thu Feb 23 Posted: Feb 23
After Class
Announcements
Class
Exercise 31: Member Initialization List
Following my example in class, convert all the constructors in all files to use member initialization lists.
CMake builds an executable for each .cpp file.
The GitHub Classroom link is in Brightspace.
All exercises are due by 4:30 pm on Monday, Feb 27
Week 6 Class 12 Thu Feb 16 Posted: Feb 16
After Class
Office Hours No Office Hours on Tuesday, Feb 21
Project 1
auto
and const
are for the main()
of srcFacts.cpp. That code should have moved to xml_parser.cpp
as part of v1d, so you will have to make the auto
and const
changes in those files.Exercises
Announcements
Project 1
I started posting issues in GitHub as feedback for Project 1. Issues for tag v1a were posted previously. Will most likely get v1b, v1d, and v1e posted by class time. I have to fix the scripts for v1c. There may be additional issues as it goes along.
Scores in Brightspace will be added later.
Monitor the course page for After Class notes as I will post when I have things finished.
Make sure to review the process for fixing and closing these issues as described in Project 2, i.e., wait until after class.
Viewing Indentation
To view indentation, as in some GitHub issues and the generated reports, use the following command:
To view different files, change the filename in the cat
command
Exercises 24 & 25 I did not finish grading these exercises yet. Most likely will not get to them until Monday.
Class
Exercise 27: Create a UML Class Diagram
Create a UML Class Diagram at yuml.me for the class diagram on the right.
Compose your class diagram at yuml.me. The resulting contents of the box on yuml.me will go into the file ClassDiagram.txt in the GitHub Classroom Repository (link in Brightspace. You should be able to copy the contents of the file ClassDiagram.txt and paste it into the editing box at yuml.me and see the diagram on the right.
Your final result should look exactly like the image shown here. The style used for the image is Boring, instead of the default Scruffy or Plain.
Make sure to commit after each of the following parts:
Note that yuml.me can be temperamental. Add iteratively and carefully.
All exercises are due by 4:30 pm on Tuesday, Feb 21
Continue to improve the design of srcFacts using more language features. There are no changes to the functionality of this project, only to the design.
In addition to the following code changes, you will maintain two modeling diagrams:
The diagrams must be updated to reflect the code for each tag. So do not tag until the part is done and the diagrams are updated.
Tag v2a
Implement and close all issues I created as feedback from Project 1. When you finish fixing an issue, there must be at least one commit that describes what you are changing. Create a tag for that commit in the form issueN tag where N
is the issue number, e.g., when you complete issue1, create the tag issue1. Do not refer to the issue number in the commit message, only in the tag. For the sequence diagram, add your calls' exact function names and (UML form of) parameters to the xml_parser. Due Feb 23
Tag v2b
Create a namespace, xml_parser
, for the functions in xml_parser. This will involve making changes to the files srcFacts.cpp, xml_parser.hpp, and xml_parser.cpp. Due Feb 24
From this point on, do not make any changes to the files xml_parser.hpp or xml_parser.cpp.
Tag v2c
Create the class XMLParser
in the files XMLParser.hpp and XMLParser.cpp where the methods call the free functions from xml_parser.hpp. Do not use any fields/data members. The method parameters must be identical to the parameters of the free functions in xml_parser.hpp. For the sequence diagram, add the XMLParser as a participant and show how it is involved between srcFacts and xml_parser. Due Feb 28
Tag v2d
Eliminate any parameters in the XMLParser methods that you can, replacing them with field/data members in the class. In other words, move as many XML parsing variables from srcFacts.cpp as possible. Do this one field/data member at a time. For the class diagram, show the added fields and the removal of parameters. For the sequence diagram, update the parameter lists of the calls to the XMLParser. Due Mar 3
Tag v2e
Inline the calls to the xml_parser free functions into your XMLParser methods. Inlining the calls does not mean adding the inline
specifier, and it does not mean changing anything in XMLParser.hpp. Do this one free function call at a time. Ultimately, your XMLParser.cpp should have no calls to xml_parser functions and will not need to include xml_parser.hpp. Do not make any changes to the files xml_parser.{hpp,cpp}. For the sequence diagram, remove the xml_parser participant and any calls. Due Mar 3
Ensure the project compiles, builds, and produces the correct answer at every commit with gcc and clang.
There is a zero-tolerance policy for the following. A zero-tolerance policy means that you will receive a zero for that part if any of the following are violated:
v2a
, v2b
, v2c
, v2d
, and v2e
, the program must compile and build in gcc and clang without errors or warnings.private
Week 6 Class 11 Tue Feb 14 Posted: Feb 14
Class
DesignFun Feedback
@return
if return type is voidExercise 24: DesignFun II
Go over your answers and fix them according to the guidelines given.
Exercise 25: Create a Sequence Diagram
Create a sequence diagram at SequenceDiagram.org for the diagram on the right, which is for parsing a start tag with an attribute.
Start with the SVG file with the GitHub Classroom Repository link at Brightspace, and commit your changes to that repository.
Your final result should look exactly like the image shown here.
Make sure to save as a SVG Image File (vector image with embedded source text)
All exercises are due by 4:30 pm on Wed Feb 15 unless otherwise noted
Week 5 Class 10 Thu Feb 09 Posted: Feb 09
Announcements
Project Due Dates A few things to check as you get to a project deadline:
TRACE()
enabledExercise Due Dates All on Monday
Class
Exercise 23: DesignFun
Finish the code in the repo DesignFun in GitHub Classroom. Be sure to follow carefully all directions in the header comment.
If you have not already, this would be an excellent exercise to try out GitHub Codespaces.
All exercises are due by 4:30 pm on Monday, Feb 13
Week 5 Class 9 Tue Feb 07 Posted: Feb 07
Announcements
Crossword Labs had an update in the past few days. Printing is much more standard. So now you can use either 1) the Print menu item in your browser or 2) the Print button
Project 1 v1d
General principles that I carefully go over and emphasize but are being overlooked:
make
and observe if it successfully buildsmake run
, and verify the resultClass
Exercise 20: Comment Events
On a sheet of paper, write down all the events for a single-line comment. Then write down the change that occurs with a block comment.
Command | Description |
---|---|
1) cmake . -DTRACE=ON |
Use the CMake variable TRACE to define the TRACE() macro |
2) make |
Rerun make to include the changes to the TRACE() macro |
3) make run |
Run the demo data with the srcfacts program |
3) ./srcfacts < line.cpp |
Directly run the srcfacts program in Linux or macOS |
4) cmake . -DTRACE=OFF |
Use the CMake variable TRACE to undefine the TRACE() macro |
4) cmake . -UTRACE |
Alternatively, remove the CMake variable TRACE |
5) make |
Rerun make to include the changes to the TRACE() macro |
I strongly recommend that at least once, you turn on the TRACE()
macro with your code and try to run it. You may be surprised.
All exercises are due by 4:30 pm on Wed Feb 08 unless otherwise noted
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.
Week 4 Class 7 Tue Jan 31 Posted: Jan 31
After Class
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.
Announcements
v1c
GitHub Desktop & Atom Users Keep your software updated. It is easy to forget about any virtual environments and not update them.
On Windows, Windows Update does not update the Ubuntu in WSL. So for WSL (and Ubuntu):
On macOS, macOS updates do not update the software in brew
. So for brew:
Also, before you install a package, do the above first.
Cleaning Up Package managers download packages and installs them. Once they are installed, the downloads are not needed, unless you want to reinstall
at some point. And, they can be downloaded again if needed.
For WSL (and Ubuntu):
For brew
:
Class
Unless noted otherwise, all exercises are due by 4:30 pm on Wed Feb 01
Week 3 Class 6 Thu Jan 26 Posted: Jan 26
After Class
Announcements
git pull
before you start making any changes to your code. That prevents
the need for a git merge after. That would have prevented some of the git warnings that students were getting.Class
Unless noted otherwise, all exercises are due by 4:30 pm on Monday, Jan 30
Week 3 Class 5 Tue Jan 24 Posted: Jan 24
After Class
git pull
before you start making any changes to your code. That prevents
the need for a git merge after. For the 010 section, that would have prevented some of the
git warnings that students were getting.Announcements
Class
Exercise 11: Separate Compilation Crossword - Delayed until after next class
Exercise 12: Rainfall IV
We continue on with the notes on Rainfall Coding Practices. Refer to Exercise 5: Rainfall I.
Unless noted otherwise, all exercises are due by 4:30 pm on Wed Jan 25
Week 2 Class 4 Thu Jan 19 Posted: Jan 19
After Class
Announcements
Navigation In WSL, if you enter the following command in the WSL shell:
the Windows File Explorer will open with the directory you are at in the WSL shell.
Carefully note that there is a single dot, .
, in the command. A single dot in a shell is the current directory. Two dots, ..
, refer to the parent directory (as in cmake ..
)
Class
Exercise 8: Build & Run srcFacts
Create your srcFacts repository from GitHub Classroom and clone the repository on your machine. Build and run the program to verify it works in your development environment. At the end of the commands, enter the following:
Upload a screenshot (or multiple) to Brightspace of these commands executing.
Exercise 9: Rainfall III
We continue on with the notes on Rainfall Coding Practices. Refer to Exercise 5: Rainfall I.
Unless noted otherwise, all exercises are due by 4:30 pm on Fri Jan 20
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
.Week 2 Class 3 Tue Jan 17 Posted: Jan 17
After Class
Missing Repositories
I did some cleanup of membership on UAComputerScience, the organization used for GitHub Classroom.
Unfortunately, if you were a member of UAComputerScience, it may have removed your access to your repository.
For most of you, this should not be a problem.
I am restoring access. If you don't have access, send me an email, or a message via Teams.
Update Going through all the repositories, it is only those who took another class of mine (e.g,. Software Engineering) and were members (instead of "outside collaborators"). For those few, I sent out invitations to restore access to your repository.
Navigation In WSL, if you enter the following command in the WSL shell:
the Windows File Explorer will open with the directory you are at in the WSL shell.
Carefully note that there is a single dot, .
, in the command. A single dot in a shell is the current directory. Two dots, ..
, refer to the parent directory (as in cmake ..
)
Announcements
Ubuntu 20.04
If you are having issues installing gh
in WSL, then you probably have Ubuntu 20.04 installed instead of
Ubuntu 22.04. To check your version of Ubuntu:
At some point you will need to update. In the meantime, you can use the following commands to
directly install gh
:
Note that to install an updated CMake, you will have to follow the directions at apt.kitware.com for Ubuntu Focal Fossa (20.04)
Class
Exercise 7: Rainfall II
We continue on with the notes on Rainfall Coding Practices. Refer to Exercise 5: Rainfall I.
Unless noted otherwise, all exercises are due by 4:30 pm on Wed Jan 18
The scores and feedback for Exercise 6: rainfall.cpp is in two parts:
feedback1
branch of your repository. Best to view this on GitHub.The report check/shows the following:
cmake ..; make; make run; make check
git show
cmake ..; make; make run; make check
for the code in this commitdiff
of rainfall.cpp with what I enteredI use the report to give feedback. In some cases, the report can be off, e.g., if you had extra commits.
Overall observations:
git push
.Valid commit messages:
Invalid commit messages:
Week 1 Class 2 Thu Jan 12 Posted: Jan 12
After Class
If you are having issues installing gh
in WSL, then you probably have Ubuntu 20.04 installed instead of
Ubuntu 22.04. To check your version of Ubuntu:
At some point you will need to update. In the meantime, you can use the following commands to
directly install gh
:
Note that to install an updated CMake, you will have to follow the directions at apt.kitware.com for Ubuntu Focal Fossa (20.04)
If this doesn't work, then use GitHub Codespaces to work on Rainfall.
Announcements
Class
Exercise 5: Rainfall I
Note Due to the required setup, Exercise 5 is due by 8 am on Monday, Jan 16. Even with this extra time, there is a lot of setup, so start early.
Unless noted otherwise, all exercises are due by 4:30 pm on Fri Jan 13
Take the starting rainfall.cpp code and make the same changes that I make in class.
Your code is in a repository from GitHub Classroom:
Then you clone the repository. Cloning creates a local repository that is a copy of your repository at GitHub.
Now to setup the build:
Git Workflow on Rainfall
Note Your code must build and compile. If you have a build warning or error, fix these before making any more changes to the code.
Note You must commit each change that I make separately and use the exact commit message that I use in class
You can follow along and see the commits that I make in class:
If you have any questions or issues, make sure to contact me.
Week 1 Class 1 Tue Jan 10 Posted: Jan 10
After Class
Announcements
O'Reilly Online Learning The course textbooks are available in O'Reilly Online Learning.
You do not have to be on the campus network (e.g., via VPN) to access O'Reilly Online Learning.
To access content, click the "Institution not listed?" link below the dropdown and enter your UA email. You will then create an account and use that account from now on.
For more information: Library LibGuide
Exercises
Exercise 2: Course Content Crossword
Upload a PDF of the completed crossword to Brightspace in Assessments/Assignments, Exercise 2: Course Content Crossword
Make sure to follow the print directions given in class to create a PDF of the crossword.
Also, try to include the headers and footers in the pdf.
All exercises are due by 4:30 pm on Wed Jan 11
Greetings and welcome to CPSC 421 Object-Oriented Programming (OOP) for Spring 2023.
See you on Tuesday, Jan 10 at 2:00 pm - 3:15 pm in Arts & Sciences (CAS) room 134