Traditional Object Oriented programming developers(like me), are used to programming in the imperative style. More emphasis was on designing class hierarchies, algorithms ( sequence of commands/statements to perform a unit of operation), tracking changes in the state, control flow.
Writing code , describing the details in each statement/command, tracking the state changes, creating CFG(Control flow Graphs) to analyze all possible flows(order of execution), creating unit tests so that maximum code-coverage is accomplished etc were the major tasks of an OO programmer.
But for enhancing/maintaining a functionality OO programmer should again track the control flow, state changes of local variables and global variables due to hidden dependencies etc. Enhancing/Extending functionality is not as predictable as it seems to be.
In imperative programming, same design patterns are written over and over again.
Expressing what you wanted to achieve is very difficult in imperative programming (even in OO languages).
It takes time for a developer to go through a code snippet and understand the intent, since all those sequence of statements express how the code executes and we can figure out what is being accomplished only after careful study of the order of statements , dependencies etc.
Functional Programming:-
- A style of programming that emphasizes the evaluation of expression rather than execution of commands.
- Code is an expression that specifies properties of the object we want to get as a result rather than a sequence of statements.
- In this declarative approach we compose code differently.
- Control flow contains function calls, including recursion.
- Primary manipulation unit is function. Functions are first-class objects and data collections rather than objects.
C# and Visual Basic support both imperative and functional programming approaches. Started understanding and appreciating the functional programming constructs in C#.
Hope combining both the functional approach and imperative approach improve personal coding productivity as mentioned in many tutorials.
No comments:
Post a Comment