Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

CMP4266 Computer Programming

Lecture - 1

CMP4266 , School of CS & DT, Birmingham City University.


Why Learn to Program?

 Programming is nearly in every aspect of our daily lives e.g.


cars, health, buildings, networking etc...
 We all need to get better at coding!
– Helps you talk to actual programmers.
– Flexible tool to do anything
– A big plus in you CV, and will help you to work with different fields.
– Programming has high paying average and has a growing market
demand

CMP4266 , School of CS & DT, Birmingham City University.


Why Python?

The 2018 Top Programming Languages – IEEE Spectrum

CMP4266 , School of CS & DT, Birmingham City University.


Outline

 Overview of the Module CMP4266

 Software Development Process

 Introduction to Computer Programming and Python

CMP4266 , School of CS & DT, Birmingham City University.


Overview of the Module - Teaching Team

 Module leader – Dr. Shadi Basurra

 Tutors
 Mr. Richard Kay - Email: richard.kay@bcu.ac.uk
 Dr. Andrew Stokes - Email: andrew.stokes@bcu.ac.uk
 Mr. Stish Sarna - Email: Stish.Sarna@bcu.ac.uk
 Mr. Besher Alhalabi - Email: Besher.Alhalabi@mail.bcu.ac.uk
 Dr. Martyn Ratcliffe - Email: Martyn.Ratcliffe@bcu.ac.uk
 Dr. Khaled Mahbub - Email: Khaled.Mahbub@bcu.ac.uk
 Dr. Shadi Basurra - Email: Shadi.Basurra@bcu.ac.uk

 Demonstrators:
– To help you out with your programming tasks and programming assessments

CMP4266 , School of CS & DT, Birmingham City University.


Overview of the Module - Organisation
 Lectures:
 Wk1 – Wk12
 1 lecture per week (2 hour each lecture), discussion of the topics in
abstract levels + providing hands-on working examples

 Lab Sessions:
 Wk1 – Wk12
 1 lab session per week (2 hours each session), teacher supported
practical and assignment works.
 Completed lab work should be submitted weekly on Moodle. The labs
will be assessed through the 48 hours coding challenge.

 Self Study: all weeks, 4-5 hours/week/20 credit module is assumed.

CMP4266 , School of CS & DT, Birmingham City University.


Optional - support by BCU Centre for Academic Success

 Session 1: Tuesdays 1-2 pm C260- Curzon


 Session 2: Wednesday 10-11am C423 - Curzon
 Session 3: Thursday 9-10 am MP402 Millennium Point

CMP4266 , School of CS & DT, Birmingham City University.


Overview of the Module - Module Contents
 Introduction to software development lifecycle

 Introduction to computer programming


– Python 3.6 using Spyder IDE (An integrated development
environment (IDE) )

 Covering different activities of software development process including


– Design
– Testing
– Debugging
– Simple Algorithms

CMP4266 , School of CS & DT, Birmingham City University.


Overview of the Module – Logbook for Lab Sessions

 You are advised to keep a logbook for formative and regular self
assessment purpose.

 We recommend that the logbook is a paper based (bound notebook), on


which you can get staff feedback.

 You should regularly review and update your logbook based on your lab
works.

CMP4266 , School of CS & DT, Birmingham City University.


Assessment – Development of a Banking System

 The assessment comprises of three Components.

• For Comp1 (15%) - Moodle quiz will take place on the


week commencing 28 October 2019

• For Comp2 (15%) - 48 hours coding challenge to


complete on Moodle. This will take place on the week
commencing 11 November 2019

• For Comp3 (70%) - Computer programme, design,


solution and testing. Hand in is on 12pm Mid-day 15
January 2020

CMP4266 , School of CS & DT, Birmingham City University.


Overview of the Module - Communication

 Contact your /tutors using the following media (preferred order)


– Lab Sessions
– Moodle Discussion Forum
– Email
– Personal Contact (appointments by email)
– Possible drop-in session (if situation demands, will be announced later)

CMP4266 , School of CS & DT, Birmingham City University.


Overview of the Module – Textbooks and Resources

 Tony Gaddis, “Starting Out with Python”, 3/E, Pearson Education

 Computing Labs equipped with Python, Spyder IDE and Tkinter.

 Official documentation from Python website, i.e.


https://www.python.org/doc/

 Official documentation from Tkinter package , i.e.


https://docs.python.org/2/library/tkinter.html

 Moodle

CMP4266 , School of CS & DT, Birmingham City University.


Software Development Process

(Based on: Ian Sommerville, “Software Engineering" 9/E, Addison-Wesley)

CMP4266 , School of CS & DT, Birmingham City University.


Software Development Process

 A structured set of activities required to develop a software system.

Design &
Specification Validation Evolution
Implementation

 The major activities involved in a software development process are:


o Specification – defining what the system should do;

o Design and implementation – defining the organization of the system and


implementing the system;

o Validation – checking that it does what the customer wants;

o Evolution – changing the system in response to changing customer needs.

CMP4266 , School of CS & DT, Birmingham City University.


Software Specification

 The process of establishing what services are required and the constraints
on the system’s operation and development.

Design &
Specification Validation Evolution
Implementation

 Major steps in software specification are:


– Feasibility study
- Is it technically and financially feasible to build the system?
– Requirements elicitation and analysis
- What do the system stakeholders require or expect from the system?
– Requirements specification
- Defining the requirements in detail
– Requirements validation
- Checking the validity of the requirements

CMP4266 , School of CS & DT, Birmingham City University.


Software Design and Implementation

 Software design and implementation is the stage in the


software engineering process at which an executable software
system is developed.

Design &
Specification Validation Evolution
Implementation

 Software design and implementation activities are invariably


inter-leaved.
– Software design is a creative activity in which you identify software
components and their relationships, based on a customer’s
requirements.
– Implementation is the process of realizing the design as a program.

CMP4266 , School of CS & DT, Birmingham City University.


Use case diagram

 Simplest representation of user’s interaction with a system.


 High level methodology to identify, clarify and organise system
requirements.
 A use case diagram contains four components:
– The boundary, which defines the system of interest in relation to the
world around it
– The actors, usually individuals involved with the system defined
according to their roles.
– The use cases, which are the specific roles played by the actors within
and around the system. g to their roles.
– The relationships between and among the actors and the use cases.

CMP4266 , School of CS & DT, Birmingham City University.


Use case diagram - Example

 The following is an example of airline reservation system. A


ticket clerk can check in passenger, add reservation and
cancel flight reservation.

CMP4266 , School of CS & DT, Birmingham City University.


Use case diagram – 1.1 Exercise:
In-class
 You are required to develop an employee management system. Exercise

 As part of the design process, you need to draw a user case diagram for
the system.
 In this system a HR officer can create and update employee records.
However, HR manager should verify and accept the data/changes provided
by the HR officer before it is stored into the system.
 Payroll manager should be able to print employee pay slip, process
employee salary payment and produce HR management reports. HR
management reports should be checked/viewed monthly by the HR
manager.
 From the above system requirements:
– Name of the boundary
– What are the actors?
– What are the use cases?
– Identify the relationships between actors and use cases?
CMP4266 , School of CS & DT, Birmingham City University.
Major Design Activities

Design &
Specification Validation Evolution
Implementation

 Architectural design, where you identify the overall structure of the system,
the principal components (sometimes called sub-systems or modules), their
relationships and how they are distributed.
 Interface design, where you define the interfaces between system
components, and between the system and users (Known as GUI)!
 Component design, where you take each system component and design
how it will operate.
 Database design, where you design the system data structures and how
these are to be represented in a database.

CMP4266 , School of CS & DT, Birmingham City University.


Class Diagram for a University System

CMP4266 , School of CS & DT, Birmingham City University.


Example: Architectural design for ATM

CMP4266 , School of CS & DT, Birmingham City University.


Software Validation

Design &
Specification Validation Evolution
Implementation

 Verification and validation (V & V) is intended to show that a system


conforms to its specification and meets the requirements of the system
customer.
 System testing involves executing the system with test cases that are
derived from the specification of the real data to be processed by the
system.
 Testing establishes the existence of defects in the implementation.
 Debugging is the process of fixing errors and problems that have been
discovered by testing.
 Programmers (debuggers) use their knowledge of the programming
language and the intended outcome of the test to locate and repair the
program error.
CMP4266 , School of CS & DT, Birmingham City University.
Software Validation

 Testing stages
– Development or component testing
- Individual components are tested independently;
- Components may be functions or objects or coherent groupings of
these entities.
– System testing
- Testing of the system as a whole. Components that have been
separately developed and off-the-shelf systems may be integrated
with newly developed components. The complete system is then
tested.
– Acceptance testing
- Customers test a system to decide whether or not it is ready to be
accepted from the system developers and deployed in the customer
environment. Primarily for custom systems.

CMP4266 , School of CS & DT, Birmingham City University.


Software Evolution (Maintenance)

Design &
Specification Validation Evolution
Implementation

 Software is inherently flexible and can change.

 As requirements change through changing business circumstances, the


software that supports the business must also evolve and change.

– New requirements emerge when the software is used;


– The business environment changes;
– Errors must be repaired;
– New computers and equipment is added to the system;
– The performance or reliability of the system may have to be improved.

CMP4266 , School of CS & DT, Birmingham City University.


Introduction to Computer Program and Python

(Based on: Tony Gaddis, “Starting Out with Python”, 3/E, Pearson Education)

CMP4266 , School of CS & DT, Birmingham City University.


Execution of Computer Program

 Program: set of instructions that a computer follows to perform a task.


(commonly referred to as Software)

 The part of the computer that actually runs programs is known as Central
processing unit (CPU).

 Main memory, Known as Random Access Memory or RAM, where


computer stores a program while program is running, and data used by the
program.

 CPU is able to quickly access data in RAM

CMP4266 , School of CS & DT, Birmingham City University.


Machine Language and Assembly Language

 All data in a computer is stored in sequences of 0s and 1s. i.e. all the
instructions used in a program should be supplied to CPU in a
representation using only 0 and 1, which CPU can interpret and execute.
This representation is known as machine language.
– Example: 10110000 this is an instruction for an Intel microprocessor. It tells the
microprocessor to move a value into the CPU.
 Impractical for people to write in machine language

 Assembly language: uses short words (mnemonics) for instructions instead


of binary numbers. Easier for programmers to work with
– Example mnemonics : add, mul, mov etc.
- add ax, bx
 Assembler: translates assembly language to machine language for
execution by CPU

CMP4266 , School of CS & DT, Birmingham City University.


High Level Programming Languages
 Low-level language: close in nature to machine language
– Example: assembly language

 High-Level language: allows simple creation of powerful and complex programs (e.g. Python,
C#, Java)
– No need to know how CPU works or write large number of instructions
– More intuitive to understand
– Example: In a high level language like Python, we will be able to display the message Hello world on
the computer screen with following simple instruction:
print("Hellow World")

To do the same thing in assembly language would require several instructions, and an intimate
knowledge of how the CPU interacts with the computer’s screen.

CMP4266 , School of CS & DT, Birmingham City University.


High Level Programming Language

 Key words: predefined words used to write program in high-level language


– Each key word has specific meaning e.g;
- Import, print, and, if …

 Operators: perform operations on data


– Example: math operators to perform arithmetic (e.g. +, -, *, /)

 Syntax: set of rules to be followed when writing program

 Statement: individual instruction used in high-level language

CMP4266 , School of CS & DT, Birmingham City University.


Compilers and Interpreters

 Programs written in high-level languages must be translated


into machine language to be executed

 Compiler: translates high-level language program into


separate machine language program
– Machine language program can be executed at any time

 Interpreter: translates and executes instructions in high-level


language program
– Used by Python language
– Interprets one instruction at a time
– No separate machine language program

CMP4266 , School of CS & DT, Birmingham City University.


Using Python

 Python must be installed and configured prior to use


– One of the items installed is the Python interpreter

 Python interpreter can be used in two modes:


– Interactive mode: enter statements on keyboard
– Script mode: save statements in Python script

 Spyder (Integrated Development Program): single program


that provides tools to write, execute and test a program
– Automatically installed when Anaconda Navigator is installed

CMP4266 , School of CS & DT, Birmingham City University.


Using Python (Interactive Mode)

 When you start Python in interactive mode, you will see a prompt In[n]:
– Indicates the interpreter is waiting for a Python statement to be typed
– “In[n]” to indicate that Python is waiting to accept user input
– Prompt reappears after previous statement is executed
– Error message displayed If you incorrectly type a statement
 Statements entered in interactive mode are not saved as a program

CMP4266 , School of CS & DT, Birmingham City University.


Run Python IDE - Spyder
In-class
 Run Anaconda Exercise

 Launch Spyder IDE App from the grid list on Anaconda Navigator.
 Using the Spyder IDE interactive mode, on the prompt ln[1]: try the
following:
– print("Hello World!")
– 2+2
– x=5
– print(x)
– print 98

CMP4266 , School of CS & DT, Birmingham City University.


Using Python (Script Mode)
In-class
 To have a program use script mode Exercise
– Spyder has built-in text editor with features designed to help
write Python programs
– Save a set of Python statements in a file
– The filename should have the .py extension
– To run the file, or script, you can use the Spyer editer, and then click
Run the programme

CMP4266 , School of CS & DT, Birmingham City University.

You might also like