1 / 15

Features of classes: Attributes Behavior/Operations/Methods

Features of classes: Attributes Behavior/Operations/Methods PRIVATE PART is INVISIBLE to the outside. Table of Contents. Logic overview. What is a proposition. Proposition and logical operators. Negation. Conjunction. Disjunction. Exclusive OR. Implication. Biconditional.

paco
Download Presentation

Features of classes: Attributes Behavior/Operations/Methods

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cis4932 (Dr. Ed Jones)

  2. Features of classes: • Attributes • Behavior/Operations/Methods • PRIVATE PART is INVISIBLE to the outside. Cis4932 (Dr. Ed Jones)

  3. Table of Contents Logic overview • What is a proposition • Proposition and logical operators Negation Conjunction Disjunction Exclusive OR Implication Biconditional • What are bit operators Cis4932 (Dr. Ed Jones)

  4. Feature of Classes • Attributes – • private part • data describing an object • referred to as the STATE • Attribute values determine BEHAVIOR, • i.e., how the methods react to messages. Cis4932 (Dr. Ed Jones)

  5. Feature of Classes contd (2) Behavior/Operations/Methods:  - Typically functions (methods) are for manipulating the object: - Set operations -- store values into the state - Inquiry operations – return values of state variable(s) Computation operations – perform computation using state variable, without modifying state variables. Transformational operations – modify state variables.  Cis4932 (Dr. Ed Jones)

  6. (3) PRIVATE PART is INVISIBLE to the outside. - Hard to verify effect of certain public operations.- • Approaches:  • Function-Driven. (Divide and Conquer). • Test each function (method). • If each method works, • then the whole class must work. • - Use function testing techniques on each method • Document test of each function Cis4932 (Dr. Ed Jones)

  7. Challenge #1 Gaining access to the internal state Why this is important ? Testing requires "finding" the results so that it can be compared to the expected result. When the result is trapped inside an object, one must be able to access it.  Cis4932 (Dr. Ed Jones)

  8. Challenge #1 contd   What is required The class must be modified temporarily to permit access to the internal state. HOWEVER, the goal must be to minimize the intrusiveness of such modifications. Principle: If you modify what you are testing, then you're not testing the original (real) thing. Cis4932 (Dr. Ed Jones)

  9. Limitations of Function-Driven approach • Class methods are not independent. Correctness of one requires correctness of other methods.  • Order in which to test methods. • Ability to test internal/private functions. • Ability to see the EFFECTS of a function call, when there is an internal state change. Cis4932 (Dr. Ed Jones)

  10. Approach to Gain Access to Internal State • Add "hooks" to the interface of the class • (public section) • - DATA TYPE: • struct instate declaring all the • internal state variables  • - INQUIRY FUNCTIONS: • a) Get_State (instate &) -- returns values of all state variables  (contd) Cis4932 (Dr. Ed Jones)

  11. Approach to Gain Access to Internal State contd • SET FUNCTIONS: • a) Set_State (instate &) -- set state variables to the values contained in the state record being passed.    • (2) LAST RESORT -- Make EVERYTHING PUBLIC.  Cis4932 (Dr. Ed Jones)

  12. Limitations of State Driven approach • Hard to identify significant states • Must understand formal specification • using state models. • c) Hard to get visibility into • current internal state.  Cis4932 (Dr. Ed Jones)

  13. (3) Semantics/Usage-Driven approach. (Semantics = the intended meaning/usage of objects of a class type)  Example: Stack rules. Push before Pop Detection of empty/overflow. - Sequence of calls to public methods required to DO A JOB - valid and invalid sequences - Focus is on correct "external" behavior  Cis4932 (Dr. Ed Jones)

  14. (2) State-Driven. (State = internal/private variables inside class). • Identify relevant states • (not every value of every • variable is significant).  • Ensure all state transitions • have been exercised • (state-transition coverage). Cis4932 (Dr. Ed Jones)

  15. TRUTH TABLE p q p  q T T T T F F F T F F F T • Biconditional Definition 6: Biconditional Let p & q be propositions. The biconditinal p  q is the proposition that is true when p & q have the same truth values and false otherwise. Cis4932 (Dr. Ed Jones)

More Related