Log message #4153213

# At Username Text
# Jun 22nd 2018, 08:14 birdy247 and if when saving a Pen, it looks at the 'StationaryCubpaordForPenRules" to see if it needs to save a Ruler
# Jun 22nd 2018, 08:14 neon1024 `function build(?Pen $pen, ?Ruler $ruler): Stationary`
# Jun 22nd 2018, 08:13 neon1024 Or chain them from the initial parent id. With it’s own class you have more freedom :slightly_smiling_face:
# Jun 22nd 2018, 08:13 birdy247 ok, this sounds good
# Jun 22nd 2018, 08:13 neon1024 You could even have a method which creates a whole collection from id’s or something
# Jun 22nd 2018, 08:12 neon1024 The advantage for me here is that I can use that class anywhere
# Jun 22nd 2018, 08:12 birdy247 Pens, Rulers etc... all belongTo an invoiceItem
# Jun 22nd 2018, 08:12 birdy247 I kind of alreayd have stattionary
# Jun 22nd 2018, 08:12 neon1024 Just my thoughts anyway :slightly_smiling_face:
# Jun 22nd 2018, 08:11 neon1024 I mean, urgh, I can’t believe I’ll say this, you could make magic methods for `has{Thing}()`
# Jun 22nd 2018, 08:10 neon1024 `$stationary->hasPen()` `$stationary->hasRuler()`
# Jun 22nd 2018, 08:10 neon1024 Then you can have whatever accessor methods you like
# Jun 22nd 2018, 08:10 neon1024 So the way the objects are dependent is represented in code
# Jun 22nd 2018, 08:10 neon1024 Then you can just add extra methods in the class to create Rulers, Highlighters, Protractors
# Jun 22nd 2018, 08:09 neon1024 `public function save(array $data){ if (!empty($data['Pen']) { $this->Pen = $this->Pens->createEntity($data['Pen']) }` etc
# Jun 22nd 2018, 08:09 neon1024 Then the class just has
# Jun 22nd 2018, 08:09 neon1024 `$stationary = new Stationary();` `$stationary->save($dataArray)` perhaps
# Jun 22nd 2018, 08:08 neon1024 No, wai t asec
# Jun 22nd 2018, 08:07 neon1024 `$stationary = new Stationary(Pen $pen, Ruler $ruler);`
# Jun 22nd 2018, 08:07 neon1024 If the objects are tightly coupled, wrapping up the way they are created feels logical to me
# Jun 22nd 2018, 08:06 birdy247 Thats why I put the logic into Listeners, as it never really felt like it belonged anywhere
# Jun 22nd 2018, 08:06 birdy247 The main issue is, if a Pen needs to save a Ruler, is dpendent on some other information
# Jun 22nd 2018, 08:05 birdy247 but are you suggesting to move this into another class?
# Jun 22nd 2018, 08:05 birdy247 Everything we are saving is rpresented by a cake model
# Jun 22nd 2018, 08:05 birdy247 It feels quite complex whats happening, but I know it could be made beautfiully simple
# Jun 22nd 2018, 08:04 birdy247 continuous improvement :slightly_smiling_face:
# Jun 22nd 2018, 08:04 birdy247 no not at all
# Jun 22nd 2018, 08:04 neon1024 #braindump
# Jun 22nd 2018, 08:03 neon1024 Sorry, that sounds like a lecture reading it back.
# Jun 22nd 2018, 08:03 neon1024 Trying to write tests for events in something, Crud I think, was quite tough
# Jun 22nd 2018, 08:02 neon1024 *imho
# Jun 22nd 2018, 08:02 neon1024 Class abstractions will be ten billion times easier to test than events
# Jun 22nd 2018, 08:02 birdy247 I am keen to get things working (mvp) and ensure all tests are passing, then we can refactor
# Jun 22nd 2018, 08:01 birdy247 I agree, I expect this code to go through many iterations before we are 100% happy with it
# Jun 22nd 2018, 08:00 neon1024 If the objects are as tightly coupled as you say
# Jun 22nd 2018, 08:00 neon1024 `$stationary->hasPen() { // Drawing }`
# Jun 22nd 2018, 08:00 neon1024 Then I can work with the Collection abstraction and query it to know if certain objects exist
# Jun 22nd 2018, 08:00 neon1024 Like a collection concept
# Jun 22nd 2018, 08:00 neon1024 Stationary class which composes other class instances of Pen, Ruler, etc
# Jun 22nd 2018, 07:59 neon1024 So you might also push up to a Super class
# Jun 22nd 2018, 07:59 neon1024 I’m creating a collection of objects