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

PPT
Object-oriented concepts
PDF
Object Oriented Paradigm
PPT
Object oriented programming (oop) cs304 power point slides lecture 01
PPT
Object-Oriented Programming Concepts
PDF
PPT
What is OOP?
PDF
Oop basic overview
PPTX
Introduction to Object Oriented Programming
Object-oriented concepts
Object Oriented Paradigm
Object oriented programming (oop) cs304 power point slides lecture 01
Object-Oriented Programming Concepts
What is OOP?
Oop basic overview
Introduction to Object Oriented Programming

What's hot (20)

PDF
Introduction to object oriented programming
PPTX
Fundamentals of OOP (Object Oriented Programming)
PPTX
PPTX
Classes And Objects
PPT
OOPs concept and implementation
PDF
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
PPT
Lecture 2
PPTX
PPT
OOP Basics
PDF
Object oriented programming With C#
PPT
Basic concepts of object oriented programming
PPTX
OOP Introduction with java programming language
PDF
Object Oriented Concepts in Real Projects
PPTX
Java object oriented programming concepts - Brainsmartlabs
PPTX
Std 12 computer chapter 6 object oriented concepts (part 1)
PPT
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
PPTX
Introduction to oop with c++
PPT
Oops ppt
Introduction to object oriented programming
Fundamentals of OOP (Object Oriented Programming)
Classes And Objects
OOPs concept and implementation
Introduction to Object-Oriented Programming & Design Principles (TCF 2014)
Lecture 2
OOP Basics
Object oriented programming With C#
Basic concepts of object oriented programming
OOP Introduction with java programming language
Object Oriented Concepts in Real Projects
Java object oriented programming concepts - Brainsmartlabs
Std 12 computer chapter 6 object oriented concepts (part 1)
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Introduction to oop with c++
Oops ppt
Ad

Viewers also liked (9)

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

Similar to Ruby OOP: Objects over Classes (20)

PDF
Aman kingrubyoo pnew
ODP
Intro Ruby Classes Part I
PPTX
Object-oriented in ruby
PDF
The Ruby Object Model by Rafael Magana
PPT
Ruby for C# Developers
PDF
RG OOP-talk
PDF
OOP vs COP
ZIP
Meta Programming in Ruby - Code Camp 2010
PDF
Workin On The Rails Road
DOCX
Ruby Interview Questions
PPTX
Ruby object model - Understanding of object play role for ruby
PDF
05 ruby classes
PDF
PPT
OOP intro.ppt
KEY
Ruby objects
PPTX
On the path to become a jr. developer short version
PDF
PDF
Object Oriented Programming_combined.ppt.pdf
PPTX
Object_Oriented_Programming_combined.ppt
Aman kingrubyoo pnew
Intro Ruby Classes Part I
Object-oriented in ruby
The Ruby Object Model by Rafael Magana
Ruby for C# Developers
RG OOP-talk
OOP vs COP
Meta Programming in Ruby - Code Camp 2010
Workin On The Rails Road
Ruby Interview Questions
Ruby object model - Understanding of object play role for ruby
05 ruby classes
OOP intro.ppt
Ruby objects
On the path to become a jr. developer short version
Object Oriented Programming_combined.ppt.pdf
Object_Oriented_Programming_combined.ppt

More from Aman King (9)

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

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
NewMind AI Monthly Chronicles - July 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Encapsulation theory and applications.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Electronic commerce courselecture one. Pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Spectral efficient network and resource selection model in 5G networks
NewMind AI Monthly Chronicles - July 2025
The AUB Centre for AI in Media Proposal.docx
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Encapsulation_ Review paper, used for researhc scholars
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Review of recent advances in non-invasive hemoglobin estimation
Electronic commerce courselecture one. Pdf
Empathic Computing: Creating Shared Understanding
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
A Presentation on Artificial Intelligence

Ruby OOP: Objects over Classes