0
OOP vs COPObjects against Classes
The beginning ...About a year ago, I said to a friend:"Why is it called OOP? It should be calledCOP as the classes are mor...
The beginning ...Some time later I saw this post of Uncle Bob"The Last programming Language" where hetalks about Clojure a...
The beginning ...            Then I discovered this book. At            the moment this is the best            book that I...
The beginning ...Then I began to study Ruby and work inJavascript.In Javascript the concept of class does notexist!In Ruby...
OOP - Rubyirb(main):001:0> a = [1, 2]=> [1, 2]irb(main):002:0> a.somma()NoMethodError: undefined method `somma for [1, 2]:...
OOP - Javascriptvar obj = {   type: "xxx",   color: "red",   getInfo: function () {      return this.type +  is  + this.co...
Language matters!?Is it just a language problem or is theresomething else?     Lets start from the beginning ...
Object Oriented ProgrammingWhat is it ?
OOP - Is it this?
OOP - or this?
OOP - OR THIS ????
Lets ask "Dad"...http://en.wikiquote.org/wiki/Alan_Kay"OOP to me means onlymessaging, local retention andprotection and hi...
So OOP is:●   Messaging●   Local retention & protection●   Hiding of State-process●   Extreme late binding
Where are the classes????
Where are the objects ?????
Lets ask Alan again...http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en"It was probably in 1967 when som...
Lets ask Alan again...http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-October/017019.html"Just a gentle remind...
Why OOP ...OOP creates a modular design that is easilymodified without having to restructure the entiresystem.
Why OOP ...Keeps large software projects manageable forhuman programmers
Why OOP ...Keeps large software projects manageable forhuman programmers via:Modularization - Decompose problem intosmalle...
Why OOP ...Keeps large software projects manageable forhuman programmers via:Abstraction -- Understandability - Terminolog...
Why OOP ...Keeps large software projects manageable forhuman programmers via:Encapsulation -- Information Hiding - Hidecom...
Why OOP ...Keeps large software projects manageable forhuman programmers via:Composability -- Structured Design - Interfac...
Why OOP ...Keeps large software projects manageable forhuman programmers via:Hierarchy - Incremental development fromsmall...
Why OOP ...Keeps large software projects manageable forhuman programmers via:Continuity - Changes and maintenance in onlya...
Why OOP ...ModularizationAbstractionEncapsulationComposabilityHierarchyContinuityetc ...
OOP could be this?
OOPThe strongest concept of OOP is "messaging",so while we are developing we shouldconcentrate on how the objects communic...
OOP - System LevelWhen we develop a system we should focuson:● Separation of concern● High level of abstraction
OOP - System LevelWe obtain a Hexagonal Architecture
OOP - Object LevelHow can we discover ports and adapters?●   Encapsulation●   Information Hiding●   Low Coupling●   High C...
OOP - Object LevelThe objects should have:●   Low Coupling●   High Cohesion●   Composite Simpler Than The Sum●   Context I...
OOP - Object LevelWe should compose the objects to describe thesystem, so we have:● Declarative Layer - Where the objects ...
And the classes???The classes are "the declarative layer of thedeclarative layer". The classes are "factories"for the obje...
OOP - Rubyirb(main):001:0> a = [1, 2]=> [1, 2]irb(main):002:0> a.somma()NoMethodError: undefined method `somma for [1, 2]:...
OOP - Javascriptvar obj = {   type: "xxx",   color: "red",   getInfo: function () {      return this.type +  is  + this.co...
OOP - Scheme(define (make-from-real-imag x y) (define (dispatch op)  (cond ((eq? op real-part) x)       ((eq? op imag-part...
OOP - Schemees:> (define x (make-from-real-imag 1 2))>x#<procedure:dispatch>> (x real-part)1> (x imag-part)2>
ExampleThere is a web server that exposes some APIsto manage playlists of images. We create adesktop program to manage the...
OOP vs COP            Thank YOU !!!twitter: https://twitter.com/#!/GPad619github: https://github.com/gpade-mail: gpadovani...
OOP vs COP
Upcoming SlideShare
Loading in...5
×

OOP vs COP

2,674

Published on

Are we using correctly OOP? Are we focus on the right "thing" when we are desiging and programming in OOP?

Published in: Education, Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,674
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
26
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "OOP vs COP"

  1. 1. OOP vs COPObjects against Classes
  2. 2. The beginning ...About a year ago, I said to a friend:"Why is it called OOP? It should be calledCOP as the classes are more important!"...my friend stopped saying "ciao" to me for amonth...he works in Python and Javascript!
  3. 3. The beginning ...Some time later I saw this post of Uncle Bob"The Last programming Language" where hetalks about Clojure and I read a phrase that lefta strong impression on me:Inheritance is not the only way to do polymorphism
  4. 4. The beginning ... Then I discovered this book. At the moment this is the best book that I have ever read about TDD and design ...
  5. 5. The beginning ...Then I began to study Ruby and work inJavascript.In Javascript the concept of class does notexist!In Ruby the objects are softer than in C# orJava.
  6. 6. OOP - Rubyirb(main):001:0> a = [1, 2]=> [1, 2]irb(main):002:0> a.somma()NoMethodError: undefined method `somma for [1, 2]:Array from (irb):2 from C:/Ruby192/bin/irb:12:in `<main>irb(main):003:0> def a.somma()irb(main):004:1> self.inject(:+)irb(main):005:1> end=> nilirb(main):006:0> a.somma=> 3irb(main):007:0>
  7. 7. OOP - Javascriptvar obj = { type: "xxx", color: "red", getInfo: function () { return this.type + is + this.color; }};obj.color = "black";alert(obj.getInfo());
  8. 8. Language matters!?Is it just a language problem or is theresomething else? Lets start from the beginning ...
  9. 9. Object Oriented ProgrammingWhat is it ?
  10. 10. OOP - Is it this?
  11. 11. OOP - or this?
  12. 12. OOP - OR THIS ????
  13. 13. Lets ask "Dad"...http://en.wikiquote.org/wiki/Alan_Kay"OOP to me means onlymessaging, local retention andprotection and hiding of state-process, and extreme late-binding of all things. It can bedone in Smalltalk and in LISP.There are possibly othersystems in which this ispossible, but Im not aware ofthem."
  14. 14. So OOP is:● Messaging● Local retention & protection● Hiding of State-process● Extreme late binding
  15. 15. Where are the classes????
  16. 16. Where are the objects ?????
  17. 17. Lets ask Alan again...http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en"It was probably in 1967 when someone asked me whatI was doing, and I said: Its object-oriented programming."[...]"I thought of objects being like biological cells and/orindividual computers on a network, only able tocommunicate with messages (so messaging came at thevery beginning -- it took a while to see how to domessaging in a programming language efficiently enoughto be useful)."
  18. 18. Lets ask Alan again...http://lists.squeakfoundation.org/pipermail/squeak-dev/1998-October/017019.html"Just a gentle reminder that I took some pains at the lastOOPSLA to try to remind everyone that Smalltalk is notonly NOT its syntax or the class library, it is not evenabout classes. Im sorry that I long ago coined the term"objects" for this topic because it gets many people tofocus on the lesser idea."The big idea is "messaging" [ ... ]
  19. 19. Why OOP ...OOP creates a modular design that is easilymodified without having to restructure the entiresystem.
  20. 20. Why OOP ...Keeps large software projects manageable forhuman programmers
  21. 21. Why OOP ...Keeps large software projects manageable forhuman programmers via:Modularization - Decompose problem intosmaller subproblems that can be solvedindependently.
  22. 22. Why OOP ...Keeps large software projects manageable forhuman programmers via:Abstraction -- Understandability - Terminologyof the problem domain is reflected in thesoftware solution. Individual modules areunderstandable by human readers.
  23. 23. Why OOP ...Keeps large software projects manageable forhuman programmers via:Encapsulation -- Information Hiding - Hidecomplexity from the user of a software or SDK.Protect low-level functionality
  24. 24. Why OOP ...Keeps large software projects manageable forhuman programmers via:Composability -- Structured Design - Interfacesallow modules to combine freely in order toproduce new systems.
  25. 25. Why OOP ...Keeps large software projects manageable forhuman programmers via:Hierarchy - Incremental development fromsmall and simple to more complex modules.
  26. 26. Why OOP ...Keeps large software projects manageable forhuman programmers via:Continuity - Changes and maintenance in onlya few modules does not affect the overallarchitecture.
  27. 27. Why OOP ...ModularizationAbstractionEncapsulationComposabilityHierarchyContinuityetc ...
  28. 28. OOP could be this?
  29. 29. OOPThe strongest concept of OOP is "messaging",so while we are developing we shouldconcentrate on how the objects communicatebetween themselves
  30. 30. OOP - System LevelWhen we develop a system we should focuson:● Separation of concern● High level of abstraction
  31. 31. OOP - System LevelWe obtain a Hexagonal Architecture
  32. 32. OOP - Object LevelHow can we discover ports and adapters?● Encapsulation● Information Hiding● Low Coupling● High Cohesion● Composite Simpler Than The Sum● Context Independence● Hide the correct information
  33. 33. OOP - Object LevelThe objects should have:● Low Coupling● High Cohesion● Composite Simpler Than The Sum● Context Independence● Hide the correct information
  34. 34. OOP - Object LevelWe should compose the objects to describe thesystem, so we have:● Declarative Layer - Where the objects are created and composed● Application Layer - Where the object communicates
  35. 35. And the classes???The classes are "the declarative layer of thedeclarative layer". The classes are "factories"for the objects. So you could have otherfactories for the objects...
  36. 36. OOP - Rubyirb(main):001:0> a = [1, 2]=> [1, 2]irb(main):002:0> a.somma()NoMethodError: undefined method `somma for [1, 2]:Array from (irb):2 from C:/Ruby192/bin/irb:12:in `<main>irb(main):003:0> def a.somma()irb(main):004:1> self.inject(:+)irb(main):005:1> end=> nilirb(main):006:0> a.somma=> 3irb(main):007:0>
  37. 37. OOP - Javascriptvar obj = { type: "xxx", color: "red", getInfo: function () { return this.type + is + this.color; }};obj.color = "black";alert(obj.getInfo());
  38. 38. OOP - Scheme(define (make-from-real-imag x y) (define (dispatch op) (cond ((eq? op real-part) x) ((eq? op imag-part) y) ((eq? op magnitude) (sqrt (+ (square x) (square y)))) ((eq? op angle) (atan y x)) (else (error "Unknown op -- MAKE-FROM-REAL-IMAG"op)))) dispatch)
  39. 39. OOP - Schemees:> (define x (make-from-real-imag 1 2))>x#<procedure:dispatch>> (x real-part)1> (x imag-part)2>
  40. 40. ExampleThere is a web server that exposes some APIsto manage playlists of images. We create adesktop program to manage these playlists ...server: https://github.com/gpad/rmsclient: https://github.com/gpad/PlayListManager
  41. 41. OOP vs COP Thank YOU !!!twitter: https://twitter.com/#!/GPad619github: https://github.com/gpade-mail: gpadovani@gmail.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×