Re: design?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sjef wrote:
> Hi there,
> 
> I am starting a new, very small project. A simple question and answering 
> form. In one screen, question and answer can be typed, the strings will be 
> saved in a database table questions which holds question and answer (as 
> there is only one answer to a question). There will be a webpage displaying 
> all the questions, clickable to the webpage of the answer to the question 
> clicked.
> 
> I want to create a class Question for dealing wiht the questions and a class 
> answer for the answers. Each could contain an array with the their part of 
> the content of the database table. The class Question manages the class 
> Answer, so when instantiating the Question, the Answer will follow.
> Beside of this I want to create a 'visual' component class that creates the 
> lists as displayed on the webpage.
> 
> Is this a good idea? Or should I not bother, and just create one class 
> Question that also deals with the Answers.
> 

You have essentially three pages:
  one that displays a form and inputs the entered data to a database;
  one that gets a list of questions from the database;
  one that displays a specific question/answer pair.

As a ballpark estimate, I'd say that the above should be possible in
under 100 lines of PHP code.

You are looking at creating a Question class, an Answer class and a
Visual/List class.  The net result being that you double the number of
PHP files and considerably increase the amount of code, there isn't much
opportunity for code reuse here.

Now, if the objective is to play with php OOP then go ahead.  I would
even suggest a DB class, a TableRow class, the Question and Answer then
inherit from the TableRow, a TableRows class from which your List class
would inherit.  Maybe throw a few in to control the templates etc. as well.

If the objective is just to get the job done and the site out, I don't
see why you should bother with OOP at all.


David

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux