An Example of Code Refactoring with Legacy Code in a Flight Model Software

Size: px
Start display at page:

Download "An Example of Code Refactoring with Legacy Code in a Flight Model Software"

Transcription

1 An Example of Code Refactoring with Legacy Code in a Flight Model Software Eric Shi H. Peter Stassen, Mentor The MITRE Corporation TJHSST Computer Systems Lab, January 11, 2008 Abstract As software code ages, it becomes increasingly important for it easily to be maintained and understood by programmers who may work with the code. Modern software may utilize legacy code for the purpose of supporting specific features. Therefore, refactoring techniques must be applied to the code to ease the process of implementing future modifications. Refactoring emphasizes improving the design of an already-written piece of code without changing its function. This project seeks to apply refactoring techniques to components of the flight model software used at the Air Traffic Management Lab at the MITRE Corporations Center for Advanced Aviation System Development. Keywords: Design patterns, flight simulation, legacy code, refactoring 1

2 Contents 1 Introduction 3 2 Background 4 3 Simflight Design Target Generation Module Structure Procedure Cataloging of Global Variables Data Classes Move to C C++ Coding Conventions Application of a Design Pattern Testing and Analysis Results and Conclusion 7 Appendix 8 References 10 Acknowledgments 11 2

3 1 Introduction In the simulation and modeling industry, many companies continue to use aging pieces of code in their programs simply because the code performs its function correctly. From a management perspective, there is no need to direct programmers to rewrite code that already works. Legacy code, however, may be inefficient, inflexible, and difficult to maintain as programmers take advantage of newer programming languages and techniques. The Air Traffic Management (ATM) Lab at the MITRE Corporations Center for Advanced Aviation System Development in McLean, Virginia conducts research from the perspective of National Airspace System stakeholders. This group includes the flight crew, air traffic controllers, and air traffic managers. The purpose of conducting such research is to gather both quantitative data and qualitative data via human feedback from simulations. This helps evaluate and mature new concepts to build an industry consensus. This project concerns the cockpit simulator of the ATM Lab, a fixed-base, medium fidelity generic air-transport category airplane. This simulator can implement new instrumentation and software rapidly and has data collection capability. The programmers at the cockpit portion of the ATM Lab have been continually modifying the cockpit component of the flight simulator software since its inception in 1993 without a comprehensive rework of its basic design. The code, originally written in C, was designed to run across the network on multiple machines due to processor limitations at the time and did not utilize an object-oriented design. Software design decays as programmers change a program to realize short-term goals. Today, the programmers have noticed that the code has become difficult to manage and that interprocess communications have proliferated in the form of redundant data structures. The purpose of this project is to refactor and rework the fltsim module in the ATM Lab Cockpit Simulator. Refactoring is important in the software design process because it ensures maintainability and readability in code. The software is changed such that its internal structure is improved, but its function remains the same. The C code used in the modules needs to be updated to meet todays programming standards, such as object-oriented design and naming conventions. This project develops skills in working with a mature software system, implementing design patterns, and learning to refactor software for maintainability. While refactoring software does not necessarily result in an expected performance gain and only affects the programmers who work directly with the code, it is expected to make the product cheaper to maintain over time compared to a non-refactored program. The result of this project is a single module in C++ which utilizes object oriented design, meets todays programming standards, and can be easily maintained in the future. 3

4 2 Background Refactoring is a practice that is specific to software engineering. It is difficult to identify the origin of the term refactoring, and the process of improving code after it has been written has been recognized and practiced since the 1980 s. Some programmers habitually practice refactoring, while others view it as a new concept. The first dissertation on refactoring, Refactoring Object-Oriented Frameworks, was published in 1992 by William Opdyke, which examines refactorings useful for object-oriented C++ frameworks [5]. This paper is known as the most substantial work on this subject [2]. Another comprehensive resource is Refactoring: Improving the Design of Existing Code by Martin Fowler, originally published in This book identifies principles of refactoring and discusses over 70 refactorings. The Extract Method is a refactoring in which a code fragment in a particularly long method is turned into its own method. The purpose of the Extract Method is to improve code clarity. If a switch statement chooses different behavior depending on object type, then the Replace Conditional with Polymorphism can be applied. This refactoring moves each set of actions into a method in the class of the corresponding object. Different situations call for different refactorings. Design patterns is a practice separate from refactoring, but relevant to code design. They are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context. The important aspect of design patterns is that they are solutions to general problems that occur in software design, so the same pattern can be applied in a variety of scenarios [3]. Many design patterns are based on object-oriented designs, so it would be appropriate to apply design patterns in this project in the rewriting of C code in C++. In programming environments, many developers may work on a piece of code. Therefore, there is a need for a consistent writing style throughout the code. Code consistency brings maintainability, robustness, and fewer bugs. Conventions for formatting, naming, documentation, programming, and packaging are important when striving for efficient code, especially in teams. Although there is no official set of conventions, many books on programming style offer suggestions. For the purposes of refactoring fltsim, The Elements of C++ Style by Trevor Misfeldt, Gregory Bumgardner, and Andrew Gray is used [4]. 3 Simflight Design 3.1 Target Generation Fltsim is a module that comprises the actual flight model in the cockpit simulator. It is a simulation event generator and a client of the Generic Target Generator (GTG), which is a simplified framework for Integrated Target Protocol (ITP) applications. Target generation refers to the creation of simulated aircraft among the multiple applications that comprise 4

5 a simulation. ITP facilitates the communication of target data to applications that require information updates for the target. The implication of using GTG is that the main loop GTG clients is in GTG and only defines the callback functions for the framework. The entire simulation is controlled by a central application, the Central Simulation Manager (CSM). It allows the user to define the applications involved in a simulation run and starts, pauses, and stops the applications simultaneously. A user can also define the networked computers on which different applications run. An important role of CSM is to ensure that the clocks in each application are synchronized throughout the entire simulation run. The refactored version of fltsim is called simflight. 3.2 Module Structure GTG requires fltsim to specify functions so that the application can be run properly: an internal initialization, an external initialization, check events, timeout, pause, resume, shutdown, and handle message. The module is further divided among components that create representations of aircraft, terrain, atmosphere, data collection, and more. In total, fltsim contains 36 files. These models communicate through data structures (structs) that are passed around in intercommunication functions. By introducing an object-oriented design, class representations of these components were created and the intermediate data structures were replaced with a set of data classes. 4 Procedure 4.1 Cataloging of Global Variables The first step in refactoring fltsim was to go through every file in fltsim and record the variables that would be preserved in the refactored module. These variables, found at the global scope, represented information that fltsim components and other ITP applications require to function, such as indicated airspeed (IAS), aircraft nose direction, pitch rate, etc. These variables were later placed in data objects, according to a new design. Fltsim had nearly 750 documented global variables. 4.2 Data Classes The most significant feature of the new simflight module is the way data is set and accessed. Simflight data is divided among various classes, depending on what the data describes. Specifically, the classes are divided according to an industry-wide standard for numbering aircraft systems, the ATA system. ATA Chapter 22 is the Auto Flight system, so variables related to Auto Flight would be found in FsDataAta22. With the data in a centralized location, the global interprocess structs were replaced by direct access to the data classes. By 5

6 restricting initialization of each data class to a single instance, it is ensured that all simflight components have access the same set of data. Therefore all functions that replicated data structures were removed from fltsim. It should be noted that the sole purpose of these data classes is to store variables, so they do not contain any functions other than the constructor and the destructor. 4.3 Move to C++ The refactoring of the fltsim module also involved a rewrite of C code into C++. It is important to note that changing the language in which a program is written per se does not qualify as a refactoring. The important aspect of rewriting fltsim in C++ was that it made the new design possible. C++ also increases the range of applicable design patterns and future refactorings. Corresponding.h and.cpp files for every fltsim component and their respective functions were written. In extreme cases, functions had to be created from C macros (Figures 1 and 2). By using the C++ Standard Template Library (STL), char arrays were replaced by std::string statements. Although char arrays were replaced, there remain several instances in the refactored code in which c_str() must be called in order to send a string to a GTG or ITP callback. With native support in C++ for boolean data with bool, true, and false keywords, preprocessor macros defining FALSE as 0 and TRUE as 1 were eliminated C++ Coding Conventions 4.4 Application of a Design Pattern A problem that occurred was that multiple copies of models would be created by components that did not check for an already existing instance. Not only was spawning multiple FlightDynamic models nonsensical, but it also introduced pointer access errors. Therefore, a design pattern was used to solve the problem of restricting instantiations of a class to a single instance, the Singleton Pattern. The Singleton Pattern solves this problem because it makes the class responsible for keeping track of its instance. By calling the Instance function of a model, the class checks to see if there is an existing instance (Figure 3). If one does not exist, it calls the constructor to create an one and returns the pointer. If an instance exists, it simply returns the pointer to the object. To restrict access to a model s constructors, various functions were declared at the protected level. To take advantage of inheritance in C++, the simulation models (FsAeroynamics, FsAircraft, FsAtmosphere, FsControlModel, FsEngine, FsFlightDyanmics, FsTerrain, and FsWind) were declared as derivations of the base class FsModel (Figure 4). 6

7 4.5 Testing and Analysis 5 Results and Conclusion 7

8 Appendix System Codes 21 Air Conditioning 36 Pneumatic 22 Auto Flight 38 Water/Waste 23 Communications 44 Cabin Systems 24 Electrical Power 45 Central Maintenance Computer 25 Equipment/Furnishings 46 Information Systems 26 Fire Protection 49 Airborne Auxiliary Power 27 Flight Controls 52 Doors 28 Fuel 56 Windows 29 Hydraulic Power 73 Engine Fuel and Control 30 Ice and Rain Protection 74 Ignition 31 Indicating/Recording Systems 75 Bleed Air 32 Landing Gear 77 Engine Indicating 33 Lights 78 Engine Exhaust 34 Navigation 79 Engine Oil 35 Oxygen 80 Starting Table 1: ATA Chapter Codes [1] #define CF_Open(filen) { \ FILE *fp=null; \ if ((fp = fopen(filen, "r")) == NULL) { \ char config_fname[256]; \ sprintf(config_fname, "config/%s", filen); \ if ((fp = fopen(config_fname, "r")) == NULL) { \ fprintf(stderr, "Unable to open %s, trying to continue...\n", filen); \ } \ } \ if (fp!= NULL) { \ char config_word[21]; \ while (fscanf(fp, "%s", config_word)!= EOF) { \ if (*config_word == # ) { \ Read_To_Eoln(fp) Figure 1: Code fragment from config.h 8

9 void FsAircraft::initStructuralModel(FsConfigList::ConfigListRec *configrec) {... std::fstream ifile(("../config/"+configrec->m_filename).c_str(), std::ios::in); if (!ifile) { std::cout << "ERROR: " << configrec->m_filename.c_str() << " not found." << std::endl; return; } while (!ifile.eof()) {... }... } Figure 2: The refactored code in a FsAircraft initialization function FsModel* FsModel::Instance() { static FsModel inst; return &inst; } Figure 3: Code snippet of the Instance function from FsModel.cpp class FsEngine: public FsModel { public:... protected: FsEngine(); ~FsEngine(); FsEngine(const FsEngine&); FsEngine& operator = (const FsEngine&); }; Figure 4: FsEngine inherits the Instance function from FsModel 9

10 References [1] Eitel, James M. Table of Contents. Boeing 777 Master Minimum Equipment List. I-II. [2] Fowler, Martin. Principles in Refactoring. Refactoring: Improving the Design of Existing Code. Boston: Addison-Wesley, [3] Gamma, Erich, et al. Introduction. Design Patterns: Elements of Reusable Object- Oriented Software. By Gamma, et al.. Boston: Addison-Wesley, [4] Misfeldt, Trevor, Gregory Bumgardner, and Andrew Gray. The Elements of C++ Style. Cambridge, United Kingdom: Cambridge University Press, [5] Opdyke, William F. Refactoring Object-Oriented Frameworks. Diss. U of Illinois at Urbana-Champaign, Acknowledgments 10

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET

VB.NET. Exercise 1: Creating Your First Application in Visual Basic.NET VB.NET Module 1: Getting Started This module introduces Visual Basic.NET and explains how it fits into the.net platform. It explains how to use the programming tools in Microsoft Visual Studio.NET and

More information

2559 : Introduction to Visual Basic.NET Programming with Microsoft.NET

2559 : Introduction to Visual Basic.NET Programming with Microsoft.NET 2559 : Introduction to Visual Basic.NET Programming with Microsoft.NET Introduction Elements of this syllabus are subject to change. This five-day instructor-led course provides students with the knowledge

More information

ITT Technical Institute. IT217P Programming in C++ II Onsite Course SYLLABUS

ITT Technical Institute. IT217P Programming in C++ II Onsite Course SYLLABUS ITT Technical Institute IT217P Programming in C++ II Onsite Course SYLLABUS Credit hours: 4 Contact/Instructional hours: 66 (46 Theory Hours, 20 Lab Hours) Prerequisite(s) and/or Corequisite(s): Prerequisites:

More information

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8

More information

Analysis of the Test Driven Development by Example

Analysis of the Test Driven Development by Example Computer Science and Applications 1 (2013) 5-13 Aleksandar Bulajic and Radoslav Stojic The Faculty of Information Technology, Metropolitan University, Belgrade, 11000, Serbia Received: June 18, 2013 /

More information

C++ (Non for C Programmer) (BT307) 40 Hours

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

Recitation 13. Software Engineering Practices and Introduction to Design Patterns

Recitation 13. Software Engineering Practices and Introduction to Design Patterns Recitation 13 Software Engineering Practices and Introduction to Design Patterns Software Development is chaotic During that 90% time: Good engineers think, research, read the codebase, and recognize design

More information

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Introduction p. xxix The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured Language p. 6 C Is a Programmer's Language

More information

Multimedia-Programmierung Übung 3

Multimedia-Programmierung Übung 3 Multimedia-Programmierung Übung 3 Ludwig-Maximilians-Universität München Sommersemester 2016 Ludwig-Maximilians-Universität München Multimedia-Programmierung 1-1 Today Ludwig-Maximilians-Universität München

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University

(12-1) OOP: Polymorphism in C++ D & D Chapter 12. Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University (12-1) OOP: Polymorphism in C++ D & D Chapter 12 Instructor - Andrew S. O Fallon CptS 122 (April 3, 2019) Washington State University Key Concepts Polymorphism virtual functions Virtual function tables

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

THINK LIKE CREATIVE PROBLEM SOLVING V. ANTON SPRAUL

THINK LIKE CREATIVE PROBLEM SOLVING V. ANTON SPRAUL THINK LIKE A PROGRAMMERA A N I N T R O D U C T I O N T O CREATIVE PROBLEM SOLVING V. ANTON SPRAUL CODE EAT SLEEP INDEX Numbers and Symbols && operator (logical and), 48 short-circuit evaluation of, 129,

More information

Source Code Rejuvenation is not Refactoring

Source Code Rejuvenation is not Refactoring Source Code Rejuvenation is not Refactoring Peter Pirkelbauer Damian Dechev Bjarne Stroustrup Texas A&M University SOFSEM 2010 Parasol Lab (Texas A&M) Source Code Rejuvenation is not Refactoring Jan 25

More information

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005

Wrapping a complex C++ library for Eiffel. FINAL REPORT July 1 st, 2005 Wrapping a complex C++ library for Eiffel FINAL REPORT July 1 st, 2005 Semester project Student: Supervising Assistant: Supervising Professor: Simon Reinhard simonrei@student.ethz.ch Bernd Schoeller Bertrand

More information

And Even More and More C++ Fundamentals of Computer Science

And Even More and More C++ Fundamentals of Computer Science And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Special Members Friendship Classes are an expanded version of data structures (structs) Like structs, the hold data members

More information

Module 10 Inheritance, Virtual Functions, and Polymorphism

Module 10 Inheritance, Virtual Functions, and Polymorphism Module 10 Inheritance, Virtual Functions, and Polymorphism Table of Contents CRITICAL SKILL 10.1: Inheritance Fundamentals... 2 CRITICAL SKILL 10.2: Base Class Access Control... 7 CRITICAL SKILL 10.3:

More information

2. COURSE DESIGNATION: 3. COURSE DESCRIPTIONS:

2. COURSE DESIGNATION: 3. COURSE DESCRIPTIONS: College of San Mateo Official Course Outline 1. COURSE ID: CIS 278 TITLE: (CS1) Programming Methods: C++ C-ID: COMP 122 Units: 4.0 units Hours/Semester: 48.0-54.0 Lecture hours; 48.0-54.0 Lab hours; and

More information

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature

2D1358 Object Oriented Program Construction in C++ Exercises & Labs. Course Registration / Accounts. Course Literature 2D1358 Object Oriented Program Construction in C++ Exercises & Labs Lecturer: Frank Hoffmann hoffmann@nada.kth.se Assistents: Danica Kragic danik @nada.kth.se Anders Orebäck oreback @nada.kth.se Peter

More information

M Introduction to Visual Basic.NET Programming with Microsoft.NET 5 Day Course

M Introduction to Visual Basic.NET Programming with Microsoft.NET 5 Day Course Module 1: Getting Started This module introduces Visual Basic.NET and explains how it fits into the.net platform. It explains how to use the programming tools in Microsoft Visual Studio.NET and provides

More information

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1 What is a Design Pattern? Each pattern Describes a problem which occurs over and over again in our environment,and then describes the core of the problem Novelists, playwrights and other writers rarely

More information

Information System Architecture. Indra Tobing

Information System Architecture. Indra Tobing Indra Tobing What is IS Information architecture is the term used to describe the structure of a system, i.e the way information is grouped, the navigation methods and terminology used within the system.

More information

C The new standard

C The new standard C++11 - The new standard Lars Kühne Institut für Informatik Lehrstuhl für theoretische Informatik II Friedrich-Schiller-Universität Jena January 16, 2013 Overview A little bit of history: C++ was initially

More information

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 15: Inheritance and Polymorphism, STL (pronobis@kth.se) Overview Overview Lecture 15: Inheritance and Polymorphism, STL Wrap Up Additional Bits about Classes Overloading Inheritance Polymorphism

More information

INCORPORATING ADVANCED PROGRAMMING TECHNIQUES IN THE COMPUTER INFORMATION SYSTEMS CURRICULUM

INCORPORATING ADVANCED PROGRAMMING TECHNIQUES IN THE COMPUTER INFORMATION SYSTEMS CURRICULUM INCORPORATING ADVANCED PROGRAMMING TECHNIQUES IN THE COMPUTER INFORMATION SYSTEMS CURRICULUM Charles S. Saxon, Eastern Michigan University, charles.saxon@emich.edu ABSTRACT Incorporating advanced programming

More information

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay

C++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming

More information

McCa!"s Triangle of Quality

McCa!s Triangle of Quality McCa!"s Triangle of Quality Maintainability Portability Flexibility Reusability Testability Interoperability PRODUCT REVISION PRODUCT TRANSITION PRODUCT OPERATION Correctness Usability Reliability Efficiency

More information

An Introduction to C++

An Introduction to C++ An Introduction to C++ Introduction to C++ C++ classes C++ class details To create a complex type in C In the.h file Define structs to store data Declare function prototypes The.h file serves as the interface

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

Tool Support for Complex Refactoring to Design Patterns

Tool Support for Complex Refactoring to Design Patterns Tool Support for Complex Refactoring to Design Patterns Carmen Zannier 1, Frank Maurer 1 1 University of Calgary, Department of Computer Science, Calgary, Alberta, Canada T2N 1N4 {zannierc, maurer}@cpsc.ucalgary.ca

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson

More on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson More on Design CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson Outline Additional Design-Related Topics Design Patterns Singleton Strategy Model View Controller Design by

More information

use static size for this buffer

use static size for this buffer Software Design (C++) 4. Templates and standard library (STL) Juha Vihavainen University of Helsinki Overview Introduction to templates (generics) std::vector again templates: specialization by code generation

More information

Part X. Advanced C ++

Part X. Advanced C ++ Part X Advanced C ++ topics Philip Blakely (LSC) Advanced C++ 158 / 217 References The following are highly regarded books. They are fairly in-depth, and I haven t read them in their entirity. However,

More information

Introduction to C++ Programming Pearson Education, Inc. All rights reserved.

Introduction to C++ Programming Pearson Education, Inc. All rights reserved. 1 2 Introduction to C++ Programming 2 What s in a name? that which we call a rose By any other name would smell as sweet. William Shakespeare When faced with a decision, I always ask, What would be the

More information

C++ Basics. Brian A. Malloy. References Data Expressions Control Structures Functions. Slide 1 of 24. Go Back. Full Screen. Quit.

C++ Basics. Brian A. Malloy. References Data Expressions Control Structures Functions. Slide 1 of 24. Go Back. Full Screen. Quit. C++ Basics January 19, 2012 Brian A. Malloy Slide 1 of 24 1. Many find Deitel quintessentially readable; most find Stroustrup inscrutable and overbearing: Slide 2 of 24 1.1. Meyers Texts Two excellent

More information

S1000D - An Overview. Background, Benefits, and Overview of S1000D Data Module Structures

S1000D - An Overview. Background, Benefits, and Overview of S1000D Data Module Structures S1000D - An Overview Background, Benefits, and Overview of S1000D Data Module Structures What is S1000D? S1000D is an international specification for technical publications, utilizing a Common Source Database.

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

Extract Slice Refactoring. Rani Ettinger, Programming Tools Group, May 19th, 2003

Extract Slice Refactoring. Rani Ettinger, Programming Tools Group, May 19th, 2003 Extract Slice Refactoring Rani Ettinger, Programming Tools Group, May 19th, 2003 Outline Extract Slice Refactoring: Motivation Example Mechanics Correctness issues: Behaviour Preservation Limitations and

More information

Elevate your Code to Modern C++ with Automated Tooling. Peter Sommerlad

Elevate your Code to Modern C++ with Automated Tooling. Peter Sommerlad Elevate your Code to Modern C++ with Automated Tooling Peter Sommerlad Simple C++ Less Code == More Software Know your language and its (modern) idioms Don t be afraid of STL or templates Start small.

More information

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am

CMSC 202 Section 010x Spring Justin Martineau, Tuesday 11:30am CMSC 202 Section 010x Spring 2007 Computer Science II Final Exam Name: Username: Score Max Section: (check one) 0101 - Justin Martineau, Tuesday 11:30am 0102 - Sandeep Balijepalli, Thursday 11:30am 0103

More information

IT-2670: C/C++ PROGRAMMING LANGUAGE

IT-2670: C/C++ PROGRAMMING LANGUAGE IT-2670: C/C++ Programming Language 1 IT-2670: C/C++ PROGRAMMING LANGUAGE Cuyahoga Community College Viewing:IT-2670 : C/C++ Programming Language Board of Trustees: 2015-05-28 Academic Term: Fall 2018

More information

Basic Types, Variables, Literals, Constants

Basic Types, Variables, Literals, Constants Basic Types, Variables, Literals, Constants What is in a Word? A byte is the basic addressable unit of memory in RAM Typically it is 8 bits (octet) But some machines had 7, or 9, or... A word is the basic

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

Aviation & Airspace Solutions MODERNIZING SYSTEMS TRANSFORMING OPERATIONS DELIVERING PERFORMANCE

Aviation & Airspace Solutions MODERNIZING SYSTEMS TRANSFORMING OPERATIONS DELIVERING PERFORMANCE Aviation & Airspace Solutions MODERNIZING SYSTEMS TRANSFORMING OPERATIONS DELIVERING PERFORMANCE Enabling Aircraft Safety With Comprehensive Technology MODERNIZING SYSTEMS TRANSFORMING OPERATIONS DELIVERING

More information

On the correctness of template metaprograms

On the correctness of template metaprograms Proceedings of the 7 th International Conference on Applied Informatics Eger, Hungary, January 28 31, 2007 Vol 2 pp 301 308 On the correctness of template metaprograms Ádám Sipos, István Zólyomi, Zoltán

More information

Homework 4. Any questions?

Homework 4. Any questions? CSE333 SECTION 8 Homework 4 Any questions? STL Standard Template Library Has many pre-build container classes STL containers store by value, not by reference Should try to use this as much as possible

More information

G52CPP C++ Programming Lecture 18

G52CPP C++ Programming Lecture 18 G52CPP C++ Programming Lecture 18 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Welcome Back 2 Last lecture Operator Overloading Strings and streams 3 Operator overloading - what to know

More information

Chapter 11. Abstract Data Types and Encapsulation Concepts

Chapter 11. Abstract Data Types and Encapsulation Concepts Chapter 11 Abstract Data Types and Encapsulation Concepts The Concept of Abstraction An abstraction is a view or representation of an entity that includes only the most significant attributes The concept

More information

UNIT TESTING OF C++ TEMPLATE METAPROGRAMS

UNIT TESTING OF C++ TEMPLATE METAPROGRAMS STUDIA UNIV. BABEŞ BOLYAI, INFORMATICA, Volume LV, Number 1, 2010 UNIT TESTING OF C++ TEMPLATE METAPROGRAMS ÁBEL SINKOVICS Abstract. Unit testing, a method for verifying a piece of software, is a widely

More information

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++ CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 19 Introduction to C++ C++ C++ is an enormous language: All of C Classes and objects (kind of like Java, some crucial differences) Many

More information

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

TDWI strives to provide course books that are contentrich and that serve as useful reference documents after a class has ended.

TDWI strives to provide course books that are contentrich and that serve as useful reference documents after a class has ended. Previews of TDWI course books offer an opportunity to see the quality of our material and help you to select the courses that best fit your needs. The previews cannot be printed. TDWI strives to provide

More information

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli Identify and overcome the difficulties encountered by students when learning how to program List and explain the software development roles played by students List and explain the phases of the tight spiral

More information

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++ No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)

More information

Kerievsky_book.fm Page 355 Thursday, July 8, :12 PM. Index

Kerievsky_book.fm Page 355 Thursday, July 8, :12 PM. Index Kerievsky_book.fm Page 355 Thursday, July 8, 2004 12:12 PM Index A Absorbing class, 117 Abstract Factory, 70 71 Accept methods, 327 Accumulation methods, 315, 325 330 Accumulation refactorings Collecting

More information

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,

More information

Crash course on design patterns

Crash course on design patterns Crash course on design patterns Yann-Gaël Guéhéneuc guehene@emn.fr From Olivier Motelet s course (2001/10/17) École des Mines de Nantes, France Object Technology International, Inc., Canada Design patterns

More information

Abstract: Refactorings are used to improve the internal structure of software without changing its external behavior.

Abstract: Refactorings are used to improve the internal structure of software without changing its external behavior. Refactoring: Risks and its Effects on Software Quality Attribute Ramesh Kumar, Dr.Rajesh Verma Research Scholar, Department of Computer Science, Singhania University, Rajasthan. Asst. Professor, Department

More information

Preliminaries. Part I

Preliminaries. Part I Part I Preliminaries Chapters 1 through 4 present an introduction to C++ that provides the basis for understanding the rest of the material in this book. This part also provides professional programmers

More information

B16 Object Oriented Programming

B16 Object Oriented Programming B16 Object Oriented Programming Michael A. Osborne mosb@robots.ox.ac.uk http://www.robots.ox.ac.uk/~mosb/teaching.html#b16 Hilary 2013 This course will introduce object-oriented programming (OOP). It will

More information

Chapter 1: Principles of Programming and Software Engineering

Chapter 1: Principles of Programming and Software Engineering Chapter 1: Principles of Programming and Software Engineering Data Abstraction & Problem Solving with C++ Fifth Edition by Frank M. Carrano Software Engineering and Object-Oriented Design Coding without

More information

Explicit Conversion Operator Draft Working Paper

Explicit Conversion Operator Draft Working Paper Explicit Conversion Operator Draft Working Paper Lois Goldthwaite, Michael Wong IBM michaelw@ca.ibm.com ACCU Lois@LoisGoldthwaite.com Document number: N2223=07-0083 Date: 2007-03-11 Project: Programming

More information

Patterns for polymorphic operations

Patterns for polymorphic operations Patterns for polymorphic operations Three small object structural patterns for dealing with polymorphism Alexander A. Horoshilov hor@epsylontech.com Abstract Polymorphism is one of the main elements of

More information

G52CPP C++ Programming Lecture 18. Dr Jason Atkin

G52CPP C++ Programming Lecture 18. Dr Jason Atkin G52CPP C++ Programming Lecture 18 Dr Jason Atkin 1 Last lecture Operator Overloading Strings and streams 2 Operator overloading - what to know Know that you can change the meaning of operators Know that

More information

Introduction to Software Engineering

Introduction to Software Engineering Introduction to Software Engineering Gérald Monard Ecole GDR CORREL - April 16, 2013 www.monard.info Bibliography Software Engineering, 9th ed. (I. Sommerville, 2010, Pearson) Conduite de projets informatiques,

More information

Using the Xcode Debugger

Using the Xcode Debugger g Using the Xcode Debugger J Objectives In this appendix you ll: Set breakpoints and run a program in the debugger. Use the Continue program execution command to continue execution. Use the Auto window

More information

Part III. Advanced C ++

Part III. Advanced C ++ Part III Advanced C ++ topics Philip Blakely (LSC) Advanced C++ 66 / 119 References The following are highly regarded books. They are fairly in-depth, and I haven t read them in their entirity. However,

More information

Object-Oriented Programming in C# (VS 2015)

Object-Oriented Programming in C# (VS 2015) Object-Oriented Programming in C# (VS 2015) This thorough and comprehensive 5-day course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes

More information

Contemporary Design. Traditional Hardware Design. Traditional Hardware Design. HDL Based Hardware Design User Inputs. Requirements.

Contemporary Design. Traditional Hardware Design. Traditional Hardware Design. HDL Based Hardware Design User Inputs. Requirements. Contemporary Design We have been talking about design process Let s now take next steps into examining in some detail Increasing complexities of contemporary systems Demand the use of increasingly powerful

More information

BCS Higher Education Qualifications. Diploma in IT. Object Oriented Programming Syllabus

BCS Higher Education Qualifications. Diploma in IT. Object Oriented Programming Syllabus BCS Higher Education Qualifications Diploma in IT Object Oriented Programming Syllabus Version 3.0 December 2016 This is a United Kingdom government regulated qualification which is administered and approved

More information

Object-Oriented Programming in C# (VS 2012)

Object-Oriented Programming in C# (VS 2012) Object-Oriented Programming in C# (VS 2012) This thorough and comprehensive course is a practical introduction to programming in C#, utilizing the services provided by.net. This course emphasizes the C#

More information

Free Downloads C++ Coding Standards: 101 Rules, Guidelines, And Best Practices

Free Downloads C++ Coding Standards: 101 Rules, Guidelines, And Best Practices Free Downloads C++ Coding Standards: 101 Rules, Guidelines, And Best Practices Consistent, high-quality coding standards improve software quality, reduce time-to-market, promote teamwork, eliminate time

More information

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()

More information

C++ Modern and Lucid C++ for Professional Programmers

C++ Modern and Lucid C++ for Professional Programmers Informatik C++ Modern and Lucid C++ for Professional Programmers Part 1 Self-study for Introduction to C++ Prof. Peter Sommerlad Director IFS Institute for Software Rapperswil, HS 2017 Thomas Corbat Additional

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2014 Tuesday, February 25, 7-10p Name: NetID: Lab Section

More information

Space for safe skies. ESA Iris Program. Satellite Communications for Air Traffic Management (ATM)

Space for safe skies. ESA Iris Program. Satellite Communications for Air Traffic Management (ATM) Space for safe skies ESA Iris Program Satellite Communications for Air Traffic Management (ATM) 23rd Ka-Band Broadband and 35th AIAA ICSSC Conference 18/10/2017 Slide 1 Satellite Communications for the

More information

Future Directions in Simulation Modeling. C. Dennis Pegden

Future Directions in Simulation Modeling. C. Dennis Pegden Future Directions in Simulation Modeling C. Dennis Pegden Outline A half century of progress. Where do we need to go from here? How do we get there? Simulation: A Compelling Technology See the future Visualize

More information

4.1 Introduction Programming preliminaries Constructors Destructors An example... 3

4.1 Introduction Programming preliminaries Constructors Destructors An example... 3 Department of Computer Science Tackling Design Patterns Chapter 4: Factory Method design pattern Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents 4.1 Introduction.................................

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Introduction to C++ Giuseppe Lipari April 27, Scuola Superiore Sant Anna Pisa

Introduction to C++ Giuseppe Lipari  April 27, Scuola Superiore Sant Anna Pisa Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa April 27, 2009 Outline 1 Summary of the course Course content This course will cover advanced programming

More information

September 19,

September 19, September 19, 2013 1 Problems with previous examples Changes to the implementation will require recompilation & relinking of clients Extensions will require access to the source code Solutions Combine

More information

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination

University of Illinois at Urbana-Champaign Department of Computer Science. First Examination University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2007 7p-9p, Thursday, March 1 Name: NetID: Lab Section

More information

AviationSimNet Specification

AviationSimNet Specification MP 06W 0000131 AviationSimNet Specification Release Date: June 2010 Version: 2.2 Authored by the AviationSimNet Standards Working Group Published by The MITRE Corporation Sponsor: The MITRE Corporation

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE? 1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity

More information

Living and Working with Aging Software. Ralph Johnson. University of Illinois at Urbana-Champaign

Living and Working with Aging Software. Ralph Johnson. University of Illinois at Urbana-Champaign Living and Working with Aging Software Ralph Johnson University of Illinois at Urbana-Champaign rjohnson@illinois.edu Old software gets brittle n n Hard to change Hard to understand Software should be

More information

September 10,

September 10, September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible

More information

Simulation-Based FlexRay TM Conformance Testing an OVM success story

Simulation-Based FlexRay TM Conformance Testing an OVM success story Simulation-Based FlexRay TM Conformance Testing an OVM success story Mark Litterick, Co-founder & Verification Consultant, Verilab Abstract This article presents a case study on how the Open Verification

More information

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++

Course Text. Course Description. Course Objectives. StraighterLine Introduction to Programming in C++ Introduction to Programming in C++ Course Text Programming in C++, Zyante, Fall 2013 edition. Course book provided along with the course. Course Description This course introduces programming in C++ and

More information

Final Project Report

Final Project Report 16.04.02 Final Project Report Document information Project Title HP Tool Repository of SESAR standard HP methods and tools Project Number 16.04.02 Project Manager DFS Deliverable Name 16.04.02 Final Project

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

XII- COMPUTER SCIENCE VOL-II MODEL TEST I

XII- COMPUTER SCIENCE VOL-II MODEL TEST I MODEL TEST I 1. What is the significance of an object? 2. What are Keyword in c++? List a few Keyword in c++?. 3. What is a Pointer? (or) What is a Pointer Variable? 4. What is an assignment operator?

More information

Coding conventions and C++-style

Coding conventions and C++-style Chapter 1 Coding conventions and C++-style This document provides an overview of the general coding conventions that are used throughout oomph-lib. Knowledge of these conventions will greatly facilitate

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information