In this project my team and I tried our hands-on Functional Programming. Our aim was to compare challenges, efforts, and ease in developing a same application "MarkParser" (a Markdown parser) using both the paradigms.
4. What is OO Programming?
“Object-oriented programming (OOP) is a programming paradigm
based on the concept of objects which are data structures that
contain data, in the form of fields, often known as attributes; and
code, in the form of procedures, often known as methods.”
-Wikipedia
5. What is Functional Programming?
“In computer science, functional programming is a programming
paradigm, a style of building the structure and elements of computer
programs, that treats computation as the evaluation of mathematical
functions and avoids changing-state and mutable data.”
-Wikipedia
9. Design:Object Oriented using Ruby
Class Document
Main class which encapsulates markdown string. It carries out the
parsing
10. Design:Object Oriented using Ruby
Class Element
- Base class for other element classes.
- Every Html element is an instance of this class.
- BlockElement: li, ol
- InlineElement: strong, em
46. we think functional programming has higher
expressibility
Results & Discussion
47. Results & Discussion
we also think higher order functions make a lot
of sense in programming
48. Results & Discussion
we also think higher order functions make a lot
of sense in programming
also gives you a chance to put high school
mathematics into use
49. Part 1: Results & Discussion
a lot less time is spent in building and operating
on data structures
Results & Discussion
50. code for functional is very concise
in comparison to OOPS
Results & Discussion
51. however, we feel data encapsulation and abstraction
are easier to achieve in OOPS
Results & Discussion
52. refactoring code is easier, without telling the other
modules that don’t need to know
Results & Discussion
53. and at many instances, it was easier for us to think
in Object Oriented terms
OBJECT
Results & Discussion
55. some also claims that making GUI is easier in
OOPS but we have mixed opinion on that
Results & Discussion
56. So the question is which paradigm
is better?
Results & Discussion
57. So the question is which paradigm
is better?
FUNCTIONAL??
Results & Discussion
58. So the question is which paradigm
is better?
FUNCTIONAL??
(NO)
Results & Discussion
59. So the question is which paradigm
is better?
OOPS??
Results & Discussion
60. So the question is which paradigm
is better?
OOPS??
(NO)
Results & Discussion
61. Its like a fight between a bear and an alligator, the terrain
determines the outcome.
Results & Discussion
62. OOPS is generally better when there are fixed set of
OPERATIONS on things, and as code evolves new things are
added (e.g. new class)
Results & Discussion
63. Functional is generally good when there are fixed set of
THINGS, and as code evolves new operations are added to
existing things (e.g. avg func).
DATA
sum()
avg()
Results & Discussion
65. Every programming paradigm consists of certain principal
features that makes solving particular set of problems much
easier/optimal
Universal Programming paradigm is a myth
Hybrid approach may involve some trade off, and chances of
messing up may increase
Conclusions