SlideShare a Scribd company logo
OOP vs COP
Objects against Classes
The beginning ...
About a year ago, I said to a friend:

"Why is it called 'OOP'? It should be called
'COP' as the classes are more important!"

...my friend stopped saying "ciao" to me for a
month...he works in Python and Javascript!
The beginning ...
Some time later I saw this post of Uncle Bob
"The Last programming Language" where he
talks about Clojure and I read a phrase that left
a 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 in
Javascript.

In Javascript the concept of class does not
exist!

In Ruby the objects are softer than in C# or
Java.
OOP - Ruby
irb(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
=> nil
irb(main):006:0> a.somma
=> 3
irb(main):007:0>
OOP - Javascript
var 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 there
something else?




     Let's start from the beginning ...
Object Oriented Programming
What is it ?
OOP - Is it this?
OOP - or this?
OOP - OR THIS ????
Let's ask "Dad"...
http://en.wikiquote.org/wiki/Alan_Kay
"OOP to me means only
messaging, local retention and
protection and hiding of state-
process, and extreme late-
binding of all things. It can be
done in Smalltalk and in LISP.
There are possibly other
systems in which this is
possible, but I'm not aware of
them."
So OOP is:
●   Messaging
●   Local retention & protection
●   Hiding of State-process
●   Extreme late binding
Where are the classes????
Where are the objects ?????
Let's ask Alan again...
http://userpage.fu-berlin.
de/~ram/pub/pub_jf47ht81Ht/doc_kay_oo
p_en


"It was probably in 1967 when someone asked me what
I was doing, and I said: 'It's object-oriented programming'."
[...]
"I thought of objects being like biological cells and/or
individual computers on a network, only able to
communicate with messages (so messaging came at the
very beginning -- it took a while to see how to do
messaging in a programming language efficiently enough
to be useful)."
Let's 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 last
OOPSLA to try to remind everyone that Smalltalk is not
only NOT its syntax or the class library, it is not even
about classes. I'm sorry that I long ago coined the term
"objects" for this topic because it gets many people to
focus on the lesser idea."


The big idea is "messaging" [ ... ]
Why OOP ...
OOP creates a modular design that is easily
modified without having to restructure the entire
system.
Why OOP ...
Keeps large software projects manageable for
human programmers
Why OOP ...
Keeps large software projects manageable for
human programmers via:

Modularization - Decompose problem into
smaller subproblems that can be solved
independently.
Why OOP ...
Keeps large software projects manageable for
human programmers via:

Abstraction -- Understandability - Terminology
of the problem domain is reflected in the
software solution. Individual modules are
understandable by human readers.
Why OOP ...
Keeps large software projects manageable for
human programmers via:

Encapsulation -- Information Hiding - Hide
complexity from the user of a software or SDK.
Protect low-level functionality
Why OOP ...
Keeps large software projects manageable for
human programmers via:

Composability -- Structured Design - Interfaces
allow modules to combine freely in order to
produce new systems.
Why OOP ...
Keeps large software projects manageable for
human programmers via:

Hierarchy - Incremental development from
small and simple to more complex modules.
Why OOP ...
Keeps large software projects manageable for
human programmers via:

Continuity - Changes and maintenance in only
a few modules does not affect the overall
architecture.
Why OOP ...
Modularization
Abstraction
Encapsulation
Composability
Hierarchy
Continuity
etc ...
OOP could be this?
OOP
The strongest concept of OOP is "messaging",
so while we are developing we should
concentrate on how the objects communicate
between themselves
OOP - System Level
When we develop a system we should focus
on:

● Separation of concern
● High level of abstraction
OOP - System Level
We obtain a Hexagonal Architecture
OOP - Object Level
How 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 Level
The objects should have:

●   Low Coupling
●   High Cohesion
●   Composite Simpler Than The Sum
●   Context Independence
●   Hide the correct information
OOP - Object Level
We should compose the objects to describe the
system, 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 the
declarative layer". The classes are "factories"
for the objects. So you could have other
factories for the objects...
OOP - Ruby
irb(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
=> nil
irb(main):006:0> a.somma
=> 3
irb(main):007:0>
OOP - Javascript
var 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 - Scheme
es:
> (define x (make-from-real-imag 1 2))
>x
#<procedure:dispatch>
> (x 'real-part)
1
> (x 'imag-part)
2
>
Example
There is a web server that exposes some APIs
to manage playlists of images. We create a
desktop program to manage these playlists ...

server: https://github.com/gpad/rms
client: https://github.com/gpad/PlayListManager
OOP vs COP


            Thank YOU !!!

twitter: https://twitter.com/#!/GPad619
github: https://github.com/gpad
e-mail: gpadovani@gmail.com

More Related Content

What's hot

Algorithm of some numerical /computational methods
Algorithm of some numerical /computational methodsAlgorithm of some numerical /computational methods
Algorithm of some numerical /computational methods
Chandan
 
Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in javasawarkar17
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
Vaibhav Khanna
 
Race condition
Race conditionRace condition
Как писать красивый код или основы SOLID
Как писать красивый код или основы SOLIDКак писать красивый код или основы SOLID
Как писать красивый код или основы SOLID
Pavel Tsukanov
 
Transaction slide
Transaction slideTransaction slide
Transaction slide
shawon roy
 
Multi threading
Multi threadingMulti threading
Multi threading
gndu
 
HiveServer2
HiveServer2HiveServer2
HiveServer2
Schubert Zhang
 
.Net framework architecture
.Net framework architecture.Net framework architecture
.Net framework architecture
Fad Zulkifli
 
Concurrent programming
Concurrent programmingConcurrent programming
Concurrent programming
Rahul Singh
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
Arumugam90
 
Multithreading
Multithreading Multithreading
Multithreading
WafaQKhan
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
Shraddha
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Arafat Hossan
 
Parallel processing
Parallel processingParallel processing
Parallel processing
rajshreemuthiah
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
Lovely Professional University
 
Parallel processing in data warehousing and big data
Parallel processing in data warehousing and big dataParallel processing in data warehousing and big data
Parallel processing in data warehousing and big data
Abhishek Sharma
 

What's hot (20)

Algorithm of some numerical /computational methods
Algorithm of some numerical /computational methodsAlgorithm of some numerical /computational methods
Algorithm of some numerical /computational methods
 
Abstraction in java
Abstraction in javaAbstraction in java
Abstraction in java
 
Operating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphoresOperating system 24 mutex locks and semaphores
Operating system 24 mutex locks and semaphores
 
Lecture 1 oop
Lecture 1 oopLecture 1 oop
Lecture 1 oop
 
Race condition
Race conditionRace condition
Race condition
 
Как писать красивый код или основы SOLID
Как писать красивый код или основы SOLIDКак писать красивый код или основы SOLID
Как писать красивый код или основы SOLID
 
Transaction slide
Transaction slideTransaction slide
Transaction slide
 
Multi threading
Multi threadingMulti threading
Multi threading
 
HiveServer2
HiveServer2HiveServer2
HiveServer2
 
.Net framework architecture
.Net framework architecture.Net framework architecture
.Net framework architecture
 
JVM
JVMJVM
JVM
 
I/O Buffering
I/O BufferingI/O Buffering
I/O Buffering
 
Concurrent programming
Concurrent programmingConcurrent programming
Concurrent programming
 
JSP Components and Directives.pdf
JSP Components and Directives.pdfJSP Components and Directives.pdf
JSP Components and Directives.pdf
 
Multithreading
Multithreading Multithreading
Multithreading
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Parallel processing
Parallel processingParallel processing
Parallel processing
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Parallel processing in data warehousing and big data
Parallel processing in data warehousing and big dataParallel processing in data warehousing and big data
Parallel processing in data warehousing and big data
 

Similar to OOP vs COP

OO and Rails...
OO and Rails... OO and Rails...
OO and Rails... adzdavies
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
RiturajJain8
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
RichardWarburton
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
BalamuruganV28
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
Colin Riley
 
Solid principes
Solid principesSolid principes
Solid principes
Steven Ndaye
 
"Leveraging the Event Loop for Blazing-Fast Applications!", Michael Di Prisco
"Leveraging the Event Loop for Blazing-Fast Applications!",  Michael Di Prisco"Leveraging the Event Loop for Blazing-Fast Applications!",  Michael Di Prisco
"Leveraging the Event Loop for Blazing-Fast Applications!", Michael Di Prisco
Fwdays
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
danwrong
 
Scilab for real dummies
Scilab for real dummiesScilab for real dummies
Scilab for real dummies
Sunu Pradana
 
Ruby object model
Ruby object modelRuby object model
Ruby object modelmbeizer
 
Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)
muhammadmubinmacadad2
 
OOP Java
OOP JavaOOP Java
OOP Java
Saif Kassim
 
1 Introduction to JAVA.pptx
1 Introduction to JAVA.pptx1 Introduction to JAVA.pptx
1 Introduction to JAVA.pptx
Kabiles07
 
Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?
ColdFusionConference
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
TigistTilahun1
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
SULTHAN BASHA
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
devObjective
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
ColdFusionConference
 

Similar to OOP vs COP (20)

OO and Rails...
OO and Rails... OO and Rails...
OO and Rails...
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
What does OOP stand for?
What does OOP stand for?What does OOP stand for?
What does OOP stand for?
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
Solid principes
Solid principesSolid principes
Solid principes
 
"Leveraging the Event Loop for Blazing-Fast Applications!", Michael Di Prisco
"Leveraging the Event Loop for Blazing-Fast Applications!",  Michael Di Prisco"Leveraging the Event Loop for Blazing-Fast Applications!",  Michael Di Prisco
"Leveraging the Event Loop for Blazing-Fast Applications!", Michael Di Prisco
 
Metaprogramming JavaScript
Metaprogramming  JavaScriptMetaprogramming  JavaScript
Metaprogramming JavaScript
 
Scilab for real dummies
Scilab for real dummiesScilab for real dummies
Scilab for real dummies
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)Object-Oriented Programming in Java (Module 1)
Object-Oriented Programming in Java (Module 1)
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Scilabpdf
ScilabpdfScilabpdf
Scilabpdf
 
1 Introduction to JAVA.pptx
1 Introduction to JAVA.pptx1 Introduction to JAVA.pptx
1 Introduction to JAVA.pptx
 
Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?Dependency Injection Why is it awesome and Why should I care?
Dependency Injection Why is it awesome and Why should I care?
 
Chapter 1- Introduction.ppt
Chapter 1- Introduction.pptChapter 1- Introduction.ppt
Chapter 1- Introduction.ppt
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
 
Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?Dependency Injection: Why is awesome and why should I care?
Dependency Injection: Why is awesome and why should I care?
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 

More from Gianluca Padovani

A Gentle introduction to microservices
A Gentle introduction to microservicesA Gentle introduction to microservices
A Gentle introduction to microservices
Gianluca Padovani
 
Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)
Gianluca Padovani
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
Gianluca Padovani
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
Gianluca Padovani
 
DDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirDDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves Elixir
Gianluca Padovani
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
Gianluca Padovani
 
From a web application to a distributed system
From a web application to a distributed systemFrom a web application to a distributed system
From a web application to a distributed system
Gianluca Padovani
 
Beam way of life
Beam way of lifeBeam way of life
Beam way of life
Gianluca Padovani
 
Cook your KV
Cook your KVCook your KV
Cook your KV
Gianluca Padovani
 
System integration through queues
System integration through queuesSystem integration through queues
System integration through queues
Gianluca Padovani
 
Beam me up, Scotty
Beam me up, ScottyBeam me up, Scotty
Beam me up, Scotty
Gianluca Padovani
 
Docker e git lab
Docker e git labDocker e git lab
Docker e git lab
Gianluca Padovani
 
La mia prima lezione di pozioni
La mia prima lezione di pozioniLa mia prima lezione di pozioni
La mia prima lezione di pozioni
Gianluca Padovani
 
Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015
Gianluca Padovani
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...
Gianluca Padovani
 

More from Gianluca Padovani (16)

A Gentle introduction to microservices
A Gentle introduction to microservicesA Gentle introduction to microservices
A Gentle introduction to microservices
 
Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)Beam me up, scotty (PUG Roma)
Beam me up, scotty (PUG Roma)
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Tdd is not about testing (OOP)
Tdd is not about testing (OOP)Tdd is not about testing (OOP)
Tdd is not about testing (OOP)
 
DDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves ElixirDDD loves Actor Model and Actor Model loves Elixir
DDD loves Actor Model and Actor Model loves Elixir
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 
From a web application to a distributed system
From a web application to a distributed systemFrom a web application to a distributed system
From a web application to a distributed system
 
Beam way of life
Beam way of lifeBeam way of life
Beam way of life
 
Cook your KV
Cook your KVCook your KV
Cook your KV
 
System integration through queues
System integration through queuesSystem integration through queues
System integration through queues
 
Beam me up, Scotty
Beam me up, ScottyBeam me up, Scotty
Beam me up, Scotty
 
Docker e git lab
Docker e git labDocker e git lab
Docker e git lab
 
La mia prima lezione di pozioni
La mia prima lezione di pozioniLa mia prima lezione di pozioni
La mia prima lezione di pozioni
 
Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015Keynote meetup Elixir/Erlang 17 ottobre 2015
Keynote meetup Elixir/Erlang 17 ottobre 2015
 
C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...C++ Actor Model - You’ve Got Mail ...
C++ Actor Model - You’ve Got Mail ...
 
Ferrara Linux Day 2011
Ferrara Linux Day 2011Ferrara Linux Day 2011
Ferrara Linux Day 2011
 

Recently uploaded

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
Kartik Tiwari
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
gb193092
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 

Recently uploaded (20)

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Chapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdfChapter -12, Antibiotics (One Page Notes).pdf
Chapter -12, Antibiotics (One Page Notes).pdf
 
Marketing internship report file for MBA
Marketing internship report file for MBAMarketing internship report file for MBA
Marketing internship report file for MBA
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 

OOP vs COP

  • 1. OOP vs COP Objects against Classes
  • 2. The beginning ... About a year ago, I said to a friend: "Why is it called 'OOP'? It should be called 'COP' as the classes are more important!" ...my friend stopped saying "ciao" to me for a month...he works in Python and Javascript!
  • 3. The beginning ... Some time later I saw this post of Uncle Bob "The Last programming Language" where he talks about Clojure and I read a phrase that left a strong impression on me: Inheritance is not the only way to do polymorphism
  • 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. The beginning ... Then I began to study Ruby and work in Javascript. In Javascript the concept of class does not exist! In Ruby the objects are softer than in C# or Java.
  • 6. OOP - Ruby irb(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 => nil irb(main):006:0> a.somma => 3 irb(main):007:0>
  • 7. OOP - Javascript var obj = { type: "xxx", color: "red", getInfo: function () { return this.type + ' is ' + this.color; } }; obj.color = "black"; alert(obj.getInfo());
  • 8. Language matters!? Is it just a language problem or is there something else? Let's start from the beginning ...
  • 10. OOP - Is it this?
  • 11. OOP - or this?
  • 12. OOP - OR THIS ????
  • 13. Let's ask "Dad"... http://en.wikiquote.org/wiki/Alan_Kay "OOP to me means only messaging, local retention and protection and hiding of state- process, and extreme late- binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them."
  • 14. So OOP is: ● Messaging ● Local retention & protection ● Hiding of State-process ● Extreme late binding
  • 15. Where are the classes????
  • 16. Where are the objects ?????
  • 17. Let's ask Alan again... http://userpage.fu-berlin. de/~ram/pub/pub_jf47ht81Ht/doc_kay_oo p_en "It was probably in 1967 when someone asked me what I was doing, and I said: 'It's object-oriented programming'." [...] "I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful)."
  • 18. Let's 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 last OOPSLA to try to remind everyone that Smalltalk is not only NOT its syntax or the class library, it is not even about classes. I'm sorry that I long ago coined the term "objects" for this topic because it gets many people to focus on the lesser idea." The big idea is "messaging" [ ... ]
  • 19. Why OOP ... OOP creates a modular design that is easily modified without having to restructure the entire system.
  • 20. Why OOP ... Keeps large software projects manageable for human programmers
  • 21. Why OOP ... Keeps large software projects manageable for human programmers via: Modularization - Decompose problem into smaller subproblems that can be solved independently.
  • 22. Why OOP ... Keeps large software projects manageable for human programmers via: Abstraction -- Understandability - Terminology of the problem domain is reflected in the software solution. Individual modules are understandable by human readers.
  • 23. Why OOP ... Keeps large software projects manageable for human programmers via: Encapsulation -- Information Hiding - Hide complexity from the user of a software or SDK. Protect low-level functionality
  • 24. Why OOP ... Keeps large software projects manageable for human programmers via: Composability -- Structured Design - Interfaces allow modules to combine freely in order to produce new systems.
  • 25. Why OOP ... Keeps large software projects manageable for human programmers via: Hierarchy - Incremental development from small and simple to more complex modules.
  • 26. Why OOP ... Keeps large software projects manageable for human programmers via: Continuity - Changes and maintenance in only a few modules does not affect the overall architecture.
  • 28. OOP could be this?
  • 29. OOP The strongest concept of OOP is "messaging", so while we are developing we should concentrate on how the objects communicate between themselves
  • 30. OOP - System Level When we develop a system we should focus on: ● Separation of concern ● High level of abstraction
  • 31. OOP - System Level We obtain a Hexagonal Architecture
  • 32. OOP - Object Level How 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. OOP - Object Level The objects should have: ● Low Coupling ● High Cohesion ● Composite Simpler Than The Sum ● Context Independence ● Hide the correct information
  • 34. OOP - Object Level We should compose the objects to describe the system, so we have: ● Declarative Layer - Where the objects are created and composed ● Application Layer - Where the object communicates
  • 35. And the classes??? The classes are "the declarative layer of the declarative layer". The classes are "factories" for the objects. So you could have other factories for the objects...
  • 36. OOP - Ruby irb(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 => nil irb(main):006:0> a.somma => 3 irb(main):007:0>
  • 37. OOP - Javascript var obj = { type: "xxx", color: "red", getInfo: function () { return this.type + ' is ' + this.color; } }; obj.color = "black"; alert(obj.getInfo());
  • 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. OOP - Scheme es: > (define x (make-from-real-imag 1 2)) >x #<procedure:dispatch> > (x 'real-part) 1 > (x 'imag-part) 2 >
  • 40. Example There is a web server that exposes some APIs to manage playlists of images. We create a desktop program to manage these playlists ... server: https://github.com/gpad/rms client: https://github.com/gpad/PlayListManager
  • 41.
  • 42. OOP vs COP Thank YOU !!! twitter: https://twitter.com/#!/GPad619 github: https://github.com/gpad e-mail: gpadovani@gmail.com