Software Design Lecture Notes Fall 2004 Today ----- 1) Project reports / feedback 2) Interaction of OpenGL and Gui 3) Discussion of OO version of teapots. 4) Small amounts of fun Tomorrow -------- 1) documentation scavenger hunt! 2) more fun Bottom-up OO design ------------------- 1) start with procedural exercises a) look for opportunities to improve interfaces b) identify invariants c) look for opportunities to improve error-prone semantics 2) grow objects by a) grouping related procedures b) grouping related data c) use object semantics to enforce invariants 3) refactor objects a) think of IS-A and HAS-A tradeoffs 4) identify patterns a) visitor pattern b) bridge pattern 5) look for opportunities to generalize a) think in terms of language creation b) what's next? Three ways to vary behavior --------------------------- 1) data-driven 2) object-driven (inheritance) 3) object-driven (reference) State management ---------------- One aspect of the OO design is that most state is stored in both OpenGL and in one of my objects: pro) this makes it easier to organize data logically pro) object constructors are a natural place to store and document default values pro) we can keep multiple objects of each type and swap them in and out example: switching among multiple cameras con) resource use (probably not significant) con) we take on the burden of maintaining consistency example: when we change an object, we usually have to invoke setup to make the change effective Fun with teapots ---------------- Some things you might want to play with in order to get more familiar with OpenGL: 1) fiddle with parameters to see the effect a) fog b) positional and directional lights 2) take advantage of the OOness a) create more objects b) create more cameras and switch among them c) play "where's my teapot?!?" 3) play with the object structure a) create more teapots and play with their parameters b) write additional object types for glutSolidCube or the other glut shapes c) use Cube to implement an object that draws Rectangles (see glScale) d) in lab we will learn how to build objects from polygons 4) make an OpenGL world that is also a RemoteObject