W3C home > Mailing lists > Public > public-pointer-events@w3.org > January to March 2013

Re: pointerType extensibility

From: <brandon.wallace@yahoo.com>
Date: Sat, 16 Feb 2013 07:49:04 -0600
Message-Id: <89A038A2-C2A3-4A13-BA59-D1D4631A0682@yahoo.com>
Cc: Rick Byers <rbyers@google.com>, Pointer Events WG <public-pointer-events@w3.org>
To: François REMY <francois.remy.dev@outlook.com>
Sorry, I accidentally hit Send.

I wanted to add that, while the multiple boolean properties idea also suffers from being slightly harder to use, at least it allows for more flexibility in the way future devices compatibly present themselves.

--
Brandon

On Feb 16, 2013, at 7:45 AM, brandon.wallace@yahoo.com wrote:

> Using instanceof is a bit more tedious than accessing a pointerType property.  With instanceof,an author is reduced to writing a string of if/else statements.  A pointerType property gives authors several options: if/else statements, switch statements, virtual dispatch tables, etc.
> 
> Pure OO designs work best when the different functionality can be captured in overridden virtual methods and the client code doesn't need to actually know the concrete type.  Its usefulness starts to decline when knowing the actual type of object you have is important.
> 
> Also, this approach is limited to single inheritance.  When a new device comes out, it may make sense for it to masquerade as more than one type of legacy device.  This would not be possible.
> 
> --
> Brandon
> 
> On Feb 15, 2013, at 2:51 PM, François REMY <francois.remy.dev@outlook.com> wrote:
> 
>> This is probably a good idea.
>>  
>>  
>>  
>> De : Rick Byers
>> Envoyé : ‎15‎ ‎février‎ ‎2013 ‎19‎:‎55
>> À : François REMY
>> Cc : Pointer Events WG
>> Objet : Re: pointerType extensibility
>>  
>> We agreed on the PE call that this was probably something we could address in V2 (although it might mean pointerType becomes deprecated and inaccurate), and so it shouldn't block going to LCWD.
>> 
>> Since we've already started the discussion (even if we may leave it unfinished until V2), let me try one other proposal that should feel more natural from an OO design perspective.  Instead of have a pointerType field at all, why not just use the type of the event object itself to signal pointer type, and encourage use of 'instanceof' checks.  For the most part people would program to the PointerEvent interface, but they could do, eg. 'instanceof TouchPointerEvent', and in the future browsers (and libraries?) could add, eg. DepthCamPointerEvent and have it derive from TouchPointerEvent.
>> 
>> I know this pure OO approach isn't normally how we design web APIs, but this is a traditional OO extensibility problem we're trying to solve.
>> 
>> Rick
>> 
>> On Tuesday, February 12, 2013, François REMY wrote:
>> > if (e.isPointerType('depth-cam')) {
>> > ... light up additional 3-d features
>> > } else if (e.isPointerType('touch') {
>> > ... definitely a non-depth-cam touch device
>> > }
>> >
>> > Since we probably only care about JavaScript, it's simpler and I think
>> > just as powerful to define a set of boolean read-only properties on the
>> > event, eg. PointerEvent.isMouse, PointerEvent.isTouch, etc.
>> 
>> I agree, a set of boolean properties would be nice. It allows for pointer types that inherit from older ones.                                    
Received on Saturday, 16 February 2013 13:49:33 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:17:04 GMT