Giter Site home page Giter Site logo

intro-to-scala's People

Contributors

ashokkumar avatar benhutchison avatar chanjk avatar felipeeflores avatar frediy avatar george-wilson-rea avatar hanmoi-choi avatar lukestephenson avatar lukestephenson-zendesk avatar ninth-dev avatar ntdesilv avatar petern-sc avatar sanjivsahayamrea avatar shaun-whitely avatar ssanj avatar stefan-vrecic-pro avatar stilianouly avatar tcao-rea avatar tomcjohn avatar trammel avatar ttcao avatar void-kuangyi avatar wjlow avatar wsutina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

intro-to-scala's Issues

Exceptions2EitherExercises does not need an hour fifteen

I think I can complete the Exceptions2EitherExercises in 45 mins similar to the ExceptionsExercises. The content of Exceptions2EitherExercises is very similar to ExceptionsExercises so there is much less overhead in going from one to the other - only translating Exceptions -> Eithers.

This should free up 30 mins which we can use somewhere else; maybe on the
TryExercises or LogParser?

Deprioritise zip exercises.

I think zipping isn't very important in this course. If we de-prioritise it (put it in the bonus section), we can bump getNames, getAdults and reverseList, which are exercises to rewrite imperative code in a functional way. I ran this recently and found that it was valuable.

Or we could introduce collect here to prepare students for Exception and Either exercises.

Add more exercises to Day 1.

I think we need to add at least 1 hard exercise to Types and List.

Some things we could consider adding:

  • Tuples (Intro)
  • Creating your own case class (Types)

Introduce `flatMap` in `OptionExcercises2`

should we introduce flatMap on findJobIdByHumanId.

At this point people understand what an Option type is and how/when to use it. findJobIdByHumanId is a very good example of how you combine two Options. The IDE suggest that you should use flatMap instead of map.flatten.

The next exercise findJobByHumanId has the same intuition. We could introduce it here to show the difference.

Add more examples to Option1Exercises.mkTrafficLight

  /**
    * scala> mkTrafficLight("red")
    * = Some(Red)
    *
    * scala> mkTrafficLight("bob")
    * = None
    **/
  def mkTrafficLight(str: String): Option[TrafficLight] = ???

should also have:

  /**
    * scala> mkTrafficLight("red")
    * = Some(Red)
    *
    * scala> mkTrafficLight("green")
    * = Some(Green)
    *
    * scala> mkTrafficLight("yellow")
    * = Some(Yellow)
    *
    * scala> mkTrafficLight("bob")
    * = None
    **/
  def mkTrafficLight(str: String): Option[TrafficLight] = ???

ExceptionExercisesTest

For the createPerson function the assertions need to be fixed for the tests:

  • "should return Person if supplied a valid name and age"
    The test should assert Person("Fred", 32)

  • "should throw an EmptyNameException if the name supplied is empty"
    The test should assert "provided name is empty"

  • "should throw an InvalidAgeValueException if the age supplied is not an Int"
    The test should assert InvalidAgeValueException is thrown instead of InvalidAgeRangeException

Remove mkTrafficLightOrNull exercises from NullExercises

Remove mkTrafficLightOrNull exercises from NullExercises:

def mkTrafficLightOrNull(str: String): TrafficLight = ???
def mkTrafficLightOrNullThenShow(str: String): String = ???

as these are covered by the Person exercises:

def mkPersonOrNull(name: String, age: Int): Person = ???
def mkPersonOrNullThenChangeName(oldName: String, age: Int, newName: String): Person = ???

Upgrade to Scala 2.13

Will help in simplifying type signatures of collections

Depends on Delight and ScalaTest to be upgraded first

Add more examples to Option1Exercises.mkTrafficLightThenShow

This:

  /**
    * scala> mkTrafficLightThenShow("red")
    * = "Traffic light is red"
    *
    * scala> mkTrafficLightThenShow("bob")
    * = "Traffic light `bob` is invalid"
    *
    * Hint: Use `mkTrafficLight` and pattern matching.
    *
    * You can pattern match on `Option` using its two constructors `Some` and `None`:
    *
    * ```
    * optSomething match {
    *   case Some(a) => // do something with `a`
    *   case None => // do something else
    * }
    * ```
    */
  def mkTrafficLightThenShow(str: String): String = ???

should change to:

  /**
    * scala> mkTrafficLightThenShow("red")
    * = "Traffic light is red"
    *
    * scala> mkTrafficLightThenShow("yellow")
    * = "Traffic light is yellow"
    *
    * scala> mkTrafficLightThenShow("green")
    * = "Traffic light is green"
    *
    * scala> mkTrafficLightThenShow("bob")
    * = "Traffic light `bob` is invalid"
    *
    * Hint: Use `mkTrafficLight` and pattern matching.
    *
    * You can pattern match on `Option` using its two constructors `Some` and `None`:
    *
    * ```
    * optSomething match {
    *   case Some(a) => // do something with `a`
    *   case None => // do something else
    * }
    * ```
    */
  def mkTrafficLightThenShow(str: String): String = ???

Do we need Wallet in TypeExercises?

We cover most of what Wallet does in TypeExercises with Person. Do we need to double up?

 //Type -> String
  def showWallet(wallet: Wallet): String = ???

is the same as:

def showPerson1(person: Person): String 
def showPerson2(person: Person): String 
 //immutable copy
  def purchase(cost: Double, wallet: Wallet): Wallet = ???

is the same as:

 def changeName(newName: String, person: Person): Person = ???

TyperExercises.showTrafficLightStr extension

To support the extension of TyperExercises.showTrafficLightStr:

We have a new traffic light called Flashing, with a frequency, e.g. "flashing 20", "flashing 100"

Extend showTrafficLightStr that you have just implemented above to support this new functionality.

should we mention:

Hint: String.split and pattern match on Array

or were you thinking of introducing regexs here?

"""flashing\s\(d+)""".r

Flashing with Frequency in TypeExercises

Adding a Flashing with a frequency to TypeExercises makes this a little too complex as:

  • We need to explain Regex matching or
  • Explain splitting and matching on Array.

If we get rid of the frequency this exercise will be much easier and we can easily demonstrate the compile-checked exhaustiveness.

  /**
    * We have a new traffic light called Flashing, with a frequency, e.g. "flashing 20", "flashing 100"
    *
    * Extend `showTrafficLightStr` that you have just implemented above to support this new functionality.
    *
    * Use a test driven approach to implement this new functionality.
    *
    * scala> showTrafficLightStr("flashing 20")
    * = "The traffic light is flashing with a frequency of 20"
    *
    * scala> showTrafficLightStr("flashing 100")
    * = "The traffic light is flashing with a frequency of 100"
    *
    * Hint: Use flashing regex and pattern matching or 
    * use `.split(" ")` and pattern-match on `Array("flashing", frequency)`
    **/

  val flashing = """^flashing\s(\d+)$""".r

Calculating `min` is weird.

In reality I would use NonEmptyList.from(list) and then reduce on the NEL.

But here people have to fold on the tail and it feels so odd.

Maybe we can rewrite this into an exercise where we concatenate a bunch of strings together?

Or to reverse a list?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.