07.01.2013 Views

David Defour - Université de Perpignan

David Defour - Université de Perpignan

David Defour - Université de Perpignan

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Drawbacks of JSONification<br />

• Sends state, not behavior, of object<br />

–So, properties that are <strong>de</strong>rived from other properties will be<br />

inconsistent on client if other properties are changed<br />

• Example: Java “Circle” class<br />

–getRadius<br />

• Returns instance variable<br />

–getArea<br />

• Returns Math.PI*radius*radius<br />

• JSONified instance<br />

658<br />

jeudi 26 janvier 12<br />

–Example<br />

• Make new Circle(10). Pass to JSONObject, call toString<br />

• Result: { "radius": 10.0, "area": 314.15927…}<br />

–Problem<br />

• If client-si<strong>de</strong> co<strong>de</strong> changes radius, area doesn’t match

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!