frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

On Having a Data Object

https://www.natemeyvis.com/on-having-a-data-object/
36•Theaetetus•5d ago

Comments

reillyse•14h ago
The fact that people expect a data object, as argued by the author, is a very strong argument in favor of having one.

Onboarding new programmers to your codebase and making the codebase simpler for developers to reason about is a massive non-functional benefit. Unless you have a very strong reason to do things otherwise, follow the principle of "least surprise". In fact vibe coding adds another layer to this - an LLM generally expects the most common pattern - and so maintenance and testing will be orders of magnitude easier.

hexbin010•14h ago
It's a trade off like everything. More DTOs means more mapping, more coming up with names, more files etc. There's definitely a middle ground.

You can (should) also apply it selectively. Eg for auth, I'd never want a single UserDTO used for creating and displaying a user - creating a user requires a password, a field you don't want when retrieving a user, to avoid mistakes.

I know DDD advocates would say that you're then not being true to DDD, but yes that's business. It's very very hard to get everyone to agree with the reduced velocity of 100% adherence to DDD for an extended period. In my experience it starts off as "this is great" then people start hate reviewing PRs for simple changes that have 28 new files (particularly in Java) and they quietly moan to the boss about being slowed down by DDD

codemonkey-zeta•13h ago
Author is on the verge of having a Clojure epiphany.

> 1. You should often be using different objects in different contexts.

This is because "data" are just "facts" that your application has observed. Different facts are relevant in different circumstances. The User class in my application may be very similar to the User class in your application, they may even have identical "login" implementations, but neither captures the "essence" of a "User", because the set of facts one could observe about Users is unbounded, and combinatorially explosive. This holds for subsets of facts as well. Maybe our login method only cares about a User's email address and password, but to support all the other stuff in our app, we have to either: 1. Pass along every piece of data and behavior the entire app specifies 2. Create another data object that captures only the facts that login cares about (e.g. a LoginPayload object, or a LoginUser object, Credential object, etc.)

Option 1 is a nightmare because refactoring requires taking into consideration ALL usages of the object, regardless of whether or not the changes are relevant to the caller. Option 2 sucks because your Object hierarchy is combinatorial on the number of distinct _callers_. That's why it is so hard to refactor large systems programmed in this style.

> 3. The classes get huge and painful.

The author observed the combinatorial explosion of facts!

If you have a rich information landscape that is relevant to your application, you are going to have a bad time if you try modeling it with Data Objects. Full stop.

See Rich Hickey's talks, but in particular this section about the shortcomings of data objects compared to plain data structures (maps in this case).

https://www.youtube.com/watch?v=aSEQfqNYNAc

bccdee•10h ago
> Option 2 sucks because your Object hierarchy is combinatorial on the number of distinct _callers_.

I kinda like that. Suppose we do something like `let mut authn = UserLoginView.build(userDataRepository); let session = authn.login(user, pwd)`. You no longer get to have one monolithic user object—you need a separate UserDataRepository and UserLoginView—but the relationship between those two objects encodes exactly what the login process does and doesn't need to know about users. No action-at-a-distance.

I've never used clojure, but the impression I get of its "many functions operating over the same map" philosophy is that you trade away your ability to make structural guarantees about which functions depend on which fields. It's the opposite of the strong structural guarantees I love in Rust or Haskell.

codemonkey-zeta•5h ago
> you trade away your ability to make structural guarantees about which functions depend on which fields

You might make this trade off using map keys like strings or keywords, but not if you use namespace qualified keywords like ::my-namespace/id, in combination with something like spec.alpha or malli, in which case you can easily make those structural guarantees in a way that is more expressive than an ordinary type system.

oftenwrong•13h ago
There is something to be said for having some basic data access libraries already in place, even if they are not ideal, so that developers can bang out functionality more quickly. That is the typical selling point of ORMs, isn't it? While there are well-known downsides, you can skip the ORM when it's not a good fit, or later when you realise that it is causing a problem.

Generally, I prefer to create functions for specific queries, rather than for specific "entity" types, and the return type of each query matching the result of the query. This fits with the reality that queries often involve multiple entity types.

My favourite application-later database tool so far is https://www.jooq.org/ because it allows for code generation from the database schema, allowing for type-safe construction of queries. I find this makes it easier to create and maintain queries. It is a relatively unopinionated power tool, with minimal attempts at "automagic" behaviour. I find myself missing jOOQ now that I am not working much with Java.

rokkamokka•8h ago
In my experience (in our rather large MVC-style Laravel code base) DTOs are almost always an unnecessary abstraction. I'm much more content just shuffling actual Models around, with small methods that map these to whatever format the client then requires. I've refactored away many a DTO added by junior developers and the code is always much simplified.
Noumenon72•8h ago
I'm not sure I understand the different approaches being compared here. Are you opposing 1 and supporting 2?

  1. HatsService with methods .get_hats(), .throw_hats()  
  2. wearable_hats = db.query(Hats).map(hat => WearableHatDto(hat)
     throwable_hats = db.query(Hats).map(hat => ThrowableHatDto(hat)

Visopsys: OS maintained by a single developer since 1997

https://visopsys.org/
215•kome•6h ago•34 comments

Pomelli

https://blog.google/technology/google-labs/pomelli/
101•birriel•5h ago•30 comments

How I use every Claude Code feature

https://blog.sshh.io/p/how-i-use-every-claude-code-feature
106•sshh12•4h ago•30 comments

Claude Code can debug low-level cryptography

https://words.filippo.io/claude-debugging/
247•Bogdanp•9h ago•125 comments

Updated practice for review articles and position papers in ArXiv CS category

https://blog.arxiv.org/2025/10/31/attention-authors-updated-practice-for-review-articles-and-posi...
427•dw64•13h ago•198 comments

Anonymous credentials: rate-limit bots and agents without compromising privacy

https://blog.cloudflare.com/private-rate-limiting/
43•eleye•3h ago•14 comments

GHC now runs in the browser

https://discourse.haskell.org/t/ghc-now-runs-in-your-browser/13169
269•kaycebasques•12h ago•85 comments

Crossfire: High-performance lockless spsc/mpsc/mpmc channels for Rust

https://github.com/frostyplanet/crossfire-rs
11•0x1997•1h ago•0 comments

Show HN: Why write code if the LLM can just do the thing? (web app experiment)

https://github.com/samrolken/nokode
266•samrolken•10h ago•193 comments

3M Diskette Reference Manual (1983) [pdf]

https://retrocmp.de/fdd/diskette/3M_Diskette_Reference_Manual_May83.pdf
40•susam•5d ago•9 comments

Beginner-friendly, unofficial documentation for Helix text editor

https://helix-editor.vercel.app/start-here/basics/
107•Curiositry•9h ago•33 comments

SQLite concurrency and why you should care about it

https://jellyfin.org/posts/SQLite-locking/
271•HunOL•15h ago•115 comments

SailfishOS: A Linux-based European alternative to dominant mobile OSes

https://sailfishos.org/info/
201•ForHackernews•6h ago•83 comments

Automatically Translating C to Rust

https://cacm.acm.org/research/automatically-translating-c-to-rust/
15•FromTheArchives•1w ago•0 comments

The Smol Training Playbook: The Secrets to Building World-Class LLMs

https://huggingface.co/spaces/HuggingFaceTB/smol-training-playbook
153•kashifr•2d ago•8 comments

How to Build a Solar Powered Electric Oven

https://solar.lowtechmagazine.com/2025/10/how-to-build-a-solar-powered-electric-oven/
22•surprisetalk•1w ago•11 comments

A Few Words About Async

https://yoric.github.io/post/quite-a-few-words-about-async/
17•vinhnx•3h ago•0 comments

Sufficiently Smart Compiler

https://wiki.c2.com/?SufficientlySmartCompiler
3•coffeeaddict1•4d ago•0 comments

Why "everyone dies" gets AGI all wrong

https://bengoertzel.substack.com/p/why-everyone-dies-gets-agi-all-wrong
67•danans•3h ago•126 comments

The hardest program I've ever written (2015)

https://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/
71•jacobedawson•3d ago•38 comments

OpenDesk by the Centre for Digital Sovereignty

https://www.opendesk.eu/en/product
40•athousandsteps•6h ago•4 comments

Hard Rust requirements from May onward

https://lists.debian.org/debian-devel/2025/10/msg00285.html
347•rkta•21h ago•614 comments

RegEx Crossword

https://jimbly.github.io/regex-crossword/
29•a022311•4d ago•11 comments

CharlotteOS – An Experimental Modern Operating System

https://github.com/charlotte-os/Catten
154•ementally•15h ago•77 comments

Chat Control proposal fails again after public opposition

https://andreafortuna.org/2025/11/01/chat-control-proposal-fails-again-after-massive-public-oppos...
473•speckx•11h ago•130 comments

Show HN: A simple drag and drop tool to document and label fuse boxes

https://github.com/alexadam/fuse-box-labels
9•eg312•1d ago•2 comments

Word2vec-style vector arithmetic on docs embeddings

https://technicalwriting.dev/embeddings/arithmetic/index.html
55•kaycebasques•9h ago•11 comments

Show HN: KeyLeak Detector – Scan websites for exposed API keys and secrets

https://github.com/Amal-David/keyleak-detector
16•amaldavid•5h ago•5 comments

I built my own CityMapper

https://asherfalcon.com/blog/posts/5
125•ashfn•5d ago•17 comments

Austria: Pylons as sculpture for public acceptance of expanding electrification

https://www.goodgoodgood.co/articles/austrian-power-giants-power-line-animals
101•Geekette•4d ago•46 comments