Code: Review of Java Fundamentals: Object-oriented Design from

Review of Java Fundamentals: Object-oriented Design

When I picked up the Java programming language a few years back, I focused on understanding the syntax, API and tooling of the language. Yet one area that I quickly glazed over was object oriented design patterns. Over the years, I’ve been itching to research this topic since I’ve heard that good architecture and the right design patterns could increase the maintainability of my source code.
For that reason, I decided last week that I would level up my design skills and take a course over Java object oriented design patterns on

The pluralsight course covered the popular SOLID principles mentioned in most Java OO design textbooks but with the authors spin on things.

After taking the course over a 3 day time span, I feel like it was time well spent! I had a lot of misconceptions about object oriented programming that were debunked in the first hour of the modules. Here are a few things I absorbed from the course.

1. The object with the most data should do the heavy lifting

2. Ask for help from objects, not their data

We can illustrate the first two points with a simple use case.
In this example we want to find the number of books with less than 100 pages in a shelf.

Ok Code

// ES6
const numOfShortBooks = shelf.getBooks().filter(book => book.getTotalPages() < MAX_PAGES_FOR_SHORT_BOOK).length

Figure: Code 1.1

The problem here is that the shelf object is exposing too much information about itself, which could make refactoring hard.
In the course, the author states that objects should communicate and accomplish tasks using public methods, while keeping their inner data structures private and locked down. Avoid getter and setters of internal data like the plague. Not doing so will produce more run-time exceptions because of the unexpected way a external class is using your code.
Check this out.

Improved Code

// ES6
const numOfShortBooks = shelf.countBooksByTotalPages(MAX_PAGES_FOR_SHORT_BOOK)

Figure: Code 1.2

As you can see, the method calls were wrapped inside .countBooksByTotalPages() to hide the complexity. Less code, less bugs.

3. Prefer interfaces over concrete classes.

In OO design, your objects should care about getting the job done regardless of the class. That's why you should prefer interacting with interfaces rather than classes. Interfaces will give you a greater number of objects that can fulfill a role because it's based on abilities. However, class must have the correct super class in it's class hierarchy to meet a requirement.

// in groovy language
interface Talkative {
  void speak()
class Person {
    println("Where's my money?")
class Dog {
    println("woof! woof!")

def saySomething(Talkative thing){

// :-( Doesn't work with Dog
def personSaySomething(Person person){

saySomething(new Person()) // prints where's my money!
saySomething(new Dog()) // prints woof! woof!

personSaySomething(new Person()) // prints where's my money!
personSaySomething(new Dog()) // Error! Dog isn't of class Person

Figure: Code 1.3

In the above code, you can see that the saySomething() method is more flexible then personSaySomething().

Review: 5/5 - Recommended
+ Short and concise
+ Covers the popular SOLID principles
+ Straight forward and complete examples

- It not about designing objects. For that you'll have to find a course over Object-oriented analysis and design (OOAD)

- More info:
Java Fundamentals: Object-oriented Design

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me:

Subscription Review: New Scientist

Throughout 2011 I have been loyal subscription holder to the scientific magazine New Scientist.
I love it how each week I’m presented with the latest scientific discoveries that blow my mind.

So, what is New Scientist?

New Scientist reports on the very latest science and technology news, putting discoveries and advances in the context of everyday life. New Scientist relates the advancements of human knowledge to the broader impacts on society and culture, making it essential reading for people who ask why. – From:

Here are my top 5 hottest stories from 2011

  1. Fallible DNA evidence can mean prison or freedom

    New Scientist reveals that much of the DNA analysis now conducted in crime labs can suffer from worrying subjectivity and bias.

  2. Neutrino watch: Speed claim baffles CERN theoryfest

    OPERA … announced that neutrinos traveling from CERN had apparently moved faster than light.

  3. Move over, Einstein: Machines will take it from here

    Schmidt recorded this movement using a motion tracking camera which fed numbers into his computer. What he was looking for was an equation describing the motion of the pendulums.

    Note: I wrote an article over this here

  4. How online games are solving uncomputable problems
  5. Better than human? What’s next for Jeopardy! computer


  • Well thought out and highly organized magazine.
  • Scientific Job Board
  • Amazing Scientific News
  • Articles are easy for ordinary person to understand.
  • Offers short lessons over complex topics
  • “The Last Word” – answers to scientific questions about everyday phenomena.


  • Topics can sometimes become repetitive
  • No references for most articles.
  • It’s only news, so you can’t apply want you learn.

Price: ~$99 annually (on line discounts may vary)
You can check out “New Scientist” at

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me:

Download Videos From Your Browser’s Cache

I watch tons of videos on-line in any given week from sites like, dailymotion, and newgrounds.
From time to time I stumble across videos that I would love to keep in my video collections. The way that I save the videos is by saving the browser cache folder and searching for the video within there.
To simplify this process I use VideoCacheView from
VideoCacheView is freeware and easy to use. All you do is download and extract the zip file, then launch the program.

Let’s say that I want to download “TFS Abridged Parody Episode 24” from

TFS Abridged Parody Episode 24 Video
TFS Abridged Parody Episode 24 Video
. All I would have to do are two step to get the file.
Step 1: Open the link and have the video load to the completion.
Step 2: After that launch VideoCacheView.exe and right click on the temporary file to save the video.
That’s it.

Video Cache View Right click to save
Video Cache View Right click to save

Once last thing. Most of the videos are in the flv file format. To solve this problem, you can use “iWisoft Free Video Converter” to convert from one file format to another, like wmv or avi.

Video Cache View: Download here

Larry Battle

I love to program, and discover new tech. Check out my stackoverflow and github accounts.

More Posts - Website

Follow Me: