5 ms·
Very interesting! In the context of C++ some of us have been calling these programming/design principles "Value Oriented Design". Some talks on the topic: - M
by arximboldi 6y ago
Very interesting!
In the context of C++ some of us have been calling these programming/design principles "Value Oriented Design". Some talks on the topic:
- Most Valuable Values (Juan Pedro Bolívar) https://www.youtube.com/watch?v=_oBx_NbLghY https://www.youtube.com/watch?v=_oBx_NbLghY
- Squaring the circle, value oriented design in an object oriented system (Juanpe) https://www.youtube.com/watch?v=e2-FRFEx8CA https://www.youtube.com/watch?v=e2-FRFEx8CA
- Objects vs Values: Value Oriented Programming in an Object Oriented World (Tony van Eerd) https://www.youtube.com/watch?v=2JGH_SWURrI https://www.youtube.com/watch?v=2JGH_SWURrI
- phaedrus 6y agoSomething I've found applying Value Oriented Design to C++ is that it often leads to freeing designs of arbitrary limitations that weren't clear beforehand but in hindsight you realize, "well, of course I should also be able to use it this (other) way." For example I'm porting a parser engine, implemented in another language, to C++ and it wasn't clear what the hierarchy of objects should be for the purpose of RAII (because there are circular dependencies) (the original implementation language was garbage collected). The original implementation loaded a grammar file and directly created objects with pointers (originally, references) to other objects. I introduced an intermediate layer where the file is first read into data structs which hold the integer values from the file. So instead of objects pointing to objects, the links are implicit because of things having the same index. The representation of the loaded grammar file is now copyable, moveable, immutable, etc. A side effect is it's trivial to tell whether the file loading code is correct or not when the result is just the same data with structure applied to it, rather than having the added dimension of determining whether a graph of objects are correctly relating to each other. Then I construct the actual parser engine objects from the data representation structs. True that didn't in itself solve the RAII-hierarchy problem, but what it did do is make it easier to isolate that problem to just the domain of how the objects are used and not commingling that with the problem of how the file is loaded. The epiphany I spoke of is that after this refactor, it became clear: the file is arbitrary. For testing, or for use of the parser with a grammar which does not change, I could dispense with the file load step and just encode the grammar directly in value-structs. Why I think this is significant is that "the way I was trained" to think of making code like this unit-testable is to mock the file reading interface. That's a lot of work for something that's only necessary because of an over-emphasis on objects and behaviors instead of thinking about data and values.
- gpderetta 6y agoSean Parent has also written a lot on the topic.
- arximboldi 6y agoYes! Also the book Elements of Programming by Stepanov has a lot of "value orientation" in it.
- gpderetta 6y agoUnsurprising as I believe Sean is a "disciple" of Stepanov (I think they worked together at Adobe).
- accountLost 6y agoSee also https://matt.diephouse.com/2018/08/value-oriented-programming/ https://matt.diephouse.com/2018/08/value-oriented-programmin... for a very quick introduction.
- gpderetta 6y agoUnsurprisingly David Abrahams, before moving to Apple, was an extremely influential member of the C++ Boost community, where value based programming is praticed extensively.