Primitives, composition, abstraction, and patterns, Python Programming

 

Primitives, Composition, Abstraction, and Patterns

 

We will  start  by thinking about  how  the  PCAP  framework applies to computer programs, in general. We may do that by taking in table 3.1, exploring the PCAP concepts in data, functions, and objects.

 

Data

 

The primitive data  items in most programming languages are things  like integer variables, ?oating point values, and  strings. We can use those into data  structures  such as lists, dictionaries, arrays and records. Creating  a data  structure  allows  us,  at the  most  simple  level,  to think  of a type  of primitive data  elements as if it were  one thing,  freeing  us from information.   Sometimes, we just think  of a section  of data,  not  in type  of its relaying representation, but  in terms  of what  it shows.  So, we may think  of a set of functions, or a family  tree, without thinking whether it is an array or a list in its basic representation. Abstract data  types  gives a way  of abstracting away  from representational details  and allowing us to focus on what  the data  really means.

 

 

Procedures

 

The primitive procedures of a language are things  like built-in  numeric operations and  basic list application. We may combine these  using  the facilities of the language, such as if and  while, or by using  procedure composition (f(g(x))).  If we try  to abstract away  from  the details  of how a particular calculation is done,  we can describe  a new  function; de?ning a function allows  us to use it for computational programs without thinking about  the information  of how  those  computational jobs get completed.   You can think  of this  process  as essentially creating a new  primitive, which  we may then  use  while  ignoring the information  of how  it is created.  One  way  to save common patterns of abstraction in method is to abstract over functions themselves, with higher-order methods.

 

Objects

 

Object-oriented programming provides a number of methods of abstraction and  pattern capture in both  data  and  function. At the most  basic level, objects can be used  as files, combining with primitive data  component. More usually, they give strategies for jointly abstracting a data  representation and the procedures that work  on it. The features of polymorphism and inheritance are particularly important.

 

Procedures

Data

Primitives

Means of combination

Means of abstraction

Means of capturing patterns

+, *, ==

if, while, f(g(x))

def

higher-order procedures

numbers, strings

lists, dictionaries, objects

ADTS, classes

Generic functions, inheritance




 

 

 

 

 

 

Table 3.1          Primitives, combination, abstraction, patterns framework for computer programs

 

Posted Date: 8/11/2012 1:30:02 AM | Location : United States







Related Discussions:- Primitives, composition, abstraction, and patterns, Assignment Help, Ask Question on Primitives, composition, abstraction, and patterns, Get Answer, Expert's Help, Primitives, composition, abstraction, and patterns Discussions

Write discussion on Primitives, composition, abstraction, and patterns
Your posts are moderated
Related Questions
python program of motion of a particle in viscus medium

List mutation and shared structure Lists are mutable data  structures, which defines  that  we can actually modifies  the values  stored in their components. We do this by usi

For this assignment, you are to: 1.    Modify the output format of your Python script from Assignment 1 to match the input format of your C program from Assignment 2. 2.    W

A program to count how many files are on the file system which displays summary information regarding the total number of bytes used by all files and a breakdown of the number of b


Assume you have a truck which has to travel across a desert from the base camp at position 0 (left) to the target camp at position 4 (right). The intermediate positions 1,2, and 3

Define a function that draws a pentagon of a size you provide when you call the function. Include a ''''''docstring'''''' as the first line of the function''s body — it tells the p

This assignment involves writing a program to solve word search puzzles. For example in the following word grid it is possible to find the words active, stock, ethernet and java. N

Python Programs You must submit the source code and samples of output for each program.Please do not provide python file (eg. Filename.py). Copy all source code to one word fi

The goal of this exercise is to write a \business phrase" generator, which each time it is called produces lines of business speak, such as: It's time that we became uber-effici