User loginNavigation |
Functional Object-Oriented ProgrammingI've been experimenting, in Ruby, with something that we may loosely call 'functional' object-oriented programming. I write objects with non-mutating methods -- basically, these objects are stored 'requests' of a certain type. Various values can be derived from the request on demand. If I ever decide to implement caching, well, that wouldn't be functional but it's hidden from the user. Whenever I need actual state in my application, I make sure to split it out from the classes. Instead, I pass stateful information from method call to method call until the result is complete -- saving myself the hassle of state-tracking and so forth. I'm sure there is some efficiency penalty for this approach, though it makes my life much easier (and more reproducible!). There is a similarity between what I am doing and 'continuation passing style' though I can't quite place my finger on it. What do you all think of this style of "functional object-oriented programming"? There are quite a few approaches fucntional object-oriented programming out there already, like FOOPS and Object-Gofer; but these proposals are about faking object-oriented semantics -- a stateful object -- with monads. By Jason Dusek at 2007-05-03 17:56 | LtU Forum | previous forum topic | next forum topic | other blogs | 13843 reads
|
Browse archives
Active forum topics |
Recent comments
16 weeks 1 day ago
16 weeks 1 day ago
16 weeks 1 day ago
38 weeks 3 days ago
42 weeks 5 days ago
44 weeks 2 days ago
44 weeks 2 days ago
47 weeks 2 hours ago
51 weeks 4 days ago
51 weeks 4 days ago