Concepts and Terminology (Functional Transformation)
This topic introduces the concepts and terminology of pure functional transformations. The functional transformation approach to transforming data yields code that is often quicker to program, more expressive, and easier to debug and maintain than more traditional, imperative programming.
Note that the topics in this section are not intended to fully explain functional programming. Instead, these topics identify some of the functional programming capabilities that make it easier to transform XML from one shape to another.
In pure functional transformation, a set of functions, called pure functions, define how to transform a set of structured data from its original form into another form. The word "pure" indicates that the functions are composable, which requires that they are:
Self-contained, so that they can be freely ordered and rearranged without entanglement or interdependencies with the rest of the program. Pure transformations have no knowledge of or effect upon their environment. That is, the functions used in the transformation have no side effects.
Stateless, so that executing the same function or specific set of functions on the same input will always result in the same output. Pure transformations have no memory of their prior use.
In the rest of this tutorial, the term "pure function" is used in a general sense to indicate a programming approach, and not a specific language feature.
Note that pure functions must be implemented as methods in C# and functions in Visual Basic. (In Visual Basic, subroutines cannot return a value, and therefore they are not used for writing pure functional transformations.)
Also, you should not confuse pure functions with pure virtual methods in C++. The latter indicates that the containing class is abstract and that no method body is supplied.
Functional programming is a programming approach that directly supports pure functional transformation.
Historically, general-purpose functional programming languages, such as ML, Scheme, Haskell, and F# (from Microsoft Research), have been primarily of interest to the academic community. Although it has always been possible to write pure functional transformations in C# and Visual Basic, the difficulty of doing so has not made it an attractive option to most programmers. With C# 3.0 and Visual Basic 9.0, however, new language constructs such as lambda expressions and type inference make it functional programming much easier and more productive.
For more information about functional programming, see Functional Programming vs. Imperative Programming.
Domain-Specific FP Languages
Although general functional programming languages have not been widely adopted, specific domain-specific functional programming languages have had better success. For example, Cascading Style Sheets (CSS) are used to determine the look and feel of many Web pages, and Extensible Stylesheet Language Transformations (XSLT) style sheets are used extensively in XML data manipulation. For more information about XSLT, see XSLT Transformations.