There is an alternative model used in Scala, but which can really be used anywhere. This is a constructor / extractor model. A constructor is just a class constructor. An extractor is a method that, when called, returns the parameters that are passed to the constructor, creating a clone of this object.
For dynamic languages, you simply return the list and execute it. For statically typed languages, you can go to the list of objects that must then be processed so that each type can be correctly assigned, or you must have a tuple type with a parameter so that you can return each parameter with the correct type.
In a specific case of Scala, its Extractors are similar to static Java methods, and they receive the object as input. It either returns parameters or returns None , which performs an analog analogue with Java null .
The idea is that you can decompose what you have created, which can pretty much have an idea.
Now, another concept that you might have is that “tell, don't ask” intends to support business rules with the data to which it relates. Now the business rules for the presentation are necessarily related to the presentation, so you have a problem with querying the data model ... if you do not invert the game. A model can display a view to display data by passing them the appropriate fields, rather than requesting them. Thus, the model tells the view to display data, and the view tells the model about its update.
source share