Lesson 11
Class Construction Conclusion
This module discussed how to create compound data types from smaller types using classes.
You learned that classes are user-defined data types, and that objects are instances of those classes.
In general, there may be zero, one, or more instances of any given class. Classes have attributes, and objects provide particular values for each attribute.
You also learned how to represent classes, objects, and their attributes in Unified Modeling Language (UML)-style diagrams, and how to draw a
diagram that represents the relationships among classes.
Composition syntax
You simply create objects of your existing class inside the new class.
This is called composition because the new class is composed of objects of existing classes.
Glossary
This module introduced you to the following terms:
- Anonymous object: An anonymous object is essentially a value that has no name. Because the object has no name,
there is no way to refer to them beyond the point where they are created.
Consequently, they have "expression scope", meaning they are created, evaluated, and destroyed all within a single expression.
- Attribute: Components of a class, also known as a field or member variable. Often determined in the design phase by asking the question "what does the class know, track, record, or maintain?"
- Boolean: An expression or variable that can have only a true or false value. Java provides a Boolean type and the literal values True and False.
- Class diagram:A method of displaying a class and its attributes in a reasonably language-independent fashion.
- Composition over inheritance:Composition over inheritance (or composite reuse principle) in object-oriented programming is the principle that classes should achieve polymorphic behavior and code reuse by their composition (by containing instances of other classes that implement the desired functionality) rather than inheritance from a base or parent class
- Field: A member variable that can be properites of the class.
- Function:
- Member variable: In object-oriented programming, a member variable (sometimes called a member field)
is a variable that is associated with a specific object, and accessible for all its methods (member functions).
- Method
- Object diagram: An object diagram shows this relation between the instantiated classes and the defined class, and the relation between these objects in the system.
- Primitive: A data type that is not an object.
- UML:Unified Modeling Language, an industry-standard modeling language used to diagram the relationship of elements to oneanother, interrelated processes within a project, and code architecture.
The next module will discuss the characteristics of operations and methods in classes and how to diagram them.
UserDefined Data Types - Quiz