Functional programming and Assignment 2

I've solved the assignment 2 in Scala, now I would like to prepare the same in Clojure but I'm a little disappoined. Reading inside the assignment 2 classes I can't find any without a mutable state.... where is the functional programming? I'll write the assignment 2 in a functional style way. But it will took me some time. Meanwhile I'm disappointed, the first Scala course was all based on functional programming and now after only one week it is disappeared. Can we use functional programming style, or on the first simple project we do we will use only imperative style and forgot about the functional part?

Comments

  1. Hi Marco, I share your disappointment. My guess is that the secret goal was to show how ugly mutable code (interrelated, public mutable fields!) is so that people would appreciate FP more :-)

    Good luck with doing it in Clojure! I guess Rich Hiceky's simulation of ants[1] could be an inspiration there?

    I have expressed my own frustration with the code in a blog post that tries to replace the mutable health-stage fields with something more reasonable - "Surfacing Hidden Design: Seeking A Better Alternative To Interrelated Mutable Fields" [2]. You might (or not :)) be interested in looking at it.

    [1] https://github.com/juliangamble/clojure-ants-simulation
    [2] http://wondersofcode.wordpress.com/2013/11/18/surfacing-hidden-design-seeking-a-better-alternative-to-interrelated-mutable-fields/

    ReplyDelete
    Replies
    1. Txs, this evening I'll read it. I think Martin was really great in showing the ugliness of mutable code... I'm watching the EpidemicDisplay now...

      Delete
  2. Could not agree more.
    The assignment description was lacking, and I spent most of my time digging into the Q&A trying to understand if a dead person is also sick or not.
    Huge waste of time.
    One good thing, it remind me how bad it is to have public variables.

    ReplyDelete

Post a Comment