The complexity of the design

P

Phillip Taylor

I have made my own custom control. It looks like a single line textbox
with icons on the right hand side. It pretty much has the same
functionality as Microsoft Outlooks "To" field, where you can Alt-K to
complete things etc. Mine has a different purpose but is essentially
the same style.

Anyway the issue I have is managing the complexity of the box. the
user can interact by clicking buttons to open search windows, type
names directly into the text box or by setting it programatically (?)
using the exposed properties.

It leads to extremely complex code like this however:

public property ObjectID as Int32
....
set(value as Int32)
if (inMethod) then exit sub

inMethod = true

textbox.text = lookup(value)
icon = imageX
me.mObjectId = value

inMethod = false

end set


--
There is no said problem per say, but I need things like inMethod
booleans to stop a nightmare of redundant callbacks and invocations of
bad text. I don't feel I could centrallise this because each technique
works with different inputs. (i.e. Int32, or String, or result from
search window) etc.

Is there a good design pattern or common solution that makes working
with this kind of code easier?

Phillip Taylor
 
C

Cor Ligthert[MVP]

Phillip,

If you keep in mind that a control gives you always back a string in the
text property. (It is entered by the keyboard) then your problem will become
probably easier.

If you add a value property to your box (or overide it), then you can set in
that the formulas to make from a string an integer or a datetime just as it
is needed. I would not go to far in that. A Value property is mostly
returning one type of value.

Cor
 
P

Phillip Taylor

Phillip,

If you keep in mind that a control gives you always back a string in the
text property. (It is entered by the keyboard) then your problem will become
probably easier.

? Can explain what you mean here please? The application will set the
ObjectID property on my control, a user may type into an embedded text
field or a user may click on buttons to generate the result. There
isn't a single way to represent the internal state.
If you add a value property to your box (or overide it), then you can set in
that the formulas to make from a string an integer or a datetime just as it
is needed. I would not go to far in that. A Value property is mostly
returning one type of value.

It's not to do with accepting multiple types in a value field or using
method overloading, it's about three completely different events that
have different inputs. I wondered if they could be simplified.

Anyone?
 
C

Cor Ligthert[MVP]

? Can explain what you mean here please?

Keep it simple then others beside you can understood it too. Therefore
follow the routes as they are normal done.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top