Just a quick little OOP tidbit for you folks out there...
"Method chaining" is the act of calling one method right after another in the same "statement" (same line of code). This is done for convenience really, as it makes manipulating an object possible in one line instead of many.
For instance, in my example posted (link below), you can create a "Photo" object and maniuplate it like this:
sunrise = new Photo();
sunrise.setLocation("sunrise.jpg").setCaption("A sunrise").setPhotoDate("8/9/03");
To enable method chaining in your custom classes, check out this code sample. Note that "return this;" is at the end of every "setter" method. This is the key to enabling method chaining, and the entire point of this entry.

Leave a comment