you cre a te the Product B a cklog for the project described in L a b 1 • How m a ny stories (user stories)? • Do you remember INVEST? • Priority? • Estim a tion? 13
form a tting guidelines. https://google.github.io/styleguide/javaguide.html • Use indent a tion, whitesp a ce, a nd comments e ff ectively to enh a nce re a d a bility. 16
n a mes for v a ri a bles, functions, cl a sses, etc. • Identi f iers (n a me of v a ri a bles a nd cl a sses) a re Nouns • Methods a re Verbs • Avoid using misle a ding or cryptic n a mes. • Follow consistent n a ming conventions. 17
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. • Single Line vs Multiple Line ( a nd J a v a Doc) comments 18
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. • 21
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. 30
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(); } }
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 … }
f iles inside src/m a in/j a v a / a nd src/test/j a v a /. pom.xml for M a ven README.md: Overview a nd instructions. Unit test cl a sses using JUnit or simil a r in src/test/ .gitignore - A critic a l f ile to exclude unw a nted f iles 34
[email protected] Summer 2025 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.