Baixe o app para aproveitar ainda mais
Prévia do material em texto
Projeto de Software / P3 Java sem Orientação a Objetos Márcio Ribeiro marcio@ic.ufal.br twitter.com/marciomribeiro You already know how to program! 3 Aspects of programming § Programming is controlling § Programming is teaching § Programming is problem solving § Programming is crea<ve § Programming is abstrac<on § Programming is concrete § Programming is modelling But... what is a program?! 5 What is a program?! § Sequences of instruc<ons expressed in specific programming language § Instruc<ons wriFen (programmed/coded) by programmers § Model of complex system Object-‐Oriented Programming to model our systems But first, we need to study an OO language! 9 Hello world! public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } }! 10 Compiling and Execu<ng § javac HelloWorld.java § Java Compiler § .class file is generated § java HelloWorld § Java Interpreter § What about the main arguments? § java Soma 5 9 § args[0] = 5 § args[1] = 9 11 Conven<ons § Java is case sensi<ve § Why code conven<ons? § 80% of the life<me cost of a piece of so\ware goes to maintenance § Hardly any so\ware is maintained for its whole life by the original author § Code conven<ons improve the readability of the so\ware, allowing engineers to understand new code more quickly and thoroughly From http://www.oracle.com/technetwork/java/codeconv-‐138413.html 12 Java Code Conven<on Examples public class LinkedList<E> { /** * Adds the specified object at the beginning of this list. * * @param object the object to add. */ public void addFirst(E object) { addFirstImpl(object); } /** * Returns the first element in this list. * * @return the first element. */ public E getFirst() { return getFirstImpl(); } … }! 13 You can use the javadoc tool… 14 … to generate HTML-‐based documenta<on 15 Java Technology § It is a language § High level § So\ware development process: § It is a plaaorm § Two components • Java Virtual Machine • Java Applica3on Programming Interface 16 Portability 17 Java Plaaorm § Development § Compila<on, Execu<on, Debugging, Documenta<on § Applica<on Programming Interface (API) § Useful classes § UI Toolkits § Swing, Java 2D § Deployment § Java Web Start § Integra<on libraries § Databases, Remote Method Invoca<on (RMI) Eclipse IDE 19 Eclipse IDE § So\ware free § Open-‐source project § Developed by Eclipse Founda<on § Resources: § IBM Ra<onal § Borland § IDE architecture based on plug-‐ins § JDT (Java Development Tools) is just one plug-‐in § We can implement our own plug-‐ins 20 Using Eclipse § New project § Name § Loca<on § Layout § Perspec<ves § Project proper<es § Java Build Path § New Package § New class § Running Let us write a program in Java using Eclipse! What can we improve?! 23 What can we improve? § Documenta<on § Define and document constants § Very important for maintenance tasks § BeFer produc<vity § Isn’t main big? 24 Refactoring § Examples: § Constants: “Replace Magic Number with Symbolic Constant” § Method very big: “Extract method” § isEmpty boolean example A change made to the internal structure of so\ware to make it easier to understand and cheaper to modify without changing its observable behavior.
Compartilhar