<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8588448388030930849</id><updated>2011-04-27T08:19:41.712-07:00</updated><category term='Uncategorized'/><title type='text'>Hitech Blogs</title><subtitle type='html'>A "Hitech" Technical Blog</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-4303172057056651094</id><published>2008-12-26T08:40:00.000-08:00</published><updated>2008-12-26T08:49:32.727-08:00</updated><title type='text'>Blogger’s Blogspot blogging platform Tips and Trics Improve Google Adsense ,Improve Earning ,Earn Money Online , Good Blogger ,:-</title><content type='html'>Hey MakeUseOf! I thought I would share with you what I have learned about Blogger’s Blogspot blogging platform over the last 8 months or so. I jumped into the new Blogger almost immediately after its beta launch and then I wanted to customize it - You know, make it my own.&lt;br /&gt;&lt;br /&gt;So I went out looking for how to do it. And here is that wisdom I uncovered. Consider it a gift from me to you. Poor old Blogger gets a bad wrap, namely because people do not know how to manipulate it. I hope this article helps you guys out and if you have any others please let me know in the comments…&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Removing The Blogger Bar&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I hated the blogger bar across the top of my Web site because it didn’t really go with my template and I already had a Google search bar integrated. So I went on a mission to remove it and de-bloggerify my blog. I searched far and wide and for some reason kept hitting a dead end. It turns out that the code used to change the old blogger templates no longer works! So after tracking down the CSS changes here is how I did it:&lt;br /&gt;&lt;br /&gt;Blogger Tips - Removing The Blogger Bar&lt;br /&gt;&lt;br /&gt;All you need to do is add the following CSS to your template under edit HTML. You need to put in anywhere in your template between the &lt;style&gt;&lt;/style&gt; tags.&lt;br /&gt;&lt;br /&gt;     #navbar-iframe { height:0px; visibility:hidden; display:none; }&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Add a randomizer to show different quotes, graphics or html.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I used to be really jealous of Feedburner’s awesome quotes that change on refresh. I went out looking for my own way to do something similar. It was a long and grueling task but I found it (Well actually my buddy Mike Commodore found it). Check out how I use a free Randomizer ASP application to get my own random geeky quotes and ads to display. I have the quotes on display in my subheader here and the Wicked Tee’s Ad is also on a separate randomizer. To download the RandomQ program hit their website here. For detailed instructions on how we got it to work using iFrame’s check out these step by step instructions.&lt;br /&gt;&lt;br /&gt;Show different quiotes with each refresh&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. Recent comments&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Use this script to achieve a WordPress-esque Recent Comments module for your side bar! Start some riots among your readers! Let them know what others have to say. This site provides a widget creator that I used to make my recent comments module. I found that after adding this, it actually encouraged people to comment more frequently. I don’t know if they like seeing their name up in lights or if they read what others wrote and want to kick in their two cents… But either way it has increased commenting by about 70%!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. That’s a lot of comments!!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Replace your commenting system with Intense Debate for more control over comments with a social flare. It is really easy to do, check out this information from their web site:&lt;br /&gt;&lt;br /&gt;   Interested in the comments your friends make? What if there was a way to follow your friends and be notified when, where, and also what they comment? Intense Debate provides this functionality through RSS feeds for each user. Subscribers will be notified in their RSS readers with a direct link to view the context surrounding the comment as well. Give it a try!&lt;br /&gt;&lt;br /&gt;   Also, don’t waste anymore time checking back in on a blog to see if anyone responded to your comment. Now you can get email notifications of replies to your comments, letting you know when the conversation continues while you’re gone.&lt;br /&gt;&lt;br /&gt;ID&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;5. Adding inline ads&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Want to add advertisements into your posts for maximum exposure? By having your ads out their in front of peoples face they just might click them more often. I am not a big believer in ads. But maybe you are and by following these instructions from MyDigitialLife you can add adds in your post between post or even in the footer. It is not hard to do and involves a little modification to your template. Due to the fact that Blogger parses out some code and changes some characters when you enter it manually in the html this will show you a workaround for that.From their web site:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;6. Use Feedburner&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Feedburner lets you “burn your feed” and add feed flare. Before they were a Google company they were awesome but now that they are a part of the Google they are even better. I use Feedburner for feed statistics, monitoring users subscriptions, managing our daily email blast list and adding feed flare enhancements to your feed. This is a MUST do for any blog. Almost a no brainer. Blogger lets you specify your Feedburner information in their ‘Site Feed’ tab inside your dashboard. Once there you will see a place to plug in your Feeburners URL.&lt;br /&gt;&lt;br /&gt;feedBurner&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;7. Add additional pages (Add links to older posts that you can customize like a contact page.)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is one thing I always hear people complaining about blogger. But I can’t add a second page or even a page for contact information… Wahhh Wahhh Wahhh. How about a little creativity? For this hack all I did was create some posts labeled About Us Contact Us etc. And then made their published dates way back when and linked to the posts from my template. Result - pseudo additional pages!&lt;br /&gt;&lt;br /&gt;NewPages&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;8. Use a real domain name instead of blogger’s default naming conventions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the beginning before we knew any better we though using a free service like Blogger meant being locked into certain things like the sub-domain name off of Blogspot. Google lets you “Brand” your blog and link up a real domain name to forward to your Blogspot address. But they did one better and redirect their address’s to yours. So even if you type in http://askTheAdmin.blogspot.com you will wind up at http://www.askTheAdmin.com! Sweet.&lt;br /&gt;&lt;br /&gt;Your-Domain-Name&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;9. Add Instant Messaging to your Blogger blog.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Want to chat with your users real time? I added Plugoo to my site, linked it up with my AIM account and I am in constant contact with users looking for help or just wanting to say what’s up. This is not for everyone but I found it so cool I now turn my AOL IM mobile when I am AFK and my IM’s hit me via Text message on my Smart Phone.&lt;br /&gt;&lt;br /&gt;pluggo&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;10. Update you blog daily and have quality content. .&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And the last but certainly not least Blogger tip/hack is not a hack at all but a piece of advice . Update your blog on a daily basis. Because that is all the readers want now isn’t it? Would you read your own site - if it wasn’t yours?? If your answer is no, then you got some serious re-thinking to do!&lt;br /&gt;&lt;br /&gt;Do you have any additional tips or tricks for blogger or other blog hosts? We would love to hear about it in the comments!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-4303172057056651094?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/4303172057056651094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/add-url-submit-url-search-engines-msn.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4303172057056651094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4303172057056651094'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/add-url-submit-url-search-engines-msn.html' title='Blogger’s Blogspot blogging platform Tips and Trics Improve Google Adsense ,Improve Earning ,Earn Money Online , Good Blogger ,:-'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-8178949053212434079</id><published>2008-12-26T08:00:00.000-08:00</published><updated>2008-12-26T08:02:17.723-08:00</updated><title type='text'>My New Blogs "Midhun SH Thunderrocks"</title><content type='html'>I am Wishing YOu To Visit My Blogs&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;http://hitechblogs.blogspot.com/&lt;br /&gt;http://mallump3world.blogspot.com/&lt;br /&gt;http://midorkut.blogspot.com/&lt;br /&gt;http://torrentmama.blogspot.com/&lt;br /&gt;http://googleadsense4blogs.blogspot.com/&lt;br /&gt;http://enggseminars.blogspot.com/&lt;br /&gt;http://midblogs.blogspot.com/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-8178949053212434079?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/8178949053212434079/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/my-new-blogs-midhun-sh-thunderrocks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/8178949053212434079'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/8178949053212434079'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/my-new-blogs-midhun-sh-thunderrocks.html' title='My New Blogs &quot;Midhun SH Thunderrocks&quot;'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-6466996373340550412</id><published>2008-12-26T07:47:00.001-08:00</published><updated>2008-12-26T07:59:59.635-08:00</updated><title type='text'>Adsense Updated</title><content type='html'>First page bid estimates: AdWords Editor now uses first page bid estimates for your keywords. Minimum cost-per-click (CPC) bids are no longer used.&lt;br /&gt;&lt;br /&gt;Keyword Quality Score: The Keywords tab now displays the Quality Score for your keywords.&lt;br /&gt;&lt;br /&gt;Keyword Opportunities locale: Tailor your keyword suggestions to a particular language and location by changing your Keyword Opportunities locale.&lt;br /&gt;&lt;br /&gt;Campaign targeting in the data view: You can view your targeting settings in the new 'Language' and 'Location' columns on the Campaigns tab. These columns are hidden by default, but you can select them with the column chooser.&lt;br /&gt;&lt;br /&gt;Other updates:&lt;br /&gt;&lt;br /&gt;The 'Volume' column on the Keyword expansion tab of the Keyword Opportunities tool now shows absolute numbers (traffic for the last month) instead of scaled values.&lt;br /&gt;The Keyword Opportunities tool isn't available for draft accounts.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-6466996373340550412?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/6466996373340550412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/adsense-updated.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/6466996373340550412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/6466996373340550412'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/adsense-updated.html' title='Adsense Updated'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-2402754348233275230</id><published>2008-12-26T07:33:00.001-08:00</published><updated>2008-12-26T07:36:26.665-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Finding Prime Factors</title><content type='html'>This week i have been moderlately busy with work and school. But on my spare time i have been working away at the problems on Project Euler…on my way to a solution i came up with a neat little program (which i wrote in C++) to find the prime factors of a number. Here it is:&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Author: Collin Doering&lt;br /&gt;* Date Completed: April 3, 2008&lt;br /&gt;* Version: 1.0&lt;br /&gt;*/&lt;br /&gt;&lt;br /&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;br /&gt;&lt;br /&gt;using std::cout;&lt;br /&gt;using std::endl;&lt;br /&gt;using std::cin;&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Determines if a given parameter is prime&lt;br /&gt;*/&lt;br /&gt;bool isPrime(int num) {&lt;br /&gt;for (int x = 2; x != ((num / 2) + 1); ++x) {&lt;br /&gt;if ((num % x) == 0) {&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Returns the largest prime divisor of a given number&lt;br /&gt;*/&lt;br /&gt;int largestPrimeDivisor(int num) {&lt;br /&gt;int x = 0;&lt;br /&gt;for (x = num; x &gt; 0; –x) {&lt;br /&gt;if ((num % x) == 0) {&lt;br /&gt;if (isPrime(x)) {&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return x;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*&lt;br /&gt;* Start of execution&lt;br /&gt;*/&lt;br /&gt;int main(void) {&lt;br /&gt;int x = 0; //last prime factor&lt;br /&gt;cout &lt;&lt; “Enter a integer:” &lt;&lt; endl;&lt;br /&gt;for (x = 123456; !isPrime(x); x /= largestPrimeDivisor(x)) {&lt;br /&gt;cout &lt;&lt; largestPrimeDivisor(x) &lt;&lt; endl; //output each prime factor&lt;br /&gt;}&lt;br /&gt;cout &lt;&lt; x &lt;&lt; endl; //output last prime factor&lt;br /&gt;&lt;br /&gt;getchar();&lt;br /&gt;return 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;The only thing is that i have to find the largest prime factor of the number 600851475143…which is larger then any number type in C++..so i am a little stuck on how i am going to solve the problem..anyways..once i do find a solution i will post it and explain..for now i just thought i would show my neat little program :PThanks for the read&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-2402754348233275230?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/2402754348233275230/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/finding-prime-factors_26.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/2402754348233275230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/2402754348233275230'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/finding-prime-factors_26.html' title='Finding Prime Factors'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-1155535607429579519</id><published>2008-12-26T07:33:00.000-08:00</published><updated>2008-12-26T07:36:26.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>My Beautiful Discovery of Matrices</title><content type='html'>&lt;p&gt;Hi all, as of late i have been quite busy with school; unfortunately in my grade 12 math courses matrices are not gone over for more then one class or so, thus leaving one with little knowledge about their power and the immense amount of fun they are. So on my spare time i decided i would use good ol’ &lt;a href="http://wikipedia.org/"&gt;wikipedia&lt;/a&gt; to cure my craving for knowledge. After about 5 hours of straight reading learning and solving i decided that my matrices knowledge was pretty good…o and of course i was quite hungry. The time flew by while i was learning…i started working and the next time i looked at the clock it was 5 hours later :P…anyways i thought i would just show some cool things about what i learned:&lt;/p&gt; &lt;p&gt;Given: x + y + z = 6,     3x +  2y + z = 10,     x + 3y +2z = 13&lt;br /&gt;Which can for the following Matrix:&lt;code&gt;&lt;br /&gt;---------------&lt;br /&gt;1    1    1  |   6&lt;br /&gt;3    2    1  |  10&lt;br /&gt;1    3    2  |  13&lt;br /&gt;---------------&lt;/code&gt;&lt;br /&gt;Now, by using some &lt;a href="http://en.wikipedia.org/wiki/Elementary_matrix_transformations"&gt;elementary row operations&lt;/a&gt; we can simplify the matrix above to &lt;a href="http://en.wikipedia.org/wiki/Row-echelon_form"&gt;row echelon form&lt;/a&gt; by using &lt;a href="http://en.wikipedia.org/wiki/Gaussian_elimination"&gt;Gaussian elimination&lt;/a&gt;, after which the matrix would look like the following:&lt;code&gt;&lt;br /&gt;------------------&lt;br /&gt;1    1    1   |  6&lt;br /&gt;0    1    1/2 |  7/2&lt;br /&gt;0    0    3/2 |  9/2&lt;br /&gt;-----------------&lt;/code&gt;&lt;br /&gt;After which, we simplify to &lt;a href="http://en.wikipedia.org/wiki/Reduced_row_echelon_form"&gt;reduced row echelon form&lt;/a&gt; which will look like the following:&lt;code&gt;&lt;br /&gt;---------------&lt;br /&gt;1    0    0  |  1&lt;br /&gt;0    1 0  |  2&lt;br /&gt;0    0    1  |  3&lt;br /&gt;---------------&lt;/code&gt;&lt;br /&gt;Therefore we know our answers are: z = 3, y = 2, x = 1&lt;/p&gt; &lt;p&gt;Pretty neat eh &lt;img src="http://rekahsoft.org/wp-includes/images/smilies/icon_razz.gif" alt=":P" class="wp-smiley" /&gt; There are many more ways to solve linear equations any more methods of doing so. For more info see &lt;a href="http://en.wikipedia.org/wiki/System_of_linear_equations"&gt;this&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-1155535607429579519?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/1155535607429579519/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/my-beautiful-discovery-of-matrices.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/1155535607429579519'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/1155535607429579519'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/my-beautiful-discovery-of-matrices.html' title='My Beautiful Discovery of Matrices'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-2277195648344064459</id><published>2008-12-26T07:32:00.000-08:00</published><updated>2008-12-26T07:36:26.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Netbeans 6.2 Released</title><content type='html'>Just a quick post to let those of you who don’t know yet…Netbeans 6.0 is out :D I am going to try it tonight so expect screenshots and a review soon…I have been waiting for this release for quite some time :D&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-2277195648344064459?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/2277195648344064459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/netbeans-62-released.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/2277195648344064459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/2277195648344064459'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/netbeans-62-released.html' title='Netbeans 6.2 Released'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-4800196355145458758</id><published>2008-12-26T07:27:00.001-08:00</published><updated>2008-12-26T07:36:26.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Finding Prime Factors</title><content type='html'>&lt;p&gt;This week i have been moderlately busy with work and school. But on my spare time i have been working away at the problems on &lt;a href="http://projecteuler.net/"&gt;Project Euler&lt;/a&gt;…on my way to a solution i came up with a neat little program (which i wrote in C++) to find the prime factors of a number. Here it is:&lt;/p&gt; &lt;p&gt;&lt;code&gt;/*&lt;br /&gt;* Author: Collin Doering&lt;br /&gt;* Date Completed: April 3, 2008&lt;br /&gt;* Version: 1.0&lt;br /&gt;*/&lt;/code&gt;&lt;/p&gt; &lt;p&gt;#include &lt;iostream&gt;&lt;br /&gt;#include &lt;stdlib.h&gt;&lt;/p&gt; &lt;p&gt;using std::cout;&lt;br /&gt;using std::endl;&lt;br /&gt;using std::cin;&lt;/p&gt; &lt;p&gt;/*&lt;br /&gt;* Determines if a given parameter is prime&lt;br /&gt;*/&lt;br /&gt;bool isPrime(int num) {&lt;br /&gt;for (int x = 2; x != ((num / 2) + 1); ++x) {&lt;br /&gt;if ((num % x) == 0) {&lt;br /&gt;return false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return true;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;/*&lt;br /&gt;* Returns the largest prime divisor of a given number&lt;br /&gt;*/&lt;br /&gt;int largestPrimeDivisor(int num) {&lt;br /&gt;int x = 0;&lt;br /&gt;for (x = num; x &gt; 0; –x) {&lt;br /&gt;if ((num % x) == 0) {&lt;br /&gt;if (isPrime(x)) {&lt;br /&gt;break;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;return x;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;/*&lt;br /&gt;* Start of execution&lt;br /&gt;*/&lt;br /&gt;int main(void) {&lt;br /&gt;int x = 0; //last prime factor&lt;br /&gt;cout &lt;&lt; “Enter a integer:” &lt;&lt; endl;&lt;br /&gt;for (x = 123456; !isPrime(x); x /= largestPrimeDivisor(x)) {&lt;br /&gt;cout &lt;&lt; largestPrimeDivisor(x) &lt;&lt; endl; //output each prime factor&lt;br /&gt;}&lt;br /&gt;cout &lt;&lt;&gt; &lt;p&gt;getchar();&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/p&gt; &lt;p&gt;The only thing is that i have to find the largest prime factor of the number 600851475143…which is larger then any number type in C++..so i am a little stuck on how i am going to solve the problem..anyways..once i do find a solution i will post it and explain..for now i just thought i would show my neat little program :PThanks for the read&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-4800196355145458758?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/4800196355145458758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/finding-prime-factors.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4800196355145458758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4800196355145458758'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/finding-prime-factors.html' title='Finding Prime Factors'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-4602388196715333015</id><published>2008-12-26T07:27:00.000-08:00</published><updated>2008-12-26T07:36:26.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Ubuntu 8.04 Hardy Heron Released! And an interesting problem</title><content type='html'>Hi all, for those of you who do not already know, the new version of ubuntu (8.04) was released yesterday :D. I know today i will be doing my switch and will do a little write up. But for now you can read a wired review!&lt;br /&gt;&lt;br /&gt;Also two days ago i came up with an interesting problem. Here it is: Given a function f(x)=x^2 how many lines can intersect f(x) such that the area between the functions is 1? I have been working at a solution, but the answer may be infinite! If anyone knows a way to solve this problem let me know :P Anyways thanks for reading this short update :P and enjoy the new ubuntu 8.04!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-4602388196715333015?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/4602388196715333015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/ubuntu-804-hardy-heron-released-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4602388196715333015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4602388196715333015'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/ubuntu-804-hardy-heron-released-and.html' title='Ubuntu 8.04 Hardy Heron Released! And an interesting problem'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-5233342996064328235</id><published>2008-12-26T07:26:00.000-08:00</published><updated>2008-12-26T07:36:26.666-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Designing an Object</title><content type='html'>If there may exist an object with a method that is not appropriate at all points in the existence of the object, then the object or the method are flawed.&lt;br /&gt;&lt;br /&gt;A class encapsulating a compile phase in an IDE might have a blocking or non-blocking execute() method, plus a getErrorMessages(). There is an obvious protocol in using this class - instantiate, call execute(), call getErrorMessages(). It's not particularly hard to use, though it's also not hard to get wrong. Even if you decide not to help those users who don't bother to learn the protocol, it's worth thinking about whether that protocol should even exist, and what the alternative is.&lt;br /&gt;&lt;br /&gt;Many readers would probably, when prompted at least, make execute() return the error messages (or a Future for them), which solves the problem quite well. If you wouldn't, keep adding phases plus methods only appropriate for each phase, to one class that grows and grows, until you end up agreeing or changing career :) Anyway, in this case it's clear that the object was flawed by doing two things one after the other - executing the compile phase and delivering results.&lt;br /&gt;&lt;br /&gt;I bet most people could train themselves to spot this flaw and remove it, and if anyone only goes that far as a result of reading this post I'll be happy. But most people are probably quite happy with another flaw, java.util.Iterator.next(), which is only allowed when hasNext() returns true, in most Iterator implementations. But moving next() or hasNext() onto another object doesn't really work for Iterator. For a long time I was unhappy with Iterator, but didn't really have a solution, despite trying a couple of things out.&lt;br /&gt;&lt;br /&gt;The biggest use of Iterator directly in Java for many years was in what has since been replaced by a foreach loop. There are some detractors of, well, anything new, but generally the foreach loop was really well received by the Java community. It provides a higher-level interface than the Iterator gives us. We can write a lot of code using the foreach loop that would have been more verbose and awkward to get right using Iterator directly. But foreach is only one abstraction; there are some more that are higher still than it, and don't (but can) depend on Iterator. If you don't know what those abstractions are I really think you should take the time to learn about map, filter and reduce, and the more general but less usable parent of those, fold. But this isn't a post about those, so I'll return to the topic at hand.&lt;br /&gt;&lt;br /&gt;Iterator has been shown to be flawed, though flawed in a way that is acceptable to most of us and in a way we're used to, and in a way that seems non-trivial to solve (without knowing about map, filter, reduce and fold!). You might not be in a position to, or even want to, replace Iterator, but at least you should know not to copy its design, or bind yourself unnecessarily to it. You're now either armed with a simple way of deciding between two API designs, or you're about to tell me why I'm wrong.&lt;br /&gt;&lt;br /&gt;Happy coding.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-5233342996064328235?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/5233342996064328235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/designing-object.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/5233342996064328235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/5233342996064328235'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/designing-object.html' title='Designing an Object'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-3932342948441806566</id><published>2008-12-26T07:25:00.001-08:00</published><updated>2008-12-26T07:36:26.667-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Optional Values in Java</title><content type='html'>&lt;p&gt;If you take some Java code and write psuedocode representing it, you'll probably find that you don't bother with null checks and you don't bother with getters and setters. Sure, in psuedocode you're lazy, but it's more than that - null is usually wrong, so much so that intentional uses of null look like sloppy code. &lt;/p&gt;&lt;p&gt;In fact, if you're writing an API, you probably want to keep null out of your interactions with your users - you want to make sure they realise their mistake if they give you null and you don't want to give them null, lest they forget to check it. But there are actual times when you need some way of representing an optional value. &lt;/p&gt;&lt;p&gt;One particularly popular approach is to use sentinel values - let's say "" for Strings, Double.NaN for doubles, -1 for ints. Now everywhere you read the value you need to check for the sentinel, or be sure that not checking for it won't cause you problems. &lt;/p&gt;&lt;p&gt;Another approach is to use an empty list to represent no value, and a list of 1 element otherwise. Again you need to check whether the list is empty before getting the result out. &lt;/p&gt;&lt;p&gt; You could make a class that might hold a value, that has methods called  &lt;code&gt;hasValue()&lt;/code&gt; and &lt;code&gt;getValue()&lt;/code&gt;.  Again, requires a check. &lt;/p&gt;&lt;p&gt; In all these you need to remember to check before you get the value - not much of an improvement over using null directly. &lt;/p&gt;&lt;p&gt; If I categorise some code including null checks (no, not nunchucks), then we'll have something to toy with: &lt;/p&gt;&lt;p&gt; 1. foreach&lt;/p&gt;&lt;pre&gt;&lt;code&gt;if (x != null) {&lt;br /&gt;doStuffWith(x);&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;2. map&lt;pre&gt;&lt;code&gt;String s;&lt;br /&gt;if (x == null) {&lt;br /&gt;s = null;&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;s = x.toString();&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;3. fold&lt;pre&gt;&lt;code&gt;int length;&lt;br /&gt;if (s == null) {&lt;br /&gt;length = 0;&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;length = s.length();&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;Those were some strange names I gave to these categories! Let's tackle foreach first: Think of a value that might be null as a collection containing 0 or 1 elements - foreach would be a loop that runs 0 or 1 times to do something with the value. &lt;p&gt;map is a mapping from a domain containing null, to a co-domain containing null, - for example, mapping from rectangular coordinates to polar coordinates should probably yield null for a null input, if it doesn't throw an exception. &lt;/p&gt;&lt;p&gt;fold is a more manageable name for a 'catamorphism', which is a transformation that tends to yield a simpler value than the collection it's applied to (which seems the opposite of a fold in origami). In the case of a possibly-null value, the result is simpler because the result is (usually) a not null value. &lt;/p&gt;&lt;p&gt;Being responsible non-repetitive Java programmers, we'd like to encapsulate our possibly-null value plus the checks into an object with three methods, foreach, map and fold, rather than repeating them everywhere:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;interface Optional&lt;t&gt; {&lt;br /&gt;void foreach(Task&lt;t&gt; task);&lt;br /&gt;&lt;r&gt; R map(Conversion&lt;t,r&gt; conversion);&lt;br /&gt;&lt;r&gt; R fold(R theDefault, Conversion&lt;t,r&gt; conversion);&lt;br /&gt;}&lt;/r&gt;&lt;/r&gt;&lt;/code&gt;&lt;/pre&gt;(you might really want to make Optional Iterable so that you get Java's foreach loop, rather than providing foreach, as an implementation detail). &lt;p&gt;In the same way that java.util.Collections.sort can take a Comparator, each of these methods takes in an object that has a method that gets called if and when it needs to be.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;interface Task&lt;t&gt; { void execute(T value); }&lt;br /&gt;interface Conversion&lt;t,r&gt; { R convert(T value); }&lt;/code&gt;&lt;/pre&gt;Let's look at how we can convert the earlier null-using code to code using Optional. &lt;p&gt; 1. foreach&lt;/p&gt;&lt;pre&gt;&lt;code&gt;x.foreach(doStuff);&lt;/code&gt;&lt;/pre&gt;2. map&lt;pre&gt;&lt;code&gt;String s=x.map(toString);&lt;/code&gt;&lt;/pre&gt;3. fold&lt;pre&gt;&lt;code&gt;int length=x.fold(0,length);&lt;/code&gt;&lt;/pre&gt;Of course, the likelihood is that you're not lucky enough to already have &lt;code&gt;doStuff&lt;/code&gt; stored as a Task, &lt;code&gt;toString&lt;/code&gt; stored as a Conversion and &lt;code&gt;length&lt;/code&gt; stored as a Conversion, so perhaps you'd use an anonymous class to provide those. Unfortunately the syntax for anonymous classes bloats the code too much to be readable in a blog (or an IDE). &lt;p&gt;It would be useful to have good syntax for using foreach, map and fold in Java, so that there was at last an attractive alternative to null. For now we'll have to settle for attractive semantics rather than attractive syntax though. &lt;/p&gt;&lt;p&gt;I think this is beautiful because it provides a level of abstraction that gets you further from a potential source of bugs, makes your code more expressive about what it accepts, and lets you do in objects what otherwise would be repetitive. &lt;/p&gt;&lt;p&gt;A complete implementation of Optional is available in Functional Java under the name Option. There, Task is called E, and Conversion is called F. Option is most widely known as Maybe, from Haskell. &lt;/p&gt;&lt;p&gt; May your nulls rest in peace.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-3932342948441806566?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/3932342948441806566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/optional-values-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/3932342948441806566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/3932342948441806566'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/optional-values-in-java.html' title='Optional Values in Java'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-5023424726287307787</id><published>2008-12-26T07:25:00.000-08:00</published><updated>2008-12-26T07:36:26.667-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Implementing the Builder pattern in Java without repeating code</title><content type='html'>&lt;p&gt;When writing some Java wrappers around some CGI requests at work, I began with a normal implementation of the builder design pattern, but when I realised I was going to have to do this for about 50 CGI requests, and some of them were nested (CGI requests with query parameters to be sent on to a further CGI request on another machine), and that many of the parameters had interesting constraints, I realised that while the API might be fine, the implementation we were looking at, Josh Bloch's, encouraged repetition of logic. &lt;/p&gt;&lt;p&gt; Anyway, here's an example to get us started.  The problem: &lt;/p&gt;&lt;pre&gt;&lt;code&gt;Person person = new Person("John", "Jackson", 1979, 11, 10, "AC2193");&lt;/code&gt;&lt;/pre&gt; We wanted something more like:&lt;pre&gt;&lt;code&gt;Person person = new Person.Builder()&lt;br /&gt;   .forename("John")&lt;br /&gt;   .surname("Jackson")&lt;br /&gt;   .yearOfBirth(1979)&lt;br /&gt;   .monthOfBirth(11)&lt;br /&gt;   .dateOfBirth(10)&lt;br /&gt;   .nationalInsuranceNumber("AC2193").build();&lt;/code&gt;&lt;/pre&gt;To keep the code short, we'll use a simpler class as an example, a Person consisting of name and age. As you'll see, even this can be large enough to be interesting.&lt;pre&gt;&lt;code&gt;public class Person&lt;br /&gt;{&lt;br /&gt;   private final String name;&lt;br /&gt;   private final int age;&lt;br /&gt;&lt;br /&gt;   private Person(Builder builder)&lt;br /&gt;   {&lt;br /&gt;       this.builder = builder;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static class Builder&lt;br /&gt;   {&lt;br /&gt;       private String name;&lt;br /&gt;       private int age;&lt;br /&gt;&lt;br /&gt;       public Builder name(String name)&lt;br /&gt;       {&lt;br /&gt;           this.name = name;&lt;br /&gt;           return this;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public Builder age(int age)&lt;br /&gt;       {&lt;br /&gt;           this.age = age;&lt;br /&gt;           return this;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public Person build()&lt;br /&gt;       {&lt;br /&gt;           return new Person(this);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public String getName()&lt;br /&gt;   {&lt;br /&gt;       return name;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public int getAge()&lt;br /&gt;   {&lt;br /&gt;       return age;&lt;br /&gt;   }&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt;Even for 2 parameters, this is quite a lot of code, though thus far there isn't really any logic to be duplciated. Now let's look at a really simple constraint, that values cannot be set twice. &lt;p&gt; The most obvious way of trying this would be to have a boolean alongside each field in the builder, e.g.:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;private String name;&lt;br /&gt;private boolean nameAlreadySet;&lt;br /&gt;&lt;br /&gt;private int age;&lt;br /&gt;private boolean ageAlreadySet;&lt;/code&gt;&lt;/pre&gt;And then in the name(String) and age(int) methods in the Builder you would check the value of that boolean, and throw an IllegalStateException if the boolean had already been set. This is clearly a repetition, which can lead to copy-and-paste errors or just make things hard to change. &lt;p&gt;In object-orientated programming the usual way of handling this would be to package the field with its boolean in an object and call it, say, MaxOnce&lt;t&gt;. There is a good reason not to go down this path, though, it's difficult to chain MaxOnce with other such types, for example when we want BoundedInt, which prevents values outside a certain range, to work with MaxOnce. So we have a problem that the classes don't work together well. Time for another approach. &lt;/t&gt;&lt;/p&gt;&lt;p&gt;It would help if MaxOnce and BoundedInt were more like filters that data gets passed through (or not, if the data is invalid). Enter Parameter.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;private final Parameter&lt;string&gt; name = maxOnce("name", null);&lt;br /&gt;&lt;br /&gt;private final Parameter&lt;integer&gt; age = bound(maxOnce("age", 0), 0, Integer.MAX_VALUE);&lt;/code&gt;&lt;/pre&gt; Notice how bound and maxOnce are chained together in the age parameter It's easy to see how you might write other filters. Here's a largely useless example:&lt;pre&gt;&lt;code&gt;Parameter&lt;integer&gt; number = not(5, bound(maxOnce(0, "a number from one to ten, but not five"), 1, 10));&lt;/code&gt;&lt;/pre&gt;For a Parameter that has no default, it might be handy to store the value as an Option, rather than use null, or an empty String or some other sentinel. In another case we want to store the value as a TreeMap (for sparse arrays, mentioned later). So generally we'd like to be able to specify an input type and an output type for a Parameter.&lt;pre&gt;&lt;code&gt;private final Parameter&lt;string,&gt;&gt; name = maxOnce("name");&lt;br /&gt;&lt;br /&gt;private final Parameter&lt;integer,&gt;&gt; age = bound(maxOnce("age"), 0, Integer.MAX_VALUE);&lt;/code&gt;&lt;/pre&gt;Note that bound and maxOnce work together for the age parameter, as two filters. &lt;p&gt; In a few cases, the Parameters that we use are allowed to take multiple indexed values. They are effectively sparse arrays. The Parameter's input type is a Pair&lt;integer,&gt; and the output type is a TreeMap&lt;integer,&gt; - each incoming Pair gets added to the TreeMap.&lt;/p&gt;&lt;pre&gt;&lt;code&gt;private final Parameter&lt;pair&lt;integer,&gt;, TreeMap&lt;integer,&gt;&gt; = ...;&lt;/code&gt;&lt;/pre&gt;We can see that the Parameter is more a declaration than it is an actual value. Then it's quite handy that, actually, Parameter holds no mutable state - we store that in a Map&lt;parameter,&gt; but with slightly better types, wrapped up as a GenericBuilder, and we don't modify that Map, we copy it when we add values, like CopyOnWriteArrayList does in the Java libraries. &lt;p&gt; Here's the original Person class with a new implementation:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;public class Person&lt;br /&gt;{&lt;br /&gt;   private final GenericBuilder finalValues;&lt;br /&gt;&lt;br /&gt;   private static final Parameter&lt;string,&gt;&gt; nameParam = param("name", "The name of the person", Conversion.&lt;string&gt;identity());&lt;br /&gt;&lt;br /&gt;   private static final Parameter&lt;integer,&gt;&gt; ageParam = notNegative(param("age", "The age of the person", Conversion.stringToInt));&lt;br /&gt;&lt;br /&gt;   private Person(GenericBuilder finalValues)&lt;br /&gt;   {&lt;br /&gt;       if (realBuider.isDefault(nameParam) || realBuilder.isDefault(ageParam))&lt;br /&gt;           throw new IllegalStateException();&lt;br /&gt;&lt;br /&gt;       this.finalValues = finalValues;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public static final class Builder&lt;br /&gt;   {&lt;br /&gt;       private GenericBuilder realBuilder = new GenericBuilder();&lt;br /&gt;&lt;br /&gt;       public Builder name(String name)&lt;br /&gt;       {&lt;br /&gt;           realBuilder = realBuilder.with(nameParam, name);&lt;br /&gt;           return this;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public Builder age(int age)&lt;br /&gt;       {&lt;br /&gt;           realBuilder = realBuilder.with(ageParam, age);&lt;br /&gt;           return this;&lt;br /&gt;       }&lt;br /&gt;&lt;br /&gt;       public Person build()&lt;br /&gt;       {&lt;br /&gt;           return new Person(realBuilder);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;    &lt;br /&gt;   public String getName()&lt;br /&gt;   {&lt;br /&gt;       return finalValues.get(nameParam);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   public int getAge()&lt;br /&gt;   {&lt;br /&gt;       return finalValues.get(ageParam);&lt;br /&gt;   }&lt;br /&gt;}There are a couple of extra bells and whistles in the real code, such as building and parsing URLs containing the parameters. I have another post taking this one step further (using Parameters from code generation) in the pipeline.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-5023424726287307787?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/5023424726287307787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/implementing-builder-pattern-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/5023424726287307787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/5023424726287307787'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/implementing-builder-pattern-in-java.html' title='Implementing the Builder pattern in Java without repeating code'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-4422938135086652887</id><published>2008-12-26T07:24:00.000-08:00</published><updated>2008-12-26T07:36:26.667-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>My Scala Coding Style</title><content type='html'>&lt;p&gt;This was originally a posting to the scala-tools mailing list, in response to someone asking how to make the Eclipse plugin format using braces on the next line and spaces instead of tabs. &lt;/p&gt;&lt;p&gt; I used the braces-on-next-line rule, lining up the { to the previous line rule for years, and tabs and no spaces, for years.  I was happy with it.  I used an 80-character line length limit, which made coding in a text terminal easy, and tabs equivalent to 8 characters (though the actual tab width didn't really matter as I only used indentation to signify nesting depth, not to line up individual characters).  My code was very structured. &lt;/p&gt;&lt;p&gt; If you look at my blog's very early days, you will find a post somewhere saying to avoid anonymous classes in Java.  This is exactly the opposite of what I'd say now (now I'd say avoid Java :) ).  It dawned on me after a while that the reason I didn't like anonymous classes was that my coding style made them a real pain in the backside to use.  Specifically, if you have one anonymous class inside another with the above coding style, you end up splitting most lines of actual code. &lt;/p&gt;&lt;p&gt; Then I learned Lisp. &lt;/p&gt;&lt;p&gt; I realised that my overly structured Java code penalised me for nesting.  So nesting must be bad, or the coding style must be bad. &lt;/p&gt;&lt;p&gt; Most human languages are highly recursive - within one sentence you can set up phrases, talk about what would happen in the future, and discuss two possible futures or even possible pasts.  Only one language is known of that isn't highly recursive - the Piraha language.  In Piraha the culture discourages talking about the future, or any event that you haven't seen personally, or been told about by another.  A &lt;a href="http://edge.org/3rd_culture/everett07/everett07_index.html"&gt;researcher who lived with them&lt;/a&gt; and learned their language tried telling them about Jesus (yes, there are God-botherers in linguistics too).  One Piraha asked what Jesus looked like - and when the researcher said he didn't know, as Jesus lived 2,000 years ago, the Piraha wasn't interested anymore.  This actually caused the researcher to start questioning his own religion, but that's a little beside the point. &lt;/p&gt;&lt;p&gt; I imagine that if you asked a Piraha to design a computer programming language (or a suitable analogy to one - perhaps they wouldn't be interested in computers), I imagine it would be limited to a nesting level of 2, by virtue of a 25-space tab and an 80-character line limit.  And if they invented braces, I'm sure they would be lined up. &lt;/p&gt;&lt;p&gt; This has parallels in our society too.  The more fluent amongst us can happily deal with long sentences, discussing multiple futures.  The less fluent (perhaps speakers of a foreign language learning English) will generally prefer shorter sentences, discussing only the present. &lt;/p&gt;&lt;p&gt; In summary, pick a coding style that doesn't punish nesting, unless you want to make the language 'unnaturally' statement-orientated.  I have taken this to an extreme - I use one space for indentation, and never place opening OR closing parens on their own lines.  I think this is a direct result of learning Lisp, but it took a long time after learning Lisp for me to change. &lt;/p&gt;&lt;p&gt; Plus, silly Scala makes putting the brace on the next line fail to parse sometimes anyway.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-4422938135086652887?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/4422938135086652887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/my-scala-coding-style.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4422938135086652887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/4422938135086652887'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/my-scala-coding-style.html' title='My Scala Coding Style'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-2833448676073772125</id><published>2008-12-26T07:21:00.001-08:00</published><updated>2008-12-26T07:36:26.667-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Binary Reading and Writing Combinators for Java</title><content type='html'>&lt;a href="http://github.com/rickyclarkson/binary4j/tree/master/README.markdown"&gt;Binary4J&lt;/a&gt; is a combinator library for reading and writing arbitrary file and stream formats.  Comment on it here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-2833448676073772125?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/2833448676073772125/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/binary-reading-and-writing-combinators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/2833448676073772125'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/2833448676073772125'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/binary-reading-and-writing-combinators.html' title='Binary Reading and Writing Combinators for Java'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8588448388030930849.post-8830808959117899422</id><published>2008-12-26T07:21:00.000-08:00</published><updated>2008-12-26T07:36:26.668-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Uncategorized'/><title type='text'>Java Just Died (no closures in Java 7)</title><content type='html'>&lt;p&gt;So it's confirmed. Despite James Gosling wanting closures, despite 3 working closure prototype compilers, despite every other JVM language supporting closures, Java 7 will not have closures. &lt;/p&gt;&lt;pre&gt;&lt;code&gt;while (true)&lt;br /&gt;   print("new Runnable() { public void run() { ")&lt;/code&gt;&lt;/pre&gt;Frankly, I'm pissed off.  I'm sure Java dying will kill the JVM too, ultimately. &lt;p&gt;In the meantime, there's Scala. But the Java community will probably prefer Groovy, because it has learned from Java that types are hard. &lt;/p&gt;&lt;p&gt; (my source: &lt;a href="http://twitter.com/theplanetarium"&gt;http://twitter.com/theplanetarium&lt;/a&gt; via Ismael Juma)&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8588448388030930849-8830808959117899422?l=hitechblogs.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hitechblogs.blogspot.com/feeds/8830808959117899422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/java-just-died-no-closures-in-java-7.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/8830808959117899422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8588448388030930849/posts/default/8830808959117899422'/><link rel='alternate' type='text/html' href='http://hitechblogs.blogspot.com/2008/12/java-just-died-no-closures-in-java-7.html' title='Java Just Died (no closures in Java 7)'/><author><name>Thunder Rocks</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
