- You need github account, node.js and text editor or IDE installed
- You can use any online materials, docs, FAQs, AI tools, Videos, etc. it is not important how can you get understanding of tasks and solutions, but we need understanding, not just solutions
- Deadline for all students: 2025-01-?? 14:00
- Here is additional materials you may refer:
- Seminars and lectures closely related to exams:
- Seminar 1
- Seminar 2
- Antipatterns and refactoring
- See examples in
/Example
directory
- Fork this repository: https://github.com/HowProgrammingWorks/Winter-2025-Exams
- Clone this repository to your machine or you can do everything in Github integrated VSCode IDE
- Create branch
exams
- See directory
/Tasks
there are 38 tasks prepared in one of the worst possible implementation and style and N more tasks to be implemented from the scratch - You can select from 3 to 6 tasks (except
difference.js
andsize.js
) to refactor and optimize - Additionaly you can select from 3 to 6 tasks to implement from the scratch
- You may do all the tasks if you want but 6 + 6 is enough for "A"
- In implemented tasks code works and gives right results. You need to change files but do not break functionality covered by tests
- In tasks without given implementation we have just tests and they should pass
- To improve code style you may use:
- Eslint to check style and analyze syntax: https://eslint.org
- Prettier to optimize style and code layout: https://prettier.io
- Here is config example: https://github.com/HowProgrammingWorks/Future/blob/master/prettier.config.js
- Here is recommended eslint config:
- Package.json example: https://github.com/HowProgrammingWorks/Future/blob/master/package.json
- Use tests from
*.tests.js
files to check tasks functionality- For example run:
node size.test.js
to checksize.js
ornpm t
(to check all taks) - Output example:
Test size.js: Passed: 11 of 11
- If tests fails you will see something like:
Case: size(23456789) -> "23 mb", expected: "123 mb"
- For example run:
- Your task is to improve (respect list priority):
- Code readability
- Code style
- Simplicity
- Quality
- Supportability
- Reliability
- Testability
- I'd advice to find a few friends from the group and cross-review the code before exams
- Here is a checklist of common problems we have in code:
- Do not mutate function input parameters
- Prefer arrow functions for JavaScript and
lambda
forPython
- Preferably use
for..of
orfor
on a variable orArray/map
, and avoidfor..in
andforEach
- Use intermediate identifiers to separate long expressions
- Prefer
const
and uselet
as a last resort, but never usevar
- Convert all magic values to constants
- Follow the rules for naming identifiers
- Think carefully about the names of identifiers so that when reading the code, everyone understands their contents
- Don't make functions too long (5-10 lines preferably, ...20 is ok, but...)
- Don't make a big stack of if statements, use arrays and objects instead
- Hints:
- Use eslint and prettier, fix all warnings
- Follow code style and naming conventions from lectures and code examples
- Respect 2 space indentation
- Add empty line between semantic blocks for visual separation
- Don't change incoming parameters
- Decompose complex functions
- Respect SRS (separation of concerns)
- Respect SRP (single responsibility principle)
- Prefer const, minimize let usage
- Remove unneeded operations, calls, arguments, blocks, etc.
- Prefer arrow functions
- Use round brackets even for single argument lambda functions
- Optimize loop invariant
- Optimize lexical scope, minimize area of identifier visibility
- Prefer
for..of
loops, sometimes use classicalfor
, in a rare use.map()
, try to avoid.forEach()
- Use intermediate variables
- Decompose long expressions
- Return result of logical expression instead of
return true; else return false;
- If you prefer any other language instead of JavaScript then translate the code into your language as close as possible
- Make each refactoring and optimization step a separate commit
- It is important not to rewrite code from scratch but to improve it step by step
- At the second seminar, I showed an example of how to optimize the code step by step
- When you're done, make a pull request to my repository
- Good luck!
- Open-source contribution: contact me please
- Conference talk or seminar participation: contact me please
- For those who want technical interview:
- Write your request in our telegram group ASAP and I'll schedule call
- For those who have projects instead of this exams tasks:
- Pet-projects, commercial projects, practical programming experience in products
- You need to create screencast video presentation of codebase and project functionality: 15-30 minutes length
- Upload it to Youtube, Google disk or other hosting with video support and add link to this video in your project repository
- Articles
- MDN contribution