You are probably being recorded (and transcribed) [at least if Sam can get the technology working again]
Start of class instructions
Approximate overview
If you’d like to suggest token events, please let me know in advance of class.
Like the second half of Tuesday’s lab, but extended! Also partnered. Today’s lab partner is your MP partner. If you are not here today, Sam will assign you a partner.
I will reserve ten minutes at the end of class today for you to make plans with your partner (e.g., meeting times).
Do we submit one project each or one project together?
Just one project for the two (sometimes three) of you.
Should we share one GitHub repository?
Yes. One of my goals is that you have experience working with another person in the same repository. (It gets better on the next assignment.)
The point of the horizontal composition exercise.
Also “What should be the meaning?”
Good tests are important
I am stunned to see how many of you wrote the following for row 0 of the surrounded box.
public String row(int i) {
if (i == 0) {
return boxChar + boxChar.repeat(contents.width()) + boxChar;
} else {
...
} // if/else
} // row(int)
Why would this disturb me? (TPS)
boxChar.repeat(contents.width() + 2)
. It’s more
concise.this
. boxChar.repeat(this.contents.width() + 2)
.this
. this.boxChar.repeat(this.contents.width() + 2)
.return
do we really
need an else
? (Sam’s okay with it.)this
. this.boxChar.repeat(this.width())
.Can I use my code from the lab in which we worked with BigFraction
?
Certainly. But cite your partner.
Can I have an extension?
Sure.
Should I throw exceptions for illegal input?
In
InteractiveCalculator
andQuickCalculator
, the answer is no. You should print an error message and go on.
In
BFCalculator
,BFRegisterSet
,BigFraction
, the answer is also no. You should assume they have correct input. Let them fail however they fail.
From Sam: What are the stumbling blocks?
Basic concepts of how to solve it? (a few)
Maven setup + VSCode is taking more time than it should. (many)
I didn’t start soon enough. (similar)
It’s a long assignment, nothing in particular. (many more)
Some parts of the assignment are hard, such as parsing strings.
Model: Read over these. Start the lab. At some point, I’ll ask if anyone has questions.
Can you give examples/situations in which one type of polymorphism is better over the other?
We tend to use parametric polymorphism when we want to build a new data type that can hold/work with “any type of object” (or perhaps some restricted types of objects). E.g., “I want a homogeneous list.”
We tend to use subtype polymorphism when we want to write methods that work with a restricted class of object. E.g., “I can do this calculation with anything that acts like a number.”
Does the letter used matter when creating a generic interface that takes multiple type parameters? In the example, T and U were used, implying that one would continue adding type parameters named V, W, X, etc., though the java.util.function.Function documentation used R and V as type parameters. Is there any correlation or importance to these?
You can use whatever letters you want. (You may even be able to use words, but no one seems to do so).
I thought Function uses
T
andR
.T
is used because it stands for “type”.R
stands forResult
.
Is it possible to specify a type within a type specification (For example,
DynamicArray<DynamicArray<String>>
to make a jagged 2D array of strings)?
Yes.
Could we dive deeper into type safety with generics and how to handle runtime exceptions related to generics?
Can you explain more about wildcard types (? super T, ? extends T) and when they are useful in practice?
How do generics in Java compare to mechanisms similar to those in other programming languages, such as C++ templates?
We’ll try to end at 3:35 so that you have time to meet with your partner(s).
You can submit whatever you’ve done, whether you are at 1, 2, 3, or 4.