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.

Growing object-oriented software vs. what I would do

2 pointsby mindBalmost 4 years ago

1 comment

tedyoungalmost 4 years ago
It&#x27;s true, &quot;good&quot; Object-Oriented Java code is hard to find, because it&#x27;s not taught very well (or is taught completely wrong, e.g., using &quot;getters&quot; and &quot;setters&quot; to &quot;encapsulate&quot; data).<p>However, I think it&#x27;s also true what the author says in terms of not everything is like an object, thought I would say that Domain-Driven Design&#x27;s idea that there are multiple _kinds_ of objects: Entities and Value Objects, and that they serve different purposes. In addition, there are data-only things used to carry data around and especially across internal&#x2F;external boundaries, those are Data Transfer Objects. With those three, I&#x27;ve found I can teach OOP to folks and get them to understand it as long as I get across one last concept: all method calls should be Commands or Queries.<p>When the author says:<p>&gt; All calls between objects are unidirectional: no public method of an actual object (not a plain data class) returns any value.<p>That&#x27;s close, because _most_ of the methods are Commands (requests for an object to change the state for which it&#x27;s responsible), and anything left are Queries (what&#x27;s your current state?).<p>&gt; Does everybody else find it so obvious that it&#x27;s not worth mentioning and I&#x27;m the clown that didn&#x27;t realize it?<p>No, it&#x27;s not said enough, and you&#x27;re not a clown. The clowns are those that teach getters and setters right after they teach you about classes and don&#x27;t tell you that the _entire_ purpose of an object is Behavior not Data. Alas, they teach this because it&#x27;s what they were taught (and it doesn&#x27;t help that the AP Computer Science curriculum in the USA explicitly teaches this).