80 likes | 142 Views
The Evil of If Statements. As you arrive… Email your assigned UTA to set up a design review meeting if you haven’t already! If you don’t have an assigned UTA – plan to talk with me before/after class. What We Will Do Today.
E N D
The Evil of If Statements As you arrive… Email your assigned UTA to set up a design review meeting if you haven’t already! If you don’t have an assigned UTA – plan to talk with me before/after class.
What We Will Do Today • You will remove some ugly code using subclasses in the exercise from last time • You will be aware of 2 Different Perspectives on Object Orient Design, as exemplified by our 2 papers on Friday • You will be able to identify problematic if statements, and you’ll be ready to apply those insights to Project 1.
Exercise from last time • Snarf the code if you haven’t already • Use subclasses (a la the shapes in the open/closed principle paper) to refactorbetIsMade and placeBet Game.java • If you have trouble, check out the HINTS.txt file for 3 levels of hints • If you still have trouble, raise your hand • When you’ve got it working, submit your code via Ambient (it’s in the eclipse menu “Ambient->Submit a Project for Grading”)
What We Will Do Today • You will remove some ugly code using subclasses in the exercise from last time • You will be aware of 2 Different Perspectives on Object Orient Design, as exemplified by our 2 papers on Friday • You will be able to identify problematic if statements, and you’ll be ready to apply those insights to Project 1.
2 (Complementary) Perspectives You code should be like clay: simple, malleable, and doing exactly what it is intended to do and no more. Every part of it should be clean and free of dependencies because you don’t know what will be changed. You code should be like a perfectly milled steel machine, designed with expansion in mind. New parts should fit in seamlessly, and it should be impossible to fit them in wrong. Focus on making it easy to extend your design in specific ways.
Picassa • Signoff on Part 1: 1/26 • Signoff on Parts 2 and 3: 2/7
What We Will Do Today • You will remove some ugly code using subclasses in the exercise from last time • You will be aware of 2 Different Perspectives: code as clay perspective, code as expandable machine perspective • You will be able to identify problematic if statements, and you’ll be ready to apply those insights to Project 1.