Download presentation
Presentation is loading. Please wait.
Published byTheodora Pearson Modified over 9 years ago
1
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.
2
Syllabus Information Course Coordinator: Dr. Bruce Weide Instructor: Jimmy Voss – E-mail: vossj@cse.ohio-state.edu – Office: 407 Caldwell – Office Hours: 2:30 – 3:30 Tu Th Course website: – http://www.cse.ohio-state.edu/sce/now/222/ http://www.cse.ohio-state.edu/sce/now/222/
3
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
4
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.
5
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++
6
Review of Resolve All Resolve components are classes with 4 predefined operations: – Swap -- denoted &= – Constructor – Destructor – Clear member function
7
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()
8
Instantiating Sequence #include "RESOLVE_Foundation.h" #include "CT/Sequence/Kernel_1a_C.h" concrete_instance class Sequence_Of_Integer : instantiates Sequence_Kernel_1a_C {};
9
Instantiating Sequence #include "RESOLVE_Foundation.h" #include "CT/Sequence/Kernel_1a_C.h" concrete_instance class Sequence_Of_Integer : instantiates Sequence_Kernel_1a_C {}; Preprocessor directives RESOLVE Keyword Template parameter
10
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
11
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.
12
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 Note: This is not the only way of filling in template parameters.
13
Instantiating Sequence #include "RESOLVE_Foundation.h" #include "CT/Sequence/Kernel_1a_C.h" concrete_instance class Sequence_Of_Integer : instantiates Sequence_Kernel_1a_C {}; Preprocessor directives RESOLVE Keyword Template type parameter
16
Formal Comment / the contract Pass by reference
17
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 ); }
18
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}
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.