• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
OOP vs COP
 

OOP vs COP

on

  • 2,586 views

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

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

Statistics

Views

Total Views
2,586
Views on SlideShare
2,576
Embed Views
10

Actions

Likes
3
Downloads
20
Comments
0

6 Embeds 10

http://us-w1.rockmelt.com 2
http://www.linkedin.com 2
https://twitter.com 2
http://www.php-talks.com 2
https://si0.twimg.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    OOP vs COP OOP vs COP Presentation Transcript

    • 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 more important!"...my friend stopped saying "ciao" to me for amonth...he works in Python and Javascript!
    • 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
    • The beginning ... Then I discovered this book. At the moment this is the best book that I have ever read about TDD and design ...
    • 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.
    • 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>
    • OOP - Javascriptvar obj = { type: "xxx", color: "red", getInfo: function () { return this.type + is + this.color; }};obj.color = "black";alert(obj.getInfo());
    • 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 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."
    • 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 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)."
    • 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" [ ... ]
    • 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 intosmaller subproblems that can be solvedindependently.
    • 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.
    • 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
    • Why OOP ...Keeps large software projects manageable forhuman programmers via:Composability -- Structured Design - Interfacesallow modules to combine freely in order toproduce new systems.
    • Why OOP ...Keeps large software projects manageable forhuman programmers via:Hierarchy - Incremental development fromsmall and simple to more complex modules.
    • Why OOP ...Keeps large software projects manageable forhuman programmers via:Continuity - Changes and maintenance in onlya few modules does not affect the overallarchitecture.
    • 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 communicatebetween themselves
    • 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 Cohesion● Composite Simpler Than The Sum● Context Independence● Hide the correct information
    • OOP - Object LevelThe objects should have:● Low Coupling● High Cohesion● Composite Simpler Than The Sum● Context Independence● Hide the correct information
    • 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
    • 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...
    • 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>
    • OOP - Javascriptvar obj = { type: "xxx", color: "red", getInfo: function () { return this.type + is + this.color; }};obj.color = "black";alert(obj.getInfo());
    • 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)
    • 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 these playlists ...server: https://github.com/gpad/rmsclient: https://github.com/gpad/PlayListManager
    • OOP vs COP Thank YOU !!!twitter: https://twitter.com/#!/GPad619github: https://github.com/gpade-mail: gpadovani@gmail.com