DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Contextual Validation: Martin Fowler Retread

Contextual Validation: Martin Fowler Retread

Martin Fowler user avatar by
Martin Fowler
·
Nov. 05, 11 · DevOps Zone · Interview
Like (1)
Save
Tweet
7.83K Views

Join the DZone community and get the full member experience.

Join For Free
this is a retread by martin fowler of an earlier version of this post which was first published in 2005.  definitely worth a read.

in my writing endeavors, i've long intended to write a chunk of material on validation. it's an area that leads to a lot of confusion and it would be good to get some solid description of some of the techniques that work well. however life is full of things to write about, rather more than time allows.

some recent readings made me think about saying a few preliminary things on the topic. one common thing i see people do is to develop validation routines for objects. these routines come in various ways, they may be in the object or external, they may return a boolean or throw an exception to indicate failure. but one thing that i think constantly trips people up is when they think object validity on a context independent way such as an isvalid method implies.

i think it's much more useful to think of validation as something that's bound to a context - typically an action that you want to do. is this order valid to be filled, is this customer valid to check in to the hotel. so rather than have methods like isvalid have methods like isvalidforcheckin.

one of the consequences of this is that saving an object to a database is itself an action. thinking about it that way raises some important questions. often when people talk about a context-free validity, they mean it in terms of saving to a database. but the various validity checks that make this up should be interrogated with the question "should failing this test prevent saving?"

in about face alan cooper advocated that we shouldn't let our ideas of valid states prevent a user from entering (and saving) incomplete information. i was reminded by this a few days ago when reading a draft of a book that jimmy nilsson is working on. he stated a principle that you should always be able to save an object, even if it has errors in it. while i'm not convinced that this should be an absolute rule, i do think people tend to prevent saving more than they ought. thinking about the context for validation may help prevent that.

reposted on 03 nov 2011

Database Object (computer science) IT Trip (search engine) POST (HTTP) Testing Book

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Adaptive Change Management: A DevOps Approach to Change Management
  • Usage of Java Streams and Lambdas in Selenium WebDriver
  • Data Visualization of Healthcare Expenses by Country Using Web Scraping in Python
  • Implementing One and Two Way SSL (Mutual Authentication) for MuleSoft Application

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo