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

CSC307 Lecture 08

CSC307 Lecture 08

Introduction to Software Engineering
Code Review
(202602)

Javier Gonzalez-Sanchez PRO

February 02, 2026

Transcript

51 slides
  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 307 Introduction to Software Engineering Lecture 08. Code Review
  2. Clean Your Code! • M a nuf a cturing vs.

    Cr a fting Softw a re • Code is me a nt for hum a n consumption, a nd it’s me a nt for computer consumption. • Cre a ting softw a re together but not scr a mbled 3
  3. Clean Code • Write e ff icient code but prioritize

    re a d a bility a nd m a int a in a bility. • Optimize perform a nce-critic a l sections only when necess a ry. 5
  4. Clean Code :: Readability (Easy to read to others) •

    Single Responsibility Principle (SRP) • Style a nd Comments • Do not Repe a t Yourselves (DRY) • Keep It Simple (KIS) • Dependency Injection (DI) • Error H a ndling 6
  5. Single Responsibility • E a ch cl a ss or

    function should h a ve one, a nd only one, job. • Keep functions focused on a single t a sk. • Bre a k down your code into sm a ller, reus a ble modules or functions. • Ensure e a ch module or function h a s a cle a r, well-de f ined purpose. • 7
  6. Don't Repeat Yourself (DRY) • Avoid code duplic a tion

    by a bstr a cting common function a lity. • Use functions or cl a sses to enc a psul a te repe a ted jobs. 8
  7. Keep It Simple (KIS) • Aim for simplicity in your

    design a nd implement a tion. • Avoid unnecess a ry complexity or over-engineering. 9
  8. Dependency Injection • An object’s dependencies (other objects it relies

    on) a re provided extern a lly r a ther th a n cre a ted intern a lly by the object itself. • Constructor injection: Dependencies a re p a ssed vi a the cl a ss constructor. • Setter injection: Dependencies a re provided through setter methods. • M a ke components more a ccessible to sw a p or extend without modifying the dependent cl a ss. 10
  9. Tip #2 19 If you are to receive a parameter

    Use the parent class instead of a child. Example: JFrame vs Main
  10. Tip #3 20 EditProject<> vs NewProject<> It is 4 classes

    instead of 2 DRY :: Do not Repeat Yourselves
  11. J. G. O. S. F. R. J. G. A. B.

    C. H. DRY :: Do not Repeat Yourselves
  12. MoveTasks.java 37 Do not use verbs as names for classes!

    Refactor MoveTasks to be Panel instead of Frame
  13. Dependency Injections 41 Pass as a parameter Sprint or Stories

    or Project, so you do not need to pass a Full Blackboard for testing
  14. Step 2 • Cre a te a Test Cl a

    ss for your very own Story (in the Test Folder) • No m a in methods inside of cl a sses th a t should not h a ve them, i.e., m a in methods for testing your p a rt goes on the test folder • Only one single m a in method in the j a v a source folder • The m a in method st a rt with “Show the Project P a ge” 47
  15. 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.

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming