SlideShare a Scribd company logo
OOPS v2.0.0-rc.1
Aditya Godbole

@aagdbl
Definitions
• Type - Set of methods

• Subtype(T) - Superset methods of the type T

• Class - Implementation of type + properties of
implementing object
Maintainability
Maintainability
Re-use
Maintainability
Re-use
of?
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
Behaviour
(not data)
Maintainability
Maintainability
• Re-use of behaviour
Maintainability
• Re-use of behaviour
• Typing and Sub-typing
Axes of maintainability
Axes of maintainability
Don’t repeat

yourself

(DRY)
Axes of maintainability
Don’t repeat

yourself

(DRY)
Axes of maintainability
Don’t repeat

yourself

(DRY)
Don’t shoot yourself

(DSY)
Maintainability
• Re-use of behaviour

• Sub-typing
Maintainability
• Re-use of behaviour

• Sub-typing Granularity
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
Composability
• Behaviour - Inject behaviour from multiple
sources

• Types - Create superset types by combining
smaller types
Classes
• Re-use

• Multiple inheritance 

• Subtyping (Polymorphism)

• Multiple inheritance
Interfaces
Interfaces
• Type definitions
Interfaces
• Type definitions
• Composable
DRY
DSY
Classes / 

Inheritance
Interfaces
Java?
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
Ruby?
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
Ruby?
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
Ruby?
Interfaces?
gem install rubycube
require “cube”
Composable Units of
BEhaviour
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
Ruby
Interfaces
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
Ruby
Interfaces
DRY
DSY
Classes / 

Inheritance
Interfaces
Mixins /

Modules
Java?
Ruby
Interfaces
??
Conflicts
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
required interface
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
(sum, pos, fact)
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
AdvancedCalc =
SimpleCalcImpl
ProductCalcT
StatsCalcT
- [:product]
+
+
=> AdvancedCalculator
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby
Using Traits
• Structural classes - Enforce structural integrity.

• Identify interactions - Create smallest possible
interface

• Traits should be smaller or equal to interfaces

• If required - extend structural class to create
glue class for required interface

• Compose using traits
Specs
• Rspec “shared_examples”

• Compose specs using “it_behaves_like”
Also achievable …
• Java 8+

• Golang
DRY
DSY
Java 8
Interfaces
Traits
Ruby Go
__/__
https://github.com/adityagodbole/rubycube

gem install rubycube

(please go and read the traits paper)

More Related Content

PDF
Micro-service architectures with Gilmour
PPTX
Tsunami
PPTX
fileE_1722655797_5000762_Unit-1OOPS.pptx
PDF
Ruby Programming Assignment Help
PDF
Ruby Programming Assignment Help
KEY
Module Magic
PPTX
Object oriented programming
PPT
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثانية
Micro-service architectures with Gilmour
Tsunami
fileE_1722655797_5000762_Unit-1OOPS.pptx
Ruby Programming Assignment Help
Ruby Programming Assignment Help
Module Magic
Object oriented programming
شرح مقرر البرمجة 2 لغة جافا - الوحدة الثانية

Similar to OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby (20)

PPTX
OOP_in_CPP_Animesh_Animated_Diagram.pptx
PDF
OOP vs COP
PPTX
6 Object Oriented Programming
PPTX
Object-oriented in ruby
PDF
A COMPLETE FILE FOR C++
PDF
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
PDF
Classboxes, nested methods, and real private methods
PPTX
Concepts of oops
KEY
Metaprogramming Primer (Part 1)
PPTX
SKILLWISE - OOPS CONCEPT
PPTX
C++ first s lide
PDF
Ruby and rails - Advanced Training (Cybage)
PPT
oops-1
PPT
Unit i
ODP
Expression problem
PPTX
Object Oriented Programming - Basic Concepts
PPT
Data structure and problem solving ch02.ppt
PDF
Type Profiler: An Analysis to guess type signatures
PDF
Effective Object Oriented Design in Cpp
KEY
Ruby objects
OOP_in_CPP_Animesh_Animated_Diagram.pptx
OOP vs COP
6 Object Oriented Programming
Object-oriented in ruby
A COMPLETE FILE FOR C++
conceptsinobjectorientedprogramminglanguages-12659959597745-phpapp02.pdf
Classboxes, nested methods, and real private methods
Concepts of oops
Metaprogramming Primer (Part 1)
SKILLWISE - OOPS CONCEPT
C++ first s lide
Ruby and rails - Advanced Training (Cybage)
oops-1
Unit i
Expression problem
Object Oriented Programming - Basic Concepts
Data structure and problem solving ch02.ppt
Type Profiler: An Analysis to guess type signatures
Effective Object Oriented Design in Cpp
Ruby objects
Ad

Recently uploaded (20)

PDF
Nekopoi APK 2025 free lastest update
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
ai tools demonstartion for schools and inter college
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Digital Strategies for Manufacturing Companies
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Transform Your Business with a Software ERP System
PDF
System and Network Administraation Chapter 3
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How Creative Agencies Leverage Project Management Software.pdf
Nekopoi APK 2025 free lastest update
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
ai tools demonstartion for schools and inter college
Wondershare Filmora 15 Crack With Activation Key [2025
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Reimagine Home Health with the Power of Agentic AI​
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Digital Strategies for Manufacturing Companies
PTS Company Brochure 2025 (1).pdf.......
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Design an Analysis of Algorithms I-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Transform Your Business with a Software ERP System
System and Network Administraation Chapter 3
Operating system designcfffgfgggggggvggggggggg
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How Creative Agencies Leverage Project Management Software.pdf
Ad

OOPS v2.0.0-rc.1 - Interfaces and Traits for Ruby