You are probably being recorded, perhaps even transcribed. Of course, the technology failed in my earlier class, so perhaps not.
Approximate overview
Academic/Scholarly
Cultural
Peer
Wellness
Misc
When considering the purpose of mini-projects, try to think more generally. Not “building a Fraction class” but “learning to build classes”. Not “creating a calculator” but “learning to use the classes we’ve built” or “separate UI from backend”.
When filling out pre-assessments, please do a brain dump of code/algorithms. Don’t just list topics you need to look up!
I’m building classes. I need constructions. THose look like public ClassName(Params). I create objects with new ClassName(args).
I’ll be working with strings, particularly in the interactive part. I use str.split(" ")
to break a string apart at spaces (I think the input looks like that).
I’m going to process the command line in the COmmandLineCalculator, for (String arg : args)
.
I’ll need to convert strings to BigIntegers or fractions. For BigIntegers that new BigInteger(str)
(I hope), for BigFractions, we wrote that as `new BigFraction(String).
We have to deal with both whole numbers and fractions. I thing there’s a str.contains(String other)
. If not, there’s a str.indexOf(String other)
.
Java has a different syntax for handling objects. foo.multiply(bar)
rather than foo*bar
.
I’ll need an array for the registers. It will have the form BigInteger[] registers = new BigInteger[26];
or something like that.
We’ll quickly go through the ones I’ve received and then see if you have others.
Can we crash and burn when we hit division by zero or should we issue an error or …?
You can crash and burn. Or you can issue an error.
Can we crash and burn on invalid input?
If the person designing the project doesn’t specify what to do, you can crash and burn.
You can crash and burn on
"1 + 2/agh"
Can I catch exceptions?
Sure.
Should we handle "1 + 2 / a"
?
Yes.
What’s an expression with no operations?
"5"
-> gives5
.
"a"
-> gives whatever was stored in register a.
Will Sam be in his office during office hours?
That is currently the plan. But some of those hours are booked.
You can book office hours at https://bit.ly/book-samr, at least if bit.ly is working. If not, look at the class home page.
Can you fix VSCode in MathLAN in fifteen minutes?
Probably. You can also show up before 10am and I’ll probably be in my office.
To understand how our code works (and why it doesn’t work), it can be helpful to form mental models of how the computer stores and processes our programs.
let
bindings.TPS: What information should we store for each class?
Note: We may also want to make the association of names with things a bit more explicit.
+-----+----+
| x | *---------> ...
+-----+----+
| y | *---------> ...
+-----+----+
or
+-----+------+
| x | 0x23 |
+-----+------+
Or we might do what we do in C and just write the names on the side.
TPS: What information should we store for each object?
You do not explicitly free unused objects in Java.
How do we avoid running out of memory?
We need something that collects the “garbage” in our program; the things that occupy memory but will never again be used.
It is impossible to determine whether an arbitrary object will be used in the future. So we look primarily at the things that we can still be referred to. Those are not garbage. Anything that is not referred to directly or indirectly can be treated as garbage.
Two main philosophies of garbage collection:
Most modern languages mark what is useful and what is not useful.
I’ve been known to say “Java is your nanny”. That is, the Java compiler tries to verify that your code is “safe” (or as safe as it can figure).
TPS: What kinds of issues can it check at compile time?
TPS: What kinds of issues might occur at runtime?
Other than objects and classes, what information should we be storing at runtime?