in functional-programming

Mutable States in Functional Programming

Functional Programming – Avoiding Mutable States

Function are at the center of functional programming.  Functions are similar to methods in Java. But they differ in certain properties.

 

  1. Functions avoid mutable states
  2. Functions are stateless

 

Mutable States:

Most of the methods in Object oriented programming modify the state of the objects. They might assign or update states of the objects. It is very normal and object oriented programming is based on this concept of state updates of objects.

But functional programming states that functions should avoid mutable states. That means they should not assign or update any state of an object.

Functions are independent in their executions and ensure that there are no side-effects during their execution.

The primary reason behind this is that having mutable states lead to concurrency issues and it is hard to leverage the parallel processing capability of multiple cores.

 

Srinivas Reddy

Srinivas Reddy

An IT - Specialist with loads of experience in Java, J2ee platforms and loves to share his experience on technology with You...

More Posts - Website

Follow Me:
TwitterFacebook

Related Posts

Srinivas Reddy
Written By:

An IT - Specialist with loads of experience in Java, J2ee platforms and loves to share his experience on technology with You...