The Art of Programming Program design and implementation.

Slides:



Advertisements
Similar presentations
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
Advertisements

compilers and interpreters
Programming Paradigms and languages
PHYS 2020 Pseudocode. Real Programmers Program in Pencil!  You can save a lot of time if you approach programming in a methodical way.  1) Write a clear.
Computers Are Your Future
Perl for biologists A. Emerson, Perl for Biologists PERL More references, complex data types and objects.
Programming Logic and Design Fourth Edition, Introductory
Chapter 1 - An Introduction to Computers and Problem Solving
MC697 Object-Oriented Programming Using Java. In this class, we will cover: How the class will be structured Difference between object-oriented programming.
Programming Creating programs that run on your PC
Computers: Tools for an Information Age
Chapter 1 Principles of Programming and Software Engineering.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 1: Getting Started by George Lamperti & BU Faculty.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
C++ fundamentals.
Distribution of Marks Internal Sessional Evaluation Assignments – 10 Quizzes – 10 Class Participation Attendence – 5 Mid – Term Test – 25 External Evaluation.
1 CS101 Introduction to Computing Lecture 19 Programming Languages.
Unit Six Assignment 1 Chris Boardley.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
Your Interactive Guide to the Digital World Discovering Computers 2012.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Computers Are Your Future Tenth Edition Chapter 11: Programming Languages & Program Development Copyright © 2009 Pearson Education, Inc. Publishing as.
Object Oriented Software Development
Languages and Environments Higher Computing Unit 2 – Software Development.
High-Level Programming Languages: C++
Introduction to Object-oriented programming and software development Lecture 1.
O BJECT O RIENTATION F UNDAMENTALS Prepared by: Gunjan Chhabra.
Simple Program Design Third Edition A Step-by-Step Approach
An Object-Oriented Approach to Programming Logic and Design
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
CS101 Introduction to Computing Lecture Programming Languages.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
CSE 219 Computer Science III Program Design Principles.
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Learners Support Publications Object Oriented Programming.
CS 3050 Object-Oriented Analysis and Design. Objectives What is “Object-Oriented?” Object-Oriented Approach Vs. Structured Approach How Has the Object-Oriented.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Introduction to OOP CPS235: Introduction.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Software Engineering Algorithms, Compilers, & Lifecycle.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming paradigms
Visit for more Learning Resources
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
OOP: Object-oriented programming
CSCI-235 Micro-Computer Applications
CS101 Introduction to Computing Lecture 19 Programming Languages
Lecture 2 Introduction to Programming
An Introduction to Visual Basic .NET and Program Design
Unit# 9: Computer Program Development
Programming Languages
and Program Development
Lecture 8 Programming Paradigm & Languages. Programming Languages The process of telling the computer what to do Also known as coding.
Presentation transcript:

The Art of Programming Program design and implementation

I have a computational problem. What should I do first ? 1.Go straight to the keyboard and start typing. 3.Check that someone else hasn’t already done it! * *(and if they have, it doesn’t cost too much)? 2.Think about the problem, design on paper the structure of the program, then start typing.  

Writing a program – design, strategies and implementation 1.Analysing the problem  What do I need to do? 2.Unstructured programming 3.Program design with structured programming  pseudo code  program blocks and flow-schemes 4.Object-oriented programming (OOP) for complex projects  defining the problem in terms of objects

Problem analysis Define carefully what you want to do, writing it down if necessary. Ask yourself: –Is it feasible? (Protein folding is difficult, particularly in Perl!) –Has it been done before ? Check literature, web etc for similar work. Check software archives or libraries for programs that do similar things. Apart from bioinformatic sources, the CPAN site contains an extensive list of free Perl libraries and routines:

Unstructured programming All the program code written in a single continuous main program. Many disadvantages for large programs difficult to follow logic if something needs to be done more than once must be re-typed hard to incorporate other code not easily modified difficult to test particular portions of the code... Many disadvantages for large programs difficult to follow logic if something needs to be done more than once must be re-typed hard to incorporate other code not easily modified difficult to test particular portions of the code...

Structured programming Structured or procedural programming attempts to divide the problem into smaller blocks or procedures which interact with other. The aim is to clearly define the structure of the program before writing program code. (At this stage we could also decide to attach pre-written libraries or other programs) Structured or procedural programming attempts to divide the problem into smaller blocks or procedures which interact with other. The aim is to clearly define the structure of the program before writing program code. (At this stage we could also decide to attach pre-written libraries or other programs)

Stuctured programming Ideally each block should be a black box –should carry out a well-defined task, interacting with other blocks only through definite inputs and outputs. input output PROGRAM FLOW

Structured programming 1.Write pseudo-code if desired to define the problem. 2.Decide on the program blocks, specifying the inputs and outputs for each blocks. 3.Refine and see if the larger blocks can be in turn sub-divided into smaller blocks. 4.Now you can start programming..just fill in the blocks with computer code ! 1.Write pseudo-code if desired to define the problem. 2.Decide on the program blocks, specifying the inputs and outputs for each blocks. 3.Refine and see if the larger blocks can be in turn sub-divided into smaller blocks. 4.Now you can start programming..just fill in the blocks with computer code ! Strategy

Structured Programming - Example Problem: From a FASTA file, extract the DNA sequence data and translate in all six reading frames.

DNA translation – pseudo code read sequence data from file –read what is in file –extract sequence data (i.e. remove FASTA headers and comments) for each reading frame –translate DNA to peptide –loop over codons and translate each codon to aminoacid or stop print results read sequence data from file –read what is in file –extract sequence data (i.e. remove FASTA headers and comments) for each reading frame –translate DNA to peptide –loop over codons and translate each codon to aminoacid or stop print results

DNA Translation -Block diagram get sequence data from file translate each OF to protein print results read file extract sequence select codon translate to aa loop over codons loop over OFs

Each box has well-defined input and outputs – information should only pass through these points translate each OF to protein CCGGTAGCCTCCAGGTC.. PVTPSELPRPRRPLPTQQQPQ.. DNA input protein output

Implementing structural design In terms of program code, there is usually a main program and calls are made to the routine from this loop (which may call other routines, etc.) After each routine has finished the computer returns to the point right after the call. In terms of program code, there is usually a main program and calls are made to the routine from this loop (which may call other routines, etc.) After each routine has finished the computer returns to the point right after the call.

DNA translation – advanced pseudo code # NOT VALID PERL # main program call get sequence loop over OFs call convertDNA end loop call results end program # NOT VALID PERL # main program call get sequence loop over OFs call convertDNA end loop call results end program get sequence call read data call del_headers get sequence call read data call del_headers convertDNA loop over codons call tr_codon end loop convertDNA loop over codons call tr_codon end loop results printresults results printresults read_data del headers tr_codon

complex block diagrams EXIT utility routine START

Structured programming - summary Structured programs divide the problem into smaller sub-units or blocks, then divided into smaller blocks.. eventually reaching the level of program code. The blocks should ideally be self-contained – interactions with other blocks should be explicit ALL programming languages support Structured Programming to some extent Useful model for small-medium sized projects. Object Oriented ProgrammingBecomes unmanageable for larger, more complex projects, with many programmers involved → Object Oriented Programming (OOP). Structured programs divide the problem into smaller sub-units or blocks, then divided into smaller blocks.. eventually reaching the level of program code. The blocks should ideally be self-contained – interactions with other blocks should be explicit ALL programming languages support Structured Programming to some extent Useful model for small-medium sized projects. Object Oriented ProgrammingBecomes unmanageable for larger, more complex projects, with many programmers involved → Object Oriented Programming (OOP).

The object-oriented approach Evolution of Program Design 1950s- 1960s 1970s s 1990’s- “simple” program models Zenith of structured programming- especially Pascal. First object-oriented languages (esp C++) traditional languages “converted” to OOP COBOL, Algol, BASIC Pascal, C, Fortran, Perl Ada, C++, JAVA, SmallTalk Visual Basic, Delphi (Object Pascal), Perl 5, (e.g. BioPerl) Examples

The object-oriented approach The program is written as a collection of interacting objects. Q: Why objects? A: Because the world is made from distinct objects, which consist of other objects, etc., and this is often a natural and powerful way of representing a situation or problem. Q: Why objects? A: Because the world is made from distinct objects, which consist of other objects, etc., and this is often a natural and powerful way of representing a situation or problem.

Example objects - chemistry molecules are made of.... atoms which consist of.... protons, neutrons and electrons.. molecules atoms nuclei electrons protons neutrons object hierarchy

OOP and structured programming In structured programs the blocks are pieces of code which are executed as the program is run In object-oriented programs objects have lives of their own – they can be created, copied, destroyed or even lost!

What is a software object? An object has two components: 1.state information which describes the current characteristics of the object and 2.behaviour which describes how it interacts with other objects. An object has two components: 1.state information which describes the current characteristics of the object and 2.behaviour which describes how it interacts with other objects.

Software representation of a cat object STATE Name Breed Weight Age Asleep STATE Name Breed Weight Age Asleep BEHAVIOUR Sleeps a lot Scratches furniture Catches mice Fights other cats BEHAVIOUR Sleeps a lot Scratches furniture Catches mice Fights other cats

Implementation of objects State is usually held as local variables (also called properties), quantities not visible outside the object (data hiding) Behaviour controlled by method functions or subroutines which act on the local variables and interface with the outside. STATE BEHAVIOUR

Key feature of OOP - Inheritance Important ability of any OOP is the ability to derive one object from a more general class of related objects: this is called inheritance. A standard eukaryotic cell nucleus, cell membrane, cytoplasm, alive or dead undergoes division, makes proteins from DNA nerve cell skin cell white blood cell

Examples of OO languages C++ –Classic example, uses C syntax Java –Based on C++, often used for Web and graphics Visual Basic, Visual C++ –Windows programming Perl ? –Possible, e.g. BioPerl, but not originally designed for objects. Implementation is a bit ad-hoc. Wanna know more ? For experts C++, for semi-experts Java and Visual Basic for beginners.

OOP - Summary  Objects provide a powerful and natural approach to representing many problems  Features such as inheritance allow already written objects to be re-used – program modification easier.   Certainly more difficult than conventional programming  Some concepts hard, even for experienced programmers  Implementation of objects often use complicated syntax/semantics  OOP not famous for efficiency (memory or execution time)  C++ once famous for being slow, now much better  Java still famous for being slow  Objects provide a powerful and natural approach to representing many problems  Features such as inheritance allow already written objects to be re-used – program modification easier.   Certainly more difficult than conventional programming  Some concepts hard, even for experienced programmers  Implementation of objects often use complicated syntax/semantics  OOP not famous for efficiency (memory or execution time)  C++ once famous for being slow, now much better  Java still famous for being slow