SDLC
MVC Tutorial for Beginners: What is, Architecture & Example
What is MVC Framework? The Model-View-Controller (MVC) framework is an architectural pattern that...
Functional programming (also called FP) is a way of thinking about software construction by creating pure functions. It avoid concepts of shared state, mutable data observed in Object Oriented Programming.
Functional langauges empazies on expressions and declarations rather than execution of statements. Therefore, unlike other procedures which depend on a local or global state, value output in FP depends only on the arguments passed to the function.
In this tutorial, you will learn-
The objective of any FP language is to mimic the mathematical functions. However, the basic process of computation is different in functional programming.
Here, are some most prominent Functional programming languages:
Immutable Data means that you should easily able to create data structures instead of modifying ones which is already exist.
Functional programs should perform operations just like as if it is for the first time. So, you will know what may or may not have happened during the program's execution, and its side effects. In FP term it is called Referential transparency.
Modular design increases productivity. Small modules can be coded quickly and have a greater chance of re-use which surely leads to faster development of programs. Apart from it, the modules can be tested separately which helps you to reduce the time spent on unit testing and debugging.
Maintainability is a simple term which means FP programming is easier to maintain as you don't need to worry about accidentally changing anything outside the given function.
First-class function
'First-class function' is a definition, attributed to programming language entities that have no restriction on their use. Therefore, first-class functions can appear anywhere in the program.
The closure is an inner function which can access variables of parent function's, even after the parent function has executed.
Higher-order functions either take other functions as arguments or return them as results.
Higher-order functions allow partial applications or currying. This technique applies a function to its arguments one at a time, as each application returning a new function which accepts the next argument.
A 'Pure function' is a function whose inputs are declared as inputs and none of them should be hidden. The outputs are also declared as outputs.
Pure functions act on their parameters. It is not efficient if not returning anything. Moreover, it offers the same output for the given parameters
Example:
Function Pure(a,b)
{
return a+b;
}
Impure functions exactly in the opposite of pure. They have hidden inputs or output; it is called impure. Impure functions cannot be used or tested in isolation as they have dependencies.
Example
int z;
function notPure(){
z = z+10;
}Function composition is combining 2 or more functions to make a new one.
Shared states is an importance concept in OOP programming. Basically, It's adding properties to objects. For example, if a HardDisk is an Object, Storage Capacity and Disk Size can be added as properties.
Side Effects
Side effects are any state changes which occur outside of a called function. The biggest goal of any FP programming language is to minimize side effects, by separating them from the rest of the software code. In FP programming It is vital to take away side effects from the rest of your programming logic.
Functional Programming | OOP |
|---|---|
FP uses Immutable data. | OOP uses Mutable data. |
Follows Declarative Programming based Model. | Follows Imperative Programming Model. |
What it focuses is on: "What you are doing. in the programme." | What it focuses is on "How you are doing your programming." |
Supports Parallel Programming. | No supports for Parallel Programming. |
Its functions have no-side effects. | Method can produce many side effects. |
Flow Control is performed using function calls & function calls with recursion. | Flow control process is conducted using loops and conditional statements. |
Execution order of statements is not very important. | Execution order of statements is important. |
Supports both "Abstraction over Data" and "Abstraction over Behavior." | Supports only "Abstraction over Data". |
Conclusion
What is MVC Framework? The Model-View-Controller (MVC) framework is an architectural pattern that...
What is Workflow Testing? WORKFLOW TESTING is a type of software testing, which checks that each...
We have compiled the most frequently asked Manual Testing Interview Questions and Answers that...
To understand Cyclomatic Complexity, lets first understand - What is Software Metric? Measurement is...
Black Box Testing Black Box Testing is a software testing method in which the functionalities of...
Project Summary This project will put you in a corporate setting. You will be testing a demo...