SlideShare a Scribd company logo
< StartupDecode workshop : #02 /> 
Object Oriented Programming 
with Ruby 
Amine Sadry 
@donaminos 
www.startupdecode.com 
meetup.com/startupDecode @startupdecode /startupDecode /user/startupDecode
< Program /> 
1. What is Programming ? 
2. OOP Principle 
3. Hands-on Ruby 
4. Encapsulation 
5. Inheritance 
6. polymorphism 
7. Apéro Networking 
www.startupdecode.com
What is 
programming?
< Machine language /> 
www.startupdecode.com
< Assembler language /> 
www.startupdecode.com 
2000 DEF PROCasm(pass,org) 
2010 P%=org 
2020 [ OPT pass 
2030 ADR R0, message 
2040 SWI OS_Write0 
2050 MOV PC, R14 
2060 .message 
2070 EQUS "Hello, World!" + CHR$(0) 
2080 ALIGN 
2090 ] 
2100 ENDPROC 
1000 REM Hello World using a mix of 
BBC Basic and ARM assembler 
1010 DIM org 100 
1020 OS_Write0 = &2 
1030 FOR pass=0 TO 3 STEP 3 
1040 PROCasm(pass,org) 
1050 NEXT pass 
1060 CALL org 
1070 END 
1080
< High-level language /> 
void main (void) 
{ 
printf ("Hello n"); 
if ( x == y ) 
printf("x equal y n"); 
} 
www.startupdecode.com 
10100110 
01010001 
11100101 
Compile
< Procedural programming /> 
main(){ 
var data1, data2; 
procedure_1(); 
procedure_2(data1); 
procedure_3(data1, data2); 
print data2; 
} 
www.startupdecode.com 
procedure_1(){ 
... 
} 
procedure_2(param){ 
…. 
} 
procedure_3(p1, p2){ 
…. 
}
Object Oriented 
Programming
< OOP principle 1/3 /> 
www.startupdecode.com 
Properties: 
● Brand 
● Color 
Actions: 
● Strart 
● Accelerate 
● Stop
< OOP principle 2/3 /> 
www.startupdecode.com 
Properties: 
● Name 
● Email 
● … 
Actions: 
● Move 
● Text 
● …
< OOP principle 3/3 /> 
www.startupdecode.com 
Class 
Attributes 
Methods
Hands-on Ruby
< Classes & objects /> 
Create a class Create an object Get object info 
class User 
... 
end 
www.startupdecode.com 
me = User.new 
puts me.class 
puts me.object_id
< Ruby code /> 
www.startupdecode.com
Encapsulation
< Encapsulation 1/2 /> 
www.startupdecode.com 
class User 
def name(name) 
@name = name 
end 
def name 
@name 
end 
end
< Ruby code /> 
www.startupdecode.com
< Encapsulation 2/2 /> 
class User 
def set_name(name) 
www.startupdecode.com 
@name = name 
end 
def get_name 
@name 
end 
end 
class User 
attr_accessor :name 
end 
class User 
attr_reader :name 
attr_writer :name 
end
< Ruby code /> 
www.startupdecode.com
Inheritance
< Inheritance /> 
www.startupdecode.com 
B 
A 
C 
A A
< Inheritance /> 
class User 
attr_accessor :name 
def login 
“I logged in!” 
end 
def logout 
“I logged out!” 
end 
end 
www.startupdecode.com 
class Freelance < User 
def add_resume 
“I added a resume!” 
end 
end 
class Entreprise < User 
def add_offer 
“I added an offer!” 
end 
end
< Ruby code /> 
www.startupdecode.com
Polymorphism
< Polymorphism /> 
www.startupdecode.com 
B 
A 
C 
A’ A”
< Polymorphism /> 
class User 
def login 
“I logged in!” 
end 
def logout 
“I logged out!” 
end 
def signup 
www.startupdecode.com 
“Basic signup!” 
end 
end 
class Freelance < User 
def add_resume 
“I added a resume!” 
end 
def signup 
“Free to signup!” 
end 
end
< Polymorphism /> 
class User 
def login 
“I logged in!” 
end 
def logout 
“I logged out!” 
end 
def signup 
www.startupdecode.com 
“Basic signup!” 
end 
end 
class Entreprise < User 
def add_offer 
“I added an offer!” 
end 
def signup 
“100$ to signup!” 
end 
end
< Ruby code /> 
www.startupdecode.com
< StartupDecode /> 
Next workshop: 
HTML 5 
A bientôt 
meetup.com/startupDecode @startupdecode /startupDecode /user/startupDecode

More Related Content

What's hot

Up & running with jasmine
Up & running with jasmineUp & running with jasmine
Up & running with jasmine
kamarul kawnayeen
 
Vue.js for beginners
Vue.js for beginnersVue.js for beginners
Vue.js for beginners
Julio Bitencourt
 
Bleeding edge web stuff
Bleeding edge web stuffBleeding edge web stuff
Bleeding edge web stuff
Niranjan Prithviraj
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteer
VodqaBLR
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
andyyou
 
Jquery
JqueryJquery
Jquery
chauhankapil
 
Ansible Configuring Windows
Ansible Configuring WindowsAnsible Configuring Windows
Ansible Configuring Windows
joehack3r
 
Gordian knot presentation
Gordian knot presentationGordian knot presentation
Gordian knot presentation
Jim Osowski
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - Ecosystem
Lucas Renan
 
Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
Emil Öberg
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
mattysmith
 
Infinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
Infinum Android Talks #17 - A quest for WebSockets by Zeljko PlesacInfinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
Infinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
Infinum
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
Sebastiano Armeli
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
Caldera Labs
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
Dragos Mihai Rusu
 
Ruby On Rails Starter Kit
Ruby On Rails Starter KitRuby On Rails Starter Kit
Ruby On Rails Starter Kit
El Orabi Mohamed Ikbal
 
Docker + Azure DevOps = Pipeline for Jekyll sites
Docker + Azure DevOps = Pipeline for Jekyll sitesDocker + Azure DevOps = Pipeline for Jekyll sites
Docker + Azure DevOps = Pipeline for Jekyll sites
Victor Silva
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
David Ličen
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
irfan1008
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
Paddy Lock
 

What's hot (20)

Up & running with jasmine
Up & running with jasmineUp & running with jasmine
Up & running with jasmine
 
Vue.js for beginners
Vue.js for beginnersVue.js for beginners
Vue.js for beginners
 
Bleeding edge web stuff
Bleeding edge web stuffBleeding edge web stuff
Bleeding edge web stuff
 
Drive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteerDrive chrome(headless) with puppeteer
Drive chrome(headless) with puppeteer
 
Vue 淺談前端建置工具
Vue 淺談前端建置工具Vue 淺談前端建置工具
Vue 淺談前端建置工具
 
Jquery
JqueryJquery
Jquery
 
Ansible Configuring Windows
Ansible Configuring WindowsAnsible Configuring Windows
Ansible Configuring Windows
 
Gordian knot presentation
Gordian knot presentationGordian knot presentation
Gordian knot presentation
 
Be Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - EcosystemBe Happy With Ruby on Rails - Ecosystem
Be Happy With Ruby on Rails - Ecosystem
 
Webpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JSWebpack Tutorial, Uppsala JS
Webpack Tutorial, Uppsala JS
 
webpack 101 slides
webpack 101 slideswebpack 101 slides
webpack 101 slides
 
Infinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
Infinum Android Talks #17 - A quest for WebSockets by Zeljko PlesacInfinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
Infinum Android Talks #17 - A quest for WebSockets by Zeljko Plesac
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
 
Introduction to AJAX In WordPress
Introduction to AJAX In WordPressIntroduction to AJAX In WordPress
Introduction to AJAX In WordPress
 
AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.AngularJS - Overcoming performance issues. Limits.
AngularJS - Overcoming performance issues. Limits.
 
Ruby On Rails Starter Kit
Ruby On Rails Starter KitRuby On Rails Starter Kit
Ruby On Rails Starter Kit
 
Docker + Azure DevOps = Pipeline for Jekyll sites
Docker + Azure DevOps = Pipeline for Jekyll sitesDocker + Azure DevOps = Pipeline for Jekyll sites
Docker + Azure DevOps = Pipeline for Jekyll sites
 
VueJS Introduction
VueJS IntroductionVueJS Introduction
VueJS Introduction
 
Cache for community edition
Cache for community editionCache for community edition
Cache for community edition
 
An Introduction to Vuejs
An Introduction to VuejsAn Introduction to Vuejs
An Introduction to Vuejs
 

Similar to Object-Oriented Programming & Ruby

Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
OKLABS
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
Nick Plante
 
Baruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion WorkshopBaruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion Workshop
Brian Sam-Bodden
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
Edorian
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
Commit University
 
WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
Ziad Saab
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
rstankov
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
Tatsuhiko Miyagawa
 
Ruby For Startups
Ruby For StartupsRuby For Startups
Ruby For Startups
Mike Subelsky
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
James Titcumb
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
James Titcumb
 
Ruby seen by a C# developer
Ruby seen by a C# developerRuby seen by a C# developer
Ruby seen by a C# developer
Emanuele DelBono
 
Ruby seen from a C# developer
Ruby seen from a C# developerRuby seen from a C# developer
Ruby seen from a C# developer
Codemotion
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
Sachirou Inoue
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
som_nangia
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
wilburlo
 
Monkeybars in the Manor
Monkeybars in the ManorMonkeybars in the Manor
Monkeybars in the Manor
martinbtt
 
A Docker-based Development Environment Even I Can Understand
A Docker-based Development Environment Even I Can UnderstandA Docker-based Development Environment Even I Can Understand
A Docker-based Development Environment Even I Can Understand
Jeremy Gimbel
 
Release responsibly (Maintaining Backwards Compatibility)
Release responsibly (Maintaining Backwards Compatibility)Release responsibly (Maintaining Backwards Compatibility)
Release responsibly (Maintaining Backwards Compatibility)
Emily Stolfo
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
James Titcumb
 

Similar to Object-Oriented Programming & Ruby (20)

Docker Introduction.pdf
Docker Introduction.pdfDocker Introduction.pdf
Docker Introduction.pdf
 
Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
Baruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion WorkshopBaruco 2014 - Rubymotion Workshop
Baruco 2014 - Rubymotion Workshop
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
WordCamp Montreal 2016 WP-API + React with server rendering
WordCamp Montreal 2016  WP-API + React with server renderingWordCamp Montreal 2016  WP-API + React with server rendering
WordCamp Montreal 2016 WP-API + React with server rendering
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Plack - LPW 2009
Plack - LPW 2009Plack - LPW 2009
Plack - LPW 2009
 
Ruby For Startups
Ruby For StartupsRuby For Startups
Ruby For Startups
 
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP Srbija 2017)
 
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
Kicking off with Zend Expressive and Doctrine ORM (PHP UK 2017)
 
Ruby seen by a C# developer
Ruby seen by a C# developerRuby seen by a C# developer
Ruby seen by a C# developer
 
Ruby seen from a C# developer
Ruby seen from a C# developerRuby seen from a C# developer
Ruby seen from a C# developer
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
 
Monkeybars in the Manor
Monkeybars in the ManorMonkeybars in the Manor
Monkeybars in the Manor
 
A Docker-based Development Environment Even I Can Understand
A Docker-based Development Environment Even I Can UnderstandA Docker-based Development Environment Even I Can Understand
A Docker-based Development Environment Even I Can Understand
 
Release responsibly (Maintaining Backwards Compatibility)
Release responsibly (Maintaining Backwards Compatibility)Release responsibly (Maintaining Backwards Compatibility)
Release responsibly (Maintaining Backwards Compatibility)
 
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
Kicking off with Zend Expressive and Doctrine ORM (Sunshine PHP 2017)
 

Recently uploaded

快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
3a0sd7z3
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
thezot
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
xjq03c34
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
Donato Onofri
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
APNIC
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
k4ncd0z
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
Tarandeep Singh
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
rtunex8r
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
3a0sd7z3
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
APNIC
 

Recently uploaded (12)

快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
快速办理(新加坡SMU毕业证书)新加坡管理大学毕业证文凭证书一模一样
 
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
一比一原版新西兰林肯大学毕业证(Lincoln毕业证书)学历如何办理
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
办理新西兰奥克兰大学毕业证学位证书范本原版一模一样
 
HijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process HollowingHijackLoader Evolution: Interactive Process Hollowing
HijackLoader Evolution: Interactive Process Hollowing
 
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
Honeypots Unveiled: Proactive Defense Tactics for Cyber Security, Phoenix Sum...
 
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理一比一原版(USYD毕业证)悉尼大学毕业证如何办理
一比一原版(USYD毕业证)悉尼大学毕业证如何办理
 
Bengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal BrandingBengaluru Dreamin' 24 - Personal Branding
Bengaluru Dreamin' 24 - Personal Branding
 
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
怎么办理(umiami毕业证书)美国迈阿密大学毕业证文凭证书实拍图原版一模一样
 
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
快速办理(Vic毕业证书)惠灵顿维多利亚大学毕业证完成信一模一样
 
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...Securing BGP: Operational Strategies and Best Practices for Network Defenders...
Securing BGP: Operational Strategies and Best Practices for Network Defenders...
 

Object-Oriented Programming & Ruby

  • 1. < StartupDecode workshop : #02 /> Object Oriented Programming with Ruby Amine Sadry @donaminos www.startupdecode.com meetup.com/startupDecode @startupdecode /startupDecode /user/startupDecode
  • 2. < Program /> 1. What is Programming ? 2. OOP Principle 3. Hands-on Ruby 4. Encapsulation 5. Inheritance 6. polymorphism 7. Apéro Networking www.startupdecode.com
  • 4. < Machine language /> www.startupdecode.com
  • 5. < Assembler language /> www.startupdecode.com 2000 DEF PROCasm(pass,org) 2010 P%=org 2020 [ OPT pass 2030 ADR R0, message 2040 SWI OS_Write0 2050 MOV PC, R14 2060 .message 2070 EQUS "Hello, World!" + CHR$(0) 2080 ALIGN 2090 ] 2100 ENDPROC 1000 REM Hello World using a mix of BBC Basic and ARM assembler 1010 DIM org 100 1020 OS_Write0 = &2 1030 FOR pass=0 TO 3 STEP 3 1040 PROCasm(pass,org) 1050 NEXT pass 1060 CALL org 1070 END 1080
  • 6. < High-level language /> void main (void) { printf ("Hello n"); if ( x == y ) printf("x equal y n"); } www.startupdecode.com 10100110 01010001 11100101 Compile
  • 7. < Procedural programming /> main(){ var data1, data2; procedure_1(); procedure_2(data1); procedure_3(data1, data2); print data2; } www.startupdecode.com procedure_1(){ ... } procedure_2(param){ …. } procedure_3(p1, p2){ …. }
  • 9. < OOP principle 1/3 /> www.startupdecode.com Properties: ● Brand ● Color Actions: ● Strart ● Accelerate ● Stop
  • 10. < OOP principle 2/3 /> www.startupdecode.com Properties: ● Name ● Email ● … Actions: ● Move ● Text ● …
  • 11. < OOP principle 3/3 /> www.startupdecode.com Class Attributes Methods
  • 13. < Classes & objects /> Create a class Create an object Get object info class User ... end www.startupdecode.com me = User.new puts me.class puts me.object_id
  • 14. < Ruby code /> www.startupdecode.com
  • 16. < Encapsulation 1/2 /> www.startupdecode.com class User def name(name) @name = name end def name @name end end
  • 17. < Ruby code /> www.startupdecode.com
  • 18. < Encapsulation 2/2 /> class User def set_name(name) www.startupdecode.com @name = name end def get_name @name end end class User attr_accessor :name end class User attr_reader :name attr_writer :name end
  • 19. < Ruby code /> www.startupdecode.com
  • 21. < Inheritance /> www.startupdecode.com B A C A A
  • 22. < Inheritance /> class User attr_accessor :name def login “I logged in!” end def logout “I logged out!” end end www.startupdecode.com class Freelance < User def add_resume “I added a resume!” end end class Entreprise < User def add_offer “I added an offer!” end end
  • 23. < Ruby code /> www.startupdecode.com
  • 25. < Polymorphism /> www.startupdecode.com B A C A’ A”
  • 26. < Polymorphism /> class User def login “I logged in!” end def logout “I logged out!” end def signup www.startupdecode.com “Basic signup!” end end class Freelance < User def add_resume “I added a resume!” end def signup “Free to signup!” end end
  • 27. < Polymorphism /> class User def login “I logged in!” end def logout “I logged out!” end def signup www.startupdecode.com “Basic signup!” end end class Entreprise < User def add_offer “I added an offer!” end def signup “100$ to signup!” end end
  • 28. < Ruby code /> www.startupdecode.com
  • 29. < StartupDecode /> Next workshop: HTML 5 A bientôt meetup.com/startupDecode @startupdecode /startupDecode /user/startupDecode