SlideShare a Scribd company logo
Objects, Objects
 Everywhere
    Mike Pack
     @zombidev
Let’s Talk Objects

  Behavior
     +
   State
Let’s Talk Objects
         Behavior

I’m a person, what can I do?
            Walk
            Talk
            Eat

 Could also be defined as:
          Move Legs
          Move Lips
         Ingest Food
Let’s Talk Objects
                 Behavior




Level of abstraction matters!
  Behavioral abstraction varies per domain.
Let’s Talk Objects
              State

I’m a person, who am I currently?
            Mike Pack
              Male
             Brown

  Therefore, I have attributes:
             Name
             Gender
            Hair Color
Let’s Talk Objects
              State



     States change
When I’m 70, my attributes might be:

            Mike Pack
              Male
              Grey
Let’s Talk Objects

 Behavior changes too!
I just learned to jump, now my behavior is:

                  Walk
                   Talk
                   Eat
                  Jump
Let’s Talk Objects

  Behavior
     +
   State
HTML

<div id=”name”>
  Mike
</div>
  Is this an object?
Attribute
       HTML         Name
<div id=”name”>
  Mike
</div>
  Is this an object?
Attribute
       HTML         Name
<div id=”name”>
  Mike
           State
</div>
  Is this an object?
Attribute
        HTML         Name
<div id=”name”>
  Mike the beef?
Where’s    State
</div>
   Is this an object?
Attribute
         HTML         Name
  <div id=”name”>
    Mike behavior?
Where’s the State
  </div>
    Is this an object?
HTML
<div id=”name”
   onclick=”...”>
  Mike
</div>
  Is this an object?
Attribute
       HTML         Name
<div id=”name”
   onclick=”...”>
  Mike      Behavior!
</div> State
  Is this an object?
HTML


               HTML is object oriented
                                (albeit, not for purist)




HTML does not exhibit other properties of an OO systems:
- Inheritance
- Polymorphism
- etc
HTML


         Don’t use onclick=”...”
However, without onclick, HTML does not exhibit behavior.
CSS

a{
  color: red;
}
 Is this an object?
CSS
        Attribute
a{       Name

  color: red;
}
 Is this an object?
CSS
        Attribute
a{       Name

  color: red;
}             State

 Is this an object?
CSS
          Attribute
 a{        Name

   color:the beef?
Where’s   red;
 }             State

   Is this an object?
CSS
a{
  color: red;
  &:hover {
    color: blue;
  }
}
Is this an object?
Attribute     CSS
 Name a {
          color: red; Behavior!
          &:hover {
            color: blue;
          }
                           State
      }
      Is this an object?
CSS
       a{
Behavior color: red;     State
         &:hover {      Change
           color: blue;
         }
       }
   Behavior changes state.
CSS


                  CSS is object oriented
                                      (not for purist)




CSS does not exhibit other properties of an OO systems:
- Inheritance
- Polymorphism
- etc
JavaScript
var book = {
 title: “The Art of
         War”
};
   Is this an object?
Attribute
 Name
            JavaScript
    var book = {
     title: “The Art of
             War”
    };
        Is this an object?
Attribute
 Name
            JavaScript
    var book = {
     title: “The Art of
             War” State
    };
        Is this an object?
Attribute
 Name
            JavaScript
   var book = {
    title: “The Art of
   Where’s the beef?
            War” State
   };
        Is this an object?
Attribute
 Name
            JavaScript
   var book = {
    title: “The Art of
   Where’s the beef?
          It’sWar”
              implicit! State
   };
        Is this an object?
JavaScript
var book = {
 title: “The Art of War”,
 constructor: function() {...},
 hasOwnProperty: function() {...},
 ...
};

      Implicit behavior.
JavaScript


JavaScript is object oriented
           (of course)
JavaScript


It’s not entirely object oriented
    JavaScript has primitives, too.
JavaScript


If it’s an object, typeof knows
   typeof {} === ‘object’ //=> true
JavaScript


Integers are not objects
typeof 1 === ‘object’ //=> false
JavaScript


  undefined is not an object
typeof undefined === ‘object’ //=> false
JavaScript


Literals are not always primitives
     typeof [] === ‘object’ //=> true
JavaScript

  typeof might not return object
     typeof true === ‘object’ //=> false
    typeof true === ‘boolean’ //=> true
         But booleans are objects!
new Boolean(1).valueOf() === true //=> true
JavaScript


Careful, typeof can bite
typeof null === ‘object’ //=> true
     new Null() //=> error
Ruby


       1

Is this an object?
Ruby        State
              (accessor)
     1
1.real #=> 1

Is this an object?
Ruby        State
              (accessor)
     1
1.real #=> 1
1 + 1 #=> 2
Is this an object?
Ruby        State
              1     (accessor)
       1.real #=> 1
Behavior 1 + 1 #=> 2
        1.+(1) #=> 2
      Is this an object?
Ruby


Ruby is object oriented
Ruby


Everything is an object
Ruby


Literal arrays are new objects
  [].object_id #=> 70318249770140
  [].object_id #=> 70318249594160
Ruby


Literal strings are new objects
‘slurpy’.object_id #=> 70318249561400
‘slurpy’.object_id #=> 70318249500340
Ruby


Literal hashes are new objects
   {}.object_id #=> 7019206373870
  {}.object_id #=> 70192063701240
Ruby


Literal regexs are new objects
  //.object_id #=> 70192063385520
  //.object_id #=> 70192067965040
Ruby


Literal ranges are new objects
 (1..2).object_id #=> 70192067946460
 (1..2).object_id #=> 70192067921120
Ruby


 Not everything creates a new
            object
Ruby has singleton objects (objects instantiated once).
Ruby


nil is a singleton
 nil.object_id #=> 4
 nil.object_id #=> 4
Ruby

booleans are singletons
   false.object_id #=> 0
   false.object_id #=> 0
    true.object_id #=> 2
    true.object_id #=> 2
Ruby


Numbers are singletons
    1.object_id #=> 3
    1.object_id #=> 3
Ruby

     um s
  xn
Fi Numbers are singletons
        1.object_id #=> 3
        1.object_id #=> 3
Ruby

Bignums are not singletons
4611686018427387904.object_id #=>
        70192063730740
4611686018427387904.object_id #=>
        70192063508580
Ruby

  Bignums are not singletons
 4611686018427387904.object_id #=>
         70192063730740
 4611686018427387904.object_id #=>
         70192063508580


Why 4611686018427387904?
bytes to store
               Ruby       integer
bytes = 0.size #=> 8
bytes to store
                Ruby          integer
bytes = 0.size #=> 8
                          8 bits per byte

bits = bytes * 8 #=> 64
                          64 bit machine
bytes to store
                Ruby          integer
bytes = 0.size #=> 8
                          8 bits per byte

bits = bytes * 8 #=> 64
                          64 bit machine

                        1 bit for sign
                       + 1 bit for Ruby
2 ** (bits - 2) #=>
4611686018427387904
Ruby
 4611686018427387904
         Bignum
     Different objects.


4611686018427387904 - 1
          Fixnum
      Singleton object.
Ruby

Why does nil have object_id of 4?

     1 have object_id of 3?

    true have object_id of 2?
Ruby
Because Matz says so
  false.object_id #=> 0
      0.object_id #=> 1
   true.object_id #=> 2
      1.object_id #=> 3
     nil.object_id #=> 4
      2.object_id #=> 5
Ruby
   Find by object_id
ObjectSpace._id2ref(0) #=> false
ObjectSpace._id2ref(1) #=> 0
ObjectSpace._id2ref(2) #=> true
ObjectSpace._id2ref(3) #=> 1
ObjectSpace._id2ref(4) #=> nil
ObjectSpace._id2ref(5) #=> 2
ObjectSpace._id2ref(6) #=> error
ObjectSpace._id2ref(7) #=> 3
ObjectSpace._id2ref(8) #=> error
Ruby

Negative object_ids
  -1.object_id #=> -1
  -2.object_id #=> -3
  -3.object_id #=> -5
Objects.useful? # => true
Objects.useful? # => true
Consistent modeling across the stack.
Objects.useful? # => true
Helpful in representing the real world.
Objects.useful? # => true
     Fun and expressive.
Thanks!
@zombidev

More Related Content

What's hot

Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with Eclipse
Peter Friese
 
Json
JsonJson
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
Vagmi Mudumbai
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Return on Intelligence
 
Ruby objects
Ruby objectsRuby objects
Ruby objects
Reuven Lerner
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 
jQuery
jQueryjQuery
03 Object Relational Mapping
03 Object Relational Mapping03 Object Relational Mapping
03 Object Relational Mapping
Ranjan Kumar
 

What's hot (8)

Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with Eclipse
 
Json
JsonJson
Json
 
Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Ruby objects
Ruby objectsRuby objects
Ruby objects
 
jQuery
jQueryjQuery
jQuery
 
jQuery
jQueryjQuery
jQuery
 
03 Object Relational Mapping
03 Object Relational Mapping03 Object Relational Mapping
03 Object Relational Mapping
 

Similar to Objects, Objects Everywhere

NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
lrdesign
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
Takuya Fujimura
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
techtalkdwango
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
Manish Jangir
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
Tarek Yehia
 
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
DevClub_lv
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
julien pauli
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worlds
Ignacio Martín
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
Andrew Hull
 
Javascript
JavascriptJavascript
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
Ruby Classes
Ruby ClassesRuby Classes
Ruby Classes
Daniel Berkompas
 
Interesting Facts About Javascript
Interesting Facts About JavascriptInteresting Facts About Javascript
Interesting Facts About Javascript
Manish Jangir
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
Evan Schultz
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hood
cowboyd
 
WDB005.1 - JavaScript for Java Developers (Lecture 1)
WDB005.1 - JavaScript for Java Developers (Lecture 1)WDB005.1 - JavaScript for Java Developers (Lecture 1)
WDB005.1 - JavaScript for Java Developers (Lecture 1)
Igor Khotin
 
Practical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSFPractical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSF
Alex Sharp
 
Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)
MongoSF
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
Ben Scheirman
 
Javascript
JavascriptJavascript
Javascript
Sunil Thakur
 

Similar to Objects, Objects Everywhere (20)

NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
 
第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript第7回みゆっき☆Think 本気で学ぶ JavaScript
第7回みゆっき☆Think 本気で学ぶ JavaScript
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
 
Understanding PHP objects
Understanding PHP objectsUnderstanding PHP objects
Understanding PHP objects
 
Symfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worldsSymfony & Javascript. Combining the best of two worlds
Symfony & Javascript. Combining the best of two worlds
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
 
Javascript
JavascriptJavascript
Javascript
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
Ruby Classes
Ruby ClassesRuby Classes
Ruby Classes
 
Interesting Facts About Javascript
Interesting Facts About JavascriptInteresting Facts About Javascript
Interesting Facts About Javascript
 
Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016Evan Schultz - Angular Summit - 2016
Evan Schultz - Angular Summit - 2016
 
The Ruby Racer: under the hood
The Ruby Racer: under the hoodThe Ruby Racer: under the hood
The Ruby Racer: under the hood
 
WDB005.1 - JavaScript for Java Developers (Lecture 1)
WDB005.1 - JavaScript for Java Developers (Lecture 1)WDB005.1 - JavaScript for Java Developers (Lecture 1)
WDB005.1 - JavaScript for Java Developers (Lecture 1)
 
Practical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSFPractical Ruby Projects with MongoDB - MongoSF
Practical Ruby Projects with MongoDB - MongoSF
 
Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)Practical Ruby Projects (Alex Sharp)
Practical Ruby Projects (Alex Sharp)
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
 
Javascript
JavascriptJavascript
Javascript
 

Recently uploaded

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 

Recently uploaded (20)

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 

Objects, Objects Everywhere

  • 1. Objects, Objects Everywhere Mike Pack @zombidev
  • 2. Let’s Talk Objects Behavior + State
  • 3. Let’s Talk Objects Behavior I’m a person, what can I do? Walk Talk Eat Could also be defined as: Move Legs Move Lips Ingest Food
  • 4. Let’s Talk Objects Behavior Level of abstraction matters! Behavioral abstraction varies per domain.
  • 5. Let’s Talk Objects State I’m a person, who am I currently? Mike Pack Male Brown Therefore, I have attributes: Name Gender Hair Color
  • 6. Let’s Talk Objects State States change When I’m 70, my attributes might be: Mike Pack Male Grey
  • 7. Let’s Talk Objects Behavior changes too! I just learned to jump, now my behavior is: Walk Talk Eat Jump
  • 8. Let’s Talk Objects Behavior + State
  • 9. HTML <div id=”name”> Mike </div> Is this an object?
  • 10. Attribute HTML Name <div id=”name”> Mike </div> Is this an object?
  • 11. Attribute HTML Name <div id=”name”> Mike State </div> Is this an object?
  • 12. Attribute HTML Name <div id=”name”> Mike the beef? Where’s State </div> Is this an object?
  • 13. Attribute HTML Name <div id=”name”> Mike behavior? Where’s the State </div> Is this an object?
  • 14. HTML <div id=”name” onclick=”...”> Mike </div> Is this an object?
  • 15. Attribute HTML Name <div id=”name” onclick=”...”> Mike Behavior! </div> State Is this an object?
  • 16. HTML HTML is object oriented (albeit, not for purist) HTML does not exhibit other properties of an OO systems: - Inheritance - Polymorphism - etc
  • 17. HTML Don’t use onclick=”...” However, without onclick, HTML does not exhibit behavior.
  • 18. CSS a{ color: red; } Is this an object?
  • 19. CSS Attribute a{ Name color: red; } Is this an object?
  • 20. CSS Attribute a{ Name color: red; } State Is this an object?
  • 21. CSS Attribute a{ Name color:the beef? Where’s red; } State Is this an object?
  • 22. CSS a{ color: red; &:hover { color: blue; } } Is this an object?
  • 23. Attribute CSS Name a { color: red; Behavior! &:hover { color: blue; } State } Is this an object?
  • 24. CSS a{ Behavior color: red; State &:hover { Change color: blue; } } Behavior changes state.
  • 25. CSS CSS is object oriented (not for purist) CSS does not exhibit other properties of an OO systems: - Inheritance - Polymorphism - etc
  • 26. JavaScript var book = { title: “The Art of War” }; Is this an object?
  • 27. Attribute Name JavaScript var book = { title: “The Art of War” }; Is this an object?
  • 28. Attribute Name JavaScript var book = { title: “The Art of War” State }; Is this an object?
  • 29. Attribute Name JavaScript var book = { title: “The Art of Where’s the beef? War” State }; Is this an object?
  • 30. Attribute Name JavaScript var book = { title: “The Art of Where’s the beef? It’sWar” implicit! State }; Is this an object?
  • 31. JavaScript var book = { title: “The Art of War”, constructor: function() {...}, hasOwnProperty: function() {...}, ... }; Implicit behavior.
  • 32. JavaScript JavaScript is object oriented (of course)
  • 33. JavaScript It’s not entirely object oriented JavaScript has primitives, too.
  • 34. JavaScript If it’s an object, typeof knows typeof {} === ‘object’ //=> true
  • 35. JavaScript Integers are not objects typeof 1 === ‘object’ //=> false
  • 36. JavaScript undefined is not an object typeof undefined === ‘object’ //=> false
  • 37. JavaScript Literals are not always primitives typeof [] === ‘object’ //=> true
  • 38. JavaScript typeof might not return object typeof true === ‘object’ //=> false typeof true === ‘boolean’ //=> true But booleans are objects! new Boolean(1).valueOf() === true //=> true
  • 39. JavaScript Careful, typeof can bite typeof null === ‘object’ //=> true new Null() //=> error
  • 40. Ruby 1 Is this an object?
  • 41. Ruby State (accessor) 1 1.real #=> 1 Is this an object?
  • 42. Ruby State (accessor) 1 1.real #=> 1 1 + 1 #=> 2 Is this an object?
  • 43. Ruby State 1 (accessor) 1.real #=> 1 Behavior 1 + 1 #=> 2 1.+(1) #=> 2 Is this an object?
  • 46. Ruby Literal arrays are new objects [].object_id #=> 70318249770140 [].object_id #=> 70318249594160
  • 47. Ruby Literal strings are new objects ‘slurpy’.object_id #=> 70318249561400 ‘slurpy’.object_id #=> 70318249500340
  • 48. Ruby Literal hashes are new objects {}.object_id #=> 7019206373870 {}.object_id #=> 70192063701240
  • 49. Ruby Literal regexs are new objects //.object_id #=> 70192063385520 //.object_id #=> 70192067965040
  • 50. Ruby Literal ranges are new objects (1..2).object_id #=> 70192067946460 (1..2).object_id #=> 70192067921120
  • 51. Ruby Not everything creates a new object Ruby has singleton objects (objects instantiated once).
  • 52. Ruby nil is a singleton nil.object_id #=> 4 nil.object_id #=> 4
  • 53. Ruby booleans are singletons false.object_id #=> 0 false.object_id #=> 0 true.object_id #=> 2 true.object_id #=> 2
  • 54. Ruby Numbers are singletons 1.object_id #=> 3 1.object_id #=> 3
  • 55. Ruby um s xn Fi Numbers are singletons 1.object_id #=> 3 1.object_id #=> 3
  • 56. Ruby Bignums are not singletons 4611686018427387904.object_id #=> 70192063730740 4611686018427387904.object_id #=> 70192063508580
  • 57. Ruby Bignums are not singletons 4611686018427387904.object_id #=> 70192063730740 4611686018427387904.object_id #=> 70192063508580 Why 4611686018427387904?
  • 58. bytes to store Ruby integer bytes = 0.size #=> 8
  • 59. bytes to store Ruby integer bytes = 0.size #=> 8 8 bits per byte bits = bytes * 8 #=> 64 64 bit machine
  • 60. bytes to store Ruby integer bytes = 0.size #=> 8 8 bits per byte bits = bytes * 8 #=> 64 64 bit machine 1 bit for sign + 1 bit for Ruby 2 ** (bits - 2) #=> 4611686018427387904
  • 61. Ruby 4611686018427387904 Bignum Different objects. 4611686018427387904 - 1 Fixnum Singleton object.
  • 62. Ruby Why does nil have object_id of 4? 1 have object_id of 3? true have object_id of 2?
  • 63. Ruby Because Matz says so false.object_id #=> 0 0.object_id #=> 1 true.object_id #=> 2 1.object_id #=> 3 nil.object_id #=> 4 2.object_id #=> 5
  • 64. Ruby Find by object_id ObjectSpace._id2ref(0) #=> false ObjectSpace._id2ref(1) #=> 0 ObjectSpace._id2ref(2) #=> true ObjectSpace._id2ref(3) #=> 1 ObjectSpace._id2ref(4) #=> nil ObjectSpace._id2ref(5) #=> 2 ObjectSpace._id2ref(6) #=> error ObjectSpace._id2ref(7) #=> 3 ObjectSpace._id2ref(8) #=> error
  • 65. Ruby Negative object_ids -1.object_id #=> -1 -2.object_id #=> -3 -3.object_id #=> -5
  • 67. Objects.useful? # => true Consistent modeling across the stack.
  • 68. Objects.useful? # => true Helpful in representing the real world.
  • 69. Objects.useful? # => true Fun and expressive.