{"id":25732364,"url":"https://github.com/howprogrammingworks/polymorphism","last_synced_at":"2026-06-11T02:31:17.076Z","repository":{"id":147758470,"uuid":"237841662","full_name":"HowProgrammingWorks/Polymorphism","owner":"HowProgrammingWorks","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-02T21:53:59.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-11-02T23:21:08.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://youtube.com/TimurShemsedinov","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HowProgrammingWorks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-02T21:46:05.000Z","updated_at":"2025-11-02T21:54:02.000Z","dependencies_parsed_at":"2023-05-27T10:15:24.262Z","dependency_job_id":null,"html_url":"https://github.com/HowProgrammingWorks/Polymorphism","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HowProgrammingWorks/Polymorphism","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HowProgrammingWorks%2FPolymorphism","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HowProgrammingWorks%2FPolymorphism/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HowProgrammingWorks%2FPolymorphism/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HowProgrammingWorks%2FPolymorphism/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HowProgrammingWorks","download_url":"https://codeload.github.com/HowProgrammingWorks/Polymorphism/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HowProgrammingWorks%2FPolymorphism/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34180147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-26T03:40:36.889Z","updated_at":"2026-06-11T02:31:17.070Z","avatar_url":"https://github.com/HowProgrammingWorks.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polymorphism\n\n## Polymorphism classification\n\n1. Ad-hoc polymorphism - Functions or operators behave differently based on argument types\n  - Function and method overloading - Multiple functions with same name, different signatures\n    - CSharp example: [`1-ad-hoc.cs`](Classification/1-ad-hoc.cs)\n    - JavaScript emulation: [`2-emulation.js`](Classification/2-emulation.js)\n  - Operator overloading - Custom behavior for built-in operators: [`3-operator.cpp`](Classification/3-operator.cpp)\n  - Type-class polymorphism - Ad-hoc polymorphism via type constraints (e.g. Haskell type classes, Rust traits)\n  - Coercion polymorphism - Implicit or explicit type conversions: [`4-coercion.js`](Classification/4-coercion.js)\n2. Subtype polymorphism - Objects of derived types can be used where base types are expected\n  - Class inheritance - IS-A relationship via base classes: [`5-abstract.ts`](Classification/5-abstract.ts)\n  - Interface / protocol polymorphism - Contracts that types must implement: [`6-protocol.js`](Classification/6-protocol.js)\n  - Structural (duck typing) polymorphism - Compatibility based on structure, not explicit inheritance: [`6-protocol.js`](Classification/6-protocol.js)\n3. Parametric polymorphism - Code written generically to work with any type\n  - Generic functions - Functions parameterized by types: JS [`9-generics.ts`](Classification/9-generics.ts)\n  - Generic data structures - Data structures parameterized by types: JS TS [`a-generics.js`](Classification/a-generics.js)\n4. Dispatch mechanisms - How the runtime selects which method to call\n  - Dynamic dispatch - Method chosen at runtime based on object type: [`7-dynamic.js`](Classification/7-dynamic.js)\n  - Virtual functions and methods - Base class methods overridable by derived classes: [`8-virtual.cpp`](Classification/8-virtual.cpp)\n  - Multiple or multimethod dispatch - Method chosen based on multiple argument types\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowprogrammingworks%2Fpolymorphism","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhowprogrammingworks%2Fpolymorphism","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhowprogrammingworks%2Fpolymorphism/lists"}