Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

8664 bites

Page 13

Python & FastAPI3 min read

Custom Field Serialization with @field_serializer

@field_serializer is an exit-only adapter for one field: it reshapes data leaving the Pydantic model without changing internals. Use it to format decimals, mask secrets, or tweak datetimes for FastAPI JSON. Never use it for validation; it only runs on output.

Python & FastAPI2 min read

Docker Compose for Local FastAPI Stacks

Docker Compose turns your laptop into a one-command datacenter. Define Postgres, Redis, and your FastAPI app in one YAML file and they boot as a networked stack.

Top 10 FastAPI interview questions for senior roles
Python & FastAPI2 min read

Top 10 FastAPI interview questions for senior roles

FastAPI interview questions rarely test syntax. They probe whether you understand its three pillars: ASGI powered async concurrency, Pydantic validation at the request boundary, and the Depends dependency injection graph that wires services together.

Async SQLAlchemy 2.0: the mental model that clicks
Python & FastAPI2 min read

Async SQLAlchemy 2.0: the mental model that clicks

SQLAlchemy's async support is a bridge, not a rewrite. AsyncSession and AsyncEngine still run the same synchronous ORM internals underneath, inside a lightweight greenlet, and only hand control back to the event loop at the moment a real database call happens.

Flutter & Dart2 min read

What is the difference between final and const in Dart?

Tests compile-time versus runtime immutability in Dart. A strong answer: final allows single assignment at runtime, but const requires a compile-time constant and deep immutability.

Flutter & Dart2 min read

Dart Variables: var, final, and const

In Dart, var creates a mutable variable, while final and const are for single-assignment. Use var for changing state, final for runtime values set once, and const for compile-time constants. The footgun is confusing final with const.

Flutter & Dart2 min read

Explain Dart positional vs named parameters and write one signature

Tests Dart parameter syntax. A strong answer covers required positional args, optional positional args in square brackets, and named args in curly braces with defaults. Red flag: claiming named parameters are always optional or confusing bracket types.

Flutter & Dart2 min read

Dart's Core Data Types: Everything is an Object

In Dart, everything is an object, from numbers to functions. This means even a simple int or String has methods and properties, unlike primitive types in other languages. The main footgun is forgetting that null itself is a type, Null.

Describe Dart's null-aware ?. and null assertion ! operators
Flutter & Dart2 min read

Describe Dart's null-aware ?. and null assertion ! operators

Tests Dart null safety mechanics: ?. short-circuits member access on null, while ! casts away nullability. A strong answer notes ?. avoids NPEs and ! is a risky opt-out. Red flag: claiming ! is safe or that ?. provides a default value.

Flutter & Dart2 min read

Dart's Control Flow: Telling Your Code What to Do Next

Control flow statements are the road signs for your code, directing execution beyond a simple top-to-bottom path. Use if/else for decisions, for/while for loops, and try/catch to handle errors. The footgun is forgetting break in a switch case.

Flutter & Dart2 min read

What problem does late solve in Dart?

Tests definite assignment and lazy init in null-safe Dart. Strong answers cover: deferred non-nullable field init, lazy final evaluation, and LateInitializationError on early access. Red flag: treating late as nullable or saying it bypasses null safety.

Flutter & Dart2 min read

Dart Function Syntax: Block Body vs. Arrow Notation

Dart functions use a block body {} for multiple statements or arrow syntax => for a single expression. Use => for simple one-liners like bool isEven(int n) => n % 2 == 0;. The footgun is using => for multi-step logic; it only works for.

Flutter & Dart2 min read

How do you use collection-if and collection-for to declaratively build a list?

Tests Dart's declarative collection control-flow features. Answer: show collection-for to filter inside a literal, collection-if for conditional items, and combine both in one expression. Red flag: imperative loops and add() instead of literal syntax.

Flutter & Dart2 min read

Dart Collections: Choosing List, Set, or Map

Dart collections organize data: use a List for ordered items, a Set for unique items, and a Map for key-value pairs. This choice is fundamental for storing UI widgets or parsing JSON. The common footgun is using a List for lookups, which is slow; use.

Flutter & Dart2 min read

What is a Dart closure? Write a function that returns a function.

Tests lexical scoping: define a closure as a function plus its captured environment, show a makeAdder where the inner function uses a parent variable after the parent returns.

Flutter & Dart2 min read

What are Dart extension methods? Implement toIntOrDefault on String.

Tests Dart extension syntax and static resolution. A strong answer defines an extension on String, uses int.tryParse with a fallback, and notes extensions do not mutate the original type. Red flag: using try-catch over tryParse or claiming dynamic dispatch.

Flutter & Dart2 min read

Dart's Sound Null Safety: No More Null Errors

In Dart, variables can't be null unless you explicitly allow it. This flips the usual model, turning potential runtime null pointer crashes into compile-time errors you can fix immediately.

Flutter & Dart2 min read

Explain Dart switch exhaustiveness for enums versus sealed classes

This tests Dart 3 exhaustiveness. A strong answer notes that enums and sealed classes both require exhaustive switches, but sealed classes allow distinct payloads because subclasses stay in the same library. A red flag is calling them just enums with methods.

Dart's Null-Aware Operators: Safely Handle Nulls
Flutter & Dart2 min read

Dart's Null-Aware Operators: Safely Handle Nulls

Null-aware operators let you work with potentially null values without a cascade of if (x != null) checks. Use them to access properties, provide defaults, or assign values only when a variable is null. The footgun is confusing safe ?. with unsafe !.

Explain Dart's event loop, microtask queue, event queue, and await behavior
Flutter & Dart2 min read

Explain Dart's event loop, microtask queue, event queue, and await behavior

Tests Dart single-threaded event loop model. Strong answer: microtasks drain before event queue tasks; await suspends the function and schedules its resumption via the event loop when the Future completes. Red flag: claiming await blocks the thread.