Session Details
Week 2,
Session 4 — Tue Mar 16
Reading
-
Big Java, §3.1–3.8
- Pay particular attention to §3.8
- Consider creating Wiki questions comparing Java classes to Python classes
HW Due
-
HW 3
Topics
-
Object-Oriented Encapsulation
-
Implementing Classes in Java
- Fields, Constructors, Methods
- Implementing an Interface
- Documented Stubs
- Test-first Programming, JUnit tests
Resources
-
Slides
Outline
-
[10 min] Questions
-
[5 min] OO encapsulation
-
[20 min] Java classes vs. Python classes. The BankAccount project has the code that the slides discuss.
- Fields, Constructors, Methods
- Overloading
- Visibility (public, private)
- Public Interface vs. Private Implementation
- The this Keyword: Implicit vs. Explicit Parameters
- Fields vs. Parameters vs. Local Variables
-
[5 min] Break
-
[20 min] Live coding on implementing a class: implement Shouter and add a test to ShouterTest in the WordGames project, as specified in the WordGames instructions.
- Implementing an Interface
- Using Documented Stubs
- Test-first Programming, JUnit tests
-
[15 min] More live coding on implementing a class: implement Censor and add a test to CensorTest in the WordGames project, as specified in the WordGames instructions.
- Fields: when you need one, how you declare one, how you initialize one
- Constructors: writing and calling
-
[30 min] Begin homework (continue working per the WordGames instructions).
HW Assigned
-
HW 4