You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/05/06 08:32:37 UTC

git commit: [flex-sdk] [refs/heads/develop] - FLEX-26048 check if date range actually contains dates

Updated Branches:
  refs/heads/develop 659a9234f -> 63bd807f8


FLEX-26048 check if date range actually contains dates


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/63bd807f
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/63bd807f
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/63bd807f

Branch: refs/heads/develop
Commit: 63bd807f8e087e164d5b6fce846bc4a917f3f140
Parents: 659a923
Author: Justin Mclean <jm...@apache.org>
Authored: Mon May 6 16:21:31 2013 +1000
Committer: Justin Mclean <jm...@apache.org>
Committed: Mon May 6 16:21:31 2013 +1000

----------------------------------------------------------------------
 .../projects/mx/src/mx/controls/DateChooser.as     |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/63bd807f/frameworks/projects/mx/src/mx/controls/DateChooser.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/mx/src/mx/controls/DateChooser.as b/frameworks/projects/mx/src/mx/controls/DateChooser.as
index 27fe888..ed05856 100644
--- a/frameworks/projects/mx/src/mx/controls/DateChooser.as
+++ b/frameworks/projects/mx/src/mx/controls/DateChooser.as
@@ -3120,14 +3120,14 @@ public class DateChooser extends UIComponent implements IFocusManagerComponent,
         else if (value is Object) 
         {
             var range:Object = {};
-            if (value.rangeStart)
+            if (value.hasOwnProperty("rangeStart") && value.rangeStart is Date)
             {
                 range.rangeStart = new Date(value.rangeStart.getFullYear(), 
                                             value.rangeStart.getMonth(), 
                                             value.rangeStart.getDate());
             }
             
-            if (value.rangeEnd)
+            if (value.hasOwnProperty("rangeEnd") && value.rangeEnd is Date)
             {
                 range.rangeEnd = new Date(value.rangeEnd.getFullYear(), 
                                           value.rangeEnd.getMonth(), 


Re: git commit: [flex-sdk] [refs/heads/develop] - FLEX-26048 check if date range actually contains dates

Posted by OmPrakash Muppirala <bi...@gmail.com>.
>
>
> If this my my code I'd remove the Object altogether and make a range class
> to pass in - that way you don't need any checks and it would be faster.
>


+1 to this.  It always bugged me that I have to send a generic object as a
function parameter.  If we have a typed object, we get the checks built-in.

Re: git commit: [flex-sdk] [refs/heads/develop] - FLEX-26048 check if date range actually contains dates

Posted by Justin Mclean <ju...@classsoftware.com>.
Hi,

> FWIW, at Adobe, the philosophy was to not do much input checking.
For a method that's called a lot/performance critical I agree. In this case it was already doing a check and doing it incorrectly so I see no harm.

If this my my code I'd remove the Object altogether and make a range class to pass in - that way you don't need any checks and it would be faster.

Thanks,
Justin

Re: git commit: [flex-sdk] [refs/heads/develop] - FLEX-26048 check if date range actually contains dates

Posted by Alex Harui <ah...@adobe.com>.
FWIW, at Adobe, the philosophy was to not do much input checking.
"Garbage-in, Garbage Out".  If you pass in garbage, it is ok to get an
exception thrown back at you.  Theoretically, folks debug their code to the
point where it won't need these checks in production.  Sure, any individual
check is small and probably leads to better developer productivity, but they
all add up to a bigger and slower runtime when they shouldn't be needed.

In fact, one of my hopes for FlexJS and its "beads" is to make it possible
for folks to swap in debug-mode beads that do have helpful input checking
and then swap in production-mode beads later.


On 5/5/13 11:32 PM, "jmclean@apache.org" <jm...@apache.org> wrote:

> Updated Branches:
>   refs/heads/develop 659a9234f -> 63bd807f8
> 
> 
> FLEX-26048 check if date range actually contains dates
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/63bd807f
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/63bd807f
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/63bd807f
> 
> Branch: refs/heads/develop
> Commit: 63bd807f8e087e164d5b6fce846bc4a917f3f140
> Parents: 659a923
> Author: Justin Mclean <jm...@apache.org>
> Authored: Mon May 6 16:21:31 2013 +1000
> Committer: Justin Mclean <jm...@apache.org>
> Committed: Mon May 6 16:21:31 2013 +1000
> 
> ----------------------------------------------------------------------
>  .../projects/mx/src/mx/controls/DateChooser.as     |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/63bd807f/frameworks/proje
> cts/mx/src/mx/controls/DateChooser.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/mx/src/mx/controls/DateChooser.as
> b/frameworks/projects/mx/src/mx/controls/DateChooser.as
> index 27fe888..ed05856 100644
> --- a/frameworks/projects/mx/src/mx/controls/DateChooser.as
> +++ b/frameworks/projects/mx/src/mx/controls/DateChooser.as
> @@ -3120,14 +3120,14 @@ public class DateChooser extends UIComponent
> implements IFocusManagerComponent,
>          else if (value is Object)
>          {
>              var range:Object = {};
> -            if (value.rangeStart)
> +            if (value.hasOwnProperty("rangeStart") && value.rangeStart is
> Date)
>              {
>                  range.rangeStart = new Date(value.rangeStart.getFullYear(),
>                                              value.rangeStart.getMonth(),
>                                              value.rangeStart.getDate());
>              }
>              
> -            if (value.rangeEnd)
> +            if (value.hasOwnProperty("rangeEnd") && value.rangeEnd is Date)
>              {
>                  range.rangeEnd = new Date(value.rangeEnd.getFullYear(),
>                                            value.rangeEnd.getMonth(),
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: git commit: [flex-sdk] [refs/heads/develop] - FLEX-26048 check if date range actually contains dates

Posted by Alex Harui <ah...@adobe.com>.
FWIW, at Adobe, the philosophy was to not do much input checking.
"Garbage-in, Garbage Out".  If you pass in garbage, it is ok to get an
exception thrown back at you.  Theoretically, folks debug their code to the
point where it won't need these checks in production.  Sure, any individual
check is small and probably leads to better developer productivity, but they
all add up to a bigger and slower runtime when they shouldn't be needed.

In fact, one of my hopes for FlexJS and its "beads" is to make it possible
for folks to swap in debug-mode beads that do have helpful input checking
and then swap in production-mode beads later.


On 5/5/13 11:32 PM, "jmclean@apache.org" <jm...@apache.org> wrote:

> Updated Branches:
>   refs/heads/develop 659a9234f -> 63bd807f8
> 
> 
> FLEX-26048 check if date range actually contains dates
> 
> 
> Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
> Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/63bd807f
> Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/63bd807f
> Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/63bd807f
> 
> Branch: refs/heads/develop
> Commit: 63bd807f8e087e164d5b6fce846bc4a917f3f140
> Parents: 659a923
> Author: Justin Mclean <jm...@apache.org>
> Authored: Mon May 6 16:21:31 2013 +1000
> Committer: Justin Mclean <jm...@apache.org>
> Committed: Mon May 6 16:21:31 2013 +1000
> 
> ----------------------------------------------------------------------
>  .../projects/mx/src/mx/controls/DateChooser.as     |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/63bd807f/frameworks/proje
> cts/mx/src/mx/controls/DateChooser.as
> ----------------------------------------------------------------------
> diff --git a/frameworks/projects/mx/src/mx/controls/DateChooser.as
> b/frameworks/projects/mx/src/mx/controls/DateChooser.as
> index 27fe888..ed05856 100644
> --- a/frameworks/projects/mx/src/mx/controls/DateChooser.as
> +++ b/frameworks/projects/mx/src/mx/controls/DateChooser.as
> @@ -3120,14 +3120,14 @@ public class DateChooser extends UIComponent
> implements IFocusManagerComponent,
>          else if (value is Object)
>          {
>              var range:Object = {};
> -            if (value.rangeStart)
> +            if (value.hasOwnProperty("rangeStart") && value.rangeStart is
> Date)
>              {
>                  range.rangeStart = new Date(value.rangeStart.getFullYear(),
>                                              value.rangeStart.getMonth(),
>                                              value.rangeStart.getDate());
>              }
>              
> -            if (value.rangeEnd)
> +            if (value.hasOwnProperty("rangeEnd") && value.rangeEnd is Date)
>              {
>                  range.rangeEnd = new Date(value.rangeEnd.getFullYear(),
>                                            value.rangeEnd.getMonth(),
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui