TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

When objects are not enough (2021)

77 pointsby o2l10 months ago

12 comments

bob102910 months ago
The objects are just one tool. You usually need a few to do the job well.<p>The biggest thing I&#x27;ve seen blow up actual OOP projects has been a lack of respect for circular dependencies in the underlying domain. If you have one of those problems where it is ambiguous which type &quot;owns&quot; another type, then the moment you start writing methods in these types you are treading into the dark forest. Often times it is unclear that your problem exhibits circular dependencies until code is already being written and shipped.<p>My approach to these situations is to <i>start</i> with a relational data model. A SQL schema (and its representative DTOs) can model circular dependencies competently. You can then have additional object models (views) that can be populated by the same relational data store (just a different query). One other advantage with the relational modeling approach is that it is very easy to explain things to the business <i>before you write a single line of code</i> [0]. The purpose of a SQL table can be demonstrated with a sample excel sheet with mock business data.<p>This path was largely inspired by Out of the Tar Pit [1] and practical experience in fairly wicked domains (semiconductor mfg., banking, etc). I am not sure <i>Functional</i> Relational Programming is the answer for everything, but the &quot;Relational&quot; part certainly seems to be universally applicable.<p>[0]: <a href="https:&#x2F;&#x2F;en.wikiquote.org&#x2F;wiki&#x2F;Fred_Brooks#:~:text=Show%20me%20your%20flowcharts%20and,%3B%20they&#x27;ll%20be%20obvious" rel="nofollow">https:&#x2F;&#x2F;en.wikiquote.org&#x2F;wiki&#x2F;Fred_Brooks#:~:text=Show%20me%...</a>.<p>[1]: <a href="https:&#x2F;&#x2F;curtclifton.net&#x2F;papers&#x2F;MoseleyMarks06a.pdf" rel="nofollow">https:&#x2F;&#x2F;curtclifton.net&#x2F;papers&#x2F;MoseleyMarks06a.pdf</a>
评论 #41074218 未加载
mattgreenrocks10 months ago
I want to re-read this and think about it more.<p>But one thing stuck out: I never liked most of the distillation of actions as clean architecture would advocate for, be they lambdas in class form (DepositAction) or interactors. I feel strongly that they are the right thing in describing business logic, however.<p>What did click for me is the conceit of a service, which the JVM world embraces. Services are plain old objects that have a method for each action you&#x27;d like to model. This is nicer than the aforementioned approaches because there is often common code to different actions. Like actions, services are the place where validation happens, persistence happens, and all of the interesting business logic. IO and orthogonal concerns are injected into them (via constructor), which lets you write tests about the core logic pretty easily.<p>What you get is the ability to reason about what happens without the incidental complexity of the web. Web handlers then boil down to decoding input, passing it to the service, examining the result of calling an action, and then outputting the appropriate data.<p>That&#x27;s all they should&#x27;ve ever been doing. :)
评论 #41075329 未加载
ChrisMarshallNY10 months ago
<i>&gt; An object has state and operations combined.</i><p>My own definition has always been that an object has state and <i>identity</i>.<p>I have never considered functions&#x2F;methods to be a requirement for something to be an object.
评论 #41071669 未加载
评论 #41075336 未加载
评论 #41068445 未加载
PaulHoule10 months ago
+1 for use of the word &quot;Reification&quot;!<p>There&#x27;s another universe of object-adjacent systems that may or may not be connected with conventional OO programming languages. Two examples I&#x27;d point to are Microsoft&#x27;s COM (designed so it is straightforward to write and call COM objects from C) and the &quot;objects&quot; in IBM&#x27;s OS&#x2F;400. In both of those cases I think the reification is the important thing, although you can see reification in Java&#x27;s object headers where objects get a number of attributes necessary for garbage collection, concurrency control, etc.
评论 #41073602 未加载
ryandv10 months ago
&gt; Smalltalk was one of the first Object-Oriented Programming Languages out there. It&#x27;s where ideas like inheritance and message-passing came from (or at least where they got popular, from what I understand);<p>It may be worth pointing out that while Smalltalk is arguably one of the key languages that popularized such ideas and other OOP concepts, these were first introduced by Simula 67.
adityaathalye10 months ago
I enjoyed this post a lot. I happened to blog about the same thing from the FP side of things [1] (well, because Closures are just the poor man&#x27;s Objects).<p>Generally, I don&#x27;t know how to (philosophically) navigate the tensions between Functional &#x2F; Object Oriented &#x2F; Imperative &#x2F; Declarative paradigms, except to remind myself about <i>The Thing That Actually Matters</i> (in my estimation)... to always remember that The State is the frenemy.<p><i>For the love of State is the root of all evil: which while some coveted after, they have erred from Lambda the Ultimate, and pierced themselves through with many sorrows.</i> --- Yours Truly.<p>:)<p>[1] <a href="https:&#x2F;&#x2F;www.evalapply.org&#x2F;posts&#x2F;what-makes-functional-programming-systems-functional&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;www.evalapply.org&#x2F;posts&#x2F;what-makes-functional-progra...</a><p>(edit: forgot to link to blog post)
artemonster10 months ago
I never liked „OOPs world“ obsession with a receiver. Why the hell receiver of a message gets to dispatch the implementation at very late moment? Why not context? And when there are many receivers? I.e. a composite object of an int and a float receive message „add“ - who decides which implementation to use and why the heck any of them may even know how to add self to another? There were many attempts to solve this and all were horrible (i.e. extension methods). I have been experimenting with these concepts too (i.e. a receiverless message is a throw, which will be picked up by an enclosing effect handler via pattern match), but its all unreadable and unmaintainble mess. Anyone doing the same thing? I would love to exchange thoughts :) extras to read: ian piumarta‘s papers on his OOP system and a paper on Korz programming language
评论 #41068307 未加载
评论 #41068491 未加载
评论 #41074096 未加载
评论 #41072825 未加载
评论 #41074375 未加载
stonethrowaway10 months ago
I want to agree with this but it’s a surface level concern. I’m not trying to belittle the author’s point but I do want to emphasize something that isn’t talked about enough.<p>Reification has two meanings in software development. Author uses one, the more familiar one - it’s discussed in many books on DDD. The other is a bit more vague and unapproachable. It’s the one I want to bring to peoples attention. It can be summed up as: “Accounts, transactions and balances are not enough.”<p>Jim Weirich hints at this perfectly in his approach to solving the Coffee Maker [0]. I’ll quote the punch line for everyone:<p>&gt; Some people may be uncomfortable with the divergence of the Analysis and the Design models. Perhaps they expect that the design model will just be a refinement of the analysis. Remember that analysis is an attempt to understand the problem domain. Although we use OO tools to represent our understanding, that understanding has only an indirect influence on the structure of the software solution (in that the software must actually provide a solution). In fact, as we refine our software design, we will find that it moves even farther away from the analysis model. Solutions oriented classes, which do not appear in analysis, will be added to the design. Classes that came from the analysis model may mutate or even disappear entirely.<p>This is the form of reification that I believe is more closely associated with how the term is used in classical OOD (f.e. Object Oriented Software Engineering: A Use Case Driven Approach), but I suppose people’s experiences may disagree. This is a kind of “right layer of abstraction” that has to be pontificated and not just put down as an object because it’s a process or a “thing” from the outwardly-behavioural view of the situation.<p>As I mentioned, it’s not talked about enough. Jim is right to call it out: it’s uncomfortable because it’s having to dig deep into the system ontology.<p>[0] <a href="http:&#x2F;&#x2F;www.cs.unibo.it&#x2F;cianca&#x2F;wwwpages&#x2F;ids&#x2F;esempi&#x2F;coffee.pdf" rel="nofollow">http:&#x2F;&#x2F;www.cs.unibo.it&#x2F;cianca&#x2F;wwwpages&#x2F;ids&#x2F;esempi&#x2F;coffee.pdf</a>
deterministic10 months ago
What works for me:<p>There are two types of objects: State objects and Tool objects.<p>The purpose of a State object is to maintain a state. Think strings, databases, files etc.<p>The purpose of a Tool object is to operate on State objects. Think loaders, printers, editors, transformers etc.<p>It’s a simple way to organise OO code. And it works. At very large scale (millions of lines of C++).<p>It is similar to the functional Data&#x2F;Function thinking. However it actually works better because State objects can enforce constraints, and Tool objects can cleanly maintain an internal temporary state while operating on State objects.
wseqyrku10 months ago
Objects are just the poor man&#x27;s actors. If you want to see what encompasses objects and more, look up the actor model.<p>That&#x27;s what I thought this article is going to talk about but not even a honorary mention.
smitty1e10 months ago
Needs &quot;2021&quot; in the headline
menotyou10 months ago
Yet another article about problems you&#x27;d never have if you wouldn&#x27;t use object oriented paradigm.
评论 #41072760 未加载
评论 #41075441 未加载