Software

Working With Objects in F#: Learn How to Use Common Object-Oriented Techniques in F# so That Various Shapes Know How to Calculate Their Own Perimeter

Download Now Free registration required

Executive Summary

There are times though when one wants to extend the kind of shapes they are working with. What about triangles, hexagons or arbitrary polygons, for instance? While it is possible to enumerate these as special forms on a Shape type like one did in the first implementation, having to incorporate the perimeter logic into a single place is not ideal. Instead, one wants to switch to a more traditional OO approach where the various shapes "Know" how to calculate their own perimeter. This paper shows how to use primary object-oriented techniques from languages such as C# and VB: implementation by inheritance and by interfaces. It also covers F#-specific object-oriented features such as object expressions, constructed classes, and named and optional arguments.

  • Format: HTML
  • Size: 0 KB