<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>software nature</title>
    <description>This blog is all about software engineering, making things, related musings. Rishikesh Parkhe is a Software Engineer, Game Developer, Artist, Designer and Implementer.  This blog and its contents are based on his opinions alone, they do not represent his employer&#39;s in any way. The opinions are subject to change through time.
</description>
    <link>https://softwarenature.com/</link>
    <atom:link href="https://softwarenature.com/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 15 Mar 2021 18:30:24 +0000</pubDate>
    <lastBuildDate>Mon, 15 Mar 2021 18:30:24 +0000</lastBuildDate>
    <generator>Jekyll v2.5.3</generator>
    
      <item>
        <title>Software development and creativity</title>
        <description>&lt;p&gt;I recently encountered an interesting discussion on Twitter regarding software development being a creative field or not. There were enough passionate arguments on both the sides. Being an artist (painter) and a software professional, I do have a few thoughts on this, which are not just limited to programming.&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;en&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;If coding doesn&amp;#39;t feel like painting or passionate creative writing, you have at least another level to master before calling yourself a programmer.&lt;/p&gt;&amp;mdash; James Coplien (@jcoplien) &lt;a href=&quot;https://twitter.com/jcoplien/status/1051428822275555329?ref_src=twsrc%5Etfw&quot;&gt;October 14, 2018&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;Thoughts:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Art is the process of improving the quality of an object.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The object’s value is thus increased in the process. For example, you may start with an uninteresting log of wood but, in the end you would create a beautiful vase out of that. Quality could be aesthetic or functional i.e. strength, conveying information, etc. A bit of disclaimer here: I don’t get abstract art, not a big fan of that (yet), whose theme is to not necessarily to have a purpose behind something, i.e. there could be brush strokes without necessary purpose - it would be left to the interpreter (audience) to make sense or find purpose in it. I am not talking about such art in this topic!&lt;/p&gt;

&lt;p&gt;With software development, something is built out of nothing or mere thoughts. There is a joy (maybe due to dopamine) which one gets when a well thought, logical contraption built using imagination, hypothesis and constraints comes to life! It is very similar to creative writing even though, I am not into that field, having read stuff, I could relate to this. With software development, there are a few facets as below.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2018-10-18/CreativityVenn.png&quot; alt=&quot;(c) Rishikesh Parkhe, Software development and creativity&quot; title=&quot;(c) Rishikesh Parkhe, Software development and creativity&quot; /&gt;&lt;/p&gt;

&lt;p&gt;(above diagram is not all inclusive, it is a rough mind dump of what I want to say)&lt;/p&gt;

&lt;p&gt;Craftsmanship involves designing, skills and passion to have a better outcome’ ‘implementation’, both can be equally creative and it is coupled with the analytical and skillful side of engineering. If there is any room for, and willingness to do things differently it could qualify as creative work. It’s goal is towards improving of quality of the product. This revolves around certain principles and practices which guide into making the changes in order to achieve the same. Beyond a certain point, the refinements become less of a necessity and more of a preference based on predictions and experience. This activity of improving quality is a highly creative task which increases value of the software, even though it may not be tangible at first. Effort put in the refinement and caring for the minor bits in software, shows. Take MacOS for example (haven’t tried Catalina yet!), everything looks handcrafted and made with care (including performance), while Windows could seem to be like things were put together with different goals in mind (although it does the job as well).&lt;/p&gt;

&lt;p&gt;Doing painting especially in oil seems very similar to software development to me. One would start with a blank canvas, then by colours and shapes build a picture of what he/she sees. Oil painting remains wet for quite a while and one could paint over it, reveal paint from below layers, erase everything and start over. You could make several changes until the painting is completely dry (even after that at times). During the painting process, the artist stops and compares, introspects on the picture - makes changes until the desired outcome is achieved. Until the painting is actually done it only is in the painter’s mind, no one else gets the picture. Same is with the software, until it is built everything is intangible and everyone has their own ideas of how it might turn out to be. Many times, I think the product owner has to play this role of an artist (as example above) or a director, who has an idea of the software in their mind. This idea would be based on external(market, need etc..) and internal factors. They have to incrementally shape, tweak, push the realisation as close to the vision as possible.&lt;/p&gt;

&lt;p&gt;Problem solving is more analytical but, also is creative, and it is equally if not more rewarding than craftsmanship. It is just like how theoretical physics and pure maths have an incredible beauty and a creative side, software development has it too.  Coming up with algorithms or logic machines which do the required work for you give a great amusement and sense of satisfaction (again, dopamine). Those ‘eureka’ moments are what makes this most interesting and engaging.&lt;/p&gt;

&lt;p&gt;Ideas and a thought process cannot be learnt however, it can be acquired. One can get inspired from other great ideas. Gathering skills building logic are a vital part of this but, ideas need to originate from one’s thinking process. In painting for example, one would struggle initially to hold the brush, mix paint properly etc. Once that is learnt, painter moves to the next level - tries to replicate paintings, imitate brush strokes, match colours. Then painters develop their own style of painting, their own palettes and brush work. After which the painter starts exploring new subjects, ideas. This is possible as the former hurdles are already crossed and there is enough mindspace and confidence to navigate one’s way. At this stage inventions (not accidental), innovations can happen.&lt;/p&gt;

&lt;p&gt;It certainly would be difficult to run businesses with artists alone, there are limiting constraints. The hardening of ideas / notions could at times override rationality. To make it effective, creativity has to be coupled with adaptability (or as we say, pragmatism). Most time is spent in hacking, engineering and crafting a solution but, having a vision / idea in mind can make the difference. The famous cliché - magic happens when art meets engineering ;-)&lt;/p&gt;

&lt;p&gt;Ending with a quote from the writer of Quake -&lt;/p&gt;
&lt;blockquote class=&quot;twitter-tweet&quot; data-lang=&quot;en&quot;&gt;&lt;p lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;You might not think that programmers are artists, but programming is an extremely creative profession. It&amp;#39;s logic-based creativity.” - John Romero&lt;/p&gt;&amp;mdash; Programming Wisdom (@CodeWisdom) &lt;a href=&quot;https://twitter.com/CodeWisdom/status/1052176582037655552?ref_src=twsrc%5Etfw&quot;&gt;October 16, 2018&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;https://platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

</description>
        <pubDate>Thu, 17 Oct 2019 10:50:00 -0600</pubDate>
        <link>https://softwarenature.com/2019/10/software-development-creativity/</link>
        <guid isPermaLink="true">https://softwarenature.com/2019/10/software-development-creativity/</guid>
        
        
        <category>posts</category>
        
        <category>articles</category>
        
      </item>
    
      <item>
        <title>Software rust</title>
        <description>&lt;p&gt;Rust is a well known phenomenon, it is the effect of the environmental conditions on the metal objects. Well how does this relate to software? Being aware of these factors can help avoid and mitigate such risks in product development. Also, is there anything as “curing time” in software? Lets find out…&lt;/p&gt;

&lt;p&gt;Software may seem like an unchangeable entity once it’s ready. Right, because it’s virtual? By virtual, I mean not having a physical existence / presence. It is virtual but, in its own world it’s real. In the software world it is affected by the elements which exist there.&lt;/p&gt;

&lt;p&gt;As it’s virtual, the expectations from it will be unreal as well. Users don’t treat software like the real thing. Example: compare a commission work for carpenter to make a chair against a commissioned work for writing software to do some accounting work. How many times would the customer go back to the carpenter for making modifications to the chair? Unless it’s a poorly built chair which doesn’t work, this will be rare. Mostly, it will be well built to the specs and customer would be reasonably happy. With software it’s quite different, as it’s virtual the raw material, the build effort is invisible. Thus, software  always seems to be a work in progress (well there will be terms and definition of done) however, it’s never solid. If you know what I mean - there is no curing time (like adhesive or cement) or time required to let the paint dry. The paint seems always wet and like an oil painting you can paint over, remove paint you can even change the body/shape. It seems to always be in a work in progress state. The problem is that this is not true.&lt;/p&gt;

&lt;p&gt;There is a phase when software is moldable and then there is a curing time, after which making changes have an effect on the solidity or robustness of the product. This curing phase may not be a tangible thing. You can get around by ensuring automated test suite passes or good coding practices and other great ideas. However, the vital thing is the knowledge. As soon as the team diverges away from the product the curing process begins. The curing process accelerator is the user of the software. The more software gets consumed, more it gets cured / starts solidifying.  Like the Schrödinger’s experiment, the box has been opened, reality has taken over 😊&lt;/p&gt;

&lt;p&gt;After this curing phase of the software, I compare its life cycle with a metal product as it exhibits similar traits. Example: A bridge built with iron can corrode / rust due to the water vapour in the air or rain. The elements in software world would be its users, the problem (domain) it’s trying to solve, third party libraries / web services, data storages, web hosts, frameworks, operating systems etc. Unless software is built as a system (including the platform its being run on) these elements are always in play and interact and affect the software. These elements listed above (it’s not a complete list) are independent and have their own life cycles, their current state however, affects the software which is deployed in the field. Example: Users found the software ‘state of the art’ when they first used it, over the years users have evolved by using other software they interact with and their expectations from the deployed software are a lot more than what they were earlier. Here the deployed software remained unchanged but, its functionality seems to have reduced (effectively). Let’s take another example: OS, let’s say the software was built using .Net 3.5 on windows XP, it all was running smoothly, one fine day Microsoft decides its discontinuing XP and thus .Net 3.5. Again, software was unchanged, its environment changed and it has a detrimental effect over it. Similarly, with data storages, third party libraries their dependencies, web services, web hosts. As another example, let’s say there is a new authentication protocol in the market, its adopted like wildfire, all the webservices which your software uses have migrated to that, and would deprecate the old one in some time. The software which is deployed would stop working after the deprecation of the older protocol unless it also uses the new protocol. These are some of the examples of elements which affect the software (that remains unchanged after deployment).&lt;/p&gt;

&lt;p&gt;Thus, I put forth a point that software out in the field has wear and tear and needs to be maintained. Like the bridge needs repainting, metal replacements, analysis, reinforcements, software also needs to be analysed for effects of the elements and maintained. It’s possible to keep a software product rust free and performing 100% by frequently monitoring the elements which it interacts with and taking necessary actions.&lt;/p&gt;
</description>
        <pubDate>Tue, 06 Aug 2019 10:50:00 +0000</pubDate>
        <link>https://softwarenature.com/2019/08/software-rust/</link>
        <guid isPermaLink="true">https://softwarenature.com/2019/08/software-rust/</guid>
        
        
        <category>posts</category>
        
        <category>articles</category>
        
      </item>
    
      <item>
        <title>Reusable components design</title>
        <description>
&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2017-04-26/banner.jpg&quot; alt=&quot;reuse in software (c) Rishikesh Parkhe&quot; title=&quot;reuse in software (c) Rishikesh Parkhe&quot; /&gt;&lt;/p&gt;

&lt;p&gt;An adage in Software Engineering goes like&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Before software can be reusable it first has to be usable.&lt;/p&gt;

  &lt;p&gt;— Ralph Johnson&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Reusability is a highly desirable attribute in Software Engineering. It is known to save time (at times) and it makes robust software. It’s the magic bullet! There are various levels at which reusability can be achieved in both ‘the what’ and ‘the how’ aspects in software. Achieving high degree of reusability is hard, it takes effort in that direction. For any enterprise the relevant questions will be what is the cost of making software highly reusable, next is when to put in the effort to build reusability into software, and how much would be gained in return.&lt;/p&gt;

&lt;p&gt;Let us take these questions one by one.&lt;/p&gt;

&lt;h4 id=&quot;what-is-the-cost-of-building-in-reusability&quot;&gt;What is the cost of building in reusability?&lt;/h4&gt;

&lt;p&gt;For the uninitiated, the cost seems to be negligible. It is often underestimated and taken for granted that if good design principles / coding practices are followed, it will result into good amount of reusability. In theory, following good design practices will make code more readable and do what it is supposed to in an elegant, efficient and sophisticated way. It will not however, always make it reusable. Maintainability is the quality which should be at the centre of concern, maintainability and reuse are related in a vague way. If the software is dominating or even surviving well for over 5 or more years that means it is maintainable and a lot of code base / components are being reused, it is serving the requirements for a long duration.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Generality (spectrum of reuse) and abstractness are directly related, the more generic it is, the more abstract it becomes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If software requirements are being thought of from a generic perspective in order to serve a wider audience, they will be more abstract and disconnected from the direct user requirements. That means the drive for developing is not coming from the core business it is something which has to be… invented. As an example, consider computer games, an engine is something which is reusable, while a game may not be. Building an engine without real requirements, trying to imagine what future games might need is a tough ask, and a bit academic in nature. It needs time and expertise to know the domain before something like this can be done. Building an engine however, is for a very high level of reuse, probably considering 100s of games being churned out using it. It is a complete software in itself whose core requirement is being reusable and doing everything what a game needs. The customers are developers. As one can observe, the scope of building an engine is exponentially growing and so it’s cost! It would be a big decision to invest into building something like this upfront.&lt;/p&gt;

&lt;p&gt;Next level (lower) would be frameworks, then services, libraries, components and then code. 
The cost involved would go up as the generality increases. Building new languages, database engines, frameworks involve a huge cost. Sometimes the business might want to build engines or invent things to be ahead of the competition and maybe forecast returns in future, for that the other side of business needs to sustain the cost of building reusability.&lt;/p&gt;

&lt;h4 id=&quot;when-to-put-in-the-effort-to-make-it-reusable&quot;&gt;When to put in the effort to make it reusable?&lt;/h4&gt;

&lt;p&gt;In case if someone else is waiting in the wings for a software requirement similar to the one which is being developed, then it makes sense to put in effort to make the code reusable or build components. However, prioritising reusability over fulfiling the core requirements of software is a recipe for disaster. It has to do one / few things right, rather than be an allrounder which can do a bit of everything but can’t completely do one thing. Perhaps, an analysis should be done for why there are similar requirements in different softwares. Sometimes there might be business reasons for having similar softwares. Sometimes less is more…&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Form follows function&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2017-04-26/ripe.jpg&quot; alt=&quot;reuse in software (c) Rishikesh Parkhe&quot; title=&quot;reuse in software (c) Rishikesh Parkhe&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Emergence principle: Let the modules emerge&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While the business requirements are being satisfied by the software a vigilant eye can always spot the components emerge from within software solutions. The components will sprout from the main features of the software and when the start to ripen on the functional software they can be easily plucked and groomed into proper shape.&lt;/p&gt;

&lt;p&gt;There is another train of thought, to build everything in a Service Oriented Architecture (microservices). That means everything is like building blocks (lego) you can plug in anything. It sounds good in theory, however software components are not exactly plug and play, they have different interfaces - which often need customisation (adapters). Every pluggable piece has its own specifications and quirks. Not everything will be factory made. This is a reasonably good strategy however, attention should be paid to how much of code is actually consumed in the application. All code should have a purpose. There is a tendency of over engineer in case of service oriented architecture.&lt;/p&gt;

&lt;p&gt;From a &lt;a href=&quot;https://en.wikipedia.org/wiki/Domain-driven_design&quot;&gt;domain driven design&lt;/a&gt;, the focus is on accurately modelling the domain and solving the core business problem.&lt;/p&gt;

&lt;p&gt;As long as there is loose coupling in the code, it is a conducive environment to sprout reusable components or services. This can be part of the main design principles while building the core software. Services based on contracts can always be provided on top of the core components once they are ready.&lt;/p&gt;

&lt;p&gt;Core software will have schedules, reusability will not.&lt;/p&gt;

&lt;h4 id=&quot;how-much-would-be-gained-in-return&quot;&gt;How much would be gained in return?&lt;/h4&gt;

&lt;p&gt;In theory reusable components are expected to work straight off the shelf. Realistically, there is an effort required to consume the reusable components or services to build software solutions. More out of the box’d ness the solution has the more narrow its applicability and the vice versa.&lt;/p&gt;

&lt;p&gt;Another interesting saying in software engineering goes like:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Telling a programmer there’s already a library to do X is like telling a songwriter there’s already a song about love.” - Pete Cordell&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s so true, as there are so many subtle differences yet, it depends on how deep one wants to go.&lt;/p&gt;
</description>
        <pubDate>Wed, 26 Apr 2017 18:50:00 +0000</pubDate>
        <link>https://softwarenature.com/2017/04/resuable-components-design/</link>
        <guid isPermaLink="true">https://softwarenature.com/2017/04/resuable-components-design/</guid>
        
        
        <category>posts</category>
        
        <category>articles</category>
        
      </item>
    
      <item>
        <title>Clustering using k-Means Algorithm</title>
        <description>&lt;h3 id=&quot;introduction&quot;&gt;Introduction&lt;/h3&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/header.png&quot; alt=&quot;clustering demo&quot; title=&quot;clustering demo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Clustering a unique problem which falls under the category of unsupervised machine learning system. 
In neural networks it also is a type of classification problem, which separates the inputs into different classes.&lt;/p&gt;

&lt;p&gt;As there is no training set available to hint or teach the system as to which point belongs to which class, this 
is an unsupervised learning. Only thing known to the system is how many clusters it requires to form (the k). The
number of clusters can also be computed using stochastic / heuristics of initial analysis of the inputs. 
It is one of the simpler clustering problems. There are more advanced clustering ways like Linear Vector 
Quantisation (LVQs) and Self-organising maps (SOMs).&lt;/p&gt;

&lt;p&gt;It works well when the problem is more intuitive i.e. if we can visualise different clusters as there is a good
amount of separation between them (example Fig. a). It is also useful when the problem space is intermixed (example 
Fig. b) yet we would like to divide the space into certain clusters.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/clustering_final.png&quot; alt=&quot;clustering&quot; title=&quot;clustering&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Fig a&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/clustering_example.png&quot; alt=&quot;clustering closely spaced inputs&quot; title=&quot;clustering closely spaced inputs&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Fig b&lt;/p&gt;

&lt;p&gt;Clustering is a NP hard problem. k-Means is more of a heuristic algorithm, which is trying to solve this NP hard 
problem. This algorithm is not able to find the global minima, it converges onto a local minima. As you can try for
yourself in the below implementation of the k-Means. The quality of the solution is dependent on the location of the 
initial guess of the centroids.&lt;/p&gt;

&lt;h3 id=&quot;the-algorithm&quot;&gt;The Algorithm&lt;/h3&gt;

&lt;h5 id=&quot;inputs&quot;&gt;Inputs&lt;/h5&gt;
&lt;p&gt;&lt;em&gt;P&lt;/em&gt; = Set of input points where every point in P is belonging to space of n dimensions.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;k&lt;/em&gt; = number of clusters&lt;/p&gt;

&lt;p&gt;The algorithm will try to minimise the following function&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/formula.png&quot; alt=&quot;minimization function&quot; title=&quot;clustering closely spaced inputs&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;step-1&quot;&gt;Step 1&lt;/h4&gt;

&lt;p&gt;This is an unsupervised learning, hence we start with the analysis of input data and keep adapting our 
computations based on new data. Take the available input data&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/clustering_1.png&quot; alt=&quot;clustering input&quot; title=&quot;clustering input&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;step-2&quot;&gt;Step 2&lt;/h4&gt;

&lt;p&gt;Initialise the &lt;em&gt;k&lt;/em&gt; cluster points in the input space. This initialisation is important as this alogrithm will latch
onto a local minima. We are going to take random point in the bounding box of the inputs.&lt;/p&gt;

&lt;h4 id=&quot;step-3&quot;&gt;Step 3&lt;/h4&gt;

&lt;p&gt;Compute the distances of each point in the input space to the cluster points.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/clustering_2.png&quot; alt=&quot;clustering stage 1&quot; title=&quot;clustering stage 1&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;step-4&quot;&gt;Step 4&lt;/h4&gt;

&lt;p&gt;Associate each point to the cluster point which is the nearest to it using the distances computed. You can combine 
step 3 and 4 for optimisation.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-05-30/clustering_3.png&quot; alt=&quot;clustering stage 2&quot; title=&quot;clustering stage 2&quot; /&gt;&lt;/p&gt;

&lt;h4 id=&quot;step-5&quot;&gt;Step 5&lt;/h4&gt;

&lt;p&gt;Compute a centroid of the points associated with the each cluster. So there will be &lt;em&gt;k&lt;/em&gt; new centroids.
Move the cluster points to the new centroid positions.&lt;/p&gt;

&lt;p&gt;Refer above fig.&lt;/p&gt;

&lt;h4 id=&quot;step-6&quot;&gt;Step 6&lt;/h4&gt;
&lt;p&gt;If there is any change in the cluster position, repeat step 3 to 5.&lt;/p&gt;

&lt;p&gt;To achieve global minima one can use the stochastic techniques or search techniques like Simulated Annealing.&lt;/p&gt;

&lt;h3 id=&quot;interactive-js-example&quot;&gt;Interactive js example&lt;/h3&gt;

&lt;html&gt;
&lt;head&gt;
&lt;script src=&quot;/assets/js/euler.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
    &lt;script type=&quot;application/javascript&quot;&gt;

    var ctx;
    var m_num_pts = 0;
    var m_num_hull_pts = 0;
    var m_pts = new Array();
    var m_colors_r = new Array();
    var m_colors_g = new Array();
    var m_colors_b = new Array();
    var m_centroids = new Array();
    var m_num_clusters = 0;
    var mouse_x = 0;
    var mouse_y = 0;

    var m_minIndex = 0;
    var m_maxIndex = 0;

    var m_AABB = {
        &quot;min&quot;: {
            &quot;x&quot;: 0,
            &quot;y&quot;: 0
        },
        &quot;max&quot;: {
            &quot;x&quot;: 0,
            &quot;y&quot;: 0
        }
    };
    
    function init() {
        m_colors_r[0] = &quot;20&quot;; m_colors_g[0] = 25; m_colors_b[0] = 250;     
        m_colors_r[1] = &quot;255&quot;; m_colors_g[1] = 140; m_colors_b[1] = 0;     
        m_colors_r[2] = &quot;255&quot;; m_colors_g[2] = 20; m_colors_b[2] = 147;     
        m_colors_r[3] = &quot;20&quot;; m_colors_g[3] = 189; m_colors_b[3] = 80;     
        m_colors_r[4] = &quot;119&quot;; m_colors_g[4] = 201; m_colors_b[4] = 255;  
        m_colors_r[5] = &quot;224&quot;; m_colors_g[5] = 204; m_colors_b[5] = 63;
        m_colors_r[6] = &quot;195&quot;; m_colors_g[6] = 155; m_colors_b[6] = 211;
        m_colors_r[7] = &quot;236&quot;; m_colors_g[7] = 112; m_colors_b[7] = 99;
        m_colors_r[8] = &quot;174&quot;; m_colors_g[8] = 182; m_colors_b[8] = 191;
        m_colors_r[9] = &quot;52&quot;; m_colors_g[9] = 73; m_colors_b[9] = 94;
        
        var canvas = document.getElementById(&quot;canvas&quot;);
        ctx = canvas.getContext(&quot;2d&quot;);
        canvas.addEventListener(&#39;mousemove&#39;, mouse_move_handler, false);
        canvas.addEventListener(&#39;mouseup&#39;, mouse_up_handler, false);

        draw();
    }
    
    function getColorForClass(type)
    {
        var i = type;
        return &quot;rgba(&quot; + m_colors_r[i] + &quot;,&quot; + m_colors_g[i] + &quot;,&quot; + m_colors_b[i] + &quot;, 1)&quot;;
    }

    function draw() {
        ctx.fillStyle = &quot;rgba(0, 10, 30, 1)&quot;;
        ctx.fillRect(0, 0, 600, 400);

        ctx.fillStyle = &quot;rgba(200, 100, 10, 0.8)&quot;;
        ctx.fillRect(mouse_x - 5, mouse_y - 5, 10, 10);

        ctx.fillStyle = &quot;rgba(250, 20, 50, 0.5)&quot;;
        for (var i = 0; i &lt; m_num_pts; i++) {
            var point = m_pts[i];
            ctx.fillStyle = getColorForClass(point.GetClass());
            ctx.fillRect(m_pts[i].GetX() - 1, m_pts[i].GetY() - 1, 4, 4);
        }
        
        ctx.fillStyle = &quot;rgba(100, 30, 22, 0.9)&quot;;
        for (var i = 0; i &lt; m_num_clusters; i++) {
            ctx.fillRect(m_centroids[i].GetX() - 3, m_centroids[i].GetY() - 3, 6, 6);
        }

        if (m_num_pts &gt; 0) {
            ctx.fillStyle = &quot;rgba(255, 170, 0, 1)&quot;;
        }

        ctx.fillStyle = &quot;rgba(170, 170, 170, 0.4)&quot;;
        ctx.fillText(&quot;RISHIKESH PARKHE&quot;, 10, 370);
        ctx.fillText(&quot;k Means clustering&quot;, 10, 385);
    }

    function mouse_move_handler(evt) {
        // Get the mouse position relative to the canvas element.
        if (evt.layerX || evt.layerX == 0) { // for Firefox
            mouse_x = evt.layerX;
            mouse_y = evt.layerY;
        } else if (evt.offsetX || evt.offsetX == 0) { // for Opera
            mouse_x = evt.offsetX;
            mouse_y = evt.offsetY;
        }

        draw();
    }

    function mouse_up_handler(evt) {
        mouse_move_handler(evt);
        var pt = new CPoint(mouse_x, mouse_y);
        m_pts[m_num_pts] = pt;
        m_num_pts++;

        draw();
    }
    
    function compute_AABB() {
        if (m_num_pts &gt; 0) {

            m_AABB.min.x = m_pts[0].GetX();
            m_AABB.max.x = m_pts[0].GetX();
            m_AABB.min.y = m_pts[0].GetY();
            m_AABB.max.y = m_pts[0].GetY();

            for (var i = 0; i &lt; m_num_pts; i++) {
                if (m_pts[i].x &lt; m_AABB.min.x) {
                    m_AABB.min.x = m_pts[i].GetX();
                }

                if (m_pts[i].x &gt; m_AABB.max.x) {
                    m_AABB.max.x = m_pts[i].GetX();
                }

                if (m_pts[i].y &lt; m_AABB.min.y) {
                    m_AABB.min.y = m_pts[i].GetY();
                }

                if (m_pts[i].y &gt; m_AABB.max.y) {
                    m_AABB.max.y = m_pts[i].GetY();
                }
            }
        }
    }

    function ComputeClusters()
    {
        m_num_clusters = document.getElementById(&quot;TextBoxNumberOfClusters&quot;).value;     
        m_centroids = new Array();
      
        for (var i = 0; i &lt; m_num_clusters; i++) {
            var x_offset = Math.random() * 10;
            var y_offset = Math.random() * 10;

            if (i % 2 == 0) {
                x_offset *= -1.0;
                y_offset *= -1.0;
            }

            m_centroids[i] = new CPoint(300 - x_offset, 300 - y_offset);
        }

        ComputeKMeans(m_pts, m_num_pts, m_num_clusters, m_centroids);
        draw();
    }
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;init()&quot;&gt;
&lt;canvas id=&quot;canvas&quot; width=&quot;600&quot; height=&quot;400&quot;&gt;&lt;/canvas&gt;
&lt;br /&gt;
Enter the number of clusters
&lt;input type=&quot;number&quot; id=&quot;TextBoxNumberOfClusters&quot; value=&quot;2&quot; min=&quot;1&quot; max=&quot;10&quot; /&gt;

&lt;button onclick=&quot;ComputeClusters()&quot;&gt;Classify&lt;/button&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;These cluster centroids are then used to compute a voronoi region. More to come in the later posts.&lt;/p&gt;
</description>
        <pubDate>Mon, 30 May 2016 09:30:00 +0000</pubDate>
        <link>https://softwarenature.com/2016/05/clustering-using-kmeans/</link>
        <guid isPermaLink="true">https://softwarenature.com/2016/05/clustering-using-kmeans/</guid>
        
        
        <category>posts</category>
        
        <category>machine_learning</category>
        
      </item>
    
      <item>
        <title>Booting up my Raspberry pi 2</title>
        <description>
&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-01-03/pi2_banner.png&quot; alt=&quot;Raspberry pi internet of things&quot; title=&quot;Raspberry pi internet of things (c) rishikesh parkhe&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Raspberry pi is a small and cheap bare minimum computer. It has been around for a while. It can be connected to various 
devices and can function like a normal desktop computer (apart from the performance aspects). Programs written in 
many different languages (ruby, python, javascript, C#, C++, java… etc) can be run on the pi!&lt;/p&gt;

&lt;p&gt;In the first incarnation of the model there were a few variants like A, A+, B,
B+. Now, there comes the pi 2 and they have really put everything into this one :)
You have to love this small powerhouse of a computer… It is absolutely perfect for the DIY or IOT (internet of things)
applications. It comes in with a dedicated graphics processor, that means the pi can do HD graphics.&lt;/p&gt;

&lt;p&gt;Some of highlighting features of the pi&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;ARM Cortex A7 quad core (900 MHz)&lt;/li&gt;
  &lt;li&gt;1GB RAM&lt;/li&gt;
  &lt;li&gt;VideoCore IV 3D graphics core&lt;/li&gt;
  &lt;li&gt;Full HDMI port&lt;/li&gt;
  &lt;li&gt;CSI Camera interface&lt;/li&gt;
  &lt;li&gt;the list goes on…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Quad core is really too much power for an embedded device (type of), if a computer is required for such usage 
or lower power consumption, it is recommended to use the earlier models.
I had ordered the pi 2 B model.&lt;/p&gt;

&lt;p&gt;The pi is a full computer hence, we need an OS for the pi. There are a lot of options ranging from&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;NOOBS&lt;/li&gt;
  &lt;li&gt;Raspbian (debain)&lt;/li&gt;
  &lt;li&gt;Windows IOT core
many more are there on the pi website.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I am going with minimal amount to begin with, hence I only need the runtime - and also I wanted to checkout the 
Win10 IOT Core&lt;/p&gt;

&lt;p&gt;Download the ISO image from &lt;a href=&quot;http://ms-iot.github.io/content/en-US/Downloads.htm&quot;&gt;http://ms-iot.github.io/content/en-US/Downloads.htm&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Installed the msi embedded into the ISO 
&lt;img src=&quot;/assets/2016-01-03/IoT_installer.jpg&quot; alt=&quot;IOT installer&quot; title=&quot;Windows IOT Core installer&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then we need to burn the .ffu image from the installed setup into the micro sd card. An adapter is requried for connecting
to the laptops.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-01-03/burn_the_image.jpg&quot; alt=&quot;Image burner windows iot&quot; title=&quot;Image burner windows iot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Thats all… Microsoft has made things very easy. Well, even Linux is easy but I wanted test the waters of the windows 10 runtime.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;/assets/2016-01-03/pi_boot.jpg&quot; alt=&quot;booting win iot&quot; title=&quot;booting win iot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I have connected the peripherals and the HDMI cable to the tele and voila, its up and running. It doesn’t do much (yet)
But, there is a blinky program here which can work straight away from the user interface seen in the picture above.&lt;/p&gt;

&lt;p&gt;Cool stuff indeed! Its got an ethernet cable, once connected it is ready to be a IOT device which can be
controlled and connected to other devices.
I have a very small monitor but it has the old style AV pins for connections. I will see how I can get
that working along with they keyboard and mouse :)&lt;/p&gt;
</description>
        <pubDate>Sun, 03 Jan 2016 09:30:00 +0000</pubDate>
        <link>https://softwarenature.com/2016/01/booting-up-my-raspberry-pi/</link>
        <guid isPermaLink="true">https://softwarenature.com/2016/01/booting-up-my-raspberry-pi/</guid>
        
        
        <category>posts</category>
        
        <category>iot</category>
        
      </item>
    
      <item>
        <title>An adventure in the Node land - first impressions</title>
        <description>&lt;p&gt;I was trying to look into Node.js which is the new &lt;em&gt;phenomenon&lt;/em&gt; on the web these days. 
Lot of people (websites) are moving to Node - from ruby / java / php. Surely, I want to find out why…&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://nodejs.org/en/&quot;&gt;&lt;img src=&quot;https://upload.wikimedia.org/wikipedia/commons/thumb/d/d9/Node.js_logo.svg/233px-Node.js_logo.svg.png&quot; alt=&quot;Node Logo&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have followed Node since it’s beginning but, never really got to use it anywhere or had a chance to
seriously experiment on it.&lt;/p&gt;

&lt;p&gt;Node is effectively a new programming runtime (platform) for just about anything. The language in play is Javascript. 
It has various modules like ‘http’ which makes it highly useful for development of web services / apps.
The runtime is very fast as it’s the V8 engine of Chrome browser. Thanks to Open source community and Google for this.&lt;/p&gt;

&lt;p&gt;Node started with Rayn Dahl at Joyent, but now it is in the hands of a foundation. The foundation consists of
members from various areas of the web. They are in charge of steering the development of node. This is
good as opposed to a normal open source developer model, as everyone recognises a potential in this.&lt;/p&gt;

&lt;p&gt;Javascript is best suited for the web, as all the client side code is javascript
anyway. This makes it easy for the development of web apps as both the client and server codebase
becomes javascript. Smaller technology stack. Or is it?&lt;/p&gt;

&lt;p&gt;Javascript is a neat little programming language, which is extremely malleable. It can be moulded for any
paradigm viz. it is a functional language but can be turned into an Object Oriented Language. 
On the other hand, this also makes it a source of a lot of problems and bugs. It is highly recommended to do 
production node js work using Test Driven Development.&lt;/p&gt;

&lt;p&gt;I have been experimenting with the Chrome engine since it began, was really excited by its speed… This was
 back in 2011&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://lh3.googleusercontent.com/-tqrmDApGQJY/TXUq7y6uqfI/AAAAAAAABhU/t6_rpR-87c8/s1600/bezier_code_html.png&quot; alt=&quot;Bezier demo&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.freewebs.com/rishiparkhe/beziercurve.html&quot;&gt;Bezier demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lets have a look a how a node application works. 
I have downloaded node js from the nodejs &lt;a href=&quot;https://nodejs.org/en/&quot;&gt;website&lt;/a&gt;. I am planning to create just a simple
hello world program that displays the current system time.&lt;/p&gt;

&lt;p&gt;Create a file named app.js (it could be anything) with the following content&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;http&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; 

&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;server&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;writeHead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&amp;#39;Content-Type&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;text/html&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;hrs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getHours&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;min&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getMinutes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sec&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;d&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;getSeconds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;htmlContent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;&amp;lt;h1&amp;gt;Hello World!&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Time is: &amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; 
    &lt;span class=&quot;nx&quot;&gt;hrs&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;:&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;min&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;:&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;sec&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;htmlContent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;server&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;From the command line start this web service which we have written in the command line&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;js&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After launching the browser with the http://localhost:3000 we should see the below screen&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-12-22/node_hello_world.jpg&quot; alt=&quot;Output&quot; /&gt;]&lt;/p&gt;

&lt;p&gt;The difference between this and something like ruby / java or an ASP.net web application or a service is that
this is a self contained - self hosted application. There is no other container requried to host this functionality.
For example we have to host the ASP.net website into IIS, ruby into apache, java using jboss etc… Here in node
we just have a ‘server.listen(3000)’ line. This is extremely powerful but it is also very low level. To write 
business applications on top of this requires considerable amount of effort. For example how do we handle routing 
serve static pages or resources, handle security, handle parameters…? Which has given rise to many web 
frameworks on the nodejs platform. One of them which seems to be quite popular is Express. More on this soon.&lt;/p&gt;

&lt;p&gt;First impressions really are that nodejs is a growing new platform with a big user and developer base, it is actively
supported, with a lot of content online. It is very lightweight and powerful runtime, which allows easy deployment also,
node has got one of the best package management solutions called the node package manager &lt;strong&gt;(npm)&lt;/strong&gt;. 
Node presents a very low level js platform which gives a huge amount of power and control to the developers however, 
that means there has to be a reliance on middleware frameworks which will be needed to do the
heavy lifting of the business applications. Thankfully there are many such frameworks now :-)&lt;/p&gt;
</description>
        <pubDate>Tue, 22 Dec 2015 22:30:00 +0000</pubDate>
        <link>https://softwarenature.com/posts/2015/12/22/adventures-in-node-js/</link>
        <guid isPermaLink="true">https://softwarenature.com/posts/2015/12/22/adventures-in-node-js/</guid>
        
        
        <category>posts</category>
        
      </item>
    
      <item>
        <title>Joy of code generation using the T4 templating engine</title>
        <description>&lt;p&gt;Generating code is a truly fascinating and a very satisfying experience for me. There is something very meta about it…
Effectively you write programs that write programs for you. I live by the advice (which also comes naturally to me) &lt;b&gt;
&lt;a href=&quot;http://c2.com/cgi/wiki?ThreeStrikesAndYouAutomate&quot; title=&quot;3 strikes you automate&quot;&gt;3 strikes you automate&lt;/a&gt;&lt;/b&gt;. Ah well, t4 then… 
We will first briefly see what T4 is, then I will explain using an example for code generation.&lt;/p&gt;

&lt;h4 id=&quot;what-is-t4-or-tttt&quot;&gt;What is T4 or TTTT?&lt;/h4&gt;

&lt;p&gt;T4 is one of the cool things Microsoft has produced, it has been around since a long time although it’s not that famous.
I have been using it since about 2009 on some odd tasks / code which I found could be automated. It’s a very handy tool for generating boiler plate code.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;T4 = Text Template Transformation Toolkit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To describe it simply it’s like XSLT (Xml Transformation) or like PHP… ASP.Net’s Razor engine works on the similar principle.
It can be used to generate any text output. There are two ways in which the t4 engine can be used.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Static code generation (compile time)&lt;/li&gt;
  &lt;li&gt;Dynamic code generation (at runtime)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a new project in Visual studio, and add the tt files into the project. I am currently using the &lt;em&gt;VS Community
Edition&lt;/em&gt; which is absolutely free and it also supports T4.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-12-03/2015-12-03.png&quot; alt=&quot;Add tt files&quot; title=&quot;Add tt files&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Once you create a .tt file you will likely see the below warning. This is normal, if you know its your tt file its fine.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-12-03/2015-12-03_1.png&quot; alt=&quot;Warnings&quot; title=&quot;Warnings&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Technically on saving the tt file, a code generator is run and that can execute all the .NET code that is embedded in the tt.
This code will run with your current privileges hence, the potential to be harmful…&lt;/p&gt;

&lt;h4 id=&quot;understanding-the-tags&quot;&gt;Understanding the tags&lt;/h4&gt;

&lt;p&gt;The tt files will contain code like below. You will see some odd tags here is a brief explanation about them.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&amp;lt;#= #&amp;gt;&lt;/b&gt; tags: These are control expressions, they contain only code. Any .NET code can be embedded into them.
They will return a value that is written into the output of the template.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&amp;lt;# #&amp;gt;&lt;/b&gt; tags: These are standard control blocks, they can be staggered across the template. You 
can write partial code in these blocks and have pure text in between and again continue with the earlier code.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&amp;lt;#@ #&amp;gt;&lt;/b&gt; tags: All template directives need to be inside these.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&amp;lt;#+ #&amp;gt;&lt;/b&gt; tags: They contain class features, this is if we define any class within the template, you can 
add methods or properties etc.. within these blocks.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;template&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hostspecific&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assembly&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Linq&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Text&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Collections.Generic&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;.txt&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Most of the code above is self-explanatory, the embedded language is C#, the extension type of generated file is .txt,
all the other code is importing the namespaces for the embedded code.&lt;/p&gt;

&lt;p&gt;These are known as the template directives. For more details here is the link &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/gg586945.aspx&quot;&gt;https://msdn.microsoft.com/en-us/library/gg586945.aspx&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;example&quot;&gt;Example&lt;/h4&gt;
&lt;p&gt;We will take a simple example to prepare a list of files in a directory, I was going to take a complex one, 
but it can take very long - probably I will do it in another post.
The goal is to generate an XML file which contains the directory path and lists all the files in it along with its attributes.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We will only talk about static code generation here, dynamic is same in principle.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lets say I have the below directory with following files in it.
&lt;img src=&quot;/assets/2015-12-03/2015-12-03_9_30.png&quot; alt=&quot;Directory&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now, I would like to generate an XML for it.&lt;/p&gt;

&lt;h4 id=&quot;lets-first-see-what-the-tt-file-actually-looks-like&quot;&gt;Lets first see what the .tt file actually looks like.&lt;/h4&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-12-03/2015-12-03-9-39.PNG&quot; alt=&quot;Visual studio project&quot; /&gt;&lt;/p&gt;

&lt;p&gt;There is another file which is a .txt file that has been generated by the t4 engine after parsing our .tt file, and its currently empty.&lt;/p&gt;

&lt;p&gt;I will add some code like below to read a directory (elementary c# stuff) into the .tt file as below. 
Remember the &lt;b&gt;&amp;lt;#=&lt;/b&gt; and the &lt;b&gt;#&amp;gt;&lt;/b&gt;, anything outside those will be directly put into the output file.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-csharp&quot; data-lang=&quot;csharp&quot;&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;template&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;debug&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;hostspecific&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;C#&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;assembly&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Core&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Linq&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Text&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.Collections.Generic&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;namespace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;System.IO&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#@&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;output&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;extension&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;.txt&amp;quot;&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xml&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DirectoryInfo&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dir&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DirectoryInfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;c:\\tmp\\downloads&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Directory&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;lt;#=dir.FullName #&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;foreach&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GetFiles&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
	  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;File&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;LastWriteTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;&amp;lt;#=file.LastWriteTime#&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
			&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Directory&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xml&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;After just saving or compiling this .tt file the code generator will kick in and generate following output text or XML ;) file for us.&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-xml&quot; data-lang=&quot;xml&quot;&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xml&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;&amp;lt;Directory&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;c:\tmp\downloads&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;File&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;LastWriteTime=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;12/03/2015 21:31:46&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
			Todo - Copy (2).txt
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;/File&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;File&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;LastWriteTime=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;12/03/2015 21:31:47&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
			Todo - Copy (3).txt
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;/File&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;File&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;LastWriteTime=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;12/03/2015 21:31:48&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
			Todo - Copy (4).txt
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;/File&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;File&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;LastWriteTime=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;12/03/2015 21:31:49&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
			Todo - Copy (5).txt
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;/File&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;File&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;LastWriteTime=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;12/03/2015 21:31:46&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
			Todo - Copy.txt
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;/File&amp;gt;&lt;/span&gt;
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;File&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;LastWriteTime=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;12/03/2015 21:31:46&amp;quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
			Todo.txt
		&lt;span class=&quot;nt&quot;&gt;&amp;lt;/File&amp;gt;&lt;/span&gt;
	&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/xml&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;That is the basic principle of the T4 templates. Static code generation is useful to generate UI code / html,
generate resources / dictionaries etc. Hope it was useful.&lt;/p&gt;
</description>
        <pubDate>Thu, 03 Dec 2015 19:30:00 +0000</pubDate>
        <link>https://softwarenature.com/posts/automation/2015/12/04/joy-of-code-generation-using-t4-templates/</link>
        <guid isPermaLink="true">https://softwarenature.com/posts/automation/2015/12/04/joy-of-code-generation-using-t4-templates/</guid>
        
        
        <category>posts</category>
        
        <category>automation</category>
        
      </item>
    
      <item>
        <title>Software developers recommended toolbox</title>
        <description>&lt;p&gt;Here is my list useful tools which have helped me in various activities involved in developing software. Most of which are indespensible :)&lt;/p&gt;

&lt;h3 id=&quot;code&quot;&gt;Code&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.visualstudio.com/&quot; title=&quot;Visual studio&quot;&gt;Visual studio&lt;/a&gt;&lt;/b&gt; - can’t do any windows development without this. Visual studio premium provides really good set of tools, but the free community edition is mostly sufficient for development.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://eclipse.org/&quot; title=&quot;Eclipse&quot;&gt;Eclipse&lt;/a&gt;&lt;/b&gt; - Really essential tool for Java / Android development for desktop / web, it supports lot of plugins and Rich client application framework. You can customise it to do any language development even ARM.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://code.visualstudio.com/&quot; title=&quot;Visual studio code&quot;&gt;Visual studio code&lt;/a&gt;&lt;/b&gt; - this is the latest addition into my toolbox, and microsoft have done it. It’s absolutely perfect for web work / scripting quick editing.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://www.scintilla.org/SciTE.html&quot; title=&quot;Scite&quot;&gt;Scite&lt;/a&gt;&lt;/b&gt; - Before visual studio code I was using this scintilla based editor as a lightweight but very powerful ruby / scripting editor&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://www.codemaid.net/&quot; title=&quot;http://www.codemaid.net/&quot;&gt;CodeMaid&lt;/a&gt;&lt;/b&gt; - Really handy free tool for cleaning up the .NET codebase. Supports batch operations as well. Supports most important customizations, could be better but still very essential.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.jetbrains.com/resharper/&quot; title=&quot;https://www.jetbrains.com/resharper/&quot;&gt;Resharper&lt;/a&gt;&lt;/b&gt; - Probably the best developer tool (addin for Visual studio) for .NET development. It really pampers the developers, once hooked difficult to do without.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://www.ncrunch.net/&quot; title=&quot;www.ncrunch.net/&quot;&gt;nCrunch&lt;/a&gt;&lt;/b&gt; -
 Concurrent test running tool. At first I thought why would I need it but, its really clever and very useful while doing test driven development. It gives a live line by line code coverage and test result while typing… imagine that.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://www.specflow.org/&quot; title=&quot;http://www.specflow.org/&quot;&gt;specflow&lt;/a&gt;&lt;/b&gt; - Behaviour driven development framework and tool for .NET development in visual studio.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://git-scm.com/&quot; title=&quot;https://git-scm.com/&quot;&gt;Git&lt;/a&gt;&lt;/b&gt; - Opensource, fast distributed version control system which understands branching properly, &lt;b&gt;&lt;a href=&quot;https://www.sourcetreeapp.com/&quot; title=&quot;https://www.sourcetreeapp.com/&quot;&gt;Source tree&lt;/a&gt;&lt;/b&gt; is brilliant application for this.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.mercurial-scm.org/&quot; title=&quot;https://www.mercurial-scm.org/&quot;&gt;Mercurial&lt;/a&gt;&lt;/b&gt; - An alternative to Git, Tortoise Hg is a great tool for this - I was using it before GUI tools for git were not present on Windows.&lt;/p&gt;

&lt;h3 id=&quot;diff-tools&quot;&gt;Diff tools&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://diffuse.sourceforge.net/&quot; title=&quot;http://diffuse.sourceforge.net/&quot;&gt;Diffuse&lt;/a&gt;&lt;/b&gt; - good opensource python gtk based diff tool, it shows word differences, lightweight does what is supposed to and gets out of the way…&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools&quot; title=&quot;P4Merge&quot;&gt;P4Merge&lt;/a&gt;&lt;/b&gt; - its a free tool from perforce, I only use it for image comparisons…&lt;/p&gt;

&lt;h3 id=&quot;image-editing&quot;&gt;Image editing&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://gimp.org&quot; title=&quot;gimp.org&quot;&gt;Gimp&lt;/a&gt;&lt;/b&gt; - Fantastic tool, great effort from opensource community. This sorts my most of the raster image editing needs, I didn’t find any need for photoshop. Its got a great scripting interface &lt;em&gt;Script Fu&lt;/em&gt; for batch editing or procedural editing.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://inkscape.org/&quot; title=&quot;https://inkscape.org/&quot;&gt;Inkscape&lt;/a&gt;&lt;/b&gt; - Again, another opensource winner for vector graphics designing&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://wiki.gnome.org/Dia&quot; title=&quot;wiki.gnome.org/Dia&quot;&gt;Dia&lt;/a&gt;&lt;/b&gt; - Good free tool for doing illustrations / structured diagrams with connected elements with lot of clip art like things&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://products.office.com/en/visio/flowchart-software&quot; title=&quot;https://products.office.com/en/visio/flowchart-software&quot;&gt;Microsoft Viso&lt;/a&gt;&lt;/b&gt; -
 This is hands down the best diagramming tool money can buy with very big library of drawable elements. Outputs in various formats, also supports printer friendly versions. Good for professional documents.&lt;/p&gt;

&lt;h3 id=&quot;productivity&quot;&gt;Productivity&lt;/h3&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/mt173057.aspx&quot; title=&quot;https://msdn.microsoft.com/en-us/mt173057.aspx&quot;&gt;Powershell&lt;/a&gt;&lt;/b&gt; - Useful for automation of tasks. Powershell scripting can save a lot of time, it can interact with .NET assemblies as well&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.ruby-lang.org/&quot; title=&quot;https://www.ruby-lang.org/&quot;&gt;Ruby interpreter&lt;/a&gt;&lt;/b&gt; - Interactive ruby prompt is also very handy for everyday automation, scripting, file manipulation, operations on strings etc..&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.onenote.com/&quot; title=&quot;https://www.onenote.com/&quot;&gt;OneNote&lt;/a&gt;&lt;/b&gt; - Handy notebook tool which works across devices, supports clipping from internet (html copy paste), drawing etc..&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.focusboosterapp.com&quot; title=&quot;https://www.focusboosterapp.com&quot;&gt;Focus booster&lt;/a&gt;&lt;/b&gt; - Pomodoro technique is a great tool for improving productivity, I found this to be a great application for desktops, its free other features are not free.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://color.adobe.com/&quot; title=&quot;https://color.adobe.com/&quot;&gt;Kuler&lt;/a&gt;&lt;/b&gt; - Adobe’s kuler which is perfect tool for getting colour palettes for websites / applications / designing work&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;http://tunein.com/&quot; title=&quot;http://tunein.com/&quot;&gt;TuneIn radio&lt;/a&gt;&lt;/b&gt; - Online radio to listen to while working hard, focus booster and this is a paradox :)&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://office.live.com/start/Excel.aspx&quot; title=&quot;https://office.live.com/start/Excel.aspx&quot;&gt;Microsoft Excel&lt;/a&gt;&lt;/b&gt; - Spreadsheet tool with wide applications, once if you get used to it, its very difficult to do without. The online version is free but doesn’t support scripts.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.openoffice.org/&quot; title=&quot;https://www.openoffice.org/&quot;&gt;Openoffice Calc&lt;/a&gt;&lt;/b&gt; - A free alternative to Excel, not that powerful but does the job…&lt;/p&gt;

&lt;p&gt;&lt;b&gt;Task scheduler&lt;/b&gt; - the good old windows task scheduler can automate a lot of things, really easy and handy tool.&lt;/p&gt;

&lt;h3 id=&quot;d-modelling&quot;&gt;3D modelling&lt;/h3&gt;

&lt;p&gt;This maybe required for 3D printing, art work or game development or illustrations / walkthroughs etc.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.blender.org/&quot; title=&quot;Blender 3D&quot;&gt;Blender&lt;/a&gt;&lt;/b&gt; - I am a power user of blender, have been using it since the begining of it, its an inspirational opensource project. Nothing else is required for doing 3D. A 3D modeller, renderer, game and physics engine, it also supports video editing… phew. STL is supported for 3D printing. Great extensibility via the &lt;em&gt;python&lt;/em&gt; scripting interface.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.rhino3d.com&quot; title=&quot;https://www.rhino3d.com&quot;&gt;Rhino3D&lt;/a&gt;&lt;/b&gt; - Advanced tool for NURBS and surface based modelling. Not a free tool, it supports plugins.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;a href=&quot;https://www.tinkercad.com/&quot; title=&quot;TinkerCAD&quot;&gt;TinkerCAD&lt;/a&gt;&lt;/b&gt; TinkerCAD is a free online CAD tool. Its not having very elaborate tools but mostly gets everything done. Good for hobby 3D printing.&lt;/p&gt;
</description>
        <pubDate>Thu, 08 Oct 2015 20:24:00 +0000</pubDate>
        <link>https://softwarenature.com/posts/tools/2015/10/09/software-developers-recommended-toolbox/</link>
        <guid isPermaLink="true">https://softwarenature.com/posts/tools/2015/10/09/software-developers-recommended-toolbox/</guid>
        
        
        <category>posts</category>
        
        <category>tools</category>
        
      </item>
    
      <item>
        <title>The Conway&#39;s Law</title>
        <description>&lt;p&gt;This is an adage in Software Engineering, and it goes like&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“organizations which design systems … are constrained to produce designs which are copies of the communication structures of these organizations”
— M. Conway&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s been there since ages, even there in the Mythical Man Month by Fred Brooks. It sounds a little funny perhaps but, if we look deeper it is very natural and is a valid sociological observation.&lt;/p&gt;

&lt;p&gt;&lt;img align=&quot;middle&quot; src=&quot;http://softwarenature.com/assets/2015-10-03/conways2.png&quot; alt=&quot;The Conway&#39;s Law explained&quot; title=&quot;The Conway&#39;s Law explained&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Does the above figure look familiar?&lt;/p&gt;

&lt;p&gt;Communication plays the most important role in software development. It sounds obvious but, for techies this has to be constantly in our mind as we tend to drift towards what we like doing. I had a change of thought with the book Domain Driven Design by Eric Evans, and his talks. The essence is that software is always facilitating a certain domain. Immediately, the focus is shifted towards the “domain” i.e. away from architecture, technology, design  (all the good stuff). Hmm… well these things exist but they are driven by the domain. What we will get by this is a software that is desired by its users. It is one of the parameter of the product’s success.&lt;/p&gt;

&lt;p&gt;Hence, we can conclude that better communication will lead to better software (it also depends on how well it will be implemented but, still its going in the right direction).&lt;/p&gt;

&lt;p&gt;Software as a whole may be monolithic or it will be composed of various components - depending on the requirements. However, there will be parts of the software that are developed by different individuals. The way in which these individuals communicate, will affect their design.&lt;/p&gt;

&lt;h4 id=&quot;example&quot;&gt;Example&lt;/h4&gt;

&lt;p&gt;Lets say a team ‘C’ is developing a software product, team B is providing a functionality which can be integrated or consumed
into the product. If teams are closely located or communicating frequently their designs will harmonious, they
 will not have to define their own models. On the other hand if the teams are not frequently communicating, 
 they will come up with a more formal interface (similar to their formal communications) and each team
  will device their internal system which is not visible or of interest to other team apart from
   the common interface.&lt;/p&gt;

&lt;p&gt;Sometimes, this system results into a cleaner design as it is separating the concerns, as the system works and
 everyone is happy about their components. However, if the goals of the two teams are different the designs
  may not be compatible. Also, if the design needs to evolve to reuse / reduce redundant code at both ends, 
  if the changes in the system are frequent, requirements change - different teams may not respond in similar
   ways to them, and the design will be affected by it. For changes / scenarios like these, the teams will need 
   to change the way they communicate.&lt;/p&gt;

&lt;p&gt;Conway’s Law is a tool to understand as to why the design has a certain attributes, it is only a natural tendency of the system.&lt;/p&gt;

&lt;h4 id=&quot;further-reading&quot;&gt;Further reading&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;http://www.melconway.com/Home/Conways_Law.html&quot; title=&quot;Conways Law&quot;&gt;melconway.com - Conways Law&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Conway%27s_law&quot; title=&quot;Conways Law&quot;&gt;Wikipedia - Conways Law&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://c2.com/cgi/wiki?ConwaysLaw&quot; title=&quot;Conways Law&quot;&gt;c2 wiki - Conways Law&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Sat, 03 Oct 2015 20:24:00 +0000</pubDate>
        <link>https://softwarenature.com/posts/agile/2015/10/04/conways-law/</link>
        <guid isPermaLink="true">https://softwarenature.com/posts/agile/2015/10/04/conways-law/</guid>
        
        
        <category>posts</category>
        
        <category>agile</category>
        
      </item>
    
      <item>
        <title>A handy burn-down chart excel template</title>
        <description>&lt;p&gt;A burndown chart is a common tool for reporting the progress in scrum or umbrella term “agile” world.
It is a very pragmatic and simplest way to check progress of the work, &lt;strong&gt;if its on time, 
it will end at zero.&lt;/strong&gt; It also gamifies the work if teams frequently look at it, with an aim to finish it to zero. 
That makes it easy to understand by anyone in the team or management. If you are using the application 
lifecycle management (ALM) tools like Microsoft Team Foundation Server
 / Jira / Mingle etc, this comes in as a featured report.&lt;/p&gt;

&lt;p&gt;A typical burndown chart would span across a time period. I would start off with a certain quantity of &lt;em&gt;stuff&lt;/em&gt;
and progressively reducing that quantity. Examples of burndown charts in software development can be like below&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Release burndown&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Sprint burndown&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Defects burndown&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common trends observed in the burndown charts are like below:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-07-15/NoProgressBDC.png&quot; alt=&quot;Underestimated work&quot; title=&quot;Underestimated work&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Above shows an &lt;strong&gt;underestimated&lt;/strong&gt; amount of work or it also shows &lt;strong&gt;slack&lt;/strong&gt; or not enough progress 
in the time period.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-07-15/IncompleteSprint.png&quot; alt=&quot;Overshoot of work&quot; title=&quot;Overshoot of work&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Above shows an overshoot and there is an offset due to more &lt;strong&gt;work added&lt;/strong&gt; in between, 
which leads to an incomplete sprint (doesn’t end at zero).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-07-15/UnderestimatedBDC.png&quot; alt=&quot;Overestimated work&quot; title=&quot;Overestimated work&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Above shows that the work has been &lt;strong&gt;overestimated&lt;/strong&gt;. Actually it has been completed faster
than estimated. The team can add more work, and there is a need to re-estimate.&lt;/p&gt;

&lt;p&gt;Generally, anyone can use burndown charts, even construction contractors, editors, movie makers,
basically the people who want to manage an estimated amount of work over a period of time. 
I have made a simple template in MS Excel which will help chart the burndown of any work.&lt;/p&gt;

&lt;h4 id=&quot;using-the-template&quot;&gt;Using the template&lt;/h4&gt;

&lt;p&gt;Download the template from the location below. Observe the total amount of work you have started with
and feed the “Starting story points” field. Provide the “Number of days” in the sprint. Now observe the 
work completed during each day and record the new value of the remaining work at the end of each day.
I haven’t created the table for the details of work items (Tasks), as that can vary from requirement 
to requirement.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/2015-07-15/BurndownChartTemplate.png&quot; alt=&quot;Excel template&quot; title=&quot;Excel burndown template&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In the above template, there is a visual for the burndown, total amount of work completed and daily velocity.
I have found that the daily velocity charting does help manage the sprint better, 
if the concerned people watch the day’s velocity they will notice the slack / excessive speed 
and apply corrections accordingly. The pie chart is a very nice way to find out what percentage 
of the work has been completed, generally burndown charts don’t give this type of feeling.&lt;/p&gt;

&lt;p&gt;I hope this will be useful to people without the ALM tools. Happy work management…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Download&lt;/strong&gt; the template here: &lt;a href=&quot;http://1drv.ms/1DH3I3j&quot; title=&quot;Excel template&quot;&gt;One drive link&lt;/a&gt;&lt;/p&gt;
</description>
        <pubDate>Wed, 15 Jul 2015 12:01:13 +0000</pubDate>
        <link>https://softwarenature.com/blog/agile/2015/07/15/A-handy-burndown-chart-excel-template/</link>
        <guid isPermaLink="true">https://softwarenature.com/blog/agile/2015/07/15/A-handy-burndown-chart-excel-template/</guid>
        
        
        <category>posts</category>
        
        <category>agile</category>
        
      </item>
    
  </channel>
</rss>
