When we think of OO, most people think of modeling THE real world in software by mapping every real world object (nouns) to entities in software. These entities are then modeled using Is-A-Has-A relationship to build complex, polymorphic hierarchies with deep object graphs. State is stored and mutated in-place inside the object to achieve the desired functionality. This paradigm leads to a fairly convoluted design and encourage imperative style of programming.

Not everyone who has designed large complex systems, think of OO the same way. For instance, people who Test Drive, do not have the luxury of a big-up-front design, instead they focus on small and incremental design. IME, TDD facilities a design that is side-effect free and encourages a declarative style of programming. While decoupling and composing objects in a functional style with the right granularity of abstraction.

Let's assume we've to build a web commenting and discussion feature (like Disqus). And we've a requirement to implement this as a jQuery Plugin. Can we apply pure functional principles to design this? Or will the design be better if we try a classical OO JS approach? In this live demo, we'll build this plugin from scratch and see how TDD will help us drive an object-functional design to strike a pragmatic balance between the 2 paradigms.

 
1 favorite thumb_down thumb_up 0 comments visibility_off  Remove from Watchlist visibility  Add to Watchlist
 

Outline/structure of the Session

  • Quick intro to TDD (5 mins)
  • Live demo of the comment's plugin with the following features (90 mins)
    • Should be able to accept comments as json
    • Should display more recent comments on top
    • Private comments should be displayed only to the author of the comment
    • Should take a URL to fetch the comments json from server
    • Others should be able to like your comment
  • Recap of certain design decisions driven by our tests and how they encouraged functional programming (10 mins)
  • Discussion on Virtual DOM and how it can influence your design (10 mins)
  • Q & A (5 mins)

Learning Outcome

  • Deeper understanding of OO and FP design principles. 
  • Communication, Simplicity and Flexibility are the hallmarks of a good design. Irrespective of the programming paradigm, TDD can help you achieve these values in your design.
  • Importance of Virtual DOM.

Target Audience

OO practitioners wanting to indulge with FP and FP programmers who don't respect OO.

schedule Submitted 1 year ago

Comments Subscribe to Comments

comment Comment on this Proposal

  • 45 mins
    Demonstration
    Beginner

    If you thought Monads are a mystery, then this demonstration would show you how to evolve your code towards a Monad without knowing about it. This demo will neither go into any Category Theory nor begin with monadic laws.  Instead, we will start with typical code that you see in your daily life as a developer, attempt to DRY (Don't Repeat Yourself) it up and eventually use Monad to remove duplication and verbosity. You'll also see how Monads make your code more declarative and succinct by sequencing the steps in your domain logic.

    Also, we know in Java8 Checked Exceptions + λ == Pain!  To be more precise, we will evolve a Try (exception handling monad) which is missing in Java8, similar to one found in Scala.  Finally, map back Try to the 3 monad laws.