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

<channel>
	<title>Gramant</title>
	<atom:link href="http://blog.gramant.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gramant.com</link>
	<description>Gramant corporate blog</description>
	<lastBuildDate>Fri, 29 Apr 2011 07:21:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Easily manage transactions in Python by using WITH statement</title>
		<link>http://blog.gramant.com/2011/04/29/python-transactions-with-statement/</link>
		<comments>http://blog.gramant.com/2011/04/29/python-transactions-with-statement/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 07:21:58 +0000</pubDate>
		<dc:creator>Сергей Нековаль</dc:creator>
				<category><![CDATA[Без категории]]></category>
		<category><![CDATA[decorator]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[transaction]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://blog.gramant.com/?p=851</guid>
		<description><![CDATA[Writing a convenient and decent-looking wrapper for working with transactions is a favorite pastime for many developers. Transactions must be able to start, finish and rollback properly, and they can also be nested. Python is a multifaceted language (or, as speechwriters say, &#8220;Multi-paradigm&#8221;), giving us innumerable ways of doing it.
As a foundation, I usually use [...]]]></description>
			<content:encoded><![CDATA[<p>Writing a convenient and decent-looking wrapper for working with transactions is a favorite pastime for many developers. Transactions must be able to start, finish and rollback properly, and they can also be nested. Python is a multifaceted language (or, as speechwriters say, &#8220;Multi-paradigm&#8221;), giving us innumerable ways of doing it.<span id="more-851"></span></p>
<p>As a foundation, I usually use Python DB API (namely, <code>psycopg2</code> module). The API itself is rather low-level and is crying for improvement. What can be done?</p>
<p>Initially, let&#8217;s just make an ordinary decorator for opening and closing a transaction:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;color: #5C5F4A;">@transactional<span style="color: black;color: #CCC;">&#40;</span>db<span style="color: black;color: #CCC;">&#41;</span>
<span style="color: #ff7700;font-weight:bold;color: #B83A24;">def</span> do_database_stuff<span style="color: black;color: #CCC;">&#40;</span><span style="color: black;color: #CCC;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;color: #B83A24;">return</span> db.<span style="color: black;">fetchall</span><span style="color: black;color: #CCC;">&#40;</span><span style="color: #483d8b;color: #666666;">'select * from employee'</span><span style="color: black;color: #CCC;">&#41;</span></pre></div></div>

</p>
<p>here <code>db</code> represents a small helper class, which monitors the opening and closing of cursors, and also contains  connection management code.</p>
<p>Our decorator is not quite cool. On the one hand, it does everything correctly and properly closes the transaction with any outcome; on the other hand, we need to write a separate function for every transaction. This is somewhat messy.</p>
<p>Lets try to write it down as a lambda expression:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;color: #5C5F4A;">transactional<span style="color: black;color: #CCC;">&#40;</span>db<span style="color: black;color: #CCC;">&#41;</span><span style="color: black;color: #CCC;">&#40;</span><span style="color: #ff7700;font-weight:bold;color: #B83A24;">lambda</span>:db.<span style="color: black;">fetchall</span><span style="color: black;color: #CCC;">&#40;</span><span style="color: #483d8b;color: #666666;">'select * from employee'</span><span style="color: black;color: #CCC;">&#41;</span><span style="color: black;color: #CCC;">&#41;</span><span style="color: black;color: #CCC;">&#40;</span><span style="color: black;color: #CCC;">&#41;</span></pre></div></div>

</p>
<p>Certainly not the cleanest line of code in the Python world. Incidentally, it is easy to make mistakes and miss the last pair of brackets.</p>
<p>To make us all happy, Python 2.5 offers a special new syntax for executable blocks, allowing better flow control of block entrance/exit. Such blocks are very common in the management of system resources: files, sockets, semaphores, etc.</p>
<p>This is how it will look like:</p>
<p>
<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;color: #5C5F4A;"><span style="color: #ff7700;font-weight:bold;color: #B83A24;">from</span> <span style="color: #dc143c;color: #8FB394;">__future__</span> <span style="color: #ff7700;font-weight:bold;color: #B83A24;">import</span> with_statement
&nbsp;
<span style="color: #ff7700;font-weight:bold;color: #B83A24;">with</span> db.<span style="color: black;">transaction</span><span style="color: black;color: #CCC;">&#40;</span><span style="color: black;color: #CCC;">&#41;</span> <span style="color: #ff7700;font-weight:bold;color: #B83A24;">as</span> tx:
    <span style="color: #ff7700;font-weight:bold;color: #B83A24;">def</span> employees = db.<span style="color: black;">fetchall</span><span style="color: black;color: #CCC;">&#40;</span><span style="color: #483d8b;color: #666666;">'select * from employee'</span><span style="color: black;color: #CCC;">&#41;</span></pre></div></div>

</p>
<p>This is just one of the possible options. We have named object, <code>tx</code>, specified in the with-expression, representing our transaction. We can later place some useful methods into <code>tx</code>.</p>
<p>How with-expression interacts with an associated object (in our case <code>tx</code>)? There are two agreements:</p>
<ol>
<li><code>obj.__enter__()</code> is always invoked before entering with-block.</li>
<li>Any way out of with-block always causes a special method <code>obj.__exit__(type, value, traceback)</code> method to be invoked, where all three parameters will be filled only when an error occurs (typically for Python, they represent type of exception, the exception object and the call stack, respectively).</li>
</ol>
<p>In our case, everything is quite simple:</p>
<ul>
<li>We make an <code>__enter__</code> method to open the transaction and perform any connection management logic.</li>
<li>Our <code>__exit__</code> callback will be closing the transaction. The simplest implementation would be to always execute always <code>commit</code> on succuss, and if the with-block threw an exception, always try to do <code>rollback </code>. In real life, of course, this is not enough &#8211; you have to keep track of what kind of exception were thrown.</li>
</ul>
<p>Python also makes sure that the call to <code>return</code> inside with-block will just as well be &#8220;filtered&#8221; by <code>__exit__ </code> callback.</p>
<p>What are the disadvantages of managing transactions via with-blocks? First of all, with-statement is not a function in terms of Python. For example, we can not repeat the execution of the block in the <code>__exit__</code> callback (in case of decorators this can easily be achieved, allowing to program any retry logic).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gramant.com/2011/04/29/python-transactions-with-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Helping multilingual teams</title>
		<link>http://blog.gramant.com/2011/03/10/helping-multilingual-teams/</link>
		<comments>http://blog.gramant.com/2011/03/10/helping-multilingual-teams/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 15:10:56 +0000</pubDate>
		<dc:creator>Denis</dc:creator>
				<category><![CDATA[Без категории]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://blog.gramant.com/?p=845</guid>
		<description><![CDATA[We have customers and partners in different countries, and not all of them can comfortably communicate in English. We use trac for bug tracking and documentation. So we wrote and maintain a plugin for trac, that uses Google Translate to translate ticket descriptions and user comments to the language specified in the user preferences.


The plugin [...]]]></description>
			<content:encoded><![CDATA[<p>We have customers and partners in different countries, and not all of them can comfortably communicate in English. We use <a href="http://trac.edgewall.org/">trac</a> for bug tracking and documentation. So we <a href="http://trac-hacks.org/wiki/GoogleTranslatePlugin">wrote and maintain a plugin</a> for trac, that uses <a href="http://translate.google.com/">Google Translate</a> to translate ticket descriptions and user comments to the language specified in the user preferences.</p>
<p><img src="http://blog.gramant.com/wp-content/uploads/2011/03/translate1.png" alt="Translate" title="Translate" width="430" height="216" class="alignnone size-full wp-image-847" /><br />
<img src="http://blog.gramant.com/wp-content/uploads/2011/03/translate2.png" alt="Translation" title="Translation" width="430" height="216" class="alignnone size-full wp-image-848" /></p>
<p><a href="http://trac-hacks.org/wiki/GoogleTranslatePlugin">The plugin home page.</a></p>
<p>Please try it out!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gramant.com/2011/03/10/helping-multilingual-teams/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why do we like Balsamiq Mockups</title>
		<link>http://blog.gramant.com/2011/02/08/why-do-we-like-balsamiq-mockups/</link>
		<comments>http://blog.gramant.com/2011/02/08/why-do-we-like-balsamiq-mockups/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 15:05:57 +0000</pubDate>
		<dc:creator>Anatol</dc:creator>
				<category><![CDATA[Без категории]]></category>

		<guid isPermaLink="false">http://blog.gramant.com/?p=803</guid>
		<description><![CDATA[A couple of months ago we started experimenting with Balsamiq Mockups. It’s a compact and very simple program with which to build wire-frame models of user interfaces. By way of example, below is one of the screens that we have drawn using it in Russian.

When we started to experiment with Balsamiq I could not have [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of months ago we started experimenting with Balsamiq Mockups. It’s a compact and very simple program with which to build wire-frame models of user interfaces. By way of example, below is one of the screens that we have drawn using it in Russian.</p>
<p><img class="aligncenter size-large wp-image-821" title="Sample Balsamiq mock-up" src="http://blog.gramant.com/wp-content/uploads/2011/02/7_general_settings_edit-1024x862.png" alt="Sample Balsamiq mock-up" width="1024" height="862" /></p>
<p>When we started to experiment with Balsamiq I could not have imagined how much this program would affect our development process and how many radical changes it would bring.</p>
<p>We develop business applications and developing online banking, online advertising and CRM are a very significant proportion of our work. We have developed some publicly available applications that include a large non client facing administration component. For example, we’ve built an E-commerce system, where about 15 screens are publicly available, while the in house admin component includes about 40 different screens, and continues to grow.</p>
<p>It’s also important that we don’t have our own graphics designers and UX designers on the team. Why? It’s probably a subject that warrants a separate post.</p>
<p>Before Balsamiq Mockups we would develop functional requirements and then make “the requirements for the designer”. These requirements we would then pass to a graphics designer with UX designer skills or an UX designer with graphics designer skills and then pass them onto the other. As they are all external contractors, they have their own schedules and priorities which may not always fit with that of the project. They can only afford to allocate a specific amount of time to the project and in this time need to draw all the screens.</p>
<p><img class="aligncenter size-full wp-image-839" title="Our development process BEFORE" src="http://blog.gramant.com/wp-content/uploads/2011/02/before_balsamiq_en2.png" alt="Our development process BEFORE" width="678" height="360" /></p>
<p>We need to continually communicate with the designer, discuss screen drafts, and try to pass on our knowledge and understanding of the business to them. Trust me, it’s quite involved process. If everything goes smoothly and our designer grasps the idea and successfully implements the design then in a month or so we would get the screens and move forward.</p>
<p>What is important here? In fact, the work of designer comprises two major parts:</p>
<p>1.    Analytical part &#8211; to decide what functionality needs to go into/onto each screen; and</p>
<p>2.    UX part &#8211; to pick and place interface elements on the screen, and do it in an optimal manner</p>
<p>The problem is that for a UX designer the analytical part requires a deep understanding of the complex business models which is time consuming and duplicates the work that we did at the beginning of the project in order to write the project requirements. Designers often have little interest in doing the analysis.</p>
<p>After we mastered Balsamiq, we plucked up the courage so instead of writing requirements for UX designers we started to draw interfaces ourselves. Although there is complex logic in Web systems such as AI, workflows, maths and graphics they are essentially flat. Between 50-80% of functionality of a typical Web app is shuffling data between front-end and DB.</p>
<p>It’s our project manager or analyst who understands the client’s business and requirements and communicates with customer and they draw the screens. This means that we can put the screens together pretty quickly. The output is a set of wireframes instead of a long specification document, which is then passed to the UX designers. This simplifies the process and makes it more efficient.</p>
<p><img class="aligncenter size-full wp-image-823" title="Development process AFTER" src="http://blog.gramant.com/wp-content/uploads/2011/02/after_balsamiq_en.png" alt="Development process AFTER" width="757" height="303" /></p>
<p>Now the mission of UX designers is to make highly-usable user friendly screens from our purely functional drawings preserving their functional integrity. After a few completed projects using Balsamiq the quality of our “pre-screens” have improved so much that in some cases we have done the UX part as well. After all it’s not rocket science.</p>
<p>As a consequence we get some interesting results. There is no need to write cumbersome requirements; most of them can now be expressed graphically using wireframes.</p>
<p>There is one more important benefit in that we now get the opportunity to embed UX design into our Agile-process. Our development speed has increased significantly, the stage of project ”acceleration” is considerably shortened.</p>
<p>Also communication with our customers has improved. Instead of discussing long texts we can talk graphical screens, which facilitates understanding between us and our client, which is one of the key elements in the success of any project.</p>
<p>It’s quite possible that there are better prototyping programs than Balsamiq Mockups. We selected it based on reviews and ratings. We tested it, liked it and bought it.  Balsamiq Mockups meets our requirements and does exactly what we need.  And it&#8217;s not that common in software industry.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gramant.com/2011/02/08/why-do-we-like-balsamiq-mockups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

