12/27/2012
Software Lifecycle, Libraries, and APIs CSC216
CSC216: Programming Concepts © Sarah Heckman 1
CSC216: Programming Concepts © Sarah Heckman 2
1 12/27/2012
Software Process
•Software Process Development Phases – Requirements/Analysis –Design – Implementation/Code –Testing –Integration – Maintenance •Software Artifacts: any document, file, or tangible creation related to the software or its creation or maintenance.
CSC216: Programming Concepts © Sarah Heckman 3
Requirements/Analysis
•Goal: Understand customer requirements for the software system •Very difficult to “get right” the first time through • Requirements may evolve over the course of developing a software system. •Software Artifacts: requirements documents, use cases, user stories
CSC216: Programming Concepts © Sarah Heckman 4
2 12/27/2012
Design
•Goal: decide the structure of the software and the hardware configurations that support it. •How individual classes and software components work together in the software system –Small programs: ~ 10 classes and interfaces –Medium programs: 1000s of classes and interfaces •Design for single user applications different from web applications and mobile applications •Software Artifacts: design documents, class diagrams, other UML diagrams
CSC216: Programming Concepts © Sarah Heckman 5
Implementation/Code
•Goal: translating design into a concrete system (i.e. code) •Can use any language, but some languages are better suited to certain types of programs than others •Software Artifacts: source code, documentation, configuration files, media, executables, bug database, source code repository
CSC216: Programming Concepts © Sarah Heckman 6
3 12/27/2012
Testing
•Goal: Execute software with intent of finding errors • While you can’t test until there is code to run, you can start planning testing when your analyzing the requirements •Software Artifacts: test code (including test harnesses, scaffolding, etc.), bug database, test database, test inputs and outputs, documentation
CSC216: Programming Concepts © Sarah Heckman 7
Integration
•Goal: to bring the entire software system together • Individual programmers or pairs work together on parts of the system. Integration brings all the pieces together into a working whole •Software Artifacts: APIs, interfaces, integration documentation
CSC216: Programming Concepts © Sarah Heckman 8
4 12/27/2012
Maintenance
•Goal: upgrade and fix the software after delivery •Just because you deliver your software doesn’t mean you’re done with it –Work on the next version –Fix bugs in the current version •Software Artifacts: all!
CSC216: Programming Concepts © Sarah Heckman 9
Software Models
•Software Models are generalized approaches to software development that incorporate the phases in different ways –Waterfall –Spiral – Iterative
CSC216: Programming Concepts © Sarah Heckman 10
5 12/27/2012
The Waterfall Model of the Software Life Cycle
Notice back/ feedback arrows.
CSC216: Programming Concepts © Sarah Heckman 11
Spiral Model Determine objectives, Evaluate alternatives, alternatives, & constraints identify & resolve risks
Risk analysis
Risk analysis
Risk analysis P1 Prototype3 Prototype2 Prototype1
Requirements Concept of plan operation Software System Requirements Product Detailed Design Design Development Requirements plan validation P2 Code
Integration Design plan validation Unit Test Develop & verify Plan next phase next level product Integration & Test A prototype is released Acceptance each “circuit.” Some Test prototypes are specifications. Part of circuit n is CSC216:evaluating Programming Concepts circuit © Sarah Heckman n‐1. 12
6 12/27/2012
Iterative Model
Iterative fundamentally means “redo.” Output from an iteration is examined for modification.
CSC216: Programming Concepts © Sarah Heckman 13
Libraries
•A library is a 3rd party collection of code that can be used in other programs –Promotes code reuse –Don’t need to “reinvent the wheel” to complete common tasks –Example: Java API –Example: JUnit
CSC216: Intro to Java Programming © Sarah Heckman 14
7 12/27/2012
Using Libraries
• Download the Library • Install the Library –An executable (Java Libraries) –A jar executable to download rest of library (JAXB) –A jar file (JUnit, Apache libraries, etc.) • Include Library on path when compiling and executing your application
CSC216: Intro to Java Programming © Sarah Heckman 15
Classpaths
•The path(s) where Java looks for libraries (i.e., referenced code) when compiling and running a program •Use the –cp argument to the java command • Separate directories/jars with a semi‐colon (;) •Each jar should be listed individually – You cannot specify a directory of jars • Alternatively, you can update the System’s PATH environment variable –Make sure you restart your terminal so the new path will be available
CSC216: Intro to Java Programming © Sarah Heckman 16
8 12/27/2012
Using Libraries on the Command Line
• Command to compile and run – Assumption is that the project is set up in directory structure like Eclipse project eos% javac -d bin -sourcepath src -sourcepath test -cp path1;path2;path3 src/pack/age1/*.java src/pack/age2/*.java test/pack/age2/*.java eos% java -cp ./bin;path1;path2;path3 pack.age1.ClassName
CSC216: Intro to Java Programming © Sarah Heckman 17
Creating a User Library in Eclipse
•Right‐click on your project, select Build Path > Configure Build Path • Select Add Library … > User Library > User Libraries…. • Select New and give your library a name. You do NOT need to add your library to the system path –But if you do add it to the system path, you can use it from the command line • Select your library and press the Add Jars button. Brows your file system and select the *.jar files appropriate for your library. Press OK. Press Finish. Press OK.
CSC216: Intro to Java Programming © Sarah Heckman 18
9 12/27/2012
Creating a User Library in Eclipse (2)
•If working with a partner, you should agree on a library name (case matters) • Each partner will create a local version of the library that points to the jar(s) on their system •The project must have the library name associated with it •If there are build path errors, the project icon will be highlighted with a big red explanation point!
CSC216: Intro to Java Programming © Sarah Heckman 19
Other Library Setups
•Some projects store all relevant *.jar files in a lib/ directory –Jars are added to lib in file system –In Eclipse, select the Add Jar option and add the jar(s) • Building applications, like Maven, will download the required jar(s) from online repositories • Building applications, like Ant and Maven, simplify compilation and running when using the command line rather than an IDE
CSC216: Intro to Java Programming © Sarah Heckman 20
10 12/27/2012
APIs
•API: Application Programming Interface –Series of webpages –Describe the public classes, interfaces, and methods of Java class libraries –Describe what functionality is available for you, the client, of the libraries to use •Example of abstraction –API tells you what a class can do, but doesn’t tell you how the class does it •Java 1.6 API: http://java.sun.com/javase/6/docs/api/
CSC216: Programming Concepts © Sarah Heckman 21
API Layout
• Packages: Upper left • Classes: Lower left • Details: Main frame –List of packages and descriptions –List of classes and descriptions –List of class members and descriptions • Inheritance hierarchy • Public fields and constants • Constructors • Methods
CSC216: Programming Concepts © Sarah Heckman 22
11 12/27/2012
Creating Our Own APIs • Sometimes we’re the client of a library –Java API –3rd Party Libraries – JFreeChart, JUnit, JAXB, etc. • Sometimes we’re writing code that others will use – Need to provide an API for those clients • Sometimes we’re working with a large team and other members of the team may need to know what we’re doing – Need to provide high level details
CSC216: Programming Concepts © Sarah Heckman 23
Javadoc • Javadoc comments are used to generate API pages • Javadoc comments are processed by a doclet –A Doclet is a Java program that generates documentation with a standard format from comments in your source code. • Command to create Javadoc % javadoc [comma-separated list of source files]
•See CSC Style Guidelines for directions on how to Javadoc your code • Eclipse will write a lot of Javadoc for you •All classes, methods, and fields MUST be Javadoced for projects –This includes test classes and methods! –You will also generate Javadoc and submit that with your zipped Eclipse project to Moodle!
CSC216: Programming Concepts © Sarah Heckman 24
12 12/27/2012
Javadoc Comments
•Start with /** and end with */ –There are 2 *s after the initial /
• Javadoc comments are placed immediately before whatever they are commenting –No additional new lines! • Javadoc tags start with @ and specify additional information about code that is handled in a specific way
CSC216: Programming Concepts © Sarah Heckman 25
Javadoc – Class Level import java.util.Scanner;
/** * A description of what the class * does. The more detailed the * better * @author Author Name * @version 1.0 */ public class MyClass { … }
CSC216: Programming Concepts © Sarah Heckman 26
13 12/27/2012
Javadoc – Method Level
/** * Describe what the method does * at the top. If it returns * something, start with “Returns * …”. * @param paramName1 param desc. * @param paramName2 param desc. * @return description of return */ public
CSC216: Programming Concepts © Sarah Heckman 27
Javadoc – Instance Fields public class MyClass { /** Describe field */ private
14 12/27/2012
References
• http://www.di.net.au/blog/index.php/2009/05/ the‐lighter‐side‐of‐the‐software‐process/ •Laurie Williams, Process Models slides: http://agile.csc.ncsu.edu/SEMaterials/ProcessM odels.pdf
CSC216: Programming Concepts © Sarah Heckman 29
15