liveBook · Manning

Subtyping

Subtyping is a type-system relationship in which values of a more specific type can be used wherever a compatible, more general type is expected.

How 4 Manning books explain it

100 SQL Server Mistakes and How to Avoid Them

A subtype is a specialized entity type that inherits common attributes from a supertype and may add unique attributes.

How it is used
Uses subtyping to organize shared person attributes while preserving role-specific attributes.
How deep it goes
Defines supertypes and subtypes through a People and Sales Persons modeling example without implementation details.
Examples
Uses People, Sales Persons, and AdventureWorks Person and Employees as subtype examples.
What you can do after
Evaluate/understand when common attributes belong in a supertype and unique attributes belong in a subtype.

Read how 100 SQL Server Mistakes and How to Avoid Them explains subtyping →

Kotlin in Action, 2E

A subtyping relation specifies when one type can be used wherever another type is expected.

How it is used
Determines whether Kotlin values and generic arguments can safely satisfy variable and function parameter types.
How deep it goes
Defines ordinary and nullable subtyping, then explains covariance and contravariance through collection, comparator, and function examples.
Examples
Uses `Int` versus `Number`, nullable assignments, read-only and mutable lists, fruit comparators, and function types.
What you can do after
Evaluate/understand whether Kotlin assignments, calls, and generic substitutions are accepted safely by the compiler.

Read how Kotlin in Action, 2E explains subtyping →

Julia as a Second Language

A subtype is a type whose values are also accepted wherever values of a more general supertype are expected.

How it is used
Organizes related values for type-compatible storage and shared method signatures.
How deep it goes
Works through subtype tests, hierarchy inspection, declarations, and dispatch without developing a formal type-system account.
Examples
Tests numeric subtype relationships, defines warrior variants, and uses a union-typed field to terminate a wagon chain.
What you can do after
Build it from scratch: define an abstract supertype and concrete subtypes, then write methods accepting the shared type.

Read how Julia as a Second Language explains subtyping →

Functional Programming in Scala, Second Edition

Subtyping is a type-system relationship in which values of one type may be used where values of another, more general type are expected.

How it is used
Combines independent effect algebras so file and console programs compose under one Free type.
How deep it goes
Descends from a motivating type error into covariance, contravariant positions, and mechanically widened type parameters.
Examples
Uses a cat program that reads lines from Files and prints them through Console.
What you can do after
Build it from scratch by widening Free effect types and correcting flatMap variance errors.

Read how Functional Programming in Scala, Second Edition explains subtyping →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.