<?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-1467120539710232930</id><updated>2012-01-31T02:39:46.624+06:00</updated><category term='C++'/><category term='Shell'/><category term='Coding Style'/><category term='Versioning'/><category term='Software Review'/><category term='TortoiseCVS'/><category term='PostgreSQL'/><category term='Software Engineering'/><category term='MFC'/><category term='Project Management'/><category term='j2se'/><category term='Linux'/><category term='গল্প'/><category term='CVS'/><category term='Apache'/><category term='JavaScript'/><category term='book'/><category term='SQA'/><category term='India'/><category term='Ajax'/><title type='text'>Off-notes off the Mind</title><subtitle type='html'>Sharing some of my thoughts with you !</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.amanpages.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>25</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-530248223829134399</id><published>2008-01-21T19:48:00.000+06:00</published><updated>2008-01-22T11:16:46.014+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Engineering'/><category scheme='http://www.blogger.com/atom/ns#' term='Project Management'/><title type='text'>The role of a team lead in agile environment</title><content type='html'>I think pure waterfall model is impractical. It is as impractical as the pendulum in  pure physics where the thread is of no weight and no friction exists. And that is what you can never have in the lab.&lt;br /&gt;&lt;br /&gt;We, the software developers know there is always 'friction' and nothing is 'massless'. The ever changing nature of the human mind and limitation to perceive what it needs results in modification in the requirement. That why we are agile, we don't just fall.&lt;br /&gt;&lt;br /&gt;Now, trust and sense of responsibility are at the base of agile methodologies among some other. Here, every member in a team is expected to be self driven and self motivated. They are given task and set free to accomplish that at their own choice. Formal managing, let alone macro managing, hardly gets its place. Then what would the team-lead do ? Should s/he dive into developing? or is there indeed any need of a team leader?&lt;br /&gt;&lt;br /&gt;Actually, there is an unavoidable need of the team-lead-role. And s/he should never dive into developing unless it is that required. Rather, he(please add an 's' before 'h', I'm lazy.) role is to keep all his mets connected as well observe aspect of their work.&lt;br /&gt;&lt;br /&gt;Team-Lead role is almost similar to the role of the wicket keeper in cricket; cheering up the players and catch all the balls behind. A team lead should also look for the quality and security of the code component. As well, he will also ensure development path is not deviated from the path. As we are talking about agile methodologies, change may come, but that change should be verified by the team lead.&lt;br /&gt;&lt;br /&gt;Besides, the team lead should accumulate the knowledge learned by each of the team members. He is to somehow implement the notion of adaptive software development(ASD proposed by Jim Highsmith) i.e. focus on collaboration and learning. He is to arrange an meeting  to share the knowledge of the team mets. It can be in lunch time, can be after lunch hour or whenever seems appropriate. Remember, there is no need to prepare  presentation as it often time consuming and deviates the concentration from the development.  Main idea is to use any wheel if developed already by a team.&lt;br /&gt;&lt;br /&gt;One point must be concerned about at this regard is to maintain the motivation and positive team spirit. Say two techniques are developed by two of the team members for similar type of problem. Both the developers are smart and techniques are smart too. Now, to server in future which method is to be used? The team lead should carefully analyze(don't take too much time, if not resolved drop it till a right time) the two techniques with participation of them and expectedly he should sort out the right one and has to convince both of them positively.&lt;br /&gt;&lt;br /&gt;Always keep in concern to maintain the team spirit and motivation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-530248223829134399?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/530248223829134399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=530248223829134399' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/530248223829134399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/530248223829134399'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2008/01/role-of-team-lead-in-agile-environment.html' title='The role of a team lead in agile environment'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-4773677133535732631</id><published>2008-01-20T18:11:00.000+06:00</published><updated>2008-01-22T11:09:04.809+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='book'/><title type='text'>Books I have read.</title><content type='html'>Reading is my hobby and forgetting is my nature. In continuation to this, I have just started reading the book "Agile Software Development Qauality Assurance" by Ioannis Stamelos and Panagiotis Sfetsos.&lt;br /&gt;&lt;br /&gt;Recently I was very much inspired by &lt;a href="http://hasin.wordpress.com/"&gt;Hasin Hayder&lt;/a&gt;   to read on, since that, I like to share my reading experience.&lt;br /&gt;&lt;br /&gt;This post will contain all my read books gradually :)&lt;br /&gt;&lt;br /&gt;1. Agile software development quality assurance&lt;br /&gt;by Ioannis G. Stamelos, Panagiotis Sfetsos&lt;br /&gt;&lt;br /&gt;2. Test-Driven Development By Example&lt;br /&gt;by Kent Beck&lt;/td&gt;&lt;br /&gt;&lt;br /&gt;3. Software engineering A practitioner's approach&lt;br /&gt;by Roger S. Pressman&lt;br /&gt;&lt;br /&gt;4. Object-oriented PHP, concepts, techniques and code&lt;br /&gt;By Peter Lavin&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-4773677133535732631?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/4773677133535732631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=4773677133535732631' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4773677133535732631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4773677133535732631'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2008/01/books-i-have-read.html' title='Books I have read.'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-8755237758726041391</id><published>2008-01-13T00:53:00.002+06:00</published><updated>2010-04-21T14:50:02.407+06:00</updated><title type='text'>JQuery</title><content type='html'>&lt;p&gt;Once it used to be stated that to be a good developer one should learn a language every year. Why? The basic reason was to widen up ones view. By learning new language we can come to know about new techniques to solve a problem. Following that rule, I tasted some languages like C/C++(:P), java, Perl, PHP VB, Bash, VRML, JavaScript, C#, VC++/MFC(it should fall in C++ !), Flash Action script, SQL, Ferite etc.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Now, should I start learning python or ruby? I know they worth knowing, those are suppose to be a pleasant experience. But, what else might be done? I think knowing some api/libs can do the same! So, we learn GTK, XFC, Enlightenment, JFP, Struts, Tapestry etc.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In this way, I have started tasting JQuery. I am not saying learning, as to 'learn'or to say "I know THIS" not just means I read few books, some articles and a handful of codes to demonstrate, rather it's a matter of a longer period than 24 hours or 30 days.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Anyway, I am just writing about what I understand while going through the journey with JQuery( JQ ). Btw, I am studying the book, "Learing JQuery" by Jonathan Chaffer and Karl Swedberg.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;o:p/&gt;&lt;strong&gt;&lt;em&gt;What we can do with JQ:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;ol style="MARGIN-TOP: 0in" type="1"&gt;&lt;li&gt;Easily access to any DOM element&lt;/li&gt;&lt;li&gt;Modify the appearance on the fly [using css]&lt;/li&gt;&lt;li&gt;Change the content of the page&lt;/li&gt;&lt;li&gt;A wide range event handling to make the page more responsive to the user&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;p&gt;Besides these using jq we can do animation on the page,&lt;/p&gt;&lt;br /&gt;&lt;st1:city&gt;&lt;br /&gt;&lt;st1:place&gt;ajax&lt;/st1:place&gt;&lt;br /&gt;&lt;/st1:city&gt;&lt;br /&gt;integration and simplify other javascript tasks.&lt;br /&gt;&lt;p&gt;&lt;o:p/&gt;JQ has an interesting factory function $() and it can refer to any object very easily, like:&lt;/p&gt;&lt;br /&gt;&lt;ol style="MARGIN-TOP: 0in" type="1"&gt;&lt;li&gt;Elements : $('p') : Gets all the paragraphs&lt;/li&gt;&lt;li&gt;A particular element: $('#an_id'): gets the element with id 'an_id'&lt;/li&gt;&lt;li&gt;Elements with same class: $('.className')&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;[to be continued, feeling sleepy..]&lt;br /&gt;&lt;p class="poweredbyzoundry"&gt;Powered by &lt;a href="http://www.zoundry.com" class="poweredbyzoundry_link" rel="nofollow"&gt;Zoundry&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/1467120539710232930-8755237758726041391?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/8755237758726041391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=8755237758726041391' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/8755237758726041391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/8755237758726041391'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2008/01/jquiery.html' title='JQuery'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-570264950742157633</id><published>2007-12-07T17:16:00.001+06:00</published><updated>2008-01-12T12:00:13.695+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SQA'/><category scheme='http://www.blogger.com/atom/ns#' term='Project Management'/><title type='text'>When captain want to score</title><content type='html'>It is a post in reply to &lt;a href="http://tech.groups.yahoo.com/group/sqa_bangladesh/message/973."&gt;SQABD Yahoo group&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Really a nice statement, there is no 'I' in TEAM.&lt;br /&gt;&lt;br /&gt;In addition to it, I would like to say, "...though it is consisted of&lt;br /&gt;some I's". And everyone, really need to be concerned about all the I's.&lt;br /&gt;&lt;br /&gt;Why I am saying this, is for another truth that you said about team&lt;br /&gt;sport. Yes, surely someone gets more credit. Say in foot ball, may be&lt;br /&gt;the scorers are highlighted. But if the scorers want to play alone it&lt;br /&gt;is not appreciated and can be risky; as we all know it will also&lt;br /&gt;hamper the team effort.&lt;br /&gt;&lt;br /&gt;Additionally, think about the case when the captain is always planning&lt;br /&gt;how to score himself and forgets to plan how to defend his back, or&lt;br /&gt;how to employ all the players for winning the match, in software&lt;br /&gt;development context, meet the deadline and keep the project and make&lt;br /&gt;the customer happy :)&lt;br /&gt;&lt;br /&gt;Though, in some organizations and in some teams, it is experienced&lt;br /&gt;that some members irrespective of his/her role often forget their&lt;br /&gt;play.Sometimes they fail to understand the difference between&lt;br /&gt;confidence and (superiority)complex. It is rather detrimental when it&lt;br /&gt;happens to the captains.&lt;br /&gt;&lt;br /&gt;Specially the captains who came up to the managerial level by his/her&lt;br /&gt;development talents, which is undoubtedly appreciable. But&lt;br /&gt;occasionally, they are found to give more concentration on&lt;br /&gt;development(not design) rather on managing. As a consequence,&lt;br /&gt;developers kept idle. There are even some situations where developers&lt;br /&gt;were kept idle for 5+ hours for a 2 decision of the skipper(and it was&lt;br /&gt;solved in 10min after that), why ? cause s/he was coding in quiet&lt;br /&gt;mode! And it was not use to happen occasionally, rather it was a&lt;br /&gt;everyday practice! Developers working late nights often had to wait&lt;br /&gt;for hours together for a decision.&lt;br /&gt;&lt;br /&gt;Moreover,another problem of captains who were a Ronaldo(I'm his&lt;br /&gt;fan!)once is frequently found in their initial planning and designing&lt;br /&gt;the system. They tends to concentrate(and confined in the box) more on&lt;br /&gt;development details. I had another experience, where the manager was&lt;br /&gt;very talented and designed an system architecture(it was really a&lt;br /&gt;nice, I admit) and made the developers write more than 60 classes! But&lt;br /&gt;the problem was s/he did not know which technology/api will be used.&lt;br /&gt;When the api is got along with the apidoc, all those piles of codes&lt;br /&gt;are kept aside for the dust to fall on and with a hope to use in&lt;br /&gt;future. Developers again started writing code when they come to know&lt;br /&gt;what to do after sitting idle for hours. And again, the captain uses&lt;br /&gt;his/her full talent to develop some roadblocks (definitely those were&lt;br /&gt;very important) but without an integration plan and guess what... even&lt;br /&gt;without a revision control system. So the developers started writing&lt;br /&gt;the drama, which was scattered and scary.....&lt;br /&gt;&lt;br /&gt;So I think, though the word TEAM has no 'I' in it but it has an 'M' at&lt;br /&gt;the lead. S/he must ensure and be concerned that there comes no 'I' in&lt;br /&gt;TEAM.&lt;br /&gt;&lt;br /&gt;Have a nice day !&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-570264950742157633?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://tech.groups.yahoo.com/group/sqa_bangladesh/message/979' title='When captain want to score'/><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/570264950742157633/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=570264950742157633' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/570264950742157633'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/570264950742157633'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/12/when-captain-want-to-score.html' title='When captain want to score'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-2973297108144508190</id><published>2007-11-22T17:10:00.002+06:00</published><updated>2007-11-25T07:18:28.137+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Review'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>NetBean, even more fun</title><content type='html'>I am not going to raise another holly war between netbeans and the eclipese IDE. But, even though eclipse ide worked great after little tweaking, i think everything work better after they are tweaked, I love netbeans for its simple and fast interface. I know, many of you already frowned as called netbeans fast ! Yes indedd. At least for C/C++ development. Netbeans appeared simply lightening fast. It easily replaced geany as my favorite IDE.&lt;br /&gt;&lt;br /&gt;It is true, eclipse user base is very rich and so is its plug-in base. Almost all the necessary tools along with huge unnecessary ones (for a particular development view) can be found with eclipse. Especially the subversion plug-in... it is simply splendid). No worries.. I will download the svn module for netbeans. Hope it will not dishearten me :)&lt;br /&gt;&lt;br /&gt;Lastly, I also admit, netbeans is very slow for java development. Last time I was developing a non-day-job project using jsp/struts. I choose netbeans and found that it takes all the memory of my computer. Again after tweaking for memory, it came up with much faster speed, even though  an honest  comment will be . SLOW.&lt;br /&gt;&lt;br /&gt;But, if for C++ development, its simply great. Additionally, you can easily create UML design graphically by drag and drop; and then use it in your project ! One interesting feature of the UML module is that, here some of the design pattern templates are built in i.e. just select a pattern, give custom name click ok... you got the classes.&lt;br /&gt;&lt;br /&gt;Finally, I am very happy with the new netbean.. I simply love it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-2973297108144508190?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/2973297108144508190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=2973297108144508190' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2973297108144508190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2973297108144508190'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/11/netbean-even-more-fun.html' title='NetBean, even more fun'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-9076250287564298126</id><published>2007-11-22T17:10:00.001+06:00</published><updated>2007-11-25T03:30:39.111+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Review'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Using Eclipse  is Fun !</title><content type='html'>My current project is about building an embedded software using C++ on a ARM board. Due to some reasons we had to use use Eclipse as we are to use a proprietary tool chain plug-in of    the editor.  Anyhow,  eclipse was too slow to proceed development work fast where deadline is always yelling at the ear and release are very frequent. I started use geany, my favorite editor, for writing codes and just used Eclipse to build the project.&lt;br /&gt;&lt;br /&gt;Tonight, I got some relax time(you know 36 degree centigrade is cooler than 40 degree centigrade ! ) and played with eclipse settings. I just stopped the indexer and some other auto completion options -- the result was out of expectation ! Eclipse became fast enough to code on :) Besides, for source code I like courier font,  so I did not miss to change that too.&lt;br /&gt;&lt;br /&gt;Now, if you are interested, go to Window-&gt;Preferences-&gt;C/C++ and set off the content assistant and indexer. Bingo... now you have a faster Eclipse.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-9076250287564298126?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/9076250287564298126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=9076250287564298126' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/9076250287564298126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/9076250287564298126'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/11/using-eclipse-is-fun.html' title='Using Eclipse  is Fun !'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-2480450251336885049</id><published>2007-11-09T17:12:00.000+06:00</published><updated>2007-11-16T13:46:06.920+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ Member initialization</title><content type='html'>Many of us may not know that member variables of a class object is initialized before the &lt;span style="font-weight: bold; font-style: italic;"&gt;body&lt;/span&gt; of the constructor is executed! The class type members are initialized with the default constructor i.e. constructor with no arguments.  Primitive type member variable  like int, float etc  does not have any constructors, so they are just initialized with an undefined initial value which is often a garbage.&lt;br /&gt;&lt;br /&gt;Anyhow, this behavior can be  changed !  While defining the constructor to initialize the member variables with desired values put a colon after the constructor's last first-bracket and initialize the member variable placing a pair of first bracket after each member name; don't forget to put the value in between the first brackets. Both the class and primitive type members can be initialized in this way. Here is an example:&lt;br /&gt;&lt;br /&gt;class A{&lt;br /&gt;   string m_name;&lt;br /&gt;   int m_id;&lt;br /&gt;&lt;br /&gt;public:&lt;br /&gt;   A(int id);&lt;br /&gt;   A(int id, string&amp;amp; name);&lt;br /&gt;};&lt;br /&gt;/////&lt;br /&gt;A::A(int id):m_id(id),m_name("No name")&lt;br /&gt;{}&lt;br /&gt;&lt;br /&gt;This is a faster way than initializing the member variables in the constructor with assignment operator. Because for the later case member variables are first initialized with their respective default garbage values than assigned with the desired values; whereas in later case they are simply initialized with the desired values !&lt;br /&gt;:)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-2480450251336885049?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/2480450251336885049/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=2480450251336885049' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2480450251336885049'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2480450251336885049'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/11/c-member-initialization.html' title='C++ Member initialization'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-8479946788061254928</id><published>2007-10-30T17:15:00.000+06:00</published><updated>2007-10-30T17:27:48.860+06:00</updated><title type='text'>Play game here</title><content type='html'>Just added 2 free games from &lt;a href="http://www.dynamicdrive.com/dynamicindex12/"&gt;DynamicDrive&lt;/a&gt;.   I love this site for its great resources. Besides, I added fading effect to pop up the game div at center. You can now play these games from this page, just click any of the game link from the top left menu !!&lt;br /&gt;&lt;br /&gt;Would you please play once and put your scores on comment ? :)&lt;br /&gt;&lt;br /&gt;Thanks for your encouragement.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-8479946788061254928?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/8479946788061254928/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=8479946788061254928' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/8479946788061254928'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/8479946788061254928'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/10/play-game-here.html' title='Play game here'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-5056137096830443957</id><published>2007-10-25T18:49:00.000+06:00</published><updated>2007-10-25T18:51:22.795+06:00</updated><title type='text'>Macadamian's Code Review Checklist</title><content type='html'>&lt;p class="MsoBodyText2"&gt;At Macadamian, we practice what we preach with peer code  reviews. Before we commit any code to source control, we check it for compliance  with this list.&lt;/p&gt; &lt;p&gt;We’ve made the checklist public for the use of software development teams  implementing code review as part of their process. For more information about  code review processes and software development best practices, read check out  the Critical Path newsletter – it’s free, too!&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.macadamian.com/codereview.htm#GeneralCodeSmokeTest"&gt;General  Code Smoke Test&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#CommentsandCodingConventions"&gt;Comments  and Coding Conventions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#ErrorHandling"&gt;Error  Handling&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#ResourceLeaks"&gt;Resource  Leaks&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#ControlStructures"&gt;Control  Structures&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#Performance"&gt;Performance&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#Functions"&gt;Functions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#BugFixes"&gt;Bug  Fixes&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.macadamian.com/index.php?option=com_content&amp;amp;task=view&amp;amp;id=27&amp;amp;Itemid=31#Math"&gt;Math&lt;/a&gt;  &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:85%;"&gt;&lt;a class="" name="GeneralCodeSmokeTest"&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" name="GeneralCodeSmokeTest"&gt;&lt;/a&gt;General Code Smoke Test&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Does the code build correctly?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;No errors should occur  when building the source code. No warnings should be introduced by changes made  to the code.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does the code execute as expected?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;When executed, the  code does what it is supposed to.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Do you understand the code you are reviewing?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;As a  reviewer, you should understand the code. If you don't, the review may not be  complete, or the code may not be well commented.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Has the developer tested the code?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Insure the  developer has unit tested the code before sending it for review. All the limit  cases should have been tested.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="CommentsandCodingConventions"&gt;&lt;/a&gt;Comments and Coding  Conventions&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Does the code respect the project coding  conventions?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Check that the coding conventions have been  followed. Variable naming, indentation, and bracket style should be used.  &lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does the source file start with an appropriate header and copyright  information?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Each source file should start with an appropriate  header and copyright information. All source files should have a comment block  describing the functionality provided by the file.&lt;/em&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are variable declarations properly  commented?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Comments are required for aspects of variables that  the name doesn't describe. Each global variable should indicate its purpose and  why it needs to be global.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are units of numeric data clearly stated?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Comment the  units of numeric data. For example, if a number represents length, indicate if  it is in feet or meters.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are all functions, methods and classes  documented?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Describe each routine, method, and class in one or  two sentences at the top of its definition. If you can't describe it in a short  sentence or two, you may need to reassess its purpose. It might be a sign that  the design needs to be improved.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are function parameters used for input or output clearly identified  as such?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Make it clear which parameters are used for input and  output.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are complex algorithms and code optimizations adequately  commented?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Complex areas, algorithms, and code optimizations  should be sufficiently commented, so other developers can understand the code  and walk through it.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does code that has been commented out have an  explanation?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;There should be an explanation for any code that is  commented out. "Dead Code" should be removed. If it is a temporary hack, it  should be identified as such.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are comments used to identify missing functionality or unresolved  issues in the code?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;A comment is required for all code not  completely implemented. The comment should describe what's left to do or is  missing. You should also use a distinctive marker that you can search for later  (For example: "TODO:francis").&lt;/em&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" name="ErrorHandling"&gt;&lt;/a&gt;Error Handling&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Are assertions used everywhere data is expected to have a valid value  or range?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Assertions make it easier to identify potential  problems. For example, test if pointers or references are valid.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are errors properly handled each time a function  returns?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;An error should be detected and handled if it affects  the execution of the rest of a routine. For example, if a resource allocation  fails, this affects the rest of the routine if it uses that resource. This  should be detected and proper action taken. In some cases, the "proper action"  may simply be to log the error.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are resources and memory released in all error  paths?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Make sure all resources and memory allocated are released  in the error paths.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are all thrown exceptions handled properly?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;If the  source code uses a routine that throws an exception, there should be a function  in the call stack that catches it and handles it properly.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Is the function caller notified when an error is  detected?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Consider notifying your caller when an error is  detected. If the error might affect your caller, the caller should be notified.  For example, the "Open" methods of a file class should return error conditions.  Even if the class stays in a valid state and other calls to the class will be  handled properly, the caller might be interested in doing some error handling of  its own.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Has error handling code been tested?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Don't forget  that error handling code that can be defective. It is important to write test  cases that exercise it.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="ResourceLeaks"&gt;&lt;/a&gt;Resource Leaks&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Is allocated memory (non-garbage collected)  freed?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;All allocated memory needs to be freed when no longer  needed. Make sure memory is released in all code paths, especially in error code  paths.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are all objects (Database connections, Sockets, Files, etc.) freed  even when an error occurs?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;File, Sockets, Database connections,  etc. (basically all objects where a creation and a deletion method exist) should  be freed even when an error occurs. For example, whenever you use "new" in C++,  there should be a delete somewhere that disposes of the object. Resources that  are opened must be closed. For example, when opening a file in most development  environments, you need to call a method to close the file when you're  done.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Is the same object released more than once?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Make sure  there's no code path where the same object is released more than once. Check  error code paths.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does the code accurately keep track of reference  counting?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Frequently a reference counter is used to keep the  reference count on objects (For example, COM objects). The object uses the  reference counter to determine when to destroy itself. In most cases, the  developer uses methods to increment or decrement the reference count. Make sure  the reference count reflects the number of times an object is referred.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="ThreadSafeness"&gt;&lt;/a&gt;Thread Safeness&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Are all global variables thread-safe?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;If global  variables can be accessed by more than one thread, code altering the global  variable should be enclosed using a synchronization mechanism such as a mutex.  Code accessing the variable should be enclosed with the same mechanism.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are objects accessed by multiple threads  thread-safe?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;If some objects can be accessed by more than one  thread, make sure member variables are protected by synchronization  mechanisms.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are locks released in the same order they are  obtained?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;It is important to release the locks in the same order  they were acquired to avoid deadlock situations. Check error code  paths.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Is there any possible deadlock or lock  contention?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Make sure there's no possibility for acquiring a set  of locks (mutex, semaphores, etc.) in different orders. For example, if Thread A  acquires Lock #1 and then Lock #2, then Thread B shouldn't acquire Lock #2 and  then Lock #1.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="ControlStructures"&gt;&lt;/a&gt;Control Structures&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Are loop ending conditions accurate?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Check all loops  to make sure they iterate the right number of times. Check the condition that  ends the loop; insure it will end out doing the expected number of  iterations.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Is the code free of unintended infinite loops?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Check  for code paths that can cause infinite loops. Make sure end loop conditions will  be met unless otherwise documented.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="Performance"&gt;&lt;/a&gt;Performance&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Do recursive functions run within a reasonable amount of stack  space?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Recursive functions should run with a reasonable amount  of stack space. Generally, it is better to code iterative functions.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are whole objects duplicated when only references are  needed?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;This happens when objects are passed by value when only  references are required. This also applies to algorithms that copy a lot of  memory. Consider using algorithm that minimizes the number of object  duplications, reducing the data that needs to be transferred in memory.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does the code have an impact on size, speed, or memory  use?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Can it be optimized? For instance, if you use data  structures with a large number of occurrences, you might want to reduce the size  of the structure.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are you using blocking system calls when performance is  involved?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Consider using a different thread for code making a  function call that blocks.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Is the code doing busy waits instead of using synchronization  mechanisms or timer events?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Doing busy waits takes up CPU time.  It is a better practice to use synchronization mechanisms.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Was this optimization really needed?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Optimizations  often make code harder to read and more likely to contain bugs. Such  optimizations should be avoided unless a need has been identified. Has the code  been profiled?&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="Functions"&gt;&lt;/a&gt;Functions&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Are function parameters explicitly verified in the  code?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;This check is encouraged for functions where you don't  control the whole range of values that are sent to the function. This isn't the  case for helper functions, for instance. Each function should check its  parameter for minimum and maximum possible values. Each pointer or reference  should be checked to see if it is null. An error or an exception should occur if  a parameter is invalid.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are arrays explicitly checked for out-of-bound  indexes?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Make sure an error message is displayed if an index is  out-of-bound.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are functions returning references to objects declared on the  stack?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Don't return references to objects declared on the stack,  return references to objects created on the heap.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Are variables initialized before they are used?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Make  sure there are no code paths where variables are used prior to being  initialized. If an object is used by more than one thread, make sure the object  is not in use by another thread when you destroy it. If an object is created by  doing a function call, make sure the object was created before using  it.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does the code re-write functionality that could be achieved by using  an existing API?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Don't reinvent the wheel. New code should use  existing functionality as much as possible. Don't rewrite source code that  already exists in the project. Code that is replicated in more than one function  should be put in a helper function for easier maintenance.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="BugFixes"&gt;&lt;/a&gt;Bug Fixes&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Does a fix made to a function change the behavior of caller  functions?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Sometimes code expects a function to behave  incorrectly. Fixing the function can, in some cases, break the caller. If this  happens, either fix the code that depends on the function, or add a comment  explaining why the code can't be changed.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Does the bug fix correct all the occurrences of the  bug?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;If the code you're reviewing is fixing a bug, make sure it  fixes all the occurrences of the bug.&lt;/em&gt;&lt;/p&gt; &lt;h3&gt;&lt;a class="" name="Math"&gt;&lt;/a&gt;Math&lt;/h3&gt; &lt;p&gt;&lt;strong&gt;Is the code doing signed/unsigned conversions?&lt;/strong&gt;&lt;br /&gt;&lt;em&gt;Check  all signed to unsigned conversions: Can sign completion cause problems? Check  all unsigned to signed conversions: Can overflow occur? Test with Minimum and  Maximum possible values.&lt;/em&gt; &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-5056137096830443957?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.macadamian.com/index.php' title='Macadamian&apos;s Code Review Checklist'/><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/5056137096830443957/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=5056137096830443957' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/5056137096830443957'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/5056137096830443957'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/10/macadamians-code-review-checklist.html' title='Macadamian&apos;s Code Review Checklist'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-4380759283439367308</id><published>2007-10-25T16:45:00.001+06:00</published><updated>2007-10-25T18:48:58.754+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Engineering'/><title type='text'>Interesting Code Review "Facts"</title><content type='html'>The benefit of code reviews is undeniable.  &lt;p&gt;Yet, code reviews don't happen in most software development organizations.  And for good reason. The way code reviews are typically handled uses an enormous  amount of people and time resources. Even with system quality improvements  developers may not feel the effort is worth the cost. &lt;/p&gt; &lt;p&gt;It turns out you don't need a high overhead code review process to get  results. At one company I worked at I created a very low overhead automated code  review system that enabled every line of code to be reviewed before it was  checked-in. &lt;/p&gt; &lt;p&gt;Here are some ideas of how code reviews can be made practical in your  organization. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;ol&gt;&lt;li&gt;&lt;a href="http://comserver/cs/forums/EditPost.aspx?PostID=326&amp;amp;ReturnUrl=%2fcs%2fforums%2fShowThread.aspx%3fPostID%3d326%23326#facts"&gt;Interesting  Code Review "Facts" &lt;/a&gt; &lt;/li&gt;&lt;li&gt;&lt;a href="http://comserver/cs/forums/EditPost.aspx?PostID=326&amp;amp;ReturnUrl=%2fcs%2fforums%2fShowThread.aspx%3fPostID%3d326%23326#std"&gt;Code  Review Standard&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;&lt;a href="http://comserver/cs/forums/EditPost.aspx?PostID=326&amp;amp;ReturnUrl=%2fcs%2fforums%2fShowThread.aspx%3fPostID%3d326%23326#per"&gt;Perspective  Based Reviews&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;&lt;a href="http://comserver/cs/forums/EditPost.aspx?PostID=326&amp;amp;ReturnUrl=%2fcs%2fforums%2fShowThread.aspx%3fPostID%3d326%23326#decide"&gt;Deciding  If Code Reviews Work&lt;/a&gt;  &lt;/li&gt;&lt;li&gt;&lt;a href="http://comserver/cs/forums/EditPost.aspx?PostID=326&amp;amp;ReturnUrl=%2fcs%2fforums%2fShowThread.aspx%3fPostID%3d326%23326#pair"&gt;Are  Code Reviews Necessary With Pair Programming? &lt;/a&gt; &lt;/li&gt;&lt;li&gt;&lt;a href="http://comserver/cs/forums/EditPost.aspx?PostID=326&amp;amp;ReturnUrl=%2fcs%2fforums%2fShowThread.aspx%3fPostID%3d326%23326#crr"&gt;Code  Review Resources&lt;/a&gt; &lt;/li&gt;&lt;/ol&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;hr /&gt; &lt;a class="" title="facts" name="facts"&gt;&lt;/a&gt; &lt;h2&gt;&lt;a class="" title="section-CodeReviews-InerestingCodeReviewFacts" name="section-CodeReviews-InerestingCodeReviewFacts"&gt;&lt;/a&gt;Interesting Code Review  "Facts" &lt;/h2&gt; &lt;p&gt;My initial impression of code reviews is that they were heavy and bloated and  a waste of time. I was wrong on all counts. Here are some interesting facts I  found in the research: &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;ol&gt;&lt;li&gt;Using two inspectors is as effective as using four or more.  &lt;/li&gt;&lt;li&gt;Using an asyncronous process is as effective as a meeting based process for  code reviews. For design reviews a meeting based approach may be more effective.   &lt;/li&gt;&lt;li&gt;One review session is as effective as multiple inspection sessions.  &lt;/li&gt;&lt;li&gt;Scenario or perspective based reviews were more effective than add-hoc and  check-list based reviews.  &lt;/li&gt;&lt;li&gt;Inspections are effective.  &lt;/li&gt;&lt;li&gt;Inspecting upstream process like requirements and designs is very effective.  &lt;/li&gt;&lt;/ol&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;The implication is that the complexity and overhead of Fagan like code  inspections are not needed and a semi-automated method will yield improved  system quality. Requirements and HLDs seem to benefit from a more structured  inspection process, which makes a certain amount of sense. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;hr /&gt; &lt;a class="" title="std" name="std"&gt;&lt;/a&gt; &lt;h2&gt;&lt;a class="" title="section-CodeReviews-CodeReviewStandard" name="section-CodeReviews-CodeReviewStandard"&gt;&lt;/a&gt;Code Review Standard &lt;/h2&gt; &lt;p&gt;This is the list of some policies I would use to create a code review  standard for my organization. Take what's here, read the review on code  research, and figure out what will work best for your organization. &lt;/p&gt; &lt;p&gt;The key point to keep in mind is that the heavy weight nature of code reviews  is not true. You can create a code review system for your group that is light  enough that you can review every change in your entire system. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-EveryLineOfCodeMustBeReviewedBeforeItIsCheckedIn" name="section-CodeReviews-EveryLineOfCodeMustBeReviewedBeforeItIsCheckedIn"&gt;&lt;/a&gt;Every  Line of Code Must Be Reviewed Before it is Checked-In &lt;/h3&gt; &lt;p&gt;Do not allow code to be checked-in unless it has been reviewed, fixed, and  rereviewed. If you can't do this then your review process isn't fast or light  enough. It can be done. &lt;/p&gt; &lt;p&gt;Reviewing code after it has checked-in is next to useless as everyone is  exposed to the unreviewed code. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-CodeMustBeIntegratedCompiledUnitTestedAndSystemTestedBeforeReview" name="section-CodeReviews-CodeMustBeIntegratedCompiledUnitTestedAndSystemTestedBeforeReview"&gt;&lt;/a&gt;Code  Must Be Integrated, Compiled, Unit Tested, and System Tested Before Review&lt;/h3&gt; &lt;p&gt;Spending time on code that is just going to change or doesn't work is a  massive waste of time. The entrance requirements for a code review are: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;Code should compile without errors or warnings (according to coding  standard).  &lt;/li&gt;&lt;li&gt;Code should be already be integrated with its parent branch.  &lt;/li&gt;&lt;li&gt;Code should be fully unit tested.  &lt;/li&gt;&lt;li&gt;Code should already pass the system tests where possible. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-DevelopPerspectiveBasedReviews" name="section-CodeReviews-DevelopPerspectiveBasedReviews"&gt;&lt;/a&gt;Develop Perspective  Based Reviews&lt;/h3&gt; &lt;p&gt;For the issues that are important in your software consider developing a &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=PerspectiveReviews"&gt;Perspective  Review &lt;/a&gt;for each issue. Perhaps special hotspots for you are  internationalization, memory corruption, memory usage, threads, semaphores, etc.  An example can be found in &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=SemaphorePerspectiveCodeReview"&gt;Semaphore  Perspective Code Review&lt;/a&gt;. &lt;/p&gt; &lt;p&gt;You can then use the perspectives to assign roles to review team members.  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-UseMeetinglessAsyncronousReviews" name="section-CodeReviews-UseMeetinglessAsyncronousReviews"&gt;&lt;/a&gt;Use Meetingless  Asyncronous Reviews&lt;/h3&gt; &lt;p&gt;You don't need to hold a big meeting for a review. Everyone can review the  code when they can find time. Simpy have a done-by date when the review must be  completed. &lt;/p&gt; &lt;p&gt;Everyone on the review must review the code. If a person can't perform the  review then the team needs to elect someone else to perform a similar role in  the review. &lt;/p&gt; &lt;p&gt;Meetingless aysncronous reviews are fast and light, yet they are still  effective. With the right tool support you can easily review every line of code  in your system. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-UseBetween2And5RelevantReviewers" name="section-CodeReviews-UseBetween2And5RelevantReviewers"&gt;&lt;/a&gt;Use Between 2 and  5 Relevant Reviewers&lt;/h3&gt; &lt;p&gt;Too many reviewers wastes everyones time. Keep the number of reviewers small  and relevant to the code being reviewed. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-AssignReviewersRolesAndPerspectives" name="section-CodeReviews-AssignReviewersRolesAndPerspectives"&gt;&lt;/a&gt;Assign  Reviewers Roles and Perspectives&lt;/h3&gt; &lt;p&gt;It's almost impossible to review a lot of different issues in a lot of code.  People get tired and they stop noticings things. &lt;/p&gt; &lt;p&gt;The way around the getting tired issue is to use &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=PerspectiveReviews"&gt;perspective  reviews&lt;/a&gt;. Create a perspective for each important issue category your are  concerned about. Assign the perspectives to people on the review team. Because  they are only reviewing for issues in their perspective they will do a better  job because they can stay more concentrated. This doesn't mean they can't find  other issues as well, but they responsible for their perspective. &lt;/p&gt; &lt;p&gt;For example, if using semaphores correctly is important in your software and  the code has semaphores, then assign someone the role of reviewing semaphore  usage. An example can be found in &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=SemaphorePerspectiveCodeReview"&gt;Semaphore  Perspective Code Review&lt;/a&gt;. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-AllReviewCommunicationShouldGoToTheReviewListAndBeLogged" name="section-CodeReviews-AllReviewCommunicationShouldGoToTheReviewListAndBeLogged"&gt;&lt;/a&gt;All  Review Communication Should Go to the Review List and be Logged&lt;/h3&gt; &lt;p&gt;Part of the benefit of a review is that people learn about the system being  reviewed. This learning feature is facilitated by broadcasting email  communication between the review team and saving all communication so it can be  read by other people later. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-DoNotRedesignInTheReview" name="section-CodeReviews-DoNotRedesignInTheReview"&gt;&lt;/a&gt;Do Not Redesign in the  Review&lt;/h3&gt; &lt;p&gt;Make a note and schedule design issues for for a later time. &lt;/p&gt; &lt;p&gt;Developers always think they can do stuff better. Take these issues off line  unless the issue is that requirements are not being met. Requirements not being  met is not the same as you could have done it better. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-DoNotCoverCodingStandardsViolationsInTheReview." name="section-CodeReviews-DoNotCoverCodingStandardsViolationsInTheReview."&gt;&lt;/a&gt;Do  Not Cover Coding Standards Violations in the Review. &lt;/h3&gt; &lt;p&gt;Send violations via email or in person. &lt;/p&gt; &lt;p&gt;Talking about violations only gets everyone angry and is a waste of time.  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-CodeIsRereviewedUntilItPasses" name="section-CodeReviews-CodeIsRereviewedUntilItPasses"&gt;&lt;/a&gt;Code Is Rereviewed  Until it Passes&lt;/h3&gt; &lt;p&gt;Code isn't reviewed once and then forgetten. Any changes made have to be  rereviewed. If you think this is too slow then your process isn't light enough.  &lt;/p&gt; &lt;p&gt;No reviewing all changes makes the process useless as people will just ignore  suggestions or introduce new bugs in any changes. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-AllIssuesMustBeFixedMarkedAsNotAnIssueOrMarkedAsBug" name="section-CodeReviews-AllIssuesMustBeFixedMarkedAsNotAnIssueOrMarkedAsBug"&gt;&lt;/a&gt;All  Issues Must be Fixed, Marked as Not an Issue, or Marked as Bug&lt;/h3&gt; &lt;p&gt;Any issue brought up to a developer must be handled. A developer just can't  ignore issues because they think it's stupid. Every issue must: &lt;/p&gt; &lt;ul&gt;&lt;li&gt;Fixed.  &lt;/li&gt;&lt;li&gt;Marked as Not an Issue. If the developer and the reviewer can't decide  between themselves if an issue should be fixed or not, then the review team gets  to decide. If there is only one reviewer then bring a manager in or another team  memember. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-AutomateYourCodeReviewSystem" name="section-CodeReviews-AutomateYourCodeReviewSystem"&gt;&lt;/a&gt;Automate Your Code  Review System&lt;/h3&gt; &lt;p&gt;You can make your process light enough by building it into your build system.  If your process isn't light enough work on until it is. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-ReviewAllCodeOnPrivateBranchBeforeAMerge" name="section-CodeReviews-ReviewAllCodeOnPrivateBranchBeforeAMerge"&gt;&lt;/a&gt;Review All  Code on Private Branch Before a Merge&lt;/h3&gt; &lt;p&gt;Code developed on a private branch doesn't need to reviewed during  development. But before the code is merged into a parent branch all code changes  must go through the complete review process. For this reason, development of a  large scale feature, may still want to perform reviews on the private branch  because that can speed up the merge process. &lt;/p&gt; &lt;p&gt;Of course, try not to have branches separate from the mainline, but for large  features that take a long time to develop you will often need separate branches.  &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-ReviewTheRightScopeOfChanges" name="section-CodeReviews-ReviewTheRightScopeOfChanges"&gt;&lt;/a&gt;Review the Right Scope  of Changes&lt;/h3&gt; &lt;p&gt;You don't have to review every line of code in every module that has changed.  Certainly if a module is new it must be completely reviewed. Other than that you  may be able to just review the changed code. Though just reviewing changed code  isn't always possible. If you are performing a semaphore perspective review, for  example, then you will need to go look at the code within in the scope of the  sempahore as well. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-StickToReviewableIssues" name="section-CodeReviews-StickToReviewableIssues"&gt;&lt;/a&gt;Stick to Reviewable  Issues&lt;/h3&gt; &lt;p&gt;Develop your list of what issues can be reviewed and how they are to be  reviewed. Usually this is in the form of check lists and perspective reviews.  Don't allow reviews on other items without changing what can be reviewed.  Otherwise people spend endless time on off-topic arguments. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-ReviewTeamReponsibleForDecidingIssues" name="section-CodeReviews-ReviewTeamReponsibleForDecidingIssues"&gt;&lt;/a&gt;Review Team  Reponsible for Deciding Issues&lt;/h3&gt; &lt;p&gt;If there is a conflict on any part of the review then the review team is  responsible for handling it. That's the only way the review process will be  light enough to work. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-KeepItCool" name="section-CodeReviews-KeepItCool"&gt;&lt;/a&gt;Keep it Cool&lt;/h3&gt; &lt;p&gt;Nobody is perfect. The attitude of the review should never be personal, it  should always be professional, with the goal of improving the system and the  people building the system. Keep your tempers. &lt;/p&gt; &lt;p&gt;Don't blame people for bugs. Work together to make things better. No finger  pointing! Not ever! &lt;/p&gt; &lt;p&gt;Meetingless reviews can help keep the anger down, but it can make it worse  too. When people are in the same room anger can ramp up really quick. And we  know in email it's very easy to say something that can be take wrong. Raise the  awareness of these issues in your team. &lt;/p&gt; &lt;p&gt;A good rule is to &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=NeverAssumeAnAttack"&gt;Never  Assume An Attack&lt;/a&gt;. If you find yourself getting angry, assume it's a  misunderstanding, not an attack. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-NoManagers" name="section-CodeReviews-NoManagers"&gt;&lt;/a&gt;No Managers&lt;/h3&gt; &lt;p&gt;Unless a manager has something to add to the reviews then they shouldn't be  involved. Issues should be decided by the review team. Managers always have to  run to a different meeting, they don't have time slots open for meetings, and  they generally don't add technical input. So you don't need managers as part of  the review process. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-IfABugWasNotCaughtInAReviewFigureOutWhy" name="section-CodeReviews-IfABugWasNotCaughtInAReviewFigureOutWhy"&gt;&lt;/a&gt;If a Bug  Was Not Caught in a Review Figure Out Why&lt;/h3&gt; &lt;p&gt;If a bug happens after a review then track down why each bug wasn't found and  then change your development process somehow to try and prevent that bug in the  future. &lt;/p&gt; &lt;p&gt;This is not always possible as running full tests are often impossible, but  it should be mostly possible. &lt;/p&gt; &lt;p&gt;I would create a bug for each bug to track down why it wasn't caught. Because  this issue is more serious than just the review. It means the unit test, the  system test, and the review did not work. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-ReviewUpstreamDocumentsToo" name="section-CodeReviews-ReviewUpstreamDocumentsToo"&gt;&lt;/a&gt;Review Upstream  Documents Too&lt;/h3&gt; &lt;p&gt;Reviewing product requirement documents, specs, standards, etc can provide  excellent return on value. Make sure those products are reviewed as well. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-FeedLeasonsLearnedIntoTheTeamAndDocumentation" name="section-CodeReviews-FeedLeasonsLearnedIntoTheTeamAndDocumentation"&gt;&lt;/a&gt;Feed  Leasons Learned Into the Team and Documentation&lt;/h3&gt; &lt;p&gt;If issues come up during the review that everyone in the team would benefit  from, then have a way to make wisdom public. &lt;/p&gt; &lt;p&gt;I would recommend a development &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=GettingYourWikiAdopted"&gt;wiki  &lt;/a&gt;where you can write documentation on anything useful that people come up  with. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;h3&gt;&lt;a class="" title="section-CodeReviews-PlugReviewsIntoYourSourceCodeControlSystem" name="section-CodeReviews-PlugReviewsIntoYourSourceCodeControlSystem"&gt;&lt;/a&gt;Plug  Reviews into Your Source Code Control System&lt;/h3&gt; &lt;p&gt;I have done this through change check-in comments. Each change has to be  reviewed before it is checked-in. The submit comment must contain a review ID  that points to some document containing the review status for the change that is  about to be submitted. The code is prevented from being submitted without a  valid passed review. If you are able to automate your code review system all  this works quite quickly and painlessly. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;hr /&gt; &lt;a class="" title="per" name="per"&gt;&lt;/a&gt; &lt;h2&gt;&lt;a class="" title="section-CodeReviews-PerspectiveBasedReviews" name="section-CodeReviews-PerspectiveBasedReviews"&gt;&lt;/a&gt;Perspective Based  Reviews&lt;/h2&gt; &lt;p&gt;Before my reseach into code reviews I had never before heard about &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=PerspectiveReviews"&gt;perspective  based reviews &lt;/a&gt;. Perspective based reviews are done from the point-of-view of  various project stakeholders. This is as apposed to everyone doing an add hoc or  checklist based review. A perspective would be a user, requirements person,  hardware interface, exception handling, mutex usage, memory usage, etc. The  thought is they are more effective because reviewers are concentrating on a  particular issue instead of trying to review everything. Do one thing well i  guess. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Reviews are driven by scenarios. A scenario tells the insepector how to go  about reading the documentation from particular perspective and what to look  for. Clearly there's a lot to the scenarios. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;Perhaps people could be assigned in various review roles. Or maybe some  people can perform reviews only from a certain perspective. &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;hr /&gt; &lt;a class="" title="decide" name="decide"&gt;&lt;/a&gt; &lt;h2&gt;&lt;a class="" title="section-CodeReviews-DecidingIfCodeReviewsWork" name="section-CodeReviews-DecidingIfCodeReviewsWork"&gt;&lt;/a&gt;Deciding If Code Reviews  Work&lt;/h2&gt; &lt;div&gt;How do you know if &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=CodeReviews"&gt;code  reviews&lt;/a&gt; are working for you? Look for  &lt;p&gt; &lt;/p&gt; &lt;ul&gt;&lt;li&gt;Increased in test execution rate. The tests suites runs through its test  suite. Unstable software can't do this.  &lt;/li&gt;&lt;li&gt;Increased pass rate.  &lt;/li&gt;&lt;li&gt;Reduction of critical bugs in QA.  &lt;/li&gt;&lt;li&gt;Reduction of field issues.  &lt;/li&gt;&lt;li&gt;Subjective improvements in quality. &lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Try to measure the issues to verify if code reviews are working for you.  &lt;/p&gt;&lt;/div&gt; &lt;p&gt; &lt;/p&gt; &lt;hr /&gt; &lt;a class="" title="pair" name="pair"&gt;&lt;/a&gt; &lt;h2&gt;&lt;a class="" title="section-CodeReviews-AreCodeReviewsNecessaryWithPairProgramming" name="section-CodeReviews-AreCodeReviewsNecessaryWithPairProgramming"&gt;&lt;/a&gt;Are Code  Reviews Necessary With Pair Programming? &lt;/h2&gt; &lt;div&gt;An issue that comes up is the relationship between &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=CodeReviews"&gt;code  reviews&lt;/a&gt; and &lt;a class="external" href="http://c2.com/cgi/wiki?PairProgramming"&gt;pair programming &lt;/a&gt;&lt;img class="outlink" alt="" src="http://www.possibility.com/epowiki/images/out.png" /&gt;.  Do you still need code reviews if you pair program?  &lt;p&gt;If you don't pair program then you definitely should perform &lt;a class="wikipage" href="http://www.possibility.com/epowiki/Wiki.jsp?page=CodeReviews"&gt;code  reviews&lt;/a&gt;. That one is easy. Unit tests and system tests simply aren't good  enough to replace code reviews. &lt;/p&gt; &lt;p&gt;After that it depends. &lt;/p&gt; &lt;p&gt;It depends on the product you are developing, it's importance, it's  complexity, and how critical it is that there be no errors. &lt;/p&gt; &lt;p&gt;Pair programming is an excellent form of active code review, but there are  many products where I don't think two eyes are enough. Some systems are complex  enough, some domains are complex enough, and some conseuqneces are severe enough  that I want more eyeballs on them before the code is let loose in a real code  running system. &lt;/p&gt; &lt;p&gt;When pair programming is used you could decide what code should be reviewed  by subsystem or by the type of change involved. &lt;/p&gt; &lt;p&gt;For example, code in a key algorithm may need to be reviewed by the impacted  parties. Perhaps a drive change needs to be reviewed. Perhaps when a piece of  code is written new or completely rewritten, it should be reviewed. Perhaps if  semaphores are added to code that would trigger a review because it changes the  system a great deal. &lt;/p&gt; &lt;p&gt;Your mileage may vary of course. &lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-4380759283439367308?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.possibility.com' title='Interesting Code Review &quot;Facts&quot;'/><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/4380759283439367308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=4380759283439367308' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4380759283439367308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4380759283439367308'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/10/interesting-code-review-facts.html' title='Interesting Code Review &quot;Facts&quot;'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-3090654980393623768</id><published>2007-10-25T16:36:00.000+06:00</published><updated>2007-10-25T16:45:18.914+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Engineering'/><title type='text'>Charecteristics of commercial software</title><content type='html'>Commercial Softwares - A term with whom most of the software professional, including me, are familiar with. There are thousands of different commercial software in different areas; even though all of them share some common properties such as: built by many, expandable,  maintainable, understandable, and stable.&lt;br /&gt;&lt;p class="docText"&gt;&lt;/p&gt;Lets see what are those:&lt;br /&gt;&lt;ul&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;span style="font-weight: bold;"&gt;Built by many&lt;/span&gt;:&lt;/span&gt; Software that  is built by a team inherently means that no single person has firsthand  knowledge of all of the code. It also means that good communication among the  team members is critically important to the software's success. Communication  has to start at the beginning; everyone on the team must share an understanding  of what exactly is being built, for whom, and when it is needed. By  understanding the customers and their requirements, you can always go back and  ask yourself, "Is this feature I'm adding really necessary?" Understanding both  the business and product requirements can help you avoid the dreaded feature  creep or increasing scope that often delays products. Communication has to  continue throughout the process: conveying interface designs so that integration  among components runs smoothly; accurately and completely documenting your code;  and conveying new member functions and their purpose to the Software Quality  Assurance (SQA) and Documentation groups.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;span style="font-weight: bold;"&gt;Expandable&lt;/span&gt;:&lt;/span&gt; You must be able  to add new features quickly and extend existing features in commercial software.  These requests often seem to come when an influential customer finds that they  need just one more thing to solve their problem. Even worse is when a limitation  is discovered only after the product is released. Whether or not code can be  easily expanded to accommodate these requests is often a function of the design.  While it may be as easy as adding a new member function, significant new  features require that the design be extended. Put simply, you have to think  ahead when designing and writing code. Just implementing to a specification,  with no thought to future expansion or maintainability, makes future changes  much more difficult. A further complication is that most software won't allow  features to be deprecated once the product is in use. You can't simply remove a  class that was ill conceived, as it is certain that if you do so, you'll find a  whole host of customers using it. Backward compatibility is often a key design  constraint.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;span style="font-weight: bold;"&gt;Maintainable&lt;/span&gt;:&lt;/span&gt; No matter how  many unit tests are written, automated tests are run, or functional tests are  executed, it is inevitable that bugs will be found after the product has been  released. For commercial software, the goal of all of the rigorous testing and  preparation is to ensure that any post-release bugs have minor consequences to  the product. What becomes crucial is that these bugs be easily and quickly  corrected for the next release. It is also likely that the person who  implemented a particular component won't be the person responsible for fixing  the bug, either because enough time has passed that he has been assigned to a  different project, or there are designated engineers responsible for support and  maintenance. Given these constraints, maintainability must be designed into the  software. There has to be an emphasis on solid design practices and clarity in  coding styles, so that the software can be efficiently maintained without  further complicating it.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;span style="font-weight: bold;"&gt;Understandable&lt;/span&gt;:&lt;/span&gt; Commercial  software often includes visible software interfaces. If you are building an  embedded system library, it needs to be understandable to the application  engineers within your company. If you are building a software library, the  interface you present must be easily understood by your customers so that they  can use it to build their own applications. This doesn't just mean that naming  conventions must make sense, but more importantly that your design and your use  of language elements, like templates, are clear and appropriate.&lt;/p&gt; &lt;/li&gt;&lt;li&gt; &lt;p class="docText"&gt;&lt;span class="docEmphStrong"&gt;&lt;span style="font-weight: bold;"&gt;Stable&lt;/span&gt;:&lt;/span&gt; Commercial software  must be stable; that is, it must be able to run for extended periods of time  without crashing, leaking memory, or having unexplained anomalies.&lt;/p&gt;&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/1467120539710232930-3090654980393623768?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/3090654980393623768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=3090654980393623768' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/3090654980393623768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/3090654980393623768'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/10/charecteristics-of-commercial-software.html' title='Charecteristics of commercial software'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-3535771085832312905</id><published>2007-10-23T18:49:00.001+06:00</published><updated>2007-10-23T18:59:55.762+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='India'/><title type='text'>Me, in Cherapunji</title><content type='html'>&lt;a href="http://www.flickr.com/photos/happyman/1667037624/" title="photo sharing"&gt;&lt;img src="http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg" alt="" style="border: 2px solid rgb(0, 0, 0);"&gt;&lt;/a&gt;&lt;br /&gt;&lt;font style="margin-top: 0px;" size="0"&gt;&lt;a href="http://www.flickr.com/photos/happyman/1667037624/"&gt;Me, in Cherapunji&lt;/a&gt;&lt;br /&gt;Originally uploaded by &lt;a href="http://www.flickr.com/people/happyman/"&gt;Happy-Man&lt;/a&gt;&lt;/font&gt; &lt;p&gt;This is a observation point at Cherapunji, India. We had a great expectation about the seven-sister fall that we read on internet before visiting India. The local guide told us in rainy season the fall becomes large enough and looks great.&lt;br /&gt;&lt;br /&gt;Hard luck !! We went in winter :(&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-3535771085832312905?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/3535771085832312905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=3535771085832312905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/3535771085832312905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/3535771085832312905'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/10/me-in-cherapunji.html' title='Me, in Cherapunji'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-6227324550699108690</id><published>2007-10-23T18:40:00.001+06:00</published><updated>2007-10-23T18:51:27.620+06:00</updated><title type='text'></title><content type='html'>&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-6227324550699108690?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/6227324550699108690/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=6227324550699108690' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/6227324550699108690'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/6227324550699108690'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/10/flickr.html' title=''/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-1538344832229960695</id><published>2007-08-21T11:01:00.000+06:00</published><updated>2007-08-21T11:09:00.120+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JavaScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Ajax'/><title type='text'>Ajax : A simple and basic example with callback function</title><content type='html'>The function takes the request url and a function as parameter. The function as parameter is used as call back function whe ajax status is ready.&lt;br /&gt;&lt;br /&gt;Feel free to use the code.&lt;br /&gt;&lt;br /&gt;function sendRequest(req,fn)&lt;br /&gt;{   &lt;br /&gt;//    alert(req);&lt;br /&gt; var xmlHttp;&lt;br /&gt;  try&lt;br /&gt;    {&lt;br /&gt;    // Firefox, Opera 8.0+, Safari&lt;br /&gt;    xmlHttp=new XMLHttpRequest();&lt;br /&gt;    }&lt;br /&gt;  catch (e)&lt;br /&gt;    {&lt;br /&gt;    // Internet Explorer&lt;br /&gt;    try&lt;br /&gt;      {&lt;br /&gt;      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");&lt;br /&gt;      }&lt;br /&gt;    catch (e)&lt;br /&gt;      {&lt;br /&gt;      try&lt;br /&gt;        {&lt;br /&gt;        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;        }&lt;br /&gt;      catch (e)&lt;br /&gt;        {&lt;br /&gt;        alert("Your browser does not support AJAX!");&lt;br /&gt;        return false;&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;    xmlHttp.onreadystatechange=function()&lt;br /&gt;      {&lt;br /&gt;      if(xmlHttp.readyState==4)&lt;br /&gt;        {&lt;br /&gt;            fn(xmlHttp.responseText);&lt;br /&gt;        }&lt;br /&gt;      }&lt;br /&gt;    xmlHttp.open("GET",req,true);&lt;br /&gt;    xmlHttp.send(null);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-style: italic; color: rgb(255, 0, 0);"&gt;Use it as:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;function OnSearch(msg)&lt;br /&gt;{&lt;br /&gt;    alert(msg);&lt;br /&gt;}&lt;br /&gt;sendRequest((url),OnSearch);&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-1538344832229960695?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/1538344832229960695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=1538344832229960695' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/1538344832229960695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/1538344832229960695'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/ajax-simple-and-basic-example-with.html' title='Ajax : A simple and basic example with callback function'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-4604540283531352981</id><published>2007-08-21T10:49:00.000+06:00</published><updated>2007-08-21T10:50:32.461+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PostgreSQL'/><title type='text'>PostgreSQL Cheat Sheet</title><content type='html'>&lt;h2&gt;CREATE DATABASE&lt;/h2&gt; &lt;pre&gt;CREATE DATABASE &lt;em&gt;dbName&lt;/em&gt;;&lt;/pre&gt; &lt;h2&gt;CREATE TABLE (with auto numbering integer id)&lt;/h2&gt; &lt;pre&gt;CREATE TABLE &lt;em&gt;tableName&lt;/em&gt; (&lt;br /&gt;id serial PRIMARY KEY,&lt;br /&gt;name varchar(50) UNIQUE NOT NULL,&lt;br /&gt;dateCreated timestamp DEFAULT current_timestamp&lt;br /&gt;);&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Add a primary key&lt;/h2&gt; &lt;pre&gt;ALTER TABLE &lt;em&gt;tableName&lt;/em&gt; ADD PRIMARY KEY (&lt;em&gt;id&lt;/em&gt;);&lt;/pre&gt;  &lt;h2&gt;Create an INDEX&lt;/h2&gt; &lt;pre&gt;CREATE UNIQUE INDEX &lt;em&gt;indexName&lt;/em&gt; ON tableName (columnNames);&lt;/pre&gt;  &lt;h2&gt;Backup a database &lt;em&gt;(command line)&lt;/em&gt;&lt;/h2&gt; &lt;pre&gt;pg_dump &lt;em&gt;dbName&lt;/em&gt; &gt; &lt;em&gt;dbName&lt;/em&gt;.sql&lt;/pre&gt;  &lt;h2&gt;Backup all databases &lt;em&gt;(command line)&lt;/em&gt;&lt;/h2&gt; &lt;pre&gt;pg_dumpall &gt; pgbackup.sql&lt;/pre&gt;  &lt;h2&gt;Run a SQL script &lt;em&gt;(command line)&lt;/em&gt;&lt;/h2&gt; &lt;pre&gt;psql -f script.sql &lt;em&gt;databaseName&lt;/em&gt;&lt;/pre&gt;  &lt;h2&gt;Search using a regular expression&lt;/h2&gt; &lt;pre&gt;SELECT column FROM table WHERE column ~ 'foo.*';&lt;/pre&gt;  &lt;h2&gt;The first &lt;em&gt;N&lt;/em&gt; records&lt;/h2&gt; &lt;pre&gt;SELECT columns FROM table LIMIT 10;&lt;/pre&gt;  &lt;h2&gt;Pagination&lt;/h2&gt; &lt;pre&gt;SELECT cols FROM table LIMIT 10 OFFSET 30;&lt;/pre&gt;  &lt;h2&gt;Prepared Statements&lt;/h2&gt; &lt;pre&gt;PREPARE preparedInsert (int, varchar) AS&lt;br /&gt;INSERT INTO tableName (intColumn, charColumn) VALUES ($1, $2);&lt;br /&gt;EXECUTE preparedInsert (1,'a');&lt;br /&gt;EXECUTE preparedInsert (2,'b');&lt;br /&gt;DEALLOCATE preparedInsert;&lt;br /&gt;&lt;/pre&gt; &lt;h2&gt;Create a Function&lt;/h2&gt; &lt;pre&gt;CREATE OR REPLACE FUNCTION month (timestamp) RETURNS integer&lt;br /&gt;AS 'SELECT date_part(''month'', $1)::integer;'&lt;br /&gt;LANGUAGE 'sql';&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Table Maintenance&lt;/h2&gt; &lt;pre&gt;VACUUM ANALYZE table;&lt;/pre&gt; &lt;h2&gt;Reindex a database, table or index&lt;/h2&gt; &lt;pre&gt;REINDEX DATABASE dbName;&lt;/pre&gt; &lt;h2&gt;Show query plan&lt;/h2&gt; &lt;pre&gt;EXPLAIN SELECT * FROM table;&lt;/pre&gt; &lt;h2&gt;Import from a file&lt;/h2&gt; &lt;pre&gt;COPY destTable FROM '/tmp/somefile';&lt;/pre&gt; &lt;h2&gt;Show all runtime parameters&lt;/h2&gt; &lt;pre&gt;SHOW ALL;&lt;/pre&gt; &lt;h2&gt;Grant all permissions to a user&lt;/h2&gt; &lt;pre&gt;GRANT ALL PRIVILEGES ON table TO username;&lt;/pre&gt;  &lt;h2&gt;Perform a transaction&lt;/h2&gt; &lt;pre&gt;BEGIN TRANSACTION&lt;br /&gt;UPDATE accounts SET balance += 50 WHERE id = 1;&lt;br /&gt;COMMIT;&lt;br /&gt;&lt;/pre&gt;  &lt;p&gt;&lt;strong&gt;Basic SQL&lt;/strong&gt;&lt;/p&gt;  &lt;h2&gt;Get all columns and rows from a table&lt;/h2&gt; &lt;pre&gt;SELECT * FROM table;&lt;/pre&gt; &lt;h2&gt;Add a new row&lt;/h2&gt; &lt;pre&gt;INSERT INTO table (column1,column2)&lt;br /&gt;VALUES (1, 'one');&lt;/pre&gt; &lt;h2&gt;Update a row&lt;/h2&gt; &lt;pre&gt;UPDATE table SET foo = 'bar' WHERE id = 1;&lt;/pre&gt; &lt;h2&gt;Delete a row&lt;/h2&gt; &lt;pre&gt;DELETE FROM table WHERE id = 1;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- &lt;p&gt;&lt;a href="http://del.icio.us/pfreitag?url=http%3A%2F%2Fwww.petefreitag.com%2Fcheatsheets%2Fpostgresql%2F&amp;title=PostgreSQL+Cheat+Sheet" title="bookmark on del.icio.us" rel="nofollow"&gt;&lt;img src="/images/del.icio.us.gif" alt="del.icio.us" border="0" /&gt; bookmark this&lt;/a&gt;    &lt;a href="http://digg.com/programming/PostgreSQL_Cheat_Sheet"&gt;digg this&lt;/a&gt;&lt;/p&gt; --&gt; &lt;p&gt;&lt;em&gt;Prints in under two pages. Questions, comments, criticism, or requests can be directed &lt;a href="http://www.petefreitag.com/contact/" rel="nofollow"&gt;Here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.petefreitag.com/cheatsheets/"&gt;More Cheat Sheets Here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;small&gt;&lt;em&gt;Copyright © 2005 &lt;a href="http://foundeo.com/"&gt;Foundeo Inc.&lt;/a&gt; (http://foundeo.com/) / &lt;a href="http://www.petefreitag.com/"&gt;Peter Freitag&lt;/a&gt; (http://www.petefreitag.com/), All Rights Reserved.&lt;br /&gt;This document may be printed freely as long as this notice stays intact.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-4604540283531352981?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.petefreitag.com/cheatsheets/postgresql/' title='PostgreSQL Cheat Sheet'/><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/4604540283531352981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=4604540283531352981' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4604540283531352981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4604540283531352981'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/postgresql-cheat-sheet.html' title='PostgreSQL Cheat Sheet'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-7128516656238275231</id><published>2007-08-21T10:43:00.000+06:00</published><updated>2007-08-21T10:49:00.816+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Apache'/><title type='text'>Apache Cheat Sheet</title><content type='html'>&lt;h1&gt;Apache Cheat Sheet&lt;/h1&gt;  &lt;h2&gt;Setup a Virtual Domain&lt;/h2&gt; &lt;pre&gt;NameVirtualHost *&lt;br /&gt;&lt;virtualhost&gt;&lt;br /&gt;DocumentRoot /web/example.com/www&lt;br /&gt;ServerName www.example.com&lt;br /&gt;&lt;em&gt;ServerAlias example.com&lt;br /&gt;CustomLog /web/example.com/logs/access.log combined&lt;br /&gt;ErrorLog /web/example.com/logs/error.log&lt;/em&gt;&lt;br /&gt;&lt;/virtualhost&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Include another conf file&lt;/h2&gt; &lt;pre&gt;Include /etc/apache/virtual-hosts/*.conf&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Hide apache version info&lt;/h2&gt; &lt;pre&gt;ServerSignature Off&lt;br /&gt;ServerTokens Prod&lt;/pre&gt;  &lt;h2&gt;Custom 404 Error message&lt;/h2&gt; &lt;pre&gt;ErrorDocument 404 /404.html&lt;/pre&gt;  &lt;h2&gt;Create a virtual directory (mod_alias)&lt;/h2&gt; &lt;pre&gt;Alias /common /web/common&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Perminant redirect (mod_alias)&lt;/h2&gt; &lt;pre&gt;Redirect permanent /old http://example.com/new&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Create a cgi-bin&lt;/h2&gt; &lt;pre&gt;ScriptAlias /cgi-bin/ /web/cgi-bin/&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Process .cgi scripts&lt;/h2&gt; &lt;pre&gt;AddHandler cgi-script .cgi&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Add a directory index&lt;/h2&gt; &lt;pre&gt;DirectoryIndex index.cfm index.cfm&lt;/pre&gt;  &lt;h2&gt;Turn off directory browsing&lt;/h2&gt; &lt;pre&gt;Options -Indexes&lt;br /&gt;&lt;/pre&gt; &lt;h2&gt;Turn on directory browsing&lt;/h2&gt; &lt;pre&gt;&lt;location&gt;&lt;br /&gt;Options +Indexes&lt;br /&gt;&lt;/location&gt;&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Create a new user for basic auth &lt;em&gt;(command line)&lt;/em&gt;&lt;/h2&gt; &lt;pre&gt;htpasswd -c /etc/apacheusers&lt;/pre&gt;  &lt;h2&gt;Apache basic authentication&lt;/h2&gt; &lt;pre&gt;AuthName "Authentication Required"&lt;br /&gt;AuthType Basic&lt;br /&gt;AuthUserFile /etc/apacheusers&lt;br /&gt;Require valid-user&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Only allow access from a specific IP&lt;/h2&gt; &lt;pre&gt;Order Deny,Allow&lt;br /&gt;Deny from all&lt;br /&gt;Allow from 127.0.0.1&lt;br /&gt;&lt;/pre&gt;  &lt;h2&gt;Only allow access from your subnet&lt;/h2&gt; &lt;pre&gt;Order Deny,Allow&lt;br /&gt;Deny from all&lt;br /&gt;Allow from 176.16.0.0/16&lt;br /&gt;&lt;/pre&gt;   &lt;p&gt;&lt;strong&gt;mod_rewrite&lt;/strong&gt;&lt;/p&gt; &lt;h2&gt;Turn on the rewrite engine&lt;/h2&gt; &lt;pre&gt;RewriteEngine On&lt;/pre&gt; &lt;h2&gt;Redirect /news/123 to /news.cfm?id=123&lt;/h2&gt; &lt;pre&gt;RewriteRule ^/news/([0-9]+)$ /news.cfm?id=$1 [PT,L]&lt;/pre&gt; &lt;h2&gt;Redirect www.example.com to example.com&lt;/h2&gt; &lt;pre&gt;RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]&lt;br /&gt;RewriteRule ^(.*)$ http://example.com$1 [R=301,L]&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;This is a work in progress - Questions, comments, criticism, or requests can be directed &lt;a href="http://www.petefreitag.com/contact/" rel="nofollow"&gt;Here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.petefreitag.com/cheatsheets/"&gt;More Cheat Sheets Here&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;&lt;small&gt;&lt;em&gt;Copyright © 2005 &lt;a href="http://www.petefreitag.com/"&gt;Peter Freitag&lt;/a&gt; (http://www.petefreitag.com/), All Rights Reserved.&lt;br /&gt;This document may be printed freely as long as this notice stays intact.&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;  &lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; _uacct = "UA-82573-6"; urchinTracker(); &lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-7128516656238275231?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://www.petefreitag.com/cheatsheets/apache/' title='Apache Cheat Sheet'/><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/7128516656238275231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=7128516656238275231' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/7128516656238275231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/7128516656238275231'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/apache-cheat-sheet.html' title='Apache Cheat Sheet'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-2495627497367886872</id><published>2007-08-14T17:38:00.000+06:00</published><updated>2007-08-14T17:42:42.405+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Coding Style'/><title type='text'>A typical source file header</title><content type='html'>&lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;//-----------------------------------------------------------------&lt;br /&gt;/**&lt;/span&gt;&lt;/p&gt;        &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;span style=""&gt; &lt;/span&gt;Author&lt;span style=""&gt;           &lt;/span&gt;: Shaikh Sonny Aman&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;eMail&lt;span style=""&gt;            &lt;/span&gt;: mailtoaman@gmail.com&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;Date&lt;span style=""&gt;             &lt;/span&gt;: 14 AUG 2007&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;License&lt;span style=""&gt;          &lt;/span&gt;: GNU Public License&lt;span style=""&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;    &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;span style=""&gt; &lt;/span&gt;(c) Copyright Shaikh Sonny Aman&lt;span style=""&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;              &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;span style=""&gt; &lt;/span&gt;App&lt;span style=""&gt;              &lt;/span&gt;: CommentCount&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;Module&lt;span style=""&gt;           &lt;/span&gt;:&lt;span style=""&gt;&lt;br /&gt;&lt;/span&gt; File&lt;span style=""&gt;             &lt;/span&gt;: CommentCounter.cpp&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;Purpose&lt;span style=""&gt;          &lt;/span&gt;: This application will count the comments in source files&lt;br /&gt;&lt;span style=""&gt;                  &lt;/span&gt;&lt;span style=""&gt;  &lt;/span&gt;and print a metric result.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;                &lt;p class="MsoNormal" style=""&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;span style=""&gt; &lt;/span&gt;Known Issues:&lt;span style=""&gt;        &lt;br /&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;History&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;^^^^^^^&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;Author&lt;span style=""&gt;                 &lt;/span&gt;Date&lt;span style=""&gt;        &lt;/span&gt;Modification&lt;br /&gt;----------------------------------------------------------------------&lt;br /&gt;&lt;span style=""&gt; &lt;/span&gt;AMAN&lt;span style=""&gt;             &lt;/span&gt;14 AUG 2007&lt;span style=""&gt;       &lt;/span&gt;Initial Creattion&lt;o:p&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 10pt; font-family: &amp;quot;Courier New&amp;quot;; color: green;"&gt;*/&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-2495627497367886872?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/2495627497367886872/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=2495627497367886872' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2495627497367886872'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2495627497367886872'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/typical-source-file-header.html' title='A typical source file header'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-7544997648127487175</id><published>2007-08-14T14:49:00.000+06:00</published><updated>2008-12-12T07:31:15.855+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Software Review'/><category scheme='http://www.blogger.com/atom/ns#' term='CVS'/><category scheme='http://www.blogger.com/atom/ns#' term='TortoiseCVS'/><category scheme='http://www.blogger.com/atom/ns#' term='Versioning'/><title type='text'>Use versioning… an easy solution --- TortoiseCVS.</title><content type='html'>Perhaps, most of us have been fallen under situation when we wished if we could get a earlier version of our work!Hence rises the importance of versioning and using some versioning tools like SourceSafe, Source Off Site and of course the CVS.&lt;br /&gt;&lt;br /&gt;Most probably, CVS is the most widely used version controlling tool. Though undoubtedly, it has some very good features, but unfortunately as well, it is a command line tool; furthermore it is mainly for Unix/Linux. For this, we face little bit problems using this excellent tool.&lt;br /&gt;&lt;br /&gt;Now, TortoiseCVS is an CVS front end built for Windows® platform and the installer also installs CVSNT, a cvs tool for Windows®.&lt;br /&gt;&lt;br /&gt;It is the easiest CVS tool I have ever used. You can right click on a folder or a document and add it to CVS. You can commit, update, view history, view change graph, diff and get any version by simply right click.&lt;br /&gt;&lt;br /&gt;Here are some screenshots:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_jfutjUkDQjE/RsFtRT1WuTI/AAAAAAAAABA/UK34Z7TiBsc/s1600-h/totoise1.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_jfutjUkDQjE/RsFtRT1WuTI/AAAAAAAAABA/UK34Z7TiBsc/s320/totoise1.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5098476397309376818" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_jfutjUkDQjE/RsFtRj1WuUI/AAAAAAAAABI/6oVq94PoWcs/s1600-h/totoise2.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_jfutjUkDQjE/RsFtRj1WuUI/AAAAAAAAABI/6oVq94PoWcs/s320/totoise2.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5098476401604344130" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_jfutjUkDQjE/RsFtRz1WuVI/AAAAAAAAABQ/tEOSZUMIQG4/s1600-h/totoise3.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_jfutjUkDQjE/RsFtRz1WuVI/AAAAAAAAABQ/tEOSZUMIQG4/s320/totoise3.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5098476405899311442" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_jfutjUkDQjE/RsFtSD1WuWI/AAAAAAAAABY/ElMTbX_vw4s/s1600-h/totoise4.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_jfutjUkDQjE/RsFtSD1WuWI/AAAAAAAAABY/ElMTbX_vw4s/s320/totoise4.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5098476410194278754" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-7544997648127487175?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/7544997648127487175/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=7544997648127487175' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/7544997648127487175'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/7544997648127487175'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/use-versioning-easy-solution.html' title='Use versioning… an easy solution --- TortoiseCVS.'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_jfutjUkDQjE/RsFtRT1WuTI/AAAAAAAAABA/UK34Z7TiBsc/s72-c/totoise1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-2112633451315119554</id><published>2007-08-09T14:46:00.000+06:00</published><updated>2007-08-09T15:11:11.437+06:00</updated><title type='text'>Parse command line and some utility functions</title><content type='html'>I was assigned to write a dictionary module for a huge MFC project. The library as well as the executable has to be fully compliance with standard c++.&lt;br /&gt;&lt;br /&gt;Now, I have to write a parser. I know I don't really have to write one, as there is already many out in the net. Why to make the wheel again ? Well known answer -- as I can :)&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;//Declare&lt;/span&gt;&lt;br /&gt;wstring CLGetKeyValue(wstring cl ,wstring key, wstring::size_type pos=0);&lt;br /&gt;void ParseCommandLine(wstring cl,wstring::size_type pos=0);&lt;br /&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;std::map &amp;lt;wstring,wstring&amp;gt;  tb;&lt;o:p&gt;&lt;/O:P&gt;&lt;/span&gt;&lt;/p&gt;&lt;wstring,wstring&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;&lt;br /&gt;//this is for parsing&lt;/span&gt;&lt;br /&gt;&lt;/wstring,wstring&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;void&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;  ParseCommandLine(wstring cl,wstring::size_type pos)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;{&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;wstring::size_type p1 = cl.find(L&lt;span style="color:maroon;"&gt;"-"&lt;/span&gt;,pos);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt;((&lt;span style="color:blue;"&gt;int&lt;/span&gt;)p1 &lt; style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;wstring::size_type p2 = cl.find(L&lt;span style="color:maroon;"&gt;" -"&lt;/span&gt;,p1+1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt;((&lt;span style="color:blue;"&gt;int&lt;/span&gt;)p2 &lt; style=""&gt;               &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;p2 = cl.length();&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;wstring pair =&lt;span style=""&gt;  &lt;/span&gt;cl.substr(p1,(p2-p1));&lt;span style=""&gt;          &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;int&lt;/span&gt; mid =  (&lt;span style="color:blue;"&gt;int&lt;/span&gt;)pair.find(L&lt;span style="color:maroon;"&gt;"  "&lt;/span&gt;);&lt;span style=""&gt;            &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;       &lt;/span&gt;tb.insert(make_pair&lt;wstring,wstring&gt;(pair.substr(1,mid-1),pair.substr(mid+1,pair.length())))  ;&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/wstring,wstring&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;       &lt;/span&gt;ParseCommandLine(cl,p2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;//This checks the presence of a key&lt;/span&gt;&lt;br /&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;color:blue;"   &gt;inline&lt;/span&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; CLHasKey(wstring cl,wstring  key)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;{&lt;span style=""&gt;           &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt;((&lt;span style="color:blue;"&gt;int&lt;/span&gt;)cl.find(L&lt;span style="color:maroon;"&gt;"-"&lt;/span&gt;+key+L&lt;span style="color:maroon;"&gt;" "&lt;/span&gt;)  &lt; style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt; 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt;  1;&lt;span style=""&gt;   &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;}&lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;//It returns the key value, assumed that the key is present&lt;/span&gt;&lt;br /&gt;&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;wstring  CLGetKeyValue(wstring cl, wstring key, wstring::size_type  pos)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;{&lt;span style=""&gt;     &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:green;"&gt;//should be  checked CLHasKey(cl,key);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;wstring::size_type p1 = cl.find(L&lt;span style="color:maroon;"&gt;"-"&lt;/span&gt;,pos);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt;((&lt;span style="color:blue;"&gt;int&lt;/span&gt;)p1 &lt; style=""&gt;    &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt; L&lt;span style="color:maroon;"&gt;""&lt;/span&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;wstring::size_type p2 = cl.find(L&lt;span style="color:maroon;"&gt;" -"&lt;/span&gt;,p1+1);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt;((&lt;span style="color:blue;"&gt;int&lt;/span&gt;)p2 &lt; style=""&gt;               &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;p2 = cl.length();&lt;span style=""&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;wstring pair =&lt;span style=""&gt;  &lt;/span&gt;cl.substr(p1,(p2-p1));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;int&lt;/span&gt; mid =  (&lt;span style="color:blue;"&gt;int&lt;/span&gt;)pair.find(L&lt;span style="color:maroon;"&gt;"  "&lt;/span&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;if&lt;/span&gt;(  key.compare(pair.substr(1,mid-1)) ==0 )&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;            &lt;/span&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt;  pair.substr(mid+1,pair.length());&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;}&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;&lt;span style=""&gt;      &lt;/span&gt;&lt;span style="color:blue;"&gt;return&lt;/span&gt;  CLGetKeyValue(cl,key,p2);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style=";font-family:'Courier New';font-size:10;"  &gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-2112633451315119554?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/2112633451315119554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=2112633451315119554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2112633451315119554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2112633451315119554'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/parse-command-line-and-some-utility.html' title='Parse command line and some utility functions'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-8676099920740858597</id><published>2007-08-08T18:03:00.000+06:00</published><updated>2007-08-08T18:08:11.796+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>Why message maps, How message maps</title><content type='html'>&lt;o:p&gt;&lt;span style="font-size:78%;"&gt;&lt;span style="font-style: italic; font-weight: bold;"&gt;( The article is taken from Kanitkar's book)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;//comserver visitors ... :D )&lt;/span&gt;&lt;/o:p&gt;&lt;br /&gt;&lt;p class="MsoNormal"&gt;Instead of using message maps we can think of using virtual functions to convert a message into a call to an appropriate handler. To understand how virtual functions can be used, look at the following code segment:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Class CFrameWnd&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;virtual void OnPaint(){}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Class myframe : public CFrameWnd&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Myframe()&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;Create(0,”Draw”);&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Void OnPaint(){}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;class myapp : public CWinApp&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;public:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;BOOL InitInstance()&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;Myframe *p;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;p = new myframe;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;m_pMainWnd = p;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;p-&gt;ShowWindow(SW_SHOWMAXIMIZED);&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;                        &lt;/span&gt;return TRUE;&lt;/p&gt;  &lt;p class="MsoNormal" style="text-indent: 0.5in;"&gt;}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;myapp a;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Here, &lt;b style=""&gt;myapp&lt;/b&gt; is the application class and &lt;b style=""&gt;a&lt;/b&gt; is the global application object. &lt;b style=""&gt;myframe&lt;/b&gt; is the frame window class. The compiler creates a table called &lt;b style=""&gt;VTABLE&lt;/b&gt; for each class that contains virtual functions and for the classes derived from it. The compiler places the address of the virtual functions for the particular class in the &lt;b style=""&gt;VTRABLE&lt;/b&gt;. If you don’t redefine a function that was declared virtual in the base class, the compiler uses the address of the base class version in the derived class’s &lt;b style=""&gt;VTABLE&lt;/b&gt;. When objects of the base class or derived class are created the compiler secretly places a pointer called &lt;b style=""&gt;vpointer&lt;/b&gt; (abbreviated as &lt;b style=""&gt;vptr&lt;/b&gt;) in the object. This pointer points to the class’s &lt;b style=""&gt;VTABLE&lt;/b&gt;.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The &lt;b style=""&gt;vptr&lt;/b&gt; is placed at the beginning of the object and is initialized to point to the starting address of its class’s &lt;b style=""&gt;VTABLE&lt;/b&gt;. This initialization is done in the constructor. All of this – setting up the &lt;b style=""&gt;VTABLE&lt;/b&gt; for each class, initializing the &lt;b style=""&gt;vptr&lt;/b&gt;, inserting the code for the virtual function call – all happens automatically. The &lt;b style=""&gt;VTABLE&lt;/b&gt;s for the two classes &lt;b style=""&gt;CFrameWnd&lt;/b&gt; and &lt;b style=""&gt;myframe&lt;/b&gt; are shown in the following figure:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;table class="MsoNormalTable" style="margin-left: -0.25pt; border-collapse: collapse;" border="0" cellpadding="0" cellspacing="0"&gt;  &lt;tbody&gt;&lt;tr style=""&gt;   &lt;td style="border-style: solid none solid solid; border-color: black -moz-use-text-color black black; border-width: 1pt medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197"&gt;   &lt;p class="MsoNormal" style=""&gt;VTABLE of CFrameWnd&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color black; border-width: medium medium medium 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;br /&gt;&lt;/td&gt;   &lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 148.1pt;" valign="top" width="197"&gt;   &lt;p class="MsoNormal" style=""&gt;VTABLE of myframe&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt;  &lt;tr style=""&gt;   &lt;td style="border-style: none none solid solid; border-color: -moz-use-text-color -moz-use-text-color black black; border-width: medium medium 1pt 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197"&gt;   &lt;p class="MsoNormal" style=""&gt;&amp;CFrameWnd::OnPaint&lt;/p&gt;   &lt;/td&gt;   &lt;td style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color black; border-width: medium medium medium 1pt; padding: 0in 5.4pt; width: 2.05in;" valign="top" width="197"&gt;   &lt;p class="MsoNormal" style=""&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;br /&gt;&lt;/td&gt;   &lt;td style="border-style: none solid solid; border-color: -moz-use-text-color black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 148.1pt;" valign="top" width="197"&gt;   &lt;p class="MsoNormal" style=""&gt;&amp;myframe::OnPaint&lt;/p&gt;   &lt;/td&gt;  &lt;/tr&gt; &lt;/tbody&gt;&lt;/table&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;In the 16-bit version of MFC, the MFC window classes were registered with &lt;b style=""&gt;AfxWndProc&lt;/b&gt;() as the message handler. In this function all the messages used to get handled. Since the 32-bit version of MFC, instead of &lt;b style=""&gt;AfxWndProc&lt;/b&gt; () the MFC window classes are registered with &lt;b style=""&gt;DefWindowProc&lt;/b&gt; () as a window procedure. Even now all the messages are ultimately routed to AfxWndProc () from where they are dispatched to various &lt;b style=""&gt;CWnd&lt;/b&gt;-derived objects. Why all messages still end up in &lt;b style=""&gt;AfxWndProc&lt;/b&gt;() has something to do with MFC’s message hook mechanism&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Had a virtual function been used for converting a message into a call to the appropriate handler, the window procedure would have looked like this:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;CFrameWnd *p;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;p = AfxGetApp()-&gt;m_pMainWnd;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;p-&gt;OnPaint();&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Here, &lt;b style=""&gt;AfxGetApp &lt;/b&gt;() fetches the address of the global application object (created from myapp). m_pMainWnd is a public data member of the &lt;b style=""&gt;CWinApp&lt;/b&gt; class. This data member contains the address of the &lt;b style=""&gt;myframe&lt;/b&gt; object assuming that the window is built using the &lt;b style=""&gt;myframe&lt;/b&gt; class. In the statement,&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;p = AfxGetApp()-&gt;m_pMainWnd&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;we are storing the address of a derived class object in a pointer to the base class object. When we call the &lt;b style=""&gt;OnPaint&lt;/b&gt; () it must be determined whether the &lt;b style=""&gt;OnPaint&lt;/b&gt; () handler &lt;b style=""&gt;CFrameWnd&lt;/b&gt; class or one in the &lt;b style=""&gt;myframe&lt;/b&gt; class should get called. To determine this, contents of &lt;b style=""&gt;p&lt;/b&gt; issued. &lt;span style=""&gt; &lt;/span&gt;&lt;b style=""&gt;p&lt;/b&gt; contains address of the &lt;b style=""&gt;myframe&lt;/b&gt; object. First two bytes starting at this address contain the &lt;b style=""&gt;vptr&lt;/b&gt;. The &lt;b style=""&gt;vptr&lt;/b&gt; points to the address of the &lt;b style=""&gt;VTABLE&lt;/b&gt; belonging to &lt;b style=""&gt;myframe&lt;/b&gt; class. From this &lt;b style=""&gt;VTABLE&lt;/b&gt;, the address of &lt;b style=""&gt;myframe&lt;/b&gt;::&lt;b style=""&gt;OnPaint&lt;/b&gt;() is obtained and the control is transferred to this address. Thus, it is the derived class’s (&lt;b style=""&gt;myframe&lt;/b&gt;’s) &lt;b style=""&gt;OnPaint&lt;/b&gt;() which gets called. Had &lt;b style=""&gt;OnPaint&lt;/b&gt;() not been declared as virtual in &lt;b style=""&gt;CFrameWnd&lt;/b&gt; class then through&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;p-&gt;OnPaint();&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;the &lt;b style=""&gt;CFrameWnd::OnPaint&lt;/b&gt; () would have been called.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This in effect means that for every possible message that &lt;b style=""&gt;CFrameWnd&lt;/b&gt; object is going to receive there must be a virtual function in it. Otherwise we would never be able to override it in a class derived from &lt;b style=""&gt;CFrameWnd&lt;/b&gt;. This would lead to a huge virtual table. Message maps are a MFC’s way avoiding this lengthy virtual table.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Another difficulty with virtual tables arises in case of user-defined messges. Suppose we write a handler, say fun() in the &lt;b style=""&gt;myframe&lt;/b&gt; class. And now to call it if we say &lt;b style=""&gt;p-&gt;fun(),&lt;/b&gt; an error will result. This is because fun() has not been defined as virtual in the &lt;b style=""&gt;CFrameWnd&lt;/b&gt; class. The difficulty is we do not have the source code of the &lt;b style=""&gt;CFrameWnd&lt;/b&gt; class hence cannot make the virtual declaration. In effect it means that we cannot tackle user-defined messages through the mechanism of &lt;b style=""&gt;&lt;i style=""&gt;virtual&lt;/i&gt;&lt;/b&gt; functions.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Let’s now understand the mechanism of message maps. Any class derived from &lt;b style=""&gt;CCmdTarget&lt;/b&gt; can contain a message map. What MFC does internally to implement a message map hidden behind some rather complex macros. To understand the message mechanism consider the following small code snippet:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;class myframe:public CFrameWnd&lt;/p&gt;  &lt;p class="MsoNormal"&gt;{&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;Void OnPaint(){}&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;DECLARE_MESSAGE_MAP()&lt;/p&gt;  &lt;p class="MsoNormal"&gt;};&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;BEGIN_MESSAGE_MAP()&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt;            &lt;/span&gt;ON_WM_PAINT()&lt;/p&gt;  &lt;p class="MsoNormal"&gt;END_MESSAGE_MAP()&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The macros DECLARE_MESSAGE_MAP(),BEGIN_MESSAGE_MAP() AND END_MESSAGE_MAP() have been defined in the file ‘afxwin.h’. During preprocessing the DECLARE_MESSAGE_MAP macro adds three members to the class declaration:&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;(a) a private array of structures called &lt;b style=""&gt;_messageEntries[]&lt;/b&gt;. Each element of this array is a structure called AFX_MSGMAP_ENTRY. In addition to other elements, this structure contains a message id and a pointer to a function that should get called when a message with this id arrives.&lt;/p&gt;  &lt;p class="MsoNormal" style="text-align: justify;"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;(b) a structure called &lt;b style=""&gt;messageMap&lt;/b&gt;. This structure contains a pointer to class's &lt;b style=""&gt;_messageEntries[]&lt;/b&gt; aray and a pointer to base class/s &lt;b style=""&gt;messageMap&lt;/b&gt; structure.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;( c) A virtual function called &lt;b style=""&gt;GetMessageMap&lt;/b&gt; () that returns &lt;b style=""&gt;messageMap&lt;/b&gt; structure's address.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Not that the &lt;b style=""&gt;_messageEntries[]&lt;/b&gt; arrray and the &lt;b style=""&gt;messageMap&lt;/b&gt; structure are static members of the class. This means there is one instance of them. The begin BEGIN_MESSAGE_MAP() macro contains the implementation of the &lt;b style=""&gt;GetMessageMap&lt;/b&gt;() function and the code to initialize the &lt;b style=""&gt;messageMap&lt;/b&gt; structure. The macros that appears between BEGIN_MESSAGE_MAP() and END_MESSAGE_MAP() fill in the &lt;b style=""&gt;_messageEntries[]&lt;/b&gt; array. Finally,END_MESSAGE_MAP() marks the end of the &lt;b style=""&gt;_messageEntries[] &lt;/b&gt;array with a &lt;b style=""&gt;NULL&lt;/b&gt; entry. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;With this infrastructure in place let us now understand how a message passed to the application window gets converted into a call to the appropriate message handler.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Suppose a message, say WM_&lt;b style=""&gt;PAINT&lt;/b&gt;, gets posted in the message queue. This message would be retrieved by the &lt;b style=""&gt;GetMEssage&lt;/b&gt;() function and would be dispatched to the &lt;b style=""&gt;AfxWndProc&lt;/b&gt;() function by the &lt;b style=""&gt;DispatchMessage&lt;/b&gt;() function. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Inside the &lt;b style=""&gt;AfxWndProc&lt;/b&gt;() function, the framework retrieves the C++ object associated with the window handle using &lt;b style=""&gt;CWnd::FromHandlePermanent&lt;/b&gt;() function. &lt;b style=""&gt;AfxWndProc&lt;/b&gt;() then calls that object’s ( the one derived using &lt;b style=""&gt;FromHandlePermanent&lt;/b&gt;() ) &lt;b style=""&gt;WindowProc&lt;/b&gt;() function. The &lt;b style=""&gt;WindowProc&lt;/b&gt;() function gets the address of &lt;b style=""&gt;myframe&lt;/b&gt;’s &lt;b style=""&gt;messageMap&lt;/b&gt; structure. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;As discussed earlier, this structure contains the address of &lt;b style=""&gt;_messageEntrioes[]&lt;/b&gt; array. The id of the message picked up from the message queue is now searched in this array. If the entry is found then the handler corresponding to it is immediately called (as you may recollect, &lt;b style=""&gt;the _messageEntries[]&lt;/b&gt; contains message ids and the names of their handlers). &lt;/p&gt;  &lt;p class="MsoNormal"&gt;If the message id is not found in the &lt;b style=""&gt;_messageEntries[]&lt;/b&gt; array of the &lt;b style=""&gt;mainframe&lt;/b&gt; class then the &lt;b style=""&gt;_messageEntries[]&lt;/b&gt; array of the &lt;b style=""&gt;myframe&lt;/b&gt;’s base class is searched. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;But how can we reach the &lt;b style=""&gt;_messageEntries&lt;/b&gt;[] array of base class? This is achieved using the pointer to the base class’s &lt;b style=""&gt;messageMap&lt;/b&gt; structure, which is stored in &lt;b style=""&gt;myframe&lt;/b&gt;’s &lt;b style=""&gt;messageMap&lt;/b&gt; structure. If the base class does not have the handler for the message the framework ascends another level and consults base class’s base class, systematically working its way to the inheritance chain until it finds the message handler or it has reached the father of all classes. If it still cannot find the message handler then the framework passes the misusage to &lt;b style=""&gt;&lt;i style=""&gt;Windows&lt;/i&gt;&lt;/b&gt; for default processing. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The MFC’s message mapping mechanism amounts to an efficient way of connecting messages to message handlers without using virtual functions. In contrast to virtual tables the amount of memory used by message maps is proportional to the number of message entries it contains.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-8676099920740858597?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/8676099920740858597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=8676099920740858597' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/8676099920740858597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/8676099920740858597'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/why-message-maps-how-message-maps.html' title='Why message maps, How message maps'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-6065993107052969597</id><published>2007-08-05T16:39:00.000+06:00</published><updated>2007-08-05T16:42:49.768+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='গল্প'/><title type='text'>বিকালে বিপদ</title><content type='html'>&lt;div class="postmsg"&gt;      &lt;p&gt;&lt;strong&gt;&lt;em&gt;(পুরানো কাগজের মাঝে খুজে পেলাম। সাত বছর আগে লিখা )&lt;/em&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;রিক্সার ওপর বসে আছি। রিক্সা রাস্তার ওপর বসে আছে। আর রিক্সাচালক বসে আছে রিক্সার পেছনে। বসে বসে অসহায় চেইনটাকে ক্লান্তিহীন ভাবে নাড়াচ্ছে। যশোর এয়ারপোর্ট থেকে ক্যান্টনমেন্ট গেট পর্যন্ত এই নিয়ে তৃতীয়বার। ভেবে দেখলাম, আমি যতবারই কোন 'মহৎ' উদ্দেশ্যে বের হই, ততবারই কোন না কোনভাবে ধরা খাই। ভাগ্যের এই পরিহাস বড়ই নির্মম।&lt;br /&gt;&lt;br /&gt;তাছাড়া আর কি'বা ব্যাখ্যা দিব, বলেন ? বিমান বাহিনীতে বৈমানিক হিসেবে কমিশন পাবার পর পোস্টিং হল যশোরে। ভেবেছিলাম উইকএন্ডে ঢাকায় গিয়ে রোশনীর সাথে ধুমসে ঘোরাঘুরি করব। কিন্তু প্রথম উইকএন্ডেই অনুমতি চেয়ে ব্যর্থ হলাম। কিন্তু, "লাভ কে লিয়ে কুচভী করেগা" মুভিটাও সেদিন দেখলাম; তাই কাউকে না বলে চুপি চুপি চলে আসি ঢাকা এবং ফিরে আসামত্রই ধরা খাই যথারীতি। ফলস্বরূপ, আগামী দুই মাস "নো উইকএন্ড"।&lt;br /&gt;&lt;br /&gt;কিন্ত, সমস্য সেটা না। বর্তমান সমস্যা হল রোশনী এখন যশোরে। তাও মাত্র চারদিনের জন্য। ঠিক রবি থেকে বুধ - যে কয়দিন সারাদিন থাকে ফ্লাইং আর বিকেলে পি.টি.। দেখা করার সুযোগ কোথায়, বলুন তো? এখন, আমি যদি এই চরম সংকটে পি.টি. ফাঁকি দিয়ে শহরে যাই, তবে কি আমাকে খুব বেশি দোষ দেয়া যায় ? এবং পরপর তিনদিনই যদি স্কোয়াড্রন লীডার আসাদ স্যার( আমার ফ্লাইং ইন্স্ট্রাক্টর ) আমাকে দেখে ফেলে, সেটাকেও তো খুব অস্বাভাবিক বলা যায় না তাই না? ? তাই আজ সকালে স্যার যখন তাঁর গম্ভীর মুখটাকে আরও গম্ভীর করে ঠান্ডা গলায় বল্লেন, "পি.টি. টাইমে যেন কাউকে শহরে না দেখি, ওকে ? আদারওয়াইজ, ইউ অল উইল হ্যাভ দ্য জোক"-- তখন ব্যাপারটাকে খুব স্বাভাবিক ভাবেই নেই। তাই আজ চতুর্থবারের মত পি.টি. টাইমে আমার শহরে আসাটা নিশ্চই আপনাদের কাছেও স্বাভাবিক লাগছে।&lt;br /&gt;&lt;br /&gt;"নাইমা পড়েন, রিস্কা আর যাবেনানে।" ঊর্ধমুখি রিক্সাচালকের উদাসী কথায় আবার রাস্তায় ফিরে আসি।পকেট থেকে ভাড়া মিটিয়ে চুপচাপ আরেকটি রিক্সায় চাপি। চারটায় "ওয়েসিস"-এ পৌছানোর কথা। এখন বাজে তিনটা পন্চাশ।&lt;br /&gt;&lt;br /&gt;আমার ঘড়িতে যখন কাঁটায় কাঁটায় চারটা এক, তখন আমি ওয়েসিস পোছাই। কিন্তু প্রতিদিনকার নির্দিষ্ট টেবিলটা (প্রায়) ফাঁকা। 'ও' নেই। নিজের মনে একটু হাসি। সামরিক কর্মকর্তা হিসেবে আমি বরাবরই প্রচন্ড পাঙ্চুয়াল, হাজার হোক রোশনী একজন 'সিভিলিয়ান'। তার দেরী হতেও পারে। দেরীর জন্য মনে মনে তাকে ক্ষমা করার স্বর্গীয় আনন্দে সময় গুনতে থাকি বসে বসে।&lt;br /&gt;&lt;br /&gt;মিনিট দুই না যেতেই হাজির হল ও'। সশব্দে চেয়ার টেনে সামনে বসল। চেহারাটা গম্ভীর। অনুমান ভুল না হলে, তার অপূর্ব নাকটার দু'পাশের ত্বক সামান্য কুঁচকে থাকার কারনটা সম্ভবত 'কিছুটা' বিরক্তি। বুঝলাম, সামথিং ইজ রঙ।&lt;br /&gt;&lt;br /&gt;"কেমন আছ, রোশনী?" মিষ্টি হাসি দেই ( অবশ্য রোদে পোড়া, ভাঁজ খাওয়া চেহারায় সেই হাসির মিষ্টতা নিয়ে কারও সন্দেহ জাগলে আমি দায়ী নই )।&lt;br /&gt;"দেরী করলে কেন?", নির্লিপ্ত প্রশ্ন।&lt;br /&gt;"মানে ?! বরং তুমিই তো.. না মানে রিক্সা... মানে ... দেখ মাত্র..." অবাক এবং ঝাঁঝাল অনুভূতির মিশ্রনটা এক নিমিষে ভ্যাবাচ্যাকায় রুপান্তরিত হয় দুইটা জিনিস খেয়াল হওয়ায়। ওভারকনফিডিন্সের জন্য আমি ঘড়িটাকে পাঁচ মিনিট স্লো রাখি, দ্বীতিয়ত, টেবিলের পাশে আগে থেকেই নিরীহভাবে পড়ে থাকা ব্যাগটা আমি চিনতে পেরেছি।&lt;br /&gt;"তোমার দেরী দেখে আমি ফোন করি। তুমি বেরিয়ে এসেছ শুনে আবার ফিরে আসলাম। আচ্ছা, তুমি কবে একটু পাঙ্চুয়াল হবে, বলেতো ?", এটকু বলে সে তার লোভনীয় ঠোঁটের বাম কোনাটা সামান্য প্রসারিত করে। আসলে, বোধহয় এটা প্রসারন নয়, এটি একটি মিষ্টি হাসি। ডিফেন্স অফিসারদের স্ত্রীর মর্যাদা এক Rank সিনিয়র ধরা হয়, অদূর ভবিষ্যতে রোশনীর যোগ্যতা বোধহয় আমার থেকে অন্তত দুই rank ওপরেই হবে। ও'র জন্য গর্বে আমার বুকটা ফুলে ওঠে। কিন্তু পরক্ষনেই আবার চুপসে যায় তার কথায়----&lt;br /&gt;&lt;br /&gt;"আজ কিন্তু আমি ছয়টা পর্যন্ত থাকব"।&lt;br /&gt;&lt;br /&gt;সময় হিসেবে বিকেল ছয়টা হয়ত তেমন গুরুত্বপূর্ন নয়, তবে এটা হল সেই সময় যখন আসাদ স্যার ভাবীকে আনতে শহরে যায়। কাঁটায় কাঁটায় ছয়টা বাজতে রোশনী উঠল।&lt;br /&gt;"চল, আমাকে একটু এগিয়ে দাও"&lt;br /&gt;"দেখ , ইয়ে, আমার একটা সমস্যা আছে এখন"&lt;br /&gt;দুই সেকেন্ড নিরব বিরতি।&lt;br /&gt;"তাই নাকি, কি সমস্যা ?" গলার স্বরে যুগপত বরফের কাঠিন্য ও শীতলান।&lt;br /&gt;"না, মানে, এক স্যার, মানে এখনই...." বুঝিনা, এত নার্ভাস হয়ে যাই কেন ওর সামনে। অথচ অফিসার হিসেবে আমি কিন্তু .... বুঝতেই পারছেন।&lt;br /&gt;"আচ্ছা,থাক তাহলে। যখন এতই ভয় পাচ্ছ তুমি তাহলে এখানেই চুপচাপ বসে থাক, আমি চল্লাম। ও হ্যাঁ, এক ঘন্টার আগে বেরিও না কিন্তু।", একটা হান্ড্রেড পার্সপন্ট ভুবনমোহিনী হাসি উপহার দিয়ে বল্ল। গলার স্বরটাও যেন একটু বেশি মিষ্টিই লাগল। তার প্রতি কৃতজ্ঞতা ও ভালোলাগায় মনটা অাপ্লুত হত যাচ্ছিল প্রায়... হঠাৎ হোঁচট খেয়ে থেমে গেল। সুগার কোটেট কুইনিন ক্যাপসুল গিলতে গিয়ে মুখের ভেতরেই যেন ভেঙ্গে গেল। আমার সুপার সেনসিটিভ অনুভূতি জানান দিল মিষ্টি প্রলেপের ভেতর আছে কুইনিনের মত সূক্ষ অপমানের ছোঁয়া। আর, আপনারা এতক্ষনে নিশ্চই টের পেয়েছেন, আনার Ego এবং ব্যক্তিত্ব অত্যন্ত প্রবল।&lt;br /&gt;&lt;br /&gt;চিন্তা করে বের করি, ওয়েসিস থেকে ঠিক বিশ পা এগোলেই ওর নানার বাড়ি যাবার গলি, যেখানে ও' এখন যাবে। ইনশাল্লাহ পার পেয়ে যাব।&lt;br /&gt;"আশ্চর্য, তুমি যে কি বল না!! কিসের ভয়? চল", আত্মবিশ্বাসে ভরপুর দৃপ্ত উত্তর আমার।&lt;br /&gt;&lt;br /&gt;বেরিয়ে আসি খোলা রাস্তার ধূলিময় মুক্ত বাতাসে। ওর সুকোমল হাতটা ধরে আবেগঘন দশ পা এগোনোর পর হঠাৎ আমার অভিজ্ঞ চোখের কোনে কি যেন ধরা পড়ে। তাকিয়ে দেখি দ্রুত অগ্রসারমান একটা কালচে ধূসর হেলমেট। T-37 জেট প্লেনের ডুয়াল ককপিটের পাশাপাশি আসনে আসাদ স্যারকে সবসময় ধূসর হলেমেট পরা অবস্থাতেই দেখি। চিনতে তাই একমুহুর্তও দেরী হলনা।&lt;br /&gt;&lt;br /&gt;গত দু'বছেরে কঠোর প্রশিক্ষন আর পেশাগত শৃংখলার পুরস্কার হিসেবে গড়ে ওঠা সহজাত রিফ্লেক্স আমাদের অহংকার। ঝট করে ডান পায়ে মাটিতে ধাক্কা দিয়ে, বাম পা'টা ব্যালে ড্যান্সের ভঙ্গিমায় এগিয়ে দিয়ে নিমেষেই পাশের দোকানে শরীরটা ঢুকিয়ে দেই অপূর্ব দক্ষতায়। তবে সব মহান কর্মেরই ছোট্ট কোন ত্রুটি থাকা স্বাবাবিক, আমার এই সুনিপুন কর্মটাও এর ব্যতিক্রম নয়। আমার ডান পা'টা নিরাপদে মাটি স্পর্শ করার ঠিক আগের মুহুর্তে দরজার কোনে একটু বেধে যায়। যে কারনে হীট সীকার মিজাইলের মত নিক্ষিপ্ত হই কাউন্টারের ওপর। উপুড় হয়ে। এই সামান্য শব্দ সহ। এটা দেখে অভিভূত হয়ে কো আঁতেল সাহিত্যিক হয়ত বর্ননা দিতেন, "বিকট শব্দযোগে অমসৃন ভূপাতন"। কিন্তু আমি একজনা দ্বায়িত্ববার, বিশিষ্ট সামরিক কর্মকর্তা, সাহিত্যিক নই।&lt;br /&gt;&lt;br /&gt;দোকানী তার চোখমুখ উজ্জল করে জিজ্ঞস করল, "কে মরিছে ভাই? ক্যাম্ভায়? খুব দুরুতো সার্ভিস লাগবে, বুঝতে পারিছি, কুন পরোব্লেম নাই, আমার কাছে আগর বাতি, কাফন, খাটিয়া...."। টুপি পরা ভদ্রলোকের থুতনীতে ঝুলন্ত মুঠো পরিমান দাড়ির শিল্পিত কাঁপন থেকে চোখ সরিয়ে চারপাশে চোখ বুলিয়ে বুঝতে পারি এটা "আখেরী বিদায়" জাতীয় দোকান।&lt;br /&gt;&lt;br /&gt;দ্রুত সমালে উঠি আমার এই "আকস্মিক অনভিপ্রেত ভারসাম্যহীনতা জনিত বিহ্বলতা" থেকে। অভ্যস্ত হাতে বাঁকা হয়ে ঝুলে থাকা সানগ্লাসটা নাকের ওপর সোজা করে পুন:স্থাপন করি। দুহাত পকেটে পুরে দৃঢ় পদক্ষেপে বেরিয়ে আসি। রোশনীকে বোঝানোর জন্য স্মার্টলী বলা শুরু করি,&lt;br /&gt;" একচুয়ালী, ব্যাপারটা হল, ইন্সটিঙ্কটিভ রিফ্লেক্স, তুমি তো জানই এজ এ ডিফেন্স অফিসার.... " মাঝ পথে থেমে যাই। সামনে রোশনী নেই। চলে গেল নাকি ?! বড় আশা নিয়ে ডান দিকে ফিরি, তার পথের দিকে। নেই। দিগুন আশা নিয়ে ধীরে ধীরে বাম দিকে তাকাই।&lt;br /&gt;&lt;br /&gt;অতি পরিচিত কাঠামোটা দেখতে পাই। হাতের ইশারায় ডাকছে। আবেগের তীব্রতায় বুঝি একটা বিট মিস্ও করি। তবে প্রবল এই অনুভূতির উচ্ছাসকে ঠিক "ভালোলাগা" না বলে নিখাদ আতঙ্ক বলে সংজ্ঞায়িত করাই বোধহয় বেশি যুক্তিযুক্ত। আটকে থাকা দীর্ঘশ্বাসটা মুক্ত করে রওনা দেই  বাইকে বসা আসাদ সারের দিকে।&lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-6065993107052969597?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/6065993107052969597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=6065993107052969597' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/6065993107052969597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/6065993107052969597'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/blog-post.html' title='বিকালে বিপদ'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-4549891183147834903</id><published>2007-08-05T15:50:00.000+06:00</published><updated>2007-08-05T16:02:11.063+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MFC'/><title type='text'>Why calling SetWindowText in PreSubclassWindow does not work for a Dialog</title><content type='html'>&lt;p&gt; The OnInitDialog() follows the PreSubClassWindow(). So any initialization done in PreSubClassWindow() will be overwritten by the initializations that take place in OnInitDialog().&lt;/p&gt;&lt;p&gt;For this, say we called SetWindowText(L" My Dialog")  in PreSubClassWindow(). After a while when OnInitDialog() is being processed, a call to SetWindowText is called with the Caption which can be set using the VS dialog editor.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Another point I would like to mention in this regard.&lt;/p&gt;&lt;p&gt;In normal window handling, we will have an &lt;b&gt;OnCreate&lt;/b&gt; handler that is invoked just as the window is created. In normal MFC window handling, we have the &lt;b&gt;PreCreateWindow&lt;/b&gt; virtual method which lets us change the &lt;b&gt;CREATESTRUCT&lt;/b&gt; values, such as style parameters.&lt;/p&gt;  &lt;p&gt;These are not accessible in dialogs. The reason is that the members of the subclass can be invoked only when the window is mapped into MFC, that is, its handler has been changed to be the &lt;b&gt;AfxWnd&lt;/b&gt; handler. But dialog controls are created long before the subclassing, which takes place on the first &lt;b&gt;DoDataExchange&lt;/b&gt; handler, which happens during the &lt;b&gt;OnInitDialog&lt;/b&gt; processing. This is far too late.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;PreSubclassWindow&lt;/b&gt; is an ideal place to make certain modifications, such as changing styles. This applies only to those styles which have an effect after the window has been created (many styles cannot be changed once the window is created. We can change the style bits( as like as calling SetWindowText as discussed above ), but the window itself is oblivious to these changes). &lt;/p&gt;&lt;p&gt;This is useful when the styles you want to change are not part of the styles presented by the dialog editor.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-4549891183147834903?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/4549891183147834903/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=4549891183147834903' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4549891183147834903'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/4549891183147834903'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/08/why-calling-setwindowtext-in.html' title='Why calling SetWindowText in PreSubclassWindow does not work for a Dialog'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-2652122697656534127</id><published>2007-06-14T18:11:00.000+06:00</published><updated>2007-06-14T18:12:49.031+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='j2se'/><title type='text'>Responsive Java, Fast Java !</title><content type='html'>&lt;div class="postmsg"&gt;জাভার বিরুদ্ধে সবচাইতে বড় অভিযোগ এটা রেসপন্স করতে দেরী করে, তাই ব্যাবহারকারীর কাছে এটা অনেক স্লো মনে হয়। অথচ, আমরা চাইলেই SwingUtils.invokeLater()ব্যাবহার করে আমাদের প্রোডাক্টকে আরও রেসপন্সিভ করতে পারি সহজেই।&lt;br /&gt;&lt;blockquote&gt;&lt;div class="incqbox"&gt;&lt;p&gt;jButton1.addActionListener(new java.awt.event.ActionListener()&lt;br /&gt;{&lt;br /&gt;     public void actionPerformed(java.awt.event.ActionEvent evt)&lt;br /&gt;    {&lt;br /&gt;                SwingUtils.invokeLater&lt;br /&gt;                (&lt;br /&gt;                  new Runnable()&lt;br /&gt;                  {&lt;br /&gt;                        JOptionPane.showMessageDialog(null, "You clicked me : ) ");&lt;br /&gt;                  }&lt;br /&gt;                )&lt;br /&gt;    }&lt;br /&gt;});&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;বেশি ভেজাল মনে  হলে একটা Action ক্লাস বানিয়ে নিন, যেটাতে এটা ইমপ্লিমেন্টেড থাকবে।&lt;br /&gt;&lt;br /&gt;Action class use করা খুবই মজার হতে পারে, তা নিয়ে আরেকদিন আলোচনা করব ইনশাল্লাহ &lt;img src="http://forum.projanmo.com/img/smilies/smile.png" alt="smile" /&gt;&lt;/p&gt;     &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-2652122697656534127?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/2652122697656534127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=2652122697656534127' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2652122697656534127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/2652122697656534127'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/06/responsive-java-fast-java.html' title='Responsive Java, Fast Java !'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-5556671788096424370</id><published>2007-06-14T17:47:00.000+06:00</published><updated>2007-06-14T17:55:11.004+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Shell'/><title type='text'>dos2unix all files in current directory using find -exec</title><content type='html'>&lt;span style="color: rgb(0, 0, 153); font-weight: bold;font-family:courier new;" &gt;$find . -exec dos2unix {} \&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153); font-family: times new roman;font-family:courier new;font-size:100%;"  &gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span&gt;Sometimes we copy some source code from windows to Linux and try to compile them. The result is often&lt;br /&gt;very unexpected and likely to have no clue whats the wrong! Most of the time it is due to nothing but the  file format difference in Linux and windows.&lt;br /&gt;&lt;br /&gt;dos2unix comes from almost all Linux distributions. it converts an windows file to Linux format.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 153); font-weight: bold;font-family:courier new;" &gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;span style="font-family:times new roman;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-5556671788096424370?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/5556671788096424370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=5556671788096424370' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/5556671788096424370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/5556671788096424370'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/06/dos2unix-all-files-in-current-directory.html' title='dos2unix all files in current directory using find -exec'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1467120539710232930.post-5990044967400877000</id><published>2007-06-14T17:05:00.000+06:00</published><updated>2007-06-14T17:56:14.801+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Shell'/><title type='text'>Change file name case to lower in linux</title><content type='html'>&lt;span style="color: rgb(0, 0, 153);"&gt;$for i in *; do mv $i `echo $i | tr [:upper:] [:lower:]`; done&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I am working on a project using MainSoft's MainWin. It converts and compiles vc6 projects in linux. MainWin provides a tool calls 'mwgenmake' which creates a makefile from the project file. Sometimes, it is required to have all the filename in lower case.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;The code above is collected.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1467120539710232930-5990044967400877000?l=blog.amanpages.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.amanpages.com/feeds/5990044967400877000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1467120539710232930&amp;postID=5990044967400877000' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/5990044967400877000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1467120539710232930/posts/default/5990044967400877000'/><link rel='alternate' type='text/html' href='http://blog.amanpages.com/2007/06/change-file-name-case-to-lower-in-linux.html' title='Change file name case to lower in linux'/><author><name>Shaikh Sonny Aman</name><uri>http://www.blogger.com/profile/17751820346652780433</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://farm3.static.flickr.com/2013/1667037624_5aaa441e14_m.jpg'/></author><thr:total>3</thr:total></entry></feed>
