TR 9:15 - 10:30 am (CAS) 136
Week 13 Class 24 Thu Apr 17 Posted: Apr 17
Announcements
For all projects, you need to follow all the coding and design practices. This means that for added classes, you must have a header comment, include guards, the works.
Exercise 79: C++ Inheritance Specifiers Crossword
This is what I tried to do in class on Tuesday, but the network issues prevented it.
Do this as extra credit. I will drop another lowest-score exercise.
Agenda
Notes: Design Pattern Composite
Compose objects into tree structures to represent part-whole hierarchies
Composite lets clients treat individual objects and compositions of objects uniformly
Convert the interface of a class into another interface clients expect
Adapter lets classes work together with incompatible interfaces
Unless otherwise noted, exercises are due by 4:30 pm on Monday, Apr 21
Project 4 continues the work on srcFacts. It is due at 11:59:59 pm Tuesday, Apr 22, and involves the following stages which must be performed in order:
Tag v4a Correct the issues in XMLParser
that affect srcfacts, xmlstats, identity, class diagram, and sequence diagram.
Tag template Redesign XMLParser
to use the Template Design Pattern. In this design pattern, extension points are virtual methods. This means new classes that inherit from XMLParser
:
srcFactsParser
in the new files srcFactsParser.hpp and srcFactsParser.cppIdentityParser
in the new files IdentityParser.hpp and IdentityParser.cppXMLStatsParser
in the new files XMLStatsParser.hpp and XMLStatsParser.cppThe pull request template
adds these new files to your repository and updates the CMakeLists.txt so that they are part of the build. Update your class and sequence diagrams to show this new design.
As before, our XML parser needs to provide access to all parts of XMLvia the following extension points from [XML notes slide 33]
XML Extension Point | Attributes |
---|---|
Start Document | |
XML Declaration | version, encoding, standalone |
Element Start Tag | qName, prefix, localName |
Element End Tag | qName, prefix, localName |
Characters | characters |
Attribute | qName, prefix, localName, value |
XML Namespace | prefix, uri |
XML Comment | value |
CDATA | characters |
Processing Instruction | target, data |
End Document |
Tag handler Extract a handler from XMLParser
called XMLParserHandler
, a new class that only handles the user-defined processing (what we previously had as callbacks). Put the entire XMLParserHandler
class in the file XMLParserHandler.hpp.
Then change srcFactsParser
, IdentityParser
, and XMLStatsParser
to inherit from XMLParserHandler
instead of XMLParser
, and rename them by replacing "Parser" in the name with "Handler". You can rename the srcFacts
files using git:
Note you will have to commit and push these changes.
You will also have to rename these files in your CMakeLists.txt. Update your class and sequence diagrams to show this new design.
Also make sure to update the class names and header comments.
Warning Once you tag template and move on to handler, you will not be able to change anything for template. So carefully check that you are done with the template part before you tag it and move on to handler
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, understand that make
uses the default target all
and means make all
. So instead of building all executable targets, build them separately as needed, e.g., make srcfacts
, make xmlstats
, or make identity
.
Keep in mind:
TA: Ms. Afia Asante aa998@uakron.edu
TA: Mr. Isaiah Ekundayo ioe2@uakron.edu