CSE 466 – Spring 2000 - Introduction - 1 5. Implement Safety – Safe Software Language Features Type and Range Safe Systems Exception Handling Re-use, Encapsulation.

Slides:



Advertisements
Similar presentations
Exceptions: when things go wrong. Various sources of error public static doSomething() { int i = 3.0; while(!done); { int i = false } ) Syntactic errors.
Advertisements

C++ Programming Languages
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 13 Exception Handling.
Exceptions and Exception Handling Carl Alphonce CSE116 March 9, 2007.
Exceptions1 Syntax, semantics, and pragmatics. Exceptions2 Syntax, semantics, pragmatics Syntax –How it looks, i.e. how we have to program to satisfy.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
ADA Langage Report Ligia Nitu. Introduction Ada is the most extensive and expensive computer language ever developed. Ada is the most extensive and expensive.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 17 Exceptions and.
CSE 466 – Fall Introduction - 1 Design for Safety 1.Hazard Identification and Fault Tree Analysis 2.Risk Assessment 3.Define Safety Measures 4.Create.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Extensibility, Safety and Performance in the SPIN Operating System Bershad et al Presentation by norm Slides shamelessly “borrowed” from Stefan Savage’s.
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Exceptions. Errors and Exceptions An error is a bug in your program –dividing by zero –going outside the bounds of an array –trying to use a null reference.
Interfaces. In this class, we will cover: What an interface is Why you would use an interface Creating an interface Using an interface Cloning an object.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Introduction to Java Chapter 11 Error Handling. Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle.
Ranga Rodrigo. Class is central to object oriented programming.
CS203 Java Object Oriented Programming Errors and Exception Handling.
PRAGMATIC PARANOIA Steven Hadfield & Anthony Rice.
Comparative Programming Languages hussein suleman uct csc304s 2003.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
What is an exception? An exception is: – an event that interrupts the normal processing of the program. –an error condition that violates the semantic.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 18 Exception Handling.
CIS 270—Application Development II Chapter 13—Exception Handling.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
ICS 313: Programming Language Theory Chapter 14: Exceptions.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Exceptions and Assertions Chapter 15 – CSCI 1302.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Exception Handling in Java Topics: Introduction Errors and Error handling Exceptions Types of Exceptions Coding Exceptions Summary.
Exceptions in Java. What is an exception? An exception is an error condition that changes the normal flow of control in a program Exceptions in Java separates.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
Error Handling Tonga Institute of Higher Education.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
1 Exceptions. 2 Syntax Errors, Runtime Errors, and Logic Errors syntax errors, runtime errors, and logic errors You learned that there are three categories.
CSE 466 – Fall Introduction - 1 Safety  Terms and Concepts  Safety Architectures  Safe Design Process  Software Specific Stuff  Sources  Hard.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
CSE 466 – Spring Introduction - 1 The Final  Hardware: probably something on memory mapped I/O (HW and SW)  OS: Probably a task diagram of some.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
Exception. Agenda Exception. Handling Exceptions. The finally Clause.
ECE122 L23: Exceptions December 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions.
Introduction to Exceptions in Java CS201, SW Development Methods.
Lecture 5: Exception Handling and Text File I/O Michael Hsu CSULA.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Eighth Lecture Exception Handling in Java
Java Exceptions a quick review….
CSE 143 Error Handling [Section 2.8] 3/30/98 CSE 143.
EE422C Software Implementation II
CSC 143 Error Handling Kinds of errors: invalid input vs programming bugs How to handle: Bugs: use assert to trap during testing Bad data: should never.
Exception Handling Imran Rashid CTO at ManiWeber Technologies.
Review CSE116 2/21/2019 B.Ramamurthy.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
Exceptions 10-May-19.
Exception Handling.
Presentation transcript:

CSE 466 – Spring Introduction Implement Safety – Safe Software Language Features Type and Range Safe Systems Exception Handling Re-use, Encapsulation Objects Operating Systems Protocols Testing Regression Testing Exception Testing (Fault Seeding) Nuts and Bolts

CSE 466 – Spring Introduction - 2 Language Features  Type and Range Safe Systems: Pascal, Ada….Java? Program WontCompile1; type MySubRange = ; Day = {Mo, Tu, We, Th, Fr, Sa, Su}; var MyVar: MySubRange; MyDate: Day; begin MyVar := 9; {will not compile – range error} MyDate := 0; {will not compile – wrong type)  True type safety also requires runtime checking. a[j] := b; what must be checked here to guarantee type safety? range of j, range of b – this takes a lot of time!  Over head in time and code size. But safety may require this.  Does type-safe = safe?  If no, then what good is a type safe system?

CSE 466 – Spring Introduction - 3 Guidelines  Make it right before you make it fast  Verify during program execution  Pre-condition invariants  Things that must be true before you attempt to perform and operation.  Post-condition invariants  Things that must be true after and operation is performed  eg while (item!=tail) { process(item); if (item->next == null) { throw new CorruptListException(“Item” + item.id()); } else item = item->next; }  Exception handling What should happen in the event of an exception? who should be responsible for this check?

CSE 466 – Spring Introduction - 4 Exception Handling  Its NOT okay to just let the system crash if some operation fails! You must, at least, get into safe mode.  it is up to the designer to perform error checking on the value returned by f1 and f2. Easily put off, or ignored. Can’t distinguish error handling from not, no guarantee that all errors are handled gracefully.  a = f1(&b,&c) if (a) switch (a) { case 1: handle exception 1 case 2: handle exception 2 … } b = f2(&e,&f) if (a) switch (a) { case 1: handle exception 1 case 2: handle exception 2 … }

CSE 466 – Spring Introduction - 5 Exception Handling in Java void myMethod() throws FatalException { try { a = x.f1(&b,&c) b = x.f2(&e,&f) } catch (IOException e) { recover and continue } catch (ArrayOutOfBoundsException e) { not recoverable, throw new FatalException(“I’m Dead”); } finally { finish up and exit } Exceptions that are not handled will terminate the current procedure and raise the exception to the caller, and so on. Exceptions are subclassed so that you can have very general or very specific exception handlers. Separates throwing exceptions functional code exception handling

CSE 466 – Spring Introduction - 6 Safety of Object Oriented SW  Strongly typed at compile time  Run time checking is not native, but can be built into class libraries for extensive modularization and re-use. The class author can force the app to deal with exceptions by throwing them! class embeddedList extends embeddedObject() { public add(embeddedObject item) throws tooBigException { if (this.len() > this.max()) throw new tooBigException(“List size too big”); else addItem2List(); }  If you call embeddedList.add() you have three choices:  Catch the exception and handle it.  Catch the exception and map it into one of your exceptions by throwing an exception of a type declared in your own throws clause.  Declare the exception in your throws clause and let the exception pass through your method (although you might have a finally clause that cleans up first). Compiler will make you aware of any exceptions you forgot to consider!  When to use exceptions and when to use status codes or other means?

CSE 466 – Spring Introduction - 7 More Language Features  Garbage collection  What is this for  Is it good or bad for embedded systems  Inheritance  Means that type safe systems can still have functions that operate on generic objects.  Means that we can re-use commonalities between objects.  Encapsulation  Means the the creator of the data structure also gets to define how the data structure is accessed and used, and when it is used improperly.  Means that the data structure can change without changing the users of the data structure (is the queue an array or a linked list…who cares!)  Re-use  Use trusted systems that have been thoroughly tested  OS  Networking  etc.  Friday … how would Java be mapped to an embedded processor…say C++ to C51. What restrictions would you need to support that?

CSE 466 – Spring Introduction Testing  Unit test (white box)  requires knowledge of the detailed implementation of a single sub-system.  Test local functionality  Control algorithms  Boundary conditions and fault response  Integration Test (gray box)  Distributed processor systems w/ ongoing communications  Subsystems are already unit tested  Primarily for interfaces and component interaction  Falt seeding includes breaking the bus, disabling a subsystem, EMI exposure, power supply fluxuation, etc  Embedded systems require physical test environments  Validation Testing  Complete system  Environmental chamber  More fault seeding, bad user, etc.  Fault Seeding and Regression Testing!!!

CSE 466 – Spring Introduction Safe Design Process  Mainly, the hazard/risk/FMEA analysis is a process not an event!  How you do things is as important as what you do.  Standards for specification, documentation, design, review, and test  ISO9000 defines quality process…one quality level is stable and predictable.  There are many processes, but the good ones include release/test early and often! Incremental analysis, development, and testing

CSE 466 – Spring Introduction - 10 Interrupt v. Polling UController Seems to work, but hangs after first measurement. Why?

CSE 466 – Spring Introduction - 11 Closer Look The ‘ping’ is a series of 16 rapid clicks which requires rapid capacitor recharge Why do I bring this up under safety? UController

CSE 466 – Spring Introduction - 12 PCB Layout

CSE 466 – Spring Introduction - 13 PCB Layout

CSE 466 – Spring Introduction - 14 Critique  Good  Power distribution  Labeling  Compactness  Placement and Routing  Improve  Labeling (visible after stuffing)  Main power Caps (big and small).1uF 10uF  Crystal case grounding? (or oscillator instead of crystal, option?)  Space for extraction tool between cap and IC  4 mounting holes (standoffs)  Poor isolation of power circuits from logic circuits  Hole diameter for the power connector?

CSE 466 – Spring Introduction - 15 Friday  Friday  Embedded Java – think about multi-threading and synchronization  UML Example for Engine Controller  Demo: Air Trombone  Demo: Talk Application  Demo: Hi Fidelity