SlideServe
Menu
Préférences
© SlideServe · v2026

Quack, waddle

agatha avatar
15 diapositives · 432 Views · Jul 27, 2014

Quack, waddle. Barry Dorrans barryd@idunno.org. Duck Typing. If it walks like a duck and quacks like a duck, it’s a duck. And this means what?. A concentration on the aspects of the object, not the underlying type. And this means what?.

Quack, waddle - slide 1
01 / 15Quack, waddle
1 / 17

Télécharger la présentation

Quack, waddle
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Quack, waddle Barry Dorrans barryd@idunno.org

  2. Duck Typing If it walks like a duck and quacks like a duck, it’s a duck.

  3. And this means what? A concentration on the aspects of the object, not the underlying type.

  4. And this means what? Who cares what the type is; if it quacks and walks then we may treat it as a duck.

  5. From Python; EAFP Easier to Ask Forgivenessthan Permission. No typeof(), isinstance(). Central to Ruby’s approach.

  6. Object Substitution Substitution can occur if an object supports the methods and properties of the expected type in use in the accepting method.

  7. Type Safety is the one true way Static types can slow productivity. .NET already has duck typing …

  8. Liskoff Substitution Principle Subclasses can substitute base class, based on type. Duck typing substitutes on ability.

  9. .NET foreach() quacks Provide a public method GetEnumerator that takes no parameters and returns a type that has two members: a method MoveNext that takes no parameters and return a Boolean, and a property Current with a getter that returns an Object.

  10. So it’s C# 3.0 var then? var declarations are decided at compile time. var is type safe.

  11. And what use is this? Very loose coupling. Type checking breaks encapsulation. Substituting Sealed classes. Testing & mock objects. Plugin versioning architectures.

  12. Killer Beak Duck typing is not performant.

  13. Code Time

  14. Library Availability www.deftflux.net/blog/page/Duck-Typing-Project.aspx Depends on http://www.codeplex.com/NGenerics

  15. And yes;duck quacks do echo www.acoustics.salford.ac.uk/acoustics_info/duck/