Thursday, October 8, 2009

BA CH13: Object Oriented Vs Functional Programming

This chapter authors compare and contrast of functional programming versus object-oriented programming. OO is discovered later to functional language sets and developed nicely. So, I am not sure how we can successfully compare these 2. I only did functional programming in few of school projects (when it’s really necessary :) and not more than that but I am OO fan and I will continue to be in the coming years too.

As author mentioned in the chapter, In Object oriented programming everything is an object and will have a state and behavior. This style provides modularity and information hiding, reusability, dynamic binding, inheritance among many others.

In functional programming, a set of functions each of which performing a task. Executing these set of function results in the solution to the problem. Like in OO, functional programming is also achieving modularity, by the use of stateless functions, high level functions, and other recursively defined types, as well as lazy evaluation, so this is only shows fine-grain modularization. I think this makes it harder to use it to build larger applications

Q1: What types of problems lend themselves to a Functional Solution?

Mathematical problems that do not require remembrance of state but simply produce results after the calculations.

Q2: What types of problems lend themselves to an Object-Oriented Solution?

Real life problems, Objects that will have state and can represent items occurring in real life and can communicate with other objects and accomplish solutions.

Q3: Is the Functional universe more flexible from a software Architecture point of view? If so, how; and of not, why?

I think, we can always just take any function and pass it to other function to wrap additional functionality around it. But I think it is difficult to manage the code like this though..

Q4: Is Object-Oriented environment more manageable as a system grows towards the enterprise level? If so, how; and of not, why?

Yes, OO system is manageable as systems grow larger. As one of the main concepts of OO it is reusable and maintainable. Additional functionality can easily be added to the existing system by simply adding new classes, inheriting, changing implementations of parent methods or over writing inherited methods, etc...

No comments:

Post a Comment