0% found this document useful (0 votes)
2 views

Lesson0Lab

The document outlines a lab for COMI 2510 Advanced Java focusing on object-oriented design principles. It includes tasks for identifying principles in design decisions and applying principles to a hypothetical map application. The lab emphasizes understanding and applying concepts like encapsulation, abstraction, and extensibility through practical examples.

Uploaded by

bobbysmith13212
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lesson0Lab

The document outlines a lab for COMI 2510 Advanced Java focusing on object-oriented design principles. It includes tasks for identifying principles in design decisions and applying principles to a hypothetical map application. The lab emphasizes understanding and applying concepts like encapsulation, abstraction, and extensibility through practical examples.

Uploaded by

bobbysmith13212
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

COMI 2510 Advanced Java

Lesson 0: Overview of object-oriented design


Lab

Be sure to complete the reading and watch the video in the class website before beginning this lab.

1. Below are design decisions made when solving the example in the video (the art-generating
software). Identify, for each example, which principle it either exemplifies or violates. (In the
principle column, put either “exemplifies principle-name” or “violates principle-name,” e.g.
“exemplifies abstraction” or “violates interface.”)

The principles are: divide-and-conquer, encapsulation, interface, information-hiding, generality,


extensibility, abstraction.

Example Principle

The public methods of each class are not specified


before implementation begins.

The program is broken into multiple classes with


clearly-defined responsibilities, such as a Gallery
class, a UserAccount class, an ArtEditor class, and
an ArtGenerator class, among others.

The UserAccount class contains information about


the user that the class doesn’t need to fulfill its
responsibilities, such as eye color and what the
user had for lunch.

Classes allow public access to implementation


details, such as the raw data of an image in the Art
class.

Data and operations related to an object’s


responsibilities are part of the object, such as the
Gallery object including algorithms to access art
sequentially.

The program is composed of one large class with


many responsibilities, possibly implemented in one
long method.

Classes allow public access to data in well-defined


ways such that the object methods are the only
way that object data is accessed.

Copyright © 2024 Margaret Burke. All rights reserved. 1


Class implementations make use of libraries for
some of their functionality and do not “reinvent
the wheel.”

Classes are designed so there is a public interface


that can be implemented in multiple ways without
changing how the object interacts with the rest of
the system. For example, the UserAccount class
has an updateCredits method that can be
overridden in a SuperUser subclass.

The public methods of each class are specified


before implementation begins.

Programmers design several similar classes for


different applications instead of designing one
class that could be reused.

Classes are designed so that each modification will


require a new method or for information to be
stored external to the class, such as a UserAccount
class that has an updateCredits method that takes
the number of credits needed as a parameter.

Classes do not have all of the data and operations


they need to fulfill their responsibilities; rather,
they rely on outside objects to “drive” them.

Classes that represent real-world entities have


only the information about those entities that they
need to fulfill their responsibilities an do not
contain superfluous information or methods.

2. Now it’s your turn! For the problem description below, come up with a design or implementation
answer for each design principle. As you are likely new to object-oriented design, your answers
might not be correct. Do your best. There are no wrong answers for this part of the assignment, as
long as you give a thoughtful answer. In the future, when you’ve learned more, revisit this problem
and see how your ideas have changed.

Consider an application that has the following functionalities:

1. It can display a map of any location on the earth. The user can zoom in or out of this map.
The map includes roadways.

2. It can allow the user to create a route on the map by clicking. The software will join each
click over the roadways and calculate the distance of the route so far. The user can undo
clicks or clear the entire route. The user can save the route under a name.

Copyright © 2024 Margaret Burke. All rights reserved. 2


3. It can manage a user account including a set of named routes which it can display on the
map and which the user can edit.

a) Divide-and-conquer principle. Propose a set of classes and responsibilities for this software
description. You can list the classes here as name / responsibility. Briefly describe how you
arrived at this set of classes.

b) Encapsulation principle. Take one of your classes and describe what data and operations it will
need to do its job. Reference how an object of the class will need to interact with other objects
to fulfill its responsibilities.

c) Interface principle. Assume a use case called “user saves a route.” In this use case, the user
clicks the save button, the user is allowed to give the route a name, and the route is saved to the
user’s account. Select which classes in your design will collaborate to fulfill this functionality and
describe how they will do it. What messages will they send each other?

d) Information hiding principle. Select a class in your system and describe the data that it will have
as part of its implementation. How will it allow access to that information, and how do those
decisions ensure that the data will be uncorruptible and that the rest of the system is protected
from implementation changes? If it’s easier, select a specific implementation for the data and
give examples.

e) Generality principle. Give examples of Java libraries you might use to solve this problem and
then answer the following question: Your company president wants to partner with a
healthcare group to create an app that will allow users to “check in” at parks, reservations, and
other outdoor locations and link the check-in with the type of activity they’re engaged in for
wellness points. The app will need to use phone data to track the users’ movement and award
points based on steps. Discuss any parts of your system that could be designed so that they
could be general enough to also be used in this system, or discuss why the systems are too
different for any parts to be reused.

f) Extensibility principle. You learn that the system is going to be extended in the future to allow
the user to create treadmill runs in virtual realities. What parts of your system can be designed
to be extended for this new application? If none, explain why.

g) Abstraction principle. Select one of the classes in your design that has a real-world counterpart
and describe details that are part of the real-world object your class is representing that are not
represented in your class.

Grading Criteria

Lab
Criteria 1: Question 1 – All fourteen principles were correctly identified. (14 points)

Criteria 2: Question 2 - The only wrong answer here is no answer. For each part of the problem, a
solution and rationale is proposed. Please provide comments in your feedback, but give your peer 2
Copyright © 2024 Margaret Burke. All rights reserved. 3
points for each part of the problem they answered, even if you believe their answer is not very correct.
(14 points)

Feedback
If you do not complete two peer evaluations, you will lose 5 points from your score. You can earn up to
5 additional points by writing helpful peer evaluations. If your feedback goes above and beyond, you
could earn as many as 10 additional points. Here are examples of feedback worth different amounts.
This feedback is based on actual lab feedback from past semesters.

To earn at least 5 points, you must provide scores and feedback for all three criteria.

Here is some example feedback at the different score levels:

0 points:
No comments, just a grade for each criterion.

1 point:
3 point comments on one criterion but not others, or sparse comments, such as “Nice job,” or “Runs
well,” (for a programming lab) etc.

3 points:
Comments that do not address all criteria in each category being evaluated but show that the
submission was carefully read (or, for a programming lab, that the program was read and executed) and
offer correct observations about the submission. For example:

Criterion 1: Great job! You got them all right except you mixed up encapsulation and abstraction.

Criterion 2: Well done! You had an answer and explanation for each principle. I like your
RouteCalculator class – I didn’t think of that.

5 points:
Comments that address each criterion in each category and describe how many points were awarded, or
comments that maybe don’t address all criteria explicitly, but are detailed and make suggestions for
improvement referencing principles that we’ve learned in class, e.g., for criterion 1:

You correctly identified all of the principles except for mixing up encapsulation and abstraction.
Remember that abstraction is like choosing what parts of a system we need to represent to
fulfill the responsibilities of a system, sort of like a road map shows only the roads including exits
and distances, because it’s for driving, and doesn’t show things like cell phone service or coffee
shop locations. Encapsulation is basically making sure an object has everything it needs to fulfill
its responsibilities and doesn’t have to go poking around in other parts of the system to do its
job.

6-10 points:
Comments that are detailed about every (or nearly every) criterion that is being evaluated and that
make suggestions for improvement referencing principles that we’ve learned in class, or that evaluate
using language that references principles we’ve learned in class. Comments that make it clear the
Copyright © 2024 Margaret Burke. All rights reserved. 4
reviewer looked carefully at the submission and took time to understand how it worked and is making
an effort to be helpful. For example, for criterion 2:

Your answers to all of the principles were really thoughtful. You decomposed the problem
further than just the obvious three classes, with support classes showing that you’d really
thought the problem through. Your encapsulation answer was a very thorough breakdown of
one of your classes, including data and operations. Your interface principle answer included
detail about how your three objects would interact such that I feel like I could implement the
system right now! Your information hiding principle answer clearly explained how the data was
protected from outside objects interfering with it and how this also protected outside objects
from implementation changes to the internal representation. Your generality answer showed
that you had looked up available Java libraries for representing map data. I think you were right
that the two systems are too different for parts to be reused – I really wanted to force
something to work for both systems! I like how you addressed each part of your system. Your
extensibility ideas were coherent – I thought that was a very difficult question – well done! You
did great answering the abstraction question, even though you had trouble identifying
abstraction in the matching. Great work, my friend!

Copyright © 2024 Margaret Burke. All rights reserved. 5

You might also like