473,394 Members | 1,645 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,394 software developers and data experts.

patterns - observer

Hi, I always seem to fall foul of the same issues when programming with a
user interface and that is showing/hiding controls depending on what the
user is doing.

Maybe it's the way I design my interfaces (web mostly) but I always end up
with what I consider a real mess of text1.visible = false stuff all over
the place, I hate it.

Anyway I was reading about the "Observer" pattern which to my mind seems to
be made for this type of scenario, but I cant seem to find a pratical
example of some working code.

So say I have a dropdown list with three items "1", "2" and "3" and each
specifies a text box to show with some info (drawn from a db) how would one
go about using the observer for this simple scenario? What messages would
be passed around to do the updates, etc?

You'll have to excuse if this is the wrong group but I tried the patterns
ng and it seems a bit dead.
Nov 16 '05 #1
2 1346
http://www.typemismatch.com/viewforum.php?f=20
"Jimbo" <ji***@example.com> wrote in message
news:nr*********************@wards.force9.net...
Hi, I always seem to fall foul of the same issues when programming with a
user interface and that is showing/hiding controls depending on what the
user is doing.

Maybe it's the way I design my interfaces (web mostly) but I always end up
with what I consider a real mess of text1.visible = false stuff all over
the place, I hate it.

Anyway I was reading about the "Observer" pattern which to my mind seems to be made for this type of scenario, but I cant seem to find a pratical
example of some working code.

So say I have a dropdown list with three items "1", "2" and "3" and each
specifies a text box to show with some info (drawn from a db) how would one go about using the observer for this simple scenario? What messages would
be passed around to do the updates, etc?

You'll have to excuse if this is the wrong group but I tried the patterns
ng and it seems a bit dead.

Nov 16 '05 #2
Hi,

"Jimbo" <ji***@example.com> wrote in message
news:nr*********************@wards.force9.net...
Hi, I always seem to fall foul of the same issues when programming with a
user interface and that is showing/hiding controls depending on what the
user is doing. [...]

Define all states your UI component can be in. Then make a method
ChangeState, which adjusts the UI depending on the state. Then you only have
one method that does the hiding/displaying, enabling/disabling, etcetera of
the UI.
You'll have to excuse if this is the wrong group but I tried the patterns
ng and it seems a bit dead.


Then read the following book: 'Design Patterns - Elements of Reusable
Object-Oriented Software' by Erich Gamma, Richard Helm, Ralph Johnson and
John Vlissides (Adisson Wesley).

HTH,
---
Tom Tempelaere
Nov 16 '05 #3

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

Similar topics

4
by: Tony Ha | last post by:
Hello I am learning Python for in the pass ten months, and have brought a few books about Python. Most of them are good books by its only right, and all of them only teach you how to write...
1
by: Julia | last post by:
Hi I have a domain model and I am looking for the correct design patterns to use, The following is my domain model Server-> the is the thread boundaries,the server create a thread the...
13
by: John Salerno | last post by:
Here are a few I'm considering: Design Patterns Explained : A New Perspective on Object-Oriented Design (2nd Edition) (Software Patterns Series) by Alan Shalloway Design Patterns C# by...
4
by: myhotline | last post by:
Hi there, I was wondering from where i can get the source code of patterns implemented in either C# or Vb.NET. Any help or advice will be highly appreciated. Thanks in advance. Regards, -ANaive
1
by: DBC User | last post by:
I have two programs and I want to communicate some information. I can't use MSMQ so right now I end up using files with filewatcher and is working fine. Is there a pattern for doing this kind of...
0
by: NiveditaB06 | last post by:
Can anyone please help me? I tried this problem , it is giving a runtime error in the below mentioned line. _observers->push_back(o); Anyone have any explanation for the reason & if anyone knows...
0
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and...
7
by: =?Utf-8?B?bWF2cmlja18xMDE=?= | last post by:
Hi, I would like to know more about design patterns and specifically using C#. Can any one recommend a good book? Thanks
2
by: Anders Dahnielson | last post by:
Sorry if this is a somewhat silly question... I'm using the Observer implementation found in 'Patterns in Python' and find it really neat. But, I have not yet fully groked the new-style class,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.