Created June 7, 2009
Last updated June 7, 2009
Classes and Objects
In this page, I will explain "Classes" and "Objects".
By the way, you should correctly understand "Classes" and "Objects".
Because, even if you understand "Inheritance" etc. , it becomes not significant.
Incidently, How many times did I fail to understand "object-oriented" because I had not understood "Classes" and "Objectes"?
The relation between "Classes" and "Objects" resembles the relation between "Tables" and "Records" in the Relational Database(RDB) closely.
First of all, if you understand it, OK.
First of all, please read the quotation from the following e-words.
In object-oriented programming, it means the existent physical or abstract subject that the software is trying to deal with, which is modeled as a collection of datas and methods and reproduced on a computer. The model that defines object is called class.
Were you able to understand?
Hereafter, I will explain concrete example of Classes and Objects. Previously, please read the following notes.
- The class that I explain by the following examples is only an "entity class".
There is various kinds of classes even if it is said that it will class.
All classes that put it out to the following concrete examples correspond to the entity class in the BCE pattern. In the BCE pattern, there are a "control class" and a "boundary class" besides the entity class.
There is other kinds of classes by applied pattern and subject (For instance, for embedded system).
If you have studied object-oriented a little, I think that you have heard the utility class. For instance, it is a class( "utility class" ) that collected a mere calculation and the function like java.lang.Math class of Java. This class is a class not generable as for the instance.
It doesn't explain them (Excluding the entity class) here.
Because the entity class was the most basic class among some kinds of classes, I decided it to giving this time to the example.
By the way, Though I think that you understand if you have drawn the ER diagram( Because "E" of the ER diagram is E of the entity ), the entity class is a relating summary of data though explained as follows.
- I think that you understand from the following examples even a little.
- Please do not think that you understand the precise definition from the following examples.
There is data shown in Figure 1. Draw the class diagram.
Figure 1 - The data of telephone number
Note. In parentheses, it is a data type.
Figure 2 - Class diagram extracted from the data of telephone number
In Figure 2,"TelephoneBook" is class name.
And, "name" and "telephoneNumber" is attribute name.
The meaning of Figure 2 is to mean the data of a record in Figure 1 is composed of the "name" and the "telephoneNumber".
And, "name= "John Smith",telephoneNumber= "200-200-1234"" is object of TelephoneBook class. (Please think that one record a record in Figure 1 is an object of Telephone book class. )
By the way, the class name was suitably given.
The attribute name was taken from the column name in Figure 1. ( The type of the attribute is also the same. )
The visibility of the attribute was omitted.
It notes it again, and "Class" mentioned here is "Entity class", and other classes do not become like this example. (If possible, please read "2.Notes before explanations" again.)
There is data shown in Figure 3. Draw the class diagram.
Figure 3 - Student information and result
Note. In parentheses, it is a data type.
Figure 4 - Class diagram extracted from student information and result information
I will explain Figure 4 from an easy thing.
Though "/" (slash mark) has adhered ahead of "totalScore" and "averageAcore", it means that these attribute are computable from other attributes etc. Such an attribute is said, "derived attribute".
Usually, An attribute in the class diagram is programmed to public module level variables and public moudle level propety procedure in class module with Excel VBA or VB6.0.
But, a derived attribute is programmed only to propety procedure. ( Though it is possible to program even by the function procedure, the property procedure is usually used. )
The straight line with which the StudentInformation class and the ResultInformation class are connected is a "association". And, the figure written soon to be near is a "multiplicity".
"*" written near the ResultInformation class means student information has a lot of result information.
Oppositely, "1" written near the StudentInformation class means that result information is each student's.
It explains this programming method at another chance because it is difficult for a moment.
(Actually, it doesn't go well if the class that manages result information is not defined when programming it. Though it need not be so, There is "Workbooks object" that manages the "Workbook object" in the Excel library, and it is easier to define the collection class in the future. But The range of the explanation on this page is exceeded , because it is not a Entity class. )
I doesn't assume the responsibility of any damage that occurs because of the use of this page.
Microsoft ,Windows ,Visual Basic and Excel are registered trademarks of Microsoft Corporation in the United States and other countries.
Visual Basic® for Applications may represent a VBA.
Mac ,Mac OS ,Mac OS X ,AppleScript are trademarks of Apple Inc., registerd in the U.S. and other countries.
Other brands and their products are trademarks or registered trademarks of their respective holders and should be noted as such.
The author of this page and these companies do not have any relationship.