News for hackers. Stuff that matters.
Re:A Theory of Software Architecture by kumarvvr on Wednesday October 28, 2020 @01:46AM (#24915643)
Move most of your code to pure functions, that is the number one mantra to solve most scaling problems in software development. Even in an OOP paradigm, it makes sense to make almost all objects as purely functional, with limited use of internal state.

The second mantra is to think a thousand times before you name something. I actually keep a list of names (..Manager, ..aggregator,etc.) gleaned from various sources, to name my classes. Earlier, I used to name most of my classes as <Function/Operation>Manager

Edit : Here is a question, that actually prompted me to keep a list.

https://stackoverflow.com/questions/1866794/naming-classes-h...

Re:A Theory of Software Architecture by jonahx on Wednesday October 28, 2020 @01:56AM (#24915698)
> (..Manager, ..aggregator,etc.)

Names ending in Manager are usually a poor choice.

See Peter Coad's "-er-er" principle:

> The “-er-er” principle. Challenge any class name that ends in “-er.” If it has no parts, change the name of the class to what each object is managing. If it has parts, put as much work in the parts that the parts know enough to do themselves.

See also: http://www.carlopescio.com/2011/04/your-coding-conventions-a...

Re:A Theory of Software Architecture by aryehof on Wednesday October 28, 2020 @02:51AM (#24915996)
I think the commenter generally views things as code acting on entities. If so, that code is suited to being called an xxxManager, or xxxService, or xxxCoordinator, or xxxController. Of course we have returned to a place in history by doing so, of creating big balls of mud as complexity increases.

Peter Coad advocated against this in favor of modeling the problem domain under consideration using an object oriented approach.

In an object oriented domain model there is no place for such external “controllers”, but I think the commenter doesn’t propose this approach.

Re:A Theory of Software Architecture by PaulDavisThe1st on Wednesday October 28, 2020 @08:58AM (#24918180)
I have an object called TransportMaster, with concrete implementations X_TransportMaster, Y_TransportMaster, Z_TransportMaster. The application instance may contain any number of any mixture of these objects, and they may be created and destroyed at any time by the user. Their use within the application is also subject to the user's whims.

Why would a TransportMasterManager, which provides factory methods, enumerations, a collection of the current set of TM's, and knowledge of the current user choice for which TM's is being used for what, have "no place" in this design?

Re:A Theory of Software Architecture by kumarvvr on Wednesday October 28, 2020 @08:51AM (#24918120)
>modeling the problem domain under consideration using an object oriented approach

Really curious. Do you have any material that explains this way of design?

I work on mostly web apps. End of the day, it's really about moving data and transforming data. So most of my programs have no choice but to deal with data, and so, my whole design process revolves around gathering, storing, operating upon and transferring data.

Re:A Theory of Software Architecture by cryptos on Wednesday October 28, 2020 @09:12AM (#24918315)
I don't know Peter Coad, but the approach reminds me of domain driven design (DDD). Most business logic would be in objects named entities, but DDD has also services, since there might be logic that affects multiple entities (actually special entities called "aggregate root").
Re:A Theory of Software Architecture by aryehof on Thursday October 29, 2020 @05:35AM (#24928682)
Peter Coad did write a number of books, which are pretty old and likely out of print. How to actually model a complex system into an object oriented domain model, is something I have long thought to teach. However, sadly there seems little appetite in a world currently dominated by procedural code acting on data, modeled using functional decomposition or through a relational data model. Of course our industry will eventually relearn the forgotten lessons and methods of the past, rename them as something new, and adopt them as the new silver bullet for software development.
Re:A Theory of Software Architecture by eatthoselemons on Wednesday October 28, 2020 @09:39AM (#24918595)
Perhaps you can explain this part from the post you linked which is perplexing me:

> AppDomainAffine, therefore, would be a more appropriate name. Unusual perhaps, but that's because of the common drift toward the mechanics of things and away from concepts (because the mechanics are usually much easier to get for techies)

how is 'AppDomainAffine' not a concept?

Re:A Theory of Software Architecture by danparsonson on Wednesday October 28, 2020 @10:34AM (#24919153)
I read that as saying that AppDomainAffine is a concept, and that's why it's an unusual name, because a lot of naming these days focuses on mechanics instead of concepts (c.f. MarshalByRefObject)
Re:A Theory of Software Architecture by eatthoselemons on Wednesday October 28, 2020 @11:32AM (#24919927)
ah okay that makes sense I was thinking it was opposite of that which made no sense
Re:A Theory of Software Architecture by nullsense on Wednesday October 28, 2020 @04:29AM (#24916523)
One of my favorite classes in my code base is called something FooBarBazListenerListener
Re:A Theory of Software Architecture by zmmmmm on Wednesday October 28, 2020 @03:23AM (#24916131)
> think a thousand times before you name something

I gave up .... I write mostly in languages that allow you to deterministically rename things with refactoring tools, so I frequently rename important classes 5 or 6 times before I'm done.

Re:A Theory of Software Architecture by marco_craveiro on Wednesday October 28, 2020 @05:20AM (#24916801)
Completely agree. I find that the right name takes ages to come about. Worse, it may require a lot of architectural refactoring that, many times, has nothing to do with the one entity you are trying to name. Instead, it is connected with the entire workflow you are designing. Nothing worse than spending ages coming up with the right name for a class, only to find out the entire class is not needed and you got the workflow all wrong :-) which I have done many a time, to be fair
Re:A Theory of Software Architecture by golergka on Wednesday October 28, 2020 @05:19AM (#24916796)
This.

Not only renaming, but re-bundling entities, moving layers, changing abstractions – refactoring is crucial during and immediately after development. As you implement your idea, you will inevitably find a better way to express it, and it's crucial to be able to re-do these things as many times as possible to reach the best possible result (if it's not a throwaway prototype, of course): no maintainer, including yourself a month later, will have a picture as full and clear as you right after finishing the first iteration.

Re:A Theory of Software Architecture by johnnylambada on Wednesday October 28, 2020 @06:06AM (#24917072)
I've been around long enough to remember a time before refactor->rename was a thing. Now naming can evolve as the class/variable evolves so there's so much less initial cognitive overhead worrying about a name than there once was.
Re:A Theory of Software Architecture by qznc on Wednesday October 28, 2020 @03:23AM (#24916130)
Likes more like a list of names to avoid for me. Manager, handler, controller, and service add little to no information. I try to find more specific verbs instead.

Distributor is a better one sometimes. For example, ConnectionDistributor instead of ConnectionManager if it accepts connections and distributes them to a thread pool.

Re:A Theory of Software Architecture by nottorp on Wednesday October 28, 2020 @06:38AM (#24917245)
Re:A Theory of Software Architecture by 0x445442 on Wednesday October 28, 2020 @12:56PM (#24921125)
The thing is a proper REST API is a Kingdom of Nouns. The core issue is that very few were doing object oriented programming and design the way it was intended. Giving me some leeway here, Kay's original idea was a programming model similar to that of the internet but in memory.

If one's position is that striving for a distributed model in memory is the wrong approach because of the inherent complexity associated with distributed systems that's fine but I rarely hear this argument. Typically, OOP/OOD is criticized based off of patterns that aren't proper.

Re:A Theory of Software Architecture by forgotmypw17 on Wednesday October 28, 2020 @02:04AM (#24915743)
Agree on the functional bit.

Naming things: I try to not think about it for more than 10 seconds, and go with the best I've got by then. I find myself renaming things sometimes, and I'm eager to do this when a better name comes to me.

Re:A Theory of Software Architecture by simongray on Wednesday October 28, 2020 @03:48AM (#24916279)
I use the thesaurus that comes with macOS whenever I think of a name and it just doesn't feel right. Then I typically find a more fitting name after spending 20 seconds looking at near synonyms.
Re:A Theory of Software Architecture by kumarvvr on Wednesday October 28, 2020 @02:41AM (#24915956)
I did try that. That is how I ended up with 50 "Manager" classes in my app.

At that point, it is a cognitive burden to handle so many "managers".

Re:A Theory of Software Architecture by chrisweekly on Wednesday October 28, 2020 @08:18AM (#24917849)
Shakespeare the software architect: "First kill all the Managers".
Re:A Theory of Software Architecture by SNACKeR99 on Wednesday October 28, 2020 @09:03AM (#24918230)
Before we shuffle off this mortal stack.
Re:A Theory of Software Architecture by jariel on Wednesday October 28, 2020 @02:24AM (#24915858)
Yes this. Naming is an intuitive thing, you can't force it, and it will get in the way, moreover, it's fluid and won't matter until later, things could change.

Just name it whatever and come back to it when it starts to matter more and you've probably thought of something better by then.

Re:A Theory of Software Architecture by philipov on Thursday October 29, 2020 @01:38AM (#24927602)
Renaming things is a luxury only enjoyed by people who don't have other people using their code downstream. Once people have used it, renaming things becomes a breaking change others in your organization will oppose.
Re:A Theory of Software Architecture by ramraj07 on Wednesday October 28, 2020 @02:12AM (#24915788)
Or hopefully your code reviewer suggests names that are better if your choice doesn't make sense
Re:A Theory of Software Architecture by forgotmypw17 on Wednesday October 28, 2020 @12:58PM (#24921155)
That is true. I am also the code reviewer at this time, but I do perform code reviews.
Re:A Theory of Software Architecture by fabb64 on Wednesday October 28, 2020 @03:27AM (#24916158)
Pure functions can also easily be memoized which can speed up processing.
Re:A Theory of Software Architecture by dheerajvs on Wednesday October 28, 2020 @02:40AM (#24915947)
Another pet peeve of mine is variable names suffixed with "Data" and "Info".
Re:A Theory of Software Architecture by ahartmetz on Wednesday October 28, 2020 @08:15AM (#24917833)
Yes, but... sometimes you have data about data (aka metadata) or about a thing, in which case "...Info" is the best thing I know of. Say FileInfo or ProgramInfo (e.g. a CNC machine program).
Re:A Theory of Software Architecture by Lio on Wednesday October 28, 2020 @10:11AM (#24918898)
Worst variable name I’ve ever seen was “data2”. There was no longer a “data” in that code but presumably there had been at one point.
Re:A Theory of Software Architecture by oaiey on Wednesday October 28, 2020 @01:49AM (#24915666)
Kill "Manager" of that list :). Adds to the naming burden (aka quality) by removing the fallback :).

I will adopt the list idea!!!

Re:A Theory of Software Architecture by 0x445442 on Wednesday October 28, 2020 @12:58PM (#24921157)
It's an old talk but it zero's in on a point that is tremendously over looked in discussions about OOP/OOD.

https://www.infoq.com/presentations/Making-Roles-Explicit-Ud...

Re:A Theory of Software Architecture by oaiey on Wednesday October 28, 2020 @01:53AM (#24915686)
Pure functions are a good solution for a onion in a request / response pattern (which a lot of the scenarios are). However, an onion architecture representing something with state (e.g. a shadow Dom implementation), sometimes a OO inner core is the right solution.
Re:A Theory of Software Architecture by hnxs on Wednesday October 28, 2020 @02:19AM (#24915831)
Would love to see your list of names if you’re willing to share!
Re:A Theory of Software Architecture by kumarvvr on Wednesday October 28, 2020 @02:34AM (#24915913)
Re:A Theory of Software Architecture by nendroid on Wednesday October 28, 2020 @01:16PM (#24921431)
It's not just pure functions. Two things break modularity: Free variables and mutation.

The problem with OOP is that no method is truly pure, no method is a combinator.

   class Thing
      var memberVar
      def addOne():
          return memberVar+1;

The above is an example of your typical class. AddOne is not modular because it cannot be used outside of the context of Thing.

You can use static functions but the static keyword defeats the purpose of a class and makes the class equivalent to a namespace containing functions.

   class Thing
      static def add(x):
           return x + 1;
the above is pointless. Just do the below:

   namespace Thing:
       def add(x):
           return x + 1; 
The point of OOP is for methods to operate on internal state. If you remove this feature from OOP you're left with something that is identical to namespaces and functions.

Use namespaces and functions when all you have are pure functions and use classes when you need internal state... there is literally no point for OOP if you aren't using internal state with your classes.

Re:A Theory of Software Architecture by Areading314 on Wednesday October 28, 2020 @01:51AM (#24915672)
Scaling is not the only way to accomplish high-performance. In many cases performance can be achieved with stateful, imperative yet efficiently executed code that economizes on the use of resources on a single node. In many cases, such as for mobile, desktop, or on-prem deployments, this is the only way to "scale" since you do not have the luxury of increasing number of nodes on demand.
Re:A Theory of Software Architecture by tarruda on Wednesday October 28, 2020 @01:55AM (#24915693)
I think the parent comment is talking about scaling in terms of software size, not performance.
Re:A Theory of Software Architecture by kumarvvr on Wednesday October 28, 2020 @02:43AM (#24915965)
I meant scaling of software development. As in, how to make sense of large amounts of code.