{"id":21015283,"url":"https://github.com/laisfrigerio/solid-principles-typescript","last_synced_at":"2025-04-12T09:37:10.974Z","repository":{"id":218665029,"uuid":"746981974","full_name":"laisfrigerio/solid-principles-typescript","owner":"laisfrigerio","description":"Implementing SOLID principles with TypeScript in a Password Generator","archived":false,"fork":false,"pushed_at":"2024-01-23T05:21:07.000Z","size":74,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T04:34:35.952Z","etag":null,"topics":["javascript","jest","jest-test","password-generator","solid","solid-principles","solid-principles-examples","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laisfrigerio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-23T02:46:39.000Z","updated_at":"2024-02-15T18:09:49.000Z","dependencies_parsed_at":"2024-01-23T07:39:09.332Z","dependency_job_id":null,"html_url":"https://github.com/laisfrigerio/solid-principles-typescript","commit_stats":null,"previous_names":["laisfrigerio/solid-principles-typescript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laisfrigerio%2Fsolid-principles-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laisfrigerio%2Fsolid-principles-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laisfrigerio%2Fsolid-principles-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laisfrigerio%2Fsolid-principles-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laisfrigerio","download_url":"https://codeload.github.com/laisfrigerio/solid-principles-typescript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248547207,"owners_count":21122468,"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","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":["javascript","jest","jest-test","password-generator","solid","solid-principles","solid-principles-examples","typescript"],"created_at":"2024-11-19T10:09:22.600Z","updated_at":"2025-04-12T09:37:10.953Z","avatar_url":"https://github.com/laisfrigerio.png","language":"TypeScript","readme":"# Solid Principles wih Typescript\n\nImplementing SOLID principles with TypeScript in a Password Generator Project.\n\n## SOLID\n\n- **S**ingle Responsibility Principle (SRP)\n- **O**pen/Closed Principle (OCP)\n- **L**iskov Substitution Principle (LSP)\n- **I**nterface Segregation Principle\n- **D**ependency Inversion Principle\n\n### Single Responsibility Principle\n\nEvery class should have a single responsibility. A class should have one, and only one, reason to change.\n\n### Open/Closed Principle\n\nYou should be able to extend a classes behavior, without modifying it. Software entities should be open for extension, but closed for modification.\n\n### Liskov Substitution Principle\n\nDerived classes must be substitutable for their base classes. Functions that use references to base classes must be able to use objects of derived classes without knowing it.\n\n### Interface Segregation Principle\n\nMake fine grained interfaces that are client specific. Clients should not be forced to depend on interfaces they do not use.\n\n### Dependency Inversion Principle\n\nDepend on abstractions, not on concretions. High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions.\n\n## Solution\n\nWe can generate a password based on the following rules:\n\n- Require a minimum of characters;\n- Require at least one upper case character;\n- Require at least one number character;\n- Require at least one special character.\n\n### The usage of SOLID principles\n\n1. We created a class for each rule under the `./src/domain/rules` folder to ensure the Single Responsibility Principle (SRP).\n2. We created the `RuleFactory` class to be responsible for creating a list of rules based on user options, following again the SRP.\n3. We created the `RuleFactory` class to be open for extension but closed for modification. We can easily add new rules by extending the `ruleClassMap` without modifying existing code (OCP).\n4. Each rule under the `./src/domain/rules` folder implements the `IPasswordGenerationRule` interface, ensuring that they are substitutable for the base type without altering the correctness of the program (LSP).\n5. The `IPasswordGenerationRule` interface follows the Interface Segregation Principle by providing a specific method (`applyRule`) relevant to the implementing rule classes. The Rule class (e.g., RequireNumberRule, RequireSpecialCharacterRule, RequireUpperCaseRule) are not forced to depend on unnecessary methods (ISP).\n6. The `RuleFactory` class depends on the abstraction provided by the `IPasswordGenerationRule` interface, ensuring that high-level modules depend on abstractions rather than concrete implementations.\n\n## 🛠️ Stack\n\n- nodejs `18.12.1`\n- typescript `5.3.3`\n- jest `^29.7.0`\n- yarn `1.22.19`\n\n## :gem: Run tests\n\n```\n    yarn install\n    yarn test\n```\n\n## Contributions\n\nFeel free to contribute and share your ideas. Open an issue and/or a Pull Request. Let's talk about SOLID principles and implementing the best practices!\n\n## 👩 Author\n\n| [\u003cimg src=\"https://avatars.githubusercontent.com/u/20709086?v=4\" width=\"100px;\" alt=\"Lais Frigério\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003e@laisfrigerio\u003c/b\u003e\u003c/sub\u003e](https://instagram.com/laisfrigerio/)\u003cbr /\u003e |\n| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the LICENSE.md file for details\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaisfrigerio%2Fsolid-principles-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaisfrigerio%2Fsolid-principles-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaisfrigerio%2Fsolid-principles-typescript/lists"}