Contents
1. Introduction2. Keywords
3. Problem
4. Solution
5. Solution's Discussion
6. Practice: Another Functional Programming Example
7. Conclusions
8. Literature & Links
1. Introduction
Programmers need to deal with data from multiple sources every time.
LINQ is a Microsoft .NET Framework component designed to facilitate the
interaction and manipulation of data. This data can be located in any of
the possible forms; for example: working memory, database, and XML. So,
this makes a amazing opportunity for writing recipes about this
powerful data manipulation language. In this first recipe a general
overview of the LINQ programming model will be presented; this will
allow the programmer to understand the fundamentals, and he or she will
be able to comprehend the mathematical base for writing LINQ
expressions.
2. Keywords
- .NET
- Composite function
- Data
- Function
- LINQ
- Programming
- Co
3. Problem
What is the foundation for LINQ component?
4. Solution
The Microsoft .NET Framework LINQ component is based on functional programming, an old programming technique used to manipulate data in an function's argument composited or combined way.
5. Solution Discussion
5.1 What is functional programming
When a programmer deal with data, he or she uses the built-in functions to transform data. This transformation data process regularly demands the usage of intermediate functions (Mukherjee, 2014). Now, how the programmer model this data tranformation with intermediate functions? It is easy. What the programmer needs to do is simple: write compound functions and glue them together. This practice is called, according to Mukherjee (2004), functional programming.
Functional programming technique comes from ancient programming times ("Functional programming", 2016). It is based on the mathematical concept of composite function. This can be illustrated as follows:
f(x) = x + 1
g(x) = x + 2
h(x, y) = x == y
These functions can be composited: function arguments are functions themselves (Mkherjee, 2014). The Illustration 1 shows graphically this basic concept:
Illustration 1. Composite function ("Algebra/Functions", 2016). |
Or more formally:
f(g(x))
which is equal to
f(g(x)) = x + 2 + 1 = x + 3
Analogically:
g(f(x)) = x + 1 + 2 = x + 3
6. Practice: Another Functional Programming Example
What is the evaluation result of h(f.g, g.f) == true for all values of x?
Solution:
z(f.g) = z(x + 3)
and
z(g.f) = z(x + 3)
Then if any value is assigned for x, the evaluates equates to true.
7. Conclusions
In this opportunity the programmer has had the opportunity to understand the LINQ's programming model: data transformation by a subsequent function calls, which is called functional programming. This model gives an intuition about LINQ internal data manipulation mechanisms as we are going to see in practice in the coming recipes. The next LINQ recipe will be focused on how to use Func<> in C# for presenting functions.
8. Literature and Links
Mukherjee, S (2014). Thinking in LINQ Harnessing the Power of Functional Programming in .NET Applications. United States: Apress.Algebra Functions (2016, January 17). Retrieved from: https://en.wikibooks.org/wiki/Algebra/Functions.
Functional programming - Wikipedia, the free encyclopedia (2016, January 17). Retrieved from: https://en.wikipedia.org/wiki/Functional_programming.
V
No hay comentarios:
Publicar un comentario
Envíe sus comentarios, dudas, sugerencias, críticas. Gracias.