1. Home
  2. Explore
  3. Computer Science
  4. Functional Programming Skills

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Functional Programming Skills

  • 36Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Functional Programming

How does the content most usefully characterize functional programming?

36 questions

  1. 1

    How does the content most usefully characterize functional programming?

    1. A

      As a programming language that supports only mathematical functions

    2. B

      As a fixed architecture that every software system must follow

    3. C

      As a strict rule that prohibits all mutable memory

    4. D

      As a set of skills that functional programmers use frequently

    Correct answer
    D

    As a set of skills that functional programmers use frequently

    Explanation

    The content presents functional programming as a set of skills rather than relying on a single definition of what is or is not functional programming.

  2. 2

    How can functional programming skills relate to object-oriented programming skills?

    1. A

      They must be learned separately because the paradigms cannot coexist

    2. B

      They are identical because both paradigms use exactly the same design skills

    3. C

      They are alternatives because using one automatically prevents using the other

    4. D

      They can be mixed and used together because the paradigms are not incompatible

    Correct answer
    D

    They can be mixed and used together because the paradigms are not incompatible

    Explanation

    The content explains that functional programming and object-oriented programming have different skills that can be combined, such as functional skills with encapsulation and object-oriented modeling.

  3. 3

    Which set lists the five major functional programming skills presented in the content?

    1. A

      Managing threads, compiling code, testing interfaces, normalizing tables, and deploying services

    2. B

      Writing classes, using inheritance, optimizing hardware, modeling objects, and designing databases

    3. C

      Parsing input, allocating memory, designing networks, writing documentation, and debugging syntax

    4. D

      Separating actions, using immutable values, using higher-order behavior, modeling data, and designing architecture

    Correct answer
    D

    Separating actions, using immutable values, using higher-order behavior, modeling data, and designing architecture

    Explanation

    The five skills are discriminating actions, calculations, and data; working with immutable values; using and creating higher-order calculations and actions; data modeling; and functional architecture.

  4. 4

    Why are the five skills described as a progression in difficulty or abstraction?

    1. A

      Higher-order behavior must always be learned before understanding calculations

    2. B

      Data modeling is presented as simpler than every other functional programming skill

    3. C

      Identifying actions, calculations, and data is foundational, while architecture is presented as a later skill

    4. D

      Architecture is foundational, while identifying data is presented as the most advanced skill

    Correct answer
    C

    Identifying actions, calculations, and data is foundational, while architecture is presented as a later skill

    Explanation

    The content describes identifying actions, calculations, and data as the beginning of functional programming and places data modeling and architecture farther up the chain.

  5. 5

    What is the central purpose of treating functional programming as a set of skills?

    1. A

      It allows programmers to focus on useful practices without resolving every definitional disagreement

    2. B

      It limits functional programming to skills that can be used only in one language

    3. C

      It makes definitions unnecessary because functional programming has no recognizable practices

    4. D

      It requires programmers to reject all practices associated with other programming paradigms

    Correct answer
    A

    It allows programmers to focus on useful practices without resolving every definitional disagreement

    Explanation

    The content recommends bypassing contradictory definitions and instead examining the skills functional programmers tend to use more often.

  6. 6

    What distinguishes a calculation from an action?

    1. A

      A calculation can run only once, while an action must be repeated several times

    2. B

      A calculation must be an operator, while an action must always be a named function

    3. C

      A calculation gives the same result for the same inputs, while an action can depend on when it runs

    4. D

      A calculation always changes stored data, while an action never produces an observable effect

    Correct answer
    C

    A calculation gives the same result for the same inputs, while an action can depend on when it runs

    Explanation

    Calculations compute outputs from inputs consistently, whereas actions may produce different results or effects depending on when they are run.

  7. 7

    Which example correctly classifies the operators described in the content?

    1. A

      Both operators are data because operators cannot produce computational results

    2. B

      The addition operator is a calculation, whereas the increment operator is an action

    3. C

      The addition operator is an action, whereas the increment operator is always a calculation

    4. D

      Both operators are actions because every operator depends on the time of execution

    Correct answer
    B

    The addition operator is a calculation, whereas the increment operator is an action

    Explanation

    The content uses addition as an example of a calculation and increment as an example of an action, noting that these categories are not limited to functions.

  8. 8

    Why are calculations and data generally easier to test and reuse than actions?

    1. A

      Their behavior does not depend on when they are run

    2. B

      They always contain fewer lines of code than actions

    3. C

      They automatically prevent every possible programming error

    4. D

      They can be used only inside the function that created them

    Correct answer
    A

    Their behavior does not depend on when they are run

    Explanation

    Calculations and data are easier to work with because their behavior is not affected by execution timing, making them easier to test and reuse.

  9. 9

    What is a recommended way to reduce the difficulty of working with actions?

    1. A

      Avoid testing actions because their timing cannot be controlled

    2. B

      Move as much logic as possible from actions into calculations

    3. C

      Move all calculations into actions so timing is centralized

    4. D

      Duplicate each action so that it can run in several places

    Correct answer
    B

    Move as much logic as possible from actions into calculations

    Explanation

    The content recommends keeping fewer lines of code in actions by moving logic into calculations, while giving extra attention to the remaining actions.

  10. 10

    Why must functional programmers pay special attention to how actions are called?

    1. A

      Actions cannot be called more than once without causing a syntax error

    2. B

      The timing, frequency, and manner of calling an action can affect its behavior

    3. C

      Actions are always slower than calculations regardless of how they are called

    4. D

      The number of arguments determines whether an action becomes immutable data

    Correct answer
    B

    The timing, frequency, and manner of calling an action can affect its behavior

    Explanation

    The content emphasizes that it matters how actions are called, when they are called, and how many times they are called.

  11. 11

    Why does software need a deliberate discipline for immutable data?

    1. A

      Computer memory is mutable, so permanence must be enforced by a team, language, or database

    2. B

      Immutable data is required only when software stores paper documents electronically

    3. C

      Mutable memory automatically preserves historical records without additional design

    4. D

      Computer memory is naturally permanent, so software must deliberately introduce changes

    Correct answer
    A

    Computer memory is mutable, so permanence must be enforced by a team, language, or database

    Explanation

    The content contrasts real-world practices for preserving records with mutable computer memory and says immutability must be rebuilt through programming, language, or database mechanisms.

  12. 12

    What is the basic operational strategy for working with immutable values?

    1. A

      Prevent all transformations so that values remain unchanged forever

    2. B

      Create copies rather than overwriting existing values

    3. C

      Store every value in a global variable and mutate it centrally

    4. D

      Overwrite values freely but record only the final result

    Correct answer
    B

    Create copies rather than overwriting existing values

    Explanation

    The content summarizes working with immutable data as making copies instead of changing existing values in place.

  13. 13

    Why is nested immutable data especially challenging to update?

    1. A

      Deeply nested values can be changed directly without copying because immutability applies only to top-level data

    2. B

      A nested update always requires changing every value in memory, including unrelated structures

    3. C

      Changing a deeply nested value may require deciding which parts of the surrounding structure to copy

    4. D

      Nested data cannot contain immutable values because only flat structures can be permanent

    Correct answer
    C

    Changing a deeply nested value may require deciding which parts of the surrounding structure to copy

    Explanation

    The content identifies nested data as challenging because updating a value deep in a structure requires determining how to copy the relevant parts of the whole data tree.

  14. 14

    In the company example, what must be considered when giving employees a raise in an immutable structure?

    1. A

      How to construct an updated copy of the company, employee, and salary structure

    2. B

      How to remove the company record before assigning new mutable salaries

    3. C

      How to overwrite every employee's salary directly in the original structure

    4. D

      How to convert all salaries into actions so they can change in place

    Correct answer
    A

    How to construct an updated copy of the company, employee, and salary structure

    Explanation

    Because the company, employees, and salaries are immutable, the programmer must determine how to create the necessary updated copies, whether for one employee or everyone.

  15. 15

    What does it mean for an action or calculation to be higher-order?

    1. A

      It must be written inside a class with several inheritance levels

    2. B

      It can be treated like a value, such as being passed, returned, or stored

    3. C

      It must execute at a higher speed than every ordinary function

    4. D

      It can operate only on numerical data rather than on behavior

    Correct answer
    B

    It can be treated like a value, such as being passed, returned, or stored

    Explanation

    Higher-order actions and calculations can be passed as arguments, returned from functions, and stored in variables like other values.

  16. 16

    What capability does higher-order programming provide when behavior is passed to another function?

    1. A

      It allows a function to manipulate or extend behavior in a regular, reusable way

    2. B

      It eliminates the need to define inputs and outputs for calculations

    3. C

      It converts every action into immutable data without requiring any additional logic

    4. D

      It prevents the receiving function from being reused with different behavior

    Correct answer
    A

    It allows a function to manipulate or extend behavior in a regular, reusable way

    Explanation

    Treating behavior as a value lets functions receive, manipulate, and extend that behavior systematically.

  17. 17

    How can a higher-order operation make an action retry automatically?

    1. A

      It can change the action into a data record that cannot be executed

    2. B

      It can take the action and return or use behavior that retries it a specified number of times

    3. C

      It can guarantee that the action will never fail during its first execution

    4. D

      It can remove all error handling because higher-order actions cannot produce failures

    Correct answer
    B

    It can take the action and return or use behavior that retries it a specified number of times

    Explanation

    The content gives the example of taking an action and automatically making it retry three times if it fails.

  18. 18

    What is the advantage of defining retry behavior at a higher-order level?

    1. A

      The program can retry only one action because higher-order behavior is not compositional

    2. B

      The retry behavior can be defined once and reused instead of rewritten as bespoke code

    3. C

      Retry behavior becomes dependent on the exact data values processed by the action

    4. D

      Each action must receive a separate custom implementation, preventing shared behavior

    Correct answer
    B

    The retry behavior can be defined once and reused instead of rewritten as bespoke code

    Explanation

    Higher-order behavior turns common boilerplate, such as retry logic, into reusable behavior that can work consistently in multiple places.

  19. 19

    Why are map, filter, and reduce considered examples of higher-order functions?

    1. A

      They are operators that can be used only for arithmetic calculations

    2. B

      They modify every input directly and therefore eliminate the need for functions

    3. C

      They store data permanently without applying any computational behavior

    4. D

      They take functions as inputs and support the construction of data-transformation pipelines

    Correct answer
    D

    They take functions as inputs and support the construction of data-transformation pipelines

    Explanation

    The content identifies map, filter, and reduce as higher-order functions because they take functions and help build sequences of data transformations.

  20. 20

    What kind of function is produced by the derivative example?

    1. A

      A function that calculates only the derivative of one predetermined mathematical function

    2. B

      A function that converts every mathematical function into a data structure

    3. C

      A function that accepts a number and returns the original function unchanged

    4. D

      A function that accepts a function and returns a new function representing its derivative

    Correct answer
    D

    A function that accepts a function and returns a new function representing its derivative

    Explanation

    The example describes a function that takes an unknown function FFF as an argument and returns a new function that calculates the derivative of FFF.

  21. 21

    What is the main purpose of data modeling?

    1. A

      To organize source code according to the order in which functions are executed

    2. B

      To replace all calculations with stored data that never changes

    3. C

      To ensure that every real-world process is represented by a single global variable

    4. D

      To structure facts and measurements so software can use them effectively

    Correct answer
    D

    To structure facts and measurements so software can use them effectively

    Explanation

    Data modeling concerns how to combine facts about the world into concrete structures that software can use effectively.

  22. 22

    What is a key design constraint for public-facing data that forms part of an API?

    1. A

      It should expose internal search structures even when they are difficult to interpret

    2. B

      It should be designed only for the server's internal calculations

    3. C

      It should prioritize compactness over clarity because users never inspect API data

    4. D

      It should be human-readable and understandable to developers using the API

    Correct answer
    D

    It should be human-readable and understandable to developers using the API

    Explanation

    Public-facing data must be understandable to the developers or programs on the other side of the library or server, so human readability is important.

  23. 23

    What is a primary concern when modeling data internally for a search process?

    1. A

      Making every internal representation human-readable for external API users

    2. B

      Using the same representation required by a public API regardless of search needs

    3. C

      Hiding all information from the search so that only the final result is stored

    4. D

      Representing the data so the search is efficient and all required information is available

    Correct answer
    D

    Representing the data so the search is efficient and all required information is available

    Explanation

    Internal data modeling is shaped by operational needs, such as efficient searching and having all necessary data available.

  24. 24

    Why may public-facing and internal data models need different designs?

    1. A

      Public data must always be mutable, while internal data must always be represented as functions

    2. B

      Internal data is intended for humans, while public data is intended only for machine memory

    3. C

      Public data emphasizes understandability, while internal data may emphasize efficient computation

    4. D

      Public data has no design constraints, while internal data must follow one universal structure

    Correct answer
    C

    Public data emphasizes understandability, while internal data may emphasize efficient computation

    Explanation

    The content distinguishes the constraints of external API data from those of internal representations used for tasks such as efficient search.

  25. 25

    Why are data-modeling skills described as relatively advanced in the progression?

    1. A

      They are simpler than identifying actions, calculations, and data because they require no abstraction

    2. B

      They concern only database storage and therefore are unrelated to functional programming

    3. C

      They must be learned before a programmer can distinguish calculations from actions

    4. D

      They address how to structure domain information effectively after more basic functional distinctions are understood

    Correct answer
    D

    They address how to structure domain information effectively after more basic functional distinctions are understood

    Explanation

    The content places data modeling near the end of the progression, after the foundational skill of distinguishing actions, calculations, and data.

  26. 26

    Why does a growing software system require architectural principles?

    1. A

      Architectural principles are needed primarily to make all code fit into one file

    2. B

      Without design principles, increasing code size can make the system unmanageable

    3. C

      A system becomes manageable by adding code without considering its organization

    4. D

      Architecture matters only for tiny programs because large systems organize themselves automatically

    Correct answer
    B

    Without design principles, increasing code size can make the system unmanageable

    Explanation

    The content explains that architecture becomes important as software scales because simply adding code can cause the system to become unmanageable.

  27. 27

    What is the central flow in a reactive data architecture?

    1. A

      A fixed interface generates no events because reactive systems avoid feedback cycles

    2. B

      Events are consumed, state is modified, and a resulting view is projected to an interface

    3. C

      Calculations are run once, after which events and state changes are ignored

    4. D

      A user interface directly modifies every database record without passing through state

    Correct answer
    B

    Events are consumed, state is modified, and a resulting view is projected to an interface

    Explanation

    Reactive architectures involve generated events, consumption of those events, modification of centralized state, and projection of the resulting world view onto a GUI or other interface.

  28. 28

    What makes reactive architecture a reaction-based architectural pattern?

    1. A

      The system requires every event to be processed by a separate unrelated application

    2. B

      The system's behavior is organized around changes to data and the reactions those changes produce

    3. C

      The system responds only to user-interface rendering and not to underlying events

    4. D

      The system avoids state and instead relies exclusively on independently timed actions

    Correct answer
    B

    The system's behavior is organized around changes to data and the reactions those changes produce

    Explanation

    The content describes the reactive cycle as being based on reactions to events and changes in data.

  29. 29

    What are the three principal layers of the Onion Architecture?

    1. A

      The interaction layer, the business rule layer, and the domain layer

    2. B

      The user layer, the testing layer, and the optimization layer

    3. C

      The input layer, the inheritance layer, and the deployment layer

    4. D

      The database layer, the networking layer, and the presentation layer

    Correct answer
    A

    The interaction layer, the business rule layer, and the domain layer

    Explanation

    The Onion Architecture is described as having an outer interaction layer, a middle business rule layer, and an inner domain layer.

  30. 30

    What belongs primarily in the interaction layer of the Onion Architecture?

    1. A

      Actions that communicate with the outside world and receive external messages

    2. B

      Timeless domain concepts that change very rarely

    3. C

      Pure business calculations that contain no actions

    4. D

      Internal search structures optimized for data retrieval

    Correct answer
    A

    Actions that communicate with the outside world and receive external messages

    Explanation

    The outer interaction layer contains actions and handles communication with the outside world.

  31. 31

    What characterizes the business rule layer in the Onion Architecture?

    1. A

      It contains only external communication actions and API adapters

    2. B

      It contains graphical projections generated directly from centralized state

    3. C

      It contains calculations representing changing business requirements

    4. D

      It contains timeless facts that are independent of business policies

    Correct answer
    C

    It contains calculations representing changing business requirements

    Explanation

    The business rule layer is a calculation-only layer containing changing requirements such as payroll calculations and vacation policies.

  32. 32

    What characterizes the domain layer in the Onion Architecture?

    1. A

      It contains a relatively timeless domain model that business rules call into

    2. B

      It contains rapidly changing code for communicating with external APIs

    3. C

      It contains only temporary data structures used during a search

    4. D

      It contains all actions required to receive messages from users

    Correct answer
    A

    It contains a relatively timeless domain model that business rules call into

    Explanation

    The inner domain layer contains the timeless domain model, such as the idea that employees receive salaries or vacation.

  33. 33

    Which statement best distinguishes a business rule from a domain concept in the employee example?

    1. A

      Neither the fact nor the amount belongs in the model because employee policies are external events

    2. B

      The fact that employees receive vacation is a business rule, while the amount is always timeless

    3. C

      Both the fact and the amount are interaction-layer actions because they involve employees

    4. D

      The amount of vacation is a business rule, while the fact that employees receive vacation is a domain concept

    Correct answer
    D

    The amount of vacation is a business rule, while the fact that employees receive vacation is a domain concept

    Explanation

    The content treats the specific vacation policy as a changeable business rule, while employees receiving vacation is a more timeless domain idea.

  34. 34

    How does the Onion Architecture organize change?

    1. A

      Frequently changing interactions are placed outside, while less frequently changing domain concepts are placed inside

    2. B

      All layers are designed to change at the same rate so no separation is needed

    3. C

      Frequently changing domain concepts are placed inside, while stable interactions are placed outside

    4. D

      The architecture places actions and timeless concepts together to simplify dependencies

    Correct answer
    A

    Frequently changing interactions are placed outside, while less frequently changing domain concepts are placed inside

    Explanation

    The outer interaction layer changes rapidly because APIs and external connections change, business rules change less rapidly, and the domain model changes least frequently.

  35. 35

    Why might a change in an external API primarily affect the interaction layer?

    1. A

      The business rule layer must store all network protocols as immutable values

    2. B

      The domain layer defines every external API message and therefore changes first

    3. C

      The API change affects only calculations because interactions never depend on external systems

    4. D

      The interaction layer contains the code that communicates with external systems

    Correct answer
    D

    The interaction layer contains the code that communicates with external systems

    Explanation

    The interaction layer connects the system to external APIs, so changes in those APIs generally require modifications there.

  36. 36

    How can an unusual situation such as employees receiving no vacation fit into the domain model?

    1. A

      It must be moved to the interaction layer because unusual values are external actions

    2. B

      It must be excluded because domain models can represent only common situations

    3. C

      It requires replacing the domain model because timeless models cannot contain numeric values

    4. D

      It can still be represented as a valid value, such as zero, within the model

    Correct answer
    D

    It can still be represented as a valid value, such as zero, within the model

    Explanation

    The content notes that even an unusual case such as zero vacation can still be modeled as a valid value within the domain model.

Question 1 of 36
Question 1 of 36

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent