Page 386 - Computer_Science_F5
P. 386

(b)  Inheritance:                             (ii)  Use frameworks like unittest
                      (i) Use inheritance to avoid code            or pytest.
                         duplication.
                      (ii) Example: classSavings         (b)  Integration tests:                   Chapter Five: Object oriented programming with Java
                            Account(BankAccount).              (i)  Test the interaction between
          FOR ONLINE READING ONLY
                                                                   different modules.
                 (c)  Composition:                             (ii)  Ensure that components work

                      (i)  Combine simple objects to               together as intended.
                           create complex ones.

                      (ii) Example: A User class       2. Debugging
                            containing multiple            (a)  Print statements: Use for quick
                            BankAccount objects.
                                                               checks on variable values and

              Stage Three: Implementing the project            program flow.
              1. Coding                                    (b)  Debugging tools:

                    Write code:                                (i)  pdb:  Python’s  built-in
                     (i)  Implement classes  and                   debugger for step-by-step
                          methods as outlined in the               execution.
                          design document.                     (ii)  IDEs: Use features in IDEs
                     (ii)  Follow coding standards                 like PyCharm or VSCode for
                          for readability and                      setting breakpoints.
                          maintainability.
                                                       3. Common techniques
              2. Modular development                       (a)  Syntax errors: Carefully review
                 (a)  Build and test: Develop each             error messages and correct typos.
                     module separately, ensuring           (b)  Logic and control flow: Ensure
                     it functions correctly before             the program logic is sound and
                     integrating.                              flow is logical.
                 (b)  Advantages:                          (c)  Exception handling: Gracefully

                     (i)  Easier debugging and testing.        handle potential errors using try-
                     (ii)  Enhances code reusability.          except blocks.


              Stage four: Testing and debugging        Example: Imagine you are a programmer
              1. Testing                               and want to develop an application
                 (a)  Unit tests:                      Library management systems. Use  the
                                                       described stages to show how you can
                     (i) Test individual functions or   undergo.
                          methods.


                                                    377
               Student’s Book  Form Five



     Computer Science Form 5.indd   377                                                     23/07/2024   12:34
   381   382   383   384   385   386   387   388   389   390   391