Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore - Intro code examples #8

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

hhandoko
Copy link
Member

@hhandoko hhandoko commented Sep 8, 2017

As mentioned in the group discussion, I've split the exercise code from the example / reference code and updated the README.md accordingly.

The exercise code now resides under exercises/ and the example / reference under references/. I've made links to the code snippets to the relevant source files to make it easier to navigate. There are also minor fixes to the example code, where a parameter argument is not being used (but I assume is needed).

In regards to README.md, mainly:

  • split long paragraph into point form (where possible) to make it more readable,
  • split the first part of 'Decomplecting Function' to ease-in the introduction 😁

Copy link
Contributor

@shishkin shishkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvements @hhandoko. I have a couple of MD syntax related issues and the .gitignore that I would like to be improved as well.

@@ -1,2 +1,266 @@
*.class
*.log
# Created by https://www.gitignore.io/api/osx,vim,code,linux,emacs,windows,eclipse,intellij+all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know nobody really looks into .gitignore but I generally dislike generated bloat like this. As a developer I want to understand what files are being created in the project directory and why. If those are my custom tools, I would ignore them at ~/.gitignore level.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'll add some comments with a bit of explanation.

My goal here was to ignore all system / OS-specific files (like OSX's .DStore) and editor / IDE config files which gets generated automatically and often accidentally committed.

I'm covering three main OS (Win, OSX, *nix) and common editors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the .gitignore starts mentioning files that you didn't even know existed, there is a risk of accidentally not committing a file. And the pursuit of ignoring all system files is pointless because you never know what strange tools and temp files people are going to have. That's why Git has a user-specific ~/.gitignore file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense... I'll revert.

<center>
<small>
_(source: [Loop1.java](https://github.com/SingaporeScalaProgrammers/scala-workshop/blob/master/references/intro/src/main/java/Loop1.java))_
</small>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this syntax doing? In the preview https://github.com/SingaporeScalaProgrammers/scala-workshop/blob/a5773757e08d4a1de72ce544d59927766104ca9e/exercises/intro/README.md it's not looking nice. Not sure how is it intended be rendered.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete fail 😁 I'll figure out alternative format (and keep it readable in raw MD).

program while learning core FP concepts such as:

* referential transparency,
* expression-based programming,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Breaking down long sentences in bullet points is good 👍

variable is inferred from the right-hand side of the assignment, `Int` in
this case;
3. `1 to 10` defines a inclusive `Range` – a sequence that can be enumerated;
4. `for (x <- seq) { ...x... }` enumerates elements of `seq` executing the
1. `1 to 10` defines a inclusive `Range` – a sequence that can be enumerated;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that MD renderer will turn this into a numbered list, but I prefer the text itself to be readable too (that was the selling point of MD, IIRC). A numbered list with ones somewhat defeats that purpose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will revert.

@@ -0,0 +1,12 @@
public class Loop1 {
public static void main(String[] args) {
int sum = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to put all the steps there. For a small tutorial like this it's good to have all the steps constantly present and it's not too many of them.

@@ -513,7 +513,7 @@ def isEven(x: Int): Boolean = x % 2 == 0
def square(x: Int): Int = x * x

def sumOfEvenSquares(max: Int): Int = {
(1 to 10)
(1 to max)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch 👍

def iterate(max: Int): List[Int] = ???
def filterEven(xs: List[Int]): List[Int] = ???
def square(xs: List[Int]): List[Int] = ???
def sum(xs: List[Int]): Int = ???
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good trick 👍 I didn't think about using ??? to show the intermediary step here.


Collection API
--------------

By a lucky coincidence Scala standard library collection API already provides
most of the functions that we've just discovered. It would be a shame not to
use them:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This supposed to be a joke 🤣

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wooosh 😅 I'll add air quotes, haha.

@hhandoko
Copy link
Member Author

@shishkin I've made the changes as we discussed. I've also uploaded the diff preview files.

Note that the diff links on the MD file points to the master branch (which will 404 until this PR is merged). Have a look here for a preview: https://rawgit.com/SingaporeScalaProgrammers/scala-workshop/chore/intro_code_examples/references/intro/diff/Loop3-Loop4.html

@@ -0,0 +1,260 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see what did you mean with the diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants