Mauna Kea Geminids
This is a movie of last night’s sky from Mauna Kea and is well worth downloading. If you’re wondering “Why is the sky blue but I can see the stars?” that’s because for the first half of the night, the moon was up! At around midnight, it sets, creating a second dramatic mountain-shadow. After moonset, the sky becomes dramatically darker as the meteor activity picks up.
The lights in the distance are Hilo.
I was looking at Poliahu’s white cloak covering the peak of Mauna Kea, and then I put my face in the water and looked down at the coral reef 40′ below me and what should I see swimming below me but a manta ray with a 12’+ wingspan?
- Imagine that you have a hierarchical object graph:
And you want to merge two instances. Some elements should combine elements from both, some must take their value from the master. My example scenario is artificial, so please don’t say ‘well, if all you have to do is number pages…’
This is my first take:
You can see my pattern:
- shallow copy
I have two problems with this code:
- It’s tedious
- The biz rules are spread out to individual classes, but they are more naturally expressed in a single place, e.g., “Merge these two, but use this one as the ‘master’ and use it’s values for Foo.Bar, Bar.Bat, and Baz.Fizz”
(Something I’m not bothered about is the explicit call to GetSomeMergeableElement().DeepCopyDeferringToMaster() — I could use reflection to iterate over the IMergeable fields and call
but I would have to cut-and-paste that loop into each subclass, so no real gain.)
I have a strong hunch that this could be done better in a functional language, but I can’t put it together. Can you?
Update: Here’s my FP-inspired implementation — what do you think?
Here’s the test code: