CMPE212 – Reminders Assignment 2 due today, 7pm.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Processing and Java David Meredith
Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Java Development Tools project.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
1 CSE 331 Java Packages; JAR Archives slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
Object Oriented Programming (OOP) LAB # 1 TA. Maram & TA. Mubaraka TA. Kholood & TA. Aamal.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
Netbeans QuickStart. Creating a project File->New Project –For now you want General->Java Application –Then fill in the project details.
Today protected access modifier Using the debugger in Eclipse JUnit testing TDD Winter 2016CMPE212 - Prof. McLeod1.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Notices Assn 2 is due Friday, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including Thursday’s lecture: Big Topics.
Winter 2006CISC121 - Prof. McLeod1 Stuff Midterm exam in JEF234 on March 9th from 7- 9pm.
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Eclipse Navigation & Usage.
Project Topic 2: Migration to Java 9
SECTION 3 MACROS: OVERVIEW.
Java Basics Packages.
CMPE212 – Stuff… Assn 2 due next Friday. Winter 2018
CMPE212 – Stuff… Assn 3 due and Quiz 2 in the lab next week.
Winter 2018 CMPE212 9/21/2018 CMPE212 – Stuff…
Setting up Eclipse Locally
Embracing Java 9 and beyond with Eclipse JDT
CISC124 Assignment 4 on Inheritance due next Monday, the 12th at 7pm.
CISC124 Last Quiz this week. Topics listed in last Tuesday’s lecture.
CISC101 Reminders Quiz 1 grading underway Assn 1 due Today, 9pm.
CISC124 Assignment 3 due this Wednesday at 7pm.
CMPE212 – Stuff… Assn 2 due this Friday. Winter 2018
Fall 2018 CISC124 12/1/2018 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Coding Concepts (Basics)
CISC124 Assignment 4 on Inheritance due today at 7pm.
Debugging Taken from notes by Dr. Neil Moore
CISC124 Assignment 4 on Inheritance due next Friday.
Testing, debugging, and using support libraries
CISC124 Assignment 3 due tomorrow at 7pm.
CISC124 Assignment 4 on Inheritance due next Friday.
Fall 2018 CISC124 2/1/2019 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
CISC/CMPE320 - Prof. McLeod
Applying OO Concepts Using Java
Fall 2018 CISC124 2/22/2019 CISC124 Quiz 1 This Week. Topics and format of quiz in last Tuesday’s notes. The prof. (me!) will start grading the quiz.
CISC/CMPE320 - Prof. McLeod
CISC124 Assignment 3 sample solution will be posted tonight after 7pm.
Debugging Taken from notes by Dr. Neil Moore
CMPE212 – Reminders Assignment 2 due this Friday.
CISC101 Reminders All assignments are now posted.
CMPE212 – Reminders Assignment 2 sample solution is posted.
CMPE212 – Reminders Assignment 3 due next Friday.
CISC101 Reminders Assignment 3 due next Friday. Winter 2019
CISC101 Reminders Assignment 2 due this Friday.
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
CMPE212 – Reminders Assignment 2 due this Friday.
Review: libraries and packages
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
Winter 2019 CMPE212 5/10/2019 CMPE212 – Reminders
CMPE212 – Reminders Assignment 2 due in a week.
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Winter 2019 CMPE212 5/25/2019 CMPE212 – Reminders
CISC101 Reminders Assignment 3 due today.
CMPE212 – Reminders Assignment 5, a JavaFX GUI, due next Friday.
CMPE212 – Reminders Assignment 2 due next Friday.
Workshop for Programming And Systems Management Teachers
Presentation transcript:

CMPE212 – Reminders Assignment 2 due today, 7pm. Winter 2019 CMPE212 5/21/2019 CMPE212 – Reminders Assignment 2 due today, 7pm. Assignment 3 due March 8 – same week as Quiz 2. Winter 2019 CMPE212 - Prof. McLeod Prof. Alan McLeod

Today Coverage Testing. Debugging in Eclipse. Winter 2019 CMPE212 5/21/2019 Today Coverage Testing. Debugging in Eclipse. Upcoming Topics, Including: Packages, Modules, Libraries, Viewing API Source Code. Winter 2019 CMPE212 - Prof. McLeod Prof. Alan McLeod

Coverage Testing in Eclipse Run Debug Coverage Provides an easy way of seeing which lines of code have been covered by your testing code. Winter 2019 CMPE212 - Prof. McLeod

Coverage Testing in Eclipse, Cont. Let’s run Coverage on Halloween5Test.java to see if we missed anything. Green – covered. Yellow – partially covered. (Conditional branch(s) missed, for example). Red – not covered. “We” did miss some tests! Winter 2019 CMPE212 - Prof. McLeod

Coverage Testing in Eclipse, Cont. Getting rid of highlighting: Click here Uses a module called EclEmma. See: http://www.eclemma.org/ Winter 2019 CMPE212 - Prof. McLeod

Debugging Sometimes a mental “walk-through” of your code is not enough to figure out an error. With the debugger you can run to a breakpoint, stop your program and then execute one line at a time while watching the call stack, variables and custom expressions. Let’s fix UseDebugger.java Winter 2019 CMPE212 - Prof. McLeod

Debugging, Summary See “Java development users guide” > “Concepts” > “Debugger” and “Java development user guide” > “Getting Started” > “Basic tutorial” > “Debugging your programs” in the Eclipse help system. Place one or more breakpoints in your edit window. Run in debug mode. Use the “step” choices. View the method call stack, variables, and use expressions if needed. Winter 2019 CMPE212 - Prof. McLeod

Aside – Skipping JRE Code in Debugger Goto Window > Preferences > Java > Debug > Step Filtering. “Select All”: Uncheck “Step through filters” Then “Apply and Close”. Winter 2019 CMPE212 - Prof. McLeod

Skipping JRE Code in Debugger, Cont. When in Debug mode: Turn on “Use Step Filters”: Now, you won’t see as much API code when you are stepping through your code. Winter 2019 CMPE212 - Prof. McLeod

Upcoming Topics & Terms Packages, Modules Enumerated Types Hierarchies, Inheritance, Polymorphism Interfaces, Anonymous Classes, Abstract Classes, Lambda Functions, Inner Classes Generic Classes Winter 2019 CMPE212 - Prof. McLeod

package package_name; Fall 2013 CMPE212 Packages “package” is a Java keyword. It provides a means of grouping classes together into a package. All classes in a package share some common theme. It is used as in: package package_name; This line is at the top of a class definition, before the public class… Winter 2019 CMPE212 - Prof. McLeod Prof. Alan McLeod

Packages and Eclipse Eclipse would prefer that you to create classes in a package. When you create a new class, specify what package you want it to belong to. This will automatically add the package package_name; line to the top of the class, the proper folder is created in src, and the new class in saved in this folder. Eventually, you will create a *.jar (or *.zip) file with all the *.class files in your package in the same folder structure. Put this user library somewhere in or below your classpath and then another class will be able to import it. Winter 2019 CMPE212 - Prof. McLeod

Packages, Cont. The structure is: classpath\folder\packagename “folder” can be a series of folders. The import statement looks like: import folder.packagename.*; The “.*” says to import all classes in the package, or you can import specific classes. Winter 2019 CMPE212 - Prof. McLeod

Packages and Eclipse, Cont. You can add to the classpath by right clicking on Project - Properties to get the window: Then choose “Add Class Folder…” (to get a project folder) or “Add External Class Folder…” (to get a file folder). Winter 2019 CMPE212 - Prof. McLeod

Packages, Cont. We have been importing existing packages already import java.util.Scanner; import java.io.*; … Winter 2019 CMPE212 - Prof. McLeod

Packages, Cont. Note that Java automatically imports the java.lang.* package for you. This package contains many classes fundamental to the Java language: String Math all Wrapper classes (Boolean, Character, Integer, Long, Float, and Double) System, and a few others… Winter 2019 CMPE212 - Prof. McLeod

import static java.lang.Math.*; static Import Used to import all static methods in a class, so that they can be used as if they were declared within the class that uses them. Example: import static java.lang.Math.*; See StaticImportMath.java. We have also seen this in JUnit5 testing classes – for the annotations and assertion methods. Winter 2019 CMPE212 - Prof. McLeod

Aside – Protected Access in Packages So far we have used public and private access modifiers. protected is what you get if you don’t specify an access modifier. This means “public inside the package, private outside the package”. Used in the API. Use sparingly! Winter 2019 CMPE212 - Prof. McLeod

Java Modules This new system of organizing large numbers of Java source code files was introduced in Java 9. Modules are a way to organize many packages into a single module. But there is a little more to it than just grouping packages and files together. Each module must have a module-info.java file: Winter 2019 CMPE212 - Prof. McLeod

module-info.java The module can be built with a large set of packages in a folder structure. The module-info file goes in the root folder of this structure. This file contains information about the name of the module, the packages that are available, and the packages that are required. Basically, the info file supplies all the needed information about how the module interacts with other modules. Winter 2019 CMPE212 - Prof. McLeod

module-info.java, Cont. The format of the file is: module module_name { requires module_name; … exports package_name; } You can have as many requires and exports lines as needed (and some others). Winter 2019 CMPE212 - Prof. McLeod

module-info.java, Cont. requires identifies modules on which this module depends. exports identifies packages in the current module that are available to other modules. This provides encapsulation at the package level! uses identifies specific interfaces and abstract classes or “services” that are used by this module. Winter 2019 CMPE212 - Prof. McLeod

open, opens, provides, with, to, transitive module-info.java, Cont. Other keywords that can be used in the info file: open, opens, provides, with, to, transitive See help docs such as the API docs for the java.lang.module package. Or: https://www.oracle.com/corporate/features/understanding-java-9-modules.html Winter 2019 CMPE212 - Prof. McLeod

Java Modules, Cont. You can also restrict what other modules can see using Reflection. (More on Reflection later…) Dependencies can be specified for use at compilation or at run time or both. Encapsulation is a big advantage. The specification of dependencies reduces the run time size of the program and will speed up execution as a result. A module name must be unique. Winter 2019 CMPE212 - Prof. McLeod

Java Modules, Cont. In this course we won’t need to create modules for our little projects… The Java platform itself is now organized into at least 95 modules. Each module can contain many packages. A lot of the stuff we have been using is in the java.base module. Winter 2019 CMPE212 - Prof. McLeod

Java Libraries A library is distributed and used from a *.jar file (“Java Archive”) on the classpath. It is a compressed file containing only *.class bytecode files organized into the package folder structure specified by the packages. Now, *.jar files also contain the required module-info.class files called “module descriptors”. The *.jar file does not contain any *.java files – these will be in a file called “src.zip” that only comes with the JDK: Winter 2019 CMPE212 - Prof. McLeod

Aside – Viewing Java API Source Code Open up the library link. Most of what we are interested in, for now, will be in the java.base module. When you locate the class or interface of interest and are doing this for the first time, you will see: Winter 2019 CMPE212 - Prof. McLeod

Aside – Viewing Java API Source Code, Cont. Click on “Attach Source…” Choose “External location”, and click on “External File”. Fill out the dialog by providing the location of the src.zip file for the JDK you are using: Winter 2019 CMPE212 - Prof. McLeod

Aside – Viewing Java API Source Code, Cont. Let’s look something up! Winter 2019 CMPE212 - Prof. McLeod