Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Data Sanitation

Name: Anonymous 2011-05-02 18:32

Quick opinion question for you:

When you're instantiating an object based on unsafe input from a form in a loosely-typed language, do you leave the sanitation up to the form handler, or to the object?

Ex:

p = new Pokemon();
p.name = sanitize(form.name);

vs.
p = new Pokemon();
p.setName(form.name); // sanitizing code in the method

Name: Anonymous 2011-05-02 19:00

>>5
The constructor should just glue up the data structure with its inputs, so (make-structure (sanitize data)).

This way you can reuse sanitize elsewhere.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List