Object Oriented Programming Languages And Eventdriven Programming Dorian P Yeager instant download
Object Oriented Programming Languages And Eventdriven Programming Dorian P Yeager instant download
https://ebookbell.com/product/object-oriented-programming-
languages-and-eventdriven-programming-dorian-p-yeager-42253260
https://ebookbell.com/product/objectoriented-programming-languages-
and-eventdriven-programming-dorian-p-yeager-5226670
https://ebookbell.com/product/object-oriented-programming-languages-
and-eventdriven-programming-dorian-p-yeager-42252990
https://ebookbell.com/product/object-oriented-programming-languages-
and-eventdriven-programming-dorian-p-yeager-43143164
https://ebookbell.com/product/object-oriented-programming-languages-
and-eventdriven-programming-dorian-p-yeager-42252604
Objectoriented Programming Languages And Eventdriven Programming
Yeager
https://ebookbell.com/product/objectoriented-programming-languages-
and-eventdriven-programming-yeager-232074700
https://ebookbell.com/product/concepts-and-semantics-of-programming-
languages-2-modular-and-objectoriented-constructs-with-ocaml-python-c-
ada-and-java-1st-edition-therese-hardin-34071910
https://ebookbell.com/product/objectoriented-programming-languages-
interpretation-iain-d-craig-2095070
https://ebookbell.com/product/objectoriented-programming-languages-
iain-d-craig-46201296
https://ebookbell.com/product/the-interpretation-of-objectoriented-
programming-languages-2nd-edition-iain-craig-ma-4199548
O -O
P L
A
E -D P
LICENSE, DISCLAIMER OF LIABILITY, AND LIMITED
WARRANTY
By purchasing or using this book (the “Work”), you agree that this
license grants permission to use the contents contained herein, but
does not give you the right of ownership to any of the textual content
in the book or ownership to any of the information or products
contained in it. This license does not permit uploading of the Work
onto the Internet or on a network (of any kind) without the written
consent of the Publisher. Duplication or dissemination of any text,
code, simulations, images, etc. contained herein is limited to and
subject to licensing terms for the respective products, and
permission must be obtained from the Publisher or the owner of the
content, etc., in order to reproduce or network any portion of the
textual material (in any media) that is contained in the Work.
M L A I LLC (“MLI” or “the
Publisher”) and anyone involved in the creation, writing, or
production of the companion disc, accompanying algorithms, code,
or computer programs (“the software”), and any accompanying Web
site or software of the Work, cannot and do not warrant the
performance or results that might be obtained by using the contents
of the Work. The author, developers, and the Publisher have used
their best efforts to insure the accuracy and functionality of the
textual material and/or programs contained in this package; we,
however, make no warranty of any kind, express or implied,
regarding the performance of these contents or programs. The Work
is sold “as is” without warranty (except for defective materials used
in manufacturing the book or due to faulty workmanship).
The author, developers, and the publisher of any accompanying
content, and anyone involved in the composition, production, and
manufacturing of this work will not be liable for damages of any kind
arising out of the use of (or the inability to use) the algorithms,
source code, computer programs, or textual material contained in
this publication. This includes, but is not limited to, loss of revenue
or profit, or other incidental, physical, or consequential damages
arising out of the use of this Work.
The sole remedy in the event of a claim of any kind is expressly
limited to replacement of the book, and only at the discretion of the
Publisher. The use of “implied warranty” and certain “exclusions”
vary from state to state, and might not apply to the purchaser of this
product.
O -O
P L
A
E -D P
Dorian P. Yeager
Copyright ©2014 by Mercury Learning and Information LLC. All
rights reserved.
Preface
Acknowledgments
Chapter 9 Python
9.1 Python: a Highly Simulated OOPL with Unobtrusive Syntax
9.1.1 Indentation
9.1.2 Keyword Arguments
9.2 The IDLE Environment and Console I/O
9.2.1 Console Output
9.2.2 Console Input
9.3 Python Data Types
9.3.1 Numeric Types
9.3.2 NoneType and the Value None, and Uninitialized
Variables
9.3.3 Sequence Types
9.3.4 String Operations
9.3.5 Hashing and the Built-In Keyed Collections
9.4 Python Scopes and Information Layering
9.4.1 Function Definitions and Function Objects
9.4.2 Class Definitions
9.4.3 Modules
9.4.4 Decorating an Object
9.4.5 Storage Management and Dynamic Variable Deletion
9.5 Sequence Control in Python
9.5.1 Exception Handling
9.5.2 The with Construct
9.5.3 Operator Precedence
9.5.4 Statement-Level Sequence Control
9.5.5 Generators, Iterators, and Comprehensions
9.5.6 Operator Overloading
9.6 Inheritance and Polymorphism
9.7 Functional Features of Python
9.8 The External Environment
9.8.1 Files and I/O
9.8.2 Python Features for Persistence—pickle and shelve
9.9 The tkinter Library and GUI Applications
9.9.1 Creating a Root Window in tkinter
9.9.2 Adding a Button and a Label
9.9.3 Threads and Windows
9.9.4 “Modal” Windows
9.9.5 Widgets and Events in tkinter
9.9.6 Canvas Objects and How to Draw with Them
9.10 A Postscript: Python, Smalltalk, and a Culture of Reusability
9.11 Summary
Appendix A Event-Driven Project Ideas
Appendix B Answers to Odd-Numbered
Exercises
Appendix C About the CD-ROM
PREFACE
TO THE STUDENT
Each of you brings to the table a year or more of study in a
particular object-oriented programming language. Some of the
subtleties of those languages you have already encountered,
probably enough of them so that you have already experienced the
difficulty of mastering some of the intricate concepts of object-
oriented programming languages. Mixed in with the concepts of
inheritance, polymorphism, generic programming, and several
variants of information hiding and access control, there are
hundreds of smaller design decisions which impact these larger
issues and impact each other as well. Most of these design
decisions are treading in well-worn paths, because imbedded in
these newer languages are myriad concepts which have been used
in languages of the past.
Your instructor has carefully selected those chapters on which
you are going to concentrate, but I encourage you to read and study
the other chapters as time permits. There is great beauty in a
consistent programming language design, and there is much to be
learned even from some of the apparently poor design decisions
which were made. All programming languages have flaws, but
usually those flaws were deliberately accepted by the designer in
order to achieve a specific goal. You may agree or disagree with the
goal, but it is important to grasp the reasons why a design decision
was made.
Event-driven programming can be frustrating and challenging,
and certainly great fun. It is included here because it is an important
tool for producing more useful and creative software, but also
because it is a showcase for the advantages of object-oriented
design. From the beginning graphical user interfaces were a major
motivation for the design of object-oriented languages, because the
hierarchy of types of objects seen on a display device (and
interacted with using a mouse and keyboard) strongly suggests a
hierarchy of software types. We dip into several EDP environments
in this text, and our purpose is always to not only give the reader the
flavor of how it feels to develop applications in that environment, but
to actually cover enough of the details so that medium-sized
projects can be undertaken and completed by the student within the
framework of a semester of college.
Omitted from the historical context presented in this text are a
great variety of languages with unique and creative designs which
have motivated today's designs. A short list of missing languages
includes APL, LISP, PROLOG, FORTRAN, COBOL, Snobol, Pascal,
and Ada. Contrary to popular opinion, none of these languages is
“dead.” Variants of them are still in use, and it is likely that they will
continue to grow and evolve and be of continuing usefulness
indefinitely. The reason for their longevity lies in their inventiveness.
At the core of each lies an idea that motivated the design, and in all
cases where the idea was clear and communicated well, there was
staying power.
If you enjoy this text, you will also enjoy studying the design and
implementation issues encountered in other languages, object-
oriented or otherwise, and you are strongly encouraged to do so. It
is likely that during that study some new types of design solutions
will take shape in your mind that would otherwise never have
occurred to you. Since the invention of the wheel, our tools have
shaped our thinking. For this reason, programming language design
lies at the heart of the discipline of computer science. I hope this text
motivates you to continue your study in this very important area.
TO THE INSTRUCTOR
The last twenty years have seen a dramatic change in computer
science curricula, engendered in part by the introduction of object-
oriented languages into those curricula and by the near-universal
use of such languages as a tool for teaching software design and
construction principles to Computer Science majors. The large
majority of departments use either Java or C++ as the major
teaching language in their curricula, and object-oriented (OO)
programming languages (OOPLs) as a whole have become very
important in our curricula. Because of the breadth and density of
concepts in this set of languages, and the fact that each is
accompanied by a sophisticated library of container classes, classes
for graphics and event-driven programming, and other concept-
heavy classes, there is now room within the OO paradigm to discuss
a large part of what we have always taught in the Programming
Languages course, while building on a broad, established base of
familiarity on the part of our students. This text is meant to be a
resource for instructors wishing to teach programming language
design and implementation from that perspective.
The student using this text should have completed a year of
study in an object-oriented programming language. The text
generalizes from that year of experience in order to present the
foundational principles of programming languages, drawing on the
students' OO background while widening their perspectives. It uses
a historical approach to link the older procedural languages to
current object-oriented languages, tracing the roots of the latter to
their origins in Simula 67. The main body of the text teaches a
selected set of object-oriented languages from the standpoint of
language design and implementation, beginning with the historically
significant and highly original Smalltalk language. Enough
information is presented to allow the students to see the depth and
power of each language, and to be able to write some interesting
programs.
Recognizing the growing importance of language-integrated
libraries, the author presents in the context of each language a
sampling of library types, including the standard types of container
classes and associated iterators. In the same way, in keeping with
the historical and current symbiosis between OO languages and
event-driven programming (EDP), the text includes an early chapter
on the basics of EDP, and follows up on that theme by including a
detailed introduction to an EDP library for each of the languages
covered.
The historical theme is reinforced in a pivotal chapter on C++
and Java similarities, tracing those languages back to their roots in
C. The student is made to see how dramatically two languages can
diverge from a common base, given two different sets of design
goals. Further chapters complete the study of C++ and Java and
provide a detailed and critical introduction to C# and Python.
Common EDP themes such as graphics, animation, and user
controls are introduced for each language, using as vehicles the
MFC library (C++), Swing (Java), Windows Forms (C#), and Tkinter
(Python).
The object-oriented paradigm isn't perfect, and it is certainly true
that a design is not necessarily good just because it is object
oriented. But the object-oriented languages taken as a group are a
very rich and rewarding study. The sheer number of concepts
involved in learning Java or C++ or any other object-oriented
language, and the requirement we now place on our students to
learn those concepts early in the curriculum, has enriched our
curricula. The accompanying demand on our students for a higher
degree of sophistication has changed the way we teach
programming and software engineering.
A course based on this text makes a natural alternative or
companion to the traditional Programming Languages course. A
variety of ways suggest themselves to accommodate such a course
into the curriculum. One idea is to offer a two-course sequence in
Programming Languages, using this as either the first or the second
course. Or two alternative courses could be offered, perhaps during
alternate years. On the other hand, if this course is used as the only
Programming Languages course at the undergraduate level, there is
ample material in it to satisfy the ACM curriculum requirements.
Along with a good theory course, it should prepare the student well
for the study of the theory, design, and implementation of
programming languages at the graduate level.
ACKNOWLEDGMENTS
A CONTEXT-SENSITIVE
INTRODUCTION
Definition
Here we introduce the term object. If we use the term in its most
general sense, we can call any data entity an object. In fact, the
term data object has been around a long time and has been used to
mean nothing more than a stored data value or aggregate of values,
to which a specific type has been assigned. But in the context of
object-oriented programming the term takes on additional
connotations. In that context, we speak of an object as consisting of
two parts: its attributes and its behaviors. Such an object is an
instantiation of an abstract data type, and in that context the
attributes are the data components of the ADT and the behaviors
are the included operations. But the strongest sense of the term
object is in the context of object-oriented languages, where more is
required to use the term than a simple abstract data type.
Definition
In the same sense as point and line are used as undefined terms in
geometry, we will start here with some undefined, or vaguely
defined, terms. To begin with, we will use the term symbol with only
the vague definition that it is a name with a meaning, either
predefined or programmer-defined. We use the term identifier to
mean a symbol with a name which is allowed to be multi-character,
which is used by the programmer for his own purposes, and which is
atomic, i.e., not divisible into component parts. An identifier might be
used, for example, to name a stored object or a type. There are in
any given language some simple formation rules for what
constitutes a valid identifier, and we will assume the reader has
experience using identifiers. A keyword is a symbol that may
conform to the rules for formation of identifiers, but which has a
language-defined meaning in certain contexts. Examples of symbols
often used as keywords are if, else, and while. A keyword which
cannot be used for any other purpose than its language-defined
meaning is called a reserved word.
We make only a weak attempt to define the term value. The term
is general enough to apply to a wide range of well-conceived and
rigorously defined entities, but in general it has two essential
aspects: it has meaning in some context, and it can be represented
by an encoding into a string of binary digits. A literal is a self-
defining symbol, i.e., one which has a value and whose name
describes its value. Some examples taken from the C-derived
languages are the character string literal “A string literal” and the
double-precision floating point literal 25.7. The term token is used to
refer to an indivisible symbol in the text of a program. Examples are
identifiers, keywords, operator symbols, literals, and bracketing
symbols (e.g., parenthesis characters and square bracket
characters).
A constant is a named, immutable value. Depending on the
implementation, the name of a constant refers to either (1) a storage
address which is initialized with the particular value at the time the
constant is defined and for which an attempt to change its value
causes an error condition, or (2) the value itself, which replaces the
name wherever it is used. A variable is a named storage location
whose value is subject to change.
An association is a (symbol, meaning) pair. In most languages
the only associations under the programmer's control are identifier
associations, in which the symbol used is formed as a valid identifier
in the language. In a few languages the programmer may also
introduce his own associations for operator symbols, such as the
plus sign. A scope rule is a rule for determining at any given time, or
at any given location in the text of a program, the set of associations
which currently applies.
Definition
ebookbell.com