PV 168: Úvod Petr Adámek (adamek@fi.muni.cz) Pavel Hrdina (polecek@mail.muni.cz) Course goal How to design and develop software to fulfill all requirements and maximize the added value for customer. Common Key Requirements • Fulfilling customers requirements • Usability (for end users) • No bugs • Short Time To Market • Total costs (including maintenance) • Flexibility / adjustability for changes (during development or in future, problem with data migration, compatibility of API / WS) Resources The Mythical Man-Month: Essays on Software Engineering Frederick P. Brooks, Jr. Addison-Wesley, 1975. 3 Resources The Mythical Man-Month: Essays on Software Engineering, Anniversary Edition Frederick P. Brooks, Jr. Addison-Wesley, 1995. http://www.amazon.com/dp/0201835959/ 4 What makes it difficult? • Complexity – many requirements, complicated domain, complicated technologies, complicated design • Lack of clarity – complicated and hard to understand code • Irresponsible attitude – not paying attention to important details, low work ethic (botcher/fušer) • Interpersonal communication (both direct and indirect) – problem with understanding between involved humans, missing common vocabulary Course organization • Lectures • A little theory, examples and demonstrations • Seminars • Practical experience • Tasks / Project • Technologies • Swing, Threads, JDBC, Unit tests, Java Servlets, JSP Resources Clean Code: A Handbook of Agile Software Craftsmanship Robert C. Martin http://amazon.com/dp/0132350882/ 7 Resources Effective Java (3rd Edition) Joshua Bloch https://www.amazon.com/dp/0134685997 8 Resources Refactoring: Improving the Design of Existing Code Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts http://amazon.com/dp/0201485672/ 9 Swing Swing • Java GUI toolkit, based on Java AWT • Part of JFC • Part of Java Cora API since Java 1.2 • Alternatives • AWT (Abstract Windows Toolkit) • SWT (Standard Widget Toolkit) • JavaFX • https://docs.oracle.com/javase/tutorial/uiswing/index.html Event driven programming • Application is reacting to events, which are delivered to appropriate component • Source of event • User (mouse, keyboard, or other input device) • Other component • Type of event • Low level (e.g. user pressed or released some key, user moved the mouse cursor, user clicked/double clicked at specific position) • High level (usually generated as reaction to some low level event, e.g. user pressed some button, user selected some menu item, user moved cursor) Event handling • For each type of event, there is an: • Event object – represents the event, contains the reference to the source component and possible other attributes (e.g. mouse cursor position). • Event listener – interface representing the component which is receiving the event (it must be implemented by any component which is receiving this type of events). • If we want to react to some event, we have to: • Create event listener (it can be implemented as regular java class, anonymous local class, or lambda expression / method reference – if the event listener interface is functional interface). • Register the event listener at the component which is emitting the events. • Events must be handled in Event Dispatcher Thread (EDT)! Example // Create instance of button component JButton button = new JButton(“My button"); // Create event listener ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent e) { // Zobrazíme dialogový box s informací o stisknutí tlačítka JOptionPane.showMessageDialog(null,"Stisknuto tlačítko: " + e.getActionCommand()); } }; // Register the event listener button.addActionListener(actionListener); First Swing Application Závěr ? <17>