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

CSC307 Lecture 07

CSC307 Lecture 07

Introduction to Software Engineering
Clean Coding
(202307)

Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. jgs CSC 307 Introduction to Software Engineering Lecture 07: Clean

    Coding Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.com Building 14 -227 Office Hours: By appointment
  2. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    2 § Modeling or Design § Construction or Coding Activities
  3. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    4 Key Ideas DRY KIS Readable (comments, names, spaces,…)
  4. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    6 Relationships Association Directed Association Reflexive Association Multiplicity Aggregation Composition Generalization Realization
  5. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    8 import javax.swing.*; public class Example extends JFrame{ public static void main(String[] args) { Example frame = new Example(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } } Method main()
  6. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    9 import javax.swing.*; public class Example extends JFrame{ public Example() { super("Hello World Swing"); GridLayout layout = new GridLayout(3,2); setLayout(layout); JLabel label = new JLabel("Hello World"); add(label); JButton button = new JButton("Click Me"); add(button); JTextField text = new JTextField("Text", 10); add(text); JCheckBox check = new JCheckBox("Option"); add(check); } public static void main(String[] args) { Example frame = new Example(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } } Layouts
  7. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    10 import javax.swing.*; public class Example extends JFrame{ public Example() { super("Hello World Swing"); BorderLayout layout = new BorderLayout(); setLayout(layout); JLabel label = new JLabel("Hello World"); add(label, BorderLayout.CENTER); JButton button = new JButton("Click Me"); add(button , BorderLayout.SOUTH); JTextField text = new JTextField("Text", 10); add(text , BorderLayout.NORTH); JCheckBox check = new JCheckBox("Option"); add(check , BorderLayout.EAST); } public static void main(String[] args) { Example frame = new Example(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } } Layouts
  8. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    31 § public void mousePressed (MouseEvent e) {} § public void mouseClicked(MouseEvent e) { } § public void mouseReleased(MouseEvent e) { } § public void mouseEntered(MouseEvent e) { } § public void mouseExited(MouseEvent e) { } § public void mouseDragged(MouseEvent me) { } § public void mouseMoved(MouseEvent e) { } MouseListener
  9. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    32 § public void mouseDragged(MouseEvent me) { } § public void mouseMoved(MouseEvent e) { } MouseMotionListener
  10. jgs Javier Gonzalez-Sanchez | CSC 308 | Winter 2023 |

    44 Office Hours Tuesday and Thursday 3 - 5 pm But an appointment required Sent me an email – [email protected]
  11. jgs CSC 307 Introduction to Software Engineering Javier Gonzalez-Sanchez, Ph.D.

    [email protected] Summer 2023 Copyright. These slides can only be used as study material for the class CSC308 at Cal Poly. They cannot be distributed or used for another purpose.