Click here to Skip to main content
15,900,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Set Focus to a cell on DataGridView Control Pin
ASysSolvers16-Oct-06 3:00
ASysSolvers16-Oct-06 3:00 
GeneralRe: How to Set Focus to a cell on DataGridView Control Pin
sam#16-Oct-06 3:24
sam#16-Oct-06 3:24 
QuestionCan't find System.Configuration.ConfigurationManager Pin
ZeedijkMike16-Oct-06 1:56
ZeedijkMike16-Oct-06 1:56 
AnswerRe: Can't find System.Configuration.ConfigurationManager Pin
albCode16-Oct-06 2:00
albCode16-Oct-06 2:00 
Questionget XML from browser window in C# windows app Pin
jarlath16-Oct-06 1:51
jarlath16-Oct-06 1:51 
AnswerRe: get XML from browser window in C# windows app Pin
Judah Gabriel Himango16-Oct-06 4:52
sponsorJudah Gabriel Himango16-Oct-06 4:52 
GeneralRe: get XML from browser window in C# windows app Pin
jarlath16-Oct-06 6:35
jarlath16-Oct-06 6:35 
QuestionBinding Business Objects to Controls (or not) Pin
Jan Limpens16-Oct-06 1:49
Jan Limpens16-Oct-06 1:49 
Hello,

I have a more ore or less complicated business object, that looks
similar to this:

<entry>
has some properties (id, pubdate...)
and a list of <version>s
each <version> has a language, a title and a description
Entry also has a list of s
each , has a List of <imageinfo>s with language, title and description

To edit the objects properties I created a similar structure of controls
<entrycontrol> has some Textboxes, a Tabstrip, holdig Tabs
corresponding to <version>s, again holding some Textboxes, and a list of
<imagescontrol>s with their <imageinfocontrol>s.

The question is, should the control A) know of the business object it
represents?
Should I instantiate EntryControl like this?
Entry e = Entry.GetEntry("abc");
EntryControl ec = new EntryControl(e);

and "inside" of EntryControl my Properties would be

public string Id {<br />
get { return entry.Id; }<br />
set {<br />
  entry Id = value;<br />
  TextBoxId.Text = value;<br />
 }<br />
}<br />
<br />

and have problems, once the user edits the fields, a call to Id, would
still yield the object's value and not the textbox' new text value.

But I'd have the advantage (still in Entry) that I could much better
encapsulate the child controls creation and logic.

public EntryControl(Entry entry) {<br />
VersionControl versionControl = new VersionControl();<br />
versionControl.Versions = entry.Versions // now I can encapsulate<br />
                                        // everything onwards in<br />
                                        // VersionControl<br />
}


or B) should my Controls be completely agnostic containers of agnostic
sub controls (as the generic .net controls are)

Instead:

class EntryControl {<br />
  private Textbox textBoxId, textBoxPubDate;<br />
<br />
  public string Id {<br />
     get {return textBoxId.Text; }<br />
     set {textBoxId.Text = value; }<br />
  }<br />
<br />
  public VersionControl VersionControl;<br />
}<br />
<br />
class Client {<br />
  void DoSomething() {<br />
     Entry e = Entry.GetEntry("abc");<br />
     EntryControl ec = new EntryControl();<br />
     ec.Id = e.Id;<br />
     ec.VersionControl = new VersionControl();<br />
     foreach(Version v in e.Versions) {<br />
        VersionTab tab = new VersionTab(); // will be difficult to<br />
                                           // reconstruct e later. What<br />
                                           // if the user inserts a new version<br />
                                           // in the middle...?<br />
        tab.Title = v.Title;<br />
ec.VersionControl.Tabs.Add(tab);<br />
     }<br />
// ...<br />
  }<br />
}


What is your opinion? What is the best pattern in relation business
objects vs controls.

To me it seems version A encapsulates better, is easier to read and is
more comfortable to use. But concurrency makes it less attractive;

B has the advantage of dumb controls that cannot do anything wrong,
but writing the client code is an ugly hack. Still there would be no mingling of business and representation layer, which I think is of advantage.

Any beautiful patterns, recomendations, ...?

Thanks!

--
Jan
www.limpens.com
AnswerRe: Binding Business Objects to Controls (or not) Pin
Ed.Poore16-Oct-06 2:54
Ed.Poore16-Oct-06 2:54 
GeneralRe: Binding Business Objects to Controls (or not) Pin
Jan Limpens16-Oct-06 2:59
Jan Limpens16-Oct-06 2:59 
Questionhow to check answers Pin
Yustme16-Oct-06 0:40
Yustme16-Oct-06 0:40 
AnswerRe: how to check answers Pin
Colin Angus Mackay16-Oct-06 0:48
Colin Angus Mackay16-Oct-06 0:48 
GeneralRe: how to check answers Pin
Yustme16-Oct-06 1:31
Yustme16-Oct-06 1:31 
GeneralRe: how to check answers Pin
Colin Angus Mackay16-Oct-06 1:51
Colin Angus Mackay16-Oct-06 1:51 
GeneralRe: how to check answers Pin
Yustme16-Oct-06 2:00
Yustme16-Oct-06 2:00 
GeneralRe: how to check answers Pin
Colin Angus Mackay16-Oct-06 2:04
Colin Angus Mackay16-Oct-06 2:04 
GeneralRe: how to check answers [modified] Pin
Yustme16-Oct-06 2:48
Yustme16-Oct-06 2:48 
GeneralRe: how to check answers Pin
Colin Angus Mackay16-Oct-06 5:51
Colin Angus Mackay16-Oct-06 5:51 
GeneralRe: how to check answers Pin
Yustme16-Oct-06 5:55
Yustme16-Oct-06 5:55 
QuestionProblem with button.Image . Pin
hdv21216-Oct-06 0:30
hdv21216-Oct-06 0:30 
AnswerRe: Problem with button.Image . Pin
sam#16-Oct-06 0:37
sam#16-Oct-06 0:37 
QuestionHow to program a messenger !? Pin
amin_behzadi16-Oct-06 0:07
professionalamin_behzadi16-Oct-06 0:07 
AnswerRe: How to program a messenger !? Pin
Colin Angus Mackay16-Oct-06 0:49
Colin Angus Mackay16-Oct-06 0:49 
AnswerRe: How to program a messenger !? Pin
sam#16-Oct-06 0:52
sam#16-Oct-06 0:52 
QuestionUsing Oledb dataadapter c# Pin
chandler8315-Oct-06 23:03
chandler8315-Oct-06 23:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.