Author Topic: Fail-fast everywhere?  (Read 2517 times)

Offline LeoMaheo

  • byte
  • *
  • Posts: 10
    • View Profile
Fail-fast everywhere?
« on: March 23, 2009, 05:10:51 am »
Hi!

Perhaps I'm being a bit pedantic, but:

I'd suggest that Matrix.setDump throw a RuntimeException if the passed float[] is not 16 elements,
instead of silently doing nothing?
(I lost a few minutes debugging my code.)

Fail-fast is the way to go, I believe.

Actually, I'd appreciate it if all functions threw RuntimeExceptions as quickly as possible,
when invoked with illegal input.

(Possibly this is even more important with closed source products,
since you cannot always tell from studying source code
how they functions internally and how they react to invalid input.)

Kind regards,
Magnus

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11769
    • View Profile
    • http://www.jpct.net
Re: Fail-fast everywhere?
« Reply #1 on: March 23, 2009, 10:44:20 am »
Just do a

Code: [Select]
Logger.setOnError(Logger.ON_ERROR_THROW_EXCEPTION );

and you'll get Exceptions in those cases that i consider to be errors.

Offline LeoMaheo

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Fail-fast everywhere?
« Reply #2 on: March 23, 2009, 05:53:35 pm »
Oh, thanks for the information :-)
Works fine (well of course)