Reply to Re: instantiating an object fails (design patterns)

Your name:

Reply:


Posted by www.douglassdavis.com on 09/16/05 18:40

Chung Leong wrote:
> www.douglassdavis.com wrote:
> > Let's say an invalid string is passed to construct it. What is the
> > appropriate way to handle this? I know in Java I would probably throw
> > an exception, but I don't know how much people really use exceptions in
> > PHP right now. So, I don't want to depend on it.
>
> That sounds like a programmer's error to me. The appropriate way to
> handle this to be to let the programmer know that he/she made a
> mistake. I would use trigger_error() or simply die().
>
> Call me old school. In my opinion things that are within a programmer's
> control are not exceptions.

I understand your perpective, but IMO there's 2 broad categories,
system exceptions, and then those things that the user of the library
does wrong, for example NumberFormatException in Java. The exception in
my library would be almost identical to a NumberFormatException.

Also, it may not be the programmer, but the end user that made the
mistake. For example, typing 5.5 in a field that only accepts
integers.

the user could validate it before making the object, but then again,
that could be part of the object's job.

--
http://www.douglassdavis.com

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация