Java Introductory Course Part 3 - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Java Introductory Course Part 3

Description:

Further appreciate the benefits of Java. Gain experience of some useful input / output methods, and some ... Great IDEs: Intellij Idea, NetBeans, Eclipse ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 12
Provided by: davel4
Category:

less

Transcript and Presenter's Notes

Title: Java Introductory Course Part 3


1
Java Introductory CoursePart 3
  • Using
  • And re-using Java!
  • (Once and Once Only Principle)
  • Programming to Interfaces
  • Simon M. Lucas

2
Session Objectives
  • Further appreciate the benefits of Java
  • Gain experience of some useful input / output
    methods, and some graphics classes
  • Perform some simple data processing
  • Learn to identify possible classes to simplify
    problem solutions and achieve greater re-use
  • Practice writing re-usable code

3
Why Java?
  • Nice language easy to read
  • E.g. keywords interface and extends
  • Platform independent
  • Easy to learn
  • Great IDEs Intellij Idea, NetBeans, Eclipse
  • Powerful API (class libraries) networking,
    graphics, threads, XML etc
  • Can be run in secure mode good for remote code
    (applets etc)
  • Tetris, SOFM

4
Typical Features of a Modern IDE
  • Allows easy re-factoring
  • Great to use
  • Short-cuts (e.g. psvm, sout)
  • navigate to definition of current word
  • Understand Java and JSP
  • Code completion
  • Method signatures
  • Speeds up learning Java immensely!
  • Auto code layout

5
Whats hard about programming?
  • Designing smart algorithms?
  • E.g. inventing quicksort if we didnt already
    have it
  • True but dont often need this
  • Great deal is about modelling and organisation
  • As we shall see
  • Other tough things multi-threaded, distributed,
    persistence, web-based

6
Program Structure
  • Monolithic to Multi-Class Re-usable

7
Exercise
  • A file contains measurements from instances of
    several different types of specimen
  • Each line consists of a specimen id followed by a
    number
  • Write a program to calculate the number of values
    recorded, the mean and the s.d. for each
    experiment
  • Print these statistics to standard output
  • Look for any classes that could be re-used in
    other applications

8
Sample DataLab Exercise
  • 0 182
  • 1 181
  • 1 190
  • 0 170
  • 0 175
  • (e.g. consider that 0Female, 1Male, and the
    second number on the line is the weight of that
    person in kilos)

9
Class Discussion
  • Working in small groups, discuss possible program
    designs to solve the above problem
  • Implement and test your design
  • Identify which parts of your program could be
    re-used in another application

10
Bar Chart Exercise
  • Consider the program (see lab) to draw a bar
    chart from an array of numbers
  • Suppose now you want to offer a plug and play
    interface, so that third party developers can
    provide their own bar styles
  • Design an interface for this, and provide a
    sample implementation (e.g. to draw faded or
    textured bars

11
Summary
  • I hope these introductory exercises have given
    you some idea about developing Java programs
  • Some advice
  • Keep each method simple
  • Programming to interfaces aids re-use
  • Keep classes tightly focussed more re-use
  • Use a good IDE
  • Enjoy!
Write a Comment
User Comments (0)
About PowerShow.com