CS160 Exploring Computer Science - PowerPoint PPT Presentation

1 / 54
About This Presentation
Title:

CS160 Exploring Computer Science

Description:

If all you have is a hammer, then everything looks like a nail. Language Generations ... Semi-colons are typically used to indicate end of each statement ... – PowerPoint PPT presentation

Number of Views:119
Avg rating:3.0/5.0
Slides: 55
Provided by: Preu
Category:

less

Transcript and Presenter's Notes

Title: CS160 Exploring Computer Science


1
CS160 Exploring Computer Science
Review of Chapters 5, 6 7
  • I think there is a world market for maybe five
    computers.
  • --- T.J. Watson, IBM Chairman, 1943

2
Chapter 5 Programming Languages
  • Language generations evolution
  • The four programming paradigms
  • Traditional programming concepts
  • Procedural Units
  • Program Translation

3
Programming Language Toolset
C
If all you have is a hammer, then everything
looks like a nail.
4
Language Generations
Five Generations Procedural Languages 1GL
Machine language 2GL Assembly language 3GL
High-level language Nonprocedural Languages 4GL
Very high-level language 5GL Natural language
  • Low levels closer to binary format
  • High levels - closer to human language

5
Machine Language
  • Written in strings of 0 and 1
  • Only language the computer understands
  • All other programming languages are translated to
    machine language
  • Computer dependent
  • Recall that CISC instructions wont work for a
    RISC architecture

6
Assembly Language
  • Uses Mnemonic codes
  • Assigns Names for memory locations
  • Depends on the Computer
  • Needs an Assembler to translates from Assembly to
    machine language so the machine can execute the
    program

7
High Level Languages 3GL
  • Identify a collection of high-level primitives
  • e.g. loops and selection constructs
  • Think and express concepts at a higher level of
    abstraction than machine language
  • Implement translation of such high-level
    primitives into machine language using an
    intermediary (Compilers)

8
High Level Languages 3GL
  • High level languages were invented to
  • break away from machine-dependence
  • allow the expression of abstract concepts
  • Compilers and interpreters are software tools
    that translate high-level source code (text) into
    machine language (binary)

9
Programming Paradigms
  • Procedural (Imperative)
  • Cobol, Fortran, C, Pascal
  • Focused at expressing an algorithm
  • Declarative
  • Prolog, SQL
  • Focused at expressing the solution to a problem
  • Functional
  • Scheme, Lisp, ML
  • Focused at identifying functional components
  • Object-Oriented
  • Smalltalk, C, Java
  • Programs are sets of cooperating components that
    contain both data and operations

10
Evolution of Programming Paradigm
11
Traditional Programming Concepts (TPC)
  • Variables and Data Types
  • Describe data and data format
  • Data Structures
  • Complex data types
  • Constants and Literals
  • Using a value directly
  • Assignment Statements
  • Assign values to variables
  • Assign result of an evaluation to a variable
  • Control Statements
  • Selection
  • Loop

12
Procedural Units
  • Procedure is an abstract modular tool that can be
    used by several different program units.
  • A Procedure needs to be defined first, and then
    invoked via procedure call wherever needed
  • Control transfers from current statement in the
    program unit to the procedure unit by means of a
    JUMP control at the time of procedure call
  • Control is returned to the original program unit
    once the procedure unit has finished executing
  • Procedures have their own set of local variables
  • Values from one program unit to another procedure
    unit can be passed via parameters declared for
    that procedure unit
  • Reading Chapter 5 Section 5.3

13
Procedural Units Control transfer
14
Procedures vs. Functions
  • Function is similar to Procedure except that a
    value is transferred back to the calling program
    as the value of the function
  • Procedures do not pass back a return value and
    preserve the calling environment
  • Functions pass back a return value that can be
    used by the calling program whenever needed

15
Grammar
  • Every language has a distinct grammar, which is a
    set of rules for creating expressions in the
    language
  • (define (sum n m) ( n m)) in Scheme
  • x n m in C
  • The syntax of a language consists of the grammar
    combined with an alphabet
  • Most languages use the normal alphabet, e.g.
    Scheme
  • Some languages use special symbols, e.g. APL

16
Program Translation
  • The steps completed by a compiler are
  • Lexical Analysis identify the individual tokens
    in the language statements reading symbol by
    symbol
  • Syntax and Semantics Analysis (a.k.a Parsing)
    Build a parse tree by reading the tokens analyzed
    by Lexical analyzer and Identify the intent of
    the program statements
  • Code Generation Produce machine language
    instructions

17
Program Translation Process
18
Program Translation Parsing
  • Early parsers required fixed-format for source
    code
  • Modern 3GL are free-format languages
  • Example
  • If cost lt cashOnHand pay cash else use
    credit card
  • is understood by the modern parsers correctly,
    but, makes it harder to read for humans, so, we
    write it as
  • If (cost lt cashOnHand)
  • pay cash
  • Else
  • use credit card
  • Semi-colons are typically used to indicate end of
    each statement
  • Key words are defined which cannot be used in
    programs to represent anything other than what
    they are defined for

19
Choosing a Language
  • Choose based on
  • What is available
  • Required interface
  • What do you know best?
  • More importantly Which language lends itself to
    the problem to be solved?

20
4GLVery High-Level Languages
  • Programmer specifies the desired results the
    language develops the solution
  • Many times more productive with a 4GL than a
    procedural language
  • Query Languages
  • Retrieve information from databases
  • Easy to learn and use

21
5GL Natural Languages
  • Resemble natural or spoken English
  • Translates human instructions into code the
    computer can execute

22
OOP Object-Oriented Programming
  • Object
  • Self-contained unit of data and instructions
  • Includes
  • Related facts (data)
  • Related functions (instructions to act on that
    data)
  • Example
  • Object cat
  • Data feet, nose, fur, tail
  • Functions eat, purr, scratch, walk
  • Cat Kitty, Susan

23
Summary
  • All programs must be translated into machine
    language in order to run
  • There are four identifiable programming
    paradigms, each with its own special features
  • High level languages provide machine independence
    and better productivity for developers and need
    some intermediary like compliers to translate to
    machine language
  • Languages are specified using grammars. This
    allows compilers to translate the programs
    unambiguously by creating appropriate parse trees
  • Traditional programming concepts include
  • Variables, Data Types, Data Structures
  • Assignment Statements
  • Control Statements like Selection and Repetition

24
Chapter 6 Software Engineering
  • Software Engineering (SE) has unique features
  • SE is a non-traditional discipline
  • SE should be
  • Measurable, predictable, repeatable
  • The System Development Life Cycle (SDLC)
  • Waterfall Model
  • Incremental Development Model
  • Program verification and validation
  • Testing and debugging techniques

25
Software Engineering is non-traditional
  • Software Engineering lacks the scientific
    foundation found in traditional engineering
  • Traditional engineering is based on scientific
    laws of physics, chemistry, and other fields
  • Software engineering has no such corresponding
    fundamental science

26
Software Engineering Studies
  • Practicum
  • Some software engineers focus their efforts on
    developing methodologies that can help
    contemporary computer professionals
  • Theory
  • Some software engineers focus their efforts on
    finding underlying principles upon which future
    methodologies can based

27
SDLC
  • Software Development Life Cycle
  • The details of the process used to develop
    software, e.g. a subset of the SLC
  • Often consists of these steps
  • Analysis (problem definition and solution
    statement)
  • Design (algorithm development)
  • Implementation (creating a program)
  • Testing (making sure the program works)

28
Development ApproachWater-Fall Model (Old)
Analysis
Design
Implement
Test
  • Requires that each stage be entirely complete
    before beginning next stage.

29
Traditional SDLC Analysis
  • Analysis
  • Identify the needs of the user
  • Interviews or market analysis
  • Establish functional specifications
  • What is the input data?
  • What is the required output?
  • What are the performance requirements?
  • Analysis focuses on what needs to happen and sets
    the goals of the system

30
Defining Diagram Table
  • A table that describes the basic operations of
    your program
  • Processing details are not shown
  • These are documentation and thinking tools for
    humans, not precise specifications

31
Traditional SDLC Design
  • Design
  • What steps are required to produce the output
    from the specified input?
  • What are the algorithms that will be used?
  • How will the process be broken down into smaller
    steps?
  • Design focuses on how the system will accomplish
    the specified goals and on the structure of the
    system

32
Modularization
  • Jargon for dividing a large program into smaller,
    more manageable pieces called routines,
    functions, procedures, and many other names
  • Requires understanding how to break a large task
    into smaller tasks

33
Structure Charts
  • A structure chart is a graphical way of
    representing a functional design
  • The chart shows the structure or hierarchy of
    your program, i.e. which functions call which
    other functions
  • All functions in the program are listed

34
Structure Charts
  • Design process is top-down
  • Processes on the upper levels call lower level
    processes never the other way around
  • Good function names often will be a verb followed
    by a noun
  • Get_Input
  • Calculate_Invoice

35
Coupling Control and Data
  • Links and dependencies between modules
  • Control coupling
  • when one module passes control to another
  • Examples function call, return
  • Data coupling
  • sharing of data between modules.
  • Examples function parameters, return values

36
Object Oriented Approach
  • Minimizing Data Coupling is inherent in OO
    approach
  • Collect routines, methods that manipulate a
    particular data item into a single module viz.,
    the object
  • Inter module coupling then becomes inter object
    communication, implemented via control coupling

37
Cohesion
  • Internal binding within function, i.e. degree of
    relatedness of a modules internal parts.
  • Logical cohesion
  • Internal elements perform activities that are
    logically similar. (E.g.. I/O function)
  • Functional cohesion
  • all parts or elements are geared towards the same
    single activity
  • Aim high intra-module cohesion

38
Golden Rule 1
Design Top-Down, but always build Bottom-Up.
  • Code and test the simplest components first.
  • Test each component before using them to make
    sure they work
  • Then use those components to build more complex
    components.

39
Golden Rule 2
Modules in a well-structured program are highly
cohesive and loosely coupled.
  • The size of the data coupling corresponds roughly
    to the level of the module in the hierarchy.

40
Dataflow Diagrams (DFD)
  • Pictorial representation of data paths
  • origin (source)
  • destination (sink, storage)
  • processing points (location of data manipulation,
    modules)

41
Dataflow diagrams (DFD)
  • Emphasize the data (information) to flow through
    system.
  • (rather than procedures to be executed)
  • By following data paths, discover where data
    units are merged, split, or altered.

42
Traditional SDLC Implementation
  • Implementation
  • Implementation consists creating programs to run
    in a specific computer environment
  • Programming language
  • Operating system
  • Hardware components
  • Users

43
Traditional SDLC Testing
  • Testing
  • Testing is done to ensure that the results is
    what is needed
  • Verification testing is done to ensure that the
    program adheres to the functional specifications
  • Validation testing is done to ensure that the
    functional specifications meet the needs of the
    user

44
Testing
  • Glass Box testing techniques utilize a knowledge
    of program structure and design to identify
    specific conditions to be tested
  • Black Box testing techniques focus on input and
    output, and ignore the internal details of how
    the program functions

45
Documentation
  • System Documentation explains the internal
    technical details of how the software is
    implemented so that it can be maintained later in
    its life cycle
  • User Documentation explains the features of the
    software from a user perspective to serve as a
    manual for the non-technical user.

46
Non-Traditional SDLC
  • Several attempts have been made to address
    problems perceived with the traditional system
    development processes
  • Incremental Development
  • Rapid Prototyping
  • Computer-Aided Software Engineering

47
Incremental Development Model
Analysis
Design
Implement
Test
  • Increments from simplified version with limited
    functionality to complete system.
  • At each stage prototype.

48
Summary
  • Modularity is crucial for developing large
    software projects
  • Structure charts and dataflow diagrams are useful
    design tools
  • Design top-down, but build bottom-up
  • Build incrementally with prototypes
  • Well-structured programs are highly cohesive, and
    loosely coupled.

49
Chapter 7 Data Structures
  • What is ADT?
  • Why introduce data structures?
  • What is a pointer?
  • The common data structures are
  • Arrays
  • Linked Lists
  • Queues
  • Stacks
  • Trees

50
Data Structures and Programming
  • Data structures is concerned with the
    representation and manipulation of data
  • All programs manipulate data
  • So, all programs represent data in some way
  • Data manipulation requires an algorithm
  • Algorithm design methods are needed to develop
    programs that do the data manipulation
  • The study of data structures and algorithms is
    fundamental to Computer Science

51
ADT Abstract Data Types
  • Memory cells are the basic storage units
  • Memory cells can be conceptually organized into
    clusters with specific forms and shapes that we
    as programmers find easier to handle
  • Example Instead of giving your scores for the
    course as a string of numbers in the grade book,
    it is organized into a table with headers and
    cell entries for readability
  • ADT is a mathematical model with a collection of
    operation defined on that model

52
Static vs. Dynamic Data
  • The shape or size or volume of data can be fixed
    (static) or can change (dynamic) over time
  • Example Registrars Student list at PCC is a
    dynamic data type as students can add/drop
    courses as well as, the number of students
    enrolling is not a fixed quantity at any given
    time.
  • We must define data types that should allow for
    such flexibility

53
What is a Data Structure?
  • A data structure is a set of variables,
    constants, and literals that are organized in a
    particular manner for ease of use and
    manipulation
  • Some forms of organization are very common, and
    have specific names, e.g.
  • Arrays
  • Lists
  • Queues
  • Stacks
  • Trees

54
Summary
  • Data can be organized in a variety of ways that
    support the development of algorithms arrays,
    linked lists, stacks, queues and trees
  • Data structures are ultimately laid out in linear
    memory cells
  • Pointers are a useful technique for creating data
    structures that do not require contiguous memory
Write a Comment
User Comments (0)
About PowerShow.com