Transcript MCS231Week1

MCS 231: Concepts of Data Structure
Class Hour:
Section 1: MW 2:15PM - 3:30PM. Hyland 2306
Instructor contact information
[email protected]
(fastest way to contact me)
McGraw 106
Office Hours: 9:00am – 11:00am
MTW or by appointment
262 472 5170
Course Objectives
- Given a basic data structure (e.g. queue, stack, list), students
will be able to apply the theory to implement applications using
those data structures and analyze efficiency of each type.
- Given a complex data structure (trees, graph),students will be
able to design and implement it, apply theory, and compute its
efficiency.
- Given a large project that uses basic and complex data
structures, students will be able to implement it using advanced
Java techniques such as inheritance and polymorphism,
interfaces and abstract classes, and the use of classes from the
JAVA API.
Course Objectives
- Given a basic data structure (e.g. queue, stack, list), students
will be able to apply the theory to implement applications using
those data structures and analyze efficiency of each type.
- Given a complex data structure (trees, graph),students will be
able to design and implement it, apply theory, and compute its
efficiency.
- Given a large project that uses basic and complex data
structures, students will be able to implement it using advanced
Java techniques such as inheritance and polymorphism,
interfaces and abstract classes, and the use of classes from the
JAVA API.
Course Objectives
- Given a basic data structure (e.g. queue, stack, list), students
will be able to apply the theory to implement applications using
those data structures and analyze efficiency of each type.
- Given a complex data structure (trees, graph),students will be
able to design and implement it, apply theory, and compute its
efficiency.
- Given a large project that uses basic and complex data
structures, students will be able to implement it using advanced
Java techniques such as inheritance and polymorphism,
interfaces and abstract classes, and the use of classes from the
JAVA API.
Technology Requirement
• J2SE Software Development Kit (SDK): ):
http://java.sun.com/javase/downloads/index.j
sp (just download SDK 5.0 or later)
• Eclipse: http://www.eclipse.org/downloads/
Course detail - Evaluation
GRADABLE
POINTS
Labs
100
Mid term Exam
150
5 Projects
500
Final Exam
200
Quizzes
50
Total
1000
Grading (+/-)
Letter
Grade
Percentage
Letter
Grade
Percentage
A
94 to 100%
A-
90 to 93%
B+
87 to 89%
B
84 to 86%
B-
80 to 83%
C+
77 to 79%
C
74 to 76%
C-
70 to 73%
D+
67 to 69%
D
64 to 66%
D-
60 to 63%
F
Less than 60%
Quiz
• Quiz is used to measure:
- class attendance
- class preparation
• Not all material will be covered in a 75-minute class
– Book complements the lectures
Must-have for success
+
Reading textbook
=
+
Practicing (labs+projects)
Devote time)
Philosophy for teaching Data
Structure in this course
• Traditional way:
implementing everything + starting from beginning+
focusing on complexity analysis
• Modern way:
taking advantages of built-in methods from Java/C++
• Hybrid way:
taking advantages of built-in methods for simple data
structure + implement everything for complex data
structure + emphasize on complexity analysis
Philosophy for teaching Data
Structure in this course
• Traditional way:
implementing everything + starting from beginning+
focusing on complexity analysis
• Modern way:
taking advantages of built-in methods from Java/C++
• Hybrid way:
taking advantages of built-in methods for simple data
structure + implement everything for complex data
structure + emphasize on complexity analysis
Philosophy for teaching Data
Structure in this course
• Traditional way:
implementing everything + starting from beginning+
focusing on complexity analysis
• Modern way:
taking advantages of built-in methods from Java/C++
• Hybrid way:
taking advantages of built-in methods for simple
data structure + implement everything for
complex data structure + emphasize on
complexity analysis
Getting started…
Prerequisite:MCS 220
What do we still remember or know about
Java and Software life cycle activity?
Class Focus
Balance between theory and implementation
Strict deadlines, high standard,
ridiculous demands (always)
Assessment
Prerequisite:MCS 220
What do we still remember or know about
Java and Software life cycle activity?
Assessment
1.1 What does “UML” stand for?
a. Understanding Modern Language
b. Unified Modeling Language
c. Unified Modern Language
d. Understanding Modeling Language
Assessment
1.2 This task is not included in a software
development process.
a. Architectural, component, and detailed
designs
b. Implementation
c. Acceptable tests
d. Maintenance
e. Marketing
Assessment
1.3 Which of the following symbols can be
used in a UML class diagram to represent
access ability of a data member or a method
a.
b.
c.
d.
–
+
#
*
Assessment
1.5 What is the complexity of selection sort
a. O(n)
b. O(nlog2(n))
c. O(n2)
d. O(log2(n))
Assessment
2.1 Overriding a method differs from overloading a
method because:
a. For an overloaded constructor, the superclass
constructor will always be called first.
b. For an overridden constructor, the superclass
constructor will always be called first.
c. Overloaded methods have the same signature.
d. Overridden methods have the same signature
Assessment
2.2 Using the protected keyword gives a
member:
a.public access (any classes can access it).
b.package access (only classes in the same
inheritance hierarchy can access it).
c.private access (nobody can access it)
d.block scope (only the variables inside the
same block can access it).
Assessment
2.3 Suppose method1 is declared as
void method1 ( int a, float b )
Which of the following methods overloads method1?
a. void method2 ( int a, float b ).
b. void method2 ( float a, int b ).
c. void method1 ( float a, float b ).
d. void method1 ( int b, float a ).
Assessment
2.5. Variables should be declared as data members only
if
a. they are local variables.
b. they are used only within a method.
c. they are required for use in more than one method or
their values must be saved between calls to the
class’s methods.
d. they are arguments.
Java development
environment and Review of
Java
EclipseTM Intergrated Development
Environment (IDE)
• Running Eclipse:
Warning: Never check the “Use this as the default and do not ask again” box.
The importance of workspace
• This is where you will find all your java files.
• You can switch from one workspace to
another.
• You need to define the workspace first (where
you want to put your files) before click on OK
EclipseTM tutorial
Perspective is a set of
related Views (windows)
that enable a development
specialist to perform
specific tasks
Create an Eclipse project
From the Eclipse
menu bar select File,
New, Project to start
the “New Project”
wizard.
Select “Java Project”
and click “Next”.
Create an Eclipse project
Create a Java package
• Structure in dot format:
for example: com.tm.tutorial.main
Create Java classes
Create Application class under com.tm.tutorial.main package
Create Java classes
Create Application class under com.tm.tutorial.main package
Implementation of Java class
Implementation of Java class
Generating setters and getters for
attributes
Implementation of Java class
Generating constructors
Implementation of Java class
Generating constructors
Compile Java Application
Compile Java Application
Run the application
Run the application
Run the application
Run the application
Run Application (Shorter way)
Setting up preferences in Eclipse
If you did not download
the JDK earlier in this
tutorial, and your existing
JRE does not appear
in the “Installed JREs”
preference, you must
add it yourself.
Setting up preferences in Eclipse
Setting up preferences in Eclipse
Introduction to Software Design
The Software Challenge
• In industry, a software product is expected to be used
for an extended period of time by someone who did
not write the program and who is not intimately
familiar with its internal design
• Initial specification for a software product may be
incomplete
• Specification is clarified through extensive interaction
between users of the software and the system analyst
Chapter 1: Introduction to Software
Design
49
The Software challenge
• A requirements specification should be
generated at the beginning of any software
project
• Designers and users should both approve the
document
The Software Life Cycle
• Software Life Cycle: the sequence of stages
that software products go through as they
mature from initial concept to finished product
Chapter 1: Introduction to Software
Design
51
Software Life Cycle Models
• Waterfall model: simplest way of organizing
activities that transform software from one
stage to another
• Activities are performed in sequence and the
results of one flows into the next
• Waterfall model is simple but unworkable
– Fundamental flaw is assumption that each stage
can and must be completed before the next one
occurs
Chapter 1: Introduction to Software
Design
52
Waterfall Model
Chapter 1: Introduction to Software
Design
53
Waterfall Model (continued)
Chapter 1: Introduction to Software
Design
54
Software Life Cycle Models (continued)
• Unified Model: the cycles are called phases
and iterations and the activities are called
workflows
• Four phases
–
–
–
–
Inception
Elaboration
Construction
Transition
Chapter 1: Introduction to Software
Design
55
Software Life Cycle Models (continued)
Chapter 1: Introduction to Software
Design
56
Software Life Cycle Activities
(continued)
• Certain activities are essential for software
development
–
–
–
–
–
Requirements specification
Architectural, component, and detailed designs
Implementation
Unit, integration, and acceptance tests
Installation and maintenance
Chapter 1: Introduction to Software
Design
57
Software Life Cycle Activities
(continued)
• Requirements Specification
– System analyst works with software users to clarify
the detailed system requirements
– Questions include format of input data, desired
form of any output screens, and data validation
• Analysis
– Make sure you completely understand the problem
before starting the design or program a solution
– Evaluate different approaches to the design
Chapter 1: Introduction to Software
Design
58
Software Life Cycle Activities
(continued)
• Design
– Top-down approach: breaking a system into a set
of smaller subsystems
– Object-oriented approach: identification of a set of
objects and specification of their interactions
– UML diagrams are a design tool to illustrate the
interactions between
• Classes
• Classes and external entities
Chapter 1: Introduction to Software
Design
59
Software Life Cycle Activities
(continued)
Chapter 1: Introduction to Software
Design
60
Using Abstraction to Manage
Complexity
• An abstraction is a model of a physical entity or
activity
• Abstraction helps programmers deal with complex
issues in a piecemeal fashion
• Procedural abstraction: distinguish what is to be
achieved by a procedure from its implementation
• Data abstraction: specify the data objects for a
problem and the operations to be performed on them
without concern for their representation in memory
Chapter 1: Introduction to Software
Design
61
Using Abstraction to Manage
Complexity (continued)
• If a higher-level class references a data object
only through its methods, the higher-level
class will not have to be rewritten, even if the
data representation changes
• Information hiding: Concealing the details of a
class implementation from users of the class
Chapter 1: Introduction to Software
Design
62
Abstract Data Types
• A major goal of software engineering is to
write reusable code
• Abstract data type (ADT): The combination of
data together with its methods
Chapter 1: Introduction to Software
Design
63
Interface
• A Java interface is a way to specify an ADT
– The interface specifies the names, parameters, and
return values of the ADT methods without
specifying how the methods perform their
operations and without specifying how the data is
internally represented
• Each class that implements an interface must
provide the definitions of all methods declared
in the interface
Abstract Data Types, Interfaces
• You cannot instantiate an interface
• You can declare a variable that has an interface type
and use it to reference an actual object
• A Java interface is a contract between the interface
designer and the programmer who codes a class that
implements the interface
Chapter 1: Introduction to Software
Design
65
Pre-condition, Post-condition
• Precondition: a statement of any assumptions
or constraints on the method data before the
method begins execution
• Postcondition: a statement that describes the
result of executing a method
Requirements Analysis, Use Cases,
and Sequence Diagrams
• First step in analysis is to study the problem of input
and output requirements carefully to make sure they
are understood and make sense
• Use case: list of the user actions and system
responses for a particular sub-problem in the order
that they are likely to occur
• Sequence diagram: shows all the objects involved in
this use case across the horizontal axis, time is shown
along the vertical axis
Chapter 1: Introduction to Software
Design
67