|
 |
|
 |
|
OK, let's say you spend a long, long time writing a rather nifty ComboBox for ASP.NET.
What would you do if someone looked at your code to fix issues in their own version?
What would you do if they then gave their version away for free?
It all makes me wonder why I bother. Why go to the effort of producing controls at all? Why spend time fixing the really difficult DHTML issues whenever someone else will just come along, "review" the code and then release their own version, for free, so that people don't buy from the folks that fixed the issues?
Why do I bother?
(P.S. No, I don't have kids.)
Posted by 'Geoff' on Wednesday, 15 June 2005. No comments.
|
|
 |
 |
 |
|
 |
|
 |
|
I've just put the finishing touches to the latest release (v1.1.0.2) of the PowerPack. You can download it right now.
One of the changes made in this release was moving the Javascript objects' methods into closures set through the prototype.
This is interesting stuff, if you're into DHTML, and like watching
paint dry if you don't. Feel free to switch off now.
Javascript's
notion of objects is a bit different from what developers in compiled
OO languages are used to. Instead of having a specific entity
like a constructor, Javascript just uses a function. If the
function returns something, and it's called via a "new" call instead of
a regular function call, then it's assumed to be a constructor.
Which is nice enough, but it does leave you with the problem of how you create methods in your object.
The way it was done int he PowerPack up until now was just to do something like:
function MyObject ()
{
this.myMethod = myMethodBody;
return;
}
function myMethodBody ()
{
return;
}
So
you'd be assigning a reference to the myMethodBody function to the
this.myMethod property on the new object. You could then do
something like:
var myObj = new MyObject ();
myObj.myMethod ();
Which gives you nice OO flavour.
The
new way of doing this in the PowerPack uses closures and
prototypes. This gives the same results as the above mechanism,
but it has a couple of advantages.
The equivalent closure and prototype code for the above would be:
function MyObject ()
{
return;
}
MyObject.prototype.myMethod = function ()
{
return;
}
This again allows you to use code like:
var myObj = new MyObject ();
myObj.myMethod ();
The advantages of this closure and prototype approach are:
- I'm
no longer polluting the global namespace with function names that are
redundant. (Since they'll always be called through their method names,
the function names themselves are never used.)
- The
creation of methods associated with objects can be optimised better,
since it isn't done through the constructor every time an object is
constructed.
- This is a cleaner, more Javascripty approach.
Why
did I wait until now to do this? To be honest, I don't
know. I don't know why they weren't done like this in the first
place. It's not like I wasn't aware of Javascript prototypes -
I've code I wrote in the nineties that used them.
Still, better late than never.
The complete fix list for this release is:
- ComboBox. Layout problem with absolutely-positioned Panels/DIVs in IE.
FIXED.
- ComboBox. Different layout problem with absolutely-positioned Panels/DIVs in Firefox.
FIXED.
- ComboBox. Designer wasn't appearing in design-view.
FIXED.
- ComboBox. Caused Javascript errors in Firefox if Visible was set to False.
FIXED.
- RichTextBox. Toolbar would occasionally become disabled.
FIXED.
- ComboBox, DatePicker, RichTextBox, ShowOnConditionClientSide.
All Javascript files now use enclosures and prototypes for their object definitions,
so they no longer clutter the global namespace.
FIXED.
Posted by 'Geoff' on Sunday, 05 December 2004. No comments.
|
|
 |
 |
 |
|
|
 |
|
 |
|
The good news is that I've been working on a new version of the PowerPack for y'all. A few bug fixes, a few improvements to the RichTextBox and so on.
Unforunately, I don't have FTP access to this site at the minute, so I can't upload it.
Rest assured I'll get it to you as soon as I can.
Posted by 'Geoff' on Sunday, 21 November 2004. No comments.
|
|
 |
 |
 |
|