Giter Site home page Giter Site logo

lunduniversity / introprog Goto Github PK

View Code? Open in Web Editor NEW
141.0 141.0 167.0 62.71 MB

Teaching material for "Introduction to Programming using Scala" at Lund University, LTH. http://cs.lth.se/pgk/

HTML 16.53% Scala 10.18% TeX 70.28% Java 2.84% Shell 0.08% Batchfile 0.08%
lund-university programming-courses scala teaching-materials

introprog's People

Contributors

alfredgrip avatar altaired avatar andersbuhl avatar annasjovall avatar bjornregnell avatar emilwihlander avatar erikbjare avatar exoji2e avatar fritjof-b avatar hnrklssn avatar husenap avatar jonasde avatar jos-rosenqvist-3812 avatar kuleshmaria avatar leowesterberg avatar lindskog avatar majstenmark avatar mechamagpie avatar sadphi avatar sebergo avatar snctfd avatar spekular avatar tejp avatar theolundqvist avatar tomp463 avatar tpi14owi avatar vlthr avatar wanecek avatar zolomon avatar zorobay 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  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

introprog's Issues

consider proposals from SRD

  • Lab chords:

    • improve assignment text to help understand the inputs and outputs rather than focusing too much upfront on music theory.

    • Perhaps the actual code needs to be changed: one difficulty is to understand the difference between tones and grips (toner och grepp).

    • Check if the team aspect of this lab can be supported better; some hade difficulties in how to divide to coding effort into different parts

  • General in team labs: Make them easier so that every one can participate to avoid the risk that the more competent ''take over''.

  • On pirates: it was too difficult this early, but later it might be ok. Maybe remove the difficulty of nested tables and just keep the table at one level, by counting words.

  • Maze was easy, but thats ok; maybe a choice between maze and life is good.

  • check if remaining bugs in lthopoly-team; especially the last step in the assignment

  • kanske stryka en labb? Kanske göra labbarna differentierade; de som är mer kompetenta, kanske direkt kan ge sig på en svårare uppgift

  • minska mängden arbete ge möjlighet till 'självtest' för att kunna gå vidare om man redan kan, erbjuda extrauppgifter som diagnos.

  • Omtentan med matteformel svår för vissa

Add additional behavior to SimpleWindow so that it does not do a system.exit() when last window is closed.

Was discussed on the lunch meeting 2016-05-09.

The issue regards a change in behavior as following: Add additional behavior to SimpleWindow so that it does not do a system.exit() when last window is closed.

Should not affect existing code using the SimpleWindow class.

Proposed solution is to implement a setter that can be used to disable the behavior.

Added code:

private boolean exitOnClose = true;   // The existing behavior
public static void setExitOnClose(boolean exitOnClose) {
    this.exitOnClose = exitOnClose;
}

Modifications to the event handler for the close event is also required.

Gustav has been assigned to give feedback and review the PR.

Sorry for the messy issue, it was rushed.

w06 classes fix comments

see thread in google gorup - should Task 5 on Square with mutable state really be like this???

LTH's computers don't have standard library sources/docs

This issue report is related to the course but not the course's git repo.

When using IntelliJ (I'm not sure how it works in Eclipse), it's possible to hold Ctrl and click on any standard library function to see its source code, which is useful in particular because it lets you view the javadoc/scaladoc comments right in the IDE. By default on the Linux computers in LTH's E building, this works nicely for the Java standard library, but trying to do the same for the Scala standard library only shows function heads without any implementations or comments.

If you go to File > New > Project... and select Scala, you will see that there is a Create button next to the selection of Scala SDK. It shows a window with a list that by default only contains a single entry: System - 2.11.8 without any sources or docs. It is possible to get the sources and docs by using the Download... button in this window, which will create new entries in the list (marked Ivy instead of System), and will make Ctrl-clicking work for Scala methods just like Java methods.

It would be better if the sources and docs were pre-installed so that each person who wants them won't have to download it on their own and keep it in their user directory. Maybe it could be done along with upgrading to Scala 2.12 for next year's instance of the course?

Reduction of team size for team labs

With teams of size 4-6 members problems with distributing work and responsibilities has occurred. Probably fewer of these problems will occur if the team size is decreased to 2 or 3 members.

Make changes in compendium and solutions?

During the autumn I made a note whenever I found a typo or a fault in a solution (as far as I could understand - often that solutions to sub-tasks were missing or mixed up). So should I do the process of creating a fork, commit and pull request? Or can I just make comments in downloaded PDF-file of compendium and solution and send it to Björn? I would like to help out, but I haven't worked with git before - I just read the instructions about how to commit and send pull requests, which seems doable, but all new to me.
Then I also think I found a mistake in one of the slides; w3 - part about Funktioner - title: "Funktionsvärden kan vara argument" (slide 139): Since you apply the function two times, the value should be 44 and 40 (and then 44 again), shouldn't it?
/ Sara

bank examples use IDs that don't fit in the specified data type

The examples in the bank project use IDs that are written like Swedish personal identity numbers, e.g. 6707071234. Many such IDs (in particular, the ones for people born between 1922 and 1999) are too large to fit in Ints, but the specification of Customer says that IDs need to be stored as Ints.

The use of "heltal" in chapter 2

In the exercises in chapter 2, the word "heltal" used both for the positive integers (or natural numbers) as well as all integers. I think the students will understand from the context which numbers it should be, but I suggest we use "positiva heltal" or "naturliga tal" when that is what is meant.

Idea: Lab on `match`

Goals:

  • Learn to match over case classes.
  • Learn to use a trait as a base type.

Task:

  1. Build a small expression language with one case class per language construct.
  2. Create an evaluation function using match.
  3. Extend the language with a new construct and update the evaluator.

Extra:

  1. Build a parser for the language.
  2. Create a pretty-printer that is compatible with the parser.

Importing projects into Eclipse

See appendix on Eclipse ScalaIDE on importing code. Then a .classpath file has to exist to specify Scala-jre otherwise Eclipse will not recognize the project as a Scala project. Otherwise the user has to first create a project and then import the code. @bjornregnell: Change appendix to whatever method will be used during the lectures.

When will git be a mandatory part of the course?

Me and @RXminuS discussed a few weeks ago the insanity (in our opinion) of students not learning VCS until their 2nd year (when I studied it was CVS and SVN, hopefully things have finally caught up by now).

Both me and Rik were of the opinion that Git should be mandatory for first year students, and happened to stumble upon the topic of cheating/lab review. We stumbled upon the issue of people putting up solutions to their labs publicly on GitHub etc, if it weren't for the issue of people sharing/stealing solutions we thought it would be great if everyone did, even if just as an exercise.

That lead us to the point I've been trying to explain the backstory of: What if everyone uploaded their solutions to the labs to a GitLab server maintained by the CS department at LTH? We'd smash two flies in one go: All solutions could be compared and audited to prevent cheating, and everyone would have to learn git. Whether they learn the CLI or some GUI doesn't really matter, what matters is being able to use it. However, the course would likely have to provide educational material for at least one way of using it: I'm in favor of the CLI but I can imagine a lot of people thinking a GUI would be more pragmatic and easier for students to learn the basics. An introduction to the CLI and then a recommendation to use a GUI might be the best approach.

The cheating-discovery process is arguably difficult, but it need not be perfect. People who consider cheating will realise that it's easy to get caught since the solution is on the record. The tool doesn't even have to be created right now, the fact that it could be created in the future should deter people enough.

Anyway, just a thought. Let me know what you think @bjornregnell @majstenmark @gustavcedersjo.

Gather feedback from students

We should collect feedback from students on a detail level so that unclear instructions and redundant/premature exercises will get weeded out.

The question is how. And when should the work on the revised 2017 edition begin? We probably need to start collecting feedback now so we can make a good revision later on.

w09-maze: nested function have different names in method "random"

In the code overview, the functions are named "addSurroundingWalls" and "isThreeWallsAround".
In the instructions, the functions that's mentioned are called "addWallToList" and "threeWallsAround".
In the workspace, the functions are labeled "addSurroundingWalls" and "threeWallsAround".

introduce the concept of function body in w03

The term is needed to explain the difference between the "head" and the body of a function.
Translation to Swedish: (funktions)huvud + (funktions)kropp
(The term "siganture" is actually in Java and Scala only used for param types and function name (but not return type and param names... Hence the need for the term "function head")

W05 - Exercise - Task 11b)

In the scala REPL for task 11b) line 5, it returns an error:

<console>:13: error: type mismatch;
 found   : Unit
 required: Int => ?
       (1 to 100).foreach(print(rnd.nextInt(10)))
                               ^

When I changed the code to (1 to 100).foreach(_ => print(rnd.nextInt(10) + ” “)) it worked but I'm not sure if that's the right way of writing it. What's the correct way?

Clarification of Lab 3 - pirates, task 2

2 b) Ändra i main för att testa att din besättning läses in från filen och skrivs
ut dem i konsolen. Stämmer det med filinnehållet?

Is this meant as "skrivs ut i konsolen" or "skriver ut dem i konsolen"? The formulation needs clarification as the task could mean either that println should be in readCrew or added in main as a test.

w09-maze: Can't load mazes when path contains spaces

In the maze lab, loading the maze files will fail with a FileNotFoundException if the path to the files contains spaces.

getResourcesPath returns a string that contains %20 instead of spaces. Doing .replace("%20", " ") on the string makes maze loading work correctly, but it doesn't feel like a proper solution. Maybe there are other characters that also get returned as % escape sequences.

Which IDEs will be supported?

Eclipse has been the standard in educational contexts for possibly a decade but for the past few years alternatives such as Jetbrains IDEA has grown increasingly popular in professional contexts. Is there any possibility for IDEA being presented as an alternative in the curriculum?

Jetbrains offer free educational licenses for the premium versions of their IDEs.

I could help contribute with the details if necessary.

Also: Awesome initiative with the repo, I am super-excited about having this course open source and open to PRs from students and faculty alike. I hope other teachers follow your lead!

w12_Life doesn't import correctly

It doesn't import correctly since the .classpath file doesn't contain a link to "/src/main/scala/". The files aren't located in "/src/main/scala/" but directly in "/src/".

Exercise var/val/def proposal

In chapter 1, exercise 15, many students missed the "gurka" printout on the definition and use of z and w respectively.

To illustrate when defs and vars evaluated, I propose that we use

var z = math.random
def w = math.random

The {}-expression could be explained separately.

Folder structure of `compendium/modules`

In my opinion, it's currently a mess to navigate. You need to find the list of topic -> week mappings to be able to find a particular module you are looking for.

I propose changing from the following format:

modules
├── w01-chapter.tex
├── w01-exercise.tex
├── w01-lab.tex
├── w01-solutions.tex
├── w02-chapter.tex
├── w02-exercise.tex
├── w02-lab.tex
├── w02-solutions.tex
<...>
├── w14-chapter.tex
├── w14-exercise.tex
├── w14-lab.tex
└── w14-solutions.tex

To the following format:

modules
├── w01-expressions-kojo
│   ├── w01-chapter.tex
│   ├── w01-exercise.tex
│   ├── w01-lab.tex
│   └── w01-solutions.tex
├── w02-programs
│   ├── w02-chapter.tex
│   ├── w02-exercise.tex
│   ├── w02-lab.tex
│   └── w02-solutions.tex
<...>

The folder names would be named as such: w{weeknumber}-{exercisename}-{labname}.

However, there is one added complexity which is probably the reason for this folder structure in the first place. The compendium.tex file which uses \input to include all the files using a foreach. My proposed solution to this is to generate the \input lines using a simple bash-script and put the output in ./generated. The script would look something like this:

#!/bin/bash
for module in modules/*; do
    week=$(echo $module | egrep -o "w[0-9]+")
    for chapterfile in "chapter" "exercise" "lab"; do
        echo "\\input{$module/${week}-${chapterfile}.tex}"
    done
done

Not sure how well this would merge, but I guess git would play nice as long as one carefully did everything with git mv (as the changes I have staged in my tree right now as I prepare a PR).

So, thoughts/critique/feedback?

Remove PDFs from history

The repo is currently huge due to all the PDFs being in history.

We should fix this when this round of the course is over so it's fixed by next year. Might require a git filter-branch that could require a force push.

Clarification of Lab 1 - kojo, task 7

In lab 1, kojo, the following task is described as:

"Uppgift 7. Tidmätning. Hur snabb är din dator?
a) Skriv in koden nedan i Kojos editor och kör upprepade gånger med den
gröna play-knappen. Hur lång tid tar det för din dator att räkna till 4.4 miljar-
der?"

What is the task itself? Should you press the green button 44 times to reach 4,4 billion or should the code be changed so that only one run will suffice?

adapt lab suffle to new progression

  • Don't use inheritance in TestingDeck
  • Rename TestingDeck to TestCardDeck
  • Make constructor of CardDeck private
  • Move origin method from TestingDeck to CardDeck
  • Add factory in companion object
  • Move main from companion object to some test object, e.g. TestCardDeck
  • Make cards array private and provide an apply for getting cards at pos n

add \JavaSpecInputListing feature to the compendium

Integrate function

def replaceOneLinerBlocks(lines: Vector[String], replaceWith: String = ";"): Vector[String] = {
  def checkBalance(s: String): Int = {
        var balance: Int = 0
        if (s.indexOf("{") >= 0) {
          s.toCharArray.foreach(c => {
            if (c == '{') balance += 1
            if (c == '}') balance -= 1
          }
          )
          balance
        } else -1
      def replace(s: String): String = {
        if (checkBalance(s) == 0 && s.indexOf("{") > 0 && s.indexOf("}") > 0) {
          val r = s.substring(s.indexOf('{'), s.length)
          s.replace(r, replaceWith)
        } else s
      }

      lines.map(s => replace(s))
    }

  }

to work with compendium and to be used with \JavaSpecInputListing.

Note: This function doesn't separate the class-body , attributes and class declaration. It simply replaces all one-liner methods with the given string.

Search/sort task 15 b) doesn't compile

In the search/sort chapter, task 15 b) is written as if the provided isSorted function works correctly, but it fails compilation with error: No implicit Ordering defined for T.

Task 15 d) contains the exact same code, but correctly says that there is a problem with the code.

Idea: introduce text game; make more room for creativity

The progression in the first part of the course is rather steep. One idea is to introduce the quest to make a lagom irritating text game that you can't win if you can't read the source code; to practice sequence, logic, alternative with if statements, abstraction with functions and operations on strings. In general: Labs are probably too controlled and with too little room for creativity. Labs can include more open tasks where the goal is to learn something but not to create exactly this and that well-specified program.

lab shuffle: improve case class Hand

In method isStraight

  • rename local def sequential to isSequential and give : Boolean as explicit return type
  • add comment to explain special case with ace in if stmt
  • add doc comment on isStraight
  • remove redundant toVector on cards in val sortedVals
  • should this be a (lazy) val to improve simulation performance???
  • remove redundant curly braces in if stmt and merge or clause into one line to improve readability

In method tally

  • Explain in doc comment that position 0 is unused
  • should this be a (lazy) val to improve simulation performance???

w06-turtlegraphics, left out return type

In the definition for Turtle in turtlegraphics all methods have their return type explicitly defined except for the jumpTo method. Is there a reason for this or is it just a inconsistency that should be corrected?

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.