Tutorial :What is a “field”? “Field” vs “Field Value”


In a passport there is a field: First Name, and that field has a value John.

I assert that it is correct to describe the relationship as follows:

Field First Name:

  1. Has a name (First Name).
  2. Has a set of valid values (e.g. defined by regex [A-Za-z. ]{1,30}
  3. Has a description (name that stands first in the person's full name)

And Passport is a set of pairs (field : field value), such that:

  • passport has a field "First Name"
  • passport has a value for field "First Name"

Point here is that it is incorrect to say:
"First Name value is John";

The correct way (conceptually/academically) is to say:
"passport has a value 'John' for field 'First Name'".

In practical terms it means (pseudo C#):

struct Passport {      Map<Field, object> fieldValues;  }    struct Field {      string Name;      string Description;       bool IsValidValue(object value);  }  

Q: Does this make sense? Any thoughts?


This is pretty subjective and entirely context sensitive, and seems like a silly thing to nitpick over.

Correct or not, if I'm discussing "passport" with a co-worker, I'd throw something at them if they corrected me every time I said "firstName is 'john'", and told me to say it as "passport's firstname field is 'john'". You'd just come across as annoying.


If you are going to model such thing, then you may take a look at reflection API of java or c#. It is pretty similar to what you described. Class has set of fields, field has name, type and other attributes, not value. Object is an instance of class and you can ask object for the value of specified field. Different objects of the same class have values for the same fields, so you may say they share fields. So if you are trying to model class-based OOP then you are probably right.

However this is not the only way to do OOP. There is prototype-based OOP which looks differently, as there are no classes, only objects, so objects contain field with values so there is not much difference if you say that object contain field and field has a value.

So the answer to "Does this make sense?" I think is "yes" because similar thing is in reflection and is used widely. If it is right or wrong - depends on your needs.

UPD: regarding "value = Passport[Field]" vs "value = Passport.Field.Value" I'd introduce one more passport to make it clear/

firstNameField = PassportClass.Fields["FirstName"]  myName   =   myPassport[firstNameField]  yourName = yourPassport[firstNameField]  

assumes that both passport have same fields, that makes sense. Having different passports with different fields may have a sense, just a different one.


Well..not really in c# see Scott Bellware's answer to my question about C# not being Object Oriented (kinda).

In C# passport is a class so it makes perfect sense to say

  1. "The Passport has a field FirstName"
  2. For a particular instance "FirstName value is John".

Here the first clause describes the class and the next one the object. In a more OO language like ruby I think saying "passport has a value 'John' for field 'First Name'" would be equivalent, you're just describing two objects - the Passport prototype, and the instance of it in the same sentence.

I'm getting pretty confused in it myself though. The question is oddly phrased since there would doubtless be much more to a passport than just its fields, for example a long-standing and persisted identity.


No. At least in OOP, it's the field's responsibility to retain the value. Although the object is responsible for ensuring that value is consistent with the other fields or the object's constraints, the actual "containing of the value is the field's job.

Using your example:

Field First Name:

  • Has a name (First Name).
  • Has a type (int, string, object)
  • Has a description (optional)
  • Has a value

And Passport is a set fields:

  • May define constraints on such a field as defined by the model, ensuring the value and the object's state as a whole is valid

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »