<?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-8963924286998980153</id><updated>2011-11-27T05:57:13.333+02:00</updated><category term='stacktrace'/><category term='tools'/><category term='java'/><category term='refactoring'/><category term='engineering'/><category term='bug'/><category term='thougts'/><category term='detect deadlock'/><category term='events'/><category term='cloud'/><category term='jvm'/><category term='concurrency'/><category term='Randy Pausch'/><category term='time'/><category term='motivation'/><category term='builder'/><category term='strange bug'/><category term='people'/><category term='problems'/><category term='frameworks'/><category term='python'/><category term='software engineering'/><category term='OOP'/><category term='jstack'/><category term='mandelbug'/><category term='cheatsheet'/><category term='testing'/><category term='deadlock'/><category term='OS'/><category term='heisenbug'/><title type='text'>0xABADBABE - computer science iside and outside</title><subtitle type='html'>Computer science and software engineering - everything that comes on my mind: languages, coding, algorithms, principles, paradigms, best practices, books, events, people.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-595297645603663141</id><published>2011-08-10T09:04:00.001+03:00</published><updated>2011-08-10T09:04:23.901+03:00</updated><title type='text'>Bay area game and app development meetup</title><content type='html'>Attended huge game development and mobile meetup at google office. Silicon Valley is definitely a paradise for game startups.&lt;br /&gt;Tens of panelists, hundreds of demo tables and about 400 people - brilliant opportunities for game entrepreneurs. Wired magazine, IGN.com, 148apps.com representatives answered the most burning questions in startups fundraising, management, communication sharing their success stories with community. Variety of games, platforms and API were presented. Among technology trends the latest and the most promising is HTML.&lt;br /&gt;&lt;br /&gt;&lt;a href='http://photo.blogpressapp.com/show_photo.php?p=11/08/09/5599.jpg'&gt;&lt;img src='http://photo.blogpressapp.com/photos/11/08/09/s_5599.jpg' border='0' width='320' height='320' align='right' style='margin:5px'&gt;&lt;/a&gt;&lt;br /&gt;So many developers in a limited space!&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a href='http://photo.blogpressapp.com/show_photo.php?p=11/08/09/5600.jpg'&gt;&lt;img src='http://photo.blogpressapp.com/photos/11/08/09/s_5600.jpg' border='0' width='320' height='320' style='margin:5px'&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;Endless demo tables.&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a href='http://photo.blogpressapp.com/show_photo.php?p=11/08/09/5601.jpg'&gt;&lt;img src='http://photo.blogpressapp.com/photos/11/08/09/s_5601.jpg' border='0' width='210' height='281' style='margin:5px'&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;Really nice concept of app marketing using QR codes, the only one from all the members. The bar code directs to app store, saving plenty of time spend on typing app name.&lt;br /&gt;&lt;p class='blogpress_location'&gt;Location:&lt;a href='http://maps.google.com/maps?q=Mountain%20View,%20CA&amp;z=10'&gt;Mountain View, CA&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/8963924286998980153-595297645603663141?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/595297645603663141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/08/bay-area-game-and-app-development.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/595297645603663141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/595297645603663141'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/08/bay-area-game-and-app-development.html' title='Bay area game and app development meetup'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-7113460437950937725</id><published>2011-06-22T06:33:00.001+03:00</published><updated>2011-06-22T06:33:59.395+03:00</updated><title type='text'>GEO search and web cams</title><content type='html'>Attended GEO search and web cams meet up hosted in Google.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href='http://photo.blogpressapp.com/show_photo.php?p=11/06/21/6344.jpg'&gt;&lt;img src='http://photo.blogpressapp.com/photos/11/06/21/s_6344.jpg' border='0' width='200' height='200' align='right' style='margin:5px'&gt;&lt;/a&gt;&lt;br /&gt;The first presenter was Tyler Bell talking about Search in the problem, hight level industry overview. Moreover he did great problems highlight of GEO search domain. One of the most burning problem is multiple electronic representation of the same entity.&lt;br /&gt;I raised the most burning topic for me - visual search, augmented reality and it's connection with human cognitive being. In Tyler's vision GEO application are constantly evolving form third person to first person.&lt;br /&gt;&lt;br /&gt;Second speaker, Trey Smith from NASA Ames Intelligent Robotics Group shared interesting appliance of GEO cams: Sharing Disaster Information with Mobile Devices. The basic of idea is to use crowd sourcing model to report disasters information, including coverage, damage reporte, people involved via GPS and media content data.&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a href='http://photo.blogpressapp.com/show_photo.php?p=11/06/21/6345.jpg'&gt;&lt;img src='http://photo.blogpressapp.com/photos/11/06/21/s_6345.jpg' border='0' width='320' height='320' style='margin:5px'&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;p class='blogpress_location'&gt;Location:&lt;a href='http://maps.google.com/maps?q=1950%20Charleston%20Rd,Mountain%20View,United%20States%4037.422170%2C-122.087744&amp;z=10'&gt;1950 Charleston Rd,Mountain View,United States&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/8963924286998980153-7113460437950937725?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/7113460437950937725/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/06/geo-search-and-web-cams.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7113460437950937725'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7113460437950937725'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/06/geo-search-and-web-cams.html' title='GEO search and web cams'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-5918330492383394039</id><published>2011-06-16T05:52:00.002+03:00</published><updated>2011-08-02T00:06:21.505+03:00</updated><title type='text'>Linkedin android demos meetup</title><content type='html'>Today I attended interesting startup android demo event in Linkedin office, Mountain View.&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;a href='http://photo.blogpressapp.com/show_photo.php?p=11/06/15/4429.jpg'&gt;&lt;img src='http://photo.blogpressapp.com/photos/11/06/15/s_4429.jpg' border='0' width='320' height='320' style='margin:5px'&gt;&lt;/a&gt;&lt;/center&gt;&lt;br /&gt;The event several session with 3 five minutes demo in each followed by feedback from investors. This is great opportunity for startups to market their apps for free.&lt;br /&gt;&lt;br /&gt;Among the most interesting app there were:&lt;br /&gt;&lt;br /&gt;Ninja News Reader - android app which fetch new from different sources based on friends from social networks.&lt;br /&gt;&lt;br /&gt;ThroughTwo - an app for the content sharing via simple phone calls.  Different activities on map like photo, drawing, location. Really new and creative idea.&lt;br /&gt;&lt;br /&gt;Recipes app - handy app to manage cooking  recipes.&lt;br /&gt;Guide book - application which helps to create traveling schedule with maps and other event information provided from event organizers.&lt;br /&gt;&lt;br /&gt;MessageEase - innovative way of text entering on IOS in 10 button keyboard, and has a lot of value because swipe is not released on IPhone.&lt;br /&gt;&lt;br /&gt;ParkMeter - handy app that help to park car, tracking location, picture, parking time.&lt;br /&gt;&lt;br /&gt;The great though was mentioned that productivity apps are great but adding one more organizers doesn't make your organized, which should be considered by entrepreneurs. Another great thing mentioned by investors is tendency of simplification of user interface, everything became consumer oriented.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-5918330492383394039?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/5918330492383394039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/06/linked-in-android-demos-meet-up.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/5918330492383394039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/5918330492383394039'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/06/linked-in-android-demos-meet-up.html' title='Linkedin android demos meetup'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-8299430161568590894</id><published>2011-04-22T23:01:00.001+03:00</published><updated>2011-04-28T19:20:10.652+03:00</updated><title type='text'>5 little things you should know about regexp</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;1. Groups&lt;br /&gt;I discovered this amazing feature not long time ago.&lt;br /&gt;A &lt;span class="exd_v"&gt;group&lt;/span&gt; is a pair of parentheses used to group subpatterns. For example, &lt;span class="exd_c"&gt;h(a|i)t&lt;/span&gt; matches &lt;span class="exd_c"&gt;hat&lt;/span&gt; or &lt;span class="exd_c"&gt;hit&lt;/span&gt;.  A group also captures the matching text within the parentheses. For example,    &lt;br /&gt;&lt;pre class="exd_code_body"&gt;(a(b*))+(c*)&lt;/pre&gt;&lt;pre class="exd_code_body"&gt;regex.group(1) : (a(b*))&lt;br /&gt;regex.group(2): (b*)&lt;br /&gt;regex.group(3): (c*)&lt;/pre&gt;&lt;pre class="exd_code_body"&gt;regex.group(0) - whole expression&lt;/pre&gt;&lt;br /&gt;2. Comment - great thing which unfortunately is missed in Java implementation. Python and Perl rocks!&lt;br /&gt;Roman date example, Python: &lt;br /&gt;&lt;pre class="screen"&gt;&lt;tt class="prompt"&gt;  &lt;/tt&gt;&lt;span class="userinput"&gt;pattern = &lt;span class="pystring"&gt;"""&lt;br /&gt;    ^                   # beginning of string&lt;br /&gt;    M{0,4}              # thousands - 0 to 4 M's&lt;br /&gt;    (CM|CD|D?C{0,3})    # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 C's),&lt;br /&gt;                        #            or 500-800 (D, followed by 0 to 3 C's)&lt;br /&gt;    (XC|XL|L?X{0,3})    # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 X's),&lt;br /&gt;                        #        or 50-80 (L, followed by 0 to 3 X's)&lt;br /&gt;    (IX|IV|V?I{0,3})    # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 I's),&lt;br /&gt;                        #        or 5-8 (V, followed by 0 to 3 I's)&lt;br /&gt;    $                   # end of string&lt;br /&gt;    """&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;3. Don't reinvent bicycle - use existent one. There are pleanty of great constructions which represent digits, words, beginning and end of line, learn and use this idioms. There is great library in Perl &lt;span class="tl"&gt;&lt;/span&gt;&lt;i&gt; Regexp&lt;/i&gt;::&lt;i&gt;Common&lt;/i&gt;&lt;br /&gt;which has a lot of useful shortcuts for dates, phones, etc. In java SimpleDateFormat does something similar but in a very limited context.&lt;br /&gt;&lt;br /&gt;4. Quantifieres - use carefully. Is not easy to understand all these concept of greedy, possesive and reluctant quantifiers.&lt;br /&gt;&lt;br /&gt;5. Test. Play as much with your regexp as you can before going to prod. To lazy to write unit tests?&lt;br /&gt;- No problem. There is an amazing website &lt;a href="http://regexplib.com/"&gt;regexplib&lt;/a&gt;, where you could play with it without any language and IDE.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-8299430161568590894?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/8299430161568590894/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/04/5-little-things-you-should-know-about.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8299430161568590894'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8299430161568590894'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/04/5-little-things-you-should-know-about.html' title='5 little things you should know about regexp'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-440633199404469702</id><published>2011-03-31T17:58:00.004+03:00</published><updated>2011-04-01T18:22:28.175+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='frameworks'/><category scheme='http://www.blogger.com/atom/ns#' term='cloud'/><title type='text'>Introduction to Pig, Map Reduce data processing framework</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Today I attended Hadoop meet up in General Assembly. The topic was Pig, large volume data processing framework, build on the top of Hadoop. It uses scripting  language like javascript for manipulating data and transform it into Map Reduce jobs on the top of Hadoop.&lt;br /&gt;Pig is a good way to learn &lt;a href="http://hadoop.apache.org/"&gt;Hadoop&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The framework is very easy to get in and is perfect for jump starters. Sometimes Map Reduce programming is too low level. Here Pig comes on stage Just download Cloudera VM or install &lt;a href="http://www.cloudera.com/blog/category/pig"&gt;rpm package&lt;/a&gt;. To can run it via Grunt Shell, Script file or Embedded program.&lt;br /&gt;Pig is another way to proceeds data, complimentary to &lt;a href="http://wiki.apache.org/hadoop/Hive"&gt;Hive&lt;/a&gt;, SQL style data processing framework. It gives more con toll then Hive and allows to process complex data flows.&lt;br /&gt;&lt;br /&gt;The example of pig script:&lt;br /&gt;&lt;br /&gt;&lt;pre class="JavaScript"&gt;#Use the PigStorage function to load the excite log file (excite.log or excite-small.log) into the “raw” bag as an array of records with the fields &lt;b&gt;user&lt;/b&gt;, &lt;b&gt;time&lt;/b&gt;, and &lt;b&gt;query&lt;/b&gt;.     &lt;br /&gt;raw = LOAD 'excite.log' USING PigStorage('\t') AS (user, time, query);&lt;br /&gt;&lt;br /&gt;# Call the NonURLDetector UDF to remove records if the query&lt;br /&gt;field is empty or a URL. &lt;br /&gt;clean1 = FILTER raw BY org.apache.pig.tutorial.NonURLDetector(query);&lt;br /&gt;&lt;br /&gt;# Call the ToLower UDF to change the query field to lowercase.&lt;br /&gt;clean2 = FOREACH clean1 GENERATE user, time, org.apache.pig.tutorial.ToLower(query) as query;&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Some useful pig resources:&lt;br /&gt;&lt;a href="http://wiki.apache.org/pig/PigTutorial"&gt;http://wiki.apache.org/pig/PigTutorial&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.cloudera.com/videos/introduction_to_pig"&gt;http://www.cloudera.com/videos/introduction_to_pig &lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogpress_location"&gt;Location:&lt;a href="http://maps.google.com/maps?q=East%2020%20st&amp;amp;Broadway,%20New%20York,United%20States%4040.740871%2C-74.003346&amp;amp;z=10"&gt;East 20 st&amp;amp;Broadway, New York,United States&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-440633199404469702?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/440633199404469702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/04/introduction-to-pig-map-reduce-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/440633199404469702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/440633199404469702'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/04/introduction-to-pig-map-reduce-data.html' title='Introduction to Pig, Map Reduce data processing framework'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-891526296801610141</id><published>2011-02-18T07:35:00.002+02:00</published><updated>2011-02-18T22:18:27.918+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='events'/><title type='text'>Graphs with Chris at Google tech talks</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;a href="http://3.bp.blogspot.com/-y48tA0qCNV8/TV7TurRAUZI/AAAAAAAAFD0/VPHBgRv1Kh8/s1600/hunch_graph.JPG" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="248" src="http://3.bp.blogspot.com/-y48tA0qCNV8/TV7TurRAUZI/AAAAAAAAFD0/VPHBgRv1Kh8/s320/hunch_graph.JPG" width="320" /&gt;&lt;/a&gt;Yesterday I attended interesting meetup Chris Dixon, Hunch cofounder. Chris gave amazing introduction to graph theory connecting science theory with real world projects.&lt;br /&gt;&lt;br /&gt;He started with illustration of undirected and directed graphs - on such giants as twitter and Facebook. Moreover he gave an amazing averages for twitter and Facebook exposed in curves and trends:&lt;br /&gt;- average user ages&lt;br /&gt;- likes, friends, followers per user &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Why do we care about graphs? It's a good question. The real world usage include such an areas as marketing and defense.&lt;br /&gt;&lt;br /&gt;Definitely we started with Google in graphs: Words and documents are nodes, PageRank: links are direct graphs.&lt;br /&gt;&lt;br /&gt;The interesting problem of finding clusters within existing graphs was illustrated for dating websites:&lt;br /&gt;eHarmony, match.com, JDate.com&lt;br /&gt;&lt;br /&gt;The most interesting part of presentation was principle of social networks decaying, based on two laws:&lt;br /&gt;Metcalfe's Law. Network value ~ (nodes)^2&lt;br /&gt;Newcomers with less connections join the network graph gets more benefits then social giants with many connections&lt;br /&gt;&lt;br /&gt;Then we moved to tastes graph and Chris child: Hunch - global taste engine based on graphs and social networks.&lt;br /&gt;&lt;br /&gt;Moreover we touched some technical aspects of storing and processing graphs. It's not so easy to process graphs in parallel, using Map Reduce, so notch uses super computers.&lt;br /&gt;&lt;br /&gt;Chris Dixon CEO, Hunch cofounder, investor&lt;br /&gt;Matt Gattis CTO, Co-founder Hunch&lt;br /&gt;&lt;br /&gt;&lt;div class="blogpress_location"&gt;Location:&lt;a href="http://maps.google.com/maps?q=Google,%20111%208th%20ave,%20New%20York,%20NY%4040.740878%2C-74.006478&amp;amp;z=10"&gt;Google, 111 8th ave, New York, NY&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-891526296801610141?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/891526296801610141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/02/graphs-with-chris-at-google-tech-talks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/891526296801610141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/891526296801610141'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/02/graphs-with-chris-at-google-tech-talks.html' title='Graphs with Chris at Google tech talks'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-y48tA0qCNV8/TV7TurRAUZI/AAAAAAAAFD0/VPHBgRv1Kh8/s72-c/hunch_graph.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-8481093188022120579</id><published>2011-02-11T08:21:00.002+02:00</published><updated>2011-02-13T01:02:45.325+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='heisenbug'/><category scheme='http://www.blogger.com/atom/ns#' term='thougts'/><title type='text'>The code quality: Coupling and Cohesion</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="font-size: large;"&gt;I&lt;/span&gt; want to raise the topic of code quality. I'm always passionate about the quality no matters where it comes to things, food, programming or just life.&lt;br /&gt;Thinking about code in categories &lt;i&gt;good &lt;/i&gt;and &lt;i&gt;bad&lt;/i&gt; is not really constructive, we don't get a lot of benefits. Critisizing a code doesn't bring a lot of benefits, but It might bring a lot of problems. There is not good and bad code, there is &lt;b&gt;working &lt;/b&gt;code. Yesterday I met a guy on facebook which mentioned how stupid could be people making 500 errors in 1000 lines of code.&lt;br /&gt;Most of us, the developers, have families, pets, nice cars, friends, problems, deadlines, and we are not living in our code. We are different, with different level of education, background, experience. We are not writing ideal code, which sometimes could be ugly, stupid, unreliable, whatever. And what is ideal code?&lt;br /&gt;- It's like ideal wife. Is quite, obedient, doesn't spend to much money, is faithful to you and don't get in affairs behind you.&lt;br /&gt;Still think it's possible? ;) &lt;br /&gt;-Rethink it again.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thinking  in business there is working code. Thinking in quality there is a code which is flexible for business needs and goes in one foot with business. What is quality code?&lt;br /&gt;There is no simple definitions. But there are metrics, both numeric and non-numeric. Two of them, for object oriented code were developed by Sun Microsystems engineers: &lt;b&gt;coupling &lt;/b&gt;and &lt;b&gt;cohesion&lt;/b&gt;.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Coupling &lt;/span&gt;is the degree to which one class knows about another class. If  the only knowledge that class A has about class B, is what class B has  exposed through its interface, then class A and class B are said to be  loosely coupled…that's a good thing. If, on the other hand,  class A relies on parts of class B that are not part of class B's  interface, then the coupling between the classes is tighter…&lt;i&gt;not&lt;/i&gt;  a good thing. In other words, if A knows more than it should about the  way in which B was implemented, then A and B are tightly coupled.&lt;br /&gt;Coupling means that one class gets at the implementation of another class.&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;Driver campbell = new Driver();  &lt;br /&gt;Car ford = new Car("Ford", "red");  &lt;br /&gt;. . .  &lt;br /&gt;&lt;br /&gt;public class Driver  &lt;br /&gt;{  &lt;br /&gt;  Car myCar; &lt;br /&gt; &lt;br /&gt;  . . . .  &lt;br /&gt;&lt;br /&gt;  public void goFaster(int speed)  &lt;br /&gt;  {  &lt;br /&gt;    myCar.speed += speed;  &lt;br /&gt;  }  &lt;br /&gt;&lt;br /&gt;  . . . .  &lt;br /&gt;&lt;br /&gt;}&amp;nbsp;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The Car class has allowed access to its speed field and the Driver  class changes its value directly. This means other classes gain access  to the implementation of the Car class; any changes to that  implementation will "break" the Driver class. This is "tight coupling"  and tight coupling is A Bad Thing, because any changes to one class can  mean that other classes would have to be altered too.&lt;br /&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;To avoid tight couplingAll classes should have as small a public interface as possible.&lt;/li&gt;&lt;li&gt;All non-constant fields should have private access.&lt;/li&gt;&lt;li&gt;Any alterations to the values of fields should be via method calls.&lt;/li&gt;&lt;/ul&gt;The term &lt;span style="font-size: large;"&gt;&lt;i&gt;cohesion&lt;/i&gt; &lt;/span&gt;is used to indicate the degree to which a class  has a single, well-focused purpose. Keep in mind that cohesion is a  subjective concept. The more focused a class is, the higher its  cohesiveness—a good thing. The key benefit of high cohesion is that such  classes are typically much easier to maintain (and less frequently  changed) than classes with low cohesion. Another benefit of high  cohesion is that classes with a well-focused purpose tend to be more  reusable than other classes.  &lt;br /&gt;&lt;br /&gt;To get more about coupling and cohesion, read &lt;a href="http://www.amazon.com/SCJP-Certified-Programmer-Java-310-065/dp/0071591060/ref=sr_1_1?s=books&amp;amp;ie=UTF8&amp;amp;qid=1297404913&amp;amp;sr=1-1"&gt;SCJP study guide&lt;/a&gt; chapter 5.1.&lt;br /&gt;More over good definition and discussion around coupling and cohesion is on &lt;a href="http://www.c2.com/cgi/wiki?CouplingAndCohesion"&gt;www.c2.com&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-8481093188022120579?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/8481093188022120579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/02/code-quality-coupling-and-cohesion.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8481093188022120579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8481093188022120579'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/02/code-quality-coupling-and-cohesion.html' title='The code quality: Coupling and Cohesion'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-8216718333387760776</id><published>2011-02-04T05:24:00.004+02:00</published><updated>2011-02-07T18:24:47.070+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='events'/><title type='text'>Mobile apps NYC</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Today I've attended first this year mobile apps meetup in New York. Serko Artenian, the group organizer made an amazing overview of last year achievements in mobile industry. IPAD and Samsung galaxy were not forgotten as well. I raised a question about mobile devices battery life and it seems this is still one of the biggest pitfalls of the whole industry, I haven't seen smartphone which battery lasts at least five days of active usage.&lt;br /&gt;&lt;br /&gt;The first speaker was Paul Notzel started presented his newest mobile app which simulates US congress speaker, transforming his own voice - extremely funny. I was excited by his project textual healing: &lt;a href="http://txtualhealing.com/"&gt;txtualhealing.com&lt;/a&gt;. The main idea is to project SMS content on the walls T night time, cool isn't it?&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://www.txtualhealing.com/blog/wp-content/uploads/2010/07/71.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="240" src="http://www.txtualhealing.com/blog/wp-content/uploads/2010/07/71.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;If you're inside US and wanna try it SMS TO: 917.603.0141 ;)&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;The next presenter was Paul with Xtify.com, a great app which helps to create great relationships with your mobile customers, very handy for business.&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_hlzkxmofNck/TUvlXT53fyI/AAAAAAAAFDA/XRf8alMHd6U/s1600/IMAG1259.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="241" src="http://3.bp.blogspot.com/_hlzkxmofNck/TUvlXT53fyI/AAAAAAAAFDA/XRf8alMHd6U/s320/IMAG1259.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The evenent was hosted in HUGE design company in the most creative and comfortable office I've ever see (It's not a joke, google is not the first). Could you imagine bike racks just in your office or carpet-grass or a dog-speaker?&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_hlzkxmofNck/TUvk1BpX5qI/AAAAAAAAFC4/PL3yHAZ2oxg/s1600/IMAG1263.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="150" src="http://4.bp.blogspot.com/_hlzkxmofNck/TUvk1BpX5qI/AAAAAAAAFC4/PL3yHAZ2oxg/s200/IMAG1263.jpg" width="200" /&gt;&lt;/a&gt;&lt;a href="http://3.bp.blogspot.com/_hlzkxmofNck/TUvk4-f6nWI/AAAAAAAAFC8/H9BpluQ_t4Y/s1600/IMAG1252.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://3.bp.blogspot.com/_hlzkxmofNck/TUvk4-f6nWI/AAAAAAAAFC8/H9BpluQ_t4Y/s200/IMAG1252.jpg" style="cursor: move;" width="150" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This is my firs meet after long trip to Ukraine and I just realized how far we are, how big is technology Gap between East and West. Many thanks to Serko for organizing this event.&lt;br /&gt;&lt;br /&gt;&lt;div class="blogpress_location"&gt;Location:&lt;a href="http://maps.google.com/maps?q=Bridge%20St,Brooklyn,United%20States%4040.704198%2C-73.984770&amp;amp;z=10"&gt;Bridge St,Brooklyn,United States&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-8216718333387760776?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/8216718333387760776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/02/mobile-apps-nyc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8216718333387760776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8216718333387760776'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/02/mobile-apps-nyc.html' title='Mobile apps NYC'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_hlzkxmofNck/TUvlXT53fyI/AAAAAAAAFDA/XRf8alMHd6U/s72-c/IMAG1259.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-4224816884028315480</id><published>2011-01-25T17:01:00.005+02:00</published><updated>2011-02-07T18:33:13.514+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='problems'/><title type='text'>Birthay cake: think out of the box</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Back to my birthday. The most lovely birthday cake I've ever had:&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_hlzkxmofNck/TUdj3_Rz_jI/AAAAAAAAFCg/TN-4PCTaMNs/s1600/birth_cake.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="239" src="http://1.bp.blogspot.com/_hlzkxmofNck/TUdj3_Rz_jI/AAAAAAAAFCg/TN-4PCTaMNs/s320/birth_cake.JPG" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: large;"&gt;Without letting your knife leave the cake top, can you draw four straight lines through the following nine dots?&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;img alt="" height="136" src="http://www.psychologytoday.com/files/u275/9_dots_2.gif" width="204" /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Those who may not have come across this puzzle before might tend to approach it by joining up the dots as if they were located on the perimeter (boundary) of an imaginary square or flattened box. But this reading of the puzzle does not yield a solution, no matter how many times one tries to draw four straight lines without lifting the pencil. A dot is always left over. It is at this point where creative thinking comes into play: "What would happen if I extend one or more of the four lines beyond the box?" That hunch turns out, in fact, to be the relevant insight. One possible solution is as follows:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;One of the possible solutions is:&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://3.bp.blogspot.com/_hlzkxmofNck/TT30PVkUBAI/AAAAAAAAFBM/n2ncm2_Gwhs/s1600/postman_solution.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_hlzkxmofNck/TT30PVkUBAI/AAAAAAAAFBM/n2ncm2_Gwhs/s1600/postman_solution.gif" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-4224816884028315480?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/4224816884028315480/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2011/01/birthay-cake-think-out-of-box.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/4224816884028315480'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/4224816884028315480'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2011/01/birthay-cake-think-out-of-box.html' title='Birthay cake: think out of the box'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_hlzkxmofNck/TUdj3_Rz_jI/AAAAAAAAFCg/TN-4PCTaMNs/s72-c/birth_cake.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-1039936524063446188</id><published>2010-12-16T09:43:00.004+02:00</published><updated>2011-02-18T22:13:34.349+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='events'/><title type='text'>How to write Clean, Testable code. Google NYC meetup</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: right;"&gt;&lt;blockquote&gt;&lt;span style="font-size: large;"&gt;Testing is not like frosting&lt;/span&gt;&lt;/blockquote&gt;&lt;/div&gt;Just attended wonderful meet up in New York Google office dedicated testing. Extremely smart guy Miko, Google Engineer, gave a great talk summarizing the main concepts behind testing and TDD. Moreover he touched psychological aspects of testing, which are in my opinion even more important than technical. Everything in 30 slides, we all new these but never realize and never do. &lt;br /&gt;&lt;br /&gt;&lt;iframe allowfullscreen="" frameborder="0" height="349" src="http://www.youtube.com/embed/XcT4yYu_TTs?rel=0" title="YouTube video player" width="560"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Started from how to write hard testing code:&lt;br /&gt;- singletons and static methods (I've got some points for this)&lt;br /&gt;- put a lot of new operators&lt;br /&gt;- code complexity and violating of Demeter Law.&lt;br /&gt;...&lt;br /&gt;If you know how to create unreadable code you probably know how to fix it?&lt;br /&gt;&lt;br /&gt;Moreover he touched such a topic as creating tests from spec and BDD:&lt;br /&gt;&lt;pre class="brush: java"&gt;@Test public void itShouldCloseTheIncomingConnectionAlways()&lt;/pre&gt;&lt;br /&gt;I liked an amazing classifications of bugs into 3 categories as logical, wiring and rendering bugs. And finding super bug is just misunderstood of the concept.&lt;br /&gt;&lt;br /&gt;Just read the presentation: &lt;a href="https://docs.google.com/present/view?id=d449gch_277fc6wwc9s"&gt;How to write Clean, Testable code: Psychology of Testing&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Misko blog: is &lt;a href="http://misko.hevery.com/"&gt;misko.hevery.com&lt;/a&gt;&lt;br /&gt;And do attend NYC Google meetup, don't miss a chance to visit awesome office and great people&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-1039936524063446188?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/1039936524063446188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/12/testing-is-not-like-frosting-just.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/1039936524063446188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/1039936524063446188'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/12/testing-is-not-like-frosting-just.html' title='How to write Clean, Testable code. Google NYC meetup'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/XcT4yYu_TTs/default.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-5796455425998605946</id><published>2010-12-16T05:42:00.026+02:00</published><updated>2010-12-16T06:53:10.424+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><category scheme='http://www.blogger.com/atom/ns#' term='cheatsheet'/><title type='text'>WTF? Who owns my port?</title><content type='html'>&lt;pre&gt;&lt;span style="font-size: x-small;"&gt;&lt;span style="font-size: x-small;"&gt;java.net.BindException: &lt;b&gt;Address already in use&lt;/b&gt;: JVM_Bind &lt;/span&gt;&lt;null&gt;&lt;span style="font-size: x-small;"&gt;:&lt;b&gt;80&lt;/b&gt;&lt;br /&gt;   at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549)&lt;br /&gt;...at java.net.ServerSocket.&lt;/span&gt;&lt;init&gt;&lt;span style="font-size: x-small;"&gt;(ServerSocket.java:141)&lt;br /&gt;...at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538)&lt;br /&gt;... 12 more&lt;/span&gt;&lt;/init&gt;&lt;/null&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;Familiar situation? Someone is using our port, to find out who is this bad guy just execute the following command in a shell:&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt; &lt;td style="font-size: large; text-align: center;" width="50%"&gt;windows&lt;/td&gt; &lt;td style="font-size: large; text-align: center;" width="50%"&gt;linux&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt; &lt;td style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;b&gt;C:\Windows&amp;gt; netstat -an  *&lt;/b&gt;&lt;/td&gt;      &lt;td style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;b&gt;$ sudo netstat -anp | grep PORT_NUMBER&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;* Make sure that you run it as administrator on Windows.&lt;b&gt;&lt;span style="background-color: #f3f3f3; color: #274e13;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="background-color: #444444; color: #f3f3f3; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; | find "PORT_NUMBER"&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: #f3f3f3;"&gt; &lt;/span&gt;&lt;/b&gt;doesn't work because output for each item is 3 lines, sorry :(&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-5796455425998605946?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/5796455425998605946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/12/wtf-who-owns-my-port.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/5796455425998605946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/5796455425998605946'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/12/wtf-who-owns-my-port.html' title='WTF? Who owns my port?'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-2108731715003624535</id><published>2010-12-06T21:37:00.006+02:00</published><updated>2011-01-05T08:46:24.030+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='testing'/><category scheme='http://www.blogger.com/atom/ns#' term='OOP'/><category scheme='http://www.blogger.com/atom/ns#' term='refactoring'/><title type='text'>Tell, don't ask. Law of Demeter</title><content type='html'>Whenever you talk to a good, experienced programmer, they will tell you that "loosely coupled" classes are very important to good software design.The &lt;b&gt;Law of Demeter&lt;/b&gt; (&lt;b&gt;LoD&lt;/b&gt;) or &lt;b&gt;Principle of Least Knowledge&lt;/b&gt; is a design guideline for developing loosely coupled software, particularly object-oriented programs. &lt;br /&gt;&lt;br /&gt;Law of Demeter for functions requires that a method &lt;i&gt;M&lt;/i&gt; of an object &lt;i&gt;O&lt;/i&gt; may only invoke the methods of the following kinds of objects: &lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;i&gt;O&lt;/i&gt; itself&lt;/li&gt;&lt;li&gt;&lt;i&gt;M'&lt;/i&gt;s parameters&lt;/li&gt;&lt;li&gt;any objects created/instantiated within &lt;i&gt;M&lt;/i&gt;&lt;/li&gt;&lt;li&gt;&lt;i&gt;O'&lt;/i&gt;s direct component objects&lt;/li&gt;&lt;li&gt;a global variable, accessible by &lt;i&gt;O&lt;/i&gt;, in the scope of &lt;i&gt;M&lt;/i&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;h4&gt;Example&lt;/h4&gt;The following Java coded illustrated this law:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;public class LawOfDemeterInJava&lt;br /&gt;{&lt;br /&gt;  private Topping cheeseTopping;&lt;br /&gt;  &lt;br /&gt;  /**&lt;br /&gt;   * Good examples of following the Law of Demeter.&lt;br /&gt;   */&lt;br /&gt;  public void goodExamples(Pizza pizza)&lt;br /&gt;  {&lt;br /&gt;    Foo foo = new Foo();&lt;br /&gt;    &lt;br /&gt;    // (1) it's okay to call our own methods&lt;br /&gt;    doSomething();&lt;br /&gt;    &lt;br /&gt;    // (2) it's okay to call methods on objects passed in to our method&lt;br /&gt;    int price = pizza.getPrice();&lt;br /&gt;    &lt;br /&gt;    // (3) it's okay to call methods on any objects we create&lt;br /&gt;    cheeseTopping = new CheeseTopping();&lt;br /&gt;    float weight = cheeseTopping.getWeightUsed();&lt;br /&gt;    &lt;br /&gt;    // (4) any directly held component objects&lt;br /&gt;    foo.doBar&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void badExamples(Pizza pizza)&lt;br /&gt;  {&lt;br /&gt;    // (5) Not OK. We are calling coock() on Cheese object&lt;br /&gt;    cheeseTopping.getCheese().cook();&lt;br /&gt;&lt;br /&gt;    // (6) Not OK&lt;br /&gt;    Slice slice = pizza.getSlice();&lt;br /&gt;    slice.decorate()&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  private void doSomething()&lt;br /&gt;  {&lt;br /&gt;    // do something here ...&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4&gt;Impact on testing.&lt;/h4&gt;Following this law have a huge impact on your code testability. When It comes to unit tests you faces the problem of instantiating of dependencies on class under test (CUT). Whether you choose &lt;i&gt;mocks &lt;/i&gt;or &lt;i&gt;stubs &lt;/i&gt; (to be consistent with terminology refer to &lt;a href="http://en.wikipedia.org/wiki/Mock_object#Mocks.2C_fakes_and_stubs"&gt;Wikipedia&lt;/a&gt; or other developers source)to test you CUT, following Demeter laws significantly decrease amount of instantiation code you need to write for your tests.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-2108731715003624535?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/2108731715003624535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/12/tell-dont-ask-law-of-demeter.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/2108731715003624535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/2108731715003624535'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/12/tell-dont-ask-law-of-demeter.html' title='Tell, don&apos;t ask. Law of Demeter'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-7043128789545633613</id><published>2010-11-18T21:38:00.005+02:00</published><updated>2010-12-10T00:39:28.570+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><title type='text'>Stay linked being widows geek: symlinks</title><content type='html'>Last time I've been doing a lot of configurations stuff, which in mostly is in Windows environment. And I couldn't imagine handy application deployment without symbolic links. That's why I love linux.&lt;br /&gt;&lt;br /&gt;Fortunately Windows 7 allows us to create symlinks in linux style with &lt;b&gt;mklink &lt;/b&gt; command:&lt;br /&gt;&lt;br /&gt;C:\Foo&amp;gt;mklink java C:/app/openJDK&lt;br /&gt;Creates a symbolic link.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;MKLINK [[/D] | [/H] | [/J]] Link Target&lt;br /&gt;&lt;br /&gt;        /D      Creates a directory symbolic link.  Default is a file&lt;br /&gt;                symbolic link.&lt;br /&gt;        /H      Creates a hard link instead of a symbolic link.&lt;br /&gt;        /J      Creates a Directory Junction.&lt;br /&gt;        Link    specifies the new symbolic link name.&lt;br /&gt;        Target  specifies the path (relative or absolute) that the new link&lt;br /&gt;                refers to.&lt;br /&gt;&lt;/pre&gt;Feel like at &lt;b&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/home&lt;/span&gt;&lt;/b&gt;!&lt;br /&gt;&lt;br /&gt;You might need to run windows console as and administrator to do this!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-7043128789545633613?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/7043128789545633613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/11/stay-linked-being-widows-geek-symlinks.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7043128789545633613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7043128789545633613'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/11/stay-linked-being-widows-geek-symlinks.html' title='Stay linked being widows geek: symlinks'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-8285860476799654394</id><published>2010-11-04T22:23:00.002+02:00</published><updated>2010-11-04T22:38:01.521+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tools'/><category scheme='http://www.blogger.com/atom/ns#' term='OS'/><title type='text'>How to monitor file descriptor</title><content type='html'>&amp;nbsp; In Java development often I faced an issue with deleting files which was acquired by another processes. When you have 1 JVM, everything is fine, you can just kill it. In case of 20 Java processes things become complicated. &lt;br /&gt;In linux there is an amazing file descriptor monitoring tool &lt;b&gt;&lt;a href="http://linux.about.com/library/cmd/blcmdl1_fuser.htm"&gt;fuser&lt;/a&gt;&lt;/b&gt;, which return pid of process, which uses current file. As an alternative you can use &lt;b&gt;lsof &lt;/b&gt; which returns list of all open descriptors.&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#fuser foo.bar&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#lsof bar.baz | grep ...&lt;/div&gt;&lt;br /&gt;&amp;nbsp; In windows things are little bit complicated. One way is to install &lt;a href="http://www.cygwin.com/"&gt;cygwin&lt;/a&gt; and use the earlier mentioned approach. Another solution is &lt;b&gt;handle &lt;/b&gt;tool from sysinternals, which basically do the same thing as &lt;b&gt;fuser&lt;/b&gt;. You can download it from &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx"&gt;microsoft website.&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#handle -u&amp;nbsp; foo.bar&lt;/code&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-8285860476799654394?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/8285860476799654394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/11/how-to-monitor-file-descriptor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8285860476799654394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8285860476799654394'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/11/how-to-monitor-file-descriptor.html' title='How to monitor file descriptor'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-9219419982424437645</id><published>2010-04-09T15:54:00.001+03:00</published><updated>2010-12-16T09:57:23.007+02:00</updated><title type='text'>Sun tech days 2010 - впечатления</title><content type='html'>Свежие впечатления с всемирной конференции Sun Tech Days 2010 в Санкт Петербурге - java процветает. В первый день количество участников было просто коллосально. Все хотели увидеть Джеймса Гослинга, но он к сожалению не приехал по неизвестным причинам. Демонстрация технологических новинок была как всегда на высоте, поразила система распознавания лиц и виртуальная перчатка рисующая с JavaFX, продемонстрированная Анджелой. Безусловно Sun вкладывает очень много усилий в продвижении этой технологии. Если 2 года назад я относился скептически к JavaFX, то сейчас графические возможности сильно впечатляют и у нее все шансы занять лидирующие позиции.&lt;br /&gt;Среди докладов лучшими были доклады Саймон Риттер, с новыми улучшения в JDK 7. Его доклады поражают простотой изложения и одновременно содержательностю. По JavaFX были им были продемонстрированны впечатляющие примеры и рассказаны основные концепции. Также очень понравился Алексис с докладом по новшествам в J2EE 6.&lt;br /&gt;Мне удалось посетить 2 замечательных стенда с Java Sun Spot устройствами роботом и виртуальной перчаткой, которой рисовала Анжела на вступительном докладе и даже удалось попробовать ей поуправлять - очень занимательно.&lt;br /&gt;Из докладов по Solaris: после слияния Oracle ведет двойственную полити по отношению к OS, делая основну ставку на Solaris, известную теперь как Oracle Solaris 10, но также активно поддерживает Oracle Linux. Открыл для себя новые грани использования Dtrace, оказывается это очень просто, существую уже сотни готовых скриптов для типичных задач.&lt;br /&gt;Также побывал на стенде MySQL узнав много нового про MySQL ndb cluster, федерации и други новинки MySQL 5.5&lt;br /&gt;Очень много докладов было посвящено виртуализации, на одном из них Филип Торчинский популярно рассказал про типы виртуализации, стратегии, подробно затронув Solaris Zones. В этом сегменте политика Oracle сходна с ОС, Virtual Box - больше ориентирована для десктопа, Oracle VM - некая комплексная серверная виртуализация охватывающая все начиная от десктопа и заканчивая cloud и Solaris Zones, легковесная виртуализация с общим ядром. Узнал что такое телепортация в VirtualBox, temlates в Oracle VM&lt;br /&gt;&lt;br /&gt;В целом мероприятием очень доволен, побольше бы таких событий в сообществе разработчиков&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-9219419982424437645?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/9219419982424437645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/04/sun-tech-days-2010.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/9219419982424437645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/9219419982424437645'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/04/sun-tech-days-2010.html' title='Sun tech days 2010 - впечатления'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-7757171236378762153</id><published>2010-02-12T23:15:00.009+02:00</published><updated>2010-02-13T00:46:05.732+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrency'/><title type='text'>Semaphores</title><content type='html'>&lt;span style=";font-family:verdana;font-size:180%;"  &gt;S&lt;/span&gt;emaphore is:&lt;br /&gt;&lt;div style="float: right;"&gt;&lt;a onblur="try   {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://weeklysqueak.files.wordpress.com/2007/10/semaphore.jpg"&gt;&lt;img style="width: 237px; height: 261px;" src="http://weeklysqueak.files.wordpress.com/2007/10/semaphore.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;/div&gt; &lt;blockquote cite="http://en.wikipedia.org/wiki/Semaphore_(programming)"&gt;In computer science, a semaphore is a protected variable or abstract data type which constitutes a classic method of controlling access by several processes to a common resource in a parallel programming environment. A semaphore generally takes one of two forms: &lt;span style="font-weight: bold;"&gt;binary &lt;/span&gt;and &lt;span style="font-weight: bold;"&gt;counting&lt;/span&gt;. A binary semaphore is a simple "true/false" (locked/unlocked) flag that controls access to a single resource. A counting semaphore is a counter for a set of available resources. Either semaphore type may be employed to prevent a race condition.&lt;/blockquote&gt;&lt;br /&gt;&lt;div style="text-align: right;"&gt;&lt;span style="font-size:85%;"&gt;&lt;a href="http://http//en.wikipedia.org/wiki/Semaphore_%28programming%29"&gt;en.wikipedia.org&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Just to refresh some of my knowledge in concurrency let's see  how to implement it in java.&lt;br /&gt;We'll assume that we don't have &lt;span style="font-style: italic;"&gt;java.util.concurrent&lt;/span&gt; package, and try to use wait(), notify() primitives. After some facing some errors and pitfalls, brainstorming with my colleagues I've got the following solution:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;public class Semaphore {&lt;br /&gt;&lt;br /&gt;    private int i;&lt;br /&gt;&lt;br /&gt;    public Semaphore(int max) {&lt;br /&gt;        if (max &lt; 1)&lt;br /&gt;            throw new IllegalArgumentException("should be natural number");&lt;br /&gt;        this.i = max;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public synchronized void acquire() throws InterruptedException{&lt;br /&gt;        while (i == 0){&lt;br /&gt;            wait();&lt;br /&gt;        }&lt;br /&gt;        i--;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public synchronized void release() {&lt;br /&gt;        i++;&lt;br /&gt;        notify();&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;We use counter to track how much treads acquire resource. Current solution is very basic has some limitations:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;doesn't deal with tread interruption, which can cause threads stuck, in case where all threads are waiting and last one is interrupted&lt;br /&gt;&lt;/li&gt;&lt;li&gt;doesn't handle situation, when some tread will call redundant release() method, when no threads acquire semaphore&lt;/li&gt;&lt;li&gt;doesn't guarantee order in which tread will be released. It could be implements using queue data structure, like bounded buffer. &lt;/li&gt;&lt;li&gt;intensively uses synchronization&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;The most perfect 'educational' solution which I found is Doug's Lee &lt;a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/Semaphore.java"&gt;implementation&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Constructing semaphore with with counter 1, we'll got mutex, which have effect similar to lock in java, except reentrancy and allows to acquire and release it from different treads.&lt;br /&gt;&lt;pre&gt;Semaphore mutex = new Semaphore(1);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you decide to dive into Semaphores, it might be useful to read papers of its founder, Dijkstra (not for the beginners):&lt;br /&gt;&lt;a href="http://www.cs.utexas.edu/users/EWD/transcriptions/EWD01xx/EWD123.html"&gt;http://www.cs.utexas.edu/users/EWD/transcriptions/EWD01xx/EWD123.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Java 1.5 Semaphore implementation, which doesn't use wait/notify and synchronized:&lt;br /&gt;&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Semaphore.html"&gt;java.util.concurrent.Semaphore.java&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Book about semaphores and synchronization problems:&lt;br /&gt;&lt;a href="http://greenteapress.com/semaphores"&gt;http://greenteapress.com/semaphores&lt;/a&gt;&lt;br /&gt;Best book about concurrency in java: "&lt;a href="http://www.javaconcurrencyinpractice.com"&gt;Java Concurency in practice&lt;/a&gt;"&lt;br /&gt;&lt;br /&gt;An article about semaphore implementation:&lt;br /&gt;&lt;a href="http://www.javaworld.com/javaworld/javaqa/1999-11/02-qa-semaphore.html"&gt;http://www.javaworld.com/javaworld/javaqa/1999-11/02-qa-semaphore.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-7757171236378762153?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/7757171236378762153/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/02/semaphores.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7757171236378762153'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7757171236378762153'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/02/semaphores.html' title='Semaphores'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-6714747581358607454</id><published>2010-01-31T15:35:00.003+02:00</published><updated>2010-01-31T17:05:59.639+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='people'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='events'/><title type='text'>PyCamp впечатления</title><content type='html'>&lt;p&gt;Вчера посетил конференцию по Python, &lt;a href="http://pycamp.org.ua/"&gt;PyCamp&lt;/a&gt; в Киеве.&lt;br /&gt;Очень классная организация, приятно удивили наличие транслироваляции онлайн видео и twitter &lt;a href="http://twitter.com/#search?q=-RT%20pykyiv+OR%20pycamp"&gt;канал&lt;/a&gt;.&lt;br /&gt;&lt;p&gt;Среди участинков, были разработчики не только из Киева, а и из Питера, Омска, Запорожья.&lt;br /&gt;Меня очень впечатлили доклады по базам данных: &lt;a href="http://en.wikipedia.org/wiki/Redis_%28dbms%29"&gt;Redis&lt;/a&gt; и &lt;a href="http://code.google.com/appengine/docs/whatisgoogleappengine.html"&gt;App Engine&lt;/a&gt; store. Redis - революционная inmemory key-value DB, и как заявлено докладчиком, по производительности обгоняющая даже &lt;a href="http://en.wikipedia.org/wiki/Memcached"&gt;memcached&lt;/a&gt;. App Engine store - одно из 2х хранилищ Google App Engine (2-e memcached).  Стоит задуматься лишний раз, нужна ли реляционная модель?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Также очень понравились доклады про декораторы в Python (провел аналогию с AOP в Java), Расширение и встраивание Python и WebSockets в Twisted. Просто влюбился в новую среду разработки для Python - PyCharm от JetBrains. Количество фич просто поражает: поддержка рефакторинга, TDD, autocompletion - на выстоте, что весьма круто для динамически типизированного языка.  Всегда хотел попробовать IntelliJ IDEA в Java, но все не находил времени, и вот теперь представится возможность. До этого использовал IDLE в ubuntu ну и emacs, где кроме подсветки и базовой подсказки ничего нет.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Несмотря на то, что мои знания синтаксиса и библиотек Python на начальном уровне, большинство презентацию были для меня понятны. Хотелось бы чуть больше live demo, по каждой из тем. Демонстрация "живого" чата, реализующего протокол &lt;a href="http://www.websockets.org/"&gt;websockets&lt;/a&gt; и PyCharm просто завели зал.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Для себя хотелось бы попробовать поиграться с &lt;a href="http://www.djangoproject.com/"&gt;Django&lt;/a&gt; ну и конечно же посмотреть сетевую библиотеку&lt;a href="http://twistedmatrix.com/trac/wiki/TwistedProject"&gt;twisted&lt;/a&gt;. Познакомился со многими новыми технологиями, про которые раньше слышал только мельком. Также был приятно удивлен, узнав про такие проекты как &lt;a href="http://cloudmade.com/"&gt;CloudMade&lt;/a&gt; и &lt;a href="http://wishes.in.ua/"&gt;wishes.in.ua&lt;/a&gt;. Побольше бы таких мероприятий в сообществе киевских разработчиков.&lt;br /&gt;&lt;/p&gt;&lt;span style="font-size:115%;"&gt;Ну и конечно же огромное спасибо организаторам и докладчикам.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-6714747581358607454?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/6714747581358607454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/01/pycamp.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/6714747581358607454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/6714747581358607454'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/01/pycamp.html' title='PyCamp впечатления'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-7577228217980715697</id><published>2010-01-18T11:57:00.016+02:00</published><updated>2010-09-29T17:10:16.192+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='refactoring'/><category scheme='http://www.blogger.com/atom/ns#' term='builder'/><title type='text'>huge constructors - builder pattern</title><content type='html'>Some weeks ago working with tons legacy code I've found such an ugly classes (all names are changes):&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;public class Monster {&lt;br /&gt;&lt;br /&gt;private static final String code;&lt;br /&gt;private static final String userId;&lt;br /&gt;private static final double weight;&lt;br /&gt;private static final int money;&lt;br /&gt;private static final String name;&lt;br /&gt;private static final double height;&lt;br /&gt;private static final Date birth;&lt;br /&gt;private static final Date death;&lt;br /&gt;private static final String type;&lt;br /&gt;// extra 30 params&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;//construction:&lt;br /&gt;public Monster(String code, String userId, double weight, int money, String name,&lt;br /&gt;double height, Date birth, Date death, String type /* ... */){&lt;br /&gt;// ... fields assignment&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;Passing values to such constructor and guessing is a hell:&lt;br /&gt;&lt;pre class="brush: java" name="code"&gt;Monster mon = new Monster("XY1", "user555", 19.5, 2345, "weird_name", &lt;br /&gt;232, someDate, anotherDate, "animalType", /* ... */);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It is extremely hard to support such code, especially when you want to pass 28th parameter, getting lost in order and types. A good question is why do we need such a huge class, but that's another story (legacy code is legacy code).&lt;br /&gt;A good solution is to use &lt;b&gt;builder pattern&lt;/b&gt;, introduced by &lt;a href="http://developers.sun.com/learning/javaoneonline/2007/pdf/TS-2689.pdf"&gt;Joshua Bloch&lt;/a&gt; and mentioned in Design Pattern GoF book. &lt;br /&gt;&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The main idea is to replace huge constructor, with private, which takes builder.&lt;br /&gt;&lt;br /&gt;Construction of that odd class now looks pretty:&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;Monster mon = new Monster("weird_name").code("XY1").userID("user555")&lt;br /&gt;.weight(19.5).type("animal").build();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;and our class contain public static class and private constructor:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;public class Monster {&lt;br /&gt;&lt;br /&gt;// class fields&lt;br /&gt;&lt;br /&gt;public static class Builder(...){..}&lt;br /&gt;&lt;br /&gt;private Monster (Builder builder){..}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Main disadvantage over constructor is that you can forget some parameters, unless in constructors, where all parameters are controlled at compile time. But you can add custom validation in build() method. Another frustrating thing is that builder adds a lot of extra code to existent class. Code generation could really help here.&lt;br /&gt;Currently java IDEs do not support builder generation. I found &lt;a href="http://code.google.com/p/bpep/"&gt;great plugin&lt;/a&gt; for eclipse, which allows to do it in 1 click like generating getters and setters.&lt;br /&gt;&lt;br /&gt;As an alternative I wrote python script generateBuilder, which does the same from shell:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(0, 153, 0);font-family:courier new;" &gt;# ./generateBuilder.py com/foo/Bar.java &gt; com/foo/_Bar.java&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre readonly="true" class="brush: python" name="code" style="font-size:9px;"&gt;#!/bin/python&lt;br /&gt;import sys, re&lt;br /&gt;&lt;br /&gt;IDENT_SIZE=4&lt;br /&gt;&lt;br /&gt;def getFields(text):&lt;br /&gt;line PT = r"""&lt;br /&gt;(private)\s*(final)\s*          amodifier and final&lt;br /&gt;([a-zA-Z_]+\w*[a-zA-Z_.]+)\s*    #java type&lt;br /&gt;([a-zA-Z_]+\w*);   #java field name&lt;br /&gt;"""&lt;br /&gt;iter = re.finditer(linePT, text, re.VERBOSE)&lt;br /&gt;return dict([m.group(4), m(group.3) for m in iter)]&lt;br /&gt;&lt;br /&gt;def ident(times=1):&lt;br /&gt;return " " * IDENT_SIZE * times&lt;br /&gt;&lt;br /&gt;def generateClass(className, fields):&lt;br /&gt;str = ident() + "public static class Builder {\n\n"&lt;br /&gt;for fName in fields.keys():&lt;br /&gt;str += "\n" + ident(2) + "private %s %s;\n" % (fields[fName], fName)&lt;br /&gt;str += "\n" + ident(2) + "public Builder() {\n" + ident(2) + "}\n\n"&lt;br /&gt;for fName in fields.keys():&lt;br /&gt;str += ident(2) + "public Builder %s(%s %s){\n" % (fName, fields&lt;br /&gt;&lt;br /&gt;[fName], fName)&lt;br /&gt;str += ident(3) + "this.%s = %s;\n" % (fName, fName)&lt;br /&gt;str += ident(3) + "return this;\n"&lt;br /&gt;str += IDENT(2) + "}\n"&lt;br /&gt;str += ident(2) + "public %s build(){\n" % (className,)&lt;br /&gt;str += ident(3) + "return new %s(this);\n" % (className,)&lt;br /&gt;str += ident(2) + "}\n"&lt;br /&gt;str += ident() + "}\n\n"&lt;br /&gt;return str&lt;br /&gt;&lt;br /&gt;def generateConstructor(className, fields):&lt;br /&gt;str = ident() + "private %s(Builder builder){\n" % (className,)&lt;br /&gt;for fName in fields.keys():&lt;br /&gt;str += ident(2) + "this.%s = builder.%s;\n" % (fName, fName)&lt;br /&gt;str += ident() + "}";&lt;br /&gt;return str&lt;br /&gt;&lt;br /&gt;if __name__ == "__main__":&lt;br /&gt;if len(sys.argv) &lt;&gt; 2:&lt;br /&gt;print "usage: generateBuilder &lt;java file name&gt;"&lt;br /&gt;sys.exit(-1)&lt;br /&gt;fName = sys.argv[1]&lt;br /&gt;f = open(fName)&lt;br /&gt;fields = getFields(text)&lt;br /&gt;className = re.search(r'(\w+)\.java', fName).group(1)&lt;br /&gt;print generateClass(className, fields)&lt;br /&gt;print generateConstructor(className, fields)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-7577228217980715697?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/7577228217980715697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2010/01/huge-constructors.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7577228217980715697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7577228217980715697'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2010/01/huge-constructors.html' title='huge constructors - builder pattern'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-5529048257749659776</id><published>2009-12-10T22:14:00.005+02:00</published><updated>2009-12-10T22:32:26.032+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='motivation'/><category scheme='http://www.blogger.com/atom/ns#' term='thougts'/><title type='text'>J. Spolsky and developers test, Q11</title><content type='html'>Today during the lunch discussion I refered to one IT guru which motivated me as a developer on early stage of my career:&lt;br /&gt;His name is &lt;a href="http://en.wikipedia.org/wiki/Joel_Spolsky"&gt;Joel Spolsky&lt;/a&gt;, Microsoft product manager in the past, currently CEO of Fog Creek Software and creator on amazing developers resource stackoverflow.com.&lt;br /&gt;&lt;br /&gt;As for me one of his major contribution into dev community is Joel's &lt;a href="http://www.joelonsoftware.com/articles/fog0000000043.html"&gt;developers test&lt;/a&gt;.&lt;br /&gt;Being a student and working on my first project, I was inpired by Joel's ideas and promoted them to my project manager. He replied: "Just try make it 12 point". So I launched continuous integration server (Cruise Controll), atached build script with unit tests, and set up 2nd screen on my table to bootstrap my productivity. Everyone in my team was happy, and it was preety strong motivation for us.&lt;br /&gt;&lt;br /&gt;I want to touch Q 11(For me it's the most burning) which is about an interview:&lt;br /&gt;"&lt;strong&gt;Do new candidates write code during their interview?&lt;/strong&gt;". I absolutely agree with Mr. Spolsy on this point and there is no point to hire developer if you don't know how good he is in his primary reponsibility - writing code. And here is the main complication:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;most companies interviews candidate for the technical background only for one hour or so&lt;br /&gt;and they do not have time for writing the code.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;it's hard to find simple coding problem. What is good for 10 min quiz: reverting strings or writing simple web app?&lt;/li&gt;&lt;br /&gt;&lt;li&gt;it doesn't work for the Ukrainian market. Unfortunately most of developers in Ukraine (I'm not an exception ) do not write a lot of 'real' code. Typicaly they do integration, bug fixing, configuration, etc. So such simple coding problems like naive traversing trees, sorting, searching, filtering, even simple money calculations make a lot of surprise.&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-5529048257749659776?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/5529048257749659776/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2009/12/j-spolsky-and-developers-test-q11.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/5529048257749659776'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/5529048257749659776'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2009/12/j-spolsky-and-developers-test-q11.html' title='J. Spolsky and developers test, Q11'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-8054281523127353188</id><published>2009-12-10T17:33:00.004+02:00</published><updated>2010-01-31T20:25:31.600+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='concurrency'/><title type='text'>Object.wait() and spurious wakeup</title><content type='html'>Few month ago I was asked an interesting java question on interview.&lt;br /&gt;The question was something like:&lt;br /&gt;&lt;em&gt;&lt;strong&gt;"Why we need to wrap Object.wait() call in while cycle?"&lt;/strong&gt;&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;The answer you could find in Joshua Bloch book "Effective Java" 2nd edition, Item 69.&lt;br /&gt;&lt;strong&gt;Always use the wait loop idiom to invoke the wait method; never invoke it outside of a loop&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;One of the reason, stated by Joshua is that:&lt;br /&gt;The waiting thread could(rarely) wake up in the absence of a notify. This is known as a &lt;a href="http://en.wikipedia.org/wiki/Spurious_wakeup"&gt;spurious wakeup&lt;/a&gt; [Posix 11.4.3.6.1; JavaSE6].&lt;br /&gt;&lt;br /&gt;Browsing javadoc I noticed, that this issue was added to &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#wait(long)"&gt;javadoc &lt;/a&gt;since 1.5 version:&lt;br /&gt;&lt;br /&gt;Another reasons to use wait inside the loop are described in J. Block book or API, mentioned above&lt;br /&gt;&lt;br /&gt;&lt;pre class="brush: java"&gt;&lt;br /&gt;synchronized (obj) {&lt;br /&gt;  while (&lt;condition&gt;)&lt;br /&gt;    obj.wait(timeout);&lt;br /&gt;    ... // Perform action appropriate to condition&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-8054281523127353188?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/8054281523127353188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2009/12/objectwait-and-spurious-wakeup.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8054281523127353188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8054281523127353188'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2009/12/objectwait-and-spurious-wakeup.html' title='Object.wait() and spurious wakeup'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-8569414051257798427</id><published>2009-09-21T13:15:00.013+03:00</published><updated>2009-09-21T18:45:50.511+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='detect deadlock'/><category scheme='http://www.blogger.com/atom/ns#' term='deadlock'/><category scheme='http://www.blogger.com/atom/ns#' term='jstack'/><category scheme='http://www.blogger.com/atom/ns#' term='stacktrace'/><category scheme='http://www.blogger.com/atom/ns#' term='jvm'/><title type='text'>Detecting deadlocks in java</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_hlzkxmofNck/SrdT-8_tYXI/AAAAAAAABqE/-JhV3P_GtZc/s1600-h/deadlock_thumb.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 268px; height: 169px;" src="http://2.bp.blogspot.com/_hlzkxmofNck/SrdT-8_tYXI/AAAAAAAABqE/-JhV3P_GtZc/s320/deadlock_thumb.jpg" alt="" id="BLOGGER_PHOTO_ID_5383864220535054706" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Recently I faced the problem of deadlocks detection in java.&lt;br /&gt;From my experience I used &lt;a href="http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html"&gt;jconsole &lt;/a&gt;to connect to application server/container jvm and to print stack trace and to find waiting thread and method. Unfortunately sometimes occurs the situations when your jvm is started without JMX extension, necessary for jconsole. Imagine the situation when your live jvm instance is frozen and you think that deadlock is the reason. Since JMX is not started you can use jstack, nice utility from &lt;a href="http://java.sun.com/javase/6/docs/technotes/tools/#troubleshoot"&gt;jdk tools&lt;/a&gt;. You need to find out a pid of jvm:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;#jstack &lt;pid&gt;&lt;/pid&gt;&lt;/span&gt;&lt;pid of="" your="" jvm=""&gt;&lt;your&gt;your_app_pid&lt;br /&gt;&lt;br /&gt;The output will be like:&lt;br /&gt;&lt;/your&gt;&lt;/pid&gt;&lt;pid of="" your="" jvm=""&gt;&lt;br /&gt;&lt;/pid&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_hlzkxmofNck/SrdghY63EBI/AAAAAAAABqc/EEIoSbM2l0I/s1600-h/jstack.JPG"&gt;&lt;img style="cursor: pointer; width: 507px; height: 247px;" src="http://2.bp.blogspot.com/_hlzkxmofNck/SrdghY63EBI/AAAAAAAABqc/EEIoSbM2l0I/s400/jstack.JPG" alt="" id="BLOGGER_PHOTO_ID_5383878006285996050" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;pid of="" your="" jvm=""&gt;   If you have access to shell with jvm another alternative is to press &lt;span style="font-style: italic;"&gt;&lt;ctrl+break&gt;&lt;/ctrl+break&gt;&lt;/span&gt; and stack trace will be printed in the shell. But be careful, if your jvm was started with -Xrs (reduce signal usage) process will be stopped.&lt;br /&gt;In case  you run your jvm on solaris you can use &lt;a href="http://en.wikipedia.org/wiki/Dtrace"&gt;dtrace &lt;/a&gt;to find deadlock.  Your java  should be started with &lt;/pid&gt;&lt;span style="font-style: italic; color: rgb(51, 102, 255);"&gt;-XX:+ExtendedDTraceProbes  &lt;/span&gt;option.&lt;br /&gt;&lt;pid of="" your="" jvm=""&gt;&lt;br /&gt;&lt;/pid&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-8569414051257798427?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/8569414051257798427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2009/09/detecting-deadlocks-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8569414051257798427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/8569414051257798427'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2009/09/detecting-deadlocks-in-java.html' title='Detecting deadlocks in java'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_hlzkxmofNck/SrdT-8_tYXI/AAAAAAAABqE/-JhV3P_GtZc/s72-c/deadlock_thumb.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-7950676632946742728</id><published>2009-01-14T18:50:00.005+02:00</published><updated>2009-01-21T17:58:08.499+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='heisenbug'/><category scheme='http://www.blogger.com/atom/ns#' term='bug'/><category scheme='http://www.blogger.com/atom/ns#' term='mandelbug'/><category scheme='http://www.blogger.com/atom/ns#' term='strange bug'/><title type='text'>Bugs are not bucks, sometimes it is hard to catch them</title><content type='html'>Twenty minutes ago I was building an application with maven on my linux virtual machine image and I've cached quite strange exception:&lt;br /&gt;java.io.IOException: read only file system, however mount -l gives all FS mounted correctly, manualy I could create regular file and directory in any location and all files were with &lt;span style="font-weight: bold;"&gt;rw&lt;/span&gt; permission for current user. I've experienced the similar bug 2 moth ago, but nobody could reproduce it again (rebooting and remounting gave nothing).&lt;br /&gt;After reboot maven build went OK, and the bug magically disappeared.&lt;br /&gt;&lt;br /&gt;Such king of bugs are are united in special category as &lt;a href="http://en.wikipedia.org/wiki/Unusual_software_bug"&gt;unusual software bugs&lt;/a&gt;. Seems that my bug is &lt;span style="font-weight: bold; font-style: italic;"&gt;Mandelbug&lt;/span&gt;, the bug which behavior is so complex, that it seems like chaotic.&lt;br /&gt;Other kind of such bugs are&lt;span class="mw-headline"&gt; &lt;span style="font-style: italic;"&gt;Heisenbug&lt;/span&gt;, &lt;/span&gt;&lt;span style="font-style: italic;"&gt;Bohrbug&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;S&lt;/span&gt;&lt;span style="font-style: italic;" class="mw-headline"&gt;chroedinbug&lt;/span&gt; etc and their can bring a real frustration to sofware developers and QA.&lt;br /&gt;&lt;br /&gt;Have you experienced such kind of bugs?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-7950676632946742728?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/7950676632946742728/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2009/01/bugs-are-not-bucks-sometimes-it-is-hard.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7950676632946742728'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/7950676632946742728'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2009/01/bugs-are-not-bucks-sometimes-it-is-hard.html' title='Bugs are not bucks, sometimes it is hard to catch them'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8963924286998980153.post-1114601015997903110</id><published>2008-12-30T18:41:00.000+02:00</published><updated>2008-12-30T20:07:16.980+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='engineering'/><category scheme='http://www.blogger.com/atom/ns#' term='time'/><category scheme='http://www.blogger.com/atom/ns#' term='software engineering'/><category scheme='http://www.blogger.com/atom/ns#' term='Randy Pausch'/><title type='text'>Engineering is ...</title><content type='html'>&lt;blockquote&gt;&lt;span style="font-size:130%;"&gt;    Engineering isn't about perfect solutions; it's about doing the best you can with limited resources. &lt;/span&gt;&lt;/blockquote&gt;&lt;p style="margin-bottom: 0in;" align="right"&gt;Randy Pausch, Computer Science Professor,&lt;br /&gt;Carnegie Mellon&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;     I found this amazing words in the &lt;a href="http://www.amazon.com/Last-Lecture-Randy-Pausch/dp/1401323251"&gt;"The last lecture"&lt;/a&gt; book. This book is not about software engineering, it's about life. Every day for the last week I wake up with this concept. Sometimes there are moments when you need to stop and ask yourself a couple of questions like "Are you going the right way? Is this solution optimal? Does you code looks fine? Are you the best in your field?".&lt;br /&gt;    Your team, knowledge, languages&amp;amp;tools, PCs, power, CPU, memory and even your salary - everything is limited. However, the most limited resource is time. Doing the best in a finite time - that is an engineering. What kind of application to create, what language or framework to study, what OS&amp;amp;tools&amp;amp; to use - that is the most challenging problems in my career of software engineer.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8963924286998980153-1114601015997903110?l=blog.abadbabe.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.abadbabe.com/feeds/1114601015997903110/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.abadbabe.com/2008/12/engineering-is.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/1114601015997903110'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8963924286998980153/posts/default/1114601015997903110'/><link rel='alternate' type='text/html' href='http://blog.abadbabe.com/2008/12/engineering-is.html' title='Engineering is ...'/><author><name>Vladimir</name><uri>http://www.blogger.com/profile/10275275069172624080</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='http://1.bp.blogspot.com/_hlzkxmofNck/TPPZzBnrXvI/AAAAAAAAE9s/aV90xsf6PKs/S220/avatar.jpg'/></author><thr:total>1</thr:total></entry></feed>
