~How to make object-oriented programming~

Japanese page(日本語) English page(英語)

This page shows how to make an object-oriented program. If you know some basic things about object-oriented programming, you can understand this contents well.

I found the material (this(sorry, this is Japanese.),this material refers to this book.) which shows how to make an object-oriented program. I have understood how I should make an object-oriented program by this material. I'll introduce the rules to make good object-oriented programs which I adjusted and the effects of this.

Also, I'll show what goal should be reached by object-oriented programming.

What is object-oriented program?

At first, I'll show the meaning of words.

"object-oriented" shows how to program.

When you object-oriented program, you don't necessarily have to use object-oriented programming language.

If you use object-oriented programming language, you can't always make an object-oriented program.

Here, I'll introduce "class" in object-oriented programming languages.

"class" have short tasks(functions) and the variable related with it.

For example, if we consider the class "HP", that will include HP as variable, restore, be injured, and judge if the character is dead or not as tasks.

Advantage of object-oriented program

The advantage of object-oriented program is the following.

Rules to make good object-oriented programs

You can understand what object-oriented program is because you can experience object-oriented program if you make object-oriented programs following the rules.

You can keep good object-oriented program without following the rules if you get familiar with object-oriented program.

The rules are the following.

If you can't remember all rules, it is usefule to remember only the first rule "make class less than 80 rows" or the second rule "make simple class".

It is difficult to make ideal object-oriented programs. At first, you can make programs forgetting ideal object-oriented programs. Then, you can arrange the programs. This arrangement is called "refactoring".

How to combine orders

The object-oriented programs are made of the short and simple orders and the combination of them.

I said "Getter" and "Setter" shouldn't be used in the above.

I'll show how to combine orders without "Getter" and "Setter". You can do that by selecting a class as an argument.

Let me show an example.

class HP{
private int hp;
public boolean deadJudge()
{
if(hp<=0)
{
return true;
}
return false;
}
}
--------------------------------------
class GameOver{
public void execute(HP PlayerHP)
{
if(PlayerHP.deadJudge()==false)
{
return;
}
(The process for "game over")
}



Web search
Site search
Related

Knowledge


Twitter
This is my twitter's profile page.


How to link to my site
I'll show how to link to my site. There are some banners in this page.


Home




Acceptable use policy Privacy policy Contact How to link to my site Twitter
Home