Devs like to talk about imagining the shape of the code or data and when people say that, all I can think of is a circle and square, traditional shapes and I can't get past that mental model.
Whenever it is explained to me I'm lost and have no idea what it means.
Can someone help me understand this?
Top comments (11)
The way data is structured/organized defines it's "shape".
TypeScript specifically has type aliases so you may see something like:
So in terms of TypeScript
Sinkis viewed as a "type" - which defines it's shape - the way the data is structured/organized (rather than viewing it as an object literal); an
isStaleproperty with a
refreshproperty with a function that returns a
sourcesproperty that nests zero or more
Sourcedata structure in a
Sinkinstance when talking about how it organizes its data.
So while Rust has
So basically an object literal? Hmm. I've heard of structs in C and languages like it. I'll check out the links you've linked here.
"shape" is a much looser concept than that.
For example in the Clojure spec guide:
From the Racket rebellion documentation:
"shape" seems to be primarily used in contexts where structured data is represented by a collection of key/value pairs where order doesn't necessarily matter. Compare that to a C
structwhich specifies memory layout so order does matter and "structure" implies a more rigid organization. Though both terms are used in a rather informal manner.
Note that when arrays are used as tuples (wikipedia):
they could manifest a shape.
Order matters as the key is coupled to the position so a tuple would have shape and structure.
In the context of class-based objection orientation "shape" sometimes refers to the public interface while "structure" also reveals the internal organization.
Maybe it's to do with the structure of data, like how deeply nested a JSON object's properties go...
I've never heard that expression. Do you have a concrete example? I've heard design of the code (often related to en.wikipedia.org/wiki/Software_des...) or structure or data. But not "shape".