[Techtalk] object oriented references

Emma Jane Hogbin emmajane at xtrinsic.com
Wed May 7 23:42:03 EST 2003


On Thu, May 08, 2003 at 10:41:15AM +1000, Jacinta Richardson wrote:
> I don't know what level intermediate is.  I know that sounds silly but
> basically I don't know what you know and don't know, and therefore I don't
> know where to start in telling you stuff.

Heh. Fair enough. Here's the kind of article that I've been reading up to
now:
	Back to class
	http://www.devshed.com/Server_Side/PHP/BackToClass/page4.html
	OO Design: Abstract Classes
	http://phpbuilder.com/columns/griffin20030207.php3?print_mode=1
	Classes and PHP
	http://phpbuilder.com/columns/rod19990601.php3
	Object Oriented Programming in PHP
	http://phpbuilder.com/columns/luis20000420.php3
	(and a bunch more like this for PHP)
	Yib's Pet Rock primer
	http://cmc.uib.no/moo/yib/

I want something that isn't a PHP tutorial...the Perl Monk articles you
recommended are along the same vein--too general or maybe just not the
information I'm looking for. I'll take a closer look through the Perl 
Training notes though.

> Perhaps you need a Questions class as well.  Which may be a container for
> each Question object.  In the big-ugly project I mention in the article
> "When/Where is OO useful" we ended up having Hosts objects as well as Host
> objects.  Domains objects as well as Domain.  Subnets and Subnet.  We had
> to have.  So the code would basically say:
> 	my @subnets = Subnets->get_all();

I've tried to be very careful about creating new objects. I think it's
more of which function should go into what object for the most efficient
code. The projects I've worked on up to now have been so small that I
haven't worried about how efficient the code was.

> As for what functions should got into Part, Question, Quiz... well that
> depends on what these things mean.  Perhaps you can give us object
> descriptions:

Sure...I know that conventions have methodsLikeThis but I find _s easier
to read. Much of this code is several months old. It works, but it was my
first ever attempt at making objects. There's already stuff that I really
don't like about it, but that's what I'm trying to figure out now.

Quiz: a "quiz" of sorts. There are currently two different types in use:
language placement test (with 5-10 different types of questions); survey
with non-marked answers that are used for the questionnaire "pre-test"
	get_meta() 	// global information about the quiz template
	sum_quiz() 	// add up the points for a perfect quiz
	prereq() 	// pre-requisite quizzes that must be completed before
			// this quiz
	stu_prereq 	// check to see if this student has done the prereq
	start_quiz() 	// open a new quiz "summary" that includes info about
			// start and finish time, it's been marked and what
			// email the student received
	get_stusummary() // get the id from the summary table for this
			// student
	get_parts() 	// get all the parts for this quiz
	store_parts()	// update the property for the object that holds
			// an array of all parts in the quiz
	select_part()	// create an HTML list of all parts in the quiz
	get_all_questions() // get the questions for this quiz
	[then a bunch of functions that are from an old file and are
	currently not being used -- they're for marking quizzes and
	producing reports of submitted quizzes from students]

Part: all questions must be contained in a part. A Quiz contains 1 or many
parts. For language placement tests each part has a theme e.g. listening
comprehension, grammar, etc.
	get_part()	// get info about only this part
	get_questions()	// get the questions in this part
	get_all_questions() // get the questions in the whole Quiz
	ask_questions()	// return questions for student viewing instead of
			// editing
	store_questions() // Put a copy of all questions for this part
			// into an array
	store_all_questions() // All questions in the Quiz
	sum_part()	// the points for this part
	sum_todate()	// cummulative marks up to and including this part
	select_question() // HTML list to select one question in a part
	save_part()	// save the HTML page for editing the part

Question: a single question
	get_deets()	// get details about a question including type
	get_edeets()	// get details about a survey part
	set_deets()	// set all the things about this question
		// properties include things like: score, answer, display
		// multiple choice options in random order, type of
		// question, if there's a pre-fill for a fill-in-the-blank
		// question, etc
	question_types() // edit interface for the question
	nomark_questions() // alter the edit interface if this is not a
		// marked question
	select_qtypes()	// create a drop down list with all question types
	get_qtypes()	// get all question types from the database
	return_question() // show a single question to a student/user
	return_answered() // all the student to edit their current answer
		// this is the function that is killing the system because
		// it gets called times the number of questions in a part
		// (after you look at the part properties to see how many
		// questions get displayed on a page)
	print_answers()	// print the possible answers for this question
		// and display the right answer if the parameter says
		// "show" otherwise "hide"
	edit_answers()	// HTML display to edit the possible answers for
		// this question
	get_answers()	// get all the options for a given question
	save_submitted() // save the student's submitted answers
	save_marked()	// save marked questions back to the database
	set_endtime()	// update the current finish time
	check_dupes()	// check to see if the question has already been
		// answered. Depending on the Quiz type the answer may be
		// updated or skipped (if only the first answer is
		// stored). In reality though we're actually keeping all
		// submitted answers, but we're only reviewing the first
		// submitted answer for language placement tests.
	get_stuanswer()	// get the submitted answer by this student for
		// this question
	get_media()	// get sound clips/related media files for this
		// question
	print_media() // print media files with the option to edit URLs
		// and associated type -- e.g. mp3 vs. Real Media
	media_type()	// choose or change the media type
	edit_media()	// HTML edit interface for media files associated
		// with a question
	make_media()	// make a new media file entry in the database
	save_media()	// save updated media information
	make_answer()	// make a few (blank) answers in the HTML
		// interface for editing questions
	delete_answer()	// delete a possible option/answer from a multiple
		// choice question
	delete_question() // delete all answers and then delete the
		// question
	update_question() // insert updated information about this
		// question into the database includes all related
		// information such as the correct answer in a multiple
		// choice question and related media files
	save_question()	// update the "question" table -- sub to
		// update_question
	

> Unfortunately, you do have to care a bit about what programming language a
> resource is written for.  OO in Visual C++ is vastly difference from OO in
> Python which is vastly different from OO in Perl which is vastly different
> from OO in Java...  Frankly I know nothing about PHP's object system.  

Right. Which is why I'm not asking for PHP-specific
tutorials/references/etc. I'm looking for something that will take me past
the PHP tutorials and if that means reading a really great article/book
that uses C++ or Java or Python, that's ok. Coming from an environmental
science background I haven't been exposed to anything other than the
tutorials I've found on the 'net. Which is fine, but not exactly helpful
when trying to teach yourself good habits. :)

emma

--
Emma Jane Hogbin
[[ 416 417 2868 ][ www.xtrinsic.com ]]


More information about the Techtalk mailing list