- Functional Programming Principles in Scala (Scala 2 in general)
- Functional Programming in Scala Specialization (Scala 2 in general)
Each homework assignment corresponds to a specific unit in the course, labeled as unit1
, unit2
, and so on.
For each unit, there are two main components: topic
and challange
, covering both main
and test
.
In the topic
section, relevant material is explained, and template tests are provided.
The challange
section involves implementing or improving code or approaches similar to those covered in the topic
.
Tests are a required and integral part of the assignment contract unless explicitly stated otherwise.
Failure to comply with any of the following rules will result in the homework not being reviewed:
- Both
main
andtest
code must compile successfully. - Tests must be implemented unless explicitly stated otherwise.
- All tests must pass.
- The code must adhere to formatting guidelines.
Students may submit incomplete homework to verify assumptions, but any incompleteness must be explicitly stated in the submission.
The project uses scalafmt as the code formatter for Scala. All code must be formatted using scalafmt after each commit.
- Install Git on your local machine if needed.
- Install Sbt on your local machine if needed.
- Create a GitHub account (if you don’t already have one).
- Set up a private GitHub repository.
- Clone the repository locally (do not fork it).
- Push the local repository to your private GitHub repository.
- Create a new branch for each challenge assignment.
Open https://github.com/ and follow the sign-up procedure.
It's better to choose a professional-like name, usually [First][Last]
name
(my personal GitHub account is https://github.com/IgorWolkov).
Follow the guide to setup GitHub account in Intellij Idea
To create a new repository on GitHub follow the guide.
- It is required that the repository must be private.
- It is required that the repository must be named as
scala-course-spring
as the original one.
To clone a repository follow the guide.
Please do not fork the repository.
Visit https://github.com/ and follow the sign-up process.
Choose a professional username, typically in the format [First][Last]
name (e.g., my personal GitHub account is https://github.com/IgorWolkov).
Follow this guide to set up your GitHub account in IntelliJ IDEA.
To create a new repository on GitHub, follow this guide.
- Ensure the repository is private.
- Name the repository scala-course-spring to match the original repository name.
- Add collaborators
To clone the repository, follow this guide.
Important: Please do not fork the repository.
The course repository is here.
You can either use Intellij IDE or do it manually.
For manually cloning create a new folder called scala-course-spring
, move to the folder and run
git clone https://github.com/Functional-Programming-KSE/scala-course-spring.git
in the commandline
To check the remote repositories run the following command
git remote -v
in the commandline, the output should be
origin https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
origin https://github.com/Functional-Programming-KSE/scala-course-spring.git (push)
To check the branches run the following command
git branch
in the commandline, the output should be
* main
To check the code compiles run the following command
sbt clean compile
in the commandline.
Students not allowed to push the changes to the original course repository.
To prevent accidental pushes, it is necessary to detach the original repository from your private repository.
To do this, rename the origin
and disable push
to the original course repository.
To rename the origin run the following command
git remote rename origin course
in the commandline.
Run git remote -v
in the commandline, the output should be
course https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
course https://github.com/Functional-Programming-KSE/scala-course-spring.git (push)
To prevent pushing to the course repository replace push url by any non-existent url, i.e. DISABLED run the following command
git remote set-url --push course DISABLED
in the commandline.
Run git remote -v
in the commandline, the output should be
course https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
course DISABLED (push)
To link the local repository to your private GitHub repository add new origin
.
Open your new GitHub repository web page and follow the instructions in …or push an existing repository from the command line
section.
There should be a list of commands:
git remote add origin <your private repository>
git branch -M main
git push -u origin main
Run each command one-by-one in the commandline.
Execute git remote -v
in the commandline, the output should be
course https://github.com/Functional-Programming-KSE/scala-course-spring.git (fetch)
course DISABLED (push)
origin https://github.com/<your github account>/scala-course-spring.git (fetch)
origin https://github.com/<your github account>/scala-course-spring.git (push)
The original course repository may be updated from time to time.
To fetch updates from the original course repository run the following command
git pull course main
in the commandline.
A separate branch must be created for each homework assignment.
Students are not allowed to commit any changes to the main
branch, except in cases explicitly described.
Students not allowed to commit any changes to main
branch except the cases described explicitly.
To compile the source code (located in main/
folder) run
sbt clean compile
in the commandline, or
clean; compile
in the sbt
shell.
To compile the test code (located in test/
folder) run
sbt Test / compile
in the commandline, or
Test / compile
in the sbt
shell.
To execute all tests in the project run test
command.
Note: the next command fails and it is expected:
sbt test
in the commandline, or
test
in the sbt
shell.
The failure occurs because the test
command runs all tests in the project.
Since some homework tests have not been implemented yet, this results in a failure.
To execute a single tests run the following command
sbt testOnly <path to the test>
in the commandline, or
testOnly <path to the test>
in the sbt
shell,
For example to execute FunctionsSpecification
from Unit 1 topic
run the following command
sbt testOnly kse.unit1.topic.FunctionsSpecification
in the commandline, or
testOnly kse.unit1.topic.FunctionsSpecification
To execute the tests for a certain unit run the following command
sbt testOnly <path to the certain unit>
in the commandline, or
testOnly <path to the certain unit>
in the sbt
shell, where <path to the certain unit>
is
-
kse.unit1
for the Unit 1; -
kse.unit2
for the Unit 2;...
-
kse.unitN
for the Unit N;
i.e. to execute tests for Unit 1 run the following command
sbt testOnly kse.unit1
in the commandline, or
testOnly kse.unit1
in the sbt
shell,
Scalafmt is used to check the code formatting
and re-formatting the code according to the rules
described in .scalafmt.conf
file in the root (scala-course-spring
) folder.
These rules are applied for code checking in GitHub Action builds.
Follow the guide for setting up code re-formatting via your IDE.
To check whether the code in main/
is properly formatted run
sbt scalafmtCheck
in the commandline, or
scalafmtCheck
in the sbt
shell.
To check whether the code in test/
is properly formatted run
sbt "Test / scalafmtCheck"
in the commandline, or
Test / scalafmtCheck
in the sbt
shell.
To check whether the code in all locations is properly formatted run
sbt scalafmtCheckAll
in the commandline, or
scalafmtCheckAll
in the sbt
shell.
Follow the guide for setting up code re-formatting via your IDE.
To check whether the code in main/
is properly formatted run
sbt scalafmt
in the commandline, or
scalafmt
in the sbt
shell.
To check whether the code in test/
is properly formatted run
sbt "Test / scalafmt"
in the commandline, or
Test / scalafmt
in the sbt
shell.
To check whether the code in all locations is properly formatted run
sbt scalafmtAll
in the commandline, or
scalafmtAll
in the sbt
shell.
To compile the code and fix the formatting run
sbt clean compile Test/compile scalafmtAll scalafmtCheckAll
in the commandline, or
clean; compile; Test/compile; scalafmtAll; scalafmtCheckAll
in the sbt
shell.
To compile the code, fix the formatting and run tests for a certain unit run
sbt clean compile Test/compile scalafmtAll scalafmtCheckAll testOnly <path to the certain unit>
in the commandline, or
clean; compile; Test/compile; scalafmtAll; scalafmtCheckAll; testOnly <path to the certain unit>
To replicate the behavior of the GitHub Actions build locally, run:
sbt clean compile Test/compile scalafmtCheckAll testOnly <path to the certain unit>
in the commandline, or
sbt clean; compile; Test/compile; scalafmtCheckAll; testOnly <path to the certain unit>
in the sbt
shell
Students not allowed to commit any changes to main
branch except the cases described explicitly.
- It is required to have a separate branch for each homework.
- It is required to follow the naming convention for the branches:
-
unit-1
for Unit 1 -
unit-2
for Unit 2...
-
unit-n
for Unit n
-
The name convention is used in the GitHub Actions build setup to run the only tests related to a certain unit. Violating of the conventions leads to failed builds.
- Checkout
main
branch. - Update
main
branch. - Create or checkout a local
unit-n
branch. - Merge
main
branch into the localunit-n
branch. - Commit all necessary changes to the local
unit-n
branch. - Push the changes to the your private remote GitHub repository.
- Create a pull request.
- Assign reviewers
Using the IntelliJ IDEA UI to manage Git actions is easy.