اتحاد طلبة هندسة الحاسوب والشبكات - المدونه الرسميه C.N.E : Introduction For Object Oriented Part 1-EN

المشاركات الشائعة

Introduction For Object Oriented Part 1-EN




Java is an object oriented based programming language.

But why do we prefer object oriented usually?

We've used functions to simplify our work by saving time and efforts, where we've to write a calling statement each time we want to use the function code.

In the same manner, object oriented programming saves our time and efforts much further by enabling us not to only package a segment of code (as in functions), but to package statements and functions inside one reusable block of code which can be reused as much as you want!
this is the core of using object oriented, it is the principle of reusability.

Object oriented uses classes, a class requires creating an object to become useful, you can make as much objects as you want from one class.

To understand the principle of classes and objects, consider the following  real life example:

Assume that a cars factory wants to manufacture a new model of cars.
To start manufacturing, they must have a prototype for this new model,
let the new model of car be X and its prototype be Y.So, to start manufacturing, the factory should build many X's from the prototype Y, where each X is a useful copy of Y, so to start using this new car, you should have an X, not a Y! because there is only one Y which is useless for the user, while there are many X's!Each X has it's own copy of shape, engine, seats, steering … etc. So, a car X1 can be black while car X2 can be blue.

In object oriented, the prototype Y represents the class, while the car X represents the object, you cannot manipulate directly with Y but you can if you have an X.
Each object has its own copy of variables, so a variable in object X1 can have a different value from the same variable in an object X2.

Because java is an object oriented based language, you must have at least one class to have a useful, working program.

To be continued …

Arabic Version

سامر المناصرة
< >

ليست هناك تعليقات:

إرسال تعليق