DOC PREVIEW
UCSC CMPS 20 - Chain of Responsibility and Singleton Patterns

This preview shows page 1-2-21-22 out of 22 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 22 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Exam Questions Chain of Responsibility & Singleton PatternsAnnouncementsMidterm ExamPotential Exam TopicsPotential Exam QuestionsPotential Exam QuestionsPotential Exam QuestionsPotential Exam QuestionsProblem: Magic system with variable effectsAn approach: Chain of Spell HandlersChain of Spell HandlersChain of Spell HandlersChain of Spell HandlersChain of Spell HandlersChain of Responsibility PatternImplementation detailsChain of Responsibility: Pros and ConsProblem: Representing Game StateApproach: Singleton PatternSingleton ImplementationSingleton AdvantagesHomeworkExam Questions Chain of Responsibility & Singleton PatternsGame Design ExperienceProfessor Jim WhiteheadFebruary 4, 2009Creative Commons Attribution 3.0 (Except for copyrighted images) creativecommons.org/licenses/by/3.0Announcements• Homework #1, Revisited (Improved Design)► Due next Monday, February 9► Make sure you ask in section this week whether your design is procedural, object-oriented, or otherMidterm Exam• The midterm exam is this Friday► Will cover material up to and including Monday’s class (does not include today’s lecture)• Will give list of potential questions on following slides• Mostly short answer questionsPotential Exam Topics• As Univ. of California students, you are expected to be able to assess complex material and make judgments concerning its relative importance. • That said, it can be helpful to have some input from the Professor to help focus studying activity. • The following are questions/topics that are likely, but not guaranteed to appear on the exam. • Anything covered in class or in the assigned readings may appear, even if not explicitly mentioned today.Potential Exam Questions• C# language► Basic syntax► Foreach► Properties► Delegates► Lists► Arrays► Visibility rules► Enumerations► Interfaces and Abstract classes• Know how to use these, and difference between these• Abstract methods► Be prepared to read and understand C# code examples, and to write short segments of C# codePotential Exam Questions• Object-oriented design► Know the difference between procedural and object- oriented design• Know the indicators of a pure procedural design► Know the nouns/verbs rule of thumb for determining classes and methods from a problem description• Refactoring► What is a bad code smell? How is it related to refactoring?► Know the bad code smells covered in class• Duplicate code, long method, long class, switch, feature envy• Be able to define these, and identify these in a code sample• Know how to refactor these to remove themPotential Exam Questions• Be able to define classification► Know how classification relates to the is-a relationship► Know how abstraction relates to classification• UML structure diagrams► Know how to represent a class in UML► Know how to represent inheritance (is-a) and aggregation (contains) relationships among classes► Given some C# code, be able to draw a UML diagram for itPotential Exam Questions• XNA► What is a spritebatch?► What is a clock tick? How long is the default clock tick in XNA?► What is the difference between Update() and Draw() methods?► Be able to understand code that receives input from an Xbox controller• Design patterns► Know UML diagrams for each of the design patterns covered in class• Strategy, Observer, Decorator• Need to memorize these, and be able to reproduce them• Need to understand how they work• Given an example of one these patterns, be able to identify the pattern► Know what these mean:• Favor composition over inheritance• Write to an interface, not an implementationProblem: Magic system with variable effects• Consider a game that has castles, fighters, wizards, and magic cars► Fighters can be inside castles► Wizards have spells:• Some only affect the castle, weakening its walls (lightening bolt)• Other, more powerful spells, weaken the walls and do damage to the people inside (fireball explosion)• If the people inside the castle are inside a magic car, the car absorbs some, but not all, of the damage• Need some way to have the applied damage vary depending on who is inside what ► E.g., damage depends on containmentAn approach: Chain of Spell Handlers• Create objects that► Represent a cast spell► Represent castles, fighters, cars• Create a chain of object references that represent containment► Castle –references-> Car –references-> Fighter• Pass each spell object along the containment chain► Castle handles spell first, absorbs some damage, reduces power of spell, and passes it along to Car► Car handles spell, reduces power of spell (no damage – it’s magic), and passes along to Fighter► Fighter handles spell last, applying damageChain of Spell Handlers• Chain of object references looks like Decorator chain► Containment of castle(cars(fighters))• Separate object represents request (spell)fighterfightercarcarcastlefireballpower = 100HP = 500HP = 100HP = 50Fireball spell handed to castle for processing firstChain of Spell Handlers• Chain of object references looks like Decorator chain► Containment of castle(cars(fighters))• Separate object represents request (spell)fighterfightercarcarcastlefireballpower = 25HP = 425HP = 100HP = 50Fireball spell handed to castle for processing firstCastle reduces its HP, and reduces power of fireballChain of Spell Handlers• Chain of object references looks like Decorator chain► Containment of castle(cars(fighters))• Separate object represents request (spell)fighterfightercarcarcastlefireballpower = 10HP = 425HP = 100HP = 50Castle hands Fireball spell off to car (next in chain), which reduces spell powerChain of Spell Handlers• Chain of object references looks like Decorator chain► Containment of castle(cars(fighters))• Separate object represents request (spell)fighterfightercarcarcastlefireballpower = 0HP = 425HP = 100HP = 40Car hands Fireball spell off to fighter (next in chain), which applies remaining spell power as damage. Fighter is end of chain, so no further handoffs.Chain of Responsibility Pattern• IHandler interface► Successor: reference to next object in the chain► Request(): method that receives request object (e.g. spell), and takes action on it• Handler1, Handler2► Specific handler implementations (e.g., castle, car, fighter)► Each handles requests in a different wayDemonstration of Chain of Responsibility in


View Full Document

UCSC CMPS 20 - Chain of Responsibility and Singleton Patterns

Documents in this Course
Load more
Download Chain of Responsibility and Singleton Patterns
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chain of Responsibility and Singleton Patterns and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chain of Responsibility and Singleton Patterns 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?