TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-13-2009, 03:06 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default Debugging Class in creation of a Framework

Hi, I'm going into the creation / design of a framework and the first thing I'd like to know about is what a debugging class is.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 04-13-2009, 02:16 PM   #2 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

A debugging class would be a component of the framework that eases the debugging if something goes wrong while executing. An example of a debugging component could be to generate a backtrace using debug_backtrace() into some easily understandable trace, so errors/warnings/exceptions can be tracked and you can figure out where you went wrong.
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 04-13-2009, 04:35 PM   #3 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

On this subject - how would you go an create an Error class for a framework, and how would you implement it and use it?
__________________
Tanax is offline  
Reply With Quote
Old 04-13-2009, 05:48 PM   #4 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Create an Error class for a framework? I'm not entirely sure that you would want to do so.
Salathe is offline  
Reply With Quote
Old 04-13-2009, 09:20 PM   #5 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Why wouldn't you want to create an errorclass that handles Exceptions and stuff ?
__________________
Tanax is offline  
Reply With Quote
Old 04-13-2009, 09:23 PM   #6 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Firstly, error conditions and exceptions are different beasts. Secondly, you probably wouldn't want one class to take care of everything, but rather tie a collection of classes together: these will be different depending on your framework and requirements wanted.
Salathe is offline  
Reply With Quote
Old 04-13-2009, 10:10 PM   #7 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Well, isn't Exceptions a form of Error Handling - yes?
I didn't specify Error conditions, I just said Errorclass.

But okay, I see.. well, but still does anyone know a tutorial or anything about how to create a "collection of classes" to handle exceptions? Sure - it may be different than the framework I use, but I'm just looking for some guidance to understand the concept. I know how Exceptions work, I just need to understand how an Exception class works ^_^
__________________
Tanax is offline  
Reply With Quote
Old 04-14-2009, 04:03 AM   #8 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Kalle View Post
A debugging class would be a component of the framework that eases the debugging if something goes wrong while executing. An example of a debugging component could be to generate a backtrace using debug_backtrace() into some easily understandable trace, so errors/warnings/exceptions can be tracked and you can figure out where you went wrong.
Would this work with error_get_last?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 04-14-2009, 01:24 PM   #9 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Quote:
Originally Posted by Orc View Post
Would this work with error_get_last?
error_get_last() or register your own error handlers (set_error_handler & set_exception_handler) which pops all the errors onto a stack and then list all registered errors upon debugging shutdown.
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
The Following User Says Thank You to Kalle For This Useful Post:
Orc (04-25-2009)
Old 04-15-2009, 12:11 AM   #10 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Kalle View Post
error_get_last() or register your own error handlers (set_error_handler & set_exception_handler) which pops all the errors onto a stack and then list all registered errors upon debugging shutdown.
How should I create a debugging class? That's all I'm wondering now.
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 04-15-2009, 02:07 AM   #11 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

I would rather use a set of procedural functions for debugging than a class, instead of making a class where almost all methods are better served static (from my point of view).

All you need is a set of functions thats usable for debugging, and only included when debug mode is triggered (if your system ofcourse have a debugging mode).

Example of functions can be:
  • Backtracing in a nice manner thats more detailed that the regular debug_print_backtrace() output
  • Functions for catching and displaying exceptions and errors in somewhat unified interface, combining this with the backtrace is a good idea, as it can show if anywhere in the backtrace something occured
  • Assertions, http://www.php.net/assert
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
The Following User Says Thank You to Kalle For This Useful Post:
Orc (04-17-2009)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] How to organize your classes | Part 1 Tanax Advanced PHP Programming 10 03-01-2009 10:08 PM
A Generic Singleton Base Class Theo Advanced PHP Programming 7 08-18-2008 02:25 AM
[Tutorial] Basic tutorial about class basics Tanax Absolute Beginners 14 07-24-2008 01:37 PM
PHP5 Classes A to Z Part 1 quantumkangaroo Advanced PHP Programming 11 04-01-2008 04:21 AM
Tutorial: PHP and OOP, a beginners guide Village Idiot Tips & Tricks 0 09-06-2007 04:23 PM


All times are GMT. The time now is 10:25 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design