Refactoring an Existing Code Base to Improve Modularity and Quality
Total Page:16
File Type:pdf, Size:1020Kb
Iowa State University Capstones, Theses and Graduate Theses and Dissertations Dissertations 2020 Refactoring an existing code base to improve modularity and quality Souradeep Bhowmik Iowa State University Follow this and additional works at: https://lib.dr.iastate.edu/etd Recommended Citation Bhowmik, Souradeep, "Refactoring an existing code base to improve modularity and quality" (2020). Graduate Theses and Dissertations. 18279. https://lib.dr.iastate.edu/etd/18279 This Dissertation is brought to you for free and open access by the Iowa State University Capstones, Theses and Dissertations at Iowa State University Digital Repository. It has been accepted for inclusion in Graduate Theses and Dissertations by an authorized administrator of Iowa State University Digital Repository. For more information, please contact [email protected]. Refactoring an existing code base to improve modularity and quality by Souradeep Bhowmik A thesis submitted to the graduate faculty in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE Major: Computer Science Program of Study Committee: Simanta Mitra, Co-major Professor Gurpur Prabhu, Co-major Professor Ying Cai The student author, whose presentation of the scholarship herein was approved by the program of study committee, is solely responsible for the content of this thesis. The Graduate College will ensure this thesis is globally accessible and will not permit alterations after a degree is conferred. Iowa State University Ames, Iowa 2020 Copyright © Souradeep Bhowmik, 2020. All rights reserved. ii DEDICATION This thesis work is dedicated to my parents, Baran Kumar Bhowmik and Soma Bhowmik, and my brother Barnadeep Bhowmik, who mean the world to me. Their constant words of encouragement and support throughout my life has been the reason for my success. They have been with me through highs and lows and have always given me the guidance required to help me be successful in life. iii TABLE OF CONTENTS Page LIST OF FIGURES .........................................................................................................................v LIST OF TABLES ......................................................................................................................... vi NOMENCLATURE ..................................................................................................................... vii ACKNOWLEDGMENTS ........................................................................................................... viii ABSTRACT ................................................................................................................................... ix CHAPTER 1. INTRODUCTION ....................................................................................................1 CHAPTER 2. LITERATURE REVIEW .........................................................................................4 CHAPTER 3. QUALITATIVE REFACTORING STANDARDS .................................................6 Cohesion .................................................................................................................................... 6 Coupling .................................................................................................................................... 6 Code organization ...................................................................................................................... 7 Code reusability ......................................................................................................................... 7 Extensibility ............................................................................................................................... 7 CHAPTER 4. ANALYSIS OF EXISTING CODE .........................................................................8 Application Description Language ............................................................................................ 8 ADLApplication.java ........................................................................................................... 8 Input.java .............................................................................................................................. 8 Ui.Java .................................................................................................................................. 9 Parser.java ............................................................................................................................ 9 ServerGenerator.java ............................................................................................................ 9 ServerStringGenerator.java .................................................................................................. 9 ClientGenerator.java............................................................................................................. 9 Utilities.java ....................................................................................................................... 10 Constants.java..................................................................................................................... 10 Analysis of ADL ...................................................................................................................... 11 Module cohesion ................................................................................................................ 11 Module coupling................................................................................................................. 12 Code organization............................................................................................................... 13 Code reusability .................................................................................................................. 13 Extensibility........................................................................................................................ 13 CHAPTER 5. DESIGN AND IMPLEMENTATION ...................................................................14 Types of refactoring done on ADL .......................................................................................... 14 iv Change class design............................................................................................................ 14 Split variable assignment.................................................................................................... 14 Repackaging ....................................................................................................................... 14 Slide statements .................................................................................................................. 15 Removing of hard coded values ......................................................................................... 15 Class usage of static members ............................................................................................ 15 Extract functions................................................................................................................. 16 Simplify code ..................................................................................................................... 16 Extract modules .................................................................................................................. 16 Rename variables ............................................................................................................... 17 Meaningful comments ........................................................................................................ 17 Remove dead imports and code.......................................................................................... 17 Design Architecture of React app ............................................................................................ 17 Implementation of React app ................................................................................................... 19 AppContainer.jsx ................................................................................................................ 19 Login.jsx ............................................................................................................................. 20 Signup.jsx ........................................................................................................................... 20 Contact.jsx .......................................................................................................................... 20 About.jsx ............................................................................................................................ 20 All Model Components ...................................................................................................... 21 NavBar.jsx .......................................................................................................................... 21 ProfileNav.jsx ..................................................................................................................... 21 APICall.jsx ......................................................................................................................... 22 FormsComponent.jsx ......................................................................................................... 22 TD.jsx ................................................................................................................................. 22 CHAPTER 6. COMPARISON ......................................................................................................24