Chapter 6 CEN 4010, Chapter 7 CEN 4010, Chapter 8 CEN 4010, Chapter 9 CEN 4010, Chapter 10 CEN 4010, Chapter 11 CEN 4010
Objects
a cohesive collection of data plus all operations for creating, reading, altering, and destroying those data
Computation and precision fault
a formula's implementation is wrong
Frameworks
a large reusable design for a specific application domain tend to be publicly available resources like toolkits
Abstraction
a model or representation that omits some details so that it can focus on other details
Design by contract
a particular approach that uses the documentation only to capture the design but also to encourage interaction among developers
Class
a software module that partially or totally implements an abstract data type
Template Method Pattern
aims to reduce the amount of duplicate code among subclasses of the same parent class - It is particularly useful when multiple subclasses have similar but not identical implementations of the same method - This pattern addresses this problem by localizing the duplicate code structure in an abstract class from which the subclasses inherit
Composed
an object's data variables may themselves be objects, thereby encapsulating the implementations of the object's internal variables
Design Principles
are guidelines for decomposing a system's required functionality and behavior into modules
Four OO constructs
classes, objects, interfaces, and instance variables
OO Design Pattern
codifies design decisions and best practices for solving a particular design problem according to design principles templates for a solution that must be modified and adapted for each particular use
Producer Reuse
create components designed to be reused in future applications • Several issues to keep in mind - make the components general - separate dependencies (to isolate sections likely to change) - keep the component interface general and well defined - include information about any faults found and fixed - use clear naming conventions - document data structures and algorithms - keep the communication and error-handling sections separate and easy to modify
Team - SCRUM
cross functional, self organizing, based on the needs of the sprint
Object oriented design
decomposes a system into a collection of runtime components called objects that encapsulate data and functionality
Interface
defines what services the software unit provides to the rest of the system, and how other units can access those services define what the unit requires, in terms of services or assumptions, for it to work correctly
Specification
describes the externally visible properties of the software unit
Objective of Testing
discover faults • A test is successful only when a fault is discovered
Information hiding
distinguished by its guidance for decomposing a system: - Each software unit encapsulates a separate design decision that could be changed in the future - Then the interfaces and interface specifications are used to describe each software unit in terms of its externally visible properties • Using this principle, modules may exhibit different kinds of cohesion - A module that hides a data representation may be informationally cohesive - A module that hides an algorithm may be functionally cohesive • A big advantage of information hiding is that the resulting software units are loosely coupled
Scrum master - SCRUM
facilitates the sprints, removes impediments, buffer distractions, enforces rules, protect the team (servant-leader)
Uses graphs
help to identify progressively larger subsets of our system that we can implement and test incrementally
Modularity - Design Principle
is the principle of keeping separate the various unrelated aspects of a system, so that each aspect can be studied in isolation (also called separation of concerns)
Factory Method Pattern
is used to encapsulate the code that creates objects is similar to the Template method pattern
Uncoupled
modules have no interconnections at all; they are completely unrelated
Loosely coupled
modules have some dependence, but their interconnections are weak
Attributes
object's data
Methods
object's operations
Algorithmic Fault
occurs when a component's algorithm or logic does not produce proper output
Stamp Coupling
occurs when complex data structures are passed between modules - represents a more complex interface between modules, because the modules have to agree on the data's format and organization
Instance variables
program variables whose values are references to objects
Egoless programming
programs are viewed as components of a larger system, not as the property of those who wrote them
Cohesion
refers to the dependence within and among a module's internal elements (e.g., data, functions, internal modules)
Fan-in
refers to the number of units that use a particular software unit
Fan-out
refers to the number of units used by particular software unit
Uses relation
relates each software unit to the other software units on which it depends
Product owner - SCRUM
represents the customer, writes stories, prioritizes them, and adds to the product backlog
Consumer Reuse
reuse components initially developed for other projects • Four key characteristics to check about components to reuse - does the component perform the function or provide the data needed? - is it less modification than building the component from scratch? - is the component well-documented? - is there a complete record of the component's test and revision history?
Identifiable
runtime entities that can be designated as the target of a message or request
Substitutability
serves as a guideline for determining when it is safe not to reexamine the client modules of an extended class
Interface specification
should communicate to other system developers everything that they need to know to use our software unit correctly - Purpose - Preconditions (assumptions) - Protocols - Postconditions (visible effects) - Quality attributes
Law of Demeter
Allows reducing dependencies by including in each composite class methods for operating on the class's components • Benefit: client code that uses a composite class needs to know only about the composite itself and not about the composites' components
Function Cohesion
(ideal degree) - All elements essential to a single function are contained in one module, and all of the elements are essential to the performance of the function
Coincidental Cohesion
(worst degree) - Parts are unrelated to one another
6 Common Design Principles
- Modularity - Interfaces - Information hiding - Incremental development - Abstraction - Generality
Ways modules are dependent on each other
- The references made from one module to another - The amount of data passed from one module to another - The amount of control that one module has over the other
External documentation
- describe the problem - describe the algorithm - describe the data
Internal documentation
- header comment block - meaningful variable names and statement labels - other program comments - format to enhance understanding - document data (data dictionary)
UML Diagrams - Communication Diagram
A communication diagram depicts a sequence of messages between objects but it is superimposed on an object and uses the links between object as implicit communication channels
UML Diagrams - State Diagram
A state diagram shows the possible states an object can take, the events that trigger the transition between one state to the next, and the actions that result from each state change
UML Diagrams - Activity Diagram
Activity diagrams are used to model the flow of procedures or activities in a class
Informational Cohesion
Adaption of functional cohesion to data abstraction and object-based design
Object composition
Building new classes by combining component classes, much as children build structures from building blocks
Documentation fault
Documentation doesn't match what program does
Abstract class
If a class is missing implementations for some of its methods
Data Coupling
If only data values, and not structured data, are passed - simpler and less likely to be affected by changes in data representation
UML Diagrams - Sequence Diagram
Interaction diagrams describe how operations and behaviors are realized by the objects
Common Coupling
Making a change to the common data means tracing back to all components that access those data to evaluate the effect of the change
Temporal Cohesion
Module's data and functions related because they are used at the same time in an execution
Content Coupling
Occurs when one component modifies an internal data item in another component, or when one component branches into the middle of another component
Communication Cohesion
Operates on the same data set
Logical Cohesion
Parts are related only by the logic structure of code
Procedural Cohesion
Similar to temporal, and functions pertain to some related action or purpose
Performance faults
System does not perform at the speed prescribed
Capacity or boundary faults
System's performance not acceptable when certain limits are reached
OO Design Patterns
Template Method Pattern Factory Method Pattern Strategy Pattern Decorator Pattern Observer Pattern Composite Pattern
Constructor
The class definition includes this and it in turn spawns new object instances
Multiplicity
The directed arrows in the figure below depict the relationships between constructs, and the adornments at the ends of each arrow indicate this (how many of an item may exist)
Inheritance
The implementation of an object can be reused and extended to define the implementation of other objects defines a new class by directly reusing (and adding to) the definitions of an existing class
UML Class Diagram
UML class diagrams describe the object types and their static relationships
UML Diagrams - Package Diagram
UML package diagrams allow viewing a system as a small collection of packages each of which may be expanded to a larger set of classes
Dynamic binding
Variables can refer to objects of different classes over the course of a program's execution
Daily Scrum meetings - SCRUM
starts on time, lasts 15 minutes, people stand, quick status, plan the day's activities, report issues
Data Management
takes into account the system requirements concerning performance and space Four steps: - Identify the data, data structures, and relationships among them - Design services to manage the data structures and relationships - Find tools, such as database management systems, to implement some of the data management tasks - Design classes and class hierarchies to oversee the data management functions
Generality
the design principle that makes a software unit as universally applicable as possible, to increase the chance that it will be useful in some future system • We make a unit more general by increasing the number of contexts in which can it be used. There are several ways of doing this: - Parameterizing context-specific information - Removing preconditions - Simplifying postconditions
Fault identification
the process of determining what fault caused the failure
Fault correction
the process of making changes to the system so that the faults are removed
Tightly coupled
they depend a great deal on each other
Sandwiching
try to break a cycle in the uses graph - One of the cycle's units is decomposed into two units, such that one of the new units has no dependencies - Sandwiching can be applied more than once, to break either mutual dependencies in tightly coupled units or long dependency chains
Dependency Inversion
used to reverse the direction of a dependency link between two classes
Polymorphic
written in generic code that works with objects of different but related types occurs when code is written in terms of interactions with an interface, but code behavior depends on the object associated with the interface at runtime and on the implementations of that object's method
Composite Pattern
• A composite object is a heterogeneous, possibly recursive, collection of objects that represents some composite entity • The composite pattern promotes the uses of a single uniform interface
Types of Faults
• Algorithmic fault • Computation and precision fault • Documentation fault • Capacity or boundary faults • Timing or coordination faults • Performance faults • Standard and procedure faults
Exception Handling
• Allows making programs become more robust • Helps separate error checking and recover from a program's main functionality
UML Diagrams
• Class description template • Package diagrams • Interaction diagrams • Sequence diagrams • Communication diagrams • State diagrams • Activity diagrams
Algorithms
• Common objective and concern: performance (speed) • Efficiency may have hidden costs - cost to write the code faster - cost to test the code - cost to understand the code - cost to modify the code
Inheritance vs. Object Composition
• Composition is better than inheritance at preserving the encapsulation of the reused code, because a composite object accesses the component only through its advertised interface • By contrast, using the inheritance approach, the subclass's implementation is determined at design time and is static • The resulting objects are less flexible than objects instantiated from composite classes because the methods they inherit from their parent class cannot be changed at runtime • The greatest advantage of inheritance is the ability to change and specialize the behaviors of inherited methods, by selectively overriding inherited definitions
Types of Coupling
• Content coupling • Common coupling • Control coupling • Stamp coupling • Data coupling
Extreme Programming
• Define the features that programmers will implement using stories • Describe detailed test cases that the will be used to verify the software • Assign priorities to stories and test • Write code to implement the stories in a way that will pass the tests. • Two types of participants - customers: who define the features using stories, describe detailed tests and assign priorities - programmers: who implement the stories
Refactoring
• Design decisions are periodically revisited and revised • Objective: to simplify complicated solutions or to optimize the design • Also used to address changing requirements
Data Structures
• Format and store data to make data management and manipulation easy. • Several techniques that use the structure of data to organize the program - keeping the program simple - using a data structure to determine a program structure
General Guidelines to Preserve Quality
• Localize input and output • Employ pseudocode • Revise and rewrite, rather than patch • Reuse
Control Structures
• Make the code easy to read • Build the program from modular blocks • Make the code not too specific, and not too general • Use parameter names and comments to exhibit coupling among components • Make the dependency among components visible
Testing Organization
• Module testing, component testing, or unit testing • Integration testing • Function testing • Performance testing • Acceptance testing • Installation testing
Decorator Pattern
• The Decorator pattern is used to extend an object's functionality at runtime • Decorator pattern is a flexible alternative to using inheritance at design time to create subclasses that support new features
Observer Pattern
• The Observer pattern is an application of the publish-subscribe architecture style • Useful when software needs to notify multiple objects of key events
Strategy Pattern
• The Strategy pattern allows algorithms to be selected at runtime • It is useful when various algorithms are available to an application but the chose of best algorithm is not known
Representing OO Designs in the UML
• The UML is a suite of design notations that is popular for describing OO solutions • The UML can be used to visualize, specify, or document a software design • UML especially useful for describing different design alternatives, and eventually for documenting design artifacts
Pair Programming
• The driver or pilot: controlling the computer and writing the code • The navigator: reviewing the driver's code and providing feedback
Scrum
• Two to four week sprints, produces a potentially shippable or demonstrateable increment. • Sprint planning meetings to plan the sprint and obtain commitments • Product backlog drives the contents • Requirements are frozen for the sprint • Sprint must complete on time • Ends with a demonstration • Team is self organizing for each sprint
Control Coupling
• When one module passes parameters or a return code to control the behavior of another module • It is impossible for the controlled module to function without some direction from the controlling module
Why Does Software Fail?
• Wrong requirement: not what the customer wants • Missing requirement • Requirement impossible to implement • Faulty design • Faulty code • Improperly implemented design