{"id":18914186,"url":"https://github.com/sc0v0ne/method-replace-inline-code-with-function-call","last_synced_at":"2025-04-15T08:31:07.842Z","repository":{"id":104310014,"uuid":"490706462","full_name":"sc0v0ne/Method-Replace-Inline-Code-With-Function-Call","owner":"sc0v0ne","description":"The Replace Inline Code with Function Call method demonstrates functions as code improvements.","archived":true,"fork":false,"pushed_at":"2024-01-20T19:45:26.000Z","size":255,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T02:10:01.407Z","etag":null,"topics":["method","pytest","python","python-3","python3","refactoring"],"latest_commit_sha":null,"homepage":"","language":"Python","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/sc0v0ne.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-05-10T13:22:08.000Z","updated_at":"2024-11-24T13:07:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"922a1c9c-cd1d-4464-8909-cc1d51f1d5c4","html_url":"https://github.com/sc0v0ne/Method-Replace-Inline-Code-With-Function-Call","commit_stats":null,"previous_names":["sc0v0ne/method_replace_inline_code_with_function_call"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0v0ne%2FMethod-Replace-Inline-Code-With-Function-Call","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0v0ne%2FMethod-Replace-Inline-Code-With-Function-Call/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0v0ne%2FMethod-Replace-Inline-Code-With-Function-Call/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0v0ne%2FMethod-Replace-Inline-Code-With-Function-Call/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sc0v0ne","download_url":"https://codeload.github.com/sc0v0ne/Method-Replace-Inline-Code-With-Function-Call/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249035411,"owners_count":21202080,"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":["method","pytest","python","python-3","python3","refactoring"],"created_at":"2024-11-08T10:10:31.003Z","updated_at":"2025-04-15T08:31:07.546Z","avatar_url":"https://github.com/sc0v0ne.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Method Replace Inline Code with Function Call\n\n🎓 College: [College Methodist Granbery](http://granbery.edu.br/)\n\n👨‍🏫 Teacher: [Marco Antônio - Github](https://github.com/marcoaparaujo) | [Linkedin](https://www.linkedin.com/in/marco-ant%C3%B4nio-ara%C3%BAjo/)\n\n📗 Book: [Refatoração - Aperfeiçoando o design de códigos existentes - Martin Fowler](https://www.amazon.com/-/pt/dp/B087N8LKYB/ref=sr_1_1?__mk_pt_BR=%C3%85M%C3%85%C5%BD%C3%95%C3%91\u0026crid=M4T29CCKD30E\u0026keywords=refatora%C3%A7%C3%A3o\u0026qid=1651322207\u0026sprefix=refatora%C3%A7%C3%A3o%2Caps%2C203\u0026sr=8-1)\n\n\u003e FOWLER, Martin. “Replace Inline Code WIth Function Call” no código. *In*: REFATORAÇÃO: Aperfeiçoando o design de códigos existentes. 2. ed. [*S. l.*: *s. n.*], 2019. cap. 8.\n\u003e \n\n## Method\n\nThe method replace internalized code with function call ( **Replace Inline Code with Function Call**), demonstrates functions as code improvements. As the software develops, we end up creating repeated codes that bring the same result. It may not even harm the software, but maintenance over time can cause difficulties in changing so many codes that produce the same result. This method improves the code by having to create a function, this function will become just one code so that it does not need to be repeated several times. As Martin Fowler says in the book, we will package the code into this function. In places where the Code is repeated, we will just call the function.\n\n## Code\n\nThe code I am using for example is code from my repository. Which aims to check the input value and returns whether it is odd or even. [CODE](https://github.com/DevEddi/project_even_or_odd_python)\n\n## Procedure\n\n- Replace the internalized code with an existing function call.\n- Test\n\n## Test tool\n\n### PyTest\n\n```bash\n     pip install ipytest\n```\n\n## Objective of the activity\n\n1. Design or choose a code that refactoring can be applied to.\n2. Identify the associated bad smell.\n3. Write the test cases and execute\n4. Apply refactoring\n5. Run the test cases again\n6. Document each step for the presentation\n\n## Bad smell\n\n### Duplicate Code\n\nThe bad smell I found within the code below was duplicated code, as developers we ended up creating unnecessary code repetitions. This could harm the code for maintenance, requiring time to search for the repeated expression.\n\n## Old code\n\nYou can visualize how there is repetition.\n\n![Untitled](images/demostra_codigo.png)\n\n## New code applying refactoring\n\nNow observe the creation of the function being used to call the logic just once.\n\n![Untitled](images/chamada_de_função.png)\n\n## Testing\n\n![testes.png](images/testes.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsc0v0ne%2Fmethod-replace-inline-code-with-function-call","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsc0v0ne%2Fmethod-replace-inline-code-with-function-call","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsc0v0ne%2Fmethod-replace-inline-code-with-function-call/lists"}