473,396 Members | 1,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to separate GUI and data

I am new to C++/CLI. I want to do a very simple thing. In other C++
applications, my forms have always been 'context free' in the sense
that I pass them a temporary copy of the data for them to display and
munge about. If OK is pressed, the client of the form does something
with the temporary data. This approach is surely a commonplace, and I
have implemented it in real C++ something like this:

AddressData temp(original); // original could be of type AddressData,
perhaps an element in
// a vector of addresses .
AddressForm form;
if (form.Execute(temp))
{
// OK was pressed.
original = temp; // or whatever is approriate
}

bool Form::Execute(AddressData& data)
{
// populate controls from data.
bool result = ShowDialog() == DialogResult::OK;
if (result)
{
// populate data from controls.
}
}

Now, in .NET-land it seems that everything is a reference, including
so-called value types if they are added to an array. What is the usual
approach to data handling in .NET GUI design? I want to protect my data
from direct manipulation by forms, and to avoid the client of the form
knowing anything about it's implementation (e.g. all those public
controls used in MFC code).

Thanks.
UnicycleGuy

Nov 21 '06 #1
3 1448
I would say that WM_COPYDATA is still a
good candidate for what you want to do.
Best regards.

____
Jean
Nov 21 '06 #2

al***********@cambridgeconsultants.com a écrit :
I am new to C++/CLI. I want to do a very simple thing. In other C++
applications, my forms have always been 'context free' in the sense
that I pass them a temporary copy of the data for them to display and
munge about. If OK is pressed, the client of the form does something
with the temporary data. This approach is surely a commonplace, and I
have implemented it in real C++ something like this:

AddressData temp(original); // original could be of type AddressData,
perhaps an element in
// a vector of addresses .
AddressForm form;
if (form.Execute(temp))
{
// OK was pressed.
original = temp; // or whatever is approriate
}

bool Form::Execute(AddressData& data)
{
// populate controls from data.
bool result = ShowDialog() == DialogResult::OK;
if (result)
{
// populate data from controls.
}
}

Now, in .NET-land it seems that everything is a reference, including
so-called value types if they are added to an array. What is the usual
approach to data handling in .NET GUI design? I want to protect my data
from direct manipulation by forms, and to avoid the client of the form
knowing anything about it's implementation (e.g. all those public
controls used in MFC code).
Your "data" should be cloneable (ie, implement ICloneable)

Arnaud
MVP - VC

Nov 21 '06 #3
Matthew MacDonald addresses this topic in his book "Pro .NET 2.0
Windows Forms and Custom Controls in C#". He promotes the so-called
"Three Tier Design" guideline which consist in rigorously separating
the presentation, the program logic and the data.

Presentation Tier
(Windows, UI code)
/\
||
\/
Business Tier
(application logic)
/\
||
\/
Data Tier
(files, databases, networks etc.)

Here manipulation of data by forms i.e. in the form handlers is
considered evil.

"The form acts just as a switch board for all the controls it contains.
In other words, when you create the event handler for a button's
Click event, this event handler usually has two purposes:
· To forward the command to another object that can handle the task.
· To update the display based on any feedback that's returned."

By this in theory the classes of the data and presentation tier are
generic classes which you can reuse.

Look for a technique called "simple data binding with windows forms" -
this can help to seperate UI from data.

Semmel

Nov 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike Hennessy | last post by:
I'm looking for people's opinions and feedback regarding the design of the application tier, and how to best logically separate out the Data Access from the Business Object's. Per the Microsoft...
4
by: Scott Kinney | last post by:
I have an inventory database. I want to delete out-of-stock items from the main database, but keep them in a separate table so that I can reference data about them. I created a copy of the item...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
48
by: phillip.s.powell | last post by:
MySQL 3.23.58 - 4.0.17 (yep, several database server instances, don't ask) I have database Spring with table Students I have database Summer with table Students I am tasked to produce a...
4
by: Attila Forczek | last post by:
Hi, Please help me to connect two ASP.Net applications. One is an online store, based on Commerce Server 2002, the other is a database editing application. Both are ASP.Net 1.1, VB applications....
3
by: peterc | last post by:
I have an existing database with approx 500,000 rows and accessed by a few hundred users per day creating approx 1,000 new records per day plus typical reporting - relatively low volume stuff for...
3
by: LurfysMa | last post by:
I would like to hear opinions on the tradeoffs of putting the tables, forms, and queries for several related datasets in separate databases vs one combined database. I am working on an...
2
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
2
by: =?Utf-8?B?dGFtZWU=?= | last post by:
I have a data list of over 1,000 spare parts. I set it up with a master data list in a separate workbook and data validation works fine. I need autocomplete so I tried inserting a combo box with...
12
by: titan nyquist | last post by:
I have a class with data and methods that use it. Everything is contained perfectly THE PROBLEM: A separate thread has to call a method in the current instantiation of this class. There is...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.