CS 325: Software Engineering

Slides:



Advertisements
Similar presentations
Programming Types of Testing.
Advertisements

Behavioral Pattern: Interpreter C h a p t e r 5 – P a g e 149 Some programs benefit from having a language to describe operations that they can perform.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Programming Language Semantics Mooly SagivEran Yahav Schrirber 317Open space html://
An Overview of Programming Logic and Design
Describing Syntax and Semantics
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Fundamentals of Python: From First Programs Through Data Structures
Your Interactive Guide to the Digital World Discovering Computers 2012.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
CS 325: Software Engineering March 5, 2015 Modeling and Design of Rule-Based Systems Rule-Based Systems Interpreter Pattern Code Reviews.
Python Mini-Course University of Oklahoma Department of Psychology Day 1 – Lesson 2 Fundamentals of Programming Languages 4/5/09 Python Mini-Course: Day.
Fundamentals of Python: First Programs
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
INTRODUCTION TO COMPUTING CHAPTER NO. 06. Compilers and Language Translation Introduction The Compilation Process Phase 1 – Lexical Analysis Phase 2 –
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 11 Conditional.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Copyright © 2010 Certification Partners, LLC -- All Rights Reserved Perl Specialist.
Controlling Execution Programming Right from the Start with Visual Basic.NET 1/e 8.
Visual Basic Programming
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
3.2 Semantics. 2 Semantics Attribute Grammars The Meanings of Programs: Semantics Sebesta Chapter 3.
1 Program Planning and Design Important stages before actual program is written.
The Functions and Purposes of Translators Syntax (& Semantic) Analysis.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Copyright © 2003 ProsoftTraining. All rights reserved. Perl Fundamentals.
Objects – State u There are only two things we can do to an object u Inspect it’s state u Alter it’s state u This is a profound statement! u If you think.
Intermediate 2 Computing Unit 2 - Software Development.
Boolean Functions and Boolean Algebra Laxmikant Kale.
Concepts and Realization of a Diagram Editor Generator Based on Hypergraph Transformation Author: Mark Minas Presenter: Song Gu.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
© 2006 Pearson Education Chapter 3 Part 2 More about Strings and Conditional Statements Loops (for and while) 1.
PhD at CSE: Overview CSE department offers Doctoral degree in the Computer Science (CS) or Computer Engineering areas (CpE) at both MS to PhD and BS to.
Software Testing.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Process Specifications and Structured Decisions
The Selection Structure
Lecture 2 Introduction to Programming
Some Simple Definitions for Testing
Expressions and Control Flow in JavaScript
Algorithm and Ambiguity
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Chapter 9 Structuring System Requirements: Logic Modeling
Algorithm Discovery and Design
Introduction to Primitive Data types
C++ Data Types Data Type
Algorithm and Ambiguity
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Conditional Execution
From now on: Combinatorial Circuits:
Boolean Expressions to Make Comparisons
Flowcharts and Pseudo Code
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Chapter 9 Structuring System Requirements: Logic Modeling
Chapter 11 Conditional Execution
Basic Concepts of Algorithm
Chapter 10: Compilers and Language Translation
Review of Previous Lesson
CHAPTER 6 Testing and Debugging.
Programming Logic and Design Eighth Edition
Introduction to Primitive Data types
Faculty of Computer Science and Information System
Presentation transcript:

CS 325: Software Engineering Lesson Fifteen Modeling and Design of Rule-Based Systems Rule-Based Systems Interpreter Pattern Code Reviews

Rule-Based Systems Some software systems are set up to make decisions via a (occasionally convoluted) set of rules. Consider a university’s computer science department , which uses a set of admission criteria to process applications to its graduate program. Applications that clearly satisfy all of the admission criteria are classified as “accepted”; those that do not satisfy the criteria are classified as “rejected”; and the remaining applications are marked as “pending”. The applicant must have paid the application fee. The applicant must have a four-year undergraduate degree in a technical area. The applicant must have at least a 3.2 GPA on a 4.0 scale in the last two years of undergraduate course work. The applicant’s undergraduate degree is ranked (high, average, or low) based on its relevance to the CS curriculum. The applicant’s undergraduate degree-granting institution is ranked (high, average, or low). The applicant must have a sum of verbal and quantitative scores of at least 1,150 on the GRE with a quantitative score of at least 700 and a verbal score of at least 400. International applicants must have a score of at least 90 on the TOEFL Internet-Based Test or a score of at least 7.0 on the International English Language Testing System (IELTS). CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 148

Rule-Based Systems These rules can be concisely represented in a decision table. 1 2 3 4 5 6 7 Is fee paid? Y N UG degree relevant to CS? H - A L UG institution rank? All other conditions satisfied? Rule count 18 9 Accepted X Rejected Pending investigation Wait for fee paid CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 149

Rule-Based Systems To facilitate viewing the rule-based system as a software system, a grammar is defined to give the rules a syntax. rule-set ::= rule [rule] rule ::= condition-list '==>' action ';' condition-list ::= condition [‘&’ condition-list] condition ::= condition-name ‘=’ condition-value action ::= ‘accept’ | ‘reject’ | ‘pending’ | ‘wait’ condition-name ::= ‘fee-paid’ | ‘relevance’ | ‘inst-rank’ | ‘all-other’ condition-value ::= ‘Y’ | ‘N’ | ‘H’ | ‘A’ | ‘L’ Legend: ::= defined as ‘abc’ literal abc [abc] abc is optional a | b selectively a or b CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 150

Rule-Based Systems The grammar translates in a straightforward manner into a class diagram, and an actual implementation follows. CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 151

Interpreter Pattern Some programs benefit from having a language to describe operations that they can perform. The Interpreter Pattern generally describes defining a grammar for that language and using that grammar to interpret statements in that language. For example, a Boolean Expression is either a terminal expression (a Constant) or a compound expression (an AND, OR, or NOT Expression). A Boolean Expression is interpreted in the context of its variable names and values. For instance, the Boolean Expression (X AND NOT Y) OR Z in the context of (X,Y,Z) = (true, false, false) evaluates to eval(X AND NOT Y) OR eval(Z), which is (eval(X) AND eval(NOT Y)) OR false, which evaluates to (true AND NOT eval(Y)), which is NOT(false), resulting in an evaluation of true. CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 152

Interpreter Pattern As another example, consider Roman Numerals Reading left to right, a Roman Numeral can be interpreted via four “sub-interpreters”. First, the thousands characters (the leading “M” characters) are read. This is followed by the hundreds characters (either a 900-sequence “CM”, a 400-sequence “CD”, or an optional 500-sequence “D” followed by zero to three 100-sequences “C”). The tens and ones characters are handled similarly. Notice that all of the derived “expressions” are terminal. CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 153

Interpreter Pattern When a program presents a number of different, but somewhat similar, cases with which it must contend, it can be advantageous to use a simple language to describe these cases and then have the program interpret that language. Recognizing cases where the Interpreter Pattern can be helpful can be problematic, and programmers who lack training in formal languages or compilers often overlook this option. One fairly obvious place where languages are applicable is when the program must parse algebraic strings in order to carry out operations based on the computation of user-entered equations. A far more useful situation that uses the Interpreter Pattern is when the program produces varying kinds of output (e.g., generating reports based on a database without having to resort to elaborate SQL queries). CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 154

Code Reviews While there are many aspects to software quality, one particularly important emphasis is on the elimination of defects. Rationale: If the software doesn’t work right, other quality issues are irrelevant. How can defects be effectively eliminated? Since low defect content is best achieved where the defects are injected, software engineers should: remove their own defects determine the causes of their defects learn to prevent those defects When should the defects be eliminated? Rather than waiting until late in the development process (i.e., during testing, when locating and correcting defects is difficult and expensive), modern processes advocate eliminating defects during code review (and possibly even design review). CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 155

Code Reviews Defects are injected primarily during the code phase, with the design phase at second place and the requirements phase a distant third. Defects are removed primarily during the code phase, with the expensive test phase at second place and the much cheaper design phase a distant third. CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 156

Code Reviews In testing, you must detect unusual behavior figure out what the test program was doing find where the problem is in the program figure out which defect could cause such behavior With reviews and inspections, you follow your own logic know where you are when you find a defect know what the program should do, but did not know why this is a defect are in a better position to devise a correct fix CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 157

Resource defects refer to mistakes made with data, variables, or other resource initialization, manipulation, and release. Check defects are validation mistakes or mistakes made when detecting an invalid value. Interface defects are mistakes made when interacting with other parts of the software, such as an existing code library, a hardware device, a database, or an operating system. Logic defects are made with comparison operations, control flow, and computations and other types of logical mistakes. Code Reviews CS 325 Lesson Fifteen Modeling and Design of Rule-Based Systems Page 158