Object-Oriented Programming: Class 2 Recap and Muddiest Points Discussion
Today's class delved into object-oriented programming, null references, refactoring code, and designing code. We reviewed static classes and discussed the ins and outs of using "this" and "other" in programming. The muddiest points included understanding the behavior of null objects, short-circuit operators like "||," and hotkeys in IntelliJ. Join the discussion on these key concepts!
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
SE1011 Week 8, Class 2 Today Return Half Exam 3 (I have it with me) Object Oriented Programming Details Null references (as acting objects and arguments) Refactoring code Designing Code Muddiest Point SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 1
How-To Register Info Session! Who: Anyone who wants to know how to register for classes for the Winter Quarter. What: A How-To Register Info Session with step- by-step instructions on how to register for classes. Registration for the winter quarter is coming up very shortly, and we want to make sure you feel prepared! When: You pick the day: Monday, November 2nd, 1:00-1:50 p.m., or Friday, November 6th, 12:00-12:50 p.m. Where: CC 53 2
Muddiest Point I understood most of today's concepts, but would like to go over static classes again really quickly just a refresher. [Coming up soon] The origin of an xy plane falls into a pig pen. Now that's a muddy point. debugging what does the memory diagram look like when you instantiate an object with null? aren't they still equal if they're both null? How to debug a program that requires user input. Discussed at start. Discussed during this class. [Instructor answer to the question] static classes joke debugger null null debugger 3
Muddiest Point how to use this. Does || work the same way as && as a short circuit operator? So if(true || <something that can't be evaluated>) will it go on or will it crash? Not exactly a muddy point, but is there a sheet that has a bunch of useful hotkeys to use in intellij? (For example the ctrl + / for commenting out highlighted things) [Help->Default Keymap Reference] how to use "this." & "other." Should we have the comparator in the complex class? [Wait until Data Structures (CS2852)] this. & other. || short-circuit intelliJ hotkeys this. & other. Comparator Discussed at start. Discussed during this class. [Instructor answer to the question] 4
NullPointerExceptions main( ) 85638 real real 3.0 r3 double 85638 imag 0.0 Complex ref double n Complex null Complex ref prod Complex ref public void main( ) { Complex n = null; Complex r3 = new Complex(3); prod = n.multBy(r3); } 5
NullPointerExceptions main( ) 85638 real real 3.0 r3 Complex(double real, double imag) this 85638 double 85638 imag Complex ref 0.0 Complex ref other double n Complex null null Complex ref Complex ref prod public Complex multBy(Complex other) { // HERE Complex result = new Complex(); result.real = this.real * other. - this.imag * other.imag; result.imag = this.real * other. + this.imag * other.imag; return result; } Complex ref public void main( ) { Complex n = null; Complex r3 = new Complex(3); prod = r3.multBy(n); } 6
NullPointerExceptions main( ) 85638 real real 3.0 r3 Complex(double real, double imag) this 85638 double 85638 imag Complex ref 0.0 Complex ref other double n Complex null null 85642 Complex ref Complex ref real result 0.0 85642 double imag prod 0.0 Complex ref double public Complex multBy(Complex other) { Complex result = new Complex(); // HERE result.real = this.real * other. - this.imag * other.imag; result.imag = this.real * other. + this.imag * other.imag; return result; } Complex Complex ref public void main( ) { Complex n = null; Complex r3 = new Complex(3); prod = r3.multBy(n); } 7
SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 8
Acknowledgement This course is based on the text Introduction to Programming with Java by Dean & Dean, 2nd Edition SE-1011 Slide design: Dr. Mark L. Hornick Instructor: Dr. Yoder 9