Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is an alternate model, used in the Scala language, but which can really be used anywhere. It's the Constructor/Extractor model. Constructor is just that, the constructor of a class. The extractor is a method which, when called, will return the parameters which, passed to a Constructor, will create a clone of this object.</p> <p>For dynamic languages, you just return a list and be done with it. For statically typed languages, you can go the way of a list of objects, which must then be processed to that each type can be correctly assigned, or you must have a type-parameterized tuple class, so that you can return each parameter with the correct type.</p> <p>In the specific case of Scala, its Extractors are similar to Java's static methods, and they receive an object as input. It either returns the parameters, or it returns <code>None</code>, which performs a function analogue to Java's <code>null</code>.</p> <p>The idea is that you can decompose what you composed, which is pretty much what a view might want.</p> <p>Now, another notion you might have is that "tell, don't ask" intends to keep business rules <em>with</em> the data it applies to. Now, the business rules of a view necessarily belongs with the view, so you are left with the problem of having to ask the model for the data... if you don't invert the game. The model might <em>tell</em> the view to display data, passing the relevant fields to it instead of being asked for them. So the model tells the view to display data, and the view tells the model to update it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload