
Why Atomic Query Construction (AQC) Intentionally Uses Arrays Instead of DTOs
One question keeps appearing whenever someone looks at the Atomic Query Construction (AQC) pattern for the first time: Why are parameters passed as arrays instead of DTOs? At first glance, DTOs sound like the “cleaner” solution. They provide type safety, structure, and explicit contracts. In many architectures, DTOs make perfect sense. But AQC is intentionally designed around arrays, and replacing them with DTOs would undermine one of the core ideas of the pattern. To understand why, we need to look at how AQC actually works. AQC Is Parameter-Driven The central idea behind AQC is simple: Parameters shape the query. Each parameter activates a specific atomic piece of logic. For example: $params = [ 'category_id' => 5 , 'min_price' => 100 , 'max_price' => 500 , 'with' => [ 'brand' ] ]; Inside the query class: $query = Product :: query (); if ( ! empty ( $params [ 'category_id' ])) { $query -> where ( 'category_id' , $params [ 'category_id' ]); } if ( ! empty ( $params [ 'min_price' ])) {
Continue reading on Dev.to Webdev
Opens in a new tab



