{"id":30830239,"url":"https://github.com/samarjiit/loose_tight_coupling","last_synced_at":"2025-09-06T15:52:01.527Z","repository":{"id":309237028,"uuid":"1035572909","full_name":"Samarjiit/loose_tight_coupling","owner":"Samarjiit","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-10T17:44:14.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-10T19:22:28.158Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Samarjiit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2025-08-10T17:23:06.000Z","updated_at":"2025-08-10T17:44:17.000Z","dependencies_parsed_at":"2025-08-10T19:22:31.572Z","dependency_job_id":"54f68b9e-54dd-4b18-9551-0e37d79fafde","html_url":"https://github.com/Samarjiit/loose_tight_coupling","commit_stats":null,"previous_names":["samarjiit/loose_tight_coupling"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Samarjiit/loose_tight_coupling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarjiit%2Floose_tight_coupling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarjiit%2Floose_tight_coupling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarjiit%2Floose_tight_coupling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarjiit%2Floose_tight_coupling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Samarjiit","download_url":"https://codeload.github.com/Samarjiit/loose_tight_coupling/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Samarjiit%2Floose_tight_coupling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273926555,"owners_count":25192318,"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-09-06T02:00:13.247Z","response_time":2576,"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":"2025-09-06T15:51:59.469Z","updated_at":"2025-09-06T15:52:01.519Z","avatar_url":"https://github.com/Samarjiit.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tight Coupling vs Loose Coupling – Java Example\n\nThis project demonstrates the difference between **tight coupling** and **loose coupling** in Java using a simple example of fetching user details from a data source.\n\n---\n\n## 📌 Tight Coupling\n\nIn tight coupling:\n\nClasses are directly dependent on each other’s concrete implementations.\n\nExample:\nUserManager creates an instance of UserDatabase directly and calls its methods.\n\njava\nCopy\nEdit\nprivate UserDatabase userDatabase = new UserDatabase();\nProblem: If the data source changes (e.g., switch from MySQL to MongoDB or Web Service), you must modify the UserManager code.\n\nImpact:\n\nLow flexibility\n\nHard to maintain\n\nNot easily scalable\n\n## 📌 Loose Coupling\nIn loose coupling:\n\nClasses depend on abstractions (interfaces/abstract classes), not concrete implementations.\n\nExample:\n\nUserDataProvider interface defines a contract for fetching user details.\n\nDifferent implementations:\n\nUserDatabaseProvider – Fetches data from a database.\n\nWebServiceDataProvider – Fetches data from a web service.\n\nNewDatabaseProvider – Example for adding another data source.\n\nUserManager depends on UserDataProvider:\n\njava\nCopy\nEdit\nprivate UserDataProvider userDataProvider;\n\npublic UserManager(UserDataProvider provider) {\n    this.userDataProvider = provider;\n}\nBenefit: Adding a new data source only requires:\n\nCreating a new class that implements UserDataProvider.\n\nPassing it to UserManager at runtime.\n\nImpact:\n\nHigh flexibility\n\nEasier to maintain\n\nScales without modifying existing code\n\n## 📌 Key Takeaways\nTight coupling makes systems rigid and hard to change.\n\nLoose coupling promotes flexibility, maintainability, and scalability.\n\nUse interfaces or abstract classes to decouple components.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamarjiit%2Floose_tight_coupling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamarjiit%2Floose_tight_coupling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamarjiit%2Floose_tight_coupling/lists"}