4 Replies - 1143 Views - Last Post: 02 July 2009 - 09:28 PM

#1 Pwn  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 458
  • Joined: 25-November 07

General GUI programming question

Posted 02 July 2009 - 05:16 PM

In a GUI application, you have forms and controls. There is the ability to program events for nearly all controls, that I've seen. So my question is, if a user clicks on one of these controls, or performs some other action, does it create overhead in the program even if an event has not been programmed for the action.

And, if so, is it possible to disable that action so the event is not generated without disabling the entire control?

Is This A Good Question/Topic? 0
  • +

Replies To: General GUI programming question

#2 LoveIsNull  Icon User is offline

  • Recovering D.I.C Addict
  • member icon

Reputation: 52
  • View blog
  • Posts: 646
  • Joined: 10-March 09

Re: General GUI programming question

Posted 02 July 2009 - 05:49 PM

You mean to say for instance, if I have a form that has no Click event handler and the user clicks my form will it effect the performance of whatever is going on with the process at that moment?

I would have to think not, as there would be no actual code to execute (assuming you're running the process on a background thread so that the control\form would respond to these external events in the first place). The worst I could possibly see happening in the above described scenario is:

1. My form\control is clicked
2. Windows sends my application a message indicating it has been clicked
3. The run-time goes to JIT compile the code in the click event handler.
4. There is no handler. Dead.

Not that this is what actually happens, this is just the most "effort" (so to speak) that I could see the run-time actually putting into responding to something like this. It could actually be closer to:

1. My control is clicked and there is no handler. Dead.

Either way, computers these days are much faster and more efficient. The effect of a mere click or something like that would have to be virtually non-existent.

This post has been edited by LoveIsNull: 02 July 2009 - 05:51 PM

Was This Post Helpful? 0
  • +
  • -

#3 toshiro  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 21
  • View blog
  • Posts: 137
  • Joined: 27-June 09

Re: General GUI programming question

Posted 02 July 2009 - 06:26 PM

in JAVA, action listeners have explicit methods that check for each possible scenario, such as the clicklistener, which checks for a variety of things. My cs teacher says that just adding in a throw statement to all unused methods prevents any overhead/memory allocation. This methodology has worked in the past, for such trivial exploits as a JLabel 15 puzzle

On the flip side
My teacher usually gave me an exasperated look - saying that with the massive computing power in even little netbooks, that such considerations were splitting hairs. idk, im a big fan of efficiency, but that's just my style
Was This Post Helpful? 0
  • +
  • -

#4 Pwn  Icon User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 458
  • Joined: 25-November 07

Re: General GUI programming question

Posted 02 July 2009 - 08:55 PM

View Posttoshiro, on 2 Jul, 2009 - 07:26 PM, said:

On the flip side
My teacher usually gave me an exasperated look - saying that with the massive computing power in even little netbooks, that such considerations were splitting hairs. idk, im a big fan of efficiency, but that's just my style


Which probably explains the bloat and slowness in a lot of modern programs. People take their teacher's advice as WORD. I, for one, didn't see that my teachers were all that knowledgeable. The one teacher who knew a lot about a lot you could hardly understand because she was from China.

This post has been edited by Pwn: 02 July 2009 - 08:57 PM

Was This Post Helpful? 0
  • +
  • -

#5 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: General GUI programming question

Posted 02 July 2009 - 09:28 PM

In a GUI operating system, the operating system checks every event, such as a click, click and drag, double click, mouse move, etc. and puts them into a queue of events. Typically GUI applications look at the head of the queue of events and see if the event is of interest to them. If it is not it just ignores it and waits for the next event to come in. There is usually some amount of overhead involved with any GUI application. You normally have to be nice and share the processor(s) with the OS and other processes and programs. It isn't like the good old days when the computer only did one thing at a time, aka DOS. The program had sole use of the operating system and could do whatever it wanted. In a GUI OS you don't have that control. Even high end games that run on Windows or Mac or Linux have to share the processor. There is a lot of background work going on.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1