CLASS
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior. Data field members (member variables or instance variables) enable a class object to maintain state. Other kinds of members, especially methods, enable a class object's behavior. Class instances are of the type of the associated class.
A class usually represents a noun, such as a person, place or (possibly quite abstract) thing, or something nominalized. For example, "Banana" is an instance of the class "Fruit" (a "Fruit" object). It is of the type "Fruit".
Classes consist of and are composed from structural and also
behavioral constituents, though there may not be a requirement to
include any structural or behavioral constituents at all. Programming
languages that include classes as a programming construct offer support
for various class-related features. These features, and the syntaxes
with which they are provided, vary greatly. Various control features
such as member access specifiers may be provided by a language.
Structure
Some programming languages support specification of invariants as part of the definition of the class, and enforce them through the type system. Encapsulation of state is necessary for being able to enforce the invariants of the class.
Every class implements (or realizes) an interface by providing structure
(i.e. data and state) and method implementations (i.e. providing code
that specifies how methods work). There is a distinction between the
definition of an interface and the implementation of that interface. In
most languages, this line is usually blurred, because a class
declaration both defines and implements an interface. Some languages,
however, provide features that help separate interface and
implementation. For example, an abstract class can define an interface without providing implementation.
Languages that support class inheritance also allow classes to
inherit interfaces from the classes that they are derived from. In
languages that support access specifiers,
the interface of a class is considered to be the set of public members
of the class, including both methods and attributes (via implicit getter and setter methods);
any private members or internal data structures are not intended to be
depended on by client code and thus are not part of the interface.
The object-oriented programming methodology is designed in such a way
that the operations of any interface of a class are usually chosen to
be independent of each other. It results in a layered design where
clients of an interface use the methods declared in the interface. An
interface places no requirements for clients to invoke the operations of
one interface in any particular order. This approach has the benefit
that client code can assume that the operations of an interface are
available for use whenever the client holds a valid reference to the
object.
OBJECT
In computer science, an object is any entity that can be manipulated by the commands of a programming language, such as a value, variable, function, or data structure. (With the later introduction of object-oriented programming the same word, "object", refers to a particular instance of a class)
"Objects" are the foundation of object-oriented programming, and are fundamental data types in object-oriented programming languages. These languages provide extensive syntactic and semantic support for object handling, including a hierarchical type system, special notation for declaring and calling methods, and facilities for hiding selected fields from client programmers. However, objects and object-oriented programming can be implemented in any language.
Objects are used in software development to implement abstract data structures,
by bringing together the data components with the procedures that
manipulate them. Objects in object-oriented programming are key in the
concept of inheritance; thereby improving program reliability[attribution needed], simplification of software maintenance[attribution needed], the management of libraries,
and the division of work in programmer teams. Object-oriented
programming languages are generally designed to exploit and enforce
these potential advantages of the object model. Objects can also make it
possible to handle very disparate objects by the same piece of code, as long as they all have the proper method.
Properties of an object
Three properties characterize objects:
- Identity: the property of an object that distinguishes it from other objects
- State: describes the data stored in the object
- Behavior: describes the methods in the object's interface by which the object can be used
METHOD
In object-oriented programming, a method is a subroutine (or procedure or function) associated with a class.
Methods define the behavior to be exhibited by instances of the
associated class at program run time. Methods have the special property
that at runtime, they have access to data stored in an instance of the
class (or class instance or class object or object) they are associated with and are thereby able to control the state of the instance. [1] The association between class and method is called binding. A method associated with a class is said to be bound to the class. Methods can be bound to a class at compile time (static binding) or to an object at runtime (dynamic binding).[2]
Walang komento:
Mag-post ng isang Komento