{"id":22513858,"url":"https://github.com/emahtab/facade-design-pattern","last_synced_at":"2026-01-06T22:51:21.765Z","repository":{"id":79525480,"uuid":"461210426","full_name":"eMahtab/facade-design-pattern","owner":"eMahtab","description":null,"archived":false,"fork":false,"pushed_at":"2022-02-19T17:02:37.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T03:25:44.424Z","etag":null,"topics":["design-pattern","facade-pattern"],"latest_commit_sha":null,"homepage":"","language":null,"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/eMahtab.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}},"created_at":"2022-02-19T14:09:01.000Z","updated_at":"2022-07-02T16:36:27.000Z","dependencies_parsed_at":"2023-06-18T02:46:31.585Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/facade-design-pattern","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffacade-design-pattern","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffacade-design-pattern/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffacade-design-pattern/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Ffacade-design-pattern/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/facade-design-pattern/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245952116,"owners_count":20699428,"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":["design-pattern","facade-pattern"],"created_at":"2024-12-07T03:14:44.169Z","updated_at":"2026-01-06T22:51:21.733Z","avatar_url":"https://github.com/eMahtab.png","language":null,"readme":"# Facade Pattern\n\n\n![Facade Pattern](facade-pattern.png?raw=true)\n\n\n## Facade Example\n![Facade example](facade-example.JPG?raw=true)\n\nInstead of making your code work with dozens of the framework classes directly, you create a facade class which encapsulates that functionality and hides it from the rest of the code. This structure also helps you to minimize the effort of upgrading to future versions of the framework or replacing it with another one. The only thing you’d need to change in your app would be the implementation of the facade’s methods.\n\n```\nclass VideoFile\n// ...\n\nclass OggCompressionCodec\n// ...\n\nclass MPEG4CompressionCodec\n// ...\n\nclass CodecFactory\n// ...\n\nclass BitrateReader\n// ...\n\nclass AudioMixer\n// ...\n\n\n// We create a facade class to hide the framework's complexity\n// behind a simple interface. It's a trade-off between\n// functionality and simplicity.\nclass VideoConverter is\n    method convert(filename, format):File is\n        file = new VideoFile(filename)\n        sourceCodec = new CodecFactory.extract(file)\n        if (format == \"mp4\")\n            destinationCodec = new MPEG4CompressionCodec()\n        else\n            destinationCodec = new OggCompressionCodec()\n        buffer = BitrateReader.read(filename, sourceCodec)\n        result = BitrateReader.convert(buffer, destinationCodec)\n        result = (new AudioMixer()).fix(result)\n        return new File(result)\n\n// Application classes don't depend on a a lot of classes\n// provided by the complex framework. Also, if you decide to\n// switch frameworks, you only need to rewrite the facade class.\nclass Application is\n    method main() is\n        convertor = new VideoConverter()\n        mp4 = convertor.convert(\"funny-cats-video.ogg\", \"mp4\")\n        mp4.save()\n```\n\n\n# References :\n1. https://www.youtube.com/watch?v=fHPa5xzbpaA (Web Dev Simplified : Facade Pattern)\n2. https://www.youtube.com/watch?v=FLmBqI3IKMA (Traversy Media : 5 Design Patterns every engineer should know)\n3. https://refactoring.guru/design-patterns/facade\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Ffacade-design-pattern","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Ffacade-design-pattern","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Ffacade-design-pattern/lists"}