Chapter 1: Introduction - SEAS - The George Washington University

advertisement

CSci 210 -- Advanced Software Paradigms –

Exam Review

A. Bellaachia

Department of Computer Science

School of Engineering and Applied Science

The George Washington University

Washington, DC 20052

Introduction

Software Development Process

Language and Computer Architecture

Language paradigms

Language Evaluation Criteria:

 Readability

Examples: Data type, data structures, and control statements

Writability

Reliability

 Type checking

Exception handling

 Aliasing

 Maintainability

Cost

Csci 210 -- A. Bellaachia

2

Software Paradigms

Five Software Paradigms

AP: Algorithmic Paradigm

AP assumes problem is well structured

 application = program to map input to output

 finite number of steps, no errors

ASE: Analysis-Synthesis-Evaluation

 like Waterfall Model

 assumes problem is well structured

It uses problem decomposition

FD: Formal Design

FD assumes problem is well structured

It is a refinement of ASE, but uses abstraction

 problem becomes a mathematical proposition

 AI: Artificial Intelligence

It is explicitly founded on the concepts of search, knowledge and heuristics

It does not assume problem is well structured

TED: Theory of Evolutionary Design

It uses the fast that software design is an evolutionary process

It does not assume problem is well structured

Nothing is fixed, everything can evolve

Csci 210 -- A. Bellaachia

3

Software Architecture Paradigms

Architectural Elements

Processing elements

Connecting elements

Data Elements

Configuration file

Csci 210 -- A. Bellaachia

4

Software Architecture Paradigms (Cont.)

Architectural Styles (major ones)

Dataflow Systems

Pipelines

– Each layer is client for layer below it

– output of one stage = input to next

– Example: Compilers

Call & Return Systems

Layered

– Each layer is client for layer below it

– advantages: incremental, extendable

– N-tier / Client-Server

– layers can be developed independently

– Examples: Operating Systems, Web-based applications

Independent-Process

 Communicating Processes:

– Using CSP to describe different process topologies

Repository

 Blackboard

– central repository for shared info

– 3 components – knowledge source, controller, repository (blackboard)

– Example: no one single answer – fingerprints

 Architecture Evaluation: Good Structure

Cohesion

Coupling

Csci 210 -- A. Bellaachia

5

DSSA

Requirement analysis and software architecture of a domain of applications.

Examples: Wed browsers, Web servers, Word processors, etc.

There are three main elements of a DSSA:

Domain Model

Complete description of the domain

Achieved by experts in the domain, users, developers who have experience in the domain, etc.

 Reference Requirements

 Stable (or Fix)

Variable (or optional)

Requirements can also be broken into:

– Functional, Non-functional, Design, Implementation

List a reference of each requirement of the domain.

Reference Architecture

Make sure to state the right architecture style for the domain.

List a reference of each architectural element.

Csci 210 -- A. Bellaachia

6

Components

Why use components?

Major elements of a component:

 Specification

One or more implementations

Component Model:

Each of these component models addresses the following issues:

– How a component makes its services available to others?

– How component are named?

– How new components and their services are discovered at runtime.

A packaging approach:

Example: 2EE application is packaged as an E nterprise AR chive ( EAR ) file, a standard Java JAR file with an .ear extension.

A deployment approach:

J2EE uses deployment descriptors that are defined as in XML files named ejbjar.xml

.

Component Architecture

Blackbox vs. Whitebox

Components vs. Objects

Components in industry verses in-house solutions

Component disadvantages

Csci 210 -- A. Bellaachia

7

Design Patterns

Definitions

What is a Pattern?

Categories of Patterns

Pattern Characteristics

Essential Elements of a Design Pattern

Examples of design patterns:

Singleton

Adapter

 Strategy

Design Pattern Selection

How to Use a Design Pattern?

Idioms

Csci 210 -- A. Bellaachia

8

Frameworks

Definitions

Frameworks

Classification

Frameworks Evaluation

Examples

Csci 210 -- A. Bellaachia

9

Basic of Programming Languages

Built-in Types and Primitive Types

Data Aggregates and Type Constructors

Constructors

User-defined Types and Abstract Data Types

Strong Typing & Type Checking

Type Compatibility

Type Conversion

Type and Subtypes

Generic Types

Monomorphic versus Polymorphic

The Type Structure of Representative languages

Implementation Models

Implementation of Structured Types

Csci 210 -- A. Bellaachia

10

Object-Oriented Programming

Object-oriented characteristics:

Object Definition and instance creation

Encapsulation

Inheritance

 Polymorphism: “ Polymorphism (Greek for many forms) means that the same operation can be defined for many different classes, and each can be implemented in their different way.

Binding in OOP:

Static vs. Dynamics

Implementation of OO constructs

Csci 210 -- A. Bellaachia

11

Functional Programming

Functional programming characteristics

Functions in FP: composition, Apply-to-all, etc.

Performance

12

Csci 210 -- A. Bellaachia

Logic Programming

Logic programming characteristics:

 based on relations.

Horn clause

User query processing:

Resolution

Unification

Performance

Csci 210 -- A. Bellaachia

13

Concurrency

Concurrency requirements

Problems with concurrency:

 Deadlock

Starvation

Etc.

Process Interactions

Syntax for parallel processes

 Independent processes

Competing processes (Critical sections)

Communicating processes (May need to communicate)

Low-level Concurrency Primitives

Process creation and control :

 Event: Event-wait (e) and Event-signal (e)

Messages :

Remote Procedure Calls (RPCs)

Synchronization

Semaphores, Monitors, etc.

Concurrency in Java.

Csci 210 -- A. Bellaachia

14

Sample Question

Problem :

In this problem, we would like to define a DSSA for web server applications such as Apache and Internet Information Server (IIS).

The major operations of a web server include the following:

– A resource handler to determine the type of operation requested by a browser.

– Interpretation of a request protocol such as the HTTP protocol.

– An operation, called Access Control, to enforce access rule employed by the server.

– A request analysis operation to translate the location of the resource (URL) from a network location to a local file name.

– A web server has also the ability to gather information (log) about all the requests and their results.

Provide a complete DSSA for this type of applications.

15

Csci 210 -- A. Bellaachia

Sample Question

Problem:

State the major software paradigms that can be examined during the steps of the software life cycle of an application and explain why.

16

Csci 210 -- A. Bellaachia

Sample Question

Problem:

Component-based software development greatly depends on an efficient component integration strategy. You have been hired by a company and you are asked to develop a component-based system.

(a) What are the issues that you need to address in your design?

17

Csci 210 -- A. Bellaachia

Sample Question

Problem:

Give an architectural description in CSP for the following architecture:

M

0

M

2

M

5

F1 F2 O1

M

4 M

1

F3 F4

M

3

Csci 210 -- A. Bellaachia

18

Sample Question

Problem:

We have used cohesion and coupling to compare different software architectures. In this problem, we introduce a new metric, called Component Structural Complexity

(CSC). The structural complexity of a component i is defined as follows:

CSC(i) = f2out(i),

Where fout(i) is the number of components immediately subordinate to the component i, that is, the number of components directly invoked by component i

1. Design a system structural complexity (SSC) metric for the whole system using CSC metric, assuming you have a system of n components

2. Measure SSC for pipeline and layered architectures.

3. Compare SSC metric to coupling and cohesion.

Csci 210 -- A. Bellaachia

19

Sample Question

Problem:

(a) Describe why you would use design patterns in your application.

(b) Give an example of a design pattern and show how you would use it for a specific application.

State clearly your application.

20

Csci 210 -- A. Bellaachia

Sample Questions: Different Paradigms

What the major design decisions you need to consider for:

Object-oriented programming

Requirements of OOP

 Polymorphism

Class Instance Record (CIR)

FP

Requirements of FP

Be familiar with Scheme: be able to understand scheme code

LP:

Requirements of LP

 Resolution algorithm

Unification

Query processing

 Concurrency

Requirements of concurrency.

Csci 210 -- A. Bellaachia

21

Sample Question

Problem: class A { public: int a; virtual void what(){ … } virtual void who() { … }

}; class B{ public: int b virtual void what{ … }

}; class C: public A, public B { public: int c; virtual void what(){ … } virtual void who() { … } virtual void dud() { … }

};

Draw the Class Instance Record (CIR) of each class.

Csci 210 -- A. Bellaachia

22

Sample Question

Problem:

One of the programming language paradigms we have covered is logic programming.

1. Describe this paradigm and compare it to a programming language paradigm of your choice.

2. Give detailed description of the different parts of a logic program.

3. One of the drawbacks of logic programming is low performance. How would your enhance the efficiency of a logic programming compiler?

23

Csci 210 -- A. Bellaachia

Sample Question

Problem:

You are asked to extend a procedural language to become an object-oriented (OO) language.

(1) State the OO features that you need to add to your procedural language

(2) Explain how you would implement each of the features in (1)

24

Csci 210 -- A. Bellaachia

Sample Question

Problem:

Consider the following logic program:

 mother (mary, sue).

 mother (mary, bill).

 mother (sue, nancy).

 mother (sue, jeff).

 mother (jane, ron).

 father (john, sue).

 father (john, bill).

 father (bob, nancy).

 father (bob, jeff).

 Father(bill,ron).

 Parent(A,B) :- father(A,B).

Parent (A,B) :- mother(A,B).

Grandparent(C,D) :- parent(C,E), parent(E,D).

Show the trace of the processing of the following queries:

?- grandparent(Who, ron).

Add a sibling relationship to the above program and answer the following question:

?- sibling(sue, X).

Csci 210 -- A. Bellaachia

25

G o o d L u c k

Csci 210 -- A. Bellaachia

26

Download