Basic Concepts
Why learning OOD?
- Practical problems -> Model -> Code
- Better understanding of OOP
- Code details
Key Concepts
Reading material
- "Effective Java"
- Java source code(e.g. ArrayList, HashMap, PriorityQueue...)
What is good code? What is a good design?
(把代码当作艺术品,写代码当作雕刻一个艺术品!)
- Complete functionality
- Easy to use (by others)
a. clear, elegant, easy to understand, no ambiguity b. prevent users from making mistakes
3.Easy to evolve
Motivation of OOP
- 1 Structured Programming: code + data
如果一组data总是同时出现,同时总是调用一组function对这些data进行各种操作? ArrayList: array + operations on array
- 2 如果只想暴露有限的接口(interface, API)?
Example: List APIs(public methods): add(E e), get(int index), remove(int index), size() Internal Implementation(private attributes, private methods): how to store elements in the list, how to track its size,...
3 如果想重用部分程序,同时根据不同的情况扩展(extension)? Example:List -> ...
4 如何更好的进行测试(Modular testing)?