Object Design
Notes
- This is from chapter 5 of the book.
- Procedural Programming: "What does the program do?"
- In top down design we ask "What is the main task?"
- "Can I break this task down into smaller tasks?"
- And only later "What data do I need to pass to these tasks?"
- Object Oriented Programming: "What real world objects am I modeling"
- Objects need to have properties and behaviors
- Objects are instances of classes
- They have the common behavior, but different properties
- IE different die objects have different values, but all have a value, and all have the roll behavior.
- Classes are constructed from components.
- These are the elements that make up the class
- Including other classes.
- Behaviors are the things that classes can do.
- Roll, Initialize, get values, ...
- When we start to design a program we can
- Deign in a purely top down manner, not really acceptable in a class called object oriented programming
- Go completely object oriented, but probably too much
- Mix the two, what we will do for now.
- When deciding on building a class you want to have a crisp definition of the class, what it holds and what it does.
- It must contain properties or data, otherwise it is just an algorithm/function
- It must contain behaviors otherwise it is just a variable
- Later we will consider some class properties
- Has-A relationship or composition
- Is-A relationship or inheritance.