Data Abstraction and Modularity abstraction is the key principle to control the complexity electro-physics transitor microprocessor operating system library.

Slides:



Advertisements
Similar presentations
Transposing F to C Transposing F to C Andrew Kennedy & Don Syme Microsoft Research Cambridge, U.K.
Advertisements

More ML Compiling Techniques David Walker. Today More data structures lists More functions More modules.
Modules Program is built out of components. Each component defines a set of logically related entities (strong internal coupling) A component has a public.
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:
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
C++ Programming Languages
Module Language. Module language The Standard ML module language comprises the mechanisms for structuring programs into separate units. –Program units.
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.
Modules Program is built out of components. Each component defines a set of logically related entities (strong internal coupling) A component has a public.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Data Abstraction COS 441 Princeton University Fall 2004.
Programming in the large in ML Need mechanisms for –Modularization –Information hiding –Parametrization of interfaces While retaining type inference Modules:
Elaboration or: Semantic Analysis Compiler Baojian Hua
Introduction to ML Last time: Basics: integers, Booleans, tuples,... simple functions introduction to data types This time, we continue writing an evaluator.
Standard ML- Part II Compiler Baojian Hua
Modules in UHC A proposal by: Tom Hofte & Eric Eijkelenboom.
Last Time Introduction Course Logistics Introduction to ML Base Types Tuples and Records Functions & Polymorphism See Harper ’ s Intro to ML.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
Lecture 9 Concepts of Programming Languages
Abstract Data Types and Encapsulation Concepts
A Formal Model of Modularity in Aspect-Oriented Programming Jonathan Aldrich : Objects and Aspects Carnegie Mellon University.
OOP Languages: Java vs C++
The Power of Abstraction Barbara Liskov May 2013 MIT CSAIL.
F. Gava, HLPP 2005 Frédéric Gava A Modular Implementation of Parallel Data Structures in Bulk-Synchronous Parallel ML.
Programming Languages and Paradigms Object-Oriented Programming.
Chapter 11 and 12: Abstract Data Types and Encapsulation Constructs; Support for Object Orientation Lesson 11.
CS (CCN 27241) Software Engineering for Scientific Computing Lecture 5: C++ Key Concepts.
© Kenneth C. Louden, Chapter 9 – Abstract Data Types and Modules Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Bags Chapter 1 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Ada-Europe’2003 Ada as a Language Ehud Lamm The Open University of Israel.
By Neng-Fa Zhou1 Evolution of programming languages –Machine language –Assembly language –Sub-routines and loop (Fortran) –Procedures and recursion (Algol,
Programming Languages and Paradigms Object-Oriented Programming (Part II)
Programming Languages and Paradigms Object-Oriented Programming.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
EG280 Computer Science for Engineers Fundamental Concepts Chapter 1.
Review & Preview 재귀와 반복(recursion and iteration) 함수로 요약하기(procedural abstraction) 데이터로 요약하기(data abstraction) 물건중심의 프로그래밍(objects and imperative programming)
Levels of Abstraction Computer Organization. Level of Abstraction u Provides users with concepts/tools to solve problem at that level u Implementation.
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Types in programming languages1 What are types, and why do we need them?
ISBN Chapter 11 Abstract Data Types and Encapsulation Concepts.
Chapter 3 Collections. Objectives  Define the concepts and terminology related to collections  Explore the basic structures of the Java Collections.
UNIT II Queue. Syllabus Contents Concept of queue as ADT Implementation using linked and sequential organization. – linear – circular queue Concept –
Programming Languages Third Edition Chapter 11 Abstract Data Types and Modules.
Bernd Fischer RW713: Compiler and Software Language Engineering.
CSE 3302 Programming Languages Chengkai Li, Weimin He Spring 2008 Abstract Data Types and Modules Lecture 11 – ADT and Modules, Spring CSE3302 Programming.
A Type System for Higher-Order Modules Derek Dreyer, Karl Crary, and Robert Harper Carnegie Mellon University POPL 2003.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Abstract Data Type EnhanceEdu.
Cs776(Prasad)L112Modules1 Modules value : type : function :: structure : signature : functor.
Topic 2 Collections. 2-2 Objectives Define the concepts and terminology related to collections Discuss the abstract design of collections.
NML programming applicative programming value-oriented, not machine-oriented 값만 생각하는 프로그래밍 복잡한 머리는 터트려버려라.
ENEE150 – 0102 ANDREW GOFFIN Abstract Data Types.
CSE 3302 Programming Languages Chengkai Li Fall 2007 Abstract Data Types and Modules Lecture 12 – ADT and Modules, Fall CSE3302 Programming Languages,
CSE 3302 Programming Languages
UNIT II Queue.
Abstract Data Types and Encapsulation Concepts
Abstract Data Types and Modules
Abstract Data Types and Encapsulation Concepts
Queues 11/22/2018 6:47 AM 5.2 Queues Queues Dr Zeinab Eid.
Introduction Object-Oriented Programming
Overview of Programming Paradigms
Programming Languages and Paradigms
Separating Interface from Implementation
Abstraction and Objects
Drew Wyborski Programming Languages
Chapter 11 Abstraction - The concept of abstraction is fundamental in
Presentation transcript:

Data Abstraction and Modularity abstraction is the key principle to control the complexity electro-physics transitor microprocessor operating system library user program boolean circuits machine instructions assembly language C Java, ML, Haskell B, Z, HOL, Isabelle specification

abstraction: 자세한 속사정을 감춘다는 의미 - fixed interface - implementation/representation-independence Abstraction example: functional abstraction - fixed interface: name and its type - implementation-independence add(x,y) sort(a) Types are “the” language of interface

abstraction: 자세한 속사정을 감춘다는 의미 - fixed interface - implementation/representation-independence Abstraction example: data abstraction interface of int queue exception EmptyQ val emptyqueue: queue val enqueue: queue -> int -> queue val dequeue: queue -> int * queue implementation of int queue exception EmptyQ let emptyqueue =... let enqueue q n =... let dequeue q =...

interface of car val makeit: engine * size -> car val getin: car * animal -> car val getoff: car -> car val drive: car -> car implementation of car let makeit(e,s) =... let getin(c,a) =......

Language Support for Data Abstraction Use type-checking to enforce the separation: - abstract data type - module * Type checking checks if every computation is done through the interface. * Type checking checks if no information other than the interface is assumed.

module Queue = struct type queue = T | N of int * queue let emptyqueue = T let enqueue q n = n::q let dequeue q =... end module type QUEUE = sig type queue val emptyqueue: queue val enqueue: queue -> int -> queue val dequeue: queue -> int * queue end : QUEUE In ML, done by signature matching

In C, pretended by.h and.c files queue.h struct queue {...}; struct nqpair {...}; queue *emptyqueue; queue *enqueue(queue*, int); nqpair *dequeue(queue*); queue.c struct queue {...}; struct nqpair {...}; queue *emptyqueue {... }; queue *enqueue(queue* q, int x) {...}; nqpair *dequeue(queue* q) {...}; How to hide and check? 별드레게 무러바

Modules are more general than abstract data type - Modules are collection of definitions - Signatures are interfaces - Signature matching (wrapping modules by signatures) hides those not in the signature - Modules can be parameterized by modules/types Remember the ML modules and module types

Language support for abstraction: - functional abstraction, data abstraction - abstract data type, module ML: module, module type, functor C++: class, class template Ada: package, generic package - type-system automaticallys checks if the programs violates the principle ML/Haskell: sound C++, Ada: not sound Abstraction is the must in civilization. Also true in computer science. Also true in programming: - interface, implementation-independence

Object-Oriented Programming v.s. Value-Oriented Programming imperative v.s. applicative 물건중심 기계중심 명령형 객체지향 값중심 생각중심 함수형 Two representative programming paradigms. What are they?

a := 1; b := 2; c := a + b; d := a + b; 1. c 의 3 이 d 의 3 과 같은가 ? 2. a 를 바꾸면 c 도 바뀔까 ? 3. d 를 바꾸면 c 도 바뀔까 ? 4. e:=c 를 수행하면 c 를 복사해야하나 ? 5. c 갖고 일 봤으면, 그 3 을 없애도 되나 ? 싱거운 질문들

1. c 의 집합이 d 의 집합과 같은가 ? 2. a 를 바꾸면 c 도 바뀔까 ? 3. d 를 바꾸면 c 도 바뀔까 ? 4. e:=c 를 수행하면 c 를 복사해야하나 ? 5. c 갖고 일 봤으면, 그 집합을 없애도 되나 ? a := set(1,2,3); b := set(4,5,6); c := setUnion(a,b); d := setUnion(a,b); 아직도 싱거울까 ? 정수보다는 복잡한 ( 컴퓨터에 구현할 때 하는일이 많은 ) 경우

항상 공유하도록 구현하는 방안 항상 복사하도록 구현하는 방안 두가지의 짬뽕 - 무조건 복사 - 프로그램이해가 쉽다 - 메모리 소모가 크다 - 얼키고 설키고 - 버그없는 프로그램짜기 ? - 물건이 변하지않게 - 최대한 공유

fun eval(Var x, env, mem) = (entry env x, mem) | eval(Add(e,e’), env, mem) = let val (z, mem’) = eval(e, env, mem) val (z’, mem’’) = eval(e’, env, mem’) in (z+z’, mem’’) end | eval(Assign(x,e), env, mem) = let val (v,mem’) = eval(e, env, mem) val mem’’ = assign(mem’, x, v) in (v,mem’’) end