Share
VIDEOS 1 TO 50
What Is Duck Typing in Computer Programming?
What Is Duck Typing in Computer Programming?
Published: 2016/02/17
Channel: Chris Hawkes
Python Tutorial: Duck Typing and Asking Forgiveness, Not Permission (EAFP)
Python Tutorial: Duck Typing and Asking Forgiveness, Not Permission (EAFP)
Published: 2016/02/09
Channel: Corey Schafer
Lesson 10   Duck Typing
Lesson 10 Duck Typing
Published: 2015/02/09
Channel: thinkpython AU
[ Ruby Foundations ] 32 - Duck Typing
[ Ruby Foundations ] 32 - Duck Typing
Published: 2016/02/11
Channel: Neat IT Web Solutions
DUCK TYPING | Code Walks 009
DUCK TYPING | Code Walks 009
Published: 2016/07/16
Channel: Christopher Okhravi
Method Overriding, Method Overloading, Polymorphism and Duck-Typing.
Method Overriding, Method Overloading, Polymorphism and Duck-Typing.
Published: 2016/07/19
Channel: Sharp El
CTO Message - Duck Typing
CTO Message - Duck Typing
Published: 2011/04/06
Channel: DevExpress
8. Duck Typing
8. Duck Typing
Published: 2013/05/08
Channel: Arnaldo Pedro Figueira Figueira
Python Ducktyping concept
Python Ducktyping concept
Published: 2017/04/09
Channel: TheCodingProject
What Is A Type System In Programming? Strong vs. Weak
What Is A Type System In Programming? Strong vs. Weak
Published: 2016/02/17
Channel: Chris Hawkes
C Programming Tutorial 37 - Strongly Typed vs Loosely Typed Languages
C Programming Tutorial 37 - Strongly Typed vs Loosely Typed Languages
Published: 2017/05/01
Channel: CalebTheVideoMaker2
duck typing. ЗАСИДКА УТИНАЯ NEW
duck typing. ЗАСИДКА УТИНАЯ NEW
Published: 2014/03/23
Channel: АЛЕКСАНДРизДЕРЕВНЯ-LIFE
9 - 9 - Duck Typing (7:28)
9 - 9 - Duck Typing (7:28)
Published: 2015/03/18
Channel: Rich Simpson
duck typing
duck typing
Published: 2009/05/24
Channel: dubiousgeorge
Duck Typing - Intro to Computer Science
Duck Typing - Intro to Computer Science
Published: 2015/02/23
Channel: Udacity
Duck Octagon V2 Typing Test (Zealio 62g)
Duck Octagon V2 Typing Test (Zealio 62g)
Published: 2017/08/21
Channel: MechMerlin
01 08 Duck Typing vs  Type Hinting
01 08 Duck Typing vs Type Hinting
Published: 2016/06/10
Channel: codex snippet
RubyConf 2014 - Strong Duck Type Driven Development
RubyConf 2014 - Strong Duck Type Driven Development
Published: 2014/12/24
Channel: Confreaks
Programming Languages: Static and Dynamic Typing
Programming Languages: Static and Dynamic Typing
Published: 2012/05/01
Channel: Jeff Hyatt
Python Scripting Tutorial Duck Typing and Asking Forgiveness, Not Permission EAFP
Python Scripting Tutorial Duck Typing and Asking Forgiveness, Not Permission EAFP
Published: 2016/09/25
Channel: Bhaskara V Ganiga
WE TAPED ALISSA TO THE WALL (FREAKOUT)
WE TAPED ALISSA TO THE WALL (FREAKOUT)
Published: 2016/11/04
Channel: Jake Paul
Duck typing
Duck typing
Published: 2015/03/20
Channel: theShockwaveRider
Typing: Static vs Dynamic, Weak vs. Strong / Intro to JavaScript ES6 programming, lesson 17
Typing: Static vs Dynamic, Weak vs. Strong / Intro to JavaScript ES6 programming, lesson 17
Published: 2017/02/13
Channel: Hexlet
Duck Typing in Ruby - tekniqal.com
Duck Typing in Ruby - tekniqal.com
Published: 2009/03/07
Channel: tknql
Curso Python [P21] - Explicando los Objetos: Duck Typing ( el Tipado del Pato)
Curso Python [P21] - Explicando los Objetos: Duck Typing ( el Tipado del Pato)
Published: 2014/11/15
Channel: EscuelaDeVideojuegos
Duck Typing
Duck Typing
Published: 2014/11/04
Channel: Duke Greene
06 03 Duck Typing
06 03 Duck Typing
Published: 2016/07/27
Channel: Humanth Shashani
Duck Typing Highland Secondary Principals To Wall
Duck Typing Highland Secondary Principals To Wall
Published: 2017/12/08
Channel: The Winter Wolf
POODR Chapter 5: Reducing Costs with Duck Typing
POODR Chapter 5: Reducing Costs with Duck Typing
Published: 2015/09/25
Channel: Mary-Katherine McKenzie
Duck Typing Brandon
Duck Typing Brandon
Published: 2010/10/02
Channel: Nasi Thach
What does duck typing mean?
What does duck typing mean?
Published: 2015/08/03
Channel: What Does That Mean?
Ruby for Newbies - Part 6 - Duck Typing
Ruby for Newbies - Part 6 - Duck Typing
Published: 2012/08/13
Channel: Multunus Software
Typing Ducks
Typing Ducks
Published: 2011/06/27
Channel: spazzjazz01
Duck Lightsaver V2 with SA Keys (Steel plate, 62g vintage blacks)
Duck Lightsaver V2 with SA Keys (Steel plate, 62g vintage blacks)
Published: 2016/09/28
Channel: Omr
13.- Curso de Python 3.X Polimorfismo y Duck Typing.
13.- Curso de Python 3.X Polimorfismo y Duck Typing.
Published: 2014/02/15
Channel: Jesús Conde
Clases abstractas y duck typing en Python 3
Clases abstractas y duck typing en Python 3
Published: 2017/09/18
Channel: Pythonista
3 6 mixins and duck typing
3 6 mixins and duck typing
Published: 2012/03/10
Channel: Rafael Merino García
KharkivPy #4: Go: static duck typing
KharkivPy #4: Go: static duck typing
Published: 2012/06/21
Channel: Ivan Kolodyazhny
What the Duck?
What the Duck?
Published: 2015/07/13
Channel: Walter Latimer
How to Pronounce Duck Typing
How to Pronounce Duck Typing
Published: 2016/12/20
Channel: Dictionary Voice
Web Tech Topic #16 - The introduction of Duck typing "Practical Object-Oriented Design In Ruby"
Web Tech Topic #16 - The introduction of Duck typing "Practical Object-Oriented Design In Ruby"
Published: 2016/11/17
Channel: 王信凱
Lesson 2 Duck Typing
Lesson 2 Duck Typing
Published: 2017/01/23
Channel: Alfred University Computer Science
10 - 9 - Duck Typing (728)
10 - 9 - Duck Typing (728)
Published: 2013/05/10
Channel: Nathan Hadzariga
How to make a duck type wallet
How to make a duck type wallet
Published: 2016/04/22
Channel: Brittany Woodman
Programming: Typing Conventions
Programming: Typing Conventions
Published: 2017/10/18
Channel: 0612 TV w/ NERDfirst
The duck type the frezzer
The duck type the frezzer
Published: 2012/09/02
Channel: Girl Gamer Who loves fords
Baby Duck Typing on Laptop Awwwwww!!!!!!
Baby Duck Typing on Laptop Awwwwww!!!!!!
Published: 2014/02/05
Channel: BRANDEN KOEHLER
kaczka w Jasminum
kaczka w Jasminum
Published: 2009/12/17
Channel: KerliRose
Java  Vs Python - Difference Between Java And Python
Java Vs Python - Difference Between Java And Python
Published: 2017/01/21
Channel: MAD differences
Duck type bows
Duck type bows
Published: 2017/04/16
Channel: Nikolay Nanev
NEXT
GO TO RESULTS [51 .. 100]

WIKIPEDIA ARTICLE

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In computer programming, duck typing is an application of the duck test in type safety. It requires that type checking be deferred to runtime, and is implemented by means of dynamic typing or reflection.[citation needed]

Duck typing is concerned with establishing the suitability of an object for some purpose, using the principle, "If it walks like a duck and it quacks like a duck, then it must be a duck." With normal typing, suitability is assumed to be determined by an object's type only. In duck typing, an object's suitability is determined by the presence of certain methods and properties (with appropriate meaning), rather than the actual type of the object.[citation needed]

Example[edit]

This is a simple example in Python 3 that demonstrates how any object may be used in any context, up until it is used in a way that it does not support.

class Sparrow:
    def fly(self):
        print("Sparrow flying")

class Airplane:
    def fly(self):
        print("Airplane flying")

class Whale:
    def swim(self):
        print("Whale swimming")

def lift_off(entity):
    entity.fly()

sparrow = Sparrow()
airplane = Airplane()
whale = Whale()

lift_off(sparrow) # prints `Sparrow flying`
lift_off(airplane) # prints `Airplane flying`
lift_off(whale) # Throws the error `'Whale' object has no attribute 'fly'`

In statically typed languages[edit]

Certain usually statically typed languages such as Boo and the version 4 release of C# have extra type annotations[1][2] that instruct the compiler to arrange for type checking of classes to occur at run-time rather than compile time, and include run-time type checking code in the compiled output.

Comparison with other type systems[edit]

Structural type systems[edit]

Duck typing is similar to, but distinct from structural typing. Structural typing is a static typing system that determines type compatibility and equivalence by a type's structure, whereas duck typing is dynamic and determines type compatibility by only that part of a type's structure that is accessed during run time.

The OCaml, Scala, Go, Elm,[3] and Gosu languages support structural typing to varying degrees.

Protocols and Interfaces[edit]

Protocols and interfaces can provide some of the benefits of duck typing, but duck typing is distinct in that no explicit interface is defined. For example, if a third party library implements a class that cannot be modified, a client cannot use an instance of it with an interface unknown to that library even if the class does in fact satisfy the interface requirements. (A common solution to this problem is the Adapter pattern.) Duck typing would allow this. Again, all of an interface must be satisfied for compatibility.

Templates or generic types[edit]

Template, or generic functions or methods apply the duck test in a static typing context; this brings all the advantages and disadvantages of static versus dynamic type checking in general. Duck typing can also be more flexible in that only the methods actually called at run time need to be implemented, while templates require implementation of all methods that cannot be proven unreachable at compile time.

Examples include the languages C++ and D with templates, which developed from Ada generics.

Criticism[edit]

Criticism of the term itself[edit]

Use of the term "duck typing" has been considered superfluous in light of the fact that other terms, such as dynamic binding, express the concept more clearly.[4] To proponents of static type checking, duck typing suggests the absence of typing, making its incorporation of the term typing appear incoherent.

History[edit]

Alex Martelli made an early (2000) use of the term in a message to the comp.lang.python newsgroup:

In other words, don't check whether it IS-a duck: check whether it QUACKS-like-a duck, WALKS-like-a duck, etc, etc, depending on exactly what subset of duck-like behaviour you need to play your language-games with.

See also[edit]

References[edit]

  1. ^ Boo: Duck Typing Archived October 6, 2008, at the Wayback Machine.
  2. ^ "Anders Hejlsberg Introduces C# 4.0 at PDC 2008". Retrieved 30 January 2017. 
  3. ^ Czaplicki, Evan. "Core Language · An Introduction to Elm". Retrieved 30 January 2017. 
  4. ^ Lippert, Eric (2 Jan 2014). "What is "duck typing"?". Fabulous adventures in coding. Retrieved 25 May 2016. ... the whole idea of duck typing is fundamentally incoherent ...' 

Disclaimer

None of the audio/visual content is hosted on this site. All media is embedded from other sites such as GoogleVideo, Wikipedia, YouTube etc. Therefore, this site has no control over the copyright issues of the streaming media.

All issues concerning copyright violations should be aimed at the sites hosting the material. This site does not host any of the streaming media and the owner has not uploaded any of the material to the video hosting servers. Anyone can find the same content on Google Video or YouTube by themselves.

The owner of this site cannot know which documentaries are in public domain, which has been uploaded to e.g. YouTube by the owner and which has been uploaded without permission. The copyright owner must contact the source if he wants his material off the Internet completely.

Powered by YouTube
Wikipedia content is licensed under the GFDL and (CC) license