Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Software Engineering Dr Ian Reid B4, 4 lectures, Hilary Term http://www.robots.ox.ac.uk/~ian/Teaching/SoftEng
Software Engineering vs structured programming Not really a course about software engineering… Software engineering Mostly about concepts,  Structured programming Revision, coding in C and Matlab, functions Data structures structures, classes Object oriented programming objects, object-oriented concepts like inheritance, polymorphism, patterns and the standard template library
Learning Outcomes The course will aim to give a good understanding of basic design methods, and emphasize the need to produce well-structured maintainable computer software.  The course will concentrate on principles, but these will be reinforced with examples in Matlab and C/C++ programming languages.  Specifically, by the end of the course students should : understand concepts of basic program design techniques that can be  applied to a variety of programming languages, in particular Matlab and C/C++  understand the need for structured programming in software projects be able to recognise and to produce and/or maintain well structured programs have a basic understanding of the role of and advantages of object oriented design
Texts Sommerville,  Software Engineering , Addison-Wesley (8 th  edition), 2007. Wirth,  Algorithms + Data Structures = Programs , Prentice-Hall, 1975 Leveson,  Safeware: System Safety and Computers , Addison-Wesley, 1995. Lipmann and Lajoie,  C++ Primer,  Addison-Wesley, 2005. Goodrich et al.,  Data structures and algorithms in C++ , Wiley, 2004

Recommended for you

Integrating profiling into mde compilers
Integrating profiling into mde compilersIntegrating profiling into mde compilers
Integrating profiling into mde compilers

Scientific computation requires more and more performance in its algorithms. New massively parallel architectures suit well to these algorithms. They are known for offering high performance and power efficiency. Unfortunately, as parallel programming for these architectures requires a complex distribution of tasks and data, developers find difficult to implement their applications effectively. Although approaches based on source-to-source intends to provide a low learning curve for parallel programming and take advantage of architecture features to create optimized applications, programming remains difficult for neophytes. This work aims at improving performance by returning to the high-level models, specific execution data from a profiling tool enhanced by smart advices computed by an analysis engine. In order to keep the link between execution and model, the process is based on a traceability mechanism. Once the model is automatically annotated, it can be re-factored aiming better performances on the re-generated code. Hence, this work allows keeping coherence between model and code without forgetting to harness the power of parallel architectures. To illustrate and clarify key points of this approach, we provide an experimental example in GPUs context. The example uses a transformation chain from UML-MARTE models to OpenCL code.

profiling – mde – traceability – performance
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENTTHE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT

The present business network infrastructure is quickly varying with latest servers, services, connections, and ports added often, at times day by day, and with a uncontrollably inflow of laptops, storage media and wireless networks. With the increasing amount of vulnerabilities and exploits coupled with the recurrent evolution of IT infrastructure, organizations at present require more numerous vulnerability assessments. In this paper new approach the Unified process for Network vulnerability Assessments hereafter called as a unified NVA is proposed for network vulnerability assessment derived from Unified Software Development Process or Unified Process, it is a popular iterative and incremental software development process framework.

object oriented modelinunified processnetwork vulvernability
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...

This document discusses an approach to structurally validating software product line variants using graph transformations. The authors propose using model transformations to automatically validate products according to dependencies defined in the feature diagram. They introduce necessary meta-models and present graph grammars to perform validation using the AToM3 tool. The approach is illustrated through examples.

The Role of Computing in Engineering Computing is ubiquitous in engineering. Why? Awesome speed of modern, everyday computers a makes complicated analysis and simulation possible across all domains.  Applications in design and modelling. Far beyond the reach of the mortal human engineer. Indeed many modelling problems are utterly infeasible without modern computers and software. In embedded systems, computers can provide a level of power, speed, flexibility and control not otherwise possible  (eg mobile phone) Computing is “cheap” (but exercise this argument with care) Software is the key… some examples…
Example: mobile phone Even simple mobile phones rely on software Typical phone has a microcontroller (SIM card) with a small program Drive GUI Control devices (keypad, microphone, a/d, dsp, decoder)
Example: Sizewell B Nuclear power station (PWR), onstream in 1995 Software used extensively in the design Software for control! first UK reactor to use software in its Primary Protection System)
Example: A380 A380 1400 separate programs There is a software project just to manage all the software! Clearly safety-critical features of the software

Recommended for you

Software Engineering: What is That?
Software Engineering: What is That?Software Engineering: What is That?
Software Engineering: What is That?

Software Engineering: introductory lecture. Relation between SE and Computer Science Working Definition Good and bad Design

software engineeringoo software engineeringgood design
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISONSTATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON

Performance responsiveness and scalability is a make-or-break quality for software. Nearly everyone runs into performance problems at one time or another. This paper discusses about performance issues faced during Pre Examination Process Automation System (PEPAS) implemented in java technology. The challenges faced during the life cycle of the project and the mitigation actions performed. It compares 3 java technologies and shows how improvements are made through statistical analysis in response time of the application. The paper concludes with result analysis.

jmeteradobe flexgroovy grails
Introduction to networks simulation
Introduction to networks simulationIntroduction to networks simulation
Introduction to networks simulation

A brief introduction to network simulation and the difference between simulator and emulator along with the most important types of simulations techniques.

Example: NPfIT NHS National Plan for IT Plan to provide electronic care records for patients Connect 30000 GPs and 300 hospitals Provide secure access to records for healthcare professionals Provide access for patients to their own records via “Healthspace”
Software engineering versus programming Software engineering is about more than just programming/coding It is about design principles and methodologies that yield programs that are Robust  Manageable Reusable
Software vs “other” engineering How is software engineering  similar  to other engineering? Abstraction  and  Modularity Consider free-body diagram Thevenin/Norton Low output impedance / High input impedance Digital computer We return to these concepts later…
Abstraction:  free-body diagram

Recommended for you

01_Program
01_Program01_Program
01_Program

This document provides an agenda and descriptions for an Architecture-Driven Modernization workshop taking place from March 22-24, 2004 in Chicago. The workshop includes several tutorials and sessions on topics related to modernizing existing software systems through architecture-driven approaches and leveraging existing assets. Tutorials will cover application modernization strategies, managing existing software through architectural models, and harvesting reusable components from legacy code. Sessions will present methodologies for model-driven legacy migration, domain-driven modernization, addressing scale in analysis tools, mining software architecture from databases, and extending the life of software through componentization.

Is There a Return on Investment from Model-Based Systems Engineering?
Is There a Return on Investment from Model-Based Systems Engineering?Is There a Return on Investment from Model-Based Systems Engineering?
Is There a Return on Investment from Model-Based Systems Engineering?

See our latest webinar “Is There a Return on Investment from MBSE?” This question is one that many people ask. In fact, the International Council on Systems Engineering (INCOSE) has that as one of its tasks for their Value Proposition Initiative. A group of systems engineers is trying to find evidence to prove that MBSE has value. However, that becomes very difficult for a concept that has only been around for a dozen years, when the lifecycle of many of the systems of interest are measured in several decades. Your host Dr. Steven Dam will walk you through a method of finding a case for MBSE in this webinar. https://youtu.be/NnQDinanhJU

roireturn on investmentmbse
Looking Forwards to Going Backwards
Looking Forwards to Going BackwardsLooking Forwards to Going Backwards
Looking Forwards to Going Backwards

The document provides an overview of reverse engineering and its applications. It defines reverse engineering as the process of analyzing a system to understand its design and components without access to original documentation. The document discusses that reverse engineering can be used for (1) interoperability to understand proprietary systems and file formats, (2) security testing to discover vulnerabilities, and (3) understanding cryptographic algorithms and authentication mechanisms. Reverse engineering is commonly used both maliciously to create malware and beneficially by security professionals to improve system defenses.

computer sciencereverse engineering
Modularity: Op-amp buffer Unity gain buffer Vout = Vin Very high input impedance, very low output impedance + - In Out
Software vs “other” engineering How is software  different  to other engineering? Pure, weightless, flexible Capacity to incorporate massive complexity  No manufacturing defects, corrosion, aging
Intrinsic difficulties with software Analogue versus discrete state systems The “curse” of flexibility Can encourage unnecessary complexity Redefinition of tasks late in development – shifting goal-post Complexity and invisible interfaces Standard way of dealing with complexity is via modularity But this alone is not enough because interfaces can be subtle and invisible, and here too there is a need to control complexity Historical usage information Unlike physical systems, there is a limited amount of experience about standard designs
When software projects go wrong A320, Habsheim and Strasbourg

Recommended for you

On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...

This document summarizes a systematic literature review on using component-based principles and practices for architecting cyber-physical systems. The review analyzed existing research according to a classification framework and identified gaps. It found that over half the primary studies were published between 2014-2015, indicating growing interest. However, component models for cyber-physical systems have not fully explored properties like adaptation and dynamics. The review aims to enlarge the scope of architecting cyber-physical systems and cover gaps between needs in the field and current realizations.

software development
Programming and problem solving with c++, 3rd edition
Programming and problem solving with c++, 3rd editionProgramming and problem solving with c++, 3rd edition
Programming and problem solving with c++, 3rd edition

This document provides information about the book "Programming and Problem Solving with C++ 3rd Ed." including the title, authors, publisher, ISBN numbers, publication date, and subjects. It also contains introductory text from the preface and pages discussing changes between this third edition and previous editions, such as the addition of a new chapter on templates and exceptions and more complete programs included in the body of the chapters.

$
Software concepts ppt
Software concepts pptSoftware concepts ppt
Software concepts ppt

This document provides an overview of software concepts including types of software, computer languages, and operating systems. It discusses how software is broadly classified into system software and application software. System software includes language translators, operating systems, and utilities. Application software focuses on performing specific tasks. Computer languages are classified as low-level languages like machine code and assembly language or high-level languages. An operating system manages computer resources and acts as an interface between hardware and users.

software conceptstypes of softwareclassification of software
When software projects go wrong London Ambulance Service 1992, computerised ambulance despatch system fails Therac-25 2 people died and several others exposed to dangerous levels of radiation because of  software flaws in radiotherapy device OSIRIS £5M University financial package Expenditure to date more like £20-25M NPfIT? NHS £12 billion IT project comp.risks is a great source of others...
NHS National programme for IT: NPfIT Plan to provide electronic care records for patients Connect 30000 GPs and 300 hospitals Provide secure access to records for healthcare professionals Provide access for patients to their own records via “Healthspace” Laudable? Realistic? Software Engineering specialists have their doubts Ross Anderson (Prof of Security Engineering, Cambridge Computing Laboratory) wrtes in his blog “I fear the whole project will just continue on its slow slide towards becoming the biggest IT disaster ever”.
Software life-cycle Software development stages Specification Design Implementation Integration Validation Operation/Maintenance/Evolution Different types of system organise these generic activities in different ways Waterfall approach  treats them as distinct stages to be signed off chronologically In practice usually an iteration of various steps
Requirements Vague initial goals Iterative refinement Leading to more precise specification Example Calculate the n-bounce trajectory of a lossy bouncing ball. Refine this to consider What does the statement  actually  mean? Physics Initial conditions Air-resistance? Stopping criterion (criteria)? Now, think about how to design/implement

Recommended for you

Program design and problem solving techniques
Program design and problem solving techniquesProgram design and problem solving techniques
Program design and problem solving techniques

The document provides an overview of program design and problem-solving techniques. It discusses the following key points in 3 or fewer sentences: The document outlines the steps in program development including defining the problem, outlining the solution, developing an algorithm, testing the algorithm, coding the algorithm, running the program, and documenting the program. It also discusses algorithmic problem solving, writing pseudocode, meaningful naming conventions, the structure theorem of sequence, selection, and repetition, and communication between modules including variable scope, global vs local variables, and passing parameters.

program design and problem solving techniques
J044084349
J044084349J044084349
J044084349

International Journal of Engineering Research and Applications (IJERA) is an open access online peer reviewed international journal that publishes research and review articles in the fields of Computer Science, Neural Networks, Electrical Engineering, Software Engineering, Information Technology, Mechanical Engineering, Chemical Engineering, Plastic Engineering, Food Technology, Textile Engineering, Nano Technology & science, Power Electronics, Electronics & Communication Engineering, Computational mathematics, Image processing, Civil Engineering, Structural Engineering, Environmental Engineering, VLSI Testing & Low Power VLSI Design etc.

ijera(www.ijera.com)international journal of engin
Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012

This document contains sample questions for the Principles and Practices of Software Engineering exam. It is divided into two parts: Part A contains 10 short answer questions worth 2 marks each on topics like what defines software engineering, different testing stages, software architecture, and estimation models. Part B contains 5 long answer questions worth 10 marks each, from which students must answer 5. Questions cover topics such as requirements gathering techniques, software development process models, design principles, testing strategies, UML diagrams for library and supermarket systems, and software metrics and maintenance.

by neelamani
Validation/Verification Verification:  does the system confirm to spec? Validation: does it actually do what it was supposed to? Top-down vs bottom-up testing Black-box vs white-box testing Impossibility of exhaustive testing
Extreme programming (XP) Proposed in the late 90s as a reaction to problems with “traditional” development processes Takes  extreme  position compared with waterfall approach Appropriate for small-medium sized projects Teams of pairs of programmer, programming together Incremental development, frequent system releases Code constantly refined, improved, made as simple as possible Do not design for change; instead change reactively
Top down design Here want to keep in mind the general principles Abstraction Modularity Architectural design: identifying the building blocks Abstract specification: describe the data/functions and their constraints Interfaces: define how the modules fit together Component design: recursively design each block
Modular design Procedural programming: focus on algorithms Object-oriented programming: focus on data structures Algorithms Data structures Programs

Recommended for you

A tlm based platform to specify and verify component-based real-time systems
A tlm based platform to specify and verify component-based real-time systemsA tlm based platform to specify and verify component-based real-time systems
A tlm based platform to specify and verify component-based real-time systems

This paper is about modeling and verification languages with their pros and cons. Modeling is dynamic part of system development process before realization. The cost and risky situations obligate designer to model system before production and modeling gives designer more flexible and dynamic image of realized system. Formal languages and modeling methods are the ways to model and verify systems but they have their own difficulties in specifying systems. Some of them are very precise but hard to specify complex systems like TRIO, and others do not support object oriented design and hardware/software co-design in real-time systems. In this paper we are going to introduce systemC and the more abstracted method called TLM 2.0 that solved all mentioned problems.

real-time systemscomponent-based developmentmodeling
COCOMO methods for software size estimation
COCOMO methods for software size estimationCOCOMO methods for software size estimation
COCOMO methods for software size estimation

Constructive Cost Model techniques for software size estimation, delivered to post-graduate students of Object Oriented Software Engineering.

Aansprakelijkheid van de zzp-er
Aansprakelijkheid van de zzp-erAansprakelijkheid van de zzp-er
Aansprakelijkheid van de zzp-er

Aansprakelijkheid van de ZZP-er Tips • Omschrijf precies wat het object is van de overeenkomst (inspanning? resultaat?) en rol opdrachtgever daarin; • Voldoe aan informatieverplichting, houd opdrachtgever op de hoogte van de voortgang; • Zorg voor een deugdelijke exoneratie (uitsluiting van aansprakelijkheid), alternatief: schade vergoeden tot hoogte factuur; • Zorg voor een adequate verzekering.

juridisch adviseurzzp-eraansprakelijkheid
Structured programming Top-down vs bottom-up Both are useful as a means to understand the relations between high-level and low-level views of a program Top-down Code high level parts using “stubs” with assumed functionality for low-level dependencies Iteratively descend to lower-level modules  Bottom-up Code and test each low-level component Need “test harness” so that low-level can be tested in its correct context Integrate components Not hard-fast rules; combination often best
Simple design tools Flow chart Pseudo-code Wait for alarm Count = 1 While (not ready to get up and count <= 3) Hit snooze button Increment count Climb out of bed
Data flows Data flow diagram Simple example, VTOL simulator Controller Simulator Display state state thrust
Simple design tools State diagram

Recommended for you

A2 advanced portfolio_production_diary_template
A2 advanced portfolio_production_diary_templateA2 advanced portfolio_production_diary_template
A2 advanced portfolio_production_diary_template

Olivia created a short film for her advanced portfolio project. She documented her progress through production diaries. In September, she researched film posters and planned to analyze them. In October, she analyzed posters and began researching film reviews. In November, she created a layout plan for her film review. In December, she analyzed short films. In January, she conducted market research and began writing a script. In February, she storyboarded and planned filming. In March, she filmed and began editing. In April, she completed her evaluation and uploaded all work to her blog.

Reservoir Project - Digibiz 2009, M.Lindner
Reservoir Project - Digibiz 2009, M.LindnerReservoir Project - Digibiz 2009, M.Lindner
Reservoir Project - Digibiz 2009, M.Lindner
cloud computing
Sportrons overview
Sportrons overviewSportrons overview
Sportrons overview

Sportrons is the largest digital sports advertising network in America, providing video, animation, and interactive ads in sports venues. It has a nationwide network of large digital screens in stadiums and arenas, reaching over 250 million sports fans annually. Sportrons works with advertisers to create campaigns that interact with fans to gain attention and convert them to loyal customers through video, mobile, and digital ads.

Basic coding techniques Pretty much any program can be specified using: Sequences of instructions { Do A; Do B; Do C } Conditional instructions If (condition) Do A Repetitions (loops) While (condition) Do A These  semantic  concepts are implemented in different high-level programming languages using different  syntax
Implementation in Matlab and C N= 10; tot = 0; totsq = 0; for i=1:N tot = tot+i; totsq = totsq+i^2; end tot totsq int i; int tot = 0; int totsq = 0; for (i=1; i<N; i++) { tot += i; totsq += i*i; } cout << tot << endl; cout << totsq << endl;
Notes on coding style Use meaningful variable names Use comments to supplement the meaning Indent code for each block/loop Encapsulate groups of statements sensibly in functions Encapsulate related data sensibly in data structures Design top down Code bottom-up or top-down, or a combination
Matlab vs C Matlab and C are both procedural languages Matlab is an  interpreted language each statement decoded and executed in turn C is a  compiled language each module (.c file) is converted into assembly language The interfaces between the modules are Shared global data Function calls from one module to another This is resolved at  link  time when the modules are  linked  together into an  executable

Recommended for you

Tutorial Passaporte
Tutorial PassaporteTutorial Passaporte
Tutorial Passaporte

O documento fornece instruções sobre o novo passaporte eletrônico brasileiro, que contém um chip com dados biométricos do portador. Explica o processo de emissão em 7 passos, desde solicitar o documento online até recebê-lo pessoalmente, e destaca que o chip agiliza a imigração em outros países.

Mapa research brochure-swe-sharedealing-dashboard
Mapa research brochure-swe-sharedealing-dashboardMapa research brochure-swe-sharedealing-dashboard
Mapa research brochure-swe-sharedealing-dashboard

Mapa provides competitor dashboards that give insights into competitors that others cannot. The dashboards monitor competitors continuously, keep clients updated on market changes, and compare features. They help clients identify opportunities, learn from independent analysis, and create influential reports. The dashboards are a relationship, providing timely alerts and access to experts to make clients' jobs easier.

4squares
4squares4squares
4squares

1. The document presents a series of 4 questions about dividing the white areas of 4 squares (A, B, C, D) into equal pieces. 2. The questions get progressively more difficult, asking to divide square A into 2 pieces, square B into 3 pieces, and so on. 3. The document emphasizes that the mind often overcomplicates simple problems and situations, when the solutions are actually quite obvious. It encourages living simply.

Procedural programming Aim is to break program down into functional units procedures or functions Set of inputs, set of outputs In Matlab and C this procedural building block is the  function   Understanding functions…
Organisation of Matlab programs A Matlab “program” may be a script or function i.e. a sequence of instructions This script or function will typically call a bunch of other functions Functions are stored in .m files  Multiple functions can be stored in one .m file, but only first is visible outside The others are  local functions   Part of the recursive subdivision of the problem
Matlab file organisation bar FUNC.m foo.m bar.m FUNC foo
Organisation of C programs Source code .c  .cc Object file .o compilation Source code .c  .cc Object file .o compilation … .. … .. linking executable

Recommended for you

Social media-101-presentation
Social media-101-presentationSocial media-101-presentation
Social media-101-presentation

Web 2.0 and social media refer to online tools and platforms that enable users to create and share content. Social media allows for conversations between people that are not controlled or organized in a traditional way. The use of social media and Web 2.0 technologies is growing significantly, with over half of online users participating on social networks or uploading photos. These technologies have become more widely used as access to the internet on computers and mobile devices has expanded. Their rise is important for civic engagement and how organizations communicate with constituents.

Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation

This document provides an overview of object-oriented programming concepts including classes, objects, encapsulation, abstraction, inheritance, and polymorphism. It discusses different programming languages like Java and C++ that use the object-oriented paradigm. Specific concepts covered include defining classes with attributes and methods, creating object instances of classes, encapsulating data within classes, and abstract data types. Examples are provided to illustrate classes like Account and Circle and their corresponding objects.

Parallel Computing 2007: Overview
Parallel Computing 2007: OverviewParallel Computing 2007: Overview
Parallel Computing 2007: Overview

The document discusses parallel computing over the past 25 years and challenges for using multicore chips in the next decade. It aims to provide context to scale applications effectively to 32-1024 cores. Key challenges include expressing inherent application parallelism while enabling efficient mapping to hardware through programming models and runtime systems. Future work includes developing methods to restore lost parallelism information and tradeoffs between programming effort, generality and performance.

Functions Function definition Function call Function prototype Scope (local versus global data) Parameters and return value(s) Function call Low-level implementation of function calls Recursion
Function definition % compute factorial  function z = fact(n) % function body z = 1; for i=1:n z = z*i; end // compute factorial int fact(int n) { int i, val = 1; for (i=1; i<=n; i++) { val *= i; } return val; }
Function call Distinguish between The function definition Defines the set of operations that will be executed when the function is called The inputs The outputs And the function call i.e. actually using the function Formal vs Actual parameters Return value(s) The value of a function evaluation is the return value fact(10) a = 6; z = fact(a); [V,D] = eig(A);
Function prototype The  function prototype  provides enough information to the compiler so that it can check that it is being called correctly Defines the  interface Input (parameter), output (return value) myexp.c file float myexp(float x) {  const float precision = 1.0e-6; float term=1.0, res=0.0; int i=0; while (fabs(term)>precision) { res += term; i++; term = pow(x,i)/fact(i); } return res; } myexp.h file float myexp(float x);

Recommended for you

The Concurrency Challenge : Notes
The Concurrency Challenge : NotesThe Concurrency Challenge : Notes
The Concurrency Challenge : Notes

Highlighted notes of article while studying Concurrent Data Structures, CSE: The Concurrency Challenge Wen-mei W. Hwu, Kurt Keutzer, Tim Mattson IEEE Design and Test The Concurrency Challenge July-August 2008, pp. 312-320, vol. 25 DOI Bookmark: 10.1109/MDT.2008.110 Wen-mei Hwu is a professor and the Sanders-AMD Endowed Chair of Electrical and Computer Engineering at the University of Illinois at Urbana- Champaign. His research interests include architecture and compilation for parallel- computing systems. He has a BS in electrical engineering from National Taiwan University, and a PhD in computer science from the University of California, Berkeley. He is a Fellow of both the IEEE and the ACM. Kurt Keutzer is a professor of electrical engineering and computer science at the University of California, Berkeley and a principal investigator in UC Berkeley’s Universal Parallel Computing Research Center. His research focuses on the design and programming of ICs. He has a BS in mathematics from Maharishi International University, and an MS a PhD in computer science from Indiana University, Bloomington. He is a Fellow of the IEEE and a member of the ACM. Timothy G. Mattson is a principal engineer in the Applications Research Laboratory at Intel. He research inter- ests focus on performance modeling for future multicore microprocessors and how different programming models map onto these systems. He has a BS in chemistry from the University of California, Riverside; an MS in chemistry from the university of California, Santa Cruz; and a PhD in theoretical chemistry from the University of California, Santa Cruz. He is a member of the American Association for the Advancement of Sci- ence (AAAS). https://ieeexplore.ieee.org/document/4584454

concurrencychallengehardware
Ch01lect1 et
Ch01lect1 etCh01lect1 et
Ch01lect1 et

This document discusses an introduction to software engineering. It begins by defining what a computer program and software are, noting that software includes computer programs, configuration files, user documentation, support services, and system documentation. The document then discusses some key attributes of software like maintainability, dependability, efficiency, and usability. It notes that software engineering is needed for medium to large projects involving teams to deal with complexity and change. The document discusses why software development is difficult due to changes in requirements and technology, complex problem and solution domains, and difficult management of development processes. It describes how abstraction, decomposition, and hierarchy can be used to deal with complexity. Finally, it discusses different models used in software engineering like object, functional, dynamic

Management of Complexity in System Design of Large IT Solutions
Management of Complexity in System Design of Large IT SolutionsManagement of Complexity in System Design of Large IT Solutions
Management of Complexity in System Design of Large IT Solutions

The capability to manage complexity is one of the key competencies of system engineers for large IT-solutions. We call a technical system "complex" (in contrast to "complicated") if it is impossible (due to the networked interaction of its components) to predict the behavior of the whole system, even if you know exactly how each of the system components behave. On the other hand, customers expect increasingly high reliability of IT systems as their business is more and more dependent on the proper operation and interoperation of the IT systems. First we show how a network of interactions increases the complexity of the overall-system. Then we analyze the complexity management strategies of our system engineers and present generalized strategies based on examples of large customer projects. The examples demonstrate that a high maturity in managing complexity enables to provide IT solutions of ultra-high reliability even if they are complex solutions in the above defined sense.

availabilityultrahighavailablity
Scope: local variables Variables which are declared inside a function are  local variables They cannot be “seen” outside the function (block) in which they are declared A local variable exists only for the duration of the current function execution It is declared as a new variable every time the function is called It ceases to exist when the function returns It does not “remember” its value between calls
Scope: global variables Global variables exist outside all functions A global variable is visible inside functions If there exist two variables, one local, one global, with the same name, then the local one takes precedence within its local scope C and Matlab behave differently C will use a global if no local exists Matlab only uses a global if the programmer explicitly requests it Globals should be used with caution because their use inside a function compromises its encapsulation
Encapsulation Want the function to behave in the same way for the same inputs encapsulate particular functional relationship But if the function depends on a global it could behave differently for the same inputs Live example using  myexp
Function encapsulation Input parameters Output values Hidden input Input parameters Output values Hidden output

Recommended for you

Software engineering
Software engineeringSoftware engineering
Software engineering

Know more about software Engineering what content are in Software engineering product selling models software modules and principles and many more.

sesoftwaresoftware requirement
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13

The document discusses various aspects of developing computer programs and systems. It covers topics like how programmers move from defining a problem to developing an algorithm and writing code. It also discusses programming languages, structured and object-oriented programming methodologies, and the systems development life cycle from analysis through maintenance.

Mit104 software engineering
Mit104  software engineeringMit104  software engineering
Mit104 software engineering

Dear students get fully solved assignments Send your semester & Specialization name to our mail id : “ help.mbaassignments@gmail.com ” or Call us at : 08263069601

Side-effects Could set value of a global variable in a function Again this compromises the function’s encapsulation Causes a side-effect An implicit output, not captured by the interface  Makes it difficult to re-use code with confidence c.f. C and Matlab function libraries Set of re-usable routines with well defined interfaces In small projects maybe not a big problem Hugely problematic in bigger projects, especially when multiple programmers working as a team Complicates interfaces between components, possibly in unintended ways
Low-level implementation of function call Memory CODE DATA machine code global variables STACK local variable m local variable 1 return location return value n return value 1 parameter x parameter 1 … … … Activation   record
Pass by value/reference int i=5, j=10; swap(i,j); cout << i << “ “ << j << endl; Pass by value Pass by reference void swap(int a, int b) { int temp = a; a = b; b = temp; return; } void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
Recursion Recursion is the programming analogue of induction: If  p(0)  and  p(n)  implies  p(n+1) Then  p(n)  for all  n Define a function in terms of Itself Boundary conditions For example Factorial:  n! = n * (n-1)!,  0! = 1

Recommended for you

01 the big_idea
01 the big_idea01 the big_idea
01 the big_idea

The document discusses some of the origins and challenges of software engineering. It describes Brooks' classification of software difficulties as either accidental, which have solutions that can be discovered, or essential, which can only have partial solutions or none at all. Examples of essential difficulties include complexity, conformity to changing requirements, and the intangible nature of software. The document advocates that software architecture is key to addressing these difficulties and outlines some similarities and limitations between software and building architecture.

software architecture fundationstheory and pratice
Managing Complexity and Change with Scalable Software Design
Managing Complexity and Change with Scalable Software DesignManaging Complexity and Change with Scalable Software Design
Managing Complexity and Change with Scalable Software Design

This is a presentation I gave to a group of IT managers. It explains what 'scalable design' is about, discusses its motivations by a number of facts and figures about software development, and illustrates the approach through a real-world case.

flexiblityextensibilitysoftware development
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development

Aspect-Oriented Software Development (AOSD) is a programming methodology that addresses limitations in object-oriented programming for modularizing cross-cutting concerns. AOSD uses aspects to encapsulate cross-cutting concerns so they can be separated from the core functionality. Aspects are automatically incorporated into the system by a weaver. This improves modularity and makes software easier to maintain and evolve over time.

Recursion example: factorial Live demo
Data types and data structures C/C++ predefine a set of  atomic types bool, char, int, float, double C/C++ provides machanism for building compound data structures struct (class) Array Matlab supports arrays/matrices (of course) Matlab also supports structures
A  class  (struct in C) is a compound data type which encapsulates related data into a single entity class Complex { public:  double re, im; }; Defines how a variable of this type will look int i; Complex z; C/C++: struct and class Class definition Create a variable (an instance) of this type
Example:  VTOL state Represent current state as, say, a triple of numbers and a bool, (position, velocity, mass, landed) Single variable represents all numbers Better abstraction! class State { double pos, vel, mass; bool landed; }; State s; Controller Simulator Display state state thrust

Recommended for you

Programming in c++
Programming in c++Programming in c++
Programming in c++

The document discusses object-oriented programming (OOP) and some of its key concepts. It explains that OOP aims to address flaws in procedural programming by tying data more closely to the functions that operate on it. Some important OOP concepts mentioned include objects, classes, encapsulation, inheritance, polymorphism, and message passing. The document also lists several benefits of OOP like code reuse through inheritance and easier management of complex software. It provides examples of areas where OOP has common applications.

basic concepts in oop
Programming in c++
Programming in c++Programming in c++
Programming in c++

The document discusses object-oriented programming (OOP) and some of its key concepts. It explains that OOP aims to address flaws in procedural programming by tying data more closely to the functions that operate on it. Some important OOP concepts mentioned include objects, classes, encapsulation, inheritance, polymorphism, and message passing. The document also lists several benefits of OOP like code reuse through inheritance and easier management of complex software. It provides examples of areas where OOP has common applications.

object oriented programming
5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx

This document discusses parallel processing and reactive programming. It defines parallel processing as executing multiple processes concurrently using multiple processors to reduce program execution time. Reactive programming is described as having asynchronous data streams that respond non-blockingly to events. The document outlines advantages like improved responsiveness, and disadvantages like increased memory usage of these approaches. It also provides examples of suitable use cases for reactive programming.

Accessing class members State s; s.pos = 1.0; s.vel = -20.0; s.mass = 1000.0; s.landed = false; s.pos = s.pos + s.vel*deltat; Thrust = ComputeThrust(s);  In Matlab introduce structure fields without declaration s.pos = 1.0; s.vel = -20.0; … Thrust = ComputeThrust(s);
Output parameters Image ReadImage(const string filename, bool& flag); bool ReadImage(const string filename, Image& im); Input: filename (type string) Output:  im (type Image)  boolean flag indicating success/failure function [Image, errflag] = ReadImage(filename) Basically the same, but cleaner in Matlab!
Arrays An array is a data structure containing a numbered (indexed) collection of items of a single data type int a[10]; res = a[0] + a[1] + a[2];  Complex z[20]; State s[100]; for (t=1; t<100; t++) { s[t].pos = s[t-1].pos + s[t-1].vel + 0.5*g; s[t].vel = s[t-1].vel + g – GetThrust(s[t-1], burnrate)/s[t-1].mass; s[t].mass = s[t-1].mass – burnrate*escapevel; }
Multi-dimensional arrays double d[10][5]; has elements: d[0][0] d[0][1] … d[0][4] . . . d[9][0] d[9][1] … d[9][4]

Recommended for you

Hardware-Software Codesign
Hardware-Software CodesignHardware-Software Codesign
Hardware-Software Codesign

This presentation is a short introduction to issues in Hardware-Software Codesign. It discusses definition of codesign, its significance, design issues in Hardware-software codesign, Abstraction levels, Duality of harware and software

hardwaresoftwaresocial media
Software Engineering
 Software Engineering  Software Engineering
Software Engineering

This document provides an overview of software engineering concepts including the nature of software, characteristics of software, software application domains, and legacy software. It defines software engineering as a systematic, disciplined, and quantifiable approach for software development, operation, and maintenance. Some key points include: - Software has instructions, data structures, and documentation but is developed not manufactured. - Software doesn't physically wear out over time like hardware. - Most software is still custom built rather than using reusable components. - Major application domains include system software, engineering software, web applications, and artificial intelligence software. - Legacy software evolves over time to meet new requirements and technologies but can be costly and risky to maintain.

nature of softwaresoftware application domains
Computers in management
Computers in managementComputers in management
Computers in management

The document discusses software development life cycle (SDLC) and the various steps involved including requirements analysis, design, coding, testing, and maintenance. It also discusses different types of errors that can occur during software development such as unexpected input values and changes that affect software operations. It then discusses the input-process-output (IPO) cycle and how it relates to batch processing systems and online processing systems. For batch systems, the input data is collected in batches and processed as batches, with no user interaction during processing. For online systems, the user can interact with the system as transactions are processed immediately.

computers in management
Methods In C++ a  class  encapsulates related data and functions A class has both data fields  and  functions that operate on the data A class member function is called a  method  in the object-oriented programming literature
Example class Complex { public: double re, im; double Mag() { return sqrt(re*re + im*im); } double Phase() { return atan2(im, re); } }; Complex z; cout << “Magnitude=“ << z.Mag() << endl;
Constructor Whenever a variable is created (declared), memory space is allocated for it It  might  be initialised int i; int i=10; int i(10); In general this is the work of a  constructor The constructor is a special function with the same name as the class and no return type Complex(double x, double y) { { re = x; im = y; }
Information hiding / encapsulation Principle of encapsulation is that software components hide the internal details of their implementation In procedural programming, treat a function as black boxes with a well-defined interface  Need to avoid side-effects Use these functions as building blocks to create programs In object-oriented programming, a class defines a black box data structure, which has  Public interface Private data Other software components in the program can only access class through well-defined interface, minimising side-effects

Recommended for you

Life & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@PersistentLife & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@Persistent

Dr. Neeran Karnik, Technical Architect BMC Software talks about Life and Work of Prof. Butler Lampson, 1992 Turing Award Recipient

butler lampson
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt

The document discusses object-oriented design principles and patterns. It covers topics like encapsulation, inheritance, polymorphism, the open-closed principle (OCP), dependency inversion, and architectural patterns like layered architectures and domain-driven design. Examples are provided to illustrate concepts like dependency injection and inversion of control. The conclusion emphasizes applying principles pragmatically based on user needs while aiming for maintainable code.

[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES

This presentation is about a lecture I gave within the "Software systems and services" immigration course at the Gran Sasso Science Institute, L'Aquila (Italy): http://cs.gssi.infn.it/. http://www.ivanomalavolta.com

mobilesoftware engineeringsoftware development
Example class Complex { public: Complex(double x, double y) { re=x; im=y; } double Re() { return re; } double Im() { return im; } double Mag() { return sqrt(re*re + im*im);} double Phase() {  return atan2(im, re); } private: double re, im; }; Complex z(10.0,8.0); cout << “Magnitude=“ << z.Mag() << endl; cout << “Real part=“ << z.Re() << endl;
Example class Complex { public: Complex(double x, double y) {  r = sqrt(x*x + y*y); theta = atan2(y,x); } double Re() { return r*cos(theta); } double Im() { return r*sin(theta); } double Mag() { return r;} double Phase() { return theta; } } private: double r, theta; }; Complex z(10.0,8.0); cout << “Magnitude=“ << z.Mag() << endl; cout << “Real part=“ << z.Re() << endl;
C++ program organisation Complex.h class Complex { public: Complex(double x, double y);  double Re(); double Im();  double Mag(); double Phase();  private: double re, im; };
C++ program organisation Complex.cpp #include “Complex.h” Complex::Complex(double x, double y) { re = x; im = y; }  double Complex::Re() { return re; } double Complex::Im() { return im; } double Complex::Mag() {  return sqrt(re*re+im*im);  } double Complex::Phase() { return atan2(im,re); }

Recommended for you

Object-oriented programming An  object  in a programming context is an instance of a class Object-oriented programming  concerns itself primarily with the design of classes and the interfaces between these classes The design stage breaks the problem down into classes and their interfaces OOP also includes two important ideas concerned with hierarchies of objects Inheritance polymorphism
Inheritance Hierarchical relationships often arise between classes Object-oriented design supports this through  inheritance An derived class is one that has the functionality of its “parent” class but with some extra data or methods In C++ class A : public B { … };
Example class Window Data:   width, height posx, posy Methods:  raise(), hide() select(), iconify() class TextWindow Data:   cursor_x, cursor_y Methods:  redraw(), clear()  backspace(), delete() class GraphicsWindow Data:   background_colour Methods:  redraw(), clear() fill() class InteractiveGraphicsWindow Data: Methods:  MouseClick(), MouseDrag()
Polymorphism Polymorphism , Greek for “many forms” One of the most powerful object-oriented concepts Ability to hide alternative implementations behind a common interface Ability of objects of different types to respond in different ways to a similar event Example TextWindow and GraphicsWindow, redraw()

Recommended for you

Implementation In C++ run-time polymorphism implemented via  virtual functions class Window { … virtual void redraw(); };
Example Class A is base class, B and C both inherit from A If the object is of type A then call A’s func() If the object is of type B then call B’s func() If the object is of type C then call C’s func() If class A defines func() as virtual void func() = 0; then A has no implementation of func() class A is then an  abstract base class   It is not possible to create an instance of class A, only instances derived classes, B and C class A defines an  interface  to which all derived classes must conform Use this idea in designing program components Specify interface, then have a guarantee of compatibility of all derived objects
Another example Consider a vector graphics drawing package Consider base class “Drawable” A graphics object that knows how to draw itself on the screen Class hierarchy may comprise lines, curves, points, images, etc Program keeps a list of objects that have been created and on redraw, displays them one by one This is implemented easily by a loop  for (int i=0; i<N; i++) { obj[i]->Draw(); }
Templates Templating is a mechanism in C++ to create classes in which one or more types are  parameterised Example of  compile-time  polymnorphism class BoundedArray { public: float GetElement(int i) {  if (i<0 || i>=10) { cerr << “Access out of bounds”; return 0.0; } else { return a[i]; } } private: float a[10]; };

Recommended for you

Templates template <class Type> class BoundedArray { public: Type GetElement(int i) {  if (i<0 || i>=10) { cerr << “Access out of bounds”; return Type(0); } else { return a[i]; } } private: Type a[10]; }; BoundedArray<int> x; BoundedArray<Complex> z;
Design patterns Programs regularly employ similar design solutions Idea is to standardise the way these are implemented Code re-use Increased reliability Fewer errors, shorter development time An array is special case of a  container type Way of storing a collection of possibly ordered elements. List, stack, queue, double-ended list, etc Templates in C++ offer a way of providing libraries to implement these standard containers
Standard Template Library C++ provides a set of container classes Standard way of representing and manipulating container types eg, methods insert(),  append(), size(), etc STL supports Stack (FILO structure) List (efficient insertion and deletion, ordered but not indexed) Vector (extendible array) others
STL example std::vector<Type>  is an extendible array It can increase its size as the program needs it to It can be accessed like an ordinary array (eg  v[2] ) It can report its current size v.size() You can add an item to the end without needing to know how big it is v.push_back(x) #include<vector> int main() { std::vector<int> v; for (int i=0; i<20; i++) v.push_back(i); for (int i=0; i<v.size(); i++) std::cout << v[i] << std::endl; }

Recommended for you

STL, continued To create a new STL vector of a size specified at  run-time int size; std::vector<Complex> z; std::cin >> size; z.resize(size); z[5] = Complex(2.0,3.0);
STL, continued To create a two dimensional array at  run-time int width, height; std::vector< std::vector<int> > x; x.resisze(height); for (int i=0; i<height; i++) x[i].resize(width); x[2][3] = 10; …
Iterators A standard thing to want to do with a collection of data elements is to iterate over each for (int i=0; i<v.size(); i++) Not all container types support indexing A linked list has order, but only  relative order An  iterator  is a class that supports the standard programming pattern of iterating over a container type std::vector<int> v; std::vector<int>::iterator i; for (it=v.begin(); it!=v.end(); it++) … An iterator encapsulates the internal structure of how the iteration occurs
Complete example Design a program to compute a maze User-specified size  Print it out at the end Algorithm Mark all cells unvisited Choose a start cell While current cell has unvisited neighbours  Choose one at random Break wall between it and current cell Recursively enter the chosen cell

Recommended for you

Design data structures Maze class Compute method Print method Two dimensional array of Cells Cell class Accessor methods Break wall methods Wall flags Visited flag
Cell class interface class Cell {   public:   Cell();   bool Visited();    void MarkVisited();   bool BottomWall();   bool RightWall();   void BreakBottom();   void BreakRight(); private:   bool bottomwall;   bool rightwall;   bool visited; };
Maze class interface class Maze { public: Maze(int width, int height); void Compute(int x, int y); void Print(); private: int Rand(int n); int H, W; std::vector< std::vector<Cell> > cells; };
Main program int main(int argc, char* argv[]) { int width, height; cerr << &quot;Enter maze width: &quot;; cin >> width; cerr << &quot;Enter maze height: &quot;; cin >> height; Maze m(width, height); m.Compute(height-1,0); m.Print(); return 0; }

Recommended for you

Concept summary Top-down design Abstraction Encapsulation / information hiding Modularity Functions Classes / objects Inheritance Polymorphism Templates Patterns Exam questions?  See tute sheet.

More Related Content

What's hot

The role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture DescriptionsThe role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture Descriptions
Henry Muccini
 
Software Architecture: Introduction to the Abstraction
Software Architecture: Introduction to the AbstractionSoftware Architecture: Introduction to the Abstraction
Software Architecture: Introduction to the Abstraction
Henry Muccini
 
Computer Oraganisation and Architecture
Computer Oraganisation and ArchitectureComputer Oraganisation and Architecture
Computer Oraganisation and Architecture
yogesh1617
 
Integrating profiling into mde compilers
Integrating profiling into mde compilersIntegrating profiling into mde compilers
Integrating profiling into mde compilers
ijseajournal
 
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENTTHE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
ijseajournal
 
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
IJSEA
 
Software Engineering: What is That?
Software Engineering: What is That?Software Engineering: What is That?
Software Engineering: What is That?
Henry Muccini
 
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISONSTATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
ijseajournal
 
Introduction to networks simulation
Introduction to networks simulationIntroduction to networks simulation
Introduction to networks simulation
ahmed L. Khalaf
 
01_Program
01_Program01_Program
01_Program
Emmanuel Fuchs
 
Is There a Return on Investment from Model-Based Systems Engineering?
Is There a Return on Investment from Model-Based Systems Engineering?Is There a Return on Investment from Model-Based Systems Engineering?
Is There a Return on Investment from Model-Based Systems Engineering?
Elizabeth Steiner
 
Looking Forwards to Going Backwards
Looking Forwards to Going BackwardsLooking Forwards to Going Backwards
Looking Forwards to Going Backwards
Jonathan Francis Roscoe
 
On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...
University of l'aquila
 
Programming and problem solving with c++, 3rd edition
Programming and problem solving with c++, 3rd editionProgramming and problem solving with c++, 3rd edition
Programming and problem solving with c++, 3rd edition
Indian Maritime University, Visakhapatnam
 
Software concepts ppt
Software concepts pptSoftware concepts ppt
Software concepts ppt
Prof. Dr. K. Adisesha
 
Program design and problem solving techniques
Program design and problem solving techniquesProgram design and problem solving techniques
Program design and problem solving techniques
Dokka Srinivasu
 
J044084349
J044084349J044084349
J044084349
IJERA Editor
 
Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012
Neelamani Samal
 
A tlm based platform to specify and verify component-based real-time systems
A tlm based platform to specify and verify component-based real-time systemsA tlm based platform to specify and verify component-based real-time systems
A tlm based platform to specify and verify component-based real-time systems
ijseajournal
 
COCOMO methods for software size estimation
COCOMO methods for software size estimationCOCOMO methods for software size estimation
COCOMO methods for software size estimation
Pramod Parajuli
 

What's hot (20)

The role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture DescriptionsThe role of MDE in Software Architecture Descriptions
The role of MDE in Software Architecture Descriptions
 
Software Architecture: Introduction to the Abstraction
Software Architecture: Introduction to the AbstractionSoftware Architecture: Introduction to the Abstraction
Software Architecture: Introduction to the Abstraction
 
Computer Oraganisation and Architecture
Computer Oraganisation and ArchitectureComputer Oraganisation and Architecture
Computer Oraganisation and Architecture
 
Integrating profiling into mde compilers
Integrating profiling into mde compilersIntegrating profiling into mde compilers
Integrating profiling into mde compilers
 
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENTTHE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
THE UNIFIED APPROACH FOR ORGANIZATIONAL NETWORK VULNERABILITY ASSESSMENT
 
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
STRUCTURAL VALIDATION OF SOFTWARE PRODUCT LINE VARIANTS: A GRAPH TRANSFORMATI...
 
Software Engineering: What is That?
Software Engineering: What is That?Software Engineering: What is That?
Software Engineering: What is That?
 
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISONSTATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
STATISTICAL ANALYSIS FOR PERFORMANCE COMPARISON
 
Introduction to networks simulation
Introduction to networks simulationIntroduction to networks simulation
Introduction to networks simulation
 
01_Program
01_Program01_Program
01_Program
 
Is There a Return on Investment from Model-Based Systems Engineering?
Is There a Return on Investment from Model-Based Systems Engineering?Is There a Return on Investment from Model-Based Systems Engineering?
Is There a Return on Investment from Model-Based Systems Engineering?
 
Looking Forwards to Going Backwards
Looking Forwards to Going BackwardsLooking Forwards to Going Backwards
Looking Forwards to Going Backwards
 
On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...On the Use of Component-Based Principles and Practices for Architecting Cyber...
On the Use of Component-Based Principles and Practices for Architecting Cyber...
 
Programming and problem solving with c++, 3rd edition
Programming and problem solving with c++, 3rd editionProgramming and problem solving with c++, 3rd edition
Programming and problem solving with c++, 3rd edition
 
Software concepts ppt
Software concepts pptSoftware concepts ppt
Software concepts ppt
 
Program design and problem solving techniques
Program design and problem solving techniquesProgram design and problem solving techniques
Program design and problem solving techniques
 
J044084349
J044084349J044084349
J044084349
 
Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012Software Engineering Sample Question paper for 2012
Software Engineering Sample Question paper for 2012
 
A tlm based platform to specify and verify component-based real-time systems
A tlm based platform to specify and verify component-based real-time systemsA tlm based platform to specify and verify component-based real-time systems
A tlm based platform to specify and verify component-based real-time systems
 
COCOMO methods for software size estimation
COCOMO methods for software size estimationCOCOMO methods for software size estimation
COCOMO methods for software size estimation
 

Viewers also liked

Aansprakelijkheid van de zzp-er
Aansprakelijkheid van de zzp-erAansprakelijkheid van de zzp-er
Aansprakelijkheid van de zzp-er
Höcker Advocaten
 
A2 advanced portfolio_production_diary_template
A2 advanced portfolio_production_diary_templateA2 advanced portfolio_production_diary_template
A2 advanced portfolio_production_diary_template
OliviaLyons
 
Reservoir Project - Digibiz 2009, M.Lindner
Reservoir Project - Digibiz 2009, M.LindnerReservoir Project - Digibiz 2009, M.Lindner
Reservoir Project - Digibiz 2009, M.Lindner
Digibiz'09 Conference
 
Sportrons overview
Sportrons overviewSportrons overview
Sportrons overview
Chase Daddy
 
Tutorial Passaporte
Tutorial PassaporteTutorial Passaporte
Mapa research brochure-swe-sharedealing-dashboard
Mapa research brochure-swe-sharedealing-dashboardMapa research brochure-swe-sharedealing-dashboard
Mapa research brochure-swe-sharedealing-dashboard
Mapa International Limited
 
4squares
4squares4squares
4squares
tulineel
 
Social media-101-presentation
Social media-101-presentationSocial media-101-presentation
Social media-101-presentation
aja1973
 

Viewers also liked (8)

Aansprakelijkheid van de zzp-er
Aansprakelijkheid van de zzp-erAansprakelijkheid van de zzp-er
Aansprakelijkheid van de zzp-er
 
A2 advanced portfolio_production_diary_template
A2 advanced portfolio_production_diary_templateA2 advanced portfolio_production_diary_template
A2 advanced portfolio_production_diary_template
 
Reservoir Project - Digibiz 2009, M.Lindner
Reservoir Project - Digibiz 2009, M.LindnerReservoir Project - Digibiz 2009, M.Lindner
Reservoir Project - Digibiz 2009, M.Lindner
 
Sportrons overview
Sportrons overviewSportrons overview
Sportrons overview
 
Tutorial Passaporte
Tutorial PassaporteTutorial Passaporte
Tutorial Passaporte
 
Mapa research brochure-swe-sharedealing-dashboard
Mapa research brochure-swe-sharedealing-dashboardMapa research brochure-swe-sharedealing-dashboard
Mapa research brochure-swe-sharedealing-dashboard
 
4squares
4squares4squares
4squares
 
Social media-101-presentation
Social media-101-presentationSocial media-101-presentation
Social media-101-presentation
 

Similar to Software engineering

Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation
the_wumberlog
 
Parallel Computing 2007: Overview
Parallel Computing 2007: OverviewParallel Computing 2007: Overview
Parallel Computing 2007: Overview
Geoffrey Fox
 
The Concurrency Challenge : Notes
The Concurrency Challenge : NotesThe Concurrency Challenge : Notes
The Concurrency Challenge : Notes
Subhajit Sahu
 
Ch01lect1 et
Ch01lect1 etCh01lect1 et
Ch01lect1 et
AhmedHassanHaji1
 
Management of Complexity in System Design of Large IT Solutions
Management of Complexity in System Design of Large IT SolutionsManagement of Complexity in System Design of Large IT Solutions
Management of Complexity in System Design of Large IT Solutions
Michael Heiss
 
Software engineering
Software engineeringSoftware engineering
Software engineering
Rohan Bhatkar
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Mit104 software engineering
Mit104  software engineeringMit104  software engineering
Mit104 software engineering
smumbahelp
 
01 the big_idea
01 the big_idea01 the big_idea
01 the big_idea
Majong DevJfu
 
Managing Complexity and Change with Scalable Software Design
Managing Complexity and Change with Scalable Software DesignManaging Complexity and Change with Scalable Software Design
Managing Complexity and Change with Scalable Software Design
lbergmans
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development
Jignesh Patel
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
sujathavvv
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
MalarMohana
 
5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx
MohamedBilal73
 
Hardware-Software Codesign
Hardware-Software CodesignHardware-Software Codesign
Hardware-Software Codesign
Sudhanshu Janwadkar
 
Software Engineering
 Software Engineering  Software Engineering
Software Engineering
JayaKamal
 
Computers in management
Computers in managementComputers in management
Computers in management
Kinshook Chaturvedi
 
Life & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@PersistentLife & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@Persistent
Persistent Systems Ltd.
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
 
[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES
Ivano Malavolta
 

Similar to Software engineering (20)

Lecture 1 uml with java implementation
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation
 
Parallel Computing 2007: Overview
Parallel Computing 2007: OverviewParallel Computing 2007: Overview
Parallel Computing 2007: Overview
 
The Concurrency Challenge : Notes
The Concurrency Challenge : NotesThe Concurrency Challenge : Notes
The Concurrency Challenge : Notes
 
Ch01lect1 et
Ch01lect1 etCh01lect1 et
Ch01lect1 et
 
Management of Complexity in System Design of Large IT Solutions
Management of Complexity in System Design of Large IT SolutionsManagement of Complexity in System Design of Large IT Solutions
Management of Complexity in System Design of Large IT Solutions
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13
 
Mit104 software engineering
Mit104  software engineeringMit104  software engineering
Mit104 software engineering
 
01 the big_idea
01 the big_idea01 the big_idea
01 the big_idea
 
Managing Complexity and Change with Scalable Software Design
Managing Complexity and Change with Scalable Software DesignManaging Complexity and Change with Scalable Software Design
Managing Complexity and Change with Scalable Software Design
 
Aspect Oriented Software Development
Aspect Oriented Software DevelopmentAspect Oriented Software Development
Aspect Oriented Software Development
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx5.7 Parallel Processing - Reactive Programming.pdf.pptx
5.7 Parallel Processing - Reactive Programming.pdf.pptx
 
Hardware-Software Codesign
Hardware-Software CodesignHardware-Software Codesign
Hardware-Software Codesign
 
Software Engineering
 Software Engineering  Software Engineering
Software Engineering
 
Computers in management
Computers in managementComputers in management
Computers in management
 
Life & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@PersistentLife & Work of Butler Lampson | Turing100@Persistent
Life & Work of Butler Lampson | Turing100@Persistent
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES[2015/2016] Software systems engineering PRINCIPLES
[2015/2016] Software systems engineering PRINCIPLES
 

Software engineering

  • 1. Software Engineering Dr Ian Reid B4, 4 lectures, Hilary Term http://www.robots.ox.ac.uk/~ian/Teaching/SoftEng
  • 2. Software Engineering vs structured programming Not really a course about software engineering… Software engineering Mostly about concepts, Structured programming Revision, coding in C and Matlab, functions Data structures structures, classes Object oriented programming objects, object-oriented concepts like inheritance, polymorphism, patterns and the standard template library
  • 3. Learning Outcomes The course will aim to give a good understanding of basic design methods, and emphasize the need to produce well-structured maintainable computer software. The course will concentrate on principles, but these will be reinforced with examples in Matlab and C/C++ programming languages. Specifically, by the end of the course students should : understand concepts of basic program design techniques that can be applied to a variety of programming languages, in particular Matlab and C/C++ understand the need for structured programming in software projects be able to recognise and to produce and/or maintain well structured programs have a basic understanding of the role of and advantages of object oriented design
  • 4. Texts Sommerville, Software Engineering , Addison-Wesley (8 th edition), 2007. Wirth, Algorithms + Data Structures = Programs , Prentice-Hall, 1975 Leveson, Safeware: System Safety and Computers , Addison-Wesley, 1995. Lipmann and Lajoie, C++ Primer, Addison-Wesley, 2005. Goodrich et al., Data structures and algorithms in C++ , Wiley, 2004
  • 5. The Role of Computing in Engineering Computing is ubiquitous in engineering. Why? Awesome speed of modern, everyday computers a makes complicated analysis and simulation possible across all domains. Applications in design and modelling. Far beyond the reach of the mortal human engineer. Indeed many modelling problems are utterly infeasible without modern computers and software. In embedded systems, computers can provide a level of power, speed, flexibility and control not otherwise possible (eg mobile phone) Computing is “cheap” (but exercise this argument with care) Software is the key… some examples…
  • 6. Example: mobile phone Even simple mobile phones rely on software Typical phone has a microcontroller (SIM card) with a small program Drive GUI Control devices (keypad, microphone, a/d, dsp, decoder)
  • 7. Example: Sizewell B Nuclear power station (PWR), onstream in 1995 Software used extensively in the design Software for control! first UK reactor to use software in its Primary Protection System)
  • 8. Example: A380 A380 1400 separate programs There is a software project just to manage all the software! Clearly safety-critical features of the software
  • 9. Example: NPfIT NHS National Plan for IT Plan to provide electronic care records for patients Connect 30000 GPs and 300 hospitals Provide secure access to records for healthcare professionals Provide access for patients to their own records via “Healthspace”
  • 10. Software engineering versus programming Software engineering is about more than just programming/coding It is about design principles and methodologies that yield programs that are Robust Manageable Reusable
  • 11. Software vs “other” engineering How is software engineering similar to other engineering? Abstraction and Modularity Consider free-body diagram Thevenin/Norton Low output impedance / High input impedance Digital computer We return to these concepts later…
  • 13. Modularity: Op-amp buffer Unity gain buffer Vout = Vin Very high input impedance, very low output impedance + - In Out
  • 14. Software vs “other” engineering How is software different to other engineering? Pure, weightless, flexible Capacity to incorporate massive complexity No manufacturing defects, corrosion, aging
  • 15. Intrinsic difficulties with software Analogue versus discrete state systems The “curse” of flexibility Can encourage unnecessary complexity Redefinition of tasks late in development – shifting goal-post Complexity and invisible interfaces Standard way of dealing with complexity is via modularity But this alone is not enough because interfaces can be subtle and invisible, and here too there is a need to control complexity Historical usage information Unlike physical systems, there is a limited amount of experience about standard designs
  • 16. When software projects go wrong A320, Habsheim and Strasbourg
  • 17. When software projects go wrong London Ambulance Service 1992, computerised ambulance despatch system fails Therac-25 2 people died and several others exposed to dangerous levels of radiation because of software flaws in radiotherapy device OSIRIS £5M University financial package Expenditure to date more like £20-25M NPfIT? NHS £12 billion IT project comp.risks is a great source of others...
  • 18. NHS National programme for IT: NPfIT Plan to provide electronic care records for patients Connect 30000 GPs and 300 hospitals Provide secure access to records for healthcare professionals Provide access for patients to their own records via “Healthspace” Laudable? Realistic? Software Engineering specialists have their doubts Ross Anderson (Prof of Security Engineering, Cambridge Computing Laboratory) wrtes in his blog “I fear the whole project will just continue on its slow slide towards becoming the biggest IT disaster ever”.
  • 19. Software life-cycle Software development stages Specification Design Implementation Integration Validation Operation/Maintenance/Evolution Different types of system organise these generic activities in different ways Waterfall approach treats them as distinct stages to be signed off chronologically In practice usually an iteration of various steps
  • 20. Requirements Vague initial goals Iterative refinement Leading to more precise specification Example Calculate the n-bounce trajectory of a lossy bouncing ball. Refine this to consider What does the statement actually mean? Physics Initial conditions Air-resistance? Stopping criterion (criteria)? Now, think about how to design/implement
  • 21. Validation/Verification Verification: does the system confirm to spec? Validation: does it actually do what it was supposed to? Top-down vs bottom-up testing Black-box vs white-box testing Impossibility of exhaustive testing
  • 22. Extreme programming (XP) Proposed in the late 90s as a reaction to problems with “traditional” development processes Takes extreme position compared with waterfall approach Appropriate for small-medium sized projects Teams of pairs of programmer, programming together Incremental development, frequent system releases Code constantly refined, improved, made as simple as possible Do not design for change; instead change reactively
  • 23. Top down design Here want to keep in mind the general principles Abstraction Modularity Architectural design: identifying the building blocks Abstract specification: describe the data/functions and their constraints Interfaces: define how the modules fit together Component design: recursively design each block
  • 24. Modular design Procedural programming: focus on algorithms Object-oriented programming: focus on data structures Algorithms Data structures Programs
  • 25. Structured programming Top-down vs bottom-up Both are useful as a means to understand the relations between high-level and low-level views of a program Top-down Code high level parts using “stubs” with assumed functionality for low-level dependencies Iteratively descend to lower-level modules Bottom-up Code and test each low-level component Need “test harness” so that low-level can be tested in its correct context Integrate components Not hard-fast rules; combination often best
  • 26. Simple design tools Flow chart Pseudo-code Wait for alarm Count = 1 While (not ready to get up and count <= 3) Hit snooze button Increment count Climb out of bed
  • 27. Data flows Data flow diagram Simple example, VTOL simulator Controller Simulator Display state state thrust
  • 28. Simple design tools State diagram
  • 29. Basic coding techniques Pretty much any program can be specified using: Sequences of instructions { Do A; Do B; Do C } Conditional instructions If (condition) Do A Repetitions (loops) While (condition) Do A These semantic concepts are implemented in different high-level programming languages using different syntax
  • 30. Implementation in Matlab and C N= 10; tot = 0; totsq = 0; for i=1:N tot = tot+i; totsq = totsq+i^2; end tot totsq int i; int tot = 0; int totsq = 0; for (i=1; i<N; i++) { tot += i; totsq += i*i; } cout << tot << endl; cout << totsq << endl;
  • 31. Notes on coding style Use meaningful variable names Use comments to supplement the meaning Indent code for each block/loop Encapsulate groups of statements sensibly in functions Encapsulate related data sensibly in data structures Design top down Code bottom-up or top-down, or a combination
  • 32. Matlab vs C Matlab and C are both procedural languages Matlab is an interpreted language each statement decoded and executed in turn C is a compiled language each module (.c file) is converted into assembly language The interfaces between the modules are Shared global data Function calls from one module to another This is resolved at link time when the modules are linked together into an executable
  • 33. Procedural programming Aim is to break program down into functional units procedures or functions Set of inputs, set of outputs In Matlab and C this procedural building block is the function Understanding functions…
  • 34. Organisation of Matlab programs A Matlab “program” may be a script or function i.e. a sequence of instructions This script or function will typically call a bunch of other functions Functions are stored in .m files Multiple functions can be stored in one .m file, but only first is visible outside The others are local functions Part of the recursive subdivision of the problem
  • 35. Matlab file organisation bar FUNC.m foo.m bar.m FUNC foo
  • 36. Organisation of C programs Source code .c .cc Object file .o compilation Source code .c .cc Object file .o compilation … .. … .. linking executable
  • 37. Functions Function definition Function call Function prototype Scope (local versus global data) Parameters and return value(s) Function call Low-level implementation of function calls Recursion
  • 38. Function definition % compute factorial function z = fact(n) % function body z = 1; for i=1:n z = z*i; end // compute factorial int fact(int n) { int i, val = 1; for (i=1; i<=n; i++) { val *= i; } return val; }
  • 39. Function call Distinguish between The function definition Defines the set of operations that will be executed when the function is called The inputs The outputs And the function call i.e. actually using the function Formal vs Actual parameters Return value(s) The value of a function evaluation is the return value fact(10) a = 6; z = fact(a); [V,D] = eig(A);
  • 40. Function prototype The function prototype provides enough information to the compiler so that it can check that it is being called correctly Defines the interface Input (parameter), output (return value) myexp.c file float myexp(float x) { const float precision = 1.0e-6; float term=1.0, res=0.0; int i=0; while (fabs(term)>precision) { res += term; i++; term = pow(x,i)/fact(i); } return res; } myexp.h file float myexp(float x);
  • 41. Scope: local variables Variables which are declared inside a function are local variables They cannot be “seen” outside the function (block) in which they are declared A local variable exists only for the duration of the current function execution It is declared as a new variable every time the function is called It ceases to exist when the function returns It does not “remember” its value between calls
  • 42. Scope: global variables Global variables exist outside all functions A global variable is visible inside functions If there exist two variables, one local, one global, with the same name, then the local one takes precedence within its local scope C and Matlab behave differently C will use a global if no local exists Matlab only uses a global if the programmer explicitly requests it Globals should be used with caution because their use inside a function compromises its encapsulation
  • 43. Encapsulation Want the function to behave in the same way for the same inputs encapsulate particular functional relationship But if the function depends on a global it could behave differently for the same inputs Live example using myexp
  • 44. Function encapsulation Input parameters Output values Hidden input Input parameters Output values Hidden output
  • 45. Side-effects Could set value of a global variable in a function Again this compromises the function’s encapsulation Causes a side-effect An implicit output, not captured by the interface Makes it difficult to re-use code with confidence c.f. C and Matlab function libraries Set of re-usable routines with well defined interfaces In small projects maybe not a big problem Hugely problematic in bigger projects, especially when multiple programmers working as a team Complicates interfaces between components, possibly in unintended ways
  • 46. Low-level implementation of function call Memory CODE DATA machine code global variables STACK local variable m local variable 1 return location return value n return value 1 parameter x parameter 1 … … … Activation record
  • 47. Pass by value/reference int i=5, j=10; swap(i,j); cout << i << “ “ << j << endl; Pass by value Pass by reference void swap(int a, int b) { int temp = a; a = b; b = temp; return; } void swap(int& a, int& b) { int temp = a; a = b; b = temp; return; }
  • 48. Recursion Recursion is the programming analogue of induction: If p(0) and p(n) implies p(n+1) Then p(n) for all n Define a function in terms of Itself Boundary conditions For example Factorial: n! = n * (n-1)!, 0! = 1
  • 50. Data types and data structures C/C++ predefine a set of atomic types bool, char, int, float, double C/C++ provides machanism for building compound data structures struct (class) Array Matlab supports arrays/matrices (of course) Matlab also supports structures
  • 51. A class (struct in C) is a compound data type which encapsulates related data into a single entity class Complex { public: double re, im; }; Defines how a variable of this type will look int i; Complex z; C/C++: struct and class Class definition Create a variable (an instance) of this type
  • 52. Example: VTOL state Represent current state as, say, a triple of numbers and a bool, (position, velocity, mass, landed) Single variable represents all numbers Better abstraction! class State { double pos, vel, mass; bool landed; }; State s; Controller Simulator Display state state thrust
  • 53. Accessing class members State s; s.pos = 1.0; s.vel = -20.0; s.mass = 1000.0; s.landed = false; s.pos = s.pos + s.vel*deltat; Thrust = ComputeThrust(s); In Matlab introduce structure fields without declaration s.pos = 1.0; s.vel = -20.0; … Thrust = ComputeThrust(s);
  • 54. Output parameters Image ReadImage(const string filename, bool& flag); bool ReadImage(const string filename, Image& im); Input: filename (type string) Output: im (type Image) boolean flag indicating success/failure function [Image, errflag] = ReadImage(filename) Basically the same, but cleaner in Matlab!
  • 55. Arrays An array is a data structure containing a numbered (indexed) collection of items of a single data type int a[10]; res = a[0] + a[1] + a[2]; Complex z[20]; State s[100]; for (t=1; t<100; t++) { s[t].pos = s[t-1].pos + s[t-1].vel + 0.5*g; s[t].vel = s[t-1].vel + g – GetThrust(s[t-1], burnrate)/s[t-1].mass; s[t].mass = s[t-1].mass – burnrate*escapevel; }
  • 56. Multi-dimensional arrays double d[10][5]; has elements: d[0][0] d[0][1] … d[0][4] . . . d[9][0] d[9][1] … d[9][4]
  • 57. Methods In C++ a class encapsulates related data and functions A class has both data fields and functions that operate on the data A class member function is called a method in the object-oriented programming literature
  • 58. Example class Complex { public: double re, im; double Mag() { return sqrt(re*re + im*im); } double Phase() { return atan2(im, re); } }; Complex z; cout << “Magnitude=“ << z.Mag() << endl;
  • 59. Constructor Whenever a variable is created (declared), memory space is allocated for it It might be initialised int i; int i=10; int i(10); In general this is the work of a constructor The constructor is a special function with the same name as the class and no return type Complex(double x, double y) { { re = x; im = y; }
  • 60. Information hiding / encapsulation Principle of encapsulation is that software components hide the internal details of their implementation In procedural programming, treat a function as black boxes with a well-defined interface Need to avoid side-effects Use these functions as building blocks to create programs In object-oriented programming, a class defines a black box data structure, which has Public interface Private data Other software components in the program can only access class through well-defined interface, minimising side-effects
  • 61. Example class Complex { public: Complex(double x, double y) { re=x; im=y; } double Re() { return re; } double Im() { return im; } double Mag() { return sqrt(re*re + im*im);} double Phase() { return atan2(im, re); } private: double re, im; }; Complex z(10.0,8.0); cout << “Magnitude=“ << z.Mag() << endl; cout << “Real part=“ << z.Re() << endl;
  • 62. Example class Complex { public: Complex(double x, double y) { r = sqrt(x*x + y*y); theta = atan2(y,x); } double Re() { return r*cos(theta); } double Im() { return r*sin(theta); } double Mag() { return r;} double Phase() { return theta; } } private: double r, theta; }; Complex z(10.0,8.0); cout << “Magnitude=“ << z.Mag() << endl; cout << “Real part=“ << z.Re() << endl;
  • 63. C++ program organisation Complex.h class Complex { public: Complex(double x, double y); double Re(); double Im(); double Mag(); double Phase(); private: double re, im; };
  • 64. C++ program organisation Complex.cpp #include “Complex.h” Complex::Complex(double x, double y) { re = x; im = y; } double Complex::Re() { return re; } double Complex::Im() { return im; } double Complex::Mag() { return sqrt(re*re+im*im); } double Complex::Phase() { return atan2(im,re); }
  • 65. Object-oriented programming An object in a programming context is an instance of a class Object-oriented programming concerns itself primarily with the design of classes and the interfaces between these classes The design stage breaks the problem down into classes and their interfaces OOP also includes two important ideas concerned with hierarchies of objects Inheritance polymorphism
  • 66. Inheritance Hierarchical relationships often arise between classes Object-oriented design supports this through inheritance An derived class is one that has the functionality of its “parent” class but with some extra data or methods In C++ class A : public B { … };
  • 67. Example class Window Data: width, height posx, posy Methods: raise(), hide() select(), iconify() class TextWindow Data: cursor_x, cursor_y Methods: redraw(), clear() backspace(), delete() class GraphicsWindow Data: background_colour Methods: redraw(), clear() fill() class InteractiveGraphicsWindow Data: Methods: MouseClick(), MouseDrag()
  • 68. Polymorphism Polymorphism , Greek for “many forms” One of the most powerful object-oriented concepts Ability to hide alternative implementations behind a common interface Ability of objects of different types to respond in different ways to a similar event Example TextWindow and GraphicsWindow, redraw()
  • 69. Implementation In C++ run-time polymorphism implemented via virtual functions class Window { … virtual void redraw(); };
  • 70. Example Class A is base class, B and C both inherit from A If the object is of type A then call A’s func() If the object is of type B then call B’s func() If the object is of type C then call C’s func() If class A defines func() as virtual void func() = 0; then A has no implementation of func() class A is then an abstract base class It is not possible to create an instance of class A, only instances derived classes, B and C class A defines an interface to which all derived classes must conform Use this idea in designing program components Specify interface, then have a guarantee of compatibility of all derived objects
  • 71. Another example Consider a vector graphics drawing package Consider base class “Drawable” A graphics object that knows how to draw itself on the screen Class hierarchy may comprise lines, curves, points, images, etc Program keeps a list of objects that have been created and on redraw, displays them one by one This is implemented easily by a loop for (int i=0; i<N; i++) { obj[i]->Draw(); }
  • 72. Templates Templating is a mechanism in C++ to create classes in which one or more types are parameterised Example of compile-time polymnorphism class BoundedArray { public: float GetElement(int i) { if (i<0 || i>=10) { cerr << “Access out of bounds”; return 0.0; } else { return a[i]; } } private: float a[10]; };
  • 73. Templates template <class Type> class BoundedArray { public: Type GetElement(int i) { if (i<0 || i>=10) { cerr << “Access out of bounds”; return Type(0); } else { return a[i]; } } private: Type a[10]; }; BoundedArray<int> x; BoundedArray<Complex> z;
  • 74. Design patterns Programs regularly employ similar design solutions Idea is to standardise the way these are implemented Code re-use Increased reliability Fewer errors, shorter development time An array is special case of a container type Way of storing a collection of possibly ordered elements. List, stack, queue, double-ended list, etc Templates in C++ offer a way of providing libraries to implement these standard containers
  • 75. Standard Template Library C++ provides a set of container classes Standard way of representing and manipulating container types eg, methods insert(), append(), size(), etc STL supports Stack (FILO structure) List (efficient insertion and deletion, ordered but not indexed) Vector (extendible array) others
  • 76. STL example std::vector<Type> is an extendible array It can increase its size as the program needs it to It can be accessed like an ordinary array (eg v[2] ) It can report its current size v.size() You can add an item to the end without needing to know how big it is v.push_back(x) #include<vector> int main() { std::vector<int> v; for (int i=0; i<20; i++) v.push_back(i); for (int i=0; i<v.size(); i++) std::cout << v[i] << std::endl; }
  • 77. STL, continued To create a new STL vector of a size specified at run-time int size; std::vector<Complex> z; std::cin >> size; z.resize(size); z[5] = Complex(2.0,3.0);
  • 78. STL, continued To create a two dimensional array at run-time int width, height; std::vector< std::vector<int> > x; x.resisze(height); for (int i=0; i<height; i++) x[i].resize(width); x[2][3] = 10; …
  • 79. Iterators A standard thing to want to do with a collection of data elements is to iterate over each for (int i=0; i<v.size(); i++) Not all container types support indexing A linked list has order, but only relative order An iterator is a class that supports the standard programming pattern of iterating over a container type std::vector<int> v; std::vector<int>::iterator i; for (it=v.begin(); it!=v.end(); it++) … An iterator encapsulates the internal structure of how the iteration occurs
  • 80. Complete example Design a program to compute a maze User-specified size Print it out at the end Algorithm Mark all cells unvisited Choose a start cell While current cell has unvisited neighbours Choose one at random Break wall between it and current cell Recursively enter the chosen cell
  • 81. Design data structures Maze class Compute method Print method Two dimensional array of Cells Cell class Accessor methods Break wall methods Wall flags Visited flag
  • 82. Cell class interface class Cell { public: Cell(); bool Visited(); void MarkVisited(); bool BottomWall(); bool RightWall(); void BreakBottom(); void BreakRight(); private: bool bottomwall; bool rightwall; bool visited; };
  • 83. Maze class interface class Maze { public: Maze(int width, int height); void Compute(int x, int y); void Print(); private: int Rand(int n); int H, W; std::vector< std::vector<Cell> > cells; };
  • 84. Main program int main(int argc, char* argv[]) { int width, height; cerr << &quot;Enter maze width: &quot;; cin >> width; cerr << &quot;Enter maze height: &quot;; cin >> height; Maze m(width, height); m.Compute(height-1,0); m.Print(); return 0; }
  • 85. Concept summary Top-down design Abstraction Encapsulation / information hiding Modularity Functions Classes / objects Inheritance Polymorphism Templates Patterns Exam questions? See tute sheet.