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. • 3
main(String[] arg) { View view = new View (); Player player = new Player(view); Game game = new Game(view); game.ready(); do { player.move(); game.move(); } while (!game.isOver()); game.bye(); } } public class View { public void print(String s) { System.out.println(s); } } public class Game { View myView; public Game(View v) { myView = v; } public void ready() { myView.print (“Welcome!”); } // more code … }
a t expl a in why something is done, not wh a t is done. • Keep comments up to d a te with code ch a nges. • Document public APIs a nd complex logic thoroughly. 11
of my Paint App. Please review them Write a report (per version, per file): a) Readability (do you understand what is happening) b) DRY? KIS? SRP? c) What about names and comments Provide comments and feedback as needed. - what is good? What is bad?
[email protected] Fall 2024 Copyright. These slides can only be used as study material for the class CSC305 at Cal Poly. They cannot be distributed or used for another purpose.