Archive for the ‘technology’ Category

data Binding made of fail?

March 9th, 2009

The following nabbed from csharp-online.net.

using System;
using System.Windows.Forms;

class Student {
	private string name;
	private double gpa;
	
	public string Name {
		get { return name; }
		set { name = value; }
	}
	
	public double Gpa {
		get { return gpa; }
		set { gpa = value; }
	}
}

class Widget : Form
{
	TextBox textBox1;
	TextBox textBox2;
	Button button;
	Student student;
	
	public static void Main(string[] args)
	{
		Application.Run(new Widget());
	}
	
	public Widget()
	{
		student = new Student();
		student.Name = "Jeff";
		student.Gpa = 4.0;

		textBox1 = new TextBox();
		textBox2 = new TextBox();
		textBox1.DataBindings.Add(new Binding("Text", student, "Name"));
		textBox2.DataBindings.Add(new Binding("Text", student, "Gpa"));
		
		button = new Button();
		button.Click += new EventHandler(testButton_Click);
		
		TableLayoutPanel pan = new TableLayoutPanel();
		pan.ColumnCount = 3;
		pan.ColumnCount = 1;
		pan.Controls.Add(textBox1, 0, 0);
		pan.Controls.Add(textBox2, 1, 0);
		pan.Controls.Add(button, 2, 0);
		this.Controls.Add(pan);
	}
	
	private void testButton_Click(object sender, EventArgs e) {
		MessageBox.Show("Name: " + student.Name 
				+ " GPA: " + student.Gpa);
   }
}

Build with:

gmcs binding.cs -r:System.Windows.Forms

Looks tidy, except.. it doesn't do a damn thing. Values are extracted successfully from student, but setting them doesn't do anything. No matter how vigorously I edit the textboxes I always see the same values.

That's on Mono. On .NET I get this evilgram:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Reflection.TargetInvocationException: Property accessor 'Name' on object 'Student' threw the following exception:'Student.get_Name()' ---> System.MethodAccessException: Student.get_Name() ---> System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
   at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
   at System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh)
   at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh)
   at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
   at System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
   at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext)
   at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Security.Permissions.ReflectionPermission
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
   --- End of inner exception stack trace ---
   at System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
   at System.Windows.Forms.BindToObject.GetValue()
   at System.Windows.Forms.Binding.PushData(Boolean force)
   at System.Windows.Forms.Binding.UpdateIsBinding()
   at System.Windows.Forms.Binding.CheckBinding()
   at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase)
   at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding)
   at System.Windows.Forms.BindingsCollection.Add(Binding binding)
   at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding)
   at System.Windows.Forms.Control.UpdateBindings()
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.set_BindingContextInternal(BindingContext value)
   at System.Windows.Forms.ContainerControl.set_BindingContext(BindingContext value)
   at System.Windows.Forms.ContainerControl.get_BindingContext()
   at System.Windows.Forms.Control.get_BindingContextInternal()
   at System.Windows.Forms.Control.get_BindingContext()
   at System.Windows.Forms.Control.get_BindingContextInternal()
   at System.Windows.Forms.Control.get_BindingContext()
   at System.Windows.Forms.Control.UpdateBindings()
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e)
   at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e)
   at System.Windows.Forms.ContainerControl.OnCreateControl()
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Binding
    Assembly Version: 0.0.0.0
    Win32 Version:  
    CodeBase: file:///Z:/lumiere/Binding.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Accessibility
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Accessibility/2.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:


    


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

that thing about ruby

January 31st, 2009

Ruby is a great language, but one thing it needs is process. And what seems to suffer most from this is documentation.

  1. Ruby’s not ready
  2. Ruby 1.9.1 released

more bad ui from Adobe

January 27th, 2009

Found this Adobe ui bashing blog today. I really think we need more of this, our standards for ui aren't good enough. We do a lot of criticism for bad code, because we're technically minded. But bad code is less harmful sometimes than bad ui.

There's a reason ui critique is so hard to do without getting into a fit of fury. It's like a guy standing over you saying "no, don't tie your shoe laces like that, do it like this". And then he forces you to do it his way every single day for the rest of your life.

Of course, this isn't the first time we've seen Adobe, the tool builders for the designers of the world, complimented on their ui.

what is smalltalk today?

January 26th, 2009

So Smalltalk is one of those languages that gets thrown around a lot in discussions about languages. After all, it is where the object oriented paradigm pretty much originated (although I suppose Simula sort of had a version of that without that explicit name), and so many languages have drawn on it for inspiration, even if most have gone a completely different way in realizing the OO idea.

As historical reference, Smalltalk is big, no doubt about that. And as a language it is pretty clever. Dynamic and self reflective, it just runs the whole time, objects are live and can be altered on-the-fly with a change to the code.

But what is Smalltalk today? Is it worth learning? From what I can see, and I should say I haven't really spent that much time looking, it seems pretty dead. There is Squeak, where you get the whole image and you do everything inside the virtual machine. From what I understand this is the way you're supposed to use Smalltalk. But frankly I'm not interested in an application that only runs inside a VM. For the same reason that noone really wants to run apps in VirtualBox or VMware.

Most of the Squeak tutorials seem to be 404. And I have yet to see anything that's really interesting. In the end, programming is about programs, and without shiny programs to show off, what is left for us? The Smalltalk website, sporting a 1997 kind of look, has a list of apps on show. Based on that it's hard to get excited about the language.

Okay, so there is something called Seaside, a web framework. And I can kind of see how it's cool to have a web application that has to run 24/7, and meanwhile you can do live updates to the objects. But I'm not shopping for a web framework anyway, and there's a ton of them already.

So is Smalltalk merely a historical curiosity at this point?

java plugin galore

January 25th, 2009

Ever lay awake at night wondering what happens when you hit a web page with a java applet on a vanilla Ubuntu? Me neither. It turns out that it's this:


Embarrassment of riches! There are a few problems with this feature:

  1. While it's great that you help me install the plugin, I have no idea what all these things are. All I wanted was "java".
  2. There is no "default" or "recommended" choice. I can see that one of them is selected, but for all I know that's because the choices showed up in this order at random.
  3. Even if I were inclined to think that the selected choice is selected for a reason, there's another choice that's exactly the same.
  4. "No description found in plugin database." is not exactly helpful. In fact, it could be just the thing to help me here.
  5. If I wing it and install one of these, and then it turns out it doesn't work (perish the thought!), the little notification at the top of the web page isn't going to show up again (because a java plugin, working or not, would be installed). So there's no way I can come back to this screen.
  6. If I am the kind of user who understands that the choices in this dialog represent packages in the system, then I don't know what they are called, because the package names are not mentioned. So if I want to uninstall a plugin that doesn't work, I don't know what to uninstall.

There is another dialog in the Firefox settings for plugins:

Strangely, there is no option to uninstall plugins here, just disable. But I guess that if I disable the java plugin, I can revisit that java web page and get that plugin selection dialog again (and try a different one). Still, it takes a bit of detective work to figure that out, it could be made more obvious.

This example demonstrates the difference between starting on a problem, and actually solving it. I'm very pleased that we have these helper dialogs now, but it needs a bit more thought put into it.

Bug: #320989
I actually picked this example because there used to be two or three options in that dialog, but now there are five.