music |
OSdata.com |
object oriented programming
summary
This subchapter looks at object-oriented programming.
free computer programming text book projecttable of contents
|
music |
OSdata.com |
This subchapter looks at object-oriented programming.
free computer programming text book projecttable of contents
|
This subchapter looks at object-oriented programming.
Classes are the general principles and rules of how each object acts or behaves.
A class is a blueprint or prototype from which objects are created.
Oracle
A class is an implementation of an abstrated data type and encapsulates both data and operations.
Objects are a specific instance or occurence of a class.
An object is a software bundle of related state and behavior. Software objects are often used to model the real-world objects that you find in everyday life.
Oracle
An object is a run-time instance of a class.
A class is a set of rules. A class never runs. No memory is ever allocated for classes.
Objects are actually created in memory and run.
Inheritance provides a powerful and natural mechanism for organizing and structuring your software.
Oracle
A class inherits state and behavior from its superclass. Inheritance is a mechanism for organizing and structuring software programs.
An interface is a contract between a class and the outside world.
Oracle
A package is a namespace for organizing classes and interfaces in a logical manner.
Oracle
Objects interact and communicate with each other by passing messages.
Object oriented languages include:
Methods, message passing, abstraction, prototypes, blocks, and modules are also important characteristics.
Lists of some popular OO programming languages.
The original OO languages:
Some pure OO languages:
Some mostly OO languages:
Some historically procedural languages extendedd with OO features:
Languages with some OO features:
JavaScript is partially object oriented.
Michael Feathers proposed SOLID, meaning Single responsibility, Open-closed, Liskov substitution, Interface segregation and Dependency inversion.
A class should have only a single responsibility.
Classes should be open for extension, but closed for modification.
Encapsulate what varies.
Favor composition over inheritance.
Depend on abstractions. Do not depend on conrete classes.
High level modules should not depend on low level modules. Modules should depend on abstractions.
Abstractions should not depend on details.
DRY (Dont Repeat Yourself).
A class should have only one reason to change. [Tom DeMarco 1979 book Structured Analysis and Systems Analysis]
Program to interface, not implementations.
Many client-specific interfaces are better than one general-purpose interface.
Clients should not be forced to depend upon the interfaces that they dont use. Interface Segregation Principle.
Derived types must be completely substitutable for their base types. [Barbara Liskov in a 1987 Conference on Object Oriented Programming Systems Languages and Applications, Data abstraction and hierarchy]
Delegate to the respective class./p>
Suggestions from Bjarne Stroustrup, creator of C++
[1] When you program, you create a concrete representation of the ideas in your solution to some problem. Let the structure of the program reflect those ideas as directly as possible.
[a] If you can think of it as a separate idea, make it a class.
[b] If you can think of it as a aseparate entity, make it an object of some class.
[c] If two classes have something signficant in common, make that a base class. Most classes in your program will have something in common; have a (nearly) universal base class, and design it most carefully.[2] When you are defining a class that does not implement a mathematical entity like a matrix or a complex number, or a low-level type like a linked list:
[a] Dont use global data.
[b] Dont use global (nonmember) functions.
[c] Dont use public data members.
[d] Dont use friends, except to avoid [a], [b] or [c].
[e] Dont access data members of another object directly.
[f] Dont put a type field in a class, use virtual functions.
[g] Dont use inline functions; except as a significant optimization.
It should be noted that no ethically-trained software engineer would ever consent to write a DestroyBaghdad procedure. Basic professional ethics would instead require him to write a DestroyCity procedure, to which Baghdad could be given as a parameter.
Nathaniel S. Borenstein
I invented the term Object-Oriented, and I can tell you I did not have C++ in mind.
Alan Kay
If the particulars are to have meaning, there must be universals.
Plato
43 Finally, the language provides a powerful means of parameterization of program units, called generic program units. The generic parameters can be types and subprograms (as well as objects and packages) and so allow general algorithms and data structures to be defined that are applicable to all types of a given class. :Ada-Europes Ada Reference Manual: Introduction: Language Summary See legal information
1 Ada is a programming language designed to support the construction of long-lived, highly reliable software systems. The language includes facilities to define packages of related types, objects, and operations. The packages may be parameterized and the types may be extended to support the construction of libraries of reusable, adaptable software components. The operations may be implemented as subprograms using conventional sequential control structures, or as entries that include synchronization of concurrent threads of control as part of their invocation. The language treats modularity in the physical sense as well, with a facility to support separate compilation. :Ada-Europes Ada Reference Manual: Section 1: General See legal information
At the basis of object oriented programming is the idea of classification.
Classification is the grouping of things.
Socrates and Plato proposed in the theory of forms that everything we observe in physical reality is a mere shadow of the Form. The Form is aspatial (transcends space), atemporal (transcends time), and extra-mental (beyond mere thought).
In philosophy, a concept is the basic idea of form, as proposed by Socrates and Plato. A referent is a specific example of a concept..
So, the dog would be the concept and Sparky or Fluffy would be the referent.
The concept is the basic category (in object oriented programming, the class), while the referent is an individual member of the concept (in object oriented programming, the instantiation or instance.
A look at the mathematical basis for object oriented programming will reveal an early mistake that has caused a great deal of confusion and messiness to modern implementations.
Unfortunately, the first attempts dealt with a handful of implementation ideas that fit will with a tree-based structure of classification. This was great for those first experimental attempts, because tree structures were well understood and easy to implement.
It didnt take a long time for object oriented programming to be applied to concepts that were not inherently tree-like. This led to messy hacks such as multiple inheritance.
It is probably way too late for me to suggest that we should introduce a much cleaner non-tree approach that allows for better mapping of real world concepts to computer programs and algorithms.
Even though it is probably too late to make use of the underlying math, it it worth looking at it.
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
return to table of contents
free downloadable college text book
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
previous page | next page |
Tweets by @osdata |
free computer programming text book projectBuilding a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming. If you like the idea of this project, Supporting the entire project: If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church) free downloadable college text book on computer programming. |
This web site handcrafted on Macintosh computers using Tom Benders Tex-Edit Plus and served using FreeBSD .
UNIX used as a generic term unless specifically used as a trademark (such as in the phrase UNIX certified). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.
Copyright © 2010 Milo
Created: November 1, 2010, 2011
Last Updated: August 14, 2013
return to table of contents
free downloadable college text book
previous page | next page |