JavaScript, inheritance via prototype?
Monday, January 29, 2007 | Technology
Last week I was on holiday (hence zero posts) and I found myself with a little free time for a private project. I thought that given all the noise around AJAX, JSON, WPF/E and the Vista side bar I'd better get back into JavaScript (I'll post more about the project itself soon). Most web developers have done something with JavaScript at some point or another and I'm no different. I have written many a DHTML script generating custom graphs in pure HTML using tables and XML. However, after spending a little time reading a book I bought about ~7 years ago on JavaScript whilst on holiday I now realise that I never really knew JavaScript in the first place, let alone get back into it!
I am simply amazed at how much you can do with the language without ever really knowing it. I have seen JavaScript as a credential on many a CV (including my own) and I never really thought to question it, but after my own recent experience I'm sure that many a programmer thinks they already know about JavaScript but whether they really know it is another question.
I wonder if you we're to ask them how to create a JavaScript class called Customer that had an instance method call getServices(), a property called customerId as well as static property called NullCustomerId and a static method called RenderCustomer(), oh, and by the way the class must also inherit from a base class called Contact; how many of those candidates could actually write me a JavaScript class that looked that way? I know I certainly could not have until very recently.
What I'm really impressed with is that I never needed to know those things to get what I needed to do done. I have written 100's if not 1000's of lines in JavaScript over the years and now realise I never really understood it, all I ever wrote were global functions - now that's a great (not a good, but a great) language that can hide that much of it's power and still be useful.
I'm now comfortable that I know how to do the above, should that be required, along with other features such as anonymous methods, associative arrays, inheritance via prototypes and using functions as data - all JavaScript goodness. But I'm also happy that other people don't and still consider themselves proficient in JavaScript, that's a feature and the power of the JavaScript language.
I am simply amazed at how much you can do with the language without ever really knowing it. I have seen JavaScript as a credential on many a CV (including my own) and I never really thought to question it, but after my own recent experience I'm sure that many a programmer thinks they already know about JavaScript but whether they really know it is another question.
I wonder if you we're to ask them how to create a JavaScript class called Customer that had an instance method call getServices(), a property called customerId as well as static property called NullCustomerId and a static method called RenderCustomer(), oh, and by the way the class must also inherit from a base class called Contact; how many of those candidates could actually write me a JavaScript class that looked that way? I know I certainly could not have until very recently.
What I'm really impressed with is that I never needed to know those things to get what I needed to do done. I have written 100's if not 1000's of lines in JavaScript over the years and now realise I never really understood it, all I ever wrote were global functions - now that's a great (not a good, but a great) language that can hide that much of it's power and still be useful.
I'm now comfortable that I know how to do the above, should that be required, along with other features such as anonymous methods, associative arrays, inheritance via prototypes and using functions as data - all JavaScript goodness. But I'm also happy that other people don't and still consider themselves proficient in JavaScript, that's a feature and the power of the JavaScript language.
New name...
Friday, January 19, 2007 | News
This site now boasts a new name: https://compilewith.net, the old name will also work just fine (for while) so please update your links.
WPF/E
Wednesday, January 17, 2007 | .Net, Technology, WPF
There is a new technology out and freely available from Microsoft and it's called Windows Presentation Foundation. For your average web developer (beyond the name being a bit of a mouthful) there is nothing of interest here, right?
Well... maybe not. More traditionally it has been a pretty safe bet for web developers to ignore the majority of noise coming out on the Windows Forms platform or any Windows desktop technology from Microsoft and the .Net community at large. However, I think WPF is different due to WPF/E. If you are a web developer today, get the book and prepare for the "E".
For more information you might want to start here.
Well... maybe not. More traditionally it has been a pretty safe bet for web developers to ignore the majority of noise coming out on the Windows Forms platform or any Windows desktop technology from Microsoft and the .Net community at large. However, I think WPF is different due to WPF/E. If you are a web developer today, get the book and prepare for the "E".
For more information you might want to start here.
GData: The future of CRUD?
Monday, January 15, 2007 | Technology
is basically about list management (RESTful as opposed to Soap and WSDL, however); as many look to Google at the moment for inspiration, due to their innovation, could this be the future of CRUD (Create, Read, Update and Delete) for distributed services (a.k.a web services)?
In the Google document they also talk about versioning as well as managing optimistic locking, which I find very interesting as this is a prickly problem for services regardless of whether they use REST or Soap and WSDL.
This first came to my attention via Dons post on the subject.
In the Google document they also talk about versioning as well as managing optimistic locking, which I find very interesting as this is a prickly problem for services regardless of whether they use REST or Soap and WSDL.
This first came to my attention via Dons post on the subject.
IDisposable
Monday, January 15, 2007 | .Net, Technology
IDisposable is a well known and understood pattern within .Net, which is used for the timely clean up of any resources mainly designed for unmanaged resources. For a little history on where this interface came from and the purpose of the Component class you should check out http://www.dotnetrocks.com/ episode 10:
Carl Franklin: So, are you telling me that you are responsible
for the dispose method?
Chris Sells: I am responsible for the "using" statement in C# too. But don’t blame me that’s not the solution that I asked for.
Anyway, it's not the traditional use of IDisposable that this post is about. I want to talk about an "interesting" use of the IDisposable pattern: some time ago (I want to say ~3 years ago) I discovered a technique (I think originally in the NUnit codebase, but cannot be sure). The easiest way to explain what I'm banging on about here is to show you (the first time I used this technique it was for setting the mouse cursor in Windows Forms):
The way you would then use this class would be:
Once the block of code within the using has finished executing the cursor will be returned to its original state; this would more normally require a try-finally block to be used, which would reset the cursor in the finally block (leads to ugly code IMHO). When I first saw this technique I thought "That's brilliant!" and immediately stole it - my hope is that you do the same.
Carl Franklin: So, are you telling me that you are responsible
for the dispose method?
Chris Sells: I am responsible for the "using" statement in C# too. But don’t blame me that’s not the solution that I asked for.
Anyway, it's not the traditional use of IDisposable that this post is about. I want to talk about an "interesting" use of the IDisposable pattern: some time ago (I want to say ~3 years ago) I discovered a technique (I think originally in the NUnit codebase, but cannot be sure). The easiest way to explain what I'm banging on about here is to show you (the first time I used this technique it was for setting the mouse cursor in Windows Forms):
public class WaitCursor : IDisposable
{
private Form _parent;
private Cursor _previousCursor;
public WaitCursor(Form parent)
{
this._parent = parent;
this._previousCursor = this._parent.Cursor;
SetCursor(Cursors.WaitCursor);
}
private void SetCursor(Cursor targetCursor)
{
if(this._parent == null) return;
this._parent.Cursor = targetCursor;
}
public void Dispose()
{
SetCursor(this._previousCursor);
}
}
The way you would then use this class would be:
using(new WaitCursor(this))
{
// ...do some work here that
// requires the "Hour Glass"
}
Once the block of code within the using has finished executing the cursor will be returned to its original state; this would more normally require a try-finally block to be used, which would reset the cursor in the finally block (leads to ugly code IMHO). When I first saw this technique I thought "That's brilliant!" and immediately stole it - my hope is that you do the same.
Toxic
Thursday, January 11, 2007 | Management
Ever heard of the phrase "Toxic Manager", worse still, have you ever worked with a Toxic Manager? This was a brand new phrase that entered my vocabulary today; for which I am truly grateful. You see, I was starting to believe that it was me. But it's not, it's about control! More accurately put: their lack there of.
You need to look . Bullies exist the world over (sadly) and the work place is no different. The vast majority of my working career has been within a technical environment and I have only come across two real bullies - one was a young lad just out of school (as was I) and he thought the same rules applied in work as they did in school; he was mistaken. The second more recently...
You need to look . Bullies exist the world over (sadly) and the work place is no different. The vast majority of my working career has been within a technical environment and I have only come across two real bullies - one was a young lad just out of school (as was I) and he thought the same rules applied in work as they did in school; he was mistaken. The second more recently...
Wiki
Thursday, January 11, 2007 | Technology
So I'm a Wiki convert. I was introduced to wiki as a concept 3 or 4 years ago where there was a guy in our office developing a website that allowed other people to add content by editing the web pages for the site while you were on a web page using a browser! How bizarre, why would you want to do such a thing?
Scroll to the here and now and it has taken me this long to really get it - I have understood it both conceptually and technically for some time - but now I really get it with help of my friends (thank you Matt and ).
Scroll to the here and now and it has taken me this long to really get it - I have understood it both conceptually and technically for some time - but now I really get it with help of my friends (thank you Matt and ).
Newer Posts Home
Subscribe to: