Functional programming makes your application faster, improves performance, and increases your productivity. C# code is written at a higher level of abstraction, so that code will be closer to business requirements, abstracting away many low-level implementation details.This video bridges the language gap for C# developers by showing you how to create and consume functional constructs in C#. We also bridge the domain gap by showing how functional constructs can be applied in business scenarios. We’ll take you through lambda expressions and extension methods, and help you develop a deep understanding of the concepts and practices of LINQ and recursion in C#.By the end of the video, you will be able to write code using the best approach and will be able to perform unit testing in functional programming, changing how you write your applications and revolutionizing your projects.
About the Authors
Wisnu Anggoro is a Microsoft Certified Professional in C# programming and an experienced C/C++ developer. He has also authored Boost.Asio C++ Network Programming - Second Edition, published by Packt. He has been programming since he was in junior high school and started developing computer applications using the BASIC programming language in the MS-DOS environment. He has a solid experience of smart card programming as well as desktop and web application programming, such as designing, developing, and supporting live use applications for SIM Card Operating System Porting, personalization, PC/SC communication, and other smart card applications that require the use of C# and C/C++. He is currently a senior smart card software engineer at CIPTA, an Indonesian company that specializes in the innovation and technology of smart cards.
In functional programming, we write functions without side effects the way we write in Mathematics. Let’s see how to define the functions that contain the expression, definition, and parameters that can be expressed by a variable in order to solve problems.
For the rest of the discussion in this section, we have to create some code in C#. We will use Visual Studio 2015 Community Edition and .NET Framework 4.6.2. But, before getting started, we must know how to define the configuration settings.
We can also distinguish functional programming from imperative programming by the concepts. The core ideas of functional programming are encapsulated in the constructs. Let’s discuss those concepts in this video.
This video will discuss about functional programming in C#. We will be discussing both the conceptual aspects of functional programming and write code in C#, as well. Let’s explore currying, pipelining, and method chaining in detail.
Now that we have learnt the concepts of functional programming, we need to learn to transform imperative code to functional code by leveraging method chaining. This video consists of an example where we have to create an HTML-ordered list containing the list of the planets in our solar system.
So far, we have had to deal with functional programming by creating code using functional approach. Now, we can look at the advantages and limitations of the functional approach.
A delegate is a data type in C# that encapsulates a method that has particular parameters and return types. Let’s dig a little deeper into delegate syntax and use to learn how it will define the parameters and the return type of a method.
In C#, not only are we able to declare a delegate, but we are also able to use the built-in delegate from the C# standard library. This built-in delegate also applies to the generic data type, so let's discuss the generic delegate prior to discussing the built-in delegate.
A generic delegate has the ability to be assigned by a method that has an unmatched signature to the delegate. We can call this variance in delegates. There are two variances in delegates; covariance and contravariance. This video will help us learn them.
In the previous section, we already discussed how to declare a delegate using named methods. When using named methods, we have to create a method first, give it a name, and then associate it with the delegate. Let’s explore how we do that.
We now have an idea that anonymous methods can help us create a simple and short method. However, in C# 3.0, lambda expressions were announced in order to complement anonymous methods in providing a shorthand notation to create anonymous methods. This video will help us know everything related to lambda expressions.
In C#, an object or a class can be used to inform other objects or classes when something happens, which is known as an event. There are two kinds of classes in the event, they are publishers and subscribers. Let’s learn how lambda expressions are used to handle events.
Lambda expressions are not only a powerful way to provide a shorthand notation for anonymous methods, but they are also used in functional programming. In this video, we will go through the advantages of using the lambda expression in the context of functional programming.
An extension method is a capability that can extend the ability of an existing class or type without making any modification to the existing class or type. Let’s explore how extension method enables us to add methods to the existing class or type without having to either create a new derived type or recompile.
We have successfully created the IsPalindrome() extension method in the previous section. It's quite easy to call the extension method since it's defined inside the same namespace as the caller method. But, we must learn how to work with the namespace.
Not only can classes and types apply an extension method, but interfaces, collections, and any other objects can be functionally extended using an extension method as well. This video shows us how to extend interface, collection and object.
Method chaining in functional programming relies on extension methods. As we have already discussed in Section 1, method chaining makes our code easier to read. At the same time, extension method still has some limitations. Let’s take a look at the advantages and limitations of extension method.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.