0% found this document useful (0 votes)
4 views6 pages

Lab 0

The document outlines a lab assignment for COMI 2510 Advanced Java, focusing on object-oriented design principles. It includes a series of design decisions related to an art-generating software example, where students must identify principles exemplified or violated. Additionally, students are tasked with proposing design solutions for a mapping application while addressing principles such as encapsulation, interface, and extensibility.

Uploaded by

bobbysmith13212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Lab 0

The document outlines a lab assignment for COMI 2510 Advanced Java, focusing on object-oriented design principles. It includes a series of design decisions related to an art-generating software example, where students must identify principles exemplified or violated. Additionally, students are tasked with proposing design solutions for a mapping application while addressing principles such as encapsulation, interface, and extensibility.

Uploaded by

bobbysmith13212
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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 Violates encapsulation
before implementation begins.

The program is broken into multiple classes with Exemplifies divide and conquer
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 Violates generality


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 Violates info hiding


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

Data and operations related to an object’s Exemplifies encapsulation


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 Violates divide and conquer
many responsibilities, possibly implemented in one
long method.

Classes allow public access to data in well-defined Exemplifies encapsilation


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 Exemplifies generality
some of their functionality and do not “reinvent
the wheel.”

Classes are designed so there is a public interface Exemplifies 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 Exemplifies interface


before implementation begins.

Programmers design several similar classes for Violates generality


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

Classes are designed so that each modification will Exemplifies abstraction


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 Exemplifies info hiding
they need to fulfill their responsibilities; rather,
they rely on outside objects to “drive” them.

Classes that represent real-world entities have Violates abstraction


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.

Class GPS: This class will be able to access the map and register clicks,. This will be able to solve
requirements 2

Class Map: This class will be able to store maps, as well as display them. This class takes care of
requirement 1.

Class Route: This class will be able to set/save/view routes. This class takes care of requirement 3

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.

GPS class: This will need three types of data. Visual data, to see the maps. Numerical Data, to see
distances. Lastly, Spatial data, to save the gps routes. The “GPS” object of the GPS class would need to
interact with the map class in order to make the routes.

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?

The classes used to do this will be all classes. The route class will save the routes set by the user. The
map class will be used to show the map while creating the route, as well as display it when the user
wishes to see their route. Lastly, the GPS class will have more data about the route, such as distance.
The messages sent will be from gps to route, route to map, and map to gps. GPS will send route data to
the Route class. Route will send the route data to the map to be displayed. Lastly, Map will
communicate with the GPS class to display info about the route.

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.

The route class will be password protected. Before allowing access to view the saved route data, the
user will have to authenticate themselves as the creator. This protects the gps and map class since the

Copyright © 2024 Margaret Burke. All rights reserved. 3


main class will be accessible to only those who originally had access to it, regardless of implementation
changes.

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.

The map class could be designed in a way to be accessible to the public. By utilizing a public
map, a simple “check in” method could be created to check oneself into each of these wellness
points. If we would want to get even fancier, we could upgrade the Route Class to store this
data as well.

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.

The map class would need to be upgraded. If the map class were able to not only display the map data,
but also send it to be displayed elsewhere, this would work to put it into vr. The other classes would not
need to be changed for this purpose.

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.

For the map class, it has a real world counterpart: An actual map. With maps, it can show 3d objects
(trees, mountains, lakes, etc) via topographical lines. The map class wouldn’t be able to do this.

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
points for each part of the problem they answered, even if you believe their answer is not very correct.
(14 points)

Copyright © 2024 Margaret Burke. All rights reserved. 4


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
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:
Copyright © 2024 Margaret Burke. All rights reserved. 5
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. 6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy