Sunteți pe pagina 1din 37

TCC 101 COMPUTING 1

Course Overview
Semester October 2006
Course Coordinator:
Dr. Wendy Bong Chin-Wei
Course organisation

 Intro to Computer Concepts and Java Programming


 Problem solving through objects
 Classes and objects
 Control structures
 Advance Control Structures and Arrays
Overall Assessment

Type Marks Due Date


TMA 1 10% Tutorial 2 (25 Feb)
TMA 2 20% Tutorial 3 (25 Mar)
TMA 3 20% Tutorial 4 (22 Apr)
Final Examination 50% After week 19
100%
Self-Study

 Six to seven hours per week


– Averagely one hour a day
 Suggested weekly reading and corresponding
assignments
– Please follow strictly the Course Guide, Table 1.0
What to do when you have problems?

 Contact your tutor immediately.


 Do not delay in seeking help
– if you straighten out a problem when you first identify it as a
problem, you’ll be able to understand the work that comes later.
 It’s rather like getting back on the right path after
making a wrong turn.
– The longer you delay, the harder it is to get back
 Your tutor is there to help you to learn and to avoid
frustrations in your learning.
TCC 101 COMPUTING 1

Tutorial 1
Semester October 2006
Course Coordinator:
Dr. Wendy Bong Chin-Wei
Why Java as ‘first’ course?

 At the cutting edge of programming


 To support your learning of computer
fundamentals
 There is no ‘one correct way’ to program.
 Must follow rules and programming
conventions (practices)
Programming is fun

 It can be challenging at times.


 Great sense of satisfaction once their programs do
exactly what they want them to do.
 Learning how to program is challenging too, but it
can also be fun.
 Keep your tasks simple at first, learn the concepts
one by one, learn and to apply the rules and
conventions, and then finally, be creative.
 There’s no one correct way to program solutions.
Manual
solutions
Real-world problems versus
computer
solutions
 preparing a meal for your family
 preparing writing a letter
 calculating the a balance sheet for your
monthly income and expenditure balance
sheet
 maintaining a pile set of name cards.
Computer Solutions

 Accuracy
 Speed
 Availability
and convergence
 Automation
Algorithms

 In order to obtain the necessary result, a


well-defined formula or sequence of steps is
applied to the data
 All computer algorithms must be formed from
three basic constructs: Sequence,
Selection, Iteration
A sequence

A series of statements Get cup

executed in order,
passing and the control Get milk

passes unconditionally
from one statement to Get tea bag

the next
Boil water

......
A selection

A choice of Wake up

statements depending
on the result of a test
True False
or condition Weekday?

Sleep in Go to work
An iteration

A series of statements Start trip

repeated while a condition Keep


driving
is true. The condition is
evaluated each time the Are we there
False

series is completed yet?

True

Stop car
Number systems

 Computers use the binary number system, a number


system with on or off , that is 0 and 1 digits only
 Binary numbers are also used to represent
alphanumeric data such as the letters ‘A’, binary
numbers are also used.
 The letter ‘A’ is represented by the binary number
01000001 in the ASCII (American Standard Code for
Information Interchange) system. This code is used in
our PC-compatible machines and many other
computers
Decimal vs Binary Number System

 Decimal Number System


123410 = 1×103 + 2×102 + 3×101 + 4×100
= 1000 + 200 + 30 + 4
= 1234

 Binary Number System


10112 = 1×23 + 0×22 + 1×21 + 1×20
=8+0+2+1
= 11
Software
Programming languages

 Low level programming languages


– Machine languages
– Assembly languages
 High-level programming languages
Comparisons

Low-level programming High-level programming language


language
Speed Faster because the Slower because the computer needs to translate the
programmer can make high-level language to machine language for
use of the registers execution, but the machine code generated may
directly and avoid not be optimal.
redundant operations.
Portability Not portable between Portable between different computers with
different CPUs. different CPUs with no or minor modifications.
Readability Difficult to read and modify. Much easier to learn, write and modify.

Selectivity None,as each machine A computer can execute programs written in any
supports its own high-level programming language, provided
machine language. that a translation software is available.
How programs are executed

 Interpretation
– interprets (analyses) each statement in the program and then
carries out the operations one after another
 Compilation
– process of entirely translating a program written in a high-level
programming language into the corresponding machine
language before execution
– The software that compiles a program is called compiler
software (or simply a compiler).
– The result of compilation is known as object code, which is
composed of 0’s and 1’s.
– The machine only executes the object code.
Interpretation vs. Compilation
Interpretation Compilation
Execution Slower, as every statement is analysed Faster, as object code is generated once
speed each time before execution. and for all. No translation during
execution.
Execution Needs source code for real-time Source code is not necessary — just
model translation. object code.
Portability Needs an interpreter on every platform. Needs compilation once for each
platform.
Reliability Usually less reliable, as checking is done More reliable, because compilation
during interpretation. Program usually includes comprehensive
segments that have not been executed checking for the whole program.
will also be unchecked.
Intellectual Weak protection, since users can read Strong protection, since users find it
property and modify the source code. difficult to derive the program logic
or modify it.
Software development life cycle (SDLC)

 Software applications (huge program) are


getting more and more complicated and often
also involve increasing numbers of
programmers
 SDLC – A series of well-defined steps are
needed to handle and manage the
development
– help the programmer better understand the
activities in building complex software applications
Common SDLC flow and iterations

Requirement Analysis Design Implementation Testing Maintenance


Phase Phase Phase Phase Phase Phase

Requirement Analysis Design Implementation Testing


Phase Phase Phase Phase Phase

Requirement Analysis Design Implementation Testing


Phase Phase Phase Phase Phase

Maintenance
Highly sophisticated software is generally too complex Phase
to build with a single pass of the above six phases
SDLC

 Requirements phase
– thoroughly understand the purpose of the software, or the
‘problem’ to be solved by the software
– collect the requirements (needs) from the users
– a document known as a problem statement that summarises
the requirements of the clients, and the limitations of the
software
 Analysis phase
– derive the roles, functionalities, operational scenarios, and the
business entities involved
 Both are programming-language independent phases
SDLC cont’

 Specific approach such as object-oriented approach


may take place
 Design phase
– Identify objects and attributes of the objects
– Identify a class, blueprint that defines the states and the
behaviours common to all objects of a certain kind
 Implementation phase
– convert the class designs derived in the design phase to
actual class definitions in the chosen programming
language
SDLC cont’

 Testing phase
– make sure that the programs actually perform as
expected
– verify the programs by feeding test data and
checking whether the outputs are exactly the
same as the expected results
 Maintenance phase
– maintain the software system so that users can
keep continue to use and to rely on it.
Programming paradigm

 programming style
 provides (and determines) the view that the
programmer has of the execution of the
program.
 some languages are designed to support one
particular paradigm while other programming
languages support multiple paradigms
Programming paradigm 1
- Imperative programming language

 procedural programming language


 manipulates data in a step-by-step way
 most early high-level programming languages
 Pitfalls of the imperative programming
– has to specify ‘what’ problem to solve and ‘how’ to
solve it.
– little support for large system and in a team
development
– mostly problem specific
Programming paradigm 2
- Object-oriented programming & Java

 Data & operations within single entity called an


object
 Organises programs in a way that mirrors real
world
 Java
– a hybrid language involving both the object-oriented
and imperative feature
– involves thinking in terms of objects
– Java program is a collection of co-operating objects.
What are objects?

 An object represents an entity that can be


distinctly identified – a student, a desk, a circle, a
button, etc. can all be identified as objects if
relevant to the problem to be solved.
 An object has unique identity, state &
behaviours.
 The behaviour of an object is defined by a set of
methods.
Object = attributes (states or data) + behaviour (methods or
functions)
An object A Circle object
data field 1 Data Field
State radius = 5
...
data field n Method
findArea
method 1
... Behavior

method n
Classes and Objects

 Classes are constructs that define objects of the


same type.
 The class for an object comprises a collection of
data & method definitions.
 A class is a blueprint that defines what an object’s
data & methods will be.
 An object is an instance of a class. Creating an
instance is referred to as instantiation.
 There can be many instances of a class .
 The terms object & instance are interchangeable
Class and Objects (cont’)
Circle UML Graphical notation for classes

radius: double UML Graphical notation for fields

UML Graphical notation for methods


findArea(): double

new Circle() new Circle()

circle1: Circle circlen: Circle UML Graphical notation


for objects
radius = 2 ... radius = 5

A class can have many different objects /


instances
Have you achieve these for Tutorial 1?

 Discuss the problems that can be solved using


computers.
 Describe the basic components of a computer and the
relationship between hardware and software.
 Explore the programming languages and it’s method of
executions.
 Describe the Java program development and execution
model and demonstrate how to Install and use the Java
Software Development Kit
 Explain the software development cycle
 Describe what is an object and its properties.
 Describe classes and objects and relationship between
them
Self-study guide for Week 2, 3, and 4

 Read Study material


– from Unit 1 (whole units) to Unit 2 (section 1 to
section 3)
 Complete TMA 1 for submission in Tutorial 2
 Visit WawasanLearn at least 3 times a week
– start a forum discussion (make yourself known to
the Tutor and other classmates for group study)
– download additional material for extra reference
– online Quiz for self assessment

S-ar putea să vă placă și