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
oops-123991513147-phpapp02.pdf
DOCX
Object oriented programming tutorial
PPTX
Object oriented programming CLASSES-AND-OBJECTS.pptx
PPTX
Object Oriented Programming Tutorial.pptx
PPT
Object -oriented analysis and design.ppt
PPTX
Chapter 8 java
PDF
Object oriented programming
ODP
Intro Ruby Classes Part I
PDF
Unit 3-Classes ,Objects and Inheritance.pdf
PDF
Java programming -Object-Oriented Thinking- Inheritance
PDF
2.oop concept
PDF
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
PPTX
01. design pattern
PPT
Object and Classes in Java
PPTX
Abstraction in java [abstract classes and Interfaces
PPTX
Lecture 5.pptx
PPTX
Unusual C# - OOP
PPTX
Java interfaces
PDF
The Ruby Object Model by Rafael Magana
oops-123991513147-phpapp02.pdf
Object oriented programming tutorial
Object oriented programming CLASSES-AND-OBJECTS.pptx
Object Oriented Programming Tutorial.pptx
Object -oriented analysis and design.ppt
Chapter 8 java
Object oriented programming
Intro Ruby Classes Part I
Unit 3-Classes ,Objects and Inheritance.pdf
Java programming -Object-Oriented Thinking- Inheritance
2.oop concept
CS8392-OOPS-Printed-Notes-All-Units.pdf for students
01. design pattern
Object and Classes in Java
Abstraction in java [abstract classes and Interfaces
Lecture 5.pptx
Unusual C# - OOP
Java interfaces
The Ruby Object Model by Rafael Magana

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
Chapter 3 Spatial Domain Image Processing.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
madgavkar20181017ppt McKinsey Presentation.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Understanding_Digital_Forensics_Presentation.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Sensors and Actuators in IoT Systems using pdf
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Per capita expenditure prediction using model stacking based on satellite ima...
GamePlan Trading System Review: Professional Trader's Honest Take
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Transforming Manufacturing operations through Intelligent Integrations
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf

Ruby OOP: Objects over Classes