<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>Building Blocks &#187; OCD</title>
	<atom:link href="http://joelhooks.com/category/ocd/feed/" rel="self" type="application/rss+xml" />
	<link>http://joelhooks.com</link>
	<description>as simple as possible, but no simpler</description>
	<lastBuildDate>Tue, 29 Jun 2010 18:45:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
		<item>
		<title>Complex DataGrid filterFunction in Flex/Air</title>
		<link>http://joelhooks.com/2008/03/14/complex-datagrid-filterfunction-in-flexair/</link>
		<comments>http://joelhooks.com/2008/03/14/complex-datagrid-filterfunction-in-flexair/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 04:52:02 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[OCD]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://joelhooks.com/2008/03/14/complex-datagrid-filterfunction-in-flexair/</guid>
		<description><![CDATA[So I need to add robust user controlled filtering options in the application I am working on. This problem has dogged me for a month or two, with my co-workers politely insisting on more and better ways to filter their data. This is completely understandable. When you are staring down a datagrid that is virtually [...]]]></description>
			<content:encoded><![CDATA[<p>So I need to add robust user controlled filtering options in the application I am working on. This problem has dogged me for a month or two, with my co-workers politely insisting on more and better ways to filter their data. This is completely understandable. When you are staring down a datagrid that is virtually 12 feet long, getting to what you actually want to see is important.</p>
<p>This <a href="http://www.brucephillips.name/blog/index.cfm/2006/11/23/Sort-An-ArrayCollection-By-Multiple-Fields-and-Filter-An-ArrayCollection-By-Multiple-Fields-In-Flex">2006 article from Bruce Phillips</a> was a big help in the basic concept of multiple input filtering. As is his normal style, it is littered with good references to the source material from his research. This is only considering two filter parameters, however, and I need to consider n parameters, that will probably shift as the needs of the end user grow.</p>
<p>The problem is that each new filtering parameter exponentially increases the complexity of the filterFunction. I can see the pattern, but I haven't quite reached the epiphany that I need to break it down into one of those tight little functions I see real programmers creating (unfortunately, I haven't seen any that address my specific problem).</p>
<p>I thought I'd share my naive, and perhaps confusing filterFunction. It would be great to hear how others approach this problem, and come up with a concise solution.</p>
<p>This function utilizes a TextInput to get text search input from the user. It uses<br />
a series of CheckBoxes for various status condition to generate an array [ 1, 0, 1, 1 ]<br />
to represent their on/off state. It also uses two combo boxes to filter by staff members<br />
as well as clients.</p>
<p>filterFunction:</p>

<div class="wp_codebox"><table><tr id="p282"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
</pre></td><td class="code" id="p28code2"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> filterCases<span style="color: #66cc66;">&#40;</span>item:CaseVO<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">//is the item visible or hidden</span>
	<span style="color: #000000; font-weight: bold;">var</span> result:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	<span style="color: #808080; font-style: italic;">//array of CheckBox.selected property values</span>
       <span style="color: #808080; font-style: italic;">// in handy ones and zeroes. This is returned from a function</span>
       <span style="color: #808080; font-style: italic;">// that takes the actual CheckBoxes as input and gives me this.</span>
	<span style="color: #000000; font-weight: bold;">var</span> case_mask:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span> <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#93;</span>;
        <span style="color: #808080; font-style: italic;">//a couple VOs to verify the selectedItem in the ComboBoxes.</span>
	<span style="color: #000000; font-weight: bold;">var</span> client:PersonVO;
	<span style="color: #000000; font-weight: bold;">var</span> expert:PersonVO;
	<span style="color: #808080; font-style: italic;">//array iteration variable</span>
	<span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> dateFormat:DateFormatter = <span style="color: #000000; font-weight: bold;">new</span> DateFormatter<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>
	dateFormat.<span style="color: #006600;">formatString</span> = <span style="color: #ff0000;">'MM/DD/YY'</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">//text search</span>
	<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">caseNumInput</span>.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">length</span> <span style="color: #66cc66;">&amp;</span>gt; <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> searchResult:<span style="color: #0066CC;">Boolean</span> = <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'0'</span> + item.<span style="color: #006600;">case_id</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">caseNumInput</span>.<span style="color: #0066CC;">text</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">||</span>
										<span style="color: #66cc66;">&#40;</span> item.<span style="color: #006600;">style</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">caseNumInput</span>.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>  <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span> item.<span style="color: #006600;">description</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			searchResult = searchResult <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">&#40;</span> item.<span style="color: #006600;">description</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">caseNumInput</span>.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> item.<span style="color: #006600;">client_id</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			searchResult = searchResult <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">&#40;</span> personProxy.<span style="color: #006600;">personFromId</span><span style="color: #66cc66;">&#40;</span> item.<span style="color: #006600;">client_id</span> <span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">fullName</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">caseNumInput</span>.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">toLowerCase</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> item.<span style="color: #006600;">date_of_accident</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			searchResult = searchResult <span style="color: #66cc66;">||</span> <span style="color: #66cc66;">&#40;</span> dateFormat.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span>item.<span style="color: #006600;">date_of_accident</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">search</span><span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">caseNumInput</span>.<span style="color: #0066CC;">text</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt;= <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> i = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; case_mask.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">client</span>.<span style="color: #006600;">selectedItem</span> is PersonVO <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				client = caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">client</span>.<span style="color: #006600;">selectedItem</span>
&nbsp;
				<span style="color: #808080; font-style: italic;">//is an expert selected for filtering also?</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span> is PersonVO <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; searchResult<span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					expert = caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span>;
					<span style="color: #808080; font-style: italic;">//filter for client, expert, and status</span>
					<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
							<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">client_id</span> == client.<span style="color: #006600;">id</span>
							<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">expert_id</span> == expert.<span style="color: #006600;">id</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; searchResult  <span style="color: #66cc66;">&#41;</span>
						result = <span style="color: #000000; font-weight: bold;">true</span>;
				<span style="color: #66cc66;">&#125;</span>
				<span style="color: #b1b100;">else</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #808080; font-style: italic;">//filter for client and status</span>
					<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
							<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">client_id</span> == client.<span style="color: #006600;">id</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; searchResult  <span style="color: #66cc66;">&#41;</span>
						result = <span style="color: #000000; font-weight: bold;">true</span>;
				<span style="color: #66cc66;">&#125;</span>
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span> is PersonVO <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				expert = caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span>;
				<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> i = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; case_mask.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
				<span style="color: #66cc66;">&#123;</span>
					<span style="color: #808080; font-style: italic;">//filter for expert and status</span>
					 <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
					 		<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">expert_id</span> == expert.<span style="color: #006600;">id</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; searchResult  <span style="color: #66cc66;">&#41;</span>
					 	result = <span style="color: #000000; font-weight: bold;">true</span>
				<span style="color: #66cc66;">&#125;</span>
&nbsp;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #808080; font-style: italic;">//filter for client and status</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
						<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; searchResult  <span style="color: #66cc66;">&#41;</span>
					result = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">//see if a client is selected for filtering</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">client</span>.<span style="color: #006600;">selectedItem</span> is PersonVO <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		client = caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">client</span>.<span style="color: #006600;">selectedItem</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> i = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; case_mask.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//is an expert selected for filtering also?</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span> is PersonVO <span style="color: #66cc66;">&#41;</span>
			<span style="color: #66cc66;">&#123;</span>
				expert = caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span>;
				<span style="color: #808080; font-style: italic;">//filter for client, expert, and status</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
						<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">client_id</span> == client.<span style="color: #006600;">id</span>
						<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">expert_id</span> == expert.<span style="color: #006600;">id</span>  <span style="color: #66cc66;">&#41;</span>
					result = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span>
			<span style="color: #b1b100;">else</span>
			<span style="color: #66cc66;">&#123;</span>
				<span style="color: #808080; font-style: italic;">//filter for client and status</span>
				<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
						<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">client_id</span> == client.<span style="color: #006600;">id</span>  <span style="color: #66cc66;">&#41;</span>
					result = <span style="color: #000000; font-weight: bold;">true</span>;
			<span style="color: #66cc66;">&#125;</span>
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">//client isn't selected, check the expert filter.</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span> is PersonVO <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		expert = caseGrid.<span style="color: #006600;">filter</span>.<span style="color: #006600;">expert</span>.<span style="color: #006600;">selectedItem</span>;
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> i = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; case_mask.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//filter for expert and status</span>
			 <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#40;</span>case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
			 		<span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #006600;">expert_id</span> == expert.<span style="color: #006600;">id</span>  <span style="color: #66cc66;">&#41;</span>
			 	result = <span style="color: #000000; font-weight: bold;">true</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #808080; font-style: italic;">//finally, filter for the status</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> i = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt; case_mask.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">//filter for status</span>
			<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> case_mask<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&amp;</span>amp;<span style="color: #66cc66;">&amp;</span>amp; item.<span style="color: #0066CC;">status</span> == <span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#40;</span> i + <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>
				result = <span style="color: #000000; font-weight: bold;">true</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> result
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>You can see that I am repeating myself from the top down to the final else statement, cutting the filter parameters down like a layer cake. It works, and is relatively quick on a grid with 1500 or so items. This just screams "<strong>REFACTOR ME</strong>" every time I see it.</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/03/14/complex-datagrid-filterfunction-in-flexair/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Bram Cohen on what it takes to be a great programmer.</title>
		<link>http://joelhooks.com/2008/01/21/bram-cohen-on-what-it-takes-to-be-a-great-programmer/</link>
		<comments>http://joelhooks.com/2008/01/21/bram-cohen-on-what-it-takes-to-be-a-great-programmer/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 20:10:37 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[OCD]]></category>
		<category><![CDATA[Unit Testing]]></category>
		<category><![CDATA[software architecture]]></category>

		<guid isPermaLink="false">http://joelhooks.com/2008/01/21/bram-cohen-on-what-it-takes-to-be-a-great-programmer/</guid>
		<description><![CDATA[Bram's complete words here. There are only two coding skills which mostly people who are completely self-taught as a programmer miss out on: proper encapsulation, and unit tests. For proper encapsulation, you should organize your code so that changes which require modifying code in more than one module are as rare as possible, and for [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bramcohen.livejournal.com/4563.html">Bram's complete words here.</a></p>
<blockquote><p>There are only two coding skills which mostly people who are completely self-taught as a programmer miss out on: proper encapsulation, and unit tests. For proper encapsulation, you should organize your code so that changes which require modifying code in more than one module are as rare as possible, and for unit tests you should write them to be pass/fail so that all unit tests can be run as a comprehensive suite. And now you know everything you need to about those two things. Anyone who is taught the above guidelines, and decides they really want to learn those skills, will with sufficient practice become good at them.</p>
<p>Coding skill is all well and good, and you can't become a great programmer without it, but it's far from everything. I'm decent at raw coding, but I know many people who are better, and some of them are abysmal programmers. I in particular can't deal with being tasked with fixing up spaghetti code. <strong>My brain simply locks down and refuses to make any modifications which it isn't convinced will work, which is of course impossible when the source material is an incurably bug-ridden mess.</strong></p></blockquote>
<p>I've felt this way about my own code with almost everything I've written to date. It has been a struggle for me, to go from an unstructured mess to something other people might be able to look at without throwing up.</p>
<p>It is apparent why people might skip over the 'proper encapsulation and unit tests' while teaching themselves software programming in a non-formal way. They are easily overlooked, and without a grade-book shaped stick hovering over your backside to force that sort of formality, one could easily just slide past these skills and program off the cuff. One of my challenges in learning to program has been to build things properly, to <strong>not</strong> re-invent the wheel every single time I sit down to make something meaningful in software. My preference is to stand on the shoulders of those that have come before me, and use the collective knowledge of masters, past and present, to expand my understanding and knowledge in appropriate directions. The trick is to do all of this with an open mind. We need to evaluate  new ideas and differing opinions without locking onto one particular nerd dogma. I don't know that I will ever be a <em>great</em>  programmer, but I will have fun trying.</p>
<p>Here's another interesting piece regarding software education and what it takes to be a great programmer: <a href="http://itmanagement.earthweb.com/career/article.php/3722876">Who Killed the Software Engineer? (Hint: It Happened in College) </a></p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/01/21/bram-cohen-on-what-it-takes-to-be-a-great-programmer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Holding a Program in One&#039;s Head</title>
		<link>http://joelhooks.com/2008/01/21/holding-a-program-in-ones-head/</link>
		<comments>http://joelhooks.com/2008/01/21/holding-a-program-in-ones-head/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 16:30:17 +0000</pubDate>
		<dc:creator>Joel</dc:creator>
				<category><![CDATA[OCD]]></category>
		<category><![CDATA[Paul Graham]]></category>

		<guid isPermaLink="false">http://joelhooks.com/2008/01/21/holding-a-program-in-ones-head/</guid>
		<description><![CDATA[A good programmer working intensively on his own code can hold it in his mind the way a mathematician holds a problem he's working on. Mathematicians don't answer questions by working them out on paper the way schoolchildren are taught to. They do more in their heads: they try to understand a problem space well [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><font face="verdana" size="2">A good programmer working intensively on his own code can hold it in his mind the way a mathematician holds a problem he's working on.  Mathematicians don't answer questions by working them out on paper the way schoolchildren are taught to.  They do more in their heads: they try to understand a problem space well enough that they can walk around it the way you can walk around the memory of the house you grew up in.  At its best programming is the same.  You hold the whole program in your head, and you can manipulate it at will.</font></p></blockquote>
<p>I was discussing my recent experience with programming dreams, some might say nightmares, with <a href="http://puremvc.org/">Cliff Hall</a>. He pointed me to <a href="http://www.paulgraham.com/head.html">this essay</a> from <a href="http://en.wikipedia.org/wiki/Paul_Graham">Paul Graham</a> that really nails it. It is so difficult to just shut down after a long period of working on a difficult programming problem. I find myself staying up way to late, because I don't want my brain to lose the trail with mere sleep. Will... sleep... when... dead...</p>
]]></content:encoded>
			<wfw:commentRss>http://joelhooks.com/2008/01/21/holding-a-program-in-ones-head/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
	</channel>
</rss>
