From the course: Java Object-Oriented Programming
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Solution: Leverage abstraction to write simpler applications - Java Tutorial
From the course: Java Object-Oriented Programming
Solution: Leverage abstraction to write simpler applications
(upbeat music) - [Instructor] Let's reduce complexity and code duplication in our event program. We started off with the event interface and this will remain the same. However, instead of each custom event class implementing the interface, we'll have an abstract event class that implements event. Before the timestamp and ID attributes were duplicated across each event. Here, we've put the attributes in a single place, the abstract event class. The implementation of getTimestamp was also duplicated, so we've put it in this common class. Now this is an abstract class, so we can not create instances from it directly, rather other event classes we'll extend this class with more functionality. In that extension the abstract method process will need to be implemented. Let's take a look at how the password change event has changed. Instead of implementing the event interface, this class extends abstract event. In its…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
What is abstraction?1m 47s
-
(Locked)
Using abstract classes in Java to reduce code complexity5m 59s
-
(Locked)
Using interfaces in Java to provide conformity5m 1s
-
(Locked)
Discovering abstraction in Java source code4m 55s
-
(Locked)
Challenge: Leverage abstraction to write simpler applications1m 19s
-
(Locked)
Solution: Leverage abstraction to write simpler applications2m 58s
-
(Locked)
-