SlideShare a Scribd company logo
Ruby OOP: Objects over ClassesAman Kingking@thoughtworks.comRubyConf India 2010
What is OOP?
What is a class?
What is an object?
But before the serious stuff …
Detouring through a comic book universe …Image copyrighted by respective ownersSource: http://www.comics.org/
Coming back …
What is an object?
Something that takes birth …
exhibits some behavior …
interacts with other objects …
and finally dies off or is simply forgotten …
all in an effort to solve a problem.
What is a class?
A container for related behavior …
that a new object can start off with.
A class itself is an object …
used to create other objects.
When creating a new object, a class calls the object’s private initialize method.
Typically a class is named …
referenced via a global constant variable.
A class object can have singleton methods added to it.
These singleton methods can be invoked wherever the class object is accessible …
aka “class-level methods”.
Why use classes?
Some possible reasons
An object remembers the class used to create it …
explicit type checking using kind_of? …
implicit type checking using case syntax …
implicit type checking using rescue syntax.
A class can build on other classes: inheritance.
A class can share state across multiple objects: @@class_variables.
Some good reasons
A named container of behavior can have more behavior added to it.
Any added behavior becomes part of all objects created by that class.
A class can represent a common pattern of initialization.
Classes improve readability and maintainability.
What a class is not?
The fundamental building block of an application.
A strong data type.
An enforcement of contract or limitations on how objects can behave.
Ruby’s object focus
Classes are objects.
No static method-lookup tables: chain of ancestors.
Singleton methods.
Private access modifier is object-level.
Duck typing.
Finding hints in the real world …
Objects over classes: Consequences
Classes and hierarchies no longer limit you.
Think through the usage ofclass-level methods and variables: globals?
Understanding meta-programming is easier.
Effective and confident use of meta-programming.
Final words
Objects are first-class citizens.
Classes are useful but secondary.
Thank youking@thoughtworks.comhttp://www.wikyblog.com/AmanKing

More Related Content

What's hot (20)

PDF
Introduction to object oriented programming
Abzetdin Adamov
 
PPTX
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
 
PPTX
Object oriented programming
baabtra.com - No. 1 supplier of quality freshers
 
PPTX
Classes And Objects
rahulsahay19
 
PPT
OOPs concept and implementation
Sandeep Kumar P K
 
PDF
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Michael Redlich
 
PPT
Lecture 2
emailharmeet
 
PPTX
Java
Shridhar Ramesh
 
PPT
OOP Basics
CIB Egypt
 
PDF
Object oriented programming With C#
Youssef Mohammed Abohaty
 
PPT
Basic concepts of object oriented programming
Sachin Sharma
 
PPTX
OOP Introduction with java programming language
Md.Al-imran Roton
 
PDF
Object Oriented Concepts in Real Projects
EPAM
 
PPTX
Java object oriented programming concepts - Brainsmartlabs
brainsmartlabsedu
 
PPTX
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
PPT
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Dr. Sandeep Kumar Singh
 
PPTX
Introduction to oop with c++
Shruti Patel
 
PPT
Oops ppt
abhayjuneja
 
Introduction to object oriented programming
Abzetdin Adamov
 
Fundamentals of OOP (Object Oriented Programming)
MD Sulaiman
 
Classes And Objects
rahulsahay19
 
OOPs concept and implementation
Sandeep Kumar P K
 
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Michael Redlich
 
Lecture 2
emailharmeet
 
OOP Basics
CIB Egypt
 
Object oriented programming With C#
Youssef Mohammed Abohaty
 
Basic concepts of object oriented programming
Sachin Sharma
 
OOP Introduction with java programming language
Md.Al-imran Roton
 
Object Oriented Concepts in Real Projects
EPAM
 
Java object oriented programming concepts - Brainsmartlabs
brainsmartlabsedu
 
Std 12 computer chapter 6 object oriented concepts (part 1)
Nuzhat Memon
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Dr. Sandeep Kumar Singh
 
Introduction to oop with c++
Shruti Patel
 
Oops ppt
abhayjuneja
 

Viewers also liked (9)

PDF
Ruby's Object Model: Metaprogramming and other Magic
Burke Libbey
 
PPSX
Основные понятия связанные с разработкой ПО: просто о сложном. Лаабе Дмитрий.
IT-Доминанта
 
PPTX
Ruby object model
Chamnap Chhorn
 
PDF
Elasticsearch Basics
Shifa Khan
 
PDF
OOP Intro in Ruby for NHRuby Feb 2010
bturnbull
 
PPT
Ruby For Java Programmers
Mike Bowler
 
PDF
Ruby everywhere
yukihiro_matz
 
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Ruby's Object Model: Metaprogramming and other Magic
Burke Libbey
 
Основные понятия связанные с разработкой ПО: просто о сложном. Лаабе Дмитрий.
IT-Доминанта
 
Ruby object model
Chamnap Chhorn
 
Elasticsearch Basics
Shifa Khan
 
OOP Intro in Ruby for NHRuby Feb 2010
bturnbull
 
Ruby For Java Programmers
Mike Bowler
 
Ruby everywhere
yukihiro_matz
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Ad

Similar to Ruby OOP: Objects over Classes (20)

PDF
Aman kingrubyoo pnew
ThoughtWorks
 
ODP
Intro Ruby Classes Part I
Juan Leal
 
PPTX
Object-oriented in ruby
Ngọc Nguyễn
 
PDF
The Ruby Object Model by Rafael Magana
Rafael Magana
 
PPT
Ruby for C# Developers
Cory Foy
 
PDF
RG OOP-talk
ddefrenne
 
PDF
OOP vs COP
Gianluca Padovani
 
ZIP
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
PDF
Workin On The Rails Road
RubyOnRails_dude
 
DOCX
Ruby Interview Questions
Sumanth krishna
 
PPTX
Ruby object model - Understanding of object play role for ruby
Tushar Pal
 
PDF
05 ruby classes
Walker Maidana
 
PDF
Class
Armin Pašalić
 
PPT
OOP intro.ppt
NoreenNyauchiSarai1
 
KEY
Ruby objects
Reuven Lerner
 
PPTX
On the path to become a jr. developer short version
Antonelo Schoepf
 
PDF
Slides
RubyOnRails_dude
 
PDF
Object Oriented Programming_combined.ppt.pdf
AshutoshKumar211882
 
PPTX
Object_Oriented_Programming_combined.ppt
ssuser8d54ed
 
Aman kingrubyoo pnew
ThoughtWorks
 
Intro Ruby Classes Part I
Juan Leal
 
Object-oriented in ruby
Ngọc Nguyễn
 
The Ruby Object Model by Rafael Magana
Rafael Magana
 
Ruby for C# Developers
Cory Foy
 
RG OOP-talk
ddefrenne
 
OOP vs COP
Gianluca Padovani
 
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
Workin On The Rails Road
RubyOnRails_dude
 
Ruby Interview Questions
Sumanth krishna
 
Ruby object model - Understanding of object play role for ruby
Tushar Pal
 
05 ruby classes
Walker Maidana
 
OOP intro.ppt
NoreenNyauchiSarai1
 
Ruby objects
Reuven Lerner
 
On the path to become a jr. developer short version
Antonelo Schoepf
 
Object Oriented Programming_combined.ppt.pdf
AshutoshKumar211882
 
Object_Oriented_Programming_combined.ppt
ssuser8d54ed
 
Ad

More from Aman King (9)

PPTX
Infusing Agility into the Java Legacy
Aman King
 
PPTX
Agile Testing Dilemmas
Aman King
 
PPTX
From Practitioner to Coach
Aman King
 
PPTX
Simple Ruby DSL Techniques: Big Project Impact!
Aman King
 
PPTX
Paving the Way for Agile Engineering Practices
Aman King
 
PPTX
Agile Testing!
Aman King
 
PPT
Reducing Build Time
Aman King
 
PPTX
Multimethods
Aman King
 
PPTX
Agile Buzzwords in Action
Aman King
 
Infusing Agility into the Java Legacy
Aman King
 
Agile Testing Dilemmas
Aman King
 
From Practitioner to Coach
Aman King
 
Simple Ruby DSL Techniques: Big Project Impact!
Aman King
 
Paving the Way for Agile Engineering Practices
Aman King
 
Agile Testing!
Aman King
 
Reducing Build Time
Aman King
 
Multimethods
Aman King
 
Agile Buzzwords in Action
Aman King
 

Recently uploaded (20)

PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 

Ruby OOP: Objects over Classes