Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSci 162 Lecture 8 Martin van Bommel. Large-scale Programming Up to now we have been writing relatively short programs to solve simple problem Want to.

Similar presentations


Presentation on theme: "CSci 162 Lecture 8 Martin van Bommel. Large-scale Programming Up to now we have been writing relatively short programs to solve simple problem Want to."— Presentation transcript:

1 CSci 162 Lecture 8 Martin van Bommel

2 Large-scale Programming Up to now we have been writing relatively short programs to solve simple problem Want to now think about the management of large-scale programs Top-down design still works to modularize a large project into individual pieces Want pieces to be implemented by different programmers

3 Procedural Abstraction After breaking down problem into solvable chunks, must think about chunks separately Procedural abstraction –separate concerns of what a function does from details of how it does it Permits use of function in design of problem solution before implementation is done Think - integer array functions

4 Data Abstraction Data abstraction –separate concerns of types of data objects and the associated operations from the details of how represented in memory and implemented Permits focus on the use of the data in solving larger problems Again think integer array and its operations

5 Information Hiding Abstractions enable designer to make implementation decisions in a more ad-hoc fashion - can postpone implementation Concealing details of implementation of data object and only enabling manipulation via defined operations allows changes to be made at lower level without affecting upper Protecting implementation details from user is called information hiding

6 Reusable Code Reusable code - can be used by many different applications Encapsulation - packaging data object together with its operators in a library Use #include to access the library Want to be able to provide these ourselves

7 Header Files Header file - text file containing all information about a library needed by the compiler and the user of the library Contents –comment summarizing library’s purpose –#define directives –type definitions for library –comments for each library function –function prototypes in form extern prototype

8 Implementation Files Implementation file – C++ source file containing code of library’s functions and any other information needed for compiling Contents –comment summarizing library’s purpose –#include directives for header file and others –#define directives needed in implementation –type definitions used only in implementation –function implementations (including comments)

9 Interface Conceptual entity Boundary between the implementation of a library and programs that use that library Information passes across boundary whenever functions in library are called Interface mediates and gives structure to the exchange of information between library and its users -.h file serves as interface

10 Example Math library - sqrt function Implementation contains steps to calculate square root of a number User needs not know implementation, only use of function –- how to pass in value and get back result Shown in - file “cmath.h” –double sqrt(double);

11 Interface Terminology Implementor - defines functions –programmer who implements a library Client - uses functions –programmer who calls functions in library Both must know: –Function name –The arguments and their types –The type of the return result

12 Interface Design Unified - single abstraction with theme Simple - hide all complexity from client Sufficient - meet the needs of client General - meet needs of different clients Stable - never change structure and effect of a function in interface, even if implementation changes or more functions added


Download ppt "CSci 162 Lecture 8 Martin van Bommel. Large-scale Programming Up to now we have been writing relatively short programs to solve simple problem Want to."

Similar presentations


Ads by Google