{"id":22218306,"url":"https://github.com/coders-school/fan_controller","last_synced_at":"2025-07-27T14:32:35.906Z","repository":{"id":80083194,"uuid":"186422427","full_name":"coders-school/fan_controller","owner":"coders-school","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-21T06:46:44.000Z","size":174,"stargazers_count":0,"open_issues_count":0,"forks_count":30,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T03:04:02.598Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coders-school.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-13T13:12:37.000Z","updated_at":"2022-01-07T09:14:35.000Z","dependencies_parsed_at":"2024-12-02T22:20:47.006Z","dependency_job_id":"c86bd4be-96d9-4374-962b-5003b9962389","html_url":"https://github.com/coders-school/fan_controller","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coders-school/fan_controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coders-school%2Ffan_controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coders-school%2Ffan_controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coders-school%2Ffan_controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coders-school%2Ffan_controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coders-school","download_url":"https://codeload.github.com/coders-school/fan_controller/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coders-school%2Ffan_controller/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267370616,"owners_count":24076458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T22:20:13.669Z","updated_at":"2025-07-27T14:32:35.900Z","avatar_url":"https://github.com/coders-school.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Good programming practices\r\n\r\n- Clean code\r\n- Naming conventions\r\n- Code formatting\r\n- KISS\r\n- DRY\r\n- YAGNI\r\n- SOLID\r\n- GRASP\r\n- Testable code\r\n- Dependency injection\r\n- Test doubles: dummy, stub, mock\r\n- TDD\r\n\r\n## Description\r\n\r\nYour company needs a controller that can properly cool down some other devices. It will use 2 devices: a thermometer to read the temperature and a fan to control.\r\n\r\nYour architect has already proposed interfaces.\r\n\r\nThe SlowThermometer will be used as a thermometer in your product. It provides with a current temperature. It is a vendor implementation and you cannot change it.\r\n\r\nFan must be controlled appropriately and must speed up when the temperature is too high or should be disabled when it is too low. Fan speed (in rpm - rotations per minute) can be set from 1000 to 3000. It can also be equal to 0, what means that the fan is disabled.\r\n\r\nThe Controller require a termomether and a fan to work. Without them it does not work. It also needs a target temperature and a tolerance. When the temperature is in a range \u003ctargetTemperature - tolerance, targetTemperature + tolerance\u003e, controller should keep the fan speed at 1000 rpm. When it is below targetTemperature - tolerance, the fan should be disabled. When it is above, the fan speed must must be adjusted by 1 rpm per each 0.001 degree. Max speed is 3000 rpm.\r\n\r\nController can have an LCD display, which displays current temperature, target temperature and a fan speed. It can also work without a display.\r\n\r\n## Assignment\r\n\r\n### Propose improvements for the existing code\r\n\r\nWrite them on a flipchart / notepad.\r\n\r\n### Refactor the existing, tested code\r\n\r\n1. Never change both implementation and tests, because if tests fails you don't know if tests or implementation are broken\r\n2. Apply your improvements\r\n\r\n    \u003cdetails\u003e\u003csummary\u003eSpoiler\u003c/summary\u003e\r\n    \u003cp\u003e\u003cul\u003e\r\n        \u003cli\u003emissing virtual destructors\u003c/li\u003e\r\n        \u003cli\u003econst correctness (const functions, const params, const variables)\u003c/li\u003e\r\n        \u003cli\u003eredundant constructors\u003c/li\u003e\r\n        \u003cli\u003ebroken Rule of 3, 5, 0\u003c/li\u003e\r\n        \u003cli\u003eovercomplicated implementation\u003c/li\u003e\r\n        \u003cli\u003edead code\u003c/li\u003e\r\n        \u003cli\u003euse default, delete, override\u003c/li\u003e\r\n        \u003cli\u003epass shared_ptrs via \u003ccode\u003econst \u0026\u003c/code\u003e\u003c/li\u003e\r\n        \u003cli\u003e\u003ccode\u003eshared_ptr\u003c/code\u003e's constructor -\u003e \u003ccode\u003estd::make_shared\u003c/code\u003e\u003c/li\u003e\r\n    \u003c/ul\u003e\u003c/p\u003e\r\n    \u003c/details\u003e\r\n\r\n### Write a missing part in TDD mode\r\n\r\nWrite an implementation of a Controller class in TDD using either Catch2 framework in BDD style with Hippomocks as a mocking framework or using GTest with GMock. Remember about good programming practices.\r\n\r\n#### Tips\r\n\r\n- extract magic values to consts (constexpr)\r\n- use dependency injection to inject artificial thermometer for testing\r\n- use exception to simplify the error handling\r\n- use STL algorithms\r\n- use references instead of raw pointers\r\n- avoid code duplication\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoders-school%2Ffan_controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoders-school%2Ffan_controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoders-school%2Ffan_controller/lists"}