程序代写案例-COMP1006/1406

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
Abstraction
COMP1006/1406
M. Jason Hinek
Abstraction
computers (and computer programming)
2
Abstraction
computers (and computer
programming)
2
Abstraction
computers (and computer programming)
2
Abstraction
computers (and computer programming)
have many layers
2
Abstraction
In software engineering and computer science, abstraction is
a technique for managing complexity of computer systems. It
works by establishing a level of complexity on which a person
interacts with the system, suppressing the more complex details
below the current level.
-wikipedia
Java

assembly language

machine language

hardware
3
Abstraction
In software engineering and computer science, abstraction is
a technique for managing complexity of computer systems. It
works by establishing a level of complexity on which a person
interacts with the system, suppressing the more complex details
below the current level.
-wikipedia
Java

assembly language

machine language

hardware
3
Abstraction
In software engineering and computer science, abstraction is
a technique for managing complexity of computer systems. It
works by establishing a level of complexity on which a person
interacts with the system, suppressing the more complex details
below the current level.
-wikipedia
Java

assembly language

machine language

hardware
3
Abstraction
In software engineering and computer science, abstraction is
a technique for managing complexity of computer systems. It
works by establishing a level of complexity on which a person
interacts with the system, suppressing the more complex details
below the current level.
-wikipedia
Java

assembly language

machine language

hardware
3
Abstraction
In software engineering and computer science, abstraction is
a technique for managing complexity of computer systems. It
works by establishing a level of complexity on which a person
interacts with the system, suppressing the more complex details
below the current level.
-wikipedia
Java

assembly language

machine language

hardware
3
Abstraction
One of the first computers, the ENIAC computer
4
Abstraction
The first actual computer programmers were mostly women
4
Abstraction
Early way of recording your program was using Punch Cards
4
Abstraction
Assembly language introduced short ‘words’ for operations and memory
locations
First assembly language developed in 1947 by Kathleen Booth
4
Abstraction
High level languages look more like human language than machine
language
Grace Hopper developed the first compiler in 1952
(converting human words into machine code)
4
Abstraction
A first step in abstraction for us in COMP1405/1005 was the use of
variables.
Recall that a variable is a name that maps to a memory location in our
programs. Without variables, we would have to manually place data into
memory locations and remember what data was placed where. If you are
programming in machine language or assembly, you still need to do this.
A well named variable makes our programs easier to read, write and
debug. It takes away the burden of managing our data at such a low level.
5
Abstraction
A next step in abstraction for us is the notion of a procedure (which has
many different names)
· procedure
· function
· method
· subroutine
A procedure is a sequence of instructions (statements) that performs a
specific task.
Math.sin(0.172) computes the sine of 0.172 radians. We don’t really
care how it does it, we just care that it gives us the right value.
System.out.println("hi") prints the characters h and i to the screen.
How does this actually happen? Do we care how it happens?
6
Abstraction
A next step in abstraction for us is the notion of a procedure (which has
many different names)
· procedure
· function
· method
· subroutine
A procedure is a sequence of instructions (statements) that performs a
specific task.
Math.sin(0.172) computes the sine of 0.172 radians. We don’t really
care how it does it, we just care that it gives us the right value.
System.out.println("hi") prints the characters h and i to the screen.
How does this actually happen? Do we care how it happens?
6
Procedural programming
In COMP 1005/1405, you practised procedural programming. It is a
form of structured programming that helps make programming
(writing/reading/modifying code) easier for humans.
· program is a sequence of procedure (function) calls
· code that does one thing is grouped into a procedure
· helps us achieve modularization
· code that is repeated during the execution of the program is put in a
procedure
· lets us write less code (less testing and maintenance!)
· helps us write structured programs
· this helps us write better programs (Software Engineering)
We can write procedural programs in Java.
7
Procedural programming
public class MenuDrivenProgram{
public static void main(String[] args){
boolean programRunning = true;
String input = "";
while (programRunning){
displayMenu();
input = getUserInput();
programRunning = processInput(input);
}
}
}
Procedures (functions)
· should have meaningful names
(intention of function should be clear from name)
· should do one thing (and do it well)
· typically do not contain a lot of code
8
Procedural programming
In Java, procedural programming might involve writing and using a
collection of static functions
You will most likely still use objects when writing code in this style in
Java. Otherwise, we could only use primitive data types which may be
limiting.
In Particular,
· arrays are objects
· strings are objects
· many useful functions belong to objects of a given class (like println)
9
Abstraction
We will see other forms abstraction in this course.
· classes/objects
· inheritance
· polymorphism
10

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468