473,791 Members | 3,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "somethingI D" 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 1490
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 "somethingI D" 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.co m>
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<stri ng, 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<stri ng, 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
6372
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 page once the form is launched. I now want to automatically fill out a specific text-field found within the web-page that the WebBrowser object has open. Right now I am using the following code to accomplish it: ...
2
11062
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 SFSB and, from there, to the database. On the front end, all cells appear as text fields. However, for certain cells, when the user clicks on the cell, the text field turns into a drop-down field (i.e. Select object), defaulting to the value...
5
2945
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 in the associated table that this form is based on. Is there anyway I can do this with vba ? I am using a different button object to open this form for the field it is to update. button1 updates unbound field name from text1 to 101Commnets...
3
1980
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 before the page is changed? I want to say that because the values are changed but the page is never reloaded after the change, that these changes do not take effect before the server.transfer. Please let me know if I am correct here. I think I am...
7
5266
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 Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As New SqlDataAdapter("OrdersList", myConnection)
32
3700
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 RecordSource like this? Am I asking for trouble doing this with a memo field? Thanks in advance. Private Sub cmdNextNote_Click() Dim lngNid As Long If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
2
1789
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 value in the field is changed, including when changed by selecting a new date from the calendar form. The calendar form works as expected - when I select a date the date is placed in the date field of the calling form, but the OnChange event...
3
4948
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, however the column of hyperlinks lose their URL's in transit and no longer are active links. To try and fix the problem I am using this bit of code in my Excel spreadsheet to copy the URL of each hyperlink into a new column that can then be...
17
2397
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
9517
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9997
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.