Modularity Lecture 4 Course Name: High Level Programming Language Year : 2010.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Lilian Blot Announcements Teaching Evaluation Form week 9 practical session Formative Assessment week 10 during usual practical sessions group 1 Friday.
Lecture 6: Software Design (Part I)
1 Structures. 2 User-Defined Types C provides facilities to define one’s own types. These may be a composite of basic types ( int, double, etc) and other.
Programming Languages and Paradigms
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Abstract Data Types Data abstraction, or abstract data types, is a programming methodology where one defines not only the data structure to be used, but.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
1 CSE1301 Computer Programming Lecture 25: Software Engineering.
COSC 120 Computer Programming
16/11/2015 9:05 AM6/11/2015 9:05 AM6/11/2015 9:05 AMFunctions Functions A function consists of: Name Name Arguments (also called parameters) Arguments.
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 3 Data Abstraction: The Walls. © 2005 Pearson Addison-Wesley. All rights reserved3-2 Abstract Data Types Modularity –Keeps the complexity of a.
1 Chapter 11 Structured Types, Data Abstraction and Classes Dale/Weems/Headington.
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
VB in Context Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh Pittsburgh, Pa 15260
Ch4: Software Architecture and Design. 1 Modules: Interface vs. Implementation (contd..)  Interface design considerations:
CSE1301 Computer Programming: Lecture 21 Software Engineering.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
C++ fundamentals.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Comp 245 Data Structures Software Engineering. What is Software Engineering? Most students obtain the problem and immediately start coding the solution.
CS 331 Modules Chapter 6. Overview Decomposition and abstraction Program organization Abstract vs. concrete User-defined types Example discussion.
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
Chapter 6 Structures and Classes. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 6-2 Structures  2 nd aggregate data type: struct  Recall:
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
Names and Scope. Scope Suppose that a name is used many times for different entities in text of the program, or in the course of execution. When the name.
ITEC 352 Lecture 18 Functions in Assembly. Functions + Assembly Review Questions? Project due on Friday Exam –Average 76 Methods for functions in assembly.
9/20/6Lecture 3 - Instruction Set - Al1 Program Design.
Prepared By Ms.R.K.Dharme Head Computer Department.
Introduction to Computer Programming Using C Session 23 - Review.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Lecture 3 Classes, Structs, Enums Passing by reference and value Arrays.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Simple Classes. ADTs A specification for a real world data item –defines types and valid ranges –defines valid operations on the data. Specification is.
1 MT258 Computer Programming and Problem Solving Unit 4.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
1 CSE1301 Computer Programming Lecture 24: Software Engineering.
Structures and Classes Version 1.0. Topics Structures Classes Writing Structures & Classes Member Functions Class Diagrams.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
ENEE150 – 0102 ANDREW GOFFIN Project 4 & Function Pointers.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Systems Design.  Application Design  User Interface Design  Database Design.
Slide 1 Chapter 6 Structures and Classes. Slide 2 Learning Objectives  Structures  Structure types  Structures as function arguments  Initializing.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
Programming Logic and Design Seventh Edition
Coupling and Cohesion Rajni Bhalla.
Abstract Data Types and Encapsulation Concepts
About the Presentations
Stack ADT & Modularity 2 implementations of the Stack abstract data type: Array Linked List Program design: modularity, abstraction and information hiding.
Abstract Data Types and Encapsulation Concepts
Introduction to Data Structure
Programming Languages and Paradigms
Presentation transcript:

Modularity Lecture 4 Course Name: High Level Programming Language Year : 2010

3 Learning Outcomes At the end of this lecture, students are capable of: Understanding why modularity concept in programming is important.

4 Outline Material Modularity I –Interface versus Implementation –Advantage using Interface –Decomposition of File –Abstract Data –Abstract Data and Module Modularity II –Top-Down Programming and Bottom-Up Programming –Cohesion –Coupling

5 Module: a unit from the whole organization of a software system. groups together some functions, data, types, etc. Example: string functions from standard library C- string hides detail of implementation from user’s point of view (information hiding). Ex.: local variable in C function, can not be accessed by the caller function or main() Modularity I

6 Users and the module’s creator have a different perspective about the module itself. Interface: is an access point for users into a module. it explains to users about how to use it. it makes a module easier to be used and understood. it explains what services that the module provides, not how it provides the services. Interface versus Implementation

7 Users can create their own program, before the module is finished. Users programs and module program can be compiled separately. Implementation of the module itself can be changed, e.g. for fixing bugs, data structure, or for a better algorithm; without changing or re-compiling the users’ programs. Advantage of Using Interface

8 Interface: header file (.h) contains declaration of function, constant, variable, or users-defined types that have public scope data behavior. It also includes “comments” for users. Implementation: source file (.c) that contains definition of functions, along with local constants, variable, and users-defined type for private scope data behavior. It also includes “comments” for the creator of that particular module. Decomposition of File

9 Users include header file, for functions that they use, by using. Pay attention, that this is enough to compile the users programs. Modules also include their header file, so that the c compiler can check the consistency of the module program, before it reaches the linking stage. In the next slide, an example of interface is used for a function service of linked-list.c Dekomposisi File

10 Header File for linklist2.c /* Sorted linked lists of chars */ /* Linked list nodes are of type node_t */ typedef struct element { char contents; struct element *next; } node_t; /* Inserts new node with contents `key', keeping sorted. `ptr_to_head’: address of pointer to head of list */ int insertNode(node_t **ptr_to_head, char key); /*... */ int deleteNode(node_t **ptr_to_head, char); /*... */ void traverse(node_t *head); /*... */ void deleteAllNodes(node_t **); Decomposition of File

11 Abstract Data Type (ADT): A group of data and a group of instruction that operates on that particular data, in which the operation is independent from the module implementation. Example: stacks and lists. Description of a Stack ADT: Stack records data through a push and pop mechanisms. And it has a LIFO (Last In First Out) behavior, which means that input data will be in order, but output data will be in reverse order. Data Abstraction

12 There is only one stack ADT, but there is another possibility to implemented it. An particular implementation uses a particular data structure and also has functions that manipulate that particular data. In C language, a person can implement stack ADT in link-list or in array. The operations that are inside the stack ADT, are functions that are declared inside the interface file (header file.h). However, details of how the operation works, does not necessarily need to be known from the Users’ point of view. Abstraksi Data dan Modul

13 Top-Down Programming and Bottom- Up Programming Cohesion Coupling Modularity II

14 Top-Down Programming and Bottom-Up Programming Important Rule #1 Desain with Top-Down, but create with Bottom-Up Code and test the easiest component first. Test every component, before using it to create a more complex one.

15 Coupling Relation and dependency between functions: Coupling Control: –Happens when a function sends a signal control to another function. –Example: function call, return Coupling Data: –Sending data between functions –Example: function parameters, return values

16 Example 1 Structure Diagram with label that shows data coupling undanganKePesta ( nama, tanggal, jam ) { telepon ( nama ) ajakanKePesta (tanggal, jam ) bye ( nama ) } AjakanKePestabyetelepon inviteToParty nama tanggal jam nama tanggal jam Control Coupling Data Coupling

17 searchAddrBook telepon ( nama ) { set nomerTelp sebagai hasil dari cariBukuAlmt (nama ) angkat telepon tekan nomerTelp katakan “Hi nama, Ini Budi” } Example 2 Structure chart with labels showing data coupling ringUp dll... nama nomerTelp nama Return value or data that has been altered using pointer

18 Important Points about Coupling Objective: To maximize independency between module = to minimize coupling Use of Global Variables is not recommended by data coupling’s concept! –It is recommended not to use global variable in your program!

19 Important Facts about Coupling Where do you use control coupling in coding? –Function call: when a function is called, then the control is given to that function –Function return: when a coding inside a function has been completed or done, then the control is returned to the caller’s coding When do you use data coupling in coding? –Data is sent to one function via parameter –Data is returned from another function via “return” –Data is modified using pointer

20 Cohesion Cohesion: refers to how close the dependencies between lines of coding in one particular function. Logical Cohesion Logic (weak) –Ex.: Function Input / Output Function Cohesion (Strong) –Function that results with one output or activity. Purposes: function Cohesion

21 Example of Cohesive kontak ( perusahaan, pesan, mode ) { if mode = fax { kirimFax ( perusahaan, pesan) } else if mode = { kirim ( perusahaan, pesan) } Cohesive

22 Example of not Cohesive Not Cohesive kontak ( perusahaan, pesan, mode ) { if mode = fax { kirimFax ( perusahaan, pesan) } else if mode = { kirim ( perusahaan, pesan) } cetakBukuAlamat ( ) }

23 Cohesion Modules inside structural programming is tightly cohesive, but having a loosely coupling The amount of data coupling shows in general the position of a module in a programming hierarchy. Important Rule #2

24 Conclusion Modularity is an important concept in creating a complex software Design top-down, but create it bottom- up A good structure programming is one that has behaviors as follow; very cohesive with loosely coupling between modules.

25 Topic For Next Week Concurrent Versioning System –What is CVS – Concurrent Versioning System? –“Working Space” and “Repository Space” –Check-in and Check-out –Branch and Tag Assignment: –CVS has been around from the beginning of software development. For beginners, please read the following article, called “Tutorial-cvs.pdf”.

26 –Once you have read it, then install winCVS, and try to implement from what you have read into the winCVS. The only difference is that in the article it uses cvs command line interface, while winCVS is an IDE CVS for windows’ application. –Make a report of your experiment with winCVS and it will be discussed and presented in the class. Topic For Next Week