คืนค่าการตั้งค่าทั้งหมด
คุณแน่ใจว่าต้องการคืนค่าการตั้งค่าทั้งหมด ?
ลำดับตอนที่ #11 : Java Ⅳ - What is Object-Oriented Programming?
Object-Oriented
Programming
Why
Object-Oriented Programming?
Object-oriented programming makes our
lives much easier. The larger a program becomes, the harder it gets to
understand the code. Object-oriented programming makes it easy to build and
modify even very large programs. So, it's essential for making applications.
"An object" means "a
thing"; and "to be oriented" means "being centered around
something". So, "object-oriented" means "being centered
around some object". Using object-oriented programming, we can create
software objects that resemble things in the real-world, and then build
programs around them. We'll explain in more detail later on.
Getting
Started
Let's take another look at our
self-introduction program. If two people in the program introduce themselves,
we first need to create two "person objects", and then have them
introduce themselves as if
they were real people. We'll explain more about how to implement this
program using object-oriented programming later.
Classes
and Instances
Properties
and Actions
Real-world objects all have properties and actions. For example,
people have properties (e.g., name, age) and actions (e.g, walking, greeting).
Software objects are modeled after real-world objects in that they also have
properties and actions.
Classes
and Instances
Classes and instances
are two important object-oriented programming concepts. In fact,
"instance" is another name for an object; and a class is a blueprint of an instance.
As shown below, an instance (object) of a person is created based on a class
(blueprint).
Instance
Properties and Actions
An instance has properties and actions
and we define them in a class (the instance's blueprint). Let's say we want to
make a person instance with the properties name
and age, and the actions greeting and walking.
To do this, we'll define those in a Person
class.
Summary
of Classes and Instances
A class is not only a component that
groups methods together (see Java
III), but it's also - and more importantly - a blueprint for instances. An instance is
another word for an object that refers to a specific instance of an object
created using a class.
ความคิดเห็น