Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Interfaces in Action - The Art of Polymorphism

Miodrag
November 17, 2018

Interfaces in Action - The Art of Polymorphism

Understanding the importance of building loosely coupled software solutions powered by the art of the polymorphic behavior. Following the core concepts of object oriented paradigm can lead us towards the process of creating powerful functionalities in the spirit of increased flexibility, testability and extensibility.

Miodrag

November 17, 2018
Tweet

More Decks by Miodrag

Other Decks in Programming

Transcript

  1. Self-motivated software developer and future PhD in the field of

    bioinformatics. Latest technology addicted person with strong vision directed to the well - known real life challenges. Always open to learn and undertake upcoming modern technologies and development tools. Until now has worked in different companies as web and mobile software developer using Microsoft .NET framework and C# programming language. [email protected] https://www.facebook.com/miodrag.cekic.94 miodrag9581
  2. Class Hierarchy and Coupling • Class coupling • A measure

    on how one class is connected or dependent with another class/classes Application Class A Direct dependency Indirect dependency Class B Class C Class F Class D Class E Class G (Tight Coupling) (Loosely Coupling)
  3. Classes Relationships • Associations types Inheritance (Is-a relationship) Customer PremiumCustomer

    GoldCustomer Composition (Has-a relationship) Vehicle Engine Mechanism by which one class is allowed to inherit the code (fields and methods) of another class Mechanism by which one class is allowed to contain the another class
  4. Classes Relationships • Composition MediaStorage - id: int - vendor:

    string - serial: string - size: float + openDrive(): void + read(): string + write(string): bool Deletable + delete(string): bool HardDrive (HD) CompactDisc (CD) Rewritable DigitalVertileDisc (RWDVD)
  5. Interfaces in Action • First Things First: What is an

    Interface? • Structure with the definitions for a group of related functionalities • Container for declaration of the methods • Language construct like an abstract base class
  6. Interfaces in Action • First Things First: What is an

    Interface? • Contract between itself and any class implementing it • Enables “Plug & Play” functionality • Analogy with agreement or blueprint
  7. Interfaces in Action • From Composition to interface IDeletable MediaStorage

    + openDrive(): void + read(): string + write(string): bool Deletable + delete(string): bool HardDrive (HD)
  8. Interfaces in Action • WHY Interfaces? ✓ Extensibility ✓ Maintainability

    ✓ Testability • Building loosely coupled software applications in terms of improved:
  9. Interfaces in Action • Dependency Injection Design Pattern • Constructor

    injection • Setter injection • Method injection
  10. Interfaces in Action • Encryption Demo - Polymorphism.UnitTests • Mock

    mimics and isolates the behavior of a real object • Interfaces removes the dependencies and makes the code unit testable
  11. Interfaces in Action • Encryption Demo - DI through Container

    REGISTER RESOLVE R-R Runtime Reflection
  12. Wrap Up ✓Understanding the importance of building loosely coupled software

    solutions powered by the art of the polymorphic behavior. ✓Interfaces as powerful language construct in the spirit of increased flexibility, testability and extensibility.