| 
	
 | 
 Posted by Markus Ernst on 09/06/05 16:31 
Hilarion wrote: 
>> 
>> As you see there is a circle reference, as book_admin::boss is a 
>> reference back to book. I assume this is bad, and actually there are 
>> some problems that I suspect are originated there. 
> 
> Circular references are not something bad in general. Reference to 
> "parent" in a "child" and to "children" from "parent" are usually ok. 
 
Thank you, I am happy to read this! 
 
>> Is there another possibility to access properties of the calling 
>> object? I did not find any syntax similar to the parent::property 
>> syntax, and I can't use inheritance, as there is already a vertical 
>> inheritance (such as page extends book extends library...), and it 
>> is not possible to inherit two classes. 
> 
> You are using some strange inheritance (as you described it, but it's 
> not in your example code). Book should not extend page, page should 
> not extend book. Book should contain pages (have references to them), 
> page should (or could) have reference to the book. Same with library 
> and books. In your scenario each page can be treated as a book or a 
> library and each book can be treated as a library. You should 
> probably also not use inheritance between book and book admin. 
 
Yes I am sorry the example code was a poor example; I was quite tired and  
annoyed when I wrote it. The classes actually behave the way you say they  
should: 
 
- common_functions 
- entity extends common_functions 
- "thing" extends entity 
 
"Thing" will be the class to be actually instanciated, while some "things"  
can have subclasses (as page extends rubric, because a page needs all the  
properties and methods that a rubric has), and the relations between the  
objects are handled at entity level via parent and order properties - thus  
theoretically every kind of "thing" could be assigned to every other. 
 
Thank you for your clarifications. 
 
Markus
 
[Back to original message] 
 |