Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC307 Lecture 08

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

CSC307 Lecture 08

Introduction to Software Engineering
Code Review
(202602)

Avatar for Javier Gonzalez-Sanchez

Javier Gonzalez-Sanchez PRO

February 02, 2026
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info office: 14 -227 CSC 307

    Introduction to Software Engineering Lecture 08. Code Review
  2. Clean Your Code! • Manufacturing vs. Crafting Software • Code

    is meant for human consumption, and it’s meant for computer consumption. • Creating software together but not scrambled 3
  3. Clean Code • Write efficient code but prioritize readability and

    maintainability. • Optimize performance-critical sections only when necessary. 5
  4. Clean Code :: Readability (Easy to read to others) •

    Single Responsibility Principle (SRP) • Style and Comments • Do not Repeat Yourselves (DRY) • Keep It Simple (KIS) • Dependency Injection (DI) • Error Handling 6
  5. Single Responsibility • Each class or function should have one,

    and only one, job. • Keep functions focused on a single task. • Break down your code into smaller, reusable modules or functions. • Ensure each module or function has a clear, well-defined purpose. • 7
  6. Don't Repeat Yourself (DRY) • Avoid code duplication by abstracting

    common functionality. • Use functions or classes to encapsulate repeated jobs. 8
  7. Keep It Simple (KIS) • Aim for simplicity in your

    design and implementation. • Avoid unnecessary complexity or over-engineering. 9
  8. Dependency Injection • An object’s dependencies (other objects it relies

    on) are provided externally rather than created internally by the object itself. • Constructor injection: Dependencies are passed via the class constructor. • Setter injection: Dependencies are provided through setter methods. • Make components more accessible to swap or extend without modifying the dependent class. 10
  9. 18 Tip #2 If you are to receive a parameter

    Use the parent class instead of a child. Example: JFrame vs Main
  10. MoveTasks.java 37 Do not use verbs as names for classes!

    Refactor MoveTasks to be Panel instead of Frame
  11. Dependency Injections 41 Pass as a parameter Sprint, so you

    do not need to pass a Full Blackboard object for testing
  12. Step 2 • Create a Test Class for your very

    own Story (in the Test Folder) • No main methods inside of classes that should not have them, i.e., main methods for testing your part goes on the test folder • Only one single main method in the java source folder • The main method start with “Show the Project Page” 47
  13. CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D. [email protected]

    Winter 2026 Copyright. These slides can only be used as study material for the class CSC307 at Cal Poly. They cannot be distributed or used for another purpose.