Lecture 1 slides

Download Report

Transcript Lecture 1 slides

CSCI E-70
Graphical User Interface
Programming in Java
29 January 2003
Instructor: Daniel Bromberg, Mitsubishi Electric Research Labs
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
1 of 15
Welcome to E-70!
• Extend Java skills to advanced client-side libraries
– the java.awt and javax.swing package families
• Apply skills with generic libraries
– java.util.Collection, java.net, java.lang, ...
• Improve programming fluency
– Apply data structures to solve cool problems
– Learn more Object-oriented design, techniques
– Perfect Java language knowledge: syntax, idioms, limitations
• Learn the multi-threaded, event-driven, framework-based,
visual modeling way of life
• Make programs ordinary people can actually use
• Think hard, code a lot, have fun
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
2 of 15
Course Layout
• Lectures
– Every Wednesday from Jan. 29 to May 14 excl. holidays
• Maxwell Dworkin G135, 5:30-7:30 PM
• 5 minute break at the hour
– Primarily presentation and demonstrations by Instructor
• Theory, example, motivate, guide to important study points
• Present homeworks, projects, tests; outline requirements
• Announce changes in policy, schedule
– Questions and discussions as needed
• Section
– Tentative After lecture, 8-9 PM, Location TBA
– Led by your Teaching Fellow
– Driven almost entirely by student questions and needs
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
3 of 15
Additional Help
• Web Site
– http://www.fas.harvard.edu/~libe70/current
• Check constantly for updates, hints, notes
– Please read entire syllabus – many important details
• Ultimate Bulletin Board
– Group technical discussions
– Moderated by staff – both TFs and I contribute
• E-mail TFs with private questions, grading issues
• Attend regular TF office hours
– Possibly schedule additional if need more help
• Contact instructor
– course policy questions – general concerns & complaints
– office hours by appointment
• Come to us one way or another; don’t sink or disappear
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
4 of 15
Workload
• 1st half: 5-6 problem sets: 40%
– Exercises. short programs, practice “project”
• Mid-game summary: Midterm Exam: 15%
– Keep you on-target; gauge individual mastery
– root out technical weaknesses before final project
• SPRING BREAK!
• 2nd half: The Final Project (approx. 5 weeks) 45%
– 3 stages (progessive building blocks)
• Proposal (2-3 pages)
• Design charts & Class skeletons (5-8 pages)
• Final package (code + documentation, 15-30 pages)
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
5 of 15
Books & References
Required:
Graphic Java 2, Volume 2: Swing (3rd Edition)
by David M. Geary: Prentice Hall PTR; ISBN: 0130796670;
3rd edition (March 12, 1999)
Java Event Handling
by Grant Palmer: Prentice Hall PTR; ISBN:
0130418021; Bk&Cd-Rom edition (August 8, 2001)
Recommended:
Java 2D API Graphics
by Vincent J. Hardy: Prentice Hall PTR; ISBN: 0130142662;
1st edition (November 3, 1999)
(Especially if you think final project will involve drawing)
Others: see “recommended reading” handout
Topley: Advanced text & document formatting
Zukowswi: Extra JBuilder practice
Robinson et al.: Practical GUImiddleware
Walrath et al.: Printed Sun tutorial
Lewis et al.: Multithreaded applications
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
6 of 15
Prerequisites
• Enjoy using a GUI; no GUI programming needed
• Data Structures experience: beyond int x; float y;...
– one-dimensional arrays and loops should be “old hat”
– understand tables, trees, and graphs in order to apply them
• Fine to use library classes: java.util.Collection et al.
• Java/OO experience: beyond one big main()...
– Declaring base classes, derived classes
• Polymorphism (just another Big Word?)
– Formal vs. actual data types are different but “compatible”
– Reference semantics of objects
• Passing an Object as a parameter sends a reference to receiver
– Notion of “incomplete” classes
• pure functional: interfaces
• mixed implementation/functional: abstract classes
– Don’t panic – we’re here to practice all of this!
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
7 of 15
Submitting Work
• Use the ‘submit’ facility on Harvard Unix system
– personal workstation, fas.harvard.edu, ice.harvard.edu
– NO other method will be accepted! (no paper)
– man submit(1): see examples; course is cscie70
• Late penalty of 5% per day including weekends
– However: 8 free late days. Entirely self-budgeted.
– Intended for occasional “soft” extension – water pipe burst – kid
ate your homework – got sick – snow storm – disk crashed
• It will happen
• MAKE BACKUPS EVERY DAY PLEASE!
– Therefore any other extension only for medical emergencies
• Deadlines fall on Friday just before midnight
– Gives you time to mull over Wednesday’s section
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
8 of 15
Getting Started with Development
• By next class, be able to run Java 2 SDK 1.4
– Edit, compile, test Java/Swing programs
• By 3rd class, need JBuilder environment
– Will be installed in 53 Church St.
– Personal Edition 8 is free download
• Establish work environment now
– at Harvard, work, home, laptop, or combination
– See HASCS guide off of www.fas.harvard.edu
• Will distribute CD next week
– Online book, JDK 1.4 JavaDoc, JBuilder, readings, code
Stop for Questions
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
9 of 15
Submission Standards
• Clean code
–
–
–
–
Header comments: name, date, purpose, implementation notes
Thoughtfully chosen variable, constant, and class names
Consistent indentation and spacing style
Comments describing inputs, outputs, errors, and “side effects” of
every major function
• Evidence of testing
– Show graceful error handling & non-trivial, valid inputs
• Often means 2-3 well-chosen screendumps of a GUI in action
• Accompanying documentation as requested
– Projects: UML diagram, user manual, architectural overview...
• Standards will become stricter as we provide feedback
– Try your best for now; focus on clean code
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
10 of 15
Java: my take
• Best widely available OO language I know of
– Far from perfect
• too “safe”? bounds checking slows performance
• too compromised by C legacy? primitive vs. object dichotomy
• Fought over by Micro$oft
– Court ordered re-integration to Windows
– But C# is an up-and-comer? Will .NET dominate?
• Industry battles: I shrug it off
– Java not independently standardized (like C)
• May not last forever
• As a developer, be flexible and switch when the time comes
– Learn good Object Oriented programming
• applicable from C through Python to Java and beyond!
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
11 of 15
Let’s Swing!
• AWT/Swing libaries are a monstrous hairy beast
– Fear not for ye shall wrestle them to the ground
• Explain architecture on-demand for now
– Get your feet wet
– Tie code to visuals
• Let’s put up a window
–
–
–
–
–
–
import: the GUI packages
JFrame et al.: “Heavyweight” components
contentPane: access to body area
BorderLayout: basic component layout manager
JButton: interactive control
ActionListener / ActionEvent: event handling
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
12 of 15
start
Visual States
standard windows
decoration & titlebar;
inside controlled by pure
Java renderers
pressed inside
hilights
released outside
un-hilights
• Note dotted outline; means
component has focus
• can use space bar to fire
• more on focus later
resizable unless specified
otherwise. centered component
grows to fill bounds
pressed inside
hilights
released outside
un-hilights
released inside
un-hilights; msgs printed
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
13 of 15
State Machines
a
• In essence
– Stripped-down history of program’s execution
• Only what you need to react correctly to future events
b
– Theoretical basis of the “data models” I will be
rambling about
• Big Stuff
– Underlies Computer Science and Computer
Engineering at all levels
• Practical and efficient once discipline learned
– Ideally suited for processing unpredictable input over
long periods
– Forces understanding of the problem you’re solving
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
14 of 15
Follow-up
Review and additional detail:
http://java.sun.com/docs/books/tutorial/uiswing/start/index.html
especially .../start/swingTour.html
Problem Set 1:
• Student Survey
• Programming
–
–
–
–
–
–
due at end of class
due Friday Feb 7 11:59:59.999...
Install J2SE SDK v1.4
Make program modifications
Turn in screen dump, code listing
Turn in modified state diagram
Answer questions to exercises
Submit package to cscie70 library account on FAS Unix system
Stop for Questions
29 Jan 2003
CSCI E-70 Lecture 1 / Bromberg
15 of 15