[Mono-osx] 3 cross-platform questions

Joanna Carter cocoasharp at carterconsulting.org.uk
Thu Feb 26 03:08:34 EST 2009

Mac Programmer a écrit :

> Actually, that's what WinForms on Mac does, calling functions in the 
> Carbon framework, so I don't know why it would be any different with Cocoa.

It may call Carbon equivalents for WinForms functionality but Winforms 
doesn't have anywhere near asz much functionality as either Carbon or 
Cocoa provide, therefore a Winforms app translated to Carbon/Cocoa will 
not support those features.

> But really, if cross-platform custom controls are not the norm, how then 
> is Mono a useful cross-platform tool? Most of my projects involve custom 
> controls, but if using them means WinForms, then Mono starts looking 
> more like a Windows emulator and maybe it would make more sense to tell 
> users just to get Windows and run the real thing.

Mono is an excellent tool for providing cross-platform business logic 
and, since that is, usually, the major part of applications, it is very 
useful. For UI controls, though, you are still compelled to write them 
once for each platform.

> Not sure I would assign even a small part of the blame on RAD tools like 
> Delphi. It's pretty easy to prevent this from happening. Just include a 
> requirement for a project that says something like "Core 
> functionality/calculating engine/whatever must also be available to use 
> in a console app, DLL, COM Automation server, Web app (pick any one)". 
> That will pretty much sever the head from the body.

I speak as someone who started with Delphi 1 and is now using VS2008, 
and who continually encounters developers who seem to be almost proud of 
the size of their form code units. Because there is no limitation 
against writing tens of thousands of lines of business code in a UI 
class, RAD tools like Delphi and VS are definitely to blame for the lack 
of understanding of separation of UI from logic.

> method MainForm.InitializeComponent; 
> begin
>   mainWindow := new Cocoa.Window(new Cocoa.Rect(200, 200, 400, 300),
>                                  WindowStyle.Resizable or 
>                                  WindowStyle.Closable or 
>                                  WindowStyle.Titled,
>                                  BackingStoreType.Buffered, True);
>   mainWindow.Title := 'Hey, there!';
>   button1 := new Cocoa.Button(new Cocoa.Rect(200, 20, 82, 32));
>   button1.BezelStyle := BezelStyle.Rounded;
>   button1.Title := 'Blank';
>   button1.Action += new System.EventHandler(button1_Click);
>   mainWindow.View.AddSubView(button1);
>   mainWindow.Show();
> end;

Hmmm, that looks like a lot more work than using a visual designer, 
although, if the designer generated this kind of code, as does VS, I 
would not complain.

> method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
> begin
>   button1.Title := 'Pushed';
> end;

And this is the start of implementing business logic in the UI ;-)


Joanna Carter
Carter Consulting

More information about the Mono-osx mailing list