fluent_c_-_principles_practices_and_patterns_index

Fluent C - Principles, Practices, and Patterns Index

A

application binary interface (ABI), 210

avoiding poorly implemented

arrays, variable length, 63

Abstraction Layer pattern, 231-236, 256

assert statements, 13

Atomic Primitives pattern, 227-230, 257

association, versus aggregation, 133

Avoid Variants pattern, 220-224, 255,

Atomic Primitives pattern, 227-230, 257

266

authentication

further reading on, 243

error handling, 264

Isolated Primitives pattern, 224-227, 257

error logging, 266

overview of patterns for, 218, 242

automatic variables, 62

running example, 219

Avoid Variants pattern, 220-223, 255, 266

Split Variant]] Implementations, 236-242,

258

B

protecting header files with, 190

buffers, 112

weaknesses of, 217

build settings, 194

by-reference arguments, 100

  1. pragma once statements, 190

C

A

C functions, returning data from (see also func

abstract data types, 122

tions)

abstract pointers, 153

Aggregate Instance pattern, 103-107

Abstraction Layer pattern, 231-236, 256

Callee Allocates pattern, 116-119, 271

Aggregate Instance pattern, 103-107

Caller-Owned Buffer pattern, 111-114, 250

aggregation, versus association, 133

challenges of, 93

Allocation Wrapper pattern, 76-81

Immutable Instance pattern, 108-110

API Copy pattern, 207-211

Out-Parameters pattern, 99-102

APIs, flexible

overview of patterns for, xiii, 94, 120

challenges of designing, 147

Return Value pattern, 95-97, 252, 264

Dynamic Interface pattern, 156-158, 253

running example, 94

Function Control pattern, 159-162

C programming language

further reading on, 163

challenges of, viii-x

Handle pattern, 152, 269

Callback Iterator pattern, 177-181

Header Files pattern, 149-151, 248, 263

Callee Allocates pattern, 116-119, 271

interface compatibility, 210

Caller-Owned Buffer pattern, 111-114, 250

277

Caller-Owned Instance pattern, 132-136, 270

NULL pointers and, 82

central logging function, 249

problems with dynamic memory, 60

Cleanup Record pattern, 19-22

remote debuging, 247

code examples

returning error information, 48

obtaining and using, xvii

valgrind debuging tool, 78

references to examples presented in pat‐

Dedicated Ownership pattern, 72-75, 270

terns, xviii

dependency inversion principle, 148

code smells, 10

design patterns (see also individual patterns)

code variants, 225

approach to learning, xi

components, 202 (see also Self-Contained

benefits of, 259, 276

Component pattern)

challenges of C programming language, vii

cross-platform files, 255

definition of term, x

Cursor Iterator pattern, 172-176, 269

development of, x

overview of

D

data lifetime and ownership, xiv

data lifetime and ownership

error handling, xii, 4

Caller-Owned Instance pattern, 132-136, escaping

  1. ifdef hell, xvi

270

flexible APIs, xiv

further reading on, 145

iterator interfaces, xv

overview of patterns for, xiv, 122, 144

memory management, xiii

running example, 123

organizing files in modular programs, xv

Shared Instance pattern, 138-143

returning data from C functions, xiii

Software-Module with Global State pattern,

returning error information, xii

127-131, 251, 262

purpose of, vii

Stateless Software-Module pattern, 123-127

references to examples presented in pat‐

structuring programs with object-like ele‐

terns, xviii

ments, 121

references to published papers, xxi

data storage

selecting, xi, 247, 261

Dedicated Ownership pattern, application

structure of, x

of, 75

directories, configuring, 194 (see also Software-

defining and documenting clean up, 72

Module Directories pattern)

dynamic memory, 69

Dynamic Interface pattern, 156-158, 253

maintaining data for longer periods, 65

dynamic memory, 59-61, 69, 85

problems with dynamic memory, 59-61, 85

providing large pieces of immutable data,

E

108

error handling

reacting automatically to error situations, 76

challenges of, 3

selecting patterns for, 261

Cleanup Record pattern, 19-22

sharing data, 95, 111, 116

Function Split pattern, 6-8, 268

stack first approach, 62, 267

further reading on, 27

static memory, 66

Goto Error Handling pattern, 16-19

data, abstract types of, 122

Guard Clause pattern, 9-12, 268

debuging (see also error handling; error infor‐

Object-Based Error Handling pattern,

mation, returning)

22-24, 270

Dedicated Ownership and, 74

overview of patterns for, xii, 4, 26

detecting memory leaks, 70

running example, 5

eliminating memory errors, 63

Samurai Principle pattern, 12-16, 249, 265

Lazy Cleanup pattern and, 69

error information, returning

logging debug information, 77

challenges of, 29

278 | Index

further reading on, 55

returning relevant errors only, 45

Log Errors pattern, 48-52, 266

returning status information, 33

overview of patterns for, xii, 30, 55

separating initialization and cleanup, 23

Return Relevant Errors pattern, 39-43, 252, sharing state information or resources, 152

264

splitting into separate, 95

Return Status Codes pattern, 32-35, 267

splitting responsibilities, 6

running example, 30

using standardized, 221

Special Return Values pattern, 45-47, 270

unnoticed errors, 13

G

escaping

garbage collection

Eternal Memory pattern, 65-68, 251, 255, 262

dealing with lack of, 121

memory leaks and, 71

F

Global Include Directory pattern, 197-200, 248

files, organizing in modular programs

global variables, 95, 99, 103, 128

API Copy pattern, 207-211

Goto Error Handling pattern, 16-19

challenges of, 185

Guard Clause pattern, 9-12, 268

Global Include Directory pattern, 197-200,

248

H

Include Guard pattern, 189-192, 249, 263

Handle pattern, 152-155, 269

overview of patterns for, xv, 186, 216

header files (see also files, organizing in modu‐

running example, 187

lar programs)

Self-Contained Component pattern,

avoiding dependencies, 198

201-205

placing in subdirectories, 202

Software-Module Directories pattern,

placing only platform-independent func

192-195, 248, 264

tions in, 231

Stateless Software-Module pattern, 249

placing with implementation files, 193

fragmented memory, 60

protecting against multiple inclusion, 189

freed memory, 60

Header Files pattern, 149-151, 248, 263

Function Control pattern, 159-162

heap memory, 59

Function Split pattern, 6-8, 268

functions (see also C functions, returning data

from)

I

aborting programs in error conditions, 13

if statements, 20, 23

cleaning up multiple resources with, 16, 19, Immutable Instance pattern, 108-110

22

implementation details, hiding, 149

global instances and, 128

Include Guard pattern, 189-192, 249, 263

handling one kind of variant only, 228

Index Access pattern, 168-170, 252

hiding internal, 150

instances

improving readability, 9

definition of term, 121

iterating over elements, 168

sharing, 138

maintaining detailed error information, 48

software-modules and, 121

passing instances to, 138

interface compatibility, 210 (see also APIs, flex-passing meta-information about, 160

ible; Dynamic Interface pattern; iterator

placing only platform-independent in

interfaces)

header files, 231

interface segregation principle, 148

providing access to multiple threads, 132

Isolated Primitives pattern, 224-226, 257

retrieving one element at a time, 173

iterator interfaces

returning multiple pieces of information,

Callback Iterator pattern, 177-181

99, 103

Cursor Iterator pattern, 172-176, 269

Index | 279

designing flexible, 165

modular programs

further reading on, 183

organizing files in

Index Access pattern, 168-170, 252

overview of patterns for, xv

overview of patterns for, xv, 166, 182

modular programs, ease of maintaining, 149

running example, 167

(see also files, organizing in modular pro

grams)

L

multiline macros, 50

Lazy Acquisition pattern, 255

multithreaded environments, 101, 132, 177

Lazy Cleanup pattern, 69-71

lazy evaluation, 20

O

Linux overcommit, 84

Object-Based Error Handling pattern, 22-24,

Liskow substitution principle, 147

270

Log Errors pattern, 48-52, 266

object-like elements, 121

implementation example

open-closed principle, 147

central logging function, 249

organizing files (see files, organizing in modu‐

conditional logging, 252

lar programs)

context, 247

Out-Parameters pattern, 99-102

cross-platform files, 255

overcommit principle, 84

file logging, 254

file organization, 248

P

logging source filter, 250

packages, 185

multiple logging destinations, 253

passwords, 262

overview of patterns used, 259

patterns (see design patterns)

using the logger, 259

Pointer Check pattern, 81-83

pre-condition checks, 9

macros, multiline, 50

R

Makefiles, 194

resources

memory fragmentation, 85

acquiring and cleaning up multiple, 16, 19, memory leaks

22

deliberately creating, 70

lifetime and ownership of, 121

detecting, 70

sharing, 152

eliminating risk of, 63

Return Relevant Errors pattern, 39-43, 252, 264

garbage collection and, 71

Return Status Codes pattern, 32-35, 267

memory management

Return Value pattern, 95-97, 252, 264

Allocation Wrapper pattern, 76-81

return values, special, 45

challenges of, 57

returning data from C functions (see C func

data storage and dynamic memory, 59-61

tions, returning data from)

Dedicated Ownership pattern, 72-75, 270

returning error information (see error informa‐

Eternal Memory pattern, 65-68, 251, 255,

tion, returning)

262

further reading on, 90

Lazy Cleanup pattern, 69-71

S

U

V

Fair Use Sources

C Language: C Fundamentals, C Inventor - C Language Designer: Dennis Ritchie in 1972; C Standards: ANSI X3J11 (ANSI C); ISO/IEC JTC 1 (Joint Technical Committee 1) / SC 22 (Subcommittee 22) / WG 14 (Working Group 14) (ISO C); C Keywords, C Pointers, C Data Structures - C Algorithms, C Syntax, C Memory Management, C Recursion, C on Android, C on Linux, C on macOS, C on Windows, C Installation, C Containerization, C Configuration, C Compiler, C IDEs (CLion), C Development Tools, C DevOps - C SRE, C Data Science - C DataOps, C Machine Learning, C Deep Learning, C Concurrency, C History, C Bibliography, Manning C Programming Series, C Glossary, C Topics, C Courses, C Standard Library, C Libraries, C Frameworks, C Research, C GitHub, Written in C, C Popularity, C Awesome List, C Versions. (navbar_c)

Design Patterns: Design Patterns - Elements of Reusable Object-Oriented Software by GoF, Awesome Design Patterns, Awesome Software Design, Pattern, Design, Anti-Patterns, Code Smells, Best Practices, Software Architecture, Software Design, Design Principles, Design Patterns Bibliography, C Language Design Patterns, C++ Design Patterns, C# Design Patterns, Golang Design Patterns, Java Design Patterns, JavaScript Design Patterns, Kotlin Design Patterns, Node.js Design Patterns, Python Design Patterns, TypeScript Design Patterns, Scala Design Patterns, Swift Design Patterns. (navbar_designpatterns)


Cloud Monk is Retired (for now). Buddha with you. © 2005 - 2024 Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


fluent_c_-_principles_practices_and_patterns_index.txt · Last modified: 2023/09/28 14:19 by 127.0.0.1