The document discusses the visitor design pattern. It begins by providing examples of how a farm manager previously tracked information about different animal types (cows, pigs, chickens) by adding virtual functions to the animal classes. This led to issues with flexibility and maintainability.
The document then introduces the visitor pattern as a way to address these issues. It involves creating a visitor interface with accept and visit methods, and concrete visitor classes that perform specific operations. When the farm accepts a visitor, it calls accept on each animal, which in turn calls the appropriate visit method on the visitor. This allows new operations to be added without changing the animal classes.
The document provides examples of counting male animals and calculating milk production using visitor classes
Presentation given by Neil Rubens at the Centre for Database and Information Systems (Prof. Ricci), Free University of Bozen-Bolzano
For more information see http://activeintelligence.org/research/al-rs/
Practical JavaScript Programming - Session 1/8Wilson Su
JavaScript is one of the most popular skills in today’s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
“Practical JavaScript Programming” does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You’ll learn about topics like Data Types, Functions, Events, AJAX and more.
Presentation given by Neil Rubens at the Centre for Database and Information Systems (Prof. Ricci), Free University of Bozen-Bolzano
For more information see http://activeintelligence.org/research/al-rs/
Practical JavaScript Programming - Session 1/8Wilson Su
JavaScript is one of the most popular skills in today’s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it.
“Practical JavaScript Programming” does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You’ll learn about topics like Data Types, Functions, Events, AJAX and more.
This year PVS-Studio static analyzer turned 10. Although, we should clarify the point that 10 years ago it was called Viva64. Another interesting point: it's been 5 years since the previous check of the Notepad++ project. During this period of time the analyzer was significantly improved: about 190 new diagnostics were added and the old ones got refined. However, we cannot expect to see a large number of errors in Notepad++. It is quite a small project that has only 123 files with the source code. Nevertheless, there are still errors that are worth fixing.
A tutorial on how the process of writing an application using a browser’s WebAuthn API, plus how to install a server, how to generate authentication challenges & responses, and how to integrate with related IAM infrastructure.
Code: https://github.com/fido-alliance/webauthn-demo
Live slides: http://slides.com/herrjemand/jan-2018-fido-seminar-webauthn-tutorial#/
EclipseCon-Europe 2013: Optimizing performance - how to make your Eclipse-bas...martinlippert
Over the past year we worked a lot on the performance of the Spring-related tooling for Eclipse. In this session we present our lessons learned. We show how we identified Eclipse-specific performance bottlenecks, how we solved and/or worked around them, and demo the tools we used for this.
We will walk through a number of real cases that we solved and discuss how we solved them. For example, we will discuss how we improved build times of Spring projects by a factor of 10, and reduced memory consumption at the same time. All of the presented cases are not specific to Spring tooling, so that the solutions are directly applicable to other Eclipse plugins. The areas that we will cover include using the JDT API, processing types and type hierarchies in source and class files, accessing resources and file content, scaling some algorithms, and more.
Android UI Development: Tips, Tricks, and TechniquesEdgar Gonzalez
Presentation of @romainguy and @chethaase at Devoxx and the San Francisco Android user group.
Shows what tools they use to track down performance issues.
Learn hot techniques for developing more effective user interfaces in your Android applications from Android UI Toolkit engineers Romain Guy and Chet Haase.
Romain and Chet will dive into some code examples, demo some handy tools, and show you how to optimize your UI for performance while making it look great.
Didn't make it to Devoxx 2K10? Well, find out what you might have missed, as this is the same presentation Romain and Chet delivered at Devoxx.
A few topics covered in this talk include:
- Trash Talk: avoiding garbage creation when necessary and possible
- Tools: Allocation Tracking, DDMS, Heap Analysis Tool (hat), etc.
- A few tips on avoiding memory leaks
- ViewStub, ListView and compound drawables
- Graphics optimization techniques
A mental model is an explanation of how something works. It is a concept, a framework or a vision of the world that you carry in your mind to help you interpret what surrounds you and understand the relationship between things.
This talk explores how software projects are very complex systems that we should approach from different mental models, applying multidisciplinary thinking.
Pamplona Software Crafters 2018 #scpna
http://pamplonaswcraft.com/
PVS-Studio for Linux Went on a Tour Around DisneyPVS-Studio
Recently we released a Linux version of PVS-Studio analyzer, which we had used before to check a number of open-source projects such as Chromium, GCC, LLVM (Clang), and others. Now this list includes several projects developed by Walt Disney Animation Studios for the community of virtual-reality developers. Let's see what bugs and defects the analyzer found in these projects.
This year PVS-Studio static analyzer turned 10. Although, we should clarify the point that 10 years ago it was called Viva64. Another interesting point: it's been 5 years since the previous check of the Notepad++ project. During this period of time the analyzer was significantly improved: about 190 new diagnostics were added and the old ones got refined. However, we cannot expect to see a large number of errors in Notepad++. It is quite a small project that has only 123 files with the source code. Nevertheless, there are still errors that are worth fixing.
A tutorial on how the process of writing an application using a browser’s WebAuthn API, plus how to install a server, how to generate authentication challenges & responses, and how to integrate with related IAM infrastructure.
Code: https://github.com/fido-alliance/webauthn-demo
Live slides: http://slides.com/herrjemand/jan-2018-fido-seminar-webauthn-tutorial#/
EclipseCon-Europe 2013: Optimizing performance - how to make your Eclipse-bas...martinlippert
Over the past year we worked a lot on the performance of the Spring-related tooling for Eclipse. In this session we present our lessons learned. We show how we identified Eclipse-specific performance bottlenecks, how we solved and/or worked around them, and demo the tools we used for this.
We will walk through a number of real cases that we solved and discuss how we solved them. For example, we will discuss how we improved build times of Spring projects by a factor of 10, and reduced memory consumption at the same time. All of the presented cases are not specific to Spring tooling, so that the solutions are directly applicable to other Eclipse plugins. The areas that we will cover include using the JDT API, processing types and type hierarchies in source and class files, accessing resources and file content, scaling some algorithms, and more.
Android UI Development: Tips, Tricks, and TechniquesEdgar Gonzalez
Presentation of @romainguy and @chethaase at Devoxx and the San Francisco Android user group.
Shows what tools they use to track down performance issues.
Learn hot techniques for developing more effective user interfaces in your Android applications from Android UI Toolkit engineers Romain Guy and Chet Haase.
Romain and Chet will dive into some code examples, demo some handy tools, and show you how to optimize your UI for performance while making it look great.
Didn't make it to Devoxx 2K10? Well, find out what you might have missed, as this is the same presentation Romain and Chet delivered at Devoxx.
A few topics covered in this talk include:
- Trash Talk: avoiding garbage creation when necessary and possible
- Tools: Allocation Tracking, DDMS, Heap Analysis Tool (hat), etc.
- A few tips on avoiding memory leaks
- ViewStub, ListView and compound drawables
- Graphics optimization techniques
A mental model is an explanation of how something works. It is a concept, a framework or a vision of the world that you carry in your mind to help you interpret what surrounds you and understand the relationship between things.
This talk explores how software projects are very complex systems that we should approach from different mental models, applying multidisciplinary thinking.
Pamplona Software Crafters 2018 #scpna
http://pamplonaswcraft.com/
PVS-Studio for Linux Went on a Tour Around DisneyPVS-Studio
Recently we released a Linux version of PVS-Studio analyzer, which we had used before to check a number of open-source projects such as Chromium, GCC, LLVM (Clang), and others. Now this list includes several projects developed by Walt Disney Animation Studios for the community of virtual-reality developers. Let's see what bugs and defects the analyzer found in these projects.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
2. 2
Patterns and the Visitor Pattern
“Somebody has already
solved your problem”
Page 331
3. 3
What makes a great chess player?
They are not memorizing the
board and playing back a
game, they are recognizing
arrangements of pieces that
call for a specific strategy.
4. 4
What is a Design Pattern?
It is: A pattern for how
objects and methods can be
laid out to solve a problem.
Not: A class library
Not: Standard superclasses
5. 5
How they happened
Ever feel déjà vu when programming?
Many people do. So, they started looking
at good programs and seeing what
patterns or structures were occurring a lot.
They started to write them down and give
them a name.
Now you can avoid a big description and
just say “I used the observer pattern”.
6. 6
Do you know what these are?
➢Inheritance
➢Polymorphism
➢Encapsulation
➢Abstraction
7. 7
The Big 4 of Object-oriented Programming
➢Inheritance
The ability to form new classes that extend the capabilities
of existing classes
➢Polymorphism
The ability of one type to appear to be and be used as
another type
➢Encapsulation
Separating an interface from an implementation, hiding
details that may change
➢Abstraction
Reducing or factoring out details so we can focus on
concepts – objects are abstractions
8. 8
But, More
➢Flexibility/Extendibility
It should be easy to add capability.
We should not have to always modify our core classes to
add a capability.
➢Maintainability
We like to avoid spreading code all over the project to do a
specific task.
9. 9
Remember This? Add a menu option called "Count the
male animals". A bull is a male cow. A
boar is a male pig. Assume all chickens are
females
How did you implement this?
10. 10
How you likely implemented this
class CAnimal
{
public:
CAnimal();
virtual ~CAnimal();
virtual void DisplayAnimal() {}
virtual bool IsMale() const {return false;}
};
bool CPig::IsMale() const
{
return mType == Boar;
}
bool CCow::IsMale() const
{
return mType == Bull;
}
int CFarm::NumberOfMaleAnimals() const
{
int cnt = 0;
for(list<CAnimal *>::const_iterator i=mInventory.begin();
i != mInventory.end(); i++)
{
CAnimal *animal = *i;
if(animal->IsMale())
cnt++;
}
} What’s bad about this approach?
4
11. 11
What if I want to...
➢Determine how many chickens we have?
➢Total the milk production per day?
➢Determine how many animals have not been vaccinated?
➢Lots of other questions I might decide I want to ask later on.
12. 12
How we have been doing it
virtual bool IsChicken() const {return false;}
virtual bool IsVaccinated() const = 0;
virtual double GetMilkProduction() const {return 0;}
virtual bool GetSomeOtherStupidThing() const=0;
virtual bool GetSomeGettingTiredOfThisNonsense() const=0;
virtual bool GettingReallyAnnoying() const=0;
Every time I want to ask a new question, I have to modify
all of the classes that store my data.
Bad for flexibly/extendibility
Code to answer a question in
many, many places.
13. 13
The basic idea
Objects are things. Think of them like they are real
people or real cows and pigs. We want to ask our
farmer how many male animals he has.
15. 15
The problem is... We had to create a way for our animals to tell
the farmer if they are male through the box.
I’m
Male I’m
Male Me Too
I’m not
sure
16. 16
The problem is...
If we need more answers, we may end up having
to add more things that our box can tell us about
the animal.
I’m
Male I’m
Male Me Too
I’m not
sure
I’m
Brown
3 gallons
per day
VaccinatedPregnant
17. 17
What do we know?
We can create virtual functions that are passed by the animal
box to the actual cow or pig.
We can create one for each question we need to ask.
But, can we create a more general-purpose message to pass
to our animals?
25. 25
The Process
Our Visitor now knows this is a Cow. She can ask
Cow questions, now.
I’m a Bull,
don’t you see
the horns?
What
type are
you?
26. 26
Then we can deal
with the information
Bulls are boys,
so add one to
my count
27. 27
And now the code
class CCow;
class CPig;
class CChicken;
class CAnimalVisitor
{
public:
CAnimalVisitor();
virtual ~CAnimalVisitor();
virtual void VisitCow(CCow *cow) {}
virtual void VisitPig(CPig *pig) {}
virtual void VisitChicken(CChicken *chicken) {}
};
Note the forward references!
28. 28
CCountMalesVisitor
#include "CAnimalVisitor.h"
class CCountMalesVisitor: public CAnimalVisitor
{
public:
CCountMalesVisitor() {mCnt = 0;}
virtual ~CCountMalesVisitor();
virtual void VisitCow(CCow *cow);
virtual void VisitPig(CPig *pig);
int GetCount() const {return mCnt;}
private:
int mCnt;
};
void CCountMalesVisitor::VisitCow(CCow *cow)
{
if(cow->GetType() == CCow::Bull)
mCnt++;
}
void CCountMalesVisitor::VisitPig(CPig *pig)
{
if(pig->GetType() == CPig::Boar)
mCnt++;
}
Our visitor is holding a pad and is marking slash
marks for each male cow.
29. 29
How this works
void CCountMalesVisitor::VisitCow(CCow *cow)
{
if(cow->GetType() == CCow::Bull)
mCnt++;
}
void CCountMalesVisitor::VisitPig(CPig *pig)
{
if(pig->GetType() == CPig::Boar)
mCnt++;
}
As each animal calls a visit function on the visitor, it checks to
see if male and, if so, increments a counter.
31. 31
CCow::Accept
#include "CAnimalVisitor.h"
class CCow : public CAnimal
{
public:
CCow();
virtual ~CCow();
// The types of cow we can have on our farm
enum Type {Bull, BeefCow, MilkCow};
virtual void Accept(CAnimalVisitor *visitor) {visitor->VisitCow(this);}
//...
};
34. 34
Applying This
void CountMaleAnimals(CFarm &farm)
{
// Create the visitor object
CCountMalesVisitors visitor;
// Send it to the farm
farm.Accept(&visitor);
// Get the result
cout << "Number of male animals is " << visitor.GetCount() << endl;
}
35. 35
This is called the Visitor Pattern
➢ We create an object of a type derived
from our visitor class
▪This is called a concrete visitor
➢ We call Accept on the class that has the collection (Farm)
➢ It calls Accept on every object in the collection
➢ Each Accept then calls a Visit function on the visitor
➢ The visitor can now do its work, knowing the type of the object
36. 36
A Concrete Example
1. We create a visitor object.
2. We call farm.Accept(visitor).
3. farm.Accept(visitor) calls Accept on a cow
4. The cow calls visitor.VisitCow(this), passing a pointer to itself.
5. The visitor calls cow->GetType() to determine the type.
6. If the type is a Bull, the count is incremented.
7. farm.Accept(visitor) calls Accept on a chicken
8. The chicken calls visitor.VisitChicken(this), passing a pointer to itself.
9. The visitor did not override this function; the base class version does
nothing.
10.Repeat process for next cow
11.Repeat process for next pig
37. 37
Suppose I want to know total milk production?
class CMilkProductionVisitor: public CAnimalVisitor
{
public:
CMilkProductionVisitor() {mTotalProduction = 0;}
virtual ~CMilkProductionVisitor();
virtual void VisitCow(CCow *cow);
private:
double mTotalProduction;
};
void CMilkProductionVisitor::VisitCow(CCow *cow)
{
mTotalProduction += cow->GetMilkProduction();
}
Could we have done the drawing with a visitor?
6
38. 38
Process to create support for the visitor pattern
1. Create a visitor class with Visit functions for every type of object we may
visit.
2. In a superclass for every type of object we may visit, add an Accept
function.
3. In every derived class, provide an Accept function that calls the
appropriate Visit function.
4. In any class with a collection, create a loop over the collection, calling
accept on each object.
39. 39
Advantages/Disadvantages of Visitors
Advantages
You can add new capability without changing the way the data is stored.
All of the functions for an operation end up in one place.
Disadvantages
Seems like a lot of code to support.
You’re always calling Accept – meaning is in the object, not the function call.
Have to add new Visit function when you add a new type.
Visitor pattern has its detractors, BTW
42. 42
Use the visitor pattern when...
➢An object structure contains many classes of objects with different
interfaces, and you want to perform operations on these objects
that depend on their concrete classes.
➢Many distinct and unrelated operations need to be performed on
objects in an object structure, and you want to avoid "polluting"
their classes with these operations. Visitor lets you keep related
operations together by defining them in one class.
➢The classes defining the object structure rarely change, but you
often want to define new operations over the structure.
43. 43
Variations on the Theme
class CAnimalVisitor
{
public:
CAnimalVisitor();
virtual ~CAnimalVisitor();
virtual void VisitCow(CCow *cow) = 0;
virtual void VisitPig(CPig *pig) = 0;
virtual void VisitChicken(CChicken *chicken) = 0;
};
Pure Virtual Functions
44. 44
Variations on the Theme
class CAnimalVisitor
{
public:
CAnimalVisitor();
virtual ~CAnimalVisitor();
virtual void VisitDefault(CAnimal *animal) {}
virtual void VisitCow(CCow *cow);
virtual void VisitPig(CPig *pig);
virtual void VisitChicken(CChicken *chicken);
};
void CAnimalVisitor::VisitCow(CCow *cow)
{
VisitDefault(cow);
}
Providing a default visit function
48. 48
Basic CRC ideas
➢Cards can be classes or objects of the class.
• Hold an object/set a class is common
➢Feel free to make extra cards for extra objects.
➢Feel free to discard cards and replace or start over.
➢Busy cards near center of table.
• Don’t place just in an empty spot.
➢Placement helps describe collaborations
• Overlap means close control
• Adjacent implies communications
• Groupings are important
➢Run simulations often
49. 49
Design Example
You are asked to design a personal finance program. A person
can have multiple bank accounts. The common transactions
are deposits, withdrawals, and transfers. Every transaction
can be (optionally) assigned to a budget category such as
shopping or tax refund. Some transactions are split between
more than one budget category ($52 in groceries and $22 in
gas for example). Design a set of classes for this program.
See
Bank
Account
Customer
Bank name and information
Class
Responsibilities
Collaborations
50. 50
Your company manages magazine subscriptions. You have
customers who have a name, address, and phone number.
They subscribe to magazines, each with a name. To subscribe,
you make a payment on a certain date and for a certain
amount. Each subscription needs to keep track of the
payments and when the subscription expires.
51. 51
A Scenario for our Personal Finance SystemOne transaction to illustrate the case of a transfer on 2-12-10 from checking
account number 123485 to savings account number 123402 of $1000 split
between these budget categories: $750 to Rainy Day and $250 to Cancun.
The bank name for both accounts is BankMSU.
Scenario – A description on some use of our system we use as
an example.
52. 52
A CRC Example
Design a way to represent the dining philosophers problem. We have
philosophers around a circular table. Each philosopher has access to 2 forks,
one on either side of them. Each fork is shared by two philosophers. A fork
can be either on the table or in use by one philosopher. A philosopher must
have 2 forks to eat. Your system should be able to represent all possible
configurations and answer the question “can I eat?” for every philosopher.
53. 53
You are creating an email program. An email message has a date, time,
from address, to addresses, CC addresses, a subject, the text for the email
message, and a list of attachments, each of which has a size, a name, and
raw data for the attachment (an array of bytes). Addresses have an email
address and an optional name (if the system knows it). Email goes into
folders, which are in a hierarchical structure under an email account.
54. 54
A library has books. Each book is either on the shelf in the library, checked
out by an individual, or missing. Customers have a name and address. We
maintain the history of every book including when it was checked out and
when it was returned and who the customer was. We maintain the history
for every customer as well.
55. 55
You are asked to design a system to control an oil drilling platform and
associated equipment. The platform has over 100 motorized valves. Each
valve has a name, description, location, a sensor that tells how open it is (0
to 100%) and a motor to close or open the valve. There is also a specified
opening amount your program will tell the valve to set to. For example, if
valve BX37 is closed and the specified opening amount of set to 40%, the
motor will turn on and open until the sensor says the valve is 40% open.
The system also has over 200 fire detectors, each with a name, description,
location, and a status (inactive, active, fire). The location of equipment on
the platform consists of a level (what floor), section, and subsection (all
strings, for example level B3, section X24, subsection M). Your system has
named configurations. A configuration is a set of positions for all of the
valves (it is loaded from a file).
56. 56
I’m working with an piece of equipment called a Biopac. It has
channels that can read things like skin resistance and muscle
activations. For each channel it reads 1000 samples (double)
per second. I want a program where I can have input channels
read from the Biopac, filters that can clean up data, and
windows on the screen to display the data. Note that data may
be displayed in more than one way. Design the classes for this
software for me.