Encyclopedia > Object creation

  Article Content

Object creation

In computer science, object creation is the process of creating objects in object-oriented programming. It marks the onset of lifetime of an object.

In OOP, the meaning of creating objects is far more subtle than simple allocating of spaces for variables. First it is due to that in OOP, the lifetime of each object tends to vary more widely than in the case in conventional programming. There are a lot of subtle questions such as should the object considered alive in the process of creation or about the order of calling initializing code. In some sense, the creation can happen before the beginning of the program when objects are placed in a global scope.

In a typical case, the process follows:

  • calcuate the size of an object - the size is mostly the same as that of the class but can vary.
  • allocation - allocaing memory space with the size of an object plus the growth later, if possible to know in advance
  • binding methods
  • calling an initializing code of superclass
  • calling an initializing code of class being created

Those tasks can be completed at once but are sometimes left unfinished and the order of the tasks can vary and can cause several strange behavior. For example, in multi-inheritance[?], which initializing code should be called first is a difficult question to answer.

It is a complex problem how to create each object as element of an array. Most languages leave this to programmers.



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Museums in England

...   Contents Museums in England Museums in England is a link page for any museum in England. See: List of museums, Museums in Scotland, Museums in Wales, Museums ...

 
 
 
This page was created in 31.5 ms