Lec12a - COMP 2710 Software Construction Object-Oriented...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COMP 2710 Software Construction Object-Oriented Development Dr. Xiao Qin Auburn University http://www.eng.auburn.edu/~xqin [email protected] Fall, 2011 Slides are adapted from notes by Robert C. Martin 1-1 Object Oriented Programming 1-2 First Version All designs start well The program is an overnight success! How could it be more simple, elegant, and maintainable? ReadKeyboard Copy WritePRinter void copy(void) { int ch; while( (ch=ReadKeyboard()) != EOF) WritePrinter(ch); } 1-3 Advanced Principles I - 4 Second Version • We sometimes want to read from paper tape reader. • We could put a parameter in the call, but we have hundreds of users already! • No big deal, this is just an exception… we can make it work. Oh, no! Nobody said the requirements might change! Second Version Design ReadKeyboard Copy WritePrinter ReadTape bool GtapeReader = false; // remember to clear void copy(void) { int ch; while( (ch=GtapeReader ? ReadTape() : ReadKeyboard()) != EOF) WritePrinter(ch); } 1-5 Third Version How unexpected! Requirements changed again! bool GtapeReader = false; Bool GtapePunch = false; // remember to clear void copy(void) { int ch; while( (ch=GtapeReader ? ReadTape() : ReadKeyboard()) != EOF) GtapePunch ? WritePunch(ch) : WritePrinter(ch); } It seems that sometimes we need to write to a paper tape punch. We’ve had this problem before, and just added a flag. Looks like it should work again....
View Full Document

{[ snackBarMessage ]}

Page1 / 21

Lec12a - COMP 2710 Software Construction Object-Oriented...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online