/ story-11-Objects-and-Operations-2.org
story-11-Objects-and-Operations-2.org
1 #+TITLE: Story 11 - Objects and Operations, revisited 2 #+OPTIONS: author:nil date:nil 3 4 In [[file:story-7-Objects-and-Operations.org][Story 7 - Objects and Operations]], Data Object constructors (*Import*, 5 *Generate*, *Load*) are presented as Data Object functions with parameter 6 sets. 7 8 However, with the revocation of the overly complex ideas on parameter sets, 9 this also needs some rethinking. 10 11 * A word on parameters and parameter sets 12 13 Parameter sets were supposed to be a set of typed data that the Le'Sec 14 libraries would have no knowledge about, and would leave it completely to 15 the application to know what to pass, and to individual implementations 16 (dispatches) to handle. 17 18 That idea still applies, but the design was over-reaching, and consequently 19 bulky, and needed to be simplified in its core. 20 21 Experiments showed that it was much simpler to have implementations that 22 need it implement two functions, one to get a parameter value and one to set 23 it, with the parameter selected with a simple number. The caller /must/ 24 know the exact form that this value takes. 25 26 Exactly how the caller would find out this exact form is subject for 27 [[file:story-12-Parameters.org::+TITLE: Story 12 - Parameters][another story]]. 28 29 * A word on parameters in the context of Objects and of Operations 30 31 A distinction between Objects and Operations could be made that Objects to 32 not have general parameters, while Operations do. 33 34 That doesn't mean that Objects can't provide data at all, but it essentially 35 means that data it can provide is determined by the Object Class that it 36 implements rather than by the implementation. Object parameters revolve 37 more around the payload of the Object, while Operation parameters revolve 38 more around the functionality of that Operation. 39 40 * Changes in Object functionality 41 42 The Object functionality in [[file:story-7-Objects-and-Operations.org][Story 7 - Objects and Operations]] is quite 43 complex, too complex even. Experimentation showed that the idea of pieces 44 and selections was big source of confusion, so things were changed a bit. 45 46 It was determined that for the /basic/ functionality needs, the following 47 functionality would cover most of it: 48 49 - Generate :: 50 51 This generates an Object payload, hopefully randomly, given hints that the 52 functionality would receive in parameter form. 53 54 - Construct :: 55 56 This constructs an Object payload from payload data received in parameter 57 form. 58 59 - Extract :: 60 61 This extracts Object payload data in parameter form. 62 63 But this is not enough... 64 65 * Viewing some Object functionality as Operations 66 67 The Data Object constructor functionality as well as the extractor can be 68 seen as Operations performed with the associated Object, but by nature, they 69 are especially tightly tied to the associated Object. 70 71 A solution for this is to move away from the constructor and extractor 72 functionality being provided directly by the Data Object, and move to have 73 the Data Object provide the following functionality instead: 74 75 - *Get Generator* 76 - *Get Constructor* 77 - *Get Extractor* 78 79 All of these would do the same thing, to return an ephemeral Operation 80 instance, with which all sorts of things can be done, including dealing with 81 parameters and whatever the implementation allows, and finally call a per 82 Operation specific function to finalize whatever it does. 83 84 The responsibility to keep track of these ephemeral Operations would remain 85 with the associated Object, so as to not place undue burden on the 86 application. 87 88 In terms of a Data Object type factory, each of these operation types can be 89 implemented incrementally, as an extension to the base Object factory, or 90 any specialised Object type. 91 92 ** What happened with the other Object functionality? 93 94 *Import*, *Export* and *Load* are now deferred, they have been deemed 95 unnecessary at this stage. They are not lost, though, they will just be 96 picked up later.