CSE 222: Software Components in Engineering (SCE) – Introduction

26
CSE 222: Software Components in Engineering (SCE) – Introduction Instructor: Jimmy Voss Disclaimer: Not all material is original. Some is taken from the official course slides, and some is taken from Anna’s slides.

description

CSE 222: Software Components in Engineering (SCE) – Introduction. Instructor: Jimmy Voss Disclaimer: Not all material is original. Some is taken from the official course slides, and some is taken from Anna’s slides. Syllabus Information. Course Coordinator: Dr. Bruce Weide - PowerPoint PPT Presentation

Transcript of CSE 222: Software Components in Engineering (SCE) – Introduction

Page 1: CSE 222:  Software Components in Engineering (SCE) – Introduction

CSE 222: Software Components in Engineering (SCE) – Introduction

Instructor: Jimmy VossDisclaimer: Not all material is original. Some

is taken from the official course slides, and some is taken from Anna’s slides.

Page 2: CSE 222:  Software Components in Engineering (SCE) – Introduction

Syllabus Information

• Course Coordinator: Dr. Bruce Weide• Instructor: Jimmy Voss– E-mail: [email protected]– Office: 407 Caldwell– Office Hours: 2:30 – 3:30 Tu Th

• Course website:– http://www.cse.ohio-state.edu/sce/now/222/

Page 3: CSE 222:  Software Components in Engineering (SCE) – Introduction

Overview of Course

• Use RESOLVE/C++ to teach programming concepts and software engineering principles:– Use of data structures– Client View and Implementer’s View– Design by contract– Memory management / pointers– Data structure implementations

Page 4: CSE 222:  Software Components in Engineering (SCE) – Introduction

What is RESOLVE/C++?

• An approach to programming in C++• Uses formal comments to specify precise

program behavior.• Implemented using macros, classes, and

formal comments.• Implements a set of template libraries.• Implements 4 standard operations for all

components.

Page 5: CSE 222:  Software Components in Engineering (SCE) – Introduction

Review of Resolve

• Combines a programming language (C++) and a specification language.– For code to be correct, it must work precisely

when the specifications are met.– Use formal comments for specifications.– Some specifications described via keywords which

have no meaning in C++.• Disciplined way of programming C++

Page 6: CSE 222:  Software Components in Engineering (SCE) – Introduction

Review of Resolve

• All Resolve components are classes with 4 predefined operations:– Swap -- denoted &=– Constructor– Destructor– Clear member function

Page 7: CSE 222:  Software Components in Engineering (SCE) – Introduction

Sequence -- A Resolve/C++ component

• a sequence is an ordered grouping of objects– Example: “abc” is an ordered sequence of

characters. A Text object could be used.• Sequence – the Abstract RESOLVE/C++

component:– 4 operations allowed:

• Add( pos, x )• Remove( pos, x )• Accessor, i.e., [pos]• Length()

Page 8: CSE 222:  Software Components in Engineering (SCE) – Introduction

Instantiating Sequence

#include "RESOLVE_Foundation.h"

#include "CT/Sequence/Kernel_1a_C.h"

concrete_instanceclass Sequence_Of_Integer : instantiates Sequence_Kernel_1a_C <Integer>{};

Page 9: CSE 222:  Software Components in Engineering (SCE) – Introduction

Instantiating Sequence

#include "RESOLVE_Foundation.h"

#include "CT/Sequence/Kernel_1a_C.h"

concrete_instanceclass Sequence_Of_Integer : instantiates Sequence_Kernel_1a_C <Integer>{};

Preprocessor directives

RESOLVE Keyword

Template parameter

Page 10: CSE 222:  Software Components in Engineering (SCE) – Introduction

Preprocessor directives

• #include– Used to include the contents of another file at the current

location in the current file.– Example:

• #include "RESOLVE_Foundation.h"

• #define– Used for text replacement which occurs before the

program is compiled.– Examples:

• #define concrete_instance• #define procedure_body virtual void

Page 11: CSE 222:  Software Components in Engineering (SCE) – Introduction

Template parameters

• Template parameter – a token which represents a type name.

• Classes and functions can be defined on arbitrary types. To use such classes / functions, the user must supply the template parameter.

• Container classes such as Sequence require a template parameter to be instantiated.

• In this course, we instantiate template parameters via inheritance.

Page 12: CSE 222:  Software Components in Engineering (SCE) – Introduction

Inheritance and templating

• Inheritance takes on the form:class child : instantiates parent

• The child class contains all member functions and variables of the parent class.

• If the parent class has requires a template parameter, then a new class with the template parameter filled in is created via:

parent< template_type >

• Note: This is not the only way of filling in template parameters.

Page 13: CSE 222:  Software Components in Engineering (SCE) – Introduction

Instantiating Sequence

#include "RESOLVE_Foundation.h"

#include "CT/Sequence/Kernel_1a_C.h"

concrete_instanceclass Sequence_Of_Integer : instantiates Sequence_Kernel_1a_C <Integer>{};

Preprocessor directives

RESOLVE Keyword

Template type parameter

Page 14: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 15: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 16: CSE 222:  Software Components in Engineering (SCE) – Introduction

FormalComment /the contract

Pass by reference

Page 17: CSE 222:  Software Components in Engineering (SCE) – Introduction

An Example (Continued)global_procedure Smooth( preserves Sequence_Of_Integer & s1, produces Sequence_Of_Integer & s2)/*! ... !*/{ // s2 is produces mode and should not depend on // the input. s2.Clear();

object Integer Index = 0; while ( Index < s1.Length() - 1 ) { s2.Add( Index, (s1[Index] + s1[Index+1]) / 2 ); }}

Page 18: CSE 222:  Software Components in Engineering (SCE) – Introduction

Set

• Set – A set is an unordered collection of objects which contain no duplicates.

• Examples of sets:– {1, 2, 3, 4, 5}– {}– {“Bob”, “the cat”, “Tom”, “Random string”}

• Not a set:– {0, 0, 1, 2}

Page 19: CSE 222:  Software Components in Engineering (SCE) – Introduction

Requires: x self

Requires: x self

Page 20: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 21: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 22: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 23: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 24: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 25: CSE 222:  Software Components in Engineering (SCE) – Introduction
Page 26: CSE 222:  Software Components in Engineering (SCE) – Introduction