imagelogo

Durkheim's Blog


DBC Phase 0, Week 6


Object-Oriented vs. Functional Programming

January 31, 2015

Over the last few weeks at DBC, we've delved deeper and deeper into Ruby. For me personally, this has been a great introduction to object-oriented programming. In Ruby, everything is an object with particular states and methods--which allows us to manipulate the object directly. That is why we refer to Ruby as an object-oriented language. In contrast, we have functional programming which executes computations as mathematical functions. Rather than manipulating an object, it passes data through a function, giving an output.

While researching online, I tried to distinguish when either approach is appropriate. So far, it seems that object-oriented programming is best suited for situations where you have a fixed set of things you want to do (operations or methods), while functional-programming is best when you are working with (relatively) static objects or data. When performing object-oriented programming, adding methods to a Class to perform more operations may have downstream effects on other Classes that reference the Class you updated. On the other hand, with functional programming, if you were to create a new object that your function has to accommodate, there will be downstream effects on other functions.

While I think we will predominantly be working with object-oriented languages at DBC (Ruby), I'm also looking forward to learning functional programming in the future.

|