Presentation is loading. Please wait.

Presentation is loading. Please wait.

SE-1021 Software Engineering II Week 5, Class SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 1.

Similar presentations


Presentation on theme: "SE-1021 Software Engineering II Week 5, Class SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 1."— Presentation transcript:

1 SE-1021 Software Engineering II Week 5, Class SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 1

2 Announcement Johnson Controls CE event in the Todd Weir Auditorium on Monday, March 30, 5-7 PM (Spring Quarter) Direct Supply SE event Location TBA (but probably Todd Weir Aud.) Around the same time, but not on the same day… SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 2

3 What is an inner class? An inner class is Declared inside of another class Usually declared private (needed by only one class) Has access to all variables of the top-level class Even instance variables! And so … _____________________________ Even private variables! And so … ______________________________ Dean & Dean, 2 nd Ed. Pp 775-776 (Sec. 17.10) http://docs.oracle.com/javase/tutorial/java/javaOO/n ested.html SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 3

4 Drawing an inner class on a UML Diagram You might think we draw it like this: But actually, we draw it like _____________ SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 4 Gui ButtonHandler

5 Drawing an inner class on a memory-map diagram You might think we draw it like this But actually, we will draw it like_____________ SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 5 Gui ButtonHandler myGui Gui ref main

6 Anonymous Inner Class This is a class that is DECLARED at the same place it is INSTANTIATED in the program Syntax: new InterfaceName () { ClassBody } Use: Use it where you would use the constructor of the class SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 6

7 Lambda Expression A lambda expression is an anonymous inner class with shorter syntax, for interfaces with just one method. Example: e -> myMethod(e) Use: Use it where you would use a constructor or an anonymous inner class. SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 7

8 From the Horse’s Mouth* “Lambda expressions let you express instances of single-method classes more compactly.” http://docs.oracle.com/javase/tutorial/java/java OO/lambdaexpressions.htmlhttp://docs.oracle.com/javase/tutorial/java/java OO/lambdaexpressions.html (emphasis added) * “straight from the Horse’s mouth” is an idiom saying to get something from an authoritative source. It refers to looking into a horse’s mouth to determine its age. SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 8


Download ppt "SE-1021 Software Engineering II Week 5, Class SE-2811 Dr. Josiah Yoder Slide style: Dr. Hornick 1."

Similar presentations


Ads by Google