Dr. Ken Hoganson, © August 2014 Programming in R STAT8030 Programming in R COURSE NOTES 1: Hoganson Programming Languages.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
User Defined Functions
Ch:8 Design Concepts S.W Design should have following quality attribute: Functionality Usability Reliability Performance Supportability (extensibility,
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Computers Are Your Future
Programming Logic and Design Fourth Edition, Introductory
Classes & Objects Computer Science I Last updated 9/30/10.
Software Engineering and Design Principles Chapter 1.
C Lecture Notes 1 Program Control (Cont...). C Lecture Notes 2 4.8The do / while Repetition Structure The do / while repetition structure –Similar to.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 5 - Functions Outline 5.1Introduction 5.2Program.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
C++ for Engineers and Scientists Third Edition
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
© Paradigm Publishing Inc Chapter 12 Programming Concepts and Languages.
Invitation to Computer Science 5th Edition
1 Shawlands Academy Higher Computing Software Development Unit.
METHODS Introduction to Systems Programming - COMP 1005, 1405 Instructor : Behnam Hajian
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
GENERAL CONCEPTS OF OOPS INTRODUCTION With rapidly changing world and highly competitive and versatile nature of industry, the operations are becoming.
An Object-Oriented Approach to Programming Logic and Design
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
1 The Software Development Process  Systems analysis  Systems design  Implementation  Testing  Documentation  Evaluation  Maintenance.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
CPS120 Introduction to Computer Science Iteration (Looping)
Computer Concepts 2014 Chapter 12 Computer Programming.
Chapter 6 Programming Languages. © 2005 Pearson Addison-Wesley. All rights reserved 6-2 Chapter 6: Programming Languages 6.1 Historical Perspective 6.2.
Design engineering Vilnius The goal of design engineering is to produce a model that exhibits: firmness – a program should not have bugs that inhibit.
SE: CHAPTER 7 Writing The Program
June 05 David A. Gaitros Jean Muhammad Introduction to OOD and UML Dr. Jean Muhammad.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 12 Object Oriented Design.  Complements top-down design  Data-centered view of design  Reliable  Cost-effective.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 10 Slide 1 Chapter 13 Finalizing Design Specifications.
The Software Development Process
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
KIC/Computer Programming & Problem Solving 1.  Introduction  Program Modules in C  Math Library Functions  Functions  Function Definitions  Function.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
CPS120 Introduction to Computer Science Iteration (Looping)
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
Programming and Languages Dept. of Computer and Information Science IUPUI.
Introduction to OOP CPS235: Introduction.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Lecture 2 Intro. To Software Engineering and Object-Oriented Programming (1/2)
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Visit for more Learning Resources
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Lecture 1 Introduction Richard Gesick.
Engineering and Debugging an App Chapter 15
Programming Fundamentals
Functions.
An Introduction to Visual Basic .NET and Program Design
Computer Programming.
Chapter 5 - Functions Outline 5.1 Introduction
Chapter 6: Programming Languages
In C Programming Language
Programming Logic and Design Eighth Edition
Presentation transcript:

Dr. Ken Hoganson, © August 2014 Programming in R STAT8030 Programming in R COURSE NOTES 1: Hoganson Programming Languages

Dr. Ken Hoganson, © August 2014 Introduction/overview of programming ideas Quick review Not intended as the student’s first exposure to programming as a stand-along piece. Overview of language and software concepts. Programming

Dr. Ken Hoganson, © August 2014 Sequence: Selection: Iteration: Modules and modular design Recursion Objects, Inheritance, Polymorphism Programming Logic Structures

Dr. Ken Hoganson, © August 2014 Sequence is simply executing instructions in order, one at a time. We understand this intuitively. A basic idea, actually implemented in hardware inside the CPU. –Fetch instruction i, the CPU gets set to fetch instruction i + 1. –Execute instruction i –Fetch instruction i+1, the CPU gets set to fetch instruction i + 2. –Execute instruction i+1 Sequence Older programming languages used line numbers which indicated the sequence of instructions. Modern languages do not use line numbers.

Dr. Ken Hoganson, © August 2014 IF statements: (conditionals) common to all programming languages (though form may differ) IF (some condition is true) THEN do-something ELSE do-something-else Selection

Dr. Ken Hoganson, © August 2014 Selection

Dr. Ken Hoganson, © August 2014 IF statements can be compounded and nested. IF score >= 90 THEN grade = ‘A’ ELSE IF score >= 80 THEN grade = ‘B’ ELSE IF score >= 70 THEN grade = ‘C’ Etc. Compound and Nested IFs

Dr. Ken Hoganson, © August 2014

Testing multiple IF conditions is so common that most languages have a SWITCH or CASE statement: SWITCH (grade) CASE ‘A’: print “You Earned an A!” CASE ‘B’: print “You Earned a B!” etc. SWITCH or CASE

Dr. Ken Hoganson, © August 2014  Repeat a block of statements  Test before the block, or after the block WHILE (test is true) DO some set of statements REPEAT some set of statements UNTIL (test is true)  Testing after the block of code guarantees that the code inside the loop is executed at least one time. Iteration - Loops

Dr. Ken Hoganson, © August 2014 While loop test before executing the body of the loop

Dr. Ken Hoganson, © August 2014 Data, Variables, Pseudocode

Dr. Ken Hoganson, © August 2014 Better Simple Program

Dr. Ken Hoganson, © August 2014  In the early days of programming, the usefulness of breaking a program down into pieces, components, or modules was realized.  A modular program is easier to write, because the complexity is subdivided into more manageable pieces (the modules). “Divide and conquer”.  A module can be used from multiple places in a program, and from multiple other modules. This code need be written only once, and then accessed from anywhere. Reusable Modules

Dr. Ken Hoganson, © August 2014 A simple module: PROCEDURE [name] BEGIN Some set of programming statements RETURN END PROCEDURE Module Definition

Dr. Ken Hoganson, © August 2014 Calling a module: the process of transferring the CPU from the current location, to executing instructions in the module, procedure, or function.  Some instructions before the subroutine call  [subroutine name] execute module  some instructions executed after completing the call CALL

Dr. Ken Hoganson, © August 2014

Modules and complexity Modularizing a program manages complexity – smaller easier to design pieces or modules. BUT, it introduces a new level of complexity – the interaction between the modules, and the communication between modules. Which Lead to structured programming Which lead to modern understanding of data structures : the idea of packaging data together with the code that manipulates Which lead to software engineering – designing large software systems to explicitly define and systematically engineer the interactions between modules

Dr. Ken Hoganson, © August 2014 Modules and complexity Which lead to object-oriented programming, where data and code are packaged as objects. Objects can be created and deleted as needed. Objects interact through the traditional module call mechanism (now defined within the objects). Objects also are organized in a heirachy, where child objects inherit code and data structures from their parents. A new dimension of object interaction.

Dr. Ken Hoganson, © August 2014  A simple way to design software. An intuitive software engineering approach.  Particularly effective for students new to programming, OR  When learning a new programming language  Also, when building an application in ◦ new area, ◦ or with a new technology, ◦ or new techniques.  Build and test in parts, that slowly evolve  Build a prototype, and then evolve and grow the prototype. Spiral Design Model

Dr. Ken Hoganson, © August 2014 Build a prototype, and then evolve and grow the prototype. Prototype Demonstrations: and excellent way to communicate with –clients, –customers, –focus groups, –managers. Prototype demonstrations can validate the: –objectives, –goals, –and user interface Evolving Prototypes (Spiral Design)

Dr. Ken Hoganson, © August 2014

 The module has a defined interface – with possible parameters that are passed to the module, and possible values returned.  Modular (also called structured) programming simplifies the complexity within each module, but introduces complexity in the communication and interactions between modules.  Early software engineering focused on the communication complexity and topology, and in developing a standard approach to organizing a program into modules. 3.8 Modules

Dr. Ken Hoganson, © August 2014 The structured programming methodology led directly to object-oriented programming. An object is often defined as data structure (that contains the object’s attributes) and a set of methods (functions and modules) that access that data. The object is formalized within the programming language, building on ideas from structured programming. Objects

Dr. Ken Hoganson, © August 2014 Recursion is a module programming idea, where a module will CALL ITSELF! This is a useful technique in limited circumstances, that simplifies some problems. The tricky part is the stopping condition – the module should not call itself indefinitely (which would cause the machine or program to crash). It is a repeating programming logic more comlplex than loops. Recursion

Dr. Ken Hoganson, © August 2014 Threaded programming Threaded modules can run concurrently and somewhat independently “Threads of execution” Multiple modules working together/cooperating Can be a software design strategy: break down a complex system into a set of cooperating modules that interact. Some problems are simplified with this approach. Also is a parallel/high performance comptuing technology.

Dr. Ken Hoganson, © August 2014 The object paradigm led to additional programming language innovations – Objects can be grouped into classes. Objects can be defined by their membership in classes. Objects can inherit from parent classes. Additional capabilities of objects is enhanced power, but at a cost of more complex programming. Object-Oriented Programming

Dr. Ken Hoganson, © August 2014 Objects can work with different data types by “overloading” their functions. –Overloading means to have more than one meaning for a symbol or idea, which is context dependent. –Example: + means addition, or + means the logical OR operation, depending on context. Object capabilities are powerful, but make programming more complex. “R” is NOT object-oriented in the traditional sense. –“R” is a structured and interpreted language, but with additions for “Big Data”. –A nice and clean language. Object-Oriented Programming

Dr. Ken Hoganson, © August 2014 Agents: An AI language idea Combines the thread concept with the object concept. Objects can be independently operating and cooperating “agents”. Agents can run independently and concurrently, with communication with other agents and modules. AI, but also great for game design!

Dr. Ken Hoganson, © August 2014 Summary Programming is multi-dimensional, the human brain must think in multiple dimensions, and about complexity at multiple levels: L1: Syntax and grammar: the keywords and language syntax. L2: The programming paradigm: structured, threaded, objects, agents, etc. L3: Software design paradigm to be used L4: The software architecture. The design chosen to define/build the application. A hint: the architecture chosen should minimize the complexity of interactions between models/objects etc.

Dr. Ken Hoganson, © August 2014 Summary Sad fact: the challenges of programming exceed the ability of our minds to master reliably. So we use strategies to compartmentalize and manage complexity. Studies have show that even the best programmers spend most of their time revising their code already written. Code evolves, because we cannot visualize the entire project, so we “grope” our way to success, with much trial and error.

Dr. Ken Hoganson, © August 2014 Summary So if humans are poor programmers generally, why not make computers write their own code? Great idea, but not solved yet. We do not understand the human process well enough to “capture” our thinking into machine form. Hmmm, so AI is having machines follow human logic and thought process? True for much of AI. Other techniques that are a non-human modeled are in use with success.

Dr. Ken Hoganson, © August 2014 End Of Today’s Lecture. End of Lecture