Combining functional and object-oriented programming methodologies in a large commercial application
Functional programming concepts of referential transparency and lazy evaluation combine effectively with object oriented encapsulation. We present a design pattern for C++ classes that are logically immutable and fully determined by the parameters of their constructor. Hidden state is used internall...
Saved in:
| Published in: | Proceedings - International Conference on Computer Languages pp. 111 - 117 |
|---|---|
| Main Authors: | , , , |
| Format: | Conference Proceeding Journal Article |
| Language: | English |
| Published: |
IEEE
1998
|
| Subjects: | |
| ISBN: | 9780818684548, 0818684542 |
| ISSN: | 1074-8970 |
| Online Access: | Get full text |
| Tags: |
Add Tag
No Tags, Be the first to tag this record!
|
| Summary: | Functional programming concepts of referential transparency and lazy evaluation combine effectively with object oriented encapsulation. We present a design pattern for C++ classes that are logically immutable and fully determined by the parameters of their constructor. Hidden state is used internally to cache the results of computation performed in the scope of accessors, giving them lazy semantics. Modifying replicators model change by constructing a new instance without changing the original. Previously computed results are lazily copied via a back reference if the parameters upon which the computation depends have not changed. Since these classes are logically immutable they can be freely shared by reference in complex networks, mitigating the amount of actual copying performed. These techniques realize several advantages-well known to the functional programming community-including suitability for modular reasoning and parallel evaluation. 'Undo' facilities and safe recovery from exceptions can be provided with little extra effort. Examples from a large multi platform biomedical imaging application illustrate the techniques. |
|---|---|
| Bibliography: | SourceType-Scholarly Journals-2 ObjectType-Feature-2 ObjectType-Conference Paper-1 content type line 23 SourceType-Conference Papers & Proceedings-1 ObjectType-Article-3 |
| ISBN: | 9780818684548 0818684542 |
| ISSN: | 1074-8970 |
| DOI: | 10.1109/ICCL.1998.674162 |

