BACKGROUND:
One goal of Object Oriented programming is to write independent, re-usable classes. In making the switch from procedural to object oriented coding, I created my first class in this category. Web_Author.class.php takes any two-dimensional array generated by mysql_fetch_assoc and writes a web table with headings from the array data.
For this method to be really useful in a wide variety of contexts, I need to be able to control how the data is displayed in each cell. Depending on the situation, I may want the data to be read only, textbox, textarea box, menu, checkbox, or radio button.
I solved the problem by having the $val in the $key => $val pair sent to a function in the main program called "conditions". "conditions" contains a switch statment that determines how $val will be packaged in that particular cell and returns it to the method. If $val isn't intercepted by any case:, it falls through to the default block and gets returned.
QUESTION
How does an experienced PHP object oriented programmer handle dependencies like this? If I forget to include the "conditions" function in the main program, I lose a huge amount of functionality in this method. I could probably keep it from crashing altogether with an "if exists" phrase, but like I said, I lose a lot of value. How does an experienced oop coder ensure that dependent classes appear together in a new application?