473,408 Members | 2,161 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,408 software developers and data experts.

Changing field in object?

I'd like to copy a object1 into object2 so object2 can be manipulated.
Object1 is coming form the middle layer into the UI layer. I'd like
to rename a field in Object2 from "somethingID" to just "ID" and do
this several times for a few middle layer objects. This will allow me
to create generic<> lists and reference the field ID against many
object2s that are similar to object1. The middle layer objects have ID
fields with different names. This keeps me from creating one generic<>
class that I can pass in these objects from the middle layer.

Having the ID field name consistent across these few objects allows me
to use the generic class for referenceing ID at anytime. I don't have
to use switches or multiple classes at the UI layer to fill certain
form components with values from the objects...for example.

Is copying this object1 to the UI specific object2 and then changing
the field name the way to go? I could setup a transform class.
Before object1 passes into the UI layer, I transform it.

Thanks,
Brett

Feb 9 '06 #1
7 1464
Brett,
Having the ID field name consistent across these few objects allows me
to use the generic class for referenceing ID at anytime. I don't have
to use switches or multiple classes at the UI layer to fill certain
form components with values from the objects...for example.


I think I would implement a general purpose interface that your "few"
classes implement. Then you would not have to rename any fields, if the
interface provided all of the functionality you would putl in the generic
class. That way, anything that implemented the interface would work in your
UI layer.

Regards,

Randy
Feb 9 '06 #2
Ideally, an interface would work here. However, people at the middle
layer would be distracted with what people at the UI layer want. Those
particular areas of the middle layer are already complete. So middle
layer people would have to go back, retro fit, test, work with the UI
people. It should be possible for the UI people to handle it all on
their own. The middle layer people aren't much concerned with the UI,
as the UI isn't much concerned with the middle layer...as it should be.
Middle layer is building to meet certain purposes, not certain UIs.

There are several types coming from the middle layer. I just need to
rename a field in each type to something common. Then I can type a
generic<> class to perform certain operations using the renamed field.

Thanks,
Brett

Feb 9 '06 #3
Brett Romero <ac*****@cygen.com> wrote:
I'd like to copy a object1 into object2 so object2 can be manipulated.
Object1 is coming form the middle layer into the UI layer. I'd like
to rename a field in Object2 from "somethingID" to just "ID" and do
this several times for a few middle layer objects. This will allow me
to create generic<> lists and reference the field ID against many
object2s that are similar to object1. The middle layer objects have ID
fields with different names. This keeps me from creating one generic<>
class that I can pass in these objects from the middle layer.

Having the ID field name consistent across these few objects allows me
to use the generic class for referenceing ID at anytime. I don't have
to use switches or multiple classes at the UI layer to fill certain
form components with values from the objects...for example.

Is copying this object1 to the UI specific object2 and then changing
the field name the way to go? I could setup a transform class.
Before object1 passes into the UI layer, I transform it.


Changing the *fields* should have no impact on other classes, as the
fields should be private anyway. If you use an interface (as Mark
suggested) you can have an ID property which all of the similar classes
implement.

Using interfaces is the best way of ensuring the separation you talked
about in the other post. It means you should be able to test the UI
layer without even having any "real" middle layer classes, using
mocking to implement the middle layer.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 9 '06 #4
But again, this gets into having middle layer people be distracted by
the needs of UI people. If the interface is created and two properties
(sorry for calling them fields above) are implemented at the middle
layer, such that somethingID is implemented as ID, it won't stop there.
The UI will keep wanting additional properties as more meta data type
things are needed. So the middle layer people have to keep
implementing these new interface methods/properties.

The UI needs to have complete ability to do these things without the
middle having any knowledge of what's going on. How about this:

The UI side has a generic<> class that is typed as one of the middle
layer class types (eventually several types are used). Inside the
generic is a switch that delcares a Type object and checks that in the
switch. Once the switch matches, the somethingID property value is
dropped into a SortedList<string, int> where it can then be bound to a
combobox. There is another similar method in this class that binds to
a text box. In addition, I clean up any values to be presentable UI
side. For example, adding spaces and making proper letter case
changes.

Brett

Feb 9 '06 #5
Brett Romero wrote:
But again, this gets into having middle layer people be distracted by
the needs of UI people.
I don't see how. The middle layer people *should* care about what's
exposed, and should consider commonality. They're providing an
interface to another layer, and should care about that interface.
If the interface is created and two properties
(sorry for calling them fields above) are implemented at the middle
layer, such that somethingID is implemented as ID, it won't stop there.
The UI will keep wanting additional properties as more meta data type
things are needed. So the middle layer people have to keep
implementing these new interface methods/properties.
Surely they have to implement those new properties anyway though, don't
they? It's not much more work to put them in the interface as well as
the class, and it means that the implementation can change without the
UI layer needing to know, so long as they've coded to the interface
rather than to the implementation.
The UI needs to have complete ability to do these things without the
middle having any knowledge of what's going on.
The middle layer always needs to know what it's providing - after all,
it's the layer providing it! It shouldn't need to know the order in
which the members are used (unless that's part of the interface
contract, which is likely to be due to a middle layer concern rather
than a UI concern) but it absolutely must care about what it exposes.
How about this:

The UI side has a generic<> class that is typed as one of the middle
layer class types (eventually several types are used). Inside the
generic is a switch that delcares a Type object and checks that in the
switch. Once the switch matches, the somethingID property value is
dropped into a SortedList<string, int> where it can then be bound to a
combobox. There is another similar method in this class that binds to
a text box. In addition, I clean up any values to be presentable UI
side. For example, adding spaces and making proper letter case
changes.


Anything involving switching on types is begging for polymorphism to be
applied if at all possible, IMO.

Jon

Feb 9 '06 #6
>Anything involving switching on types is begging for polymorphism to be
applied if at all possible, IMO.

Exactly but how can it be applied in this case?

Thanks,
Brett

Feb 9 '06 #7
Brett Romero wrote:
Anything involving switching on types is begging for polymorphism to be
applied if at all possible, IMO.


Exactly but how can it be applied in this case?


As we've said: make your middle layer types implement a common
interface, then use the interface from the UI.

Jon

Feb 9 '06 #8

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

Similar topics

1
by: Matt | last post by:
Hi group, Here's a problem I've been trying to solve for the past several weeks. I have the standard WebBrowser object added to a form so it can access websites, and I have it load a default...
2
by: ehm | last post by:
I am working on creating an editable grid (for use in adding, deleting, and editing rows back to an Oracle database). I have a JSP that posts back to a servlet, which in turns posts to a WebLogic...
5
by: David | last post by:
Hi I seem to be getting nowhere with this. I am opening a form which will be used to input Notes into different fields in a table. My problem is changing the unbound field name to the field name...
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
7
by: Dan Sikorsky | last post by:
How do you iterate thru a dataset to change money fields to a different value? Here's what I have. My dataset is filled directly from a stored procedure. ' Create Instance of Connection and...
32
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's...
2
by: planetthoughtful | last post by:
Hi All, I have a calendar form that updates a date field on the form from which it was called. I have code in the OnChange event of the date field that I would like performed whenever the date...
3
by: Janelle.Dunlap | last post by:
I have an Excel spreadsheet containing a column of hyperlinks that I need to import into Access. I have no trouble importing (in my case actually linking) the spreadhsheet to the Access table,...
17
by: blufox | last post by:
Hi All, Can i change the execution path of methods in my process at runtime? e.g a()->b()->c()->d()->e() Now, i want execution to be altered at runtime as -
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: 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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.