<p>I often need to design a dialog in Delphi/C++Builder that allows various properties of an object to be modified, and the code to use it typically looks like this.</p>

<pre><code>Dialog.Edit1.Text := MyObject.Username;
Dialog.Edit2.Text := MyObject.Password;
// ... many more of the same

if (Dialog.ShowModal = mrOk) 
begin
  MyObject.Username := Dialog.Edit1.Text;
  MyObject.Password := Dialog.Edit2.Text;
  // ... again, many more of the same
end;
</code></pre>

<p>I also often need similar code for marshalling objects to/from xml/ini-files/whatever.</p>

<p>Are there any common idioms or techniques for avoiding this kind of simple but repetitive code?</p>

Delphi at least have 'With', though it doesn't solve the problem completely.
```
```
if (Dialog.ShowModal = mrOk) 
begin
  with MyObject do
  begin
    Username := Dialog.Edit1.Text;
    Password := Dialog.Edit2.Text;
    // ... again, many more of the same
  end;
end;
```
```
And builder AFAIK has nothing alike.