DEV Community

Srđan
Srđan

Posted on Originally published at projekt.github.io

Programming Paradigms in Dart, Part 1: What Are Programming Paradigms?

Part 1 of 7 · 4-minute read. My learning notes on the main programming paradigms, with Dart examples.

Introduction

Programming paradigms are fundamental approaches to writing software that shape how developers think about and solve problems. Just as architects might approach building design differently depending on whether they're creating a skyscraper, a bridge, or a home, programmers use different paradigms based on the problem at hand. This article explores the major programming paradigms with practical examples in Dart and relatable real-world analogies.

What Are Programming Paradigms?

A programming paradigm is a style or methodology for structuring and organizing code. It provides a framework for thinking about program design, determining how you express logic, manage data, and handle the flow of execution. Understanding these paradigms helps you choose the right tool for each job and write more effective, maintainable code.

Programming Paradigms Overview

╔═══════════════════════════════════════════════════════════╗
║               PROGRAMMING PARADIGMS FAMILY                ║
╚═══════════════════════════════════════════════════════════╝
                              │
            ┌─────────────────┴─────────────────┐
            │                                   │
   ┌────────▼────────┐                 ┌────────▼────────┐
   │   IMPERATIVE    │                 │   DECLARATIVE   │
   │  Focus: HOW     │                 │  Focus: WHAT    │
   │  Tell me the    │                 │  Describe the   │
   │  steps          │                 │  result         │
   └────────┬────────┘                 └────────┬────────┘
            │                                   │
     ┌──────┴──────┐                            │
     │             │                            │
┌────▼─────┐ ┌─────▼────┐               ┌───────▼───────┐
│PROCEDURAL│ │   OOP    │               │  FUNCTIONAL   │
│Reusable  │ │Model     │               │  Transform    │
│routines  │ │entities  │               │  data         │
└──────────┘ └──────────┘               └───────────────┘
Enter fullscreen mode Exit fullscreen mode

Procedural and object-oriented programming are both imperative styles; functional programming is a declarative style. Modern languages like Dart mix all of them — which is exactly what Article 7 is about.

Key Characteristics

╔════════════╦════════════╦═════════════╦══════════════╦═════════════╗
║ Paradigm   ║ Main Focus ║ Data        ║ Control Flow ║ Best For    ║
║            ║            ║ Handling    ║              ║             ║
╠════════════╬════════════╬═════════════╬══════════════╬═════════════╣
║            ║            ║             ║              ║             ║
║ IMPERATIVE ║    HOW     ║   Mutable   ║   Explicit   ║ Algorithms, ║
║            ║  (Steps)   ║    state    ║    steps     ║   scripts   ║
║            ║            ║             ║              ║             ║
╠════════════╬════════════╬═════════════╬══════════════╬═════════════╣
║            ║            ║             ║              ║             ║
║    OOP     ║  OBJECTS   ║ Encapsulated║   Method     ║  Complex    ║
║            ║ (Entities) ║    state    ║    calls     ║  systems    ║
║            ║            ║             ║              ║             ║
╠════════════╬════════════╬═════════════╬══════════════╬═════════════╣
║            ║            ║             ║              ║             ║
║ FUNCTIONAL ║ FUNCTIONS  ║  Immutable  ║   Function   ║    Data     ║
║            ║(Transform) ║    data     ║ composition  ║ processing  ║
║            ║            ║             ║              ║             ║
╠════════════╬════════════╬═════════════╬══════════════╬═════════════╣
║            ║            ║             ║              ║             ║
║DECLARATIVE ║    WHAT    ║  Abstract   ║   Implicit   ║ UI, queries,║
║            ║  (Result)  ║             ║              ║   configs   ║
║            ║            ║             ║              ║             ║
╠════════════╬════════════╬═════════════╬══════════════╬═════════════╣
║            ║            ║             ║              ║             ║
║PROCEDURAL  ║ PROCEDURES ║   Shared    ║   Function   ║ Sequential  ║
║            ║ (Routines) ║    state    ║    calls     ║    tasks    ║
║            ║            ║             ║              ║             ║
╚════════════╩════════════╩═════════════╩══════════════╩═════════════╝
Enter fullscreen mode Exit fullscreen mode

Each paradigm offers a unique perspective on how to structure and solve problems in code. In the following articles, we'll explore each paradigm in depth with real-world analogies and practical Dart examples.


Further Reading

Dart Language Resources:

Programming Paradigms:

Community:


Originally published at projekt.github.io/articles. I'm Srđan Ljuština — I build small, privacy-friendly apps at srdapp.rs. Find me on LinkedIn and GitHub.

Top comments (0)