10-Minute Guide to Object-Oriented Programming for Automated Testers

Object Oriented (OO) simplified by examples

Zhimin Zhan
5 min readSep 18, 2022

--

A repost of my daughter’s article with permission. I added a few notes. This is also included in the 10-minute guide series:

Most modern programming languages support object-oriented programming (OOP). Mastering OOP is a must for software engineers and test automation engineers nowadays. This quick guide is intended for non-programmers to get a quick understanding of OO, in particular, to become automated testers.

Tables of Contents:
· Object Oriented Concept in a Nutshell
· In Ruby, everything is an object (or class)
· Class Inheritance
· Child Class Can Override Behaviours
· Use your newly learned OO knowledge to understand Automated Test Script
· Review by Zhimin

Object Oriented Concept in a Nutshell

OOP sounds like a complicated concept, at least for me when I was 13 years old. It turned out to be quite simple after my father illustrated with this example:

Car is a class, a type of something, it has the following two functions (plus many more…):

  • accelerate
  • brake

My car (the one in my garage) is an object of Car, it can ‘brake’ and ‘accelerate’. I can physically drive it.

Now have a think about the statements below:

my_car = Car.new
my_car.accelerate
your_camry = Car.new
your_camry.brake

.new creates an instance of a Class, in this case, Car. The returned instance is also known as an Object.

In Ruby, everything is an object (or class)

Ruby is a pure Object-Oriented language, comparatively, Java is not as it has primitive types. Learning OO with Ruby is easier.

a_string = "Ruby is cool"
a_string.size # => 12
iphones = ["iPhone 4s", "iPhone 5S", "iPhone 5C"]
iphones.sort #=>["iPhone…

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.