I'll use C# as an example, but it should apply globally. Say I have a string value that should be one of a few constants, but I also want the client to set which string value to use so:private int foo;private string bar;public int Foo {    get { return foo; }    set    {        foo = value;        bar = getStringValueFromDatabase(value);    }}public string Bar { get { return bar; } }I use this technique quite a lot and want to know if it's considered as any formal concept.
Is this technique a design pattern? If so, what's it called?
design patterns
It's perfectly valid OO technique, though I think it can be made a bit more efficient if the lazy-loading (which is what this effectively is) is deferred until the Bar value is actually needed. private int foo;private string bar;public int Foo {    get { return foo; }    set    {        foo = value;        bar = null;    }}public string Bar{     get     {         if(bar == null)             bar = getStringValueFromDatabase(Foo);        return bar;     } }Edit: I think that's an improvement on the original code though as others have observed, even better would be to abstract the data access into a separate layer.