Learn about Java implementation of visitor patterns.
- In this video, we'll implement the Visitor Pattern.…As described in this article from DZone.…First, we'll copy some classes and interfaces…from the article.…The first is the Visitable interface.…This indicates something that can be visited,…such as a book.…Next, the Visitor interface.…And this is an object, that will do the visiting.…In other words, it will visit a Visitable.…The Book class, implements the Visitable interface.…
Visitable has one method,…and Book implements the accept method.…We'll implement the PostageVisitor class,…and it implements Visitor.…Finally, we'll test all of these.…In the before method, we'll populate the VisitableList.…We'll create items.…We're instantiating the type…private ArrayList Visitable items.…We'll create a new Book, and add it to the list.…
A second new Book, and add it to the list…We'll create a test, testPostageCalculation.…We'll calculate an anticipatedResult.…Then we'll actually calculate the Postage using this method.…And finally, we'll assert that they're equal.…We'll run the test.…
Author
Released
2/1/2017- The IMQAV model
- Downloading software
- Installing and setting up a Java coding environment
- Mock tests
- Code coverage
- Using windows, views, and modes in IntelliJ IDEA
- Creating classes and attributes
- Creating constructors
- Casting variables
- Matching literals with regular expressions
- Libraries
- Regular expressions
- Design patterns
Skill Level Intermediate
Duration
Views
Related Courses
-
Java: Database Integration with JDBC
with David Gassner2h 51m Intermediate -
NumPy Data Science Essential Training
with Charles Kelly3h 54m Intermediate
-
Introduction
-
Welcome1m 3s
-
Using the exercise files1m 8s
-
-
1. Getting Started with Java
-
JVM languages1m 8s
-
Downloading software3m 10s
-
Installing software6m 57s
-
2. Test-Driven Development
-
Introduction to testing2m 15s
-
Types of tests5m 54s
-
Mock tests2m 15s
-
Code coverage1m 47s
-
-
3. IntelliJ IDEA
-
Windows, views, and modes5m 15s
-
Projects5m 47s
-
Editor basics5m 36s
-
Refactoring2m 38s
-
Code execution1m 23s
-
Debugging2m 4s
-
-
4. Object-Oriented Java
-
Object-oriented principles1m 20s
-
Primitives59s
-
Strings4m 12s
-
Classes and attributes4m 13s
-
Classes and methods3m 46s
-
Classes and constructors2m 44s
-
Exception handling3m 27s
-
Enumerations5m 26s
-
Casting3m 19s
-
Generics1m 40s
-
Annotations1m 59s
-
Program flow control9m 43s
-
-
5. Libraries
-
Install and use libraries5m 15s
-
gson2m 40s
-
StringUtils1m 56s
-
-
6. Regular Expressions (Regex)
-
Literals4m 23s
-
Predefined character classes1m 28s
-
Regex quantifiers2m 40s
-
Regex boundaries and anchors1m 26s
-
Regex examples1m 55s
-
7. Reflection
-
Introduction to reflection1m 17s
-
Introspect fields2m 50s
-
Introspect methods2m 51s
-
Introspect constructors3m 15s
-
Introspect annotations2m 5s
-
-
8. Design Patterns
-
Singleton patterns2m 19s
-
Decorator patterns3m 23s
-
Visitor patterns2m 32s
-
9. Applying Data Science
-
Magic squares algorithm5m 11s
-
Adjacency matrix5m 42s
-
Magic characteristics1m 35s
-
Building magic cubes5m 31s
-
Conclusion
-
Next steps53s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Visitor patterns