1.3.5 how to form code in the function Style

Source: Internet
Author: User

1.3.5 how to form code in the function Style

 

The functional programming paradigm will undoubtedly have an impact on the design and implementation of applications. However, this does not mean that everything starts from the beginning, because many programming principles are being used today, it is also applicable to functional applications, especially in the design layer and how applications are organized.

Functional programming may completely change the solution to the problem at the implementation layer. Of course, you don't have to change it immediately to learn how to use functional programming. In C #, I learned how to use it effectively. In F #, the equivalent structure is also applicable. Of course, you still need to work hard. With rich functional development experience, you will learn more efficient and concise ways to express your thoughts.

The following list summarizes the impact of functional programming on the programming style, from the design layer to the Implementation Layer:

■ For functional programs on. NET, object-oriented design is still the main method for building applications and components. Although a large number of types and classes are designed to be immutable, you can still create standard classes, especially when collaborating with other. Net libraries.

■ Functional programming can simplify many standard object-oriented design patterns, because some patterns correspond directly to the language functions in F # Or C #3.0; some other modes are not required at all when using the function method. There are many examples in this book, especially in chapter 7 and chapter 8.

■ The biggest impact of functional programming is at the bottom layer, that is, writing the behavior of algorithms and applications into code. Function language integrates declarative style, concise syntax, and type inference to help us express algorithms in a readable and concise manner.

In this book, we will discuss all these aspects, starting with the functional value that constitutes the function and method, and then to the design and architecture. You will find a new pattern exclusive to functional programming. Some of the object-oriented patterns we are already familiar with are also suitable for functional programming, and some are no longer needed.

 

What is next?

 

So far, we have only talked about functional programming in the general sense. We have seen how functional programming extends the vocabulary during programming and makes code more declarative. It also discusses immutable data structures and the impact on programs. In the next section, we will discuss two basic concepts and four practical questions:

Declarative Programming and immutable data structures usually affect code clarity and readability. There are two examples in sections 1.4.1 and 1.4.2. Then, a popular question is discussed, parallelization shows how Declarative Programming facilitates code parallelism and how immutable data structures make processes safer.

 

So far, we have only focused on what makes functional programming different and why it is worth learning, but we have not seen the actual code. In the next section, we will see the source code of the four examples in the supplemental materials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.