<?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>@ecito</title>
	<atom:link href="http://eci.to/feed/" rel="self" type="application/rss+xml" />
	<link>http://eci.to</link>
	<description>I like shiny things</description>
	<lastBuildDate>Thu, 28 Oct 2010 12:15:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Interview questions (and my answers)</title>
		<link>http://eci.to/2010/10/interview-questions-and-my-answers/</link>
		<comments>http://eci.to/2010/10/interview-questions-and-my-answers/#comments</comments>
		<pubDate>Thu, 28 Oct 2010 11:11:52 +0000</pubDate>
		<dc:creator>ecito</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://eci.to/?p=135</guid>
		<description><![CDATA[So in getting ready for the plenty of interviews I&#8217;m hoping to get *hint hint*, I googled &#8220;interview questions software ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Feci.to%2F2010%2F10%2Finterview-questions-and-my-answers%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Feci.to%2F2010%2F10%2Finterview-questions-and-my-answers%2F&amp;source=ecito&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f470da22571f7f0090976c64408093ff" height="61" width="50" /><br />
			</a>
		</div>
<div class="wp-caption aligncenter" style="width: 385px"><img title="Awesome" src="http://farm1.static.flickr.com/126/420118457_b8ae6981a6.jpg" alt="" width="375" height="500" /><p class="wp-caption-text">(random flickr pic)</p></div>
<p style="text-align: left;">
<p>So in getting ready for the plenty of interviews I&#8217;m hoping to get *hint hint*, I googled &#8220;interview questions software engineer&#8221; and found this <a href="http://www.noop.nl/2009/01/100-interview-questions-for-software-developers.html" target="_blank">list of 100 questions</a> covering a wide range of topics in CS. Watch me try to answer them to the best of my knowledge and make a fool out of myself (or google them and provide links/references). Hopefully this will save you (Mr. Hiring Manager) some time in determining my capacity as a software engineer.</p>
<p>This will also serve as a good record for myself in a few years to determine how I&#8217;ve progressed from a baby newbie developer to a semi-newbie developer (I&#8217;m very modest). This <a href="http://www.indiangeek.net/wp-content/uploads/Programmer%20competency%20matrix.htm" target="_blank">Programmer Competency Matrix</a> has certainly served as a guiding light throughout my CS degree to know what I&#8217;m expected to know out there.</p>
<p>Anyways, here it goes&#8230; answers to 100 questions. This is going to take a while&#8230; The questions are categorized by:</p>
<p style="padding-left: 30px;"><span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#Requirements">Requirements</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#FunctionalDesign">Functional Design</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#TechnicalDesign">Technical Design</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#Construction">Construction</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#Algorithms">Algorithms</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#DataStructures">Data Structures</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#Testing">Testing</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#Maintenance">Maintenance</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#ConfigurationManagement">Configuration Management</a><br />
<span style="font-family: 'Lucida Console'; line-height: normal; font-size: 11px;">· </span><a href="#ProjectManagement">Project Management</a></p>
<h2><a name="Requirements"></a>Requirements</h2>
<p>1. Can you name a number of non-functional (or quality) requirements?</p>
<p style="padding-left: 30px;">&#8220;Database should be able to return 50,000  queries a second&#8221;, &#8220;All API calls should respond within 100ms&#8221;,  &#8221;The background color of every page should be blue&#8221;&#8230; etc.</p>
<p style="padding-left: 30px;"><a href="http://www.stellman-greene.com/2010/02/17/nonfunctional-requirements-qa/" target="_blank">This</a> was a good read.</p>
<p>2. What is your advice when a customer wants high performance, high usability and high security?</p>
<p style="padding-left: 30px;">What does high performance mean? how much security is high security? what is high usability?</p>
<p>3. Can you name a number of different techniques for specifying requirements? What works best in which case?</p>
<p style="padding-left: 30px;">* User stories &#8212; works best for listing the expectations the customer has of the system.<br />
* Functional specification &#8212; works best internally to figure out and document the technical details related to solving the user&#8217;s problem.<br />
* Storyboards &#8212; works best for describing how the user is going to interact with the system.<br />
* UI Mockups &#8212; works best for detailing the look and feel of the presentation layer exposed to the user.</p>
<p>4. What is requirements tracing? What is backward tracing vs. forward tracing?</p>
<p style="padding-left: 30px;">I didn&#8217;t know about this, but hey, thanks <a href="http://en.wikipedia.org/wiki/Requirements_Traceability">wikipedia</a>.</p>
<p>5. Which tools do you like to use for keeping track of requirements?</p>
<p style="padding-left: 30px;">Usually project management tools such as redmine, basecamp, JIRA, etc. It should be easy/quick to use and not get in the way.</p>
<p>6. How do you treat changing requirements? Are they good or bad? Why?</p>
<p style="padding-left: 30px;">They should be expected and embraced. By adhering to good software design principles, fast iterations and a quick feedback loop, changing requirements should not be an issue at all. Hurray for agile.</p>
<p>7. How do you search and find requirements? What are possible sources?</p>
<p style="padding-left: 30px;">I&#8217;m not sure why I would want to search for requirements. Maybe as in implicit requirements that the user might be expecting but didn&#8217;t specify? In that case I&#8217;d look at competing solutions, or ask the user what they are basing their assumptions on.</p>
<p>8. How do you prioritize requirements? Do you know different techniques?</p>
<p style="padding-left: 30px;">The customer can handle that after specifying the user stories. If they don&#8217;t care what gets implemented first, then internally I would pick some of the basic requirements to get something out the door quickly for the customer to see and comment on.</p>
<p>9. Can you name the responsibilities of the user, the customer and the developer in the requirements process?</p>
<p style="padding-left: 30px;">The customer and developer would work on building the list of requirements and prioritizing them, and then validating them against the user.</p>
<p>10. What do you do with requirements that are incomplete or incomprehensible?</p>
<p style="padding-left: 30px;">Ask the customer to clarify.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="FunctionalDesign"></a>Functional Design</h2>
<p>1. What are metaphors used for in functional design? Can you name some successful examples?</p>
<p>2. How can you reduce the user&#8217;s perception of waiting when some functions take a lot of time?</p>
<p style="padding-left: 30px;">Preload stuff, distract them with something else, give good indicators of progression and a feeling that very important work is being done.</p>
<p>3. Which controls would you use when a user must select multiple items from a big list, in a minimal amount of space</p>
<p style="padding-left: 30px;">A select box (&lt;select multiple=&#8221;yes&#8221;&gt;) or a custom matrix with fancy jQuery depending on what kind of items. On a mobile UI, probably just a tableview that you can scroll and touch to select items.</p>
<p>4. Can you name different measures to guarantee correctness of data entry?</p>
<p style="padding-left: 30px;">Validations should exist both at the front-end and back-end. jQuery can be used for character-by-character checking as the user types, and warn them of problems. Once submitted, further validations should be used before saving something to DB.</p>
<p>5. Can you name different techniques for prototyping an application?</p>
<p style="padding-left: 30px;">Paper and pen, Powerpoint/keynotes, UI mockups, WYSIWYG editors, imagination&#8230;</p>
<p>6. Can you name examples of how an application can anticipate user behavior?</p>
<p style="padding-left: 30px;">With magic&#8230; If the user is at a screen with very few branches, and high probabilities that a specific action will be taken, then take that into account&#8230; For instance if you&#8217;re asking for confirmation for some long process just go ahead and start the process if possible and cancel it if the user says no. (most browsers do this when downloading a file, they just start downloading away before you even choose a folder to save the file in).</p>
<p>7. Can you name different ways of designing access to a large and complex list of features?</p>
<p style="padding-left: 30px;">Categorize them, focus on good UX to move between the different contexts, give search, favorite, recently used functionalities for the features.</p>
<p>8. How would you design editing twenty fields for a list of 10 items? And editing 3 fields for a list of 1000 items?</p>
<p style="padding-left: 30px;">20 fields can be laid vertically in 10 columns across the screen. 3 fields could be laid out horizontally as a cell of a one column table with 1000 cells.</p>
<p>9. What is the problem of using different colors when highlighting pieces of a text?</p>
<p style="padding-left: 30px;">It confuses the user.</p>
<p>10. Can you name some limitations of a web environment vs. a Windows environment?</p>
<p style="padding-left: 30px;">The desktop (not windows) environment, has direct access to the hardware, and thus can run native, more performance specific things. There is also close to 0 lag and practically unlimited bandwidth for data operations (compared to having to contact a server).</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="TechnicalDesign"></a>Technical Design</h2>
<p>1. What do low coupling and high cohesion mean? What does the principle of encapsulation mean?</p>
<p style="padding-left: 30px;">Coupling is how dependent different modules or classes are of each other, so if the coupling is low, that means that we can more easily reuse these components elsewhere, rip stuff out, replace things, etc. High cohesion also helps with this, if methods do one thing, and one thing well, it&#8217;s easier to reuse code and unit test it. If methods are long (low cohesion), it makes it hard to read, understand, debug, test, maintain, decouple, etc&#8230;</p>
<p style="padding-left: 30px;">Encapsulation is just abstracting out details..</p>
<p>2. How do you manage conflicts in a web application when different people are editing the same data?<br />
<a href="http://stackoverflow.com/questions/129329/optimistic-vs-pessimistic-locking" target="_blank"></a></p>
<p style="padding-left: 30px;"><a href="http://stackoverflow.com/questions/129329/optimistic-vs-pessimistic-locking" target="_blank">Optimistic vs Pessimistic locking</a></p>
<p>3. Do you know about design patterns? Which design patterns have you used, and in what situations?</p>
<p style="padding-left: 30px;">MVC for web/mobile apps, delegate pattern in Obj-C, factory pattern for when I need to load up classes dynamically, decorator (in ruby/scala with mixins and traits) to add functionality to an object without affecting the original class, singleton for doing things like API access, facade to abstract awkward frameworks, strategy pattern mainly for building up Model object data structures based on an XML or JSON feed (oh the element is a person, oh the element is a string, oh the element is a number&#8230;. do X, or Y, or Z, etc&#8230;)</p>
<p>4. Do you know what a stateless business layer is? Where do long-running transactions fit into that picture?</p>
<p style="padding-left: 30px;">Not really, and can&#8217;t find any info on what this means.</p>
<p>5. What kinds of diagrams have you used in designing parts of an architecture, or a technical design?</p>
<p style="padding-left: 30px;">I guess UML and  flowcharts. Mostly just whiteboard and talk about it.</p>
<p>6. Can you name the different tiers and responsibilities in an N-tier architecture?</p>
<p style="padding-left: 30px;">Presentation, business logic, model tiers? According to <a href="http://en.wikipedia.org/wiki/Multitier_architecture" target="_blank">this</a>, I guess rails is pretty multi-tier.</p>
<p>7. Can you name different measures to guarantee correctness and robustness of data in an architecture?</p>
<p style="padding-left: 30px;">Unit tests, input validation, database consistency checks, integration tests..</p>
<p>8. Can you name any differences between object-oriented design and component-based design?</p>
<p style="padding-left: 30px;">Not too sure what <a href="http://en.wikipedia.org/wiki/Component-based_software_engineering" target="_blank">component-based design</a> is.</p>
<p>9. How would you model user authorization, user profiles and permissions in a database?</p>
<p style="padding-left: 30px;">Probably have a model object for &#8216;users&#8217; (Andre, John, Winston, etc), then a &#8216;user&#8217; would have many  &#8217;roles&#8217; (admin, moderator, manager, etc), and each &#8216;role&#8217; would have many &#8216;permissions&#8217; (read users, delete users, etc).</p>
<p>10. How would you model the animal kingdom (with species and their behavior) as a class system?</p>
<p style="padding-left: 30px;">Well I just happen to be taking biology right now, so I might make a base class &#8216;Kingdom&#8217;, and have &#8216;Phylum&#8217; inherit from it, then &#8216;Class&#8217; can inherit &#8216;Phylum&#8217;, then &#8216;Order&#8217;, &#8216;Family&#8217;, &#8216;Genus&#8217;, and finally &#8216;Species&#8217; would be at the bottom of this class inheritance structure. Then maybe use abstract factory pattern to make it easier to instantiate objects.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="Construction"></a>Construction</h2>
<p>1. How do you make sure that your code can handle different kinds of error situations?</p>
<p style="padding-left: 30px;">Unit tests! I could either sit there all day trying to break it, or just write unit tests for the intended behavior (both successful and failures) and be done with it (kinda).</p>
<p>2. Can you explain what Test-Driven Development is? Can you name some principles of Extreme Programming?</p>
<p style="padding-left: 30px;">TDD: write a test first, then write the code. Red/green/refactor. TDD helps a lot, not only to write the unit tests that you need, but also to decompose a problem into simpler steps and let your unit tests drive the design of the solution. The code practically writes itself. Some principles of extreme programming are: meet with your team often, have unit tests, integrate often, pair program.</p>
<p>3. What do you care about most when reviewing somebody else&#8217;s code?</p>
<p style="padding-left: 30px;">First of all, it should be easy to read. It should follow all the language&#8217;s coding styles (cases, spacings, indentation, etc) and the language&#8217;s idioms (common design patterns, naming conventions, etc). The code should speak for itself and not really need a bunch of comments everywhere. If it needs comments then its too complex. I don&#8217;t like fancy code, or code that tries to do too much. The more cohesive the code is, the easier it is to read.</p>
<p style="padding-left: 30px;">Also, the other person shouldn&#8217;t feel bad about criticism, or shouldn&#8217;t feel proud and married to their code, otherwise the review is useless.</p>
<p>4. When do you use an abstract class and when do you use an interface?</p>
<p style="padding-left: 30px;">I&#8217;d use an abstract class as a base class for when I care about the type of the object inheriting a certain behavior. I&#8217;d use an interface for more &#8216;abstract&#8217; situations where I don&#8217;t care who uses it, as long as they implement the interface.</p>
<p>5. Apart from the IDE, which other favorite tools do you use that you think are essential to you?</p>
<p style="padding-left: 30px;">The shell is pretty darn essential. Google, unit testing frameworks, continuous integration systems are important as well.</p>
<p>6. How do you make sure that your code is both safe and fast?</p>
<p style="padding-left: 30px;">Unit tests, benchmarks, functional tests.. Avoid global state, avoid goto. Try to make functions pure, and never modify an input argument to a function inside the function.</p>
<p>7. When do you use polymorphism and when do you use delegates?</p>
<p style="padding-left: 30px;">If I don&#8217;t care if  base/extended classes get interchanged I&#8217;d use polymorphism. I&#8217;d use delegates and interfaces for callbacks.</p>
<p>8. When would you use a class with static members and when would you use a Singleton class?</p>
<p style="padding-left: 30px;">Not too sure about this one. I&#8217;d use a singleton if I want to make sure there&#8217;s only one instance of some object during runtime.</p>
<p>9. Can you name examples of anticipating changing requirements in your code?</p>
<p style="padding-left: 30px;">The DRY principle (don&#8217;t repeat yourself) helps a whole lot with this, since we&#8217;d only have to change something once in the code, vs changing the same thing all over the place. High cohesion and low coupling helps. Common design principles such as DIP help in making code less fragile, rigid and immobile. Avoid putting constants throughout code (again DRY).</p>
<p>10. Can you describe the process you use for writing a piece of code, from requirements to delivery?</p>
<p style="padding-left: 30px;">Understand the requirements, write unit tests, code, write functional/integration tests (ideally).</p>
<p style="padding-left: 30px;">
<h2><a name="Algorithms"></a>Algorithms</h2>
<p>1. How do you find out if a number is a power of 2? And how do you know if it is an odd number?</p>
<p style="padding-left: 30px;">According to <a href="http://en.wikipedia.org/wiki/Power_of_two#Fast_algorithm_to_check_if_a_positive_number_is_a_power_of_two" target="_blank">wikipedia</a>: <span style="font-family: sans-serif;">positive <em>x</em> is a power of two if (<em>x</em> &amp; (<em>x</em> − 1)) equals zero.&#8221;</span></p>
<p style="padding-left: 30px;">if n % 2 == 0 is false then its an odd number.</p>
<p>2. How do you find the middle item in a linked list?</p>
<p style="padding-left: 30px;">I guess I&#8217;d have to iterate through the whole list to count the number of elements and then halve it, since there really isn&#8217;t a way to know how big the list is beforehand, unless you keep track of it in the linked list class or something.</p>
<p>3. How would you change the format of all the phone numbers in 10,000 static html web pages?</p>
<p style="padding-left: 30px;">sed. &#8217;nuff sed. (awesome pun intended).</p>
<p>4. Can you name an example of a recursive solution that you created?</p>
<p style="padding-left: 30px;">Oh god, nightmares of 4-5 peg tower of hanoi solvers come to mind. I&#8217;ll usually use recursion to traverse graphs.</p>
<p style="padding-left: 30px;">Recently I&#8217;ve been trying to get the hang of tail recursion in functional style languages that do tail recursion optimization. It really makes the code more expressive.</p>
<p>5. Which is faster: finding an item in a hashtable or in a sorted list?</p>
<p style="padding-left: 30px;">Hashtable. Depending on the data I might use a Trie to make it faster even.</p>
<p>6. What is the last thing you learned about algorithms from a book, magazine or web site?</p>
<p style="padding-left: 30px;">Mostly stuff regarding tail recursion for algorithms and how to implement common algorithms without using mutable variables (in functional languages). Also I&#8217;ve been trying to implement Dijkstra&#8217;s algorithm to get the shortest path in a graph (for routing ala google maps).</p>
<p>7. How would you write a function to reverse a string? And can you do that without a temporary string?</p>
<p style="padding-left: 30px;">A recursive function would do, and wouldn&#8217;t need a temporary/mutable string.</p>
<p>8. What type of language do you prefer for writing complex algorithms?</p>
<p style="padding-left: 30px;">Either a dynamic language, since it won&#8217;t get in the way so much, or a functional language, since functions are pure and will always produce the same output given an input.  Also, they would make it easier to use concurrency to speed up the algorithm. I&#8217;d stay away from weakly typed languages unless I want things to silently blow up.</p>
<p>9. In an array with integers between 1 and 1,000,000 one value is in the array twice. How do you determine which one?</p>
<p style="padding-left: 30px;">Iterate through the array and sum up all the numbers, then subtract from it another computed sum, but using the sum formula  n * (n &#8211; 1) / 2</p>
<p>10. Do you know about the Traveling Salesman Problem?</p>
<p style="padding-left: 30px;">Yes, it&#8217;s about trying to get everywhere you need to go (in a graph) as efficiently as possible. Bees have this algorithm hard-wired in their brain for collecting honey as efficiently as possible.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="DataStructures"></a>Data Structures</h2>
<p>1. How would you implement the structure of the London underground in a computer&#8217;s memory?</p>
<p style="padding-left: 30px;">Using a directed graph.</p>
<p>2. How would you store the value of a color in a database, as efficiently as possible?</p>
<p style="padding-left: 30px;">Hex RGB?</p>
<p>3. What is the difference between a queue and a stack?</p>
<p style="padding-left: 30px;">A queue is FIFO (first in first out), whereas a stack is LIFO (last in first out)</p>
<p>4. What is the difference between storing data on the heap vs. on the stack?</p>
<p style="padding-left: 30px;">The stack stores variables/data before run-time, the heap stores them during run-time</p>
<p>5. How would you store a vector in N dimensions in a datatable?</p>
<p style="padding-left: 30px;">Well, this sounds kind of awkward. Maybe encode it to a string. Otherwise what, create a column for each dimension? Not sure.</p>
<p>6. What type of language do you prefer for writing complex data structures?</p>
<p style="padding-left: 30px;">One that has good, easy to use Enumerate-able , Iterate-able primitives/classes built-in. For instance I like ruby&#8217;s [1, 2, 3] array initialization and {:x =&gt; 2, :y =&gt; 3} hash initialization.</p>
<p style="padding-left: 30px;">The more (useful) data structure libraries the language has the better, I don&#8217;t want to get bogged down having to re-implement a popular data structure.</p>
<p>7. What is the number 21 in binary format? And in hex?</p>
<p style="padding-left: 30px;">10101, 15</p>
<p>8. What is the last thing you learned about data structures from a book, magazine or web site?</p>
<p style="padding-left: 30px;">Mostly simple data structures used in web APIs&#8230; Things like GeoJSON, Open Graph Protocol, KML, etc. They make it easy to instantiate model objects in whatever language you&#8217;re using once you receive them in a message.</p>
<p style="padding-left: 30px;">On that note, I like frameworks that can parse and decompose any xml/json into native arrays and dictionaries/hashes/maps dynamically. Not only decode the primitives like numbers and strings, but also other model objects (makes it quick and easy to communicate model objects with relationships).</p>
<p>9. How would you store the results of a soccer/football competition (with teams and scores) in an XML document?</p>
<p style="padding-left: 30px;">err well this is awkward. I wouldn&#8217;t usually model something in a markup language like this. I think it would be easier to just draw the relationships on a whiteboard, and then the XML is obvious. Also, I&#8217;m not sure what they mean by &#8216;competition&#8217;. Is that just one match? or a tournament? do I need to model the brackets or whatever tournament-y specific stuff? This is probably wrong.</p>
<p style="padding-left: 30px;">&lt;competition&gt;&lt;teams&gt;&lt;team&gt;&lt;/team&gt;&lt;/teams&gt;&lt;matches&gt;&lt;match&gt;&lt;score&gt;&lt;/score&gt;&lt;/match&gt;&lt;/matches&gt;</p>
<p>10. Can you name some different text file formats for storing unicode characters?</p>
<p style="padding-left: 30px;">Err, .txt file encoded with UTF-8? I don&#8217;t know. I&#8217;m ignorant of other methods, UTF-8 seems to the most common and exists in all languages.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="Testing"></a>Testing</h2>
<p>1. Do you know what a regression test is? How do you verify that new changes have not broken existing features?</p>
<p style="padding-left: 30px;">Yes. By running the regression tests, duh.</p>
<p>2. How can you implement unit testing when there are dependencies between a business layer and a data layer?</p>
<p style="padding-left: 30px;">Replace the data layer access with mock objects. The database should be mocked out, since all unit testing is concerned with is testing the logic behind the business layer and that it has the intended behavior. The data shouldn&#8217;t be needed for unit testing (but can be used in functional testing).</p>
<p style="padding-left: 30px;">Also, it would be pretty damn awkward if your unit tests needed to spawn an instance of MSSQL or something every time you wanted to run them. Just fake it. if the code has low coupling this should be trivial.</p>
<p>3. Which tools are essential to you for testing the quality of your code?</p>
<p style="padding-left: 30px;">Unit testing frameworks, code coverage reports, static analysis..</p>
<p>4. What types of problems have you encountered most often in your products after deployment?</p>
<p style="padding-left: 30px;">Usually bugs related to underestimating the capacity of the user to break things. (Which really just reflects poor UX). Also, mostly problems in the deployment itself, when the code encounters different systems and configurations.</p>
<p>5. Do you know what code coverage is? What types of code coverage are there?</p>
<p style="padding-left: 30px;">Yes, the amount of code covered by unit tests. Basically it just gives you green/red for each line of your source code depending on wether it got executed or not. I&#8217;m not sure what are the different types.</p>
<p>6. Do you know the difference between functional testing and exploratory testing? How would you test a web site?</p>
<p style="padding-left: 30px;">I&#8217;m not sure what they mean by exploratory testing. Maybe like UI testing? I&#8217;ve used watir for automating the testing of a website. I&#8217;m hoping to someday tackle the javascript needed to automate UI testing on iOS 4.0</p>
<p>7. What is the difference between a test suite, a test case and a test plan? How would you organize testing?</p>
<p style="padding-left: 30px;">A test suite tests a whole class, a test case tests a specific intended behavior of a method. Not sure what a test plan is. I might organize testing by having a /test folder alongside /src and use the same class name adding _test.xxx or Test.xxx at the end, depending on the language.</p>
<p>8. What kind of tests would you include for a smoke test of an ecommerce web site?</p>
<p style="padding-left: 30px;">Not sure, according to <a href="http://en.wikipedia.org/wiki/Smoke_testing#Smoke_testing_in_software_development" target="_blank">wikipedia</a> I guess I&#8217;d test the basic things like being able to add an item to your cart, go through the payment process, etc.</p>
<p>9. What can you do reduce the chance that a customer finds things that he doesn&#8217;t like during acceptance testing?</p>
<p style="padding-left: 30px;">Iterate and release often. A customer seeing an application for the first time in months in bound to have a lot more things to say vs seeing an application every week.</p>
<p>10. Can you tell me something that you have learned about testing and quality assurance in the last year?</p>
<p style="padding-left: 30px;">I&#8217;m still trying to get used to doing unit testing in any language that I touch. Some make it hard, or feel out of place (objective-c, javascript). Whenever I do manage to make myself write unit tests, the benefits greatly outweigh the effort. Also, I&#8217;ve started to have many AHA! moments doing TDD, managing to solve problems that initially looked very hard. Or if I&#8217;m trying to change/refactor some code, I can just run the unit tests to make sure I didn&#8217;t break anything.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="Maintenance"></a>Maintenance</h2>
<p>1. What kind of tools are important to you for monitoring a product during maintenance?</p>
<p style="padding-left: 30px;">Not too sure about this question. If they mean monitoring a live production environment, then I guess smoke testing, functional testing, GUI testing. There&#8217;s ping services out there that monitor the health of your web service. Or  I could set up a simple cron job that ssh&#8217;s into the boxes and gathers server stats and application logs.</p>
<p>2. What is important when updating a product that is in production and is being used?</p>
<p style="padding-left: 30px;">That the update has been throughly tested and QAed. Ideally</p>
<p>3. How do you find an error in a large file with code that you cannot step through?</p>
<p style="padding-left: 30px;">Can I modify the code? Maybe stick some asserts or exceptions in there or maybe have a &#8220;debug&#8221; mode you can turn on to have the program output more detailed logs. I don&#8217;t know what I&#8217;d do if I can&#8217;t modify the code.</p>
<p>4. How can you make sure that changes in code will not affect any other parts of the product?</p>
<p style="padding-left: 30px;">Yes, with regression testing.</p>
<p>5. How do you create technical documentation for your products?</p>
<p style="padding-left: 30px;">With a word template.</p>
<p>6. What measures have you taken to make your software products more easily maintainable?</p>
<p style="padding-left: 30px;">Write easy to read, concise code. Stick to good coding styles and idioms. Write unit tests for bugfixes.</p>
<p>7. How can you debug a system in a production environment, while it is being used?</p>
<p style="padding-left: 30px;">tail -f application.log to see a log file in realtime.</p>
<p>8. Do you know what load balancing is? Can you name different types of load balancing?</p>
<p style="padding-left: 30px;">It&#8217;s basically having an intermediate coordinator between the source of requests and the servers/devices that respond to these requests. By load balancing you can reduce the chances of frying a server, you  since it distributes the work evenly amongst  the servers/devices. I could mention round robin but I can&#8217;t remember how it works exactly.</p>
<p>9. Can you name reasons why maintenance of software is the biggest/most expensive part of an application&#8217;s life cycle?</p>
<p style="padding-left: 30px;">Because it has to stand the test of time, the real-world, users, changing requirements, etc. If a change is needed, it&#8217;s the worst time to have it implemented. You have to step back through all the application lifecycle..</p>
<p>10. What is the difference between re-engineering and reverse engineering?</p>
<p style="padding-left: 30px;">By Re-engineering you&#8217;re just trying to imitate/copy the behavior. To reverse engineer is to break-down and make surrender these poor defenseless binaries, and poke at their private parts to figure out how they work exactly. I believe it&#8217;s legal to reverse engineer unless you&#8217;re trying to circumvent DRM.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="ConfigurationManagement"></a>Configuration Management</h2>
<p>1. Do you know what a baseline is in configuration management? How do you freeze an important moment in a project?</p>
<p style="padding-left: 30px;">Not sure, I guess they just mean the defaults. I&#8217;d freeze an important moment by tagging in git, or whatever version control system.</p>
<p>2. Which items do you normally place under version control?</p>
<p style="padding-left: 30px;">Source code, tests, documentation&#8230; I would try not to put binaries, images, media, large files, etc in version control.</p>
<p>3. How can you make sure that team members know who changed what in a software project?</p>
<p style="padding-left: 30px;">Use a version control management software/service like github, or simply have the source control email all the team members on a post commit hook.</p>
<p>4. Do you know the differences between tags and branches? When do you use which?</p>
<p style="padding-left: 30px;">I&#8217;d use a tag to tag a specific state of code for something like a version number. I&#8217;d branch out to start working on a new feature, maybe for major refactor, or maybe simply just to separate my work from the rest of the team for a while.</p>
<p>5. How would you manage changes to technical documentation, like the architecture of a product?</p>
<p style="padding-left: 30px;">Keep documents in some kind of version controlled system, not necessarily a source code repository.</p>
<p>6. Which tools do you need to manage the state of all digital information in a project? Which tools do you like best?</p>
<p style="padding-left: 30px;">Project management software that integrates to your source code repository and has a sort of wiki or document repository. I like redmine and basecamp. I&#8217;ve used JIRA, Trac and very slightly Microsoft Project.</p>
<p>7. How do you deal with changes that a customer wants in a released product?</p>
<p style="padding-left: 30px;">If its a small change and if it would be unreasonable to deny the change, then simply go ahead (usually trivial for web applications). Otherwise just advise the customer of what will be required (New scope, more QA, redeployment, etc)</p>
<p>8. Are there differences in managing versions and releases?</p>
<p style="padding-left: 30px;">You&#8217;re usually pushing forward when shooting for a new version, and pushing backward (freezing, testing, cutting things out) for a release.</p>
<p>9. What is the difference between managing changes in text files vs. managing changes in binary files?</p>
<p style="padding-left: 30px;">Text files can be easily versioned by line number. Binary files are harder to version and usually just get end up being replaced over and over again for any slight change.</p>
<p>10. How would you treat simultaneous development of multiple RfC&#8217;s or increments and maintenance issues?</p>
<p style="padding-left: 30px;">You got me. What? I guess just rely on the project management software. I don&#8217;t know what this question is about.</p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;">
<h2><a name="ProjectManagement"></a>Project Management</h2>
<p>1. How many of the three variables scope, time and cost can be fixed by the customer?</p>
<p style="padding-left: 30px;">Only two at a time.</p>
<p>2. Who should make estimates for the effort of a project? Who is allowed to set the deadline?</p>
<p style="padding-left: 30px;">The whole team should be involved in estimation. Deadlines should be set by the project manager/SCRUM master.</p>
<p>3. Do you prefer minimization of the number of releases or minimization of the amount of work-in-progress?</p>
<p style="padding-left: 30px;">Minimize the amount of work-in-progress. Releases should be numerous and constant. Always iterate quickly.</p>
<p>4. Which kind of diagrams do you use to track progress in a project?</p>
<p style="padding-left: 30px;">A regular calendar, Gantt chart or a burn down chart. What&#8217;s important is to see how much pressure that looming deadline is putting on you.</p>
<p>5. What is the difference between an iteration and an increment?</p>
<p style="padding-left: 30px;">There&#8217;s many increments in an iteration.</p>
<p>6. Can you explain the practice of risk management? How should risks be managed?</p>
<p style="padding-left: 30px;">Not too sure about this, but here&#8217;s <a href="http://www.projectsmart.co.uk/10-golden-rules-of-project-risk-management.html" target="_blank">10 golden rules</a>.</p>
<p>7. Do you prefer a work breakdown structure or a rolling wave planning?</p>
<p style="padding-left: 30px;">Can I have both? break down the work required for the current (rolling wave) iteration.</p>
<p>8. What do you need to be able to determine if a project is on time and within budget?</p>
<p style="padding-left: 30px;">Take a look at the burn down chart. Also, just gauge the general happiness of the team. If they&#8217;re depressed then you know that probably means things aren&#8217;t going as planned.</p>
<p>9. Can you name some differences between DSDM, Prince2 and Scrum?</p>
<p style="padding-left: 30px;">Not really.</p>
<p>10. How do you agree on scope and time with the customer, when the customer wants too much?</p>
<p style="padding-left: 30px;">Break down the project into phases, deliver a phase and go from there.</p>
<p style="padding-left: 30px;">
<p>Yup, that took a while&#8230; Now to finish reading <a href="http://steve-yegge.blogspot.com/2008/03/get-that-job-at-google.html" target="_blank">this</a> on how to get that job at google (or anywhere else cool) and read these <a href="http://www.basilv.com/psd/blog/2009/100-interview-questions-to-ask-employers" target="_blank">100 interview questions to ask employers</a>.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 1555px; width: 1px; height: 1px; overflow: hidden;"><em>Kingdom, Phylum, Class, Order, Family, Genus, Species</em></div>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://eci.to/2010/10/interview-questions-and-my-answers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hacking MessageParty with HTTParty</title>
		<link>http://eci.to/2010/08/hacking-messageparty-with-httparty/</link>
		<comments>http://eci.to/2010/08/hacking-messageparty-with-httparty/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 01:49:02 +0000</pubDate>
		<dc:creator>ecito</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://ecito.com/?p=67</guid>
		<description><![CDATA[From Mashable: &#8220;MessageParty, an early-stage YCombinator-funded startup, takes the classic concept of a chat room and adds a geosocial twist ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Feci.to%2F2010%2F08%2Fhacking-messageparty-with-httparty%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Feci.to%2F2010%2F08%2Fhacking-messageparty-with-httparty%2F&amp;source=ecito&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f470da22571f7f0090976c64408093ff" height="61" width="50" /><br />
			</a>
		</div>
<p>From Mashable: <a href="http://mashable.com/2010/08/25/messageparty/" target="_blank">&#8220;MessageParty</a>, an early-stage YCombinator-funded startup, takes the classic concept of a chat room and adds a geosocial twist by making any chat room location-aware.&#8221; Here&#8217;s the <a href="http://techcrunch.com/2010/08/24/yc-funded-messageparty-ties-location-with-chat-rooms/" target="_blank">TechCrunch</a> link.</p>
<p>Not a new idea. But the app is actually pretty cool in its simplicity (though still rough around the edges), and I found the video absolutely hilarious and illustrates the new world we live in:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="370" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/BoHl5n1EDBA?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="370" src="http://www.youtube.com/v/BoHl5n1EDBA?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Ok cool&#8230; hacking time now. I&#8217;ve been really interested in <a href="http://ecito.com/2010/08/twitter-streaming-api-node-js-appcelerator-titanium-real-time-tweet-map/" target="_blank">real-time mobile stuff</a> lately, so I was curious on how this service works. Enter <a href="http://www.wireshark.org/" target="_blank">Wireshark</a> (formerly Ethereal), a packet sniffer. So I connect my iPhone to WiFi and started looking around&#8230; they pass around the messages via plaintext HTTP in JSON payloads&#8230; looks like the client polls the server with a GET every few seconds. Simple enough&#8230; Ok let&#8217;s set up a filter &#8220;http &amp;&amp; ip.addr == 184.106.229.49&#8243; (that&#8217;s their server&#8217;s IP) and take a better look:</p>
<p><a href="http://ecito.com/wp-content/uploads/2010/08/wireshark-messageparty.png" rel="lightbox[67]" title="wireshark-messageparty"><img class="size-medium wp-image-69 alignnone" title="wireshark-messageparty" src="http://ecito.com/wp-content/uploads/2010/08/wireshark-messageparty-300x187.png" alt="" width="300" height="187" /></a></p>
<p>Simple enough&#8230; they&#8217;ve got some kind of ruby app up behind the scenes, the client GETs /rooms/:id/roommessages.json to get the new messages, and POSTs to /roommessages.json for outgoing messages. The JSON payload just basically has your profile pic url, your user_id, the room_id and the message you want to send.</p>
<p>Let&#8217;s continue the MessageParty with <a href="http://github.com/jnunemaker/httparty" target="_blank">HTTParty</a>!</p>
<script src="http://gist.github.com/550330.js?file=party.rb"></script><noscript><code><pre style='overflow:auto;margin:0;padding:0;border:1px solid #DDD;'>&lt;html&gt;
&lt;head&gt;&lt;title&gt;301 Moved Permanently&lt;/title&gt;&lt;/head&gt;
&lt;body bgcolor=&quot;white&quot;&gt;
&lt;center&gt;&lt;h1&gt;301 Moved Permanently&lt;/h1&gt;&lt;/center&gt;
&lt;hr&gt;&lt;center&gt;nginx/1.0.13&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></code></noscript>
<p>Fake the headers, fake the JSON payload, cuz they be faking everybody out there &#8230; and voila&#8230;</p>
<p><a href="http://ecito.com/wp-content/uploads/2010/08/messageparty.png" rel="lightbox[67]" title="messageparty"><img class="alignnone size-full wp-image-71" title="messageparty" src="http://ecito.com/wp-content/uploads/2010/08/messageparty.png" alt="" width="320" height="480" /></a></p>
<p>I don&#8217;t mean to be an ass, but this just ain&#8217;t gonna fly&#8230; I didn&#8217;t check if they rate limit, but you can pretty much spoof anything in there&#8230; I know it&#8217;s a very early version, but common guys&#8230; you got YC funding and tons of press.. surely you could have done better for the first version?</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://eci.to/2010/08/hacking-messageparty-with-httparty/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Twitter Streaming API + node.js + Appcelerator Titanium = Real-time tweet map</title>
		<link>http://eci.to/2010/08/twitter-streaming-api-node-js-appcelerator-titanium-real-time-tweet-map/</link>
		<comments>http://eci.to/2010/08/twitter-streaming-api-node-js-appcelerator-titanium-real-time-tweet-map/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 08:23:51 +0000</pubDate>
		<dc:creator>ecito</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://ecito.com/?p=37</guid>
		<description><![CDATA[Let me walk you through my exploration of these new technologies as I get acquainted with them. The objective will be to ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Feci.to%2F2010%2F08%2Ftwitter-streaming-api-node-js-appcelerator-titanium-real-time-tweet-map%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Feci.to%2F2010%2F08%2Ftwitter-streaming-api-node-js-appcelerator-titanium-real-time-tweet-map%2F&amp;source=ecito&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f470da22571f7f0090976c64408093ff" height="61" width="50" /><br />
			</a>
		</div>
<p>Let me walk you through my exploration of these new technologies as I get acquainted with them. The objective will be to display geo-tagged tweets around the world in real-time on a mapview, with the profile pic and tweet info on the annotation (see screenshot below). This can be accomplished in just a few lines of code, less than 100 with the help of some cool new frameworks and libraries.</p>
<h2>Comet?</h2>
<p>There&#8217;s a lot of buzz surrounding the real-time web nowadays, which involves pushing data and events from servers straight to clients just as it happens. There&#8217;s plenty of ways of achieving this, both on the browsers (websockets, long-polling, etc), and on mobile devices (sockets, AMQP clients, etc). The catch-all term is <a href="http://en.wikipedia.org/wiki/Comet_(programming)" target="_blank">Comet</a>.</p>
<p>Here&#8217;s a stackoverflow <a href="http://stackoverflow.com/questions/337985/comet-server-push-to-client-on-iphone" target="_blank">discussion on some of the options on the iPhone</a>. I tried using the STOMP client they mention and setting up an Apache ActiveMQ server (a <a href="http://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol" target="_blank">AMQP</a>) but ideal configurations proved hard to come by. Basically I set up a &#8220;topic&#8221; which is used as a one to many kind of broadcast, but messages were waiting for an acknowledgment from the phone and everything just started to lag for everybody. I&#8217;m sure this can be set up properly, and there&#8217;s other AMQPs I want to try out such as ZeroMQ and RabbitMQ, but it was just a quick test so I didn&#8217;t look too much into it.</p>
<p>On the browser the ideal way of doing push is with WebSockets, though not all browsers support it yet. There&#8217;s a couple workarounds around that, <a href="http://socket.io/" target="_blank">socket.io</a> and <a href="http://github.com/gimite/web-socket-js" target="_blank">web-socket-js</a>. This demo was pretty cool of <a href="http://jeffkreeftmeijer.com/2010/experimenting-with-node-js/" target="_blank">mouse cursors moving around</a> in real-time, and the <a href="http://www.ape-project.org/" target="_blank">APE Ajax push engine</a> also has some sweet demos.</p>
<p>Anyways, there&#8217;s plenty of info around on the web about comet and push. What I&#8217;m going to try to do here is walk you through my first exposures into <a href="http://nodejs.org/" target="_blank">node.js</a> and <a href="http://www.appcelerator.com/products/titanium-mobile-application-development/" target="_blank">Appcelerator Titanium Mobile</a> to get a real-time mashup of tweets on a mapview:</p>
<p style="text-align: center;"><a href="http://ecito.com/wp-content/uploads/2010/08/Screen-shot-2010-08-03-at-12.38.17-AM.png"><br />
</a><a href="http://ecito.com/wp-content/uploads/2010/08/Screen-shot-2010-08-03-at-12.35.50-AM.png" rel="lightbox[37]" title="Oops, left it running for a few minutes"><img class="alignleft size-medium wp-image-40" title="Oops, left it running for a few minutes" src="http://ecito.com/wp-content/uploads/2010/08/Screen-shot-2010-08-03-at-12.35.50-AM-161x300.png" alt="" width="161" height="300" /></a><a href="http://ecito.com/wp-content/uploads/2010/08/Screen-shot-2010-08-03-at-12.38.17-AM.png" rel="lightbox[37]" title="Your book is good, good for you"><img class="size-medium wp-image-42 aligncenter" title="Your book is good, good for you" src="http://ecito.com/wp-content/uploads/2010/08/Screen-shot-2010-08-03-at-12.38.17-AM-161x300.png" alt="" width="161" height="300" /></a></p>
<h2>Twitter Streaming API</h2>
<p>They&#8217;ve had this <a href="http://dev.twitter.com/pages/streaming_api_concepts" target="_blank">API</a> out for a few months now, so there&#8217;s plenty of libraries in a bunch of languages for easily accessing it. It basically involves keeping an HTTP connection open to their servers and continually receive data through that pipe. Twitter is beta testing <a href="http://dev.twitter.com/pages/user_streams" target="_blank">User Streams</a>, which is more suited for user twitter clients. Both of these APIs should eventually help out twitter with their load issues since constant polling by everybody can get pretty heavy. <a href="http://thenextweb.com/socialmedia/2010/07/31/how-user-streams-will-change-your-twitter-experience-forever/" target="_blank">Here are some more advantages</a>.</p>
<p>For the purposes of this demo, and since it&#8217;s all I have access to, we&#8217;ll be using the general purpose public streaming API. You&#8217;ll need a twitter account to be able to use the API, and they are currently using HTTP Auth on it (outside of their HTTP Auth deprecation schedule this month). The default access role grants you 10 boxes of one (lat/lon) degree, which is basically the size of a city. You can request the &#8220;locRestricted&#8221; role which allows 200 boxes of 10 degrees each. This almost covers the entire land-mass of the earth. They don&#8217;t have any way of just querying all geo-located tweets, not even with the firehose access role, so you have to construct your boxes yourself (I checked with their support).</p>
<p>Since my first test was with STOMP and ruby, here&#8217;s some <a href="http://gist.github.com/505934">lame dirty ruby to get a very crude list of  200 boxes around the continents in the format that twitter wants.</a> I couldn&#8217;t fit Asia at all in there, and a bit of Africa got left out&#8230; oh well.</p>
<p>If you just have the default access roles, 10 cities, <a href="http://gist.github.com/505958">then you can try these out</a></p>
<p>Just copy paste the array from the output, and stick into the query below&#8230;</p>
<h2>node.js</h2>
<p>It&#8217;s all the rage now, and for very good reasons. Event based non-blocking stuff is just so awesome. I haven&#8217;t done much with node.js yet other than this demo, but hopefully I&#8217;ll get to use it more soon enough. So basically just go ahead and install <a href="http://nodejs.org/" target="_blank">node.js</a>, it&#8217;s a super simple install.  Naturally there&#8217;s a twitter streaming library for node.js, called twitter-node. Here&#8217;s the <a href="http://github.com/technoweenie/twitter-node.git" target="_blank">github</a> page. Go and clone that somewhere. (I haven&#8217;t explored node.js package managers yet). Be sure to run the build script they have in there to install the base64 library you need.  Grab the boxes array from above and put it in there for the location query (for some reason I couldn&#8217;t make it to 200 boxes with this library).</p>
<p>So basically what we are going to do is create a socket server with node.js on port 6969 and for every new event the twitter library sends us, we&#8217;ll go ahead and push that to the socket, which in turn will push it out to all the clients currently connected. I haven&#8217;t figured out how to close the socket properly if a client was an asshole and didn&#8217;t FIN, leaving the socket in a sort of limbo state. I don&#8217;t know if this even matters, but basically an exception will be thrown for each of those limbo handlers, each time we try to write to it.</p>
<script src="http://gist.github.com/505950.js?file=tweet_proxy.js"></script><noscript><code><pre style='overflow:auto;margin:0;padding:0;border:1px solid #DDD;'>&lt;html&gt;
&lt;head&gt;&lt;title&gt;301 Moved Permanently&lt;/title&gt;&lt;/head&gt;
&lt;body bgcolor=&quot;white&quot;&gt;
&lt;center&gt;&lt;h1&gt;301 Moved Permanently&lt;/h1&gt;&lt;/center&gt;
&lt;hr&gt;&lt;center&gt;nginx/1.0.13&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></code></noscript>  That takes care of the server side&#8230; now to the client side.</p>
<p> </p>
<h2>Appcelerator Titanium Mobile</h2>
<p>I&#8217;m really impressed with <a href="http://www.appcelerator.com/products/titanium-mobile-application-development/" target="_blank">this open source library</a>. It&#8217;s event based javascript as well, with proxies and stuff to turn completely native. It makes so many things extremely simple that are usually a pain in the ass to do natively on both platforms. It&#8217;s still kind buggy and only supports iOS and Android at the moment, but the native builds really feel native. I like their approach to the cross-platform issue, where they try to keep things as unified as possible, but don&#8217;t let that limit themselves, so they also take advantage of each platform&#8217;s individual features. They have a module SDK so you can stick actual Objective-C or Java in there if necessary, and apparently they&#8217;ll be launching a module marketplace soon, along with Blackberry support. <a href="http://www.amlcode.com/2010/07/16/comparison-appinventor-rhomobile-phonegap-appcelerator-webview-and-aml/" target="_blank">Here&#8217;s a great overview of the different cross-platform options</a>.</p>
<p>After trying most of them out, <em>Appcelerator completely outshines them</em>. Rhomobile is cool in that it&#8217;s ruby on rails-esque, write once, and push out to FIVE different platforms (iOS, Android, Blackberry, Windows, Symbian), but it&#8217;s just too slow and fugly (not completely native).</p>
<p>Anyways&#8230; after you get everything set up with Appcelerator, go ahead and create a new project in Titanium (iPhone or iPad, don&#8217;t matter) and put the following code in your app.js. We are just adding a mapview to the window, and some buttons to control the socket connection. When the &#8216;read&#8217; event on the socket gets triggered, meaning a new JSON blob came in, we&#8217;ll parse that and create the corresponding annotation for the tweet. We can easily add a remote image to the annotation for the profile picture using <a href="http://stu.mp/" target="_blank">Joe Stump</a>&#8216;s awesome <a href="http://tweetimag.es/" target="_blank">tweetimag.es</a> service.  <script src="http://gist.github.com/506000.js?file=tweet_flow.js"></script><noscript><code><pre style='overflow:auto;margin:0;padding:0;border:1px solid #DDD;'>&lt;html&gt;
&lt;head&gt;&lt;title&gt;301 Moved Permanently&lt;/title&gt;&lt;/head&gt;
&lt;body bgcolor=&quot;white&quot;&gt;
&lt;center&gt;&lt;h1&gt;301 Moved Permanently&lt;/h1&gt;&lt;/center&gt;
&lt;hr&gt;&lt;center&gt;nginx/1.0.13&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre></code></noscript>
<p>That&#8217;s basically it. There&#8217;s a few bugs, but this isn&#8217;t about perfection, just a quick sample of these new technologies. Scary as it may be, this is pretty much where we are headed towards. A constant flow of real-time information, following us wherever we go. Can&#8217;t wait!</p>
<p>Is this particular application helpful? Maybe. I could see it being used to monitor emergency situations, or some type of big event. Problem is that very few people yet geo-tag their tweets. The average number of normal tweets was <a href="http://mashable.com/2010/06/25/tps-record/" target="_blank">750/second a month ago</a>. Compare that to maybe 10 tweets a second of geo-tagged tweets&#8230;</p>
<p>Notes:</p>
<p>With the access role I have and the boxes I use, I&#8217;m getting about 5 tweets a second on the map. Don&#8217;t go thinking that the iPhone can support that many total annotations on the map like in the screenshot above (it&#8217;s the simulator).</p>
<p>They have yet to add socket support to the Android side of Titanium, so as of now this won&#8217;t work on the Android (though it&#8217;ll probably work without modification once they do).</p>
<p>A bunch of JSON parsing exceptions happen on the &#8216;read&#8217; event of the client socket. I imagine it&#8217;s because more than one tweet might come in the JSON payload per packet or whatever triggers the &#8216;read&#8217;, so it freaks out.</p>
<p>The bugs I encountered were that the pin drop animation isn&#8217;t working in the latest version of Titanium, though I know they are on it. Also if you terminate the app it&#8217;ll be the asshole I mentioned above and not send the FIN to the socket. A curious observation is that the socket remains connected when the app goes into the background state (probably just sleeping or something).</p>
<p>Please feel free to comment below any best practices on this (I&#8217;m a newb), or any questions you may have.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://eci.to/2010/08/twitter-streaming-api-node-js-appcelerator-titanium-real-time-tweet-map/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>&#8230;Second post and a little about me</title>
		<link>http://eci.to/2010/06/second-post-and-a-little-about-me/</link>
		<comments>http://eci.to/2010/06/second-post-and-a-little-about-me/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 07:21:54 +0000</pubDate>
		<dc:creator>ecito</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ecito.com/?p=13</guid>
		<description><![CDATA[So I kinda vowed to myself not to fall in the trap of making a blog, doing a first post-post, ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Feci.to%2F2010%2F06%2Fsecond-post-and-a-little-about-me%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Feci.to%2F2010%2F06%2Fsecond-post-and-a-little-about-me%2F&amp;source=ecito&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f470da22571f7f0090976c64408093ff" height="61" width="50" /><br />
			</a>
		</div>
<p>So I kinda vowed to myself not to fall in the trap of making a blog, doing a first post-post, and that be my only post for months. I don&#8217;t think I have much to say, so filling up a blog with constant mind vomits might not come natural to me yet, but I&#8217;ll try.</p>
<p>I&#8217;ll start off by expanding on where I left off in my ever so inspiring <em><a href="http://ecito.com/2010/05/first-post/">first post</a></em><em>,</em> overview style:</p>
<h2>Programming stuff:</h2>
<p>By programming stuff, I mean I&#8217;m going to talk about whatever little code snippets or topics I find interesting. My background has been in the web and unix world; PHP / MySQL and then Ruby on Rails. Now I&#8217;m jumping into mobile, mostly with Cocoa stuff on the iPhone/iPad. I&#8217;m currently Lead Developer at <a href="http://socialmobility.com" target="_blank">Social Mobility Inc.</a></p>
<p>I&#8217;m still recovering from the shock of having a whole computer in my pocket, that is always connected, and that I can easily program. Did we have any of this even 5 years ago? I&#8217;m especially thrilled about the fact that there are gazillions of these things out there, and how mobile is quickly changing our society. I&#8217;ve always tried to stay away from fanboi-isms, but right now Apple is pretty much plowing right through the restrictive mobile space and making room for us developers. We then get great competition, and move mobile even further.</p>
<p>I&#8217;ve been learning Objective-C for almost a year now, and the amount of fun I&#8217;ve had along the way has been well worth it. Little did I know I was actually gonna enjoy the hell out of a CS degree. (I&#8217;m pessimistic like that). The language itself seemed kinda terse at the beginning, but the whole cocoa API is pretty rich and stable; considering that A: it&#8217;s a f-ing phone, and B: it&#8217;s been only 3 years on the iOS platform. Still, Haters be hatin&#8217;.</p>
<p>I&#8217;ve been interested in location based services lately, doing some things with the <a href="http://simplegeo.com" target="_blank">SimpleGeo API</a>. I&#8217;m having tons of fun in this area, mostly because nobody even knows what works yet in location. But whatever we come up with, it&#8217;s probably going to need a heavy-duty platform tailored for geo stuff. What simplegeo is doing is pretty amazing, and a lot of the tools are actually open source on <a href="http://github.com/simplegeo" target="_blank">github</a>. They have clients for ruby, Java, Python, PHP, Objective-C, .NET, etc so I&#8217;ve been covered from project to project.</p>
<p>I&#8217;m also very eager to see what people come up with for Augmented Reality. We are still in a kinda clunky phase right now in AR, but you just know that mobile computers are going to keep avalanching and be more and more ubiquitous. I&#8217;m waiting for wearable computers to be considered cool. Just as location, I find it interesting because nobody knows what&#8217;s next.</p>
<p>Nintendo did some AR things with the new 3DS, as it has two front cameras and a 3D screen. Also, some of the iPhone 4&#8242;s biggest upgrades were tailored specifically for AR. Things like better location, the gyroscope, the raw camera access. I&#8217;m expecting to see some pretty immersive things coming soon.</p>
<p>So anyways, I&#8217;m just glad I&#8217;ve found a shitload of interest in something and hope to share it with this blog, so stay tuned.</p>
<h2>Photography stuff</h2>
<p>Like every other programmer out there, I do some photography as well. I mostly do things like HDR, light graffiti and panoramic pictures to overcompensate my total lack of photography skills. The results sometimes end up not sucking so much, so I might share those things, like this little planet in South Africa:</p>
<p><a href="http://www.flickr.com/photos/50720408@N06/4659608562/sizes/l/"><img class="alignnone size-full wp-image-17" title="little planet" src="http://ecito.com/wp-content/uploads/2010/06/4659608562_d351e12fd0_t1.jpg" alt="" width="100" height="93" /></a></p>
<h2>Travel stuff</h2>
<p>Ok, I&#8217;m adding too many topics to this blog already. Let&#8217;s go back to programming. <a href="http://en.wikipedia.org/wiki/You_ain't_gonna_need_it">YAGNI</a> -fu.</p>
<h2>Random stuff</h2>
<p>There may be some random things I would like to share. Probably not, but you have been forewarned.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://eci.to/2010/06/second-post-and-a-little-about-me/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First post</title>
		<link>http://eci.to/2010/05/first-post/</link>
		<comments>http://eci.to/2010/05/first-post/#comments</comments>
		<pubDate>Fri, 21 May 2010 07:33:05 +0000</pubDate>
		<dc:creator>ecito</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ecito.com/?p=4</guid>
		<description><![CDATA[This be my first post of my blog. What shall a random encounter with my site provide you with? Well ...]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Feci.to%2F2010%2F05%2Ffirst-post%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Feci.to%2F2010%2F05%2Ffirst-post%2F&amp;source=ecito&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f470da22571f7f0090976c64408093ff" height="61" width="50" /><br />
			</a>
		</div>
<p>This be my first post of my blog. What shall a random encounter with my site provide you with? Well let&#8217;s see:</p>
<ul>
<li>Programming stuff</li>
<li>Photography stuff</li>
<li>Music stuff</li>
<li>Travel stuff</li>
<li>Random stuff</li>
</ul>
<p>Just stuff in general. We all like stuff don&#8217;t we? Let&#8217;s do this.</p>
<!-- PHP 5.x -->]]></content:encoded>
			<wfw:commentRss>http://eci.to/2010/05/first-post/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

