<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Tech Talk DC]]></title><description><![CDATA[Tech Talk DC]]></description><link>https://techtalkdc.com/</link><image><url>https://techtalkdc.com/favicon.png</url><title>Tech Talk DC</title><link>https://techtalkdc.com/</link></image><generator>Ghost 1.26</generator><lastBuildDate>Sun, 29 Jun 2025 21:59:40 GMT</lastBuildDate><atom:link href="https://techtalkdc.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Router-First Architecture in SPAs]]></title><description><![CDATA[Overcome web development challenges by following router-first architecture principles.]]></description><link>https://techtalkdc.com/router-first-architecture-in-spas/</link><guid isPermaLink="false">5b2ba59d73aee0000101b69b</guid><category><![CDATA[Angular]]></category><category><![CDATA[Architecture]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[TypeScript]]></category><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Thu, 21 Jun 2018 16:00:00 GMT</pubDate><media:content url="https://techtalkdc.com/content/images/2018/06/dev_with_shield_web.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://techtalkdc.com/content/images/2018/06/dev_with_shield_web.png" alt="Router-First Architecture in SPAs"><p><img src="https://techtalkdc.com/content/images/2018/06/illustration_v2-copy.png" alt="Router-First Architecture in SPAs"></p>
<p>Developing any software is a challenge in today's Agile environment with ever shifting requirements. Today's web is rapidly raising the bar on user expectations on how a good application should work and the pressure on front-end developers to delivering great user experiences (UX) is higher than ever. Especially in Single Page Applications (SPAs) using <a href="https://angular.io">Angular</a>, <a href="https://reactjs.org/">React</a>, <a href="https://vuejs.org/">Vue</a> or any other framework, architecting your solution to support this type of rapid change and potential growth is often an after thought. You can overcome these challenges by using router-first architecture. Let's first dig into what the challenges are.</p>
<h1 id="spachallenges">SPA Challenges</h1>
<p>There are two main challenges in developing your apps. First is defining your requirements and the second is the architecture.</p>
<h2 id="requirements">Requirements</h2>
<p>This is notoriously difficult to do, however even in Agile software development, you must remember that you can't take your first step without a roadmap in place. So, how can we ensure that we have a concrete representation of a roadmap that is not open to wide interpretation like user stories or requirements documents can be?</p>
<ul>
<li>Build a sitemap</li>
<li>Define different types of users that can log in to your system</li>
<li>Mockup rough drafts of all the views you can</li>
<li>Develop a walking skeleton of your application</li>
<li>As a bonus, insert the rough mockups in to your in progress app</li>
</ul>
<p>Doing these things will scope out the entire UX you intend to build. It will be your roadmap. It will help tease early feedback from stakeholders and if you have multiple developers on your team, they can work in parallel, just filling in the blanks without stepping on eachtother's toes.</p>
<h2 id="architecture">Architecture</h2>
<p>A walking skeleton of your application is a great start, but application archictecture is so much more than just having the right routing structure. The pieces of software you develop should be flexible and performant. However, it is possible to be overly-flexible and ovelry-optimized for the task at hand. This can waste a considerable amount of your budget and rob you users of valuable features or improvements. So, how can you hope to accomplish this?</p>
<ul>
<li>Leverage lazy-loading with modular development from the get go</li>
<li>Achieve a stateless, data-driven design</li>
<li>Enforce a decoupled component architecture</li>
<li>Create reusable user controls</li>
<li>Leverage ES6/TypeScript features to reuse code</li>
</ul>
<p>These are high-level recommendations and dive deep into them for Angular, TypeScript and RxJS, in my recently published book, <a href="http://angularforenterprise.com">Angular 6 for Enterprise-Ready Web Applications</a>.</p>
<h1 id="routerfirstprinciples">Router-First Principles</h1>
<p>In summary, a router-first architecture follows these principles:</p>
<ol>
<li>Develop a roadmap and scope</li>
<li>Design with lazy loading in mind</li>
<li>Implement a walking-skeleton navigation experience</li>
<li>Achieve a stateless, data-driven design</li>
<li>Enforce a decoupled component architecture</li>
<li>Differentiate between user controls and components</li>
<li>Maximize code reuse with ES6/TypeScript</li>
</ol>
<p>I will be talking about this topic more in meetups and conferences later this year, like on October 10-12 at <a href="https://angularmix.com">Angular Mix</a> in Orlando, FL.</p>
<p><img src="https://techtalkdc.com/content/images/2018/06/AngMIX_email_ULUCA.jpg" alt="Router-First Architecture in SPAs"></p>
<p>Hoping to see you there! In the mean time, you can get my book for a discount until June 24th, 2018.</p>
<p><strong>15% off Print + eBook:</strong> <em>AERWA15</em><br>
<strong>50% off eBook:</strong> <em>AERWA50</em></p>
<p><a href="https://www.packtpub.com/web-development/angular-6-enterprise-ready-web-applications">Buy in Print or eBook Today!</a></p>
</div>]]></content:encoded></item><item><title><![CDATA[Check out Doguhan's latest blogs]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Until further notice, I'll be blogging on the <a href="http://blog.excella.com">Excella Blog</a>.</p>
<p>I generally write about Agile Engineering, GitHub, JavaScript, Angular, Node, MongoDB, TypeScript and Docker.</p>
<p>To read my latest blogs, click <a href="https://www.excella.com/insights/author/doguhan-uluca">here</a>.</p>
</div>]]></description><link>https://techtalkdc.com/check-out-my-latest-blogs/</link><guid isPermaLink="false">5ad6917b59dadd000181384a</guid><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Fri, 07 Apr 2017 16:34:56 GMT</pubDate><content:encoded><![CDATA[<div class="kg-card-markdown"><p>Until further notice, I'll be blogging on the <a href="http://blog.excella.com">Excella Blog</a>.</p>
<p>I generally write about Agile Engineering, GitHub, JavaScript, Angular, Node, MongoDB, TypeScript and Docker.</p>
<p>To read my latest blogs, click <a href="https://www.excella.com/insights/author/doguhan-uluca">here</a>.</p>
</div>]]></content:encoded></item><item><title><![CDATA[Minimal MEAN]]></title><description><![CDATA[<p>It can be daunting to pick the right stack to deliver your idea to the cloud. Without realizing, you can introduce one too many &quot;sandbag of complexity&quot; between you and something you can release. For the first time ever it is possible to do full-stack development with a</p>]]></description><link>https://techtalkdc.com/minimal-mean/</link><guid isPermaLink="false">5ad6917b59dadd0001813849</guid><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Sat, 30 Apr 2016 14:30:49 GMT</pubDate><content:encoded><![CDATA[<p>It can be daunting to pick the right stack to deliver your idea to the cloud. Without realizing, you can introduce one too many &quot;sandbag of complexity&quot; between you and something you can release. For the first time ever it is possible to do full-stack development with a consistent set of tools and best practices using the same language, JavaScript. No more to context switching between front-end and back-end languages, libraries and tools. That is The JavaScript Promise. My easy to learn and use stack 'Minimal MEAN' will get you started and deployed on the cloud over a lazy weekend, without requiring a MongoDB install, while leveraging the latest tools like async/await with Typescript, ng2, Node v6.</p>
<p>In April 2016, I gave a talk on Minimal MEAN at <a href="https://nvite.com/novacodecamp/adbb">NOVA Code Camp 2016</a> and posted the code on <a href="https://github.com/excellalabs/minimal-mean">Excella Labs</a>. You may find my presentation slides below.</p>
<iframe src="//slides.com/doguhanuluca/minimal-mean/embed" width="576" height="420" scrolling="no" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>]]></content:encoded></item><item><title><![CDATA[You Can't Be the Master of Everything]]></title><description><![CDATA[<p><a href="http://theconnman.com">Brian Conn</a> gave a great talk at <a href="http://www.meetup.com/TechTalkDC/events/229488065/">Tech Talk DC</a> on Front-end development for full-stack developers.</p>
<p>Brian highlighted the pressures on full-stack developers to keep up with fast moving front-end libraries, tools and practices and highlighted the focus on <em>integrating</em> software vs <em>creating</em> software.</p>
<p>Brian has concrete suggestions to stay</p>]]></description><link>https://techtalkdc.com/you-cant-be-the-master-of-everything/</link><guid isPermaLink="false">5ad6917b59dadd0001813848</guid><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Thu, 21 Apr 2016 13:26:30 GMT</pubDate><content:encoded><![CDATA[<p><a href="http://theconnman.com">Brian Conn</a> gave a great talk at <a href="http://www.meetup.com/TechTalkDC/events/229488065/">Tech Talk DC</a> on Front-end development for full-stack developers.</p>
<p>Brian highlighted the pressures on full-stack developers to keep up with fast moving front-end libraries, tools and practices and highlighted the focus on <em>integrating</em> software vs <em>creating</em> software.</p>
<p>Brian has concrete suggestions to stay afloat as a full-stack developer. Some of the highlights includes:</p>
<ul>
<li>Evaluate, re-evaluate but don't expand core tool stack</li>
<li>Climb the bandwagon on new/cool tech <em>very carefully</em></li>
<li>Use a small number of mature frameworks</li>
<li>Get yourself out of the CSS game</li>
<li>Practice good front-end hygiene</li>
</ul>
<p>Overall, Brian, highlighted the importance of figuring out your strengths and weaknesses and accepting the reality that you can't be the master of everything.</p>
<p>You can download his slides right <a href="http://www.slideshare.net/duluca/frontend-development-for-full-stack-devs">here</a>.</p>
]]></content:encoded></item><item><title><![CDATA[Best Scalable Cloud Architecture: AWS Lambda]]></title><description><![CDATA[<p>On March 23rd, <a href="http://twitter.com/javascriptbully">Justin Winthers</a>, gave a presentation on AWS Lambda at the <a href="http://www.meetup.com/TechTalkDC/events/229487966/">Tech Talk DC Meetup</a>. After Justin's excellent presentation, I came away convinced that <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> is nothing short of revolutionary.</p>
<p>Justin talked about how he leveraged AWS Lambda to build <a href="http://hoozip.com">Hoozip</a>, a real-estate app for investors. He</p>]]></description><link>https://techtalkdc.com/best-scalable-cloud-architecture-aws-lambda/</link><guid isPermaLink="false">5ad6917b59dadd0001813847</guid><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Fri, 25 Mar 2016 14:55:17 GMT</pubDate><content:encoded><![CDATA[<p>On March 23rd, <a href="http://twitter.com/javascriptbully">Justin Winthers</a>, gave a presentation on AWS Lambda at the <a href="http://www.meetup.com/TechTalkDC/events/229487966/">Tech Talk DC Meetup</a>. After Justin's excellent presentation, I came away convinced that <a href="https://aws.amazon.com/lambda/">AWS Lambda</a> is nothing short of revolutionary.</p>
<p>Justin talked about how he leveraged AWS Lambda to build <a href="http://hoozip.com">Hoozip</a>, a real-estate app for investors. He also gave an example on how <a href="http://zillow.com">Zillow</a> was able execute 16 million requests on Lambda a month for a bill of $6 dollars. Yes, you read that correctly, six dollars.</p>
<p>Check out his presentation slides right <a href="http://www.slideshare.net/duluca/aws-lambda-presentation-tech-talk-dc">here</a> and feel free to ask questions in the comments below.</p>
]]></content:encoded></item><item><title><![CDATA[WordPress vs Ghost]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Tech Talk DC has migrated to <a href="https://ghost.org/">Ghost</a>. There were several factors behind this decision. While WordPress is feature-rich and has great community provided plug-ins, it is also unnecessarily complex and is slow.</p>
<h2 id="bloatandlockin">Bloat and Lock-in</h2>
<p>By moving Tech Talk DC to Ghost, I'll be losing some functionality, such as live</p></div>]]></description><link>https://techtalkdc.com/wordpress-to-ghost/</link><guid isPermaLink="false">5ad6917b59dadd00018137f9</guid><category><![CDATA[Blog]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Sat, 19 Mar 2016 15:00:00 GMT</pubDate><media:content url="https://techtalkdc.com/content/images/2018/07/wordpress-vs-ghost_raqxp1.png" medium="image"/><content:encoded><![CDATA[<div class="kg-card-markdown"><img src="https://techtalkdc.com/content/images/2018/07/wordpress-vs-ghost_raqxp1.png" alt="WordPress vs Ghost"><p>Tech Talk DC has migrated to <a href="https://ghost.org/">Ghost</a>. There were several factors behind this decision. While WordPress is feature-rich and has great community provided plug-ins, it is also unnecessarily complex and is slow.</p>
<h2 id="bloatandlockin">Bloat and Lock-in</h2>
<p>By moving Tech Talk DC to Ghost, I'll be losing some functionality, such as live blogging, Meetup.com integration or various plug-ins that have been used in some of the blog posts to render them nicely. These plug-ins pile on over time, they create ugly dependencies, but most importantly every plug-in added slows everything else down by a little.</p>
<p>I'll be bringing Disqus back and fix display issues in specific posts over time. However, the fact that I must edit old posts highlights one of the reasons for moving, vendor lock-in. Ghost posts are pure markdown, so they're portable to any current or future blogging platform.</p>
<h2 id="cost">Cost</h2>
<p>Hosting WordPress is expensive. I've been using <a href="http://www.bluehost.com">Blue Host</a> at a cost of $155 a year to host Tech Talk DC. Even though I pay for the high cost, because of the aforementioned bloat the blog runs very slowly. I can host Ghost on any server that can run <a href="http://www.nodejs.org">Node.js</a> and it is super fast. This is important because of all the mobile users out there.</p>
<p>I've chosen <a href="http://www.digitalocean.com">Digital Ocean</a> as my hosting platform. For $60 a year I can run an Ubuntu server that can not only serve my Ghost blog, but also some of my other websites like <a href="http://www.thejavascriptpromise.com">The JavaScript Promise</a> and not break a sweat.</p>
<h2 id="howtomigrate">How to Migrate</h2>
<p>There are many migration strategies as there are stars in the sky. I'll document what worked for me.</p>
<ol>
<li>Install the <a href="https://wordpress.org/plugins/ghost/">Ghost plug-in</a> to your WordPress site.</li>
<li>Under Tools menu, select Export to Ghost</li>
<li>Follow the instructions diligently :)</li>
<li>Export images to <a href="http://www.cloudinary.com">Cloudinary</a></li>
<li>Set-up Ghost on your local machine</li>
</ol>
<ul>
<li>Note: This requires familiarity with Node.js, if you're not a developer, you can purchase hosting from Ghost directly.</li>
</ul>
<ol>
<li>Import content using <code>sqlite3</code></li>
</ol>
<ul>
<li>Note: I've tried PostgreSql as well, but importing content never really worked with it. I went to great lengths to try different strategies like exporting SQL scripts out of sqlite and importing them into postgre. I even manually sliced and diced the import json file and tried the import that way manually fixing errors, but it never really fully worked against a postgre target.</li>
</ul>
<ol>
<li>Push your code to GitHub or BitBucket</li>
<li>Set up a Digital Ocean droplet</li>
</ol>
<ul>
<li>Note: Here I wanted to go fancy and leverage <a href="http://www.docker.com">Docker</a>. There's an official Ghost docker image. There's one based on Alpine linux with a tiny footprint. My initial idea was that I can isolate all my different sites as containers on my droplet. Initially I chose CoreOS as my OS, because it has a small footprint and pre-configured to host Docker containers. I failed. There were too many cryptic errors that was taking forever to overcome. Instead I went with an Ubuntu Node image. I intentionally didn't pick the Ubuntu Ghost image to avoid dealing with configuration I didn't understand. I ssh'ed into the server, used git to load my code, struggled with Ghost's config.js until I found the magical combination.</li>
</ul>
<ol>
<li>Start up your Node app(s) using nodemon, do the port/DNS song and dance and hook things up with your domain name</li>
</ol>
<ul>
<li>Note: If you want to setup multiple domains and multiple sites, in addition to ensuring your Node.js applications starting back up along side your server, check out this <a href="https://www.digitalocean.com/community/tutorials/how-to-host-multiple-node-js-applications-on-a-single-vps-with-nginx-forever-and-crontab">blog</a>.</li>
</ul>
<ol>
<li>Configure Mailgun</li>
</ol>
<h2 id="tldr">tl;dr</h2>
<p>Configuring Ghost on your own is not for the faint of heart. Expect a lot of banging of head to wall. But if you can overcome the issues, you'll end up with a simple, fast blogging, nay hosting platform of your own to host many Node.js apps in a $5 a month droplet.</p>
</div>]]></content:encoded></item><item><title><![CDATA[Why Should A Developer Care About Company Politics?]]></title><description><![CDATA[<p>My good friend <a href="https://twitter.com/saravbhatia">Sarav Bhatia</a> recently wrote <a href="https://medium.com/@saravbhatia/the-importance-of-politics-for-engineers-and-designers-learnings-from-pope-francis-and-francis-ce142330deca">an article </a>on the importance of company politics in relation to the careers of technical people. It is a great read.</p>
<p>If we care about our day to day happiness and the quality of our experiences at our jobs and the places we</p>]]></description><link>https://techtalkdc.com/why-should-a-developer-care-about-company-politics/</link><guid isPermaLink="false">5ad6917b59dadd0001813846</guid><category><![CDATA[Work Place]]></category><dc:creator><![CDATA[Doguhan Uluca]]></dc:creator><pubDate>Tue, 29 Sep 2015 09:03:00 GMT</pubDate><content:encoded><![CDATA[<p>My good friend <a href="https://twitter.com/saravbhatia">Sarav Bhatia</a> recently wrote <a href="https://medium.com/@saravbhatia/the-importance-of-politics-for-engineers-and-designers-learnings-from-pope-francis-and-francis-ce142330deca">an article </a>on the importance of company politics in relation to the careers of technical people. It is a great read.</p>
<p>If we care about our day to day happiness and the quality of our experiences at our jobs and the places we live in, politics is an unavoidable tool we must learn to utilize effectively. If you want a great job, chances are you already have that job, you just need to be willing to navigate the political structure of your company to mold your current job into the job you want to keep.</p>
<p>However, if you want to remain disinterested in the politics of your organization or what to “stay out of it”, than you should accept the fact that you’re just a passenger on a boat going somewhere and you really don’t know where that place is.</p>
<p>Check out Sarav’s article <a href="https://medium.com/@saravbhatia/the-importance-of-politics-for-engineers-and-designers-learnings-from-pope-francis-and-francis-ce142330deca">here</a>.</p>
<p></p>
]]></content:encoded></item><item><title><![CDATA[4 things to consider before creating your Ansible Playbook]]></title><description><![CDATA[<p><span class="s1">I recently started automating my build using <a href="http://www.ansible.com/home">Ansible</a> for a new project.  I heard great things about Ansible from colleagues who helped me get started and decided to take notes along the way. Here are a few items from the notes that you should consider before getting started.  </span></p>
<p><span class="s1"><strong>#1: The</strong></span></p>]]></description><link>https://techtalkdc.com/4-things-to-consider-before-creating-your-ansible-playbook/</link><guid isPermaLink="false">5ad6917b59dadd0001813845</guid><category><![CDATA[Automation]]></category><category><![CDATA[DevOps]]></category><dc:creator><![CDATA[mehtadev17]]></dc:creator><pubDate>Tue, 25 Aug 2015 10:21:00 GMT</pubDate><content:encoded><![CDATA[<p><span class="s1">I recently started automating my build using <a href="http://www.ansible.com/home">Ansible</a> for a new project.  I heard great things about Ansible from colleagues who helped me get started and decided to take notes along the way. Here are a few items from the notes that you should consider before getting started.  </span></p>
<p><span class="s1"><strong>#1: The plays have been created. You only have to put these together</strong></span></p>
<p><span class="s1">Chances are most of the roles you want to create have been implemented before. Take a look <a href="https://galaxy.ansible.com/">here</a> to find existing roles and use them in your playbook. If you absolutely have to write your own roles, use these as references to guide you. Moreover, there are many existing open-source playbooks for common automated builds that can be found with a quick google search. <a href="https://github.com/jcalazan/ansible-django-stack">Here</a> is an example of a common Django build playbook that I was able to reference. Remember to make your playbook, roles, etc open-source if you write your own custom automation.</span></p>
<p><span class="s1"><strong>#2: Know the difference between the Shell and Command modules</strong></span></p>
<p><span class="s1">Shell executes a task on the remote node using a shell which means it has access to basic shell operations and variable like $HOME, $PATH, &amp;&amp;, etc. Command module executes the specified command with arguments on all selected nodes and is not processed through the shell therefore cannot access shell operations and variables. Here is a example that highlights how one shell task can be used in place of two command tasks.</span></p>
<div>```
#Example Command 1
- name: Run a script in /usr/bin/
  command: /usr/bin/test_script.sh
<h1 id="examplecommand2">Example Command 2</h1>
<ul>
<li>name: Remove test_script.sh in /usr/bin/<br>
command: rm /usr/bin/test_script.sh</li>
</ul>
<h1 id="exampleshell">Example Shell</h1>
<ul>
<li>name: Run a script in /usr/bin/ and remove test_script.sh<br>
shell: test_script.sh ; rm test_script.sh<br>
chdir: /usr/bin/</li>
</ul>
<pre><code>
 

&lt;/div&gt;&lt;span class=&quot;s1&quot;&gt;**#3: Avoid using the Shell and Command modules**&lt;/span&gt;

&lt;span class=&quot;s1&quot;&gt;Ansible has a huge index of core modules that get installed by default. These modules make it easier to achieve simple tasks without the need to write shell scripts or commands. The list of modules can be found [here](http://docs.ansible.com/list_of_all_modules.html). Modules like pip, git, s3 (AWS), copy, yum and service make it easier to write and read Ansible playbooks. &lt;/span&gt;

Here is a simple example that migrates a database managed my Django.

&lt;div&gt;```
#Run Django database migration using django-manage module
- name: Run migration
  django_manage:
    app_path=/path/to/manage.py/
    command=migrate
    virtualenv=testenv
  sudo: no

#Run Django database migration using shell
- name: Run migration
  shell: &quot;source /testenv/bin/activate &amp;&amp; cd /path/to/manage.py/ &amp;&amp; python manage.py migrate&quot;
  sudo: no
</code></pre>
<p></p>
</div>As you can see, the built in django_manage module makes it tremendously easier and simpler to run a django specific command. On the other hand, the shell module is very complex in terms of readability and comprehension.
<p><span class="s1"><strong>#4: KISS And DRY</strong></span></p>
<p><span class="s1">I am a big proponent of the KISS (Keep it Simple Stupid!) and DRY (Don’t Repeat Yourself) software development principles. Split up you roles into individual standalone entities that can be used elsewhere. Moreover, this makes it easier for others to follow your playbook and customize as necessary. For example, create two distinct roles for database installation and database setup so that others can use the database install role but not the database specific setup role. A good rule of thumb is to split up a role when it becomes hard to maintain and read. </span></p>
<p><span class="s1"><strong>Conclusion</strong></span></p>
<p><span class="s1">Ansible is a very simple and direct automation tool with a large contributing user community. They have focused on building a tool that relies heavily on contributors to make modules, roles and playbooks in an open environment. I highly recommend trying out Ansible as your next automation tool and become a part of the growing community. </span></p>
]]></content:encoded></item><item><title><![CDATA[A First Look at Installing ASP.NET 5, Part 3: Ubuntu Linux]]></title><description><![CDATA[<p></p>
<p><em>This is the final part of a 3 part series exploring ASP.NET 5 running on Windows, Mac OSX and Linux.</em></p>
<p>Overall I found getting ASP.NET 5 to  run on Ubuntu to be quicker and easier than doing so for OS X. It might not have been easier than</p>]]></description><link>https://techtalkdc.com/a-first-look-at-installing-asp-net-5-part-3-ubuntu-linux/</link><guid isPermaLink="false">5ad6917b59dadd0001813844</guid><category><![CDATA[.NET]]></category><category><![CDATA[ASP.NET]]></category><dc:creator><![CDATA[brian-palladino]]></dc:creator><pubDate>Fri, 26 Jun 2015 17:00:05 GMT</pubDate><content:encoded><![CDATA[<p></p>
<p><em>This is the final part of a 3 part series exploring ASP.NET 5 running on Windows, Mac OSX and Linux.</em></p>
<p>Overall I found getting ASP.NET 5 to  run on Ubuntu to be quicker and easier than doing so for OS X. It might not have been easier than Installing Visual Studio 2015 RC on Windows given that it involved a lot more typing as opposed to just clicking a couple of “Download” and “Install” buttons, but it was certainly a lot faster.</p>
<p>I set up a fresh Ubuntu 14.04 VM in Parallels on my Macbook Pro and then followed the instructions at <a href="http://docs.asp.net/en/latest/getting-started/installing-on-linux.html">http://docs.asp.net/en/latest/getting-started/installing-on-linux.html</a> and <a href="https://github.com/aspnet/Home">https://github.com/aspnet/Home</a>.</p>
<p>Here’s what you need to do:</p>
<ol>
<li>Install mono: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo &quot;deb <a href="http://download.mono-project.com/repo/debian">http://download.mono-project.com/repo/debian</a> wheezy main&quot; | sudo tee /etc/apt/sources.list.d/mono-xamarin.list sudo apt-get update sudo apt-get install mono-complete</li>
<li>Install libuv: sudo apt-get install automake libtool curl curl -sSL <a href="https://github.com/libuv/libuv/archive/v1.4.2.tar.gz">https://github.com/libuv/libuv/archive/v1.4.2.tar.gz</a> | sudo tar zxfv - -C /usr/local/src cd /usr/local/src/libuv-1.4.2 sudo sh autogen.sh sudo ./configure sudo make sudo make install sudo rm -rf /usr/local/src/libuv-1.4.2 &amp;&amp; cd ~/ sudo ldconfig</li>
<li>Install the DNVM: curl -sSL <a href="https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh">https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh</a> | DNX_BRANCH=dev sh &amp;&amp; source ~/.dnx/dnvm/dnvm.sh</li>
<li>Add NuGet sources. <span class="NormalTextRun SCX35350121">Edit <span class="lang:default decode:true  crayon-inline ">~/.config/NuGet/NuGet.config</span> </span><span class="NormalTextRun SCX35350121"><span class="NormalTextRun SCX35350121"> with the following content (Note: I had to create this file and add the contents manually – I’m not sure if installing DNVM should have done it for me or not.):</span></span><?xml version="1.0" encoding="utf-8"?> <configuration> <packagesources> <add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2/"> <add key="nuget.org" value="https://www.nuget.org/api/v2/"> </add></add></packagesources> <disabledpackagesources> </disabledpackagesources></configuration></li>
<li>Get the latest DNX version: <span class="lang:default decode:true  crayon-inline ">dnvm upgrade</span></li>
<li>Install Git if it’s not already installed: <span class="lang:default decode:true  crayon-inline ">sudo apt-get install git</span></li>
<li>Clone the repo with their sample code: <span class="lang:default decode:true  crayon-inline ">git clone <a href="https://github.com/aspnet/Home">https://github.com/aspnet/Home</a></span></li>
<li><span class="TextRun SCX128585416" xml:lang="EN-US"><span class="NormalTextRun SCX128585416">Go to the directory containing the sample app you want to try out (I used </span></span><span class="TextRun SCX128585416" xml:lang="EN-US"><span class="NormalTextRun SCX128585416">home/samples/1.0.0-beta4/</span><span class="SpellingError SCX128585416">HelloMvc</span><span class="NormalTextRun SCX128585416">)</span></span></li>
<li>Load dependencies: <span class="lang:default decode:true  crayon-inline ">dnu restore</span></li>
<li>Start Kestrel: <span class="lang:default decode:true  crayon-inline ">dnx . kestrel</span></li>
<li>Check <a href="http://localhost:5004/">http://localhost:5004</a> in your browser</li>
</ol>
<p><span class="TextRun SCX219694259" xml:lang="EN-US"><span class="NormalTextRun SCX219694259">And lo and behold! I was doing something I never in my wildest dreams imagined would be possible: running an ASP.NET web site on an Ubuntu Linux box. </span></span><span class="EOP SCX219694259"> </span></p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493667/Screen-Shot-2015-06-09-at-3.51.00-PM_weji38.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_450,w_660/v1455493667/Screen-Shot-2015-06-09-at-3.51.00-PM_weji38.png?resize=660%2C450" alt="Screen Shot 2015-06-09 at 3.51.00 PM"></a></p>
<p><span class="TextRun SCX86407842" xml:lang="EN-US"><span class="NormalTextRun SCX86407842">VS Code also seems to work just fine on Ubuntu. </span></span><span class="EOP SCX86407842"> </span></p>
<figure class="wp-caption alignnone" id="attachment_1065" style="width: 660px">[![Screen Shot 2015-06-09 at 3.57.39 PM](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_450,w_660/v1455493668/Screen-Shot-2015-06-09-at-3.57.39-PM_mscfgp.png?resize=660%2C450)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493668/Screen-Shot-2015-06-09-at-3.57.39-PM_mscfgp.png)<figcaption class="wp-caption-text">You’ll never use Sublime Text again.</figcaption></figure>You’ll note that in the steps above, I pulled Microsoft’s samples from  [https://github.com/aspnet/Home](https://github.com/aspnet/Home) instead of using Yeoman to scaffold a project.
<p>While trying to install Yeoman, I encountered a number of errors and decided to skip ahead and see if I could get it working with one of their existing solutions first. Once I had done that, I did a little more research and discovered it’s a little different than for OS X.</p>
<p>I followed <a href="http://truthyfalsey.com/yeoman-working-ubuntu/">these instructions</a> and although I got some warnings about my node and npm versions being out of date (they aren’t).</p>
<p>I also had to install bower and grunt: <span class="lang:default decode:true  crayon-inline ">sudo npm install -g bower</span></p>
<p>It worked after that. I ran <span class="lang:default decode:true  crayon-inline ">sudo npm install -g yo generator-aspnet</span>  and then after that the command <span class="lang:default decode:true  crayon-inline ">yo aspnet</span>  worked, allowing me to scaffold out a new solution as described under OS X above.</p>
<p><strong>Overall Impressions</strong></p>
<p>Overall I have to say I was pleasantly surprised. I was expecting a lot more headaches trying to get up and running on a Mac or Linux box than I actually encountered, and as the product matures I’m sure the few errors I did run into will be resolved. Running from a command line in Windows didn’t seem to be a problem either.</p>
<p>Ironically, the most annoying installation was Visual Studio 2015 RC. It was a pretty glaring contrast between installing an enormous IDE and a number of much smaller command line installations. On the other hand – Visual Studio may have taken a long time (and hung at the end) but it was a single download and install – far less typing required and fewer steps where you could screw up.</p>
<p>I’ve only begun to play with VS Code, but I like what I see so far. For developers who’d rather use a Mac or a Linux box, it gives them a nice, lightweight IDE as an alternative to Visual Studio that will let them get up and running fast.</p>
<p>One enormous caveat to all of this is, of course, that ASP.NET 5 is still a work in progress and is not stable.  I’m sure some of you poor readers will try to follow the steps in one of these blog posts and discover all sorts of fun new errors and breaking changes. In that case, by all means leave a comment and let other readers know what you see and if you were able to resolve it. If it’s a new issue that hasn’t been reported yet, reporting it is as an issue in the <a href="https://github.com/aspnet">appropriate Github repo</a> is a great idea as well.</p>
<p>Still, I’m impressed with what Microsoft has come up with so far and I’m excited to see where they go from here.</p>
]]></content:encoded></item><item><title><![CDATA[A First Look at Installing ASP.NET 5, Part 2: OS X]]></title><description><![CDATA[<p><em>This is part 2 of a 3 part series exploring ASP.NET 5 running on Windows, Mac OSX and Linux.</em></p>
<p>Having tested ASP.NET 5 via Visual Studio and a command line on Windows in our last post, it was time to give it a try on OS X. I</p>]]></description><link>https://techtalkdc.com/a-first-look-at-installing-asp-net-5-part-2-os-x/</link><guid isPermaLink="false">5ad6917b59dadd0001813843</guid><category><![CDATA[.NET]]></category><category><![CDATA[ASP.NET]]></category><dc:creator><![CDATA[brian-palladino]]></dc:creator><pubDate>Fri, 26 Jun 2015 01:33:00 GMT</pubDate><content:encoded><![CDATA[<p><em>This is part 2 of a 3 part series exploring ASP.NET 5 running on Windows, Mac OSX and Linux.</em></p>
<p>Having tested ASP.NET 5 via Visual Studio and a command line on Windows in our last post, it was time to give it a try on OS X. I used my trusty Macbook Pro running OS X Yosemite v 10.0.3.</p>
<p>Since I have heavily abused my Mac, after going through the installation process I spun up an OS X VM with Parallels so I could repeat it on a clean system just in case my existing configuration somehow affected the process. I only noticed a couple of minor differences which I’ll make a note of below.</p>
<p>To install and run ASP.NET 5 on OS X, I followed the instructions at:   <a href="http://docs.asp.net/en/latest/getting-started/installing-on-mac.html">http://docs.asp.net/en/latest/getting-started/installing-on-mac.html</a></p>
<p>I already had X Code and its command line utilities, Homebrew, and Node JS and NPM installed on my Mac. I went ahead and installed the latest versions of all of these tools on my OS X VM as well.</p>
<p>From the terminal:</p>
<ol>
<li><span class="lang:default decode:true  crayon-inline ">brew tap aspnet/dnx</span>  (no errors)</li>
<li><span class="lang:default decode:true  crayon-inline ">brew install dnvm</span>  (no errors)</li>
<li><span class="lang:default decode:true  crayon-inline ">source dnvm.sh</span>  (no errors)</li>
<li><span class="lang:default decode:true  crayon-inline ">dnvm upgrade</span>  (get the latest version – no errors)</li>
</ol>
<p>Note: add <span class="lang:default decode:true  crayon-inline ">source dnvm.sh</span>  to ~/.bash_profile, ~/.bashrc or ~/.zshrc to avoid having to run ‘ source dnvm.sh’ again.</p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493687/Screen-Shot-2015-06-05-at-1.47.10-PM_m5u8xi.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_650,w_660/v1455493687/Screen-Shot-2015-06-05-at-1.47.10-PM_m5u8xi.png?resize=660%2C650" alt="Screen Shot 2015-06-05 at 1.47.10 PM"></a></p>
<p><span class="NormalTextRun SCX51449526">If DNVM is correctly installed, you should see something like this when you enter <span class="lang:default decode:true  crayon-inline ">dnvm</span> </span><span class="NormalTextRun SCX51449526"> in the terminal:</span></p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493686/Screen-Shot-2015-06-05-at-1.50.01-PM_chq3ae.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_369,w_660/v1455493686/Screen-Shot-2015-06-05-at-1.50.01-PM_chq3ae.png?resize=660%2C369" alt="Screen Shot 2015-06-05 at 1.50.01 PM"></a></p>
<p>Next, I followed the steps in Microsoft’s “<a href="http://docs.asp.net/en/latest/tutorials/your-first-mac-aspnet.html">Your First ASP.NET 5 Application on a Mac</a>” tutorial to set up my basic “Hello World” style solution.</p>
<p>First, I confirmed I had beta 4 version of DNX by running <span class="lang:default decode:true  crayon-inline ">dnvm list</span>  :</p>
<figure class="wp-caption alignnone" id="attachment_1051" style="width: 660px">[![Screen Shot 2015-06-09 at 12.45.10 PM](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_173,w_660/v1455493684/Screen-Shot-2015-06-09-at-12.45.10-PM_zp3wys.png?resize=660%2C173)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493684/Screen-Shot-2015-06-09-at-12.45.10-PM_zp3wys.png)<figcaption class="wp-caption-text">1.0.0-beta4 is the current-somewhat-stable release as of this post</figcaption></figure>At this point, I diverged from the Microsoft tutorial. They provide sample ASP.NET apps you can clone and try out   but if you want to build your own ASP.NET from scratch it seems you’re kind of out of luck without visual studio.
<p>In the tutorial, they have some placeholder text that says “Coming soon: instructions for getting started with <a href="http://yeoman.io/">Yeoman</a>.” Then they tell you to clone and try out some of their sample apps at <a href="https://github.com/aspnet/home">https://github.com/aspnet/home</a>. Intrigued, I read up on Yeoman and decided to give it a try.</p>
<p>On their website, Yeoman is described as follows:</p>
<blockquote>
<p>Yeoman helps you to kickstart new projects, prescribing best practices and tools to help you stay productive.</p>
<p>To do so, we provide a generator ecosystem. A generator is basically a plugin that can be run with the <code>yo</code> command to scaffold complete projects or useful parts.</p>
</blockquote>
<p>To <a href="http://yeoman.io/learning/index.html">install Yeoman</a>, you’ll need to install Nodejs and NPM first.</p>
<p>Next, install Yeoman and their asp.net generator:  <span class="lang:default decode:true  crayon-inline">npm install -g yo generator-aspnet</span></p>
<p><span class="TextRun SCX128716095" xml:lang="EN-US"><span class="NormalTextRun SCX128716095">When I tried this command on my Mac, I received a series of errors:</span></span><span class="EOP SCX128716095"> </span></p>
<p><a href="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493683/Screen-Shot-2015-06-05-at-2.07.59-PM_owewky.png"><img src="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_333,w_660/v1455493683/Screen-Shot-2015-06-05-at-2.07.59-PM_owewky.png?resize=660%2C333" alt="Screen Shot 2015-06-05 at 2.07.59 PM"></a></p>
<p>Trying it again with sudo resolved the problem: <span class="lang:default decode:true  crayon-inline ">sudo npm install -g yo generator-aspnet</span></p>
<p><a href="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493681/Screen-Shot-2015-06-05-at-2.08.19-PM_x6jiu8.png"><img src="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_363,w_660/v1455493681/Screen-Shot-2015-06-05-at-2.08.19-PM_x6jiu8.png?resize=660%2C362" alt="Screen Shot 2015-06-05 at 2.08.19 PM"></a></p>
<p><strong>SIDEBAR:</strong> When I repeated this step on my OS X VM, I was able to run <span class="lang:default decode:true  crayon-inline ">npm install -g yo generator-aspnet</span>  without using <span class="lang:default decode:true  crayon-inline ">sudo</span> . I assume this means when you log into an OS X VM on Parallels you have root access. I’m not sure how this works so if someone is more familiar with this topic please feel free to leave a comment.</p>
<p>Once Yeoman was installed, I used it to scaffold out an ASP.NET 5 app with the ridiculously simple <span class="lang:default decode:true  crayon-inline  ">yo aspnet</span> .</p>
<p>This brings up Yeoman’s asp.net generator, a command line tool that provides a list of project templates to choose from. I selected web application.</p>
<figure class="wp-caption alignnone" id="attachment_1054" style="width: 660px">[![Screen Shot 2015-06-05 at 2.16.12 PM](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_417,w_660/v1455493680/Screen-Shot-2015-06-05-at-2.16.12-PM_wyfiku.png?resize=660%2C417)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493680/Screen-Shot-2015-06-05-at-2.16.12-PM_wyfiku.png)<figcaption class="wp-caption-text">Fun Fact: The terminal command ‘yo’ is worth less money than the app Yo, despite being far more useful.</figcaption></figure>Next I gave my app a name when prompted and hit enter to create the scaffolding, then watched as it created all the necessary files:
<p><a href="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493679/Screen-Shot-2015-06-05-at-2.23.23-PM_a7w42n.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493679/Screen-Shot-2015-06-05-at-2.23.23-PM_a7w42n.png?resize=660%2C535" alt="Screen Shot 2015-06-05 at 2.23.23 PM"></a></p>
<p>A quick glance in Finder confirmed the new project files were all there, as expected.</p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493678/Screen-Shot-2015-06-05-at-2.26.34-PM_ducloo.png"><img src="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_300,w_279/v1455493678/Screen-Shot-2015-06-05-at-2.26.34-PM_ducloo.png?resize=279%2C300" alt="Screen Shot 2015-06-05 at 2.26.34 PM"></a></p>
<p>It’s beyond the scope of this post, but for future reference Yeoman’s asp generator <a href="http://tattoocoder.azurewebsites.net/asp-net-vnext-project-creation-using-yeoman/">provides command line options to add new components</a>, such as models, controllers, etc.</p>
<p>Although originally designed for *nix systems, Yeoman now supports Windows as well, so if you want to use a command line on a Windows box to scaffold new ASP.NET apps you can do so. See <a href="http://yeoman.io/codelab/setup.html">here</a> and <a href="http://blogs.msdn.com/b/cdndevs/archive/2014/11/24/part-1-getting-started-with-yeoman.aspx">here</a> for more.</p>
<p>Next, I downloaded and i<a href="https://code.visualstudio.com/Docs/setup">nstalled Visual Studio Code</a>. I noted that in contrast to the massive full version of Visual Studio, VS code was only a measly 64.7 MB download.</p>
<p>Installing VS Code was as simple as unzipping the downloaded file and dragged the VS Code icon to the applications folder. I then opened VS code and marveled at it’s minimalist interface – so far so good.</p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493677/Screen-Shot-2015-06-18-at-9.47.37-AM_qferjj.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_494,w_660/v1455493677/Screen-Shot-2015-06-18-at-9.47.37-AM_qferjj.png?resize=660%2C494" alt></a></p>
<p>I opened the project folder I’d just built with Yeoman and got a message about missing dependencies with a prompt to restore:</p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493676/Screen-Shot-2015-06-18-at-9.51.57-AM_hnr8e3.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_142,w_660/v1455493676/Screen-Shot-2015-06-18-at-9.51.57-AM_hnr8e3.png?resize=660%2C142" alt="Screen Shot 2015-06-18 at 9.51.57 AM"></a></p>
<p><span class="NormalTextRun SCX216595963">Hitting the ‘Restore’ button next to the message automatically downloaded and tried to install all dependencies from Terminal (as if I’d run <span class="lang:default decode:true  crayon-inline ">dnu restore</span> </span><span class="NormalTextRun SCX216595963">).</span></p>
<p><a href="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493675/Screen-Shot-2015-06-18-at-9.53.57-AM_g2yn2d.png"><img src="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_146,w_660/v1455493675/Screen-Shot-2015-06-18-at-9.53.57-AM_g2yn2d.png?resize=660%2C146" alt="Screen Shot 2015-06-18 at 9.53.57 AM"></a></p>
<p><span class="TextRun SCX105608462" xml:lang="EN-US"><span class="NormalTextRun SCX105608462">But I got some more errors and again the suggestion I try as root:</span></span><span class="EOP SCX105608462"> </span></p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493673/Screen-Shot-2015-06-18-at-9.54.08-AM_igwazo.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_434,w_660/v1455493673/Screen-Shot-2015-06-18-at-9.54.08-AM_igwazo.png?resize=660%2C434" alt="Screen Shot 2015-06-18 at 9.54.08 AM"></a></p>
<p><span class="TextRun SCX56971367" xml:lang="EN-US"><span class="NormalTextRun SCX56971367">So I tried running <span class="lang:default decode:true  crayon-inline ">sudo dnu restore</span> </span><span class="NormalTextRun SCX56971367"> from terminal myself and got some more errors:</span></span><span class="EOP SCX56971367"> </span></p>
<p>System.ComponentModel.Win32Exception: ApplicationName='bower', CommandLine='install', CurrentDirectory='/Users/brianpalladino/Projects/MacAspNet5App', Native error= Cannot find the specified file    at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0     at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in <filename unknown>:0     at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x00000] in <filename unknown>:0     at Microsoft.Framework.PackageManager.ScriptExecutor.Execute (Microsoft.Framework.Runtime.Project project, System.String scriptName, System.Func<code>2 getVariable) [0x00000] in &lt;filename unknown&gt;:0     at Microsoft.Framework.PackageManager.RestoreCommand+&lt;RestoreForProject&gt;d__74.MoveNext () [0x00000] in &lt;filename unknown&gt;:0   --- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in &lt;filename unknown&gt;:0     at System.Runtime.CompilerServices.TaskAwaiter</code>1[System.Boolean].GetResult () [0x00000] in <filename unknown>:0     at Microsoft.Framework.PackageManager.RestoreCommand+&lt;&gt;c__DisplayClass73_0+&lt;<executecommand>b__0&gt;d.MoveNext () [0x00000] in <filename unknown>:0   --- End of stack trace from previous location where exception was thrown ---    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0     at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0     at Microsoft.Framework.PackageManager.RestoreCommand+<executecommand>d__73.MoveNext () [0x00000] in <filename unknown>:0   ----------  Restore failed  ApplicationName='bower', CommandLine='install', CurrentDirectory='/Users/brianpalladino/Projects/MacAspNet5App', Native error= Cannot find the specified file</filename></executecommand></filename></filename></filename></executecommand></filename></filename></filename></filename></p>
<p>Fortunately, <a href="http://stackoverflow.com/questions/30361278/asp-net-on-mac-osx-build-failed-are-you-missing-an-assembly-reference">the omniscient demi-God Stack Overflow provided a resolution</a>:</p>
<p>sudo npm install -g bower  sudo npm install -g grunt-cli</p>
<p>I ran these commands and then ran ‘ dnu restore ‘ again. That worked – no more errors!</p>
<figure class="wp-caption alignnone" id="attachment_1062" style="width: 660px">[![All hails Stack Overflow!](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_212,w_660/v1455493671/Screen-Shot-2015-06-18-at-9.54.45-AM_ay6k3p.png?resize=660%2C211)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493671/Screen-Shot-2015-06-18-at-9.54.45-AM_ay6k3p.png)<figcaption class="wp-caption-text">All hail Stack Overflow!</figcaption></figure>Then I tried <span class="lang:default decode:true  crayon-inline">dnx .kestrel</span> to start the server, but got some more errors:
<p>Missing method .ctor in assembly /Users/brianpalladino/.dnx/packages/Microsoft.AspNet.Cryptography.Internal/1.0.0-beta4/lib/dnx451/Microsoft.AspNet.Cryptography.Internal.dll, type System.Runtime.InteropServices.DefaultDllImportSearchPathsAttribute  Can't find custom attr constructor image: /Users/brianpalladino/.dnx/packages/Microsoft.AspNet.Cryptography.Internal/1.0.0-beta4/lib/dnx451/Microsoft.AspNet.Cryptography.Internal.dll mtoken: 0x0a000004  * Assertion at class.c:5607, condition `!mono_loader_get_last_error ()' not met</p>
<p>Turns out I needed to upgrade the version of mono on my Mac. I read <a href="https://github.com/aspnet/Home/issues/518">this post</a> and tried <span class="lang:default decode:true  crayon-inline ">brew unlink mono</span>  (to unlink v 3, the version I had installed) then <span class="lang:default decode:true  crayon-inline ">brew install mono</span>  to get v 4.</p>
<p>I then ran <span class="lang:default decode:true  crayon-inline ">dnu restore</span>  again, just in case changing the version of mono might affect any project dependencies. I didn’t know if this was necessary but I figured it wouldn’t hurt anything.</p>
<p>THEN, I ran <span class="lang:default decode:true  crayon-inline ">dnx . kestrel</span>  again and it started!</p>
<p><a href="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493670/Screen-Shot-2015-06-18-at-9.58.15-AM_qvl6ut.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493670/Screen-Shot-2015-06-18-at-9.58.15-AM_qvl6ut.png?resize=586%2C71" alt="Screen Shot 2015-06-18 at 9.58.15 AM"></a></p>
<p>At this point, the nice tutorial I found on the internet told me I should be able to view the app in my browser at <a href="http://localhost:5001/">http://localhost:5001/</a>. As usual, the internet lied to me. I got the following exception when I tried to go to <a href="http://localhost:5001/">http://localhost:5001/</a>:</p>
<p>IOException: kqueue() FileSystemWatcher has reached the maximum nunmber of files to watch.  System.IO.KqueueMonitor.Add (System.String path, Boolean postEvents, System.Collections.Generic.List<code>1&amp; fds) [0x00000] in &lt;filename unknown&gt;  System.IO.KqueueMonitor.Scan (System.String path, Boolean postEvents, System.Collections.Generic.List</code>1&amp; fds) [0x00000] in <filename unknown>  System.IO.KqueueMonitor.Setup () [0x00000] in <filename unknown>  System.IO.KqueueMonitor.DoMonitor () [0x00000] in <filename unknown>  … and it goes on and on like that … do people really read these horrible things? ...</filename></filename></filename></p>
<p>Another quick search on this error found <a href="http://andreizubov.blogspot.ru/2015/04/getting-started-with-net-on-os-x-and.html">this handy post</a>. Solution:</p>
<ol>
<li>Stop kestrel (by hitting the Enter key)</li>
<li>Run <span class="lang:default decode:true  crayon-inline ">export MONO_MANAGED_WATCHER=false</span></li>
<li>Restart kestrel with <span class="lang:default decode:true  crayon-inline ">dnx . kestrel</span></li>
</ol>
<figure class="wp-caption alignnone" id="attachment_1064" style="width: 660px">[![Screen Shot 2015-06-09 at 2.05.31 PM](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_528,w_660/v1455493669/Screen-Shot-2015-06-09-at-2.05.31-PM_po8sro.png?resize=660%2C529)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493669/Screen-Shot-2015-06-09-at-2.05.31-PM_po8sro.png)<figcaption class="wp-caption-text">Trying to justify my salary with Hello World apps.</figcaption></figure>After this I refreshed my browser and… VOILA!
<p>After completing the steps above, I repeated the process on my Parallels OS X VM.</p>
<p>The second time around it all went very smoothly as I could implement the fixes for the various errors I got right from the start.</p>
<p><strong>OS X Installation Process Summarized</strong></p>
<p>Here is the entire process summarized after taking errors into account. You may need to use sudo on a few of these commands depending on whether or not you’re using a VM.</p>
<ol>
<li>Before starting: <a href="http://coolestguidesontheplanet.com/installing-homebrew-os-x-yosemite-10-10-package-manager-unix-apps/">Install X-code, command line tools, and Homebrew</a></li>
<li>Install DNVM: brew tap aspnet/dnx brew install dnvm source dnvm.sh export MONO_MANAGED_WATCHER=false dnvm upgrade</li>
</ol>
<p>3. To save yourself some typing and aggravation later, add <span class="lang:default decode:true  crayon-inline ">source dnvm.sh</span>  to ~/.bash_profile, ~/.bashrc or ~/.zshrc and add <span class="lang:default decode:true  crayon-inline ">export MONO_MANAGED_WATCHER=false</span>  to  ~/.bashrc<br>
4. Confirm you have the 1.0.0-beta4 version of DNX: <span class="lang:default decode:true  crayon-inline ">dnvm list</span><br>
5. Install NodeJs and npm: brew install node<br>
6. Install Yeoman &amp; Asp.Net Generator: <span class="lang:default decode:true  crayon-inline ">npm install -g yo generator-aspnet  </span><br>
7. Install Bower and Grunt: <span class="lang:default decode:true  crayon-inline ">npm install -g bower grunt-cli </span><br>
8. Scaffold an ASP.NET 5 app with Yeoman: <span class="lang:default decode:true  crayon-inline ">yo aspnet </span><br>
9. Go to the project directory and update project references: <span class="lang:default decode:true  crayon-inline ">dnu restore</span><br>
10. Start kestrel: <span class="lang:default decode:true  crayon-inline ">dnx . kestrel </span><br>
11. View the new web site in your brower: <a href="http://localhost:5001/">http://localhost:5001/</a><br>
12. To view or change the source code, download and install VS Code, open the newly created project in VS Code and verify there are no errors or missing references, then code away.</p>
<p>There! That wasn’t so bad was it? Now that we’ve conquered OS X, in our next post we’ll try this out on Ubuntu.</p>
]]></content:encoded></item><item><title><![CDATA[A First Look at Installing ASP.NET 5, Part 1: Windows]]></title><description><![CDATA[<p><em>This is part 1 of a 3 part series exploring ASP.NET 5 running on Windows, Mac OSX and Linux.</em></p>
<p><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728">By now, .NET developers who don’t live in caves are aware that </span></span><a href="http://weblogs.asp.net/scottgu/introducing-asp-net-5"><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728">the newest version of ASP.NET</span></span></a><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728">, in addition to being open source and in general very different</span></span></p>]]></description><link>https://techtalkdc.com/a-first-look-at-command-line-asp-net-5-part-1-windows/</link><guid isPermaLink="false">5ad6917b59dadd0001813842</guid><category><![CDATA[.NET]]></category><category><![CDATA[.Net Core]]></category><category><![CDATA[ASP.NET]]></category><category><![CDATA[Visual Studio Code]]></category><dc:creator><![CDATA[brian-palladino]]></dc:creator><pubDate>Fri, 19 Jun 2015 12:28:00 GMT</pubDate><content:encoded><![CDATA[<p><em>This is part 1 of a 3 part series exploring ASP.NET 5 running on Windows, Mac OSX and Linux.</em></p>
<p><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728">By now, .NET developers who don’t live in caves are aware that </span></span><a href="http://weblogs.asp.net/scottgu/introducing-asp-net-5"><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728">the newest version of ASP.NET</span></span></a><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728">, in addition to being open source and in general very different from previous iterations, is designed to run on multiple platforms, allowing us to finally start coding in C# on Macs and Linux machines.</span></span><span class="TextRun SCX231189728" xml:lang="EN-US"><span class="NormalTextRun SCX231189728"> They are courageously helping us “blow out some Windows” so to speak.</span></span><span class="EOP SCX231189728"> </span></p>
<p>There are already a number of <a href="https://github.com/aspnet/home">tutorials</a> and <a href="http://docs.asp.net/en/latest/conceptual-overview/aspnet.html">resources</a> online for how get started with ASP.NET 5 on a Mac or a Linux box, but since the framework is still under development and is constantly changing, I thought it would be useful to go through the process, see if I ran into any issues not highlighted in Microsoft’s current tutorials and “Getting Started” resources, and generally get a feel for how difficult it would be.</p>
<p>I find that most developers (myself included) spend far more time than they think they will installing and configuring new frameworks, tools, and environments than they think they will going in the door. It shouldn’t take three days to get that shiny new “lightweight” ORM all the cool kids are using working properly in your environment, but then somehow it does.</p>
<p>My goal here was to see just how difficult getting up and running with ASP.NET 5 on my Mac and on a Linux box would be. How many errors would I run into? What forgotten step or missing environment variable would make me lose three hours of my life trying to figure out what was wrong? What cryptic error message would I see that doesn’t show up in a Google search?  How bad would the stress headaches be? Would I be vomiting up blood 16 hours into fixing a bad install?</p>
<p>With <a href="https://code.visualstudio.com/">Visual Studio Code</a> they have also developed a lightweight, cross platform IDE that I decided to try out as well.</p>
<p>Finally, I noted that Microsoft is now offering an option to run ASP.NET 5 apps via command line in Windows, without having to install Visual Studio, so I decided to give that a go as well. Windows command prompt, Mac OS X and Ubuntu terminals… That’s a lot of keyboard action. Hence the title of this post.</p>
<p>Although I did encounter several issues, overall I was pleasantly surprised. The process was much smoother than I expected.</p>
<p>Before continuing, you should understand a few basic terms specific to the new .NET:</p>
<ul>
<li>DNX: .Net Execution Environment (the new .NET runtime basically)</li>
<li>DNVM: .Net Version Manager (select and manage DNX versions)</li>
<li>DNU: DNX Utility (package management tool for .Net apps)</li>
</ul>
<p>For more detail, see Microsoft’s <a href="http://docs.asp.net/en/latest/dnx/overview.html">DNX  overview</a>.</p>
<p>Caveat: ASP.NET 5 is still under development and constantly changing at the time of this post. If you try to reproduce the steps I used it is entirely possible you may see different behavior or errors. Keep that in mind.</p>
<p>Now, with all of that out of the way, let’s see how it all went.</p>
<p><strong>My Environment</strong></p>
<p>My experiment was conducted on a Macbook Pro running OS X Yosemite  – v 10.0.3. I used Parallels to create the different VMs I used to test the process.</p>
<p>I set up a Windows 8.1 VM so I could install ASP.NET 5 via Visual Studio the old fashioned way as a control scenario before playing with OS X and Ubuntu. I had a Windows 7 VM I’d already been using and did the command line install for Windows sans Visual Studio on that machine.</p>
<p>Since I have heavily abused my trusty Mac, after going through the installation process I spun up an OS X VM so I could repeat it on a clean system, without having to worry if my existing configuration somehow affected the process. I only noticed a couple of minor differences which I’ll make a note of.</p>
<p>Finally, I created an Ubuntu 14.04 VM to try it out on Linux.</p>
<p><strong>Getting Started on Windows with Visual Studio: The Control Scenario</strong></p>
<p>Before diving into uncharted waters I decided to try out ASP.NET 5 in a familiar environment.</p>
<p>Following Microsoft’s <a href="http://docs.asp.net/en/latest/getting-started/installing-on-windows.html">instructions</a>, I tried out ASP.NET 5 on Windows by downloading and installing <a href="https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx">Visual Studio 2015 RC</a> (Enterprise Edition) on a Windows 8.1 VM.</p>
<p>The download and installation took a while, seemed to be almost done and finally hung at “Configuring your system. This might take a while.” The message didn’t lie. It did take while. I waited over an hour before I finally gave up.</p>
<figure class="wp-caption alignnone" id="attachment_1038" style="width: 660px">[![Hung VS Install - Screen Shot 2015-06-04 at 8.10.08 PM](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_833,w_660/v1455493697/Hung-VS-Install-Screen-Shot-2015-06-04-at-8.10.08-PM_sfijza.png?resize=660%2C833)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493697/Hung-VS-Install-Screen-Shot-2015-06-04-at-8.10.08-PM_sfijza.png)<figcaption class="wp-caption-text">How long will it take to configure my system Microsoft? HOW LONG?!?!</figcaption></figure>Since I like to live dangerously, I decided to take a chance and hope the installation had really finished and that it would still work if I pulled the plug. I tried to cancel the installation (at least, that’s what I assumed the ‘Cancel’ button was for) but it didn’t actually do so – it just kept right on going.
<p>Then I killed it in task manager and tried to open VS 2015 from the start menu, but I got an error that I couldn’t open it since setup was still running – even though I had just killed it in task manager and no process appeared.</p>
<p>Ah, this was the good old Microsoft we’ve all come to know and love.</p>
<p>At this point I defaulted to the old rule of thumb: <a href="https://www.youtube.com/watch?v=nn2FB1P_Mn8">when in doubt, reboot</a>. So I restarted the VM. Much to my surprise, after Windows rebooted the Visual Studio installation suddenly resumed and this time it actually completed. I was, like <a href="https://www.youtube.com/watch?v=RP8uhXuS2n8">‘woah’</a>.</p>
<p>Once it completed I was able to open VS 2015 from the start menu and started the “<a href="http://docs.asp.net/en/latest/tutorials/your-first-aspnet-application.html">Your First ASP.NET 5 Application Using Visual Studio</a>” walk through.</p>
<p>When creating new project, I did spot a small bug – note the Asian characters at the bottom right in the following screen shot. Not being knowledgeable in Asian alphabets I don’t know what language this was, so if you know and would like to leave a comment, please enlighten me.</p>
<p><a href="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493695/New-Project-asian-chars-Screen-Shot-2015-06-04-at-8.40.10-PM_sqs1re.png"><img src="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_408,w_660/v1455493695/New-Project-asian-chars-Screen-Shot-2015-06-04-at-8.40.10-PM_sqs1re.png?resize=660%2C407" alt="New Project asian chars - Screen Shot 2015-06-04 at 8.40.10 PM"></a></p>
<p></p>
<figure class="wp-caption alignnone" id="attachment_1075" style="width: 300px">[![Reading English is already hard enough for me Microsoft.](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_145,w_300/v1455493665/Screen-Shot-2015-06-05-at-1.00.45-PM_zfg5kv.png?resize=300%2C145)](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493665/Screen-Shot-2015-06-05-at-1.00.45-PM_zfg5kv.png)<figcaption class="wp-caption-text">Reading English is already hard enough for me Microsoft.</figcaption></figure>Other than that, the rest of the walk through went smoothly and I didn’t have any problems. I was able to get a bare bones “Hello World” type ASP.NET 5 Web app up and running.
<p>I did note two things that might surprise another n00b like myself:</p>
<ul>
<li>One of the coolest new features in ASP.NET 5 is the ability to make code changes and have them immediately show up on refreshing the browser but without rebuilding the whole application. This didn’t seem to work for me at first – then I went back and reread the instructions and also checked <a href="http://stackoverflow.com/questions/24082161/asp-net-vnext-compile-code-dynamically-not-working-for-me">Stack Overflow</a> and realized you had to run the app WITHOUT debugging to use this feature.</li>
<li>I noticed that if you make a change to project.json, the new and improved framework immediately tries to execute a ‘dnu restore’ command and update project dependencies on the fly. Something to be aware of.</li>
</ul>
<p>Aside from <a href="https://www.youtube.com/watch?v=uMyCa35_mOg">a sluggish installation</a> and a label from the wrong language appearing on the screen, I didn’t have any other problems doing it the old fashioned way. Visual Studio and its installation process isn’t that different, so if you’re sticking with Windows and Visual Studio “Getting Started” with ASP.NET won’t be too different from previous versions up to this point.</p>
<p>With the control scenario out of the way, I moved on to the main event.</p>
<p><strong>Getting Started on Windows With a Command Line</strong></p>
<p>Microsoft’s <a href="http://docs.asp.net/en/latest/getting-started/installing-on-windows.html">Installing ASP.NET 5 on Windows</a> walkthrough also included instructions for doing so without Visual Studio. I decided to give it a try before moving on to OS X and Ubuntu. Run ASP.NET without Visual Studio? “Impossible!” I shouted out loud. After my coworkers stopped staring at me I gave it a shot and confirmed that it is, in fact possible.</p>
<p>As instructed, I opened a command prompt as Admin and ran the following command to download and install the DNVM:<code>&lt;br&gt;&lt;/br&gt;</code></p>
<p>@powershell -NoProfile -ExecutionPolicy unrestricted -Command &quot;&amp;{$Branch='dev';iex ((new-object net.webclient).DownloadString('<a href="https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1">https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1</a>'))}&quot;</p>
<p>No errors – so far so good.</p>
<figure class="wp-caption alignnone" id="attachment_1042" style="width: 660px">[![Screen Shot 2015-06-10 at 3.42.59 PM](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_328,w_660/v1455493694/Screen-Shot-2015-06-10-at-3.42.59-PM_jn8tjl.png?resize=660%2C328)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493694/Screen-Shot-2015-06-10-at-3.42.59-PM_jn8tjl.png)<figcaption class="wp-caption-text">Oh Command Prompt, I wish I knew how to quit you.</figcaption></figure>Next I opened a new command prompt and verified DNVM was working by typing <span class="lang:default decode:true  crayon-inline ">dnvm</span> `.`
<p>I saw the expected result indicating DNVM was installed, but also got an interesting error:</p>
<figure class="wp-caption alignnone" id="attachment_1043" style="width: 660px">[![Red is usually bad.](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_383,w_660/v1455493694/Screen-Shot-2015-06-10-at-3.50.12-PM_zfx4sy.png?resize=660%2C383)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493694/Screen-Shot-2015-06-10-at-3.50.12-PM_zfx4sy.png)<figcaption class="wp-caption-text">Red is usually bad.</figcaption></figure>I Googled the error but didn’t find anything relevant, so I decided to try to keep going and see what happened.
<p>The next step was to install the DNX by running <span class="lang:default decode:true  crayon-inline">dnvm upgrade</span> <code></code>and I got another error.<a href="http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493693/Screen-Shot-2015-06-10-at-4.02.34-PM_nmjoek.png"><img src="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_291,w_660/v1455493693/Screen-Shot-2015-06-10-at-4.02.34-PM_nmjoek.png?resize=660%2C291" alt="Screen Shot 2015-06-10 at 4.02.34 PM"></a></p>
<p>I then tried <span class="lang:default decode:true  crayon-inline">dnx</span> to see if DNX was installed in spite of this error, and it seemed that it was:<a href="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493692/Screen-Shot-2015-06-10-at-4.08.17-PM_ufh91r.png"><img src="http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_275,w_660/v1455493692/Screen-Shot-2015-06-10-at-4.08.17-PM_ufh91r.png?resize=660%2C275" alt="Screen Shot 2015-06-10 at 4.08.17 PM"></a></p>
<p>Then I cloned the source from <a href="https://github.com/aspnet/home">https://github.com/aspnet/home</a> so I could try running one of their sample apps. (NOTE: I used the sample apps in the 1.0.0-beta4 folder since I suspect those in the ‘latest’ folder are more likely to be unstable.)</p>
<p>I switched into the HelloMvc sample app directory and ran <span class="lang:default decode:true  crayon-inline">dnu restore</span><br>
which seemed to run successfully.</p>
<p>I then ran <span class="lang:default decode:true  crayon-inline ">dnx . kestrel </span> and it looks like it worked – it started, but only after a nice security warning from Windows popped up:</p>
<p><a href="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493689/Screen-Shot-2015-06-10-at-4.20.18-PM1_cvamu9.png"><img src="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_468,w_660/v1455493689/Screen-Shot-2015-06-10-at-4.20.18-PM1_cvamu9.png?resize=660%2C467" alt></a></p>
<p><span class="TextRun SCX64506237" xml:lang="EN-US"><span class="NormalTextRun SCX64506237">Once I allowed access I was able to view the site in my browser at </span></span><a href="http://localhost:5004/"><span class="TextRun SCX64506237" xml:lang="EN-US"><span class="NormalTextRun SCX64506237">http://localhost:5004/</span></span></a></p>
<p><a href="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493688/Screen-Shot-2015-06-10-at-4.27.33-PM_mmqeao.png"><img src="http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/h_370,w_660/v1455493688/Screen-Shot-2015-06-10-at-4.27.33-PM_mmqeao.png?resize=660%2C370" alt="Screen Shot 2015-06-10 at 4.27.33 PM"></a></p>
<p><a href="http://en.wiktionary.org/wiki/Qapla%27">QAPLA’!</a> Now I had a Hello-World ASP.NET site running without ever touching Visual Studio.</p>
<p>The errors I got installing the DNX do not seem to have been fatal. A cursory Google search didn’t reveal much. I took a quick look at <a href="https://github.com/aspnet/dnvm/blob/dev/src/dnvm.ps1">the code</a>, but I’m not sure what the problem is. The affected block of code in the ‘dnvm’ powershell script appears to be intended to spit out a list of DNVM commands.</p>
<p>The next day I tried it again and while I still get the first error when running <span class="lang:default decode:true  crayon-inline ">dnvm</span> <code></code>from a command prompt, I no longer get the second error when running  <span class="inline-margin:15 wrap:true lang:default decode:true crayon-inline">dnvm upgrade.</span></p>
<p>Hmmm. These errors don’t seem to have an effect, but one never likes to see strange errors on a new product.</p>
<p>Here’s a step by step summary of the process described above:</p>
<ol>
<li>Open a command prompt as administrator</li>
<li>Download and install DNVM: @powershell -NoProfile -ExecutionPolicy unrestricted -Command &quot;&amp;{$Branch='dev';iex ((new-object net.webclient).DownloadString('<a href="https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1">https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1</a>'))}&quot;</li>
<li>Confirm DNVM is installed: <span class="lang:default decode:true  crayon-inline ">dnvm</span></li>
<li>Install latest version of DNX: <span class="lang:default decode:true  crayon-inline ">dnvm upgrade</span></li>
<li>Get Microsoft’s sample ASP.NET code: <span class="lang:default decode:true  crayon-inline ">git clone <a href="https://github.com/aspnet/home">https://github.com/aspnet/home</a></span></li>
<li>CD to the source folder of whichever sample app you want to run and load dependencies: <span class="lang:default decode:true  crayon-inline ">dnu restore</span></li>
<li>Start Kestrel: <span class="lang:default decode:true  crayon-inline ">dnx . kestrel</span></li>
<li>View the site in your browser at <a href="http://localhost:5004/">http://localhost:5004/</a></li>
</ol>
<p>I noticed there didn’t seem to be a way to scaffold out a new solution in any of Microsoft’s docs. So that confused me a bit. Later, I learned about Yeoman, but we’ll get to that shortly.</p>
<p><em>Now that we’re all suitably impressed that we can run ASP.NET via command line in Windows, in our next post we’ll move on to OS X. Subcribe to TechTalkDC.com for updates and follow <a href="http://www.twitter.com/techtalkdc">@techtalkdc</a>. Stay tuned.</em></p>
]]></content:encoded></item><item><title><![CDATA[Python Technical Guide: An Introduction to PDB]]></title><description><![CDATA[<p>Any software developer knows that good code doesn’t get written right the first time, and when unexpected behavior occurs eyeballing the code or even using print statements can end up falling short. This year at PyCon, I had the pleasure of attending <a href="https://www.youtube.com/watch?v=P0pIW5tJrRM">a talk by Clayton Parker</a> about an</p>]]></description><link>https://techtalkdc.com/an-introduction-to-pdb/</link><guid isPermaLink="false">5ad6917b59dadd0001813841</guid><category><![CDATA[debug]]></category><category><![CDATA[Django]]></category><category><![CDATA[pdb]]></category><category><![CDATA[Python]]></category><dc:creator><![CDATA[kurtw]]></dc:creator><pubDate>Fri, 05 Jun 2015 15:06:00 GMT</pubDate><content:encoded><![CDATA[<p>Any software developer knows that good code doesn’t get written right the first time, and when unexpected behavior occurs eyeballing the code or even using print statements can end up falling short. This year at PyCon, I had the pleasure of attending <a href="https://www.youtube.com/watch?v=P0pIW5tJrRM">a talk by Clayton Parker</a> about an extensively useful Python module affectionately called <a href="https://docs.python.org/3/library/pdb.html">pdb</a>.</p>
<p>The official Python documents define pdb as “<a href="https://docs.python.org/3/library/pdb.html">an interactive source code debugger for Python programs.</a>” Those programmers that use IDE’s like Eclipse or PyCharm will probably be familiar with the concept of an interactive debugger as they come with one baked in. This article will assume that you are not using one of these debuggers. Now, let’s look at an example of its use.</p>
<p>import pdb message = &quot;The circumference of the circle is &quot; pdb.set_trace() pi = 3.1415 r = 5 def calculate circumference(pi, radius): return 2<em>pi</em>r print message + (calculate circumference(pi, r))</p>
<p>Let’s take a look at what we’ve got here. It’s a simple program that prints out the circumference of a circle with a radius of 5. At the top we’ve imported the pdb module and on line 4 we’ve added the line <span class="lang:python decode:true  crayon-inline">pdb.set_trace()</span> , which is what’s called a breakpoint for the code to stop at on execution. Now, let’s go ahead and run this program with <span class="lang:python decode:true  crayon-inline ">python circle.py</span> . Here’s what we get:</p>
<blockquote>
<p>/Users/kurt/ExcellaDevelop/python/circle.py(5)<module>() -&gt; pi = 3.1415 (Pdb)</module></p>
</blockquote>
<p>The debugger has stopped the execution of the program and is showing the next line after the breakpoint. It is important to note that the line that pdb shows has not been executed yet. So, what if instead you’re debugging a massive file and you forget where you are in the code? There’s a command for that! Enter the command <span class="lang:python decode:true  crayon-inline ">l</span>  or <span class="lang:python decode:true  crayon-inline ">list</span> . That will list out 11 lines of code and an arrow on the line that the debugger is stopped on.</p>
<p>(Pdb) l 1 import pdb 2 3 message = &quot;The circumference of the circle is &quot; 4 pdb.set_trace() 5 -&gt; pi = 3.1415 6 r = 5 7 8 9 def calculate_circumference(pi, radius): 10 return 2<em>pi</em>r 11</p>
<p>Now that we know where we are in the program, we can try printing out some values using the command <span class="lang:python decode:true  crayon-inline ">p</span>  or <span class="lang:python decode:true  crayon-inline ">print</span> . You can enter the command, <span class="lang:python decode:true  crayon-inline ">p pi</span>  or <span class="lang:python decode:true  crayon-inline ">p pi, r</span>  to get the value(s) of the variables. If we try to print out a variable that has not yet been instantiated then we’ll get a NameError, as seen below. Now, let’s traverse through the program with the <span class="lang:python decode:true  crayon-inline ">n</span>  or <span class="lang:python decode:true  crayon-inline ">next</span>  command.</p>
<p>(Pdb) n &gt; /Users/kurt/Excella/Develop/python/circle.py(6)<module>() -&gt; r = 5 (Pdb) p pi, r *** NameError: NameError(&quot;name 'r' is not defined&quot;,) (Pdb) p pi 3.1415</module></p>
<p>Great, just as expected. It executed line 5 and is now showing line 6, but it hasn’t executed line 6 yet. That’s demonstrated by trying to print out <span class="lang:python decode:true  crayon-inline ">r</span>  before it’s declared. If we decided that we only wanted to execute the program up to this point, we could just use the <span class="lang:python decode:true  crayon-inline ">q</span>  or <span class="lang:python decode:true  crayon-inline ">quit</span>  command to exit the program. However, this is a bit dirty and you could also use <span class="lang:python decode:true  crayon-inline ">c</span>  or <span class="lang:python decode:true  crayon-inline ">continue</span>  to execute the rest of the program to completion (or the next breakpoint).</p>
<p>But we’re not done yet. Let’s move on to the next line. What if we want to test out to code as if the variable <span class="lang:python decode:true  crayon-inline ">r</span>  had a different value? The debugger will let you do that! Let’s set <span class="lang:python decode:true  crayon-inline ">r = 8</span> .</p>
<p>(Pdb) n &gt; /Users/kurt/Excella/Develop/python/circle.py(6)<module>() -&gt; r = 5 (Pdb) n &gt; /Users/kurt/Excella/Develop/python/circle.py(9)<module>() -&gt; def calculate_circumference(pi, radius): (Pdb) r = 8 &gt; /Users/kurt/Excellanevelop/python/circle.py(12)<module>() -&gt; print message + str(calculate_circumference(pi, r))</module></module></module></p>
<p>What happened? It accepted the input <span class="lang:python decode:true  crayon-inline ">r</span>  and executed a built-in command called return, which resumes execution until the function returns. The way around this is to put a <span class="lang:python decode:true  crayon-inline ">!</span>  before, so now the command is <span class="lang:python decode:true  crayon-inline ">!r = 8</span> .</p>
<blockquote>
<p>/Users/kurt/Excella/Develop/python/circle.py(9)<module>() -&gt; def calculate_circumference(pi, radius): (Pdb) !r = 8 (Pdb)</module></p>
</blockquote>
<p>That’s more like it. The last command that we’ll discuss is the <span class="lang:python decode:true  crayon-inline ">s</span>  or <span class="lang:python decode:true  crayon-inline ">step</span>  command. If we run <span class="lang:python decode:true  crayon-inline ">next</span>  again we’ll skip the function definition because it’s not part of the current execution and get to the last line. This calls the function <span class="lang:python decode:true  crayon-inline ">calculate_circumference()</span>  and returns the circumference. When this line is next in execution <span class="lang:python decode:true  crayon-inline ">step</span>  will “step into” the function call.</p>
<p>(Pdb) s --Call-- &gt; /Users/kurt/Excella/Develop/python/circle.py(9)calculate_circumference() -&gt; def calculate_circumference(pi, radius): (Pdb) n &gt; /Users/kurt/Excella/Develop/python/circle.py(10)calculate_circumference() -&gt; return 2<em>pi</em>r (Pdb) --Return-- &gt; /Users/kurt/Excella/Develop/python/circle.py(10)calculate_circumference()-&gt;50.264 -&gt; return 2<em>pi</em>r (Pdb) The circumference of the circle is 50.264 --Return-- &gt; /Users/kurt/Excella/Develop/python/circle.py(12)<module>()-&gt;None -&gt; print message + str(calculate_circumference(pi, r))</module></p>
<p>That’s all we’ll cover now, but that’s sure not the whole of it. There is still plenty to learn and experiment with pdb. I urge you to use pdb for your debugging needs in python if you’re not already doing so, and keep doing it if you are!</p>
<p>There’s a python package called <a href="https://pypi.python.org/pypi/ipdb">ipdb</a> that adds syntax highlighting and completion. I highly suggest that you check it out if you have a chance.</p>
]]></content:encoded></item><item><title><![CDATA[To ORM or Not To ORM]]></title><description><![CDATA[<p>ORM or Object Relational Mapping give developers easy access to the database by connecting objects to database tables. ORMs are easy to use and set up, but can cause performance problems for complex queries. Here are a few tips on when to use the ORM and when not to:</p>
<p><strong>To</strong></p>]]></description><link>https://techtalkdc.com/to-orm-or-not-to-orm/</link><guid isPermaLink="false">5ad6917b59dadd0001813840</guid><category><![CDATA[Data Access]]></category><dc:creator><![CDATA[mehtadev17]]></dc:creator><pubDate>Sat, 30 May 2015 10:00:00 GMT</pubDate><content:encoded><![CDATA[<p>ORM or Object Relational Mapping give developers easy access to the database by connecting objects to database tables. ORMs are easy to use and set up, but can cause performance problems for complex queries. Here are a few tips on when to use the ORM and when not to:</p>
<p><strong>To ORM</strong></p>
<p>ORMs should be used when querying database models since they enable you to query the database directly from your code. As a result, you do not have to write extra SQL code in your applications. ORMs make the code base cleaner, easier to maintain and highly readable by centralizing the data models. This makes it easier for other developers to understand and add value to the code base. Therefore, you should use an ORM if your priority is to build lean applications.</p>
<p><strong>Not To ORM</strong></p>
<p>ORMs should not be used when there is a need to specify exactly what SQL runs on the database. For example, ORMs should not be used in data migrations because they permanently change the state of the database. Furthermore, database migrations done via the ORM that update data will update ALL of the data. Therefore you should know exactly what SQL code is executed during database migrations. ORMs should not be used for simple sql scripts that don’t need to be maintained or run more than once. ORMs can also lead to performance issues for complex SQL queries if not configured properly.</p>
<p>In conclusion, ORMs are very powerful and can make your lives better when used properly. ORMs allow you to start developing lean applications quickly and easily. In most cases, you should use an ORM when querying database models instead of writing those queries in SQL. However, queries that change the state of the database like migrations or one-off scripts should not be done via an ORM. Remember, with great power comes great responsibility so be careful or get tangled in the webs.</p>
]]></content:encoded></item><item><title><![CDATA[Three of the Most Common Mistakes Made when Using Elasticsearch]]></title><description><![CDATA[<p>In addition to being a top choice for enterprise search, Elasticsearch is also growing in popularity as an all-purpose datastore.  It’s easy to scale, it’s extremely fast, and it can be accessed via a RESTful API.  Because the documentation can be difficult to maneuver, there are a number</p>]]></description><link>https://techtalkdc.com/three-of-the-most-common-mistakes-made-when-using-elasticsearch/</link><guid isPermaLink="false">5ad6917b59dadd000181383e</guid><category><![CDATA[data]]></category><category><![CDATA[Data Storage]]></category><category><![CDATA[elasticsearch]]></category><dc:creator><![CDATA[dford]]></dc:creator><pubDate>Tue, 05 May 2015 21:15:00 GMT</pubDate><content:encoded><![CDATA[<p>In addition to being a top choice for enterprise search, Elasticsearch is also growing in popularity as an all-purpose datastore.  It’s easy to scale, it’s extremely fast, and it can be accessed via a RESTful API.  Because the documentation can be difficult to maneuver, there are a number of traps that new Elasticsearch users often fall prey to.  Here are some of the most common mistakes I’ve noticed while working with Elasticsearch at CFPB, with some additional tidbits learned at PyCon 2015 in Montreal:</p>
<h3 id="notexplicitlydefiningamapping">Not explicitly defining a mapping</h3>
<p>Elasticsearch claims to be a “schema-free” data store.  Lo and behold, you can fire up an Elasticsearch cluster, create an index, and feed it a JSON document without even thinking about schemas.  I find calling it “schema-free” to be a little misleading, however.</p>
<p>What’s actually happening behind the scenes is Elasticsearch is going through each field of the JSON document you indexed, making its best guess at which type each field is, and creating a schema for you (a “mapping” in the Elasticsearch world).  For example, if it encounters “2014-05-15”, it will add a “date” entry to the mapping for the field.  Likewise, 15.5 would be a float, and 2500 would be an integer.</p>
<p>So if Elasticsearch makes a mapping for you, what’s the problem?  Well, Elasticsearch isn’t always right.  There are certain situations where the wrong type is picked, and next thing you know you’re getting indexing errors!</p>
<p>How to fix?  Always explicitly define mappings, ESPECIALLY in any production-like environment.  The best practice here is to index a few documents, letting Elasticsearch guess the types for you.  Next go grab your mapping: <code>GET /index-name/doc_type/_mapping</code><br>
Next, make any changes you see fit.  Don’t leave anything up to chance!</p>
<h3 id="settingstoreyesforoneormorefields">Setting <code>store = yes</code> for one or more fields</h3>
<p>By default, the full document you index in Elasticsearch is stored in a field called _source.  When you run a query on a certain field, for example, Elasticsearch has  no problem going into _source and querying on that particular field.</p>
<p>It’s also possible to store individual fields separately by setting <code>store = yes</code> in the mapping for a field.  Keep in mind, everything is already stored in the _source field.  Some people think this will speed things up, but in reality, this often causes multiple reads vs. the default single read of _source, slowing things down.  Unless you know exactly what you’re doing, resist using <code>store = yes</code></p>
<h3 id="usingquerieswhenyoushouldbeusingfilters">Using queries when you should be using filters</h3>
<p>This is easily the most common of the three mistakes.  New Elasticsearch users often use queries only.  Why are there both queries and filters, and what is the difference between the two?</p>
<p>**Queries **should be used when performing a full-text search, when scoring of results is required (think search results ranked by relevancy).</p>
<p>In almost all other cases, **filters **should be used.  Filters are much faster than queries, mainly because they don’t score the results.  If you just want to return all of the widgets that are blue, or that cost more than $10, use filters!</p>
<p>It’s also possible to do a filtered query.  So if you only need to perform a full-text search on a subsection of your data, filter it first, then run the query.  It will be much faster that way.</p>
<p>In conclusion: if you need a full text search server, or if you want to play around with a NoSQL datastore, I highly recommend giving Elasticsearch a try.  Just make sure to avoid these common pitfalls, and you’ll be way ahead of the pack.</p>
]]></content:encoded></item><item><title><![CDATA[.NET Technical Guide: AutoFac]]></title><description><![CDATA[<h1 id="introduction">Introduction</h1>
<p><em>What is AutoFac?</em></p>
<p>The principle of Dependency Inversion states that you should rely on abstractions instead of concretions. It leads to code that is more scalable, testable, and maintainable because it allows us to quickly and easily swap out implementations (examples of this concept are in the following sections)</p>]]></description><link>https://techtalkdc.com/net-technical-guide-autofac/</link><guid isPermaLink="false">5ad6917b59dadd000181383d</guid><category><![CDATA[.NET]]></category><category><![CDATA[Articles]]></category><dc:creator><![CDATA[adam-zarger]]></dc:creator><pubDate>Thu, 30 Apr 2015 11:00:36 GMT</pubDate><content:encoded><![CDATA[<h1 id="introduction">Introduction</h1>
<p><em>What is AutoFac?</em></p>
<p>The principle of Dependency Inversion states that you should rely on abstractions instead of concretions. It leads to code that is more scalable, testable, and maintainable because it allows us to quickly and easily swap out implementations (examples of this concept are in the following sections). While this can be manually implemented, dependency management tools like AutoFac will automate the process for you. This technical guide will demonstrate the principle of Dependency Inversion and it’s implementation using AutoFac to manage your dependencies.**** ****</p>
<h1 id="dependencyinversion">Dependency Inversion</h1>
<p><em>What is it and why does it matter?</em></p>
<p>What does it mean to rely upon abstractions instead of concretions? To put it simply, it means we should strive to use interfaces in place of the implementations of those interfaces. A more concrete example of what this looks like in a program is explored in a later section. The reference section can also provide more information.**** ****</p>
<p>Taking advantage of dependency inversion can provide several advantages in your code:</p>
<ul>
<li>****Testability:****Injecting implementations of classes at runtime allows us the flexibility to use either the intended production implementation or a mocked version of that class. This swapping makes writing effective and encompassing unit tests a breeze.</li>
<li><strong>Separation of Concerns:</strong> Good programming practice dictates that independent logic should be isolated from unrelated functionality. Dependency inversion compliments this practice by forcing you to separate your unrelated logic into isolated classes.</li>
<li><strong>Extensibility/Scalability:</strong> When you have the ability to swap out implementations very quickly, it allows you extend the functionality of your system. For example, it is very simple to swap out one implementation of a class for another implementation with higher performance.</li>
<li>****Maintainability:****Dependency injection allows you to change implementations by changing a few lines instead of hunting down and manually swapping out multiple instances across your system.</li>
</ul>
<p>One of the most commonly used methods of adhering to dependency inversion is called dependency injection. The key to dependency injection is to “inject” (meaning pass in a version of the class in question at runtime) the implementations of classes at runtime, which allows the code to be flexible in it’s implementations. To illustrate what dependency injection is, let’s explore a simple example.**** ****</p>
<h1 id="dependencyinjectionasimpleexample">Dependency Injection: A Simple Example</h1>
<p><em>An illustration of why to use dependency injection</em></p>
<p>For our example we will create three main components: a driver class to run the console application, a status monitor class that is responsible for monitoring something, and a status writer for the status monitor to use to output the status. We will go through several iterations of code; first setting up the program, then introducing dependency injection, and finally adding AutoFac and leveraging it’s automated dependency handling.**** ****</p>
<p>FIrst, create a project in Visual Studio. I will be creating a C# Console Application for the purposes of simplicity. I named my main class Driver.cs and also created a helper class called StatusMonitor.cs, as seen in Figures A and B.</p>
<figure class="wp-caption aligncenter" id="attachment_1135" style="width: 497px">[![Figure A - Basic Driver class](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493664/Figure-A_f0t3zo.png?resize=497%2C274)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493664/Figure-A_f0t3zo.png)<figcaption class="wp-caption-text">Figure A – Basic Driver class</figcaption></figure>**** ****
<figure class="wp-caption aligncenter" id="attachment_765" style="width: 261px">[![Figure B - Empty StatusMonitor class](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493771/Figure-B-empty-statusMonitor_anbqjv.png?resize=261%2C163)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493771/Figure-B-empty-statusMonitor_anbqjv.png)<figcaption class="wp-caption-text">Figure B – Empty StatusMonitor class</figcaption></figure>The last class we need to write is the OldStatusWriter. The OldStatusWriter simply prints out a string to the console (indicating its “status”) via the WriteStatusToConsole method. OldStatusWriter uses the built-in object StreamWriter to do the actual work of printing to the console. The actual implementation of OldStreamWriter isn’t super important for this example, but the source code is included for reference (Figure C).**** ****
<p>We will also need to implement StatusMonitor to use OldStatusWriter to print out a status. The implementation of this can be seen in Figure D.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_1136" style="width: 694px">[![Figure C - OldStatusWriter class](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493664/Figure-C_eo9i3q.png?resize=660%2C416)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493664/Figure-C_eo9i3q.png)<figcaption class="wp-caption-text">Figure C – OldStatusWriter class</figcaption></figure>**** ****
<figure class="wp-caption aligncenter" id="attachment_1137" style="width: 526px">[![Figure D - StatusMonitor using OldStatusWriter](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493663/Figure-D_hk9pj3.png?resize=526%2C325)](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493663/Figure-D_hk9pj3.png)<figcaption class="wp-caption-text">Figure D – StatusMonitor using OldStatusWriter</figcaption></figure>When we run this console application, it will pop open the console, print out its status, and then wait for a key to be pressed before closing.**** ****
<p>Now that we have a foundation, let’s remember the problem we had in the initial example: having to replace an implementation.**** ****</p>
<p>Before we dive into how AutoFac can handle this situation for us, let’s make our lives a little easier by laying the groundwork for using dependency injection. The first thing we’ll do is create an interface for OldStatusWriter: IStatusWriter**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_768" style="width: 294px">[![Figure E - IStatusWriter interface](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493770/Figure-E-IStatusWriter_xgkh6z.png?resize=294%2C113)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493770/Figure-E-IStatusWriter_xgkh6z.png)<figcaption class="wp-caption-text">Figure E – IStatusWriter interface</figcaption></figure>Now, instead of creating a new instance of OldStatusWriter within the StatusMonitor, let’s make it a parameter to the constructor. This will allow us the freedom to use any status writer that we want, as long as it implements the IStatusWriter interface.**** ****
<figure class="wp-caption aligncenter" id="attachment_1138" style="width: 541px">[![Figure F - StatusMonitor with an interface argument](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493662/Figure-F_xsnusn.png?resize=541%2C325)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493662/Figure-F_xsnusn.png)<figcaption class="wp-caption-text">Figure F – StatusMonitor with an interface argument</figcaption></figure>Just as a sanity check, let’s re-run our program now that we’ve implemented the beginnings of dependency injection. It should still output the old status. Don’t forget to pass an instance of OldStatusWriter to the StatusMonitor in the Driver!**** ****
<figure class="wp-caption aligncenter" id="attachment_1139" style="width: 669px">[![Figure G - Passing OldStatusWriter to StatusMonitor in the Driver](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493661/Figure-G_ypdzs4.png?resize=660%2C265)](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493661/Figure-G_ypdzs4.png)<figcaption class="wp-caption-text">Figure G – Passing OldStatusWriter to StatusMonitor in the Driver</figcaption></figure>So now that we have some infrastructure in place, let’s swap out our OldStatusWriter with the NewStatusWriter (Figure H). For the purposes of this example, the only real difference between the Old and New status writers will be the status that it outputs.**** ****
<p>Because we have created IStatusWriter and passed an instance of it into the StatusMonitor, all we need to do is have NewStatusWriter implement the IStatusWriter interface. Then we can pass in a NewStatusWriter as a parameter when we create a new StatusMonitor in the Driver class (Figure I).**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_771" style="width: 684px">[![Figure H - NewStatusWriter class](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493769/Figure-H-NewStatusWriter_xbrzf6.png?resize=660%2C359)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493769/Figure-H-NewStatusWriter_xbrzf6.png)<figcaption class="wp-caption-text">Figure H – NewStatusWriter class</figcaption></figure>**** ****
<figure class="wp-caption aligncenter" id="attachment_1140" style="width: 686px">[![Figure I - Driver with NewStatusWriter](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493660/Figure-I_scemjb.png?resize=660%2C256)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493660/Figure-I_scemjb.png)<figcaption class="wp-caption-text">Figure I – Driver with NewStatusWriter</figcaption></figure>If we run our program again, we see that it prints out a new status, indicating that it is now using the NewStatusWriter. With one simple change, we have now replaced all the instances of OldStatusWriter within project with NewStatusWriter.**** ****
<p>We can register our interfaces and classes with AutoFac, and it will inject whatever implementation we designate for every instance of each interface. This registration code can even be pulled out into AutoFac Modules for better separation of interests. The following sections will cover AutoFac set up, registering classes and interfaces, and making Modules.**** ****</p>
<h1 id="autofac">AutoFac</h1>
<p><em>Introducing AutoFac to the example</em>**** ****</p>
<p>Now we will introduce AutoFac to our project and set it up to handle all the dependency injection for us. The first thing to do is include the AutoFac package. Open up the package manager, select “Online”, search for AutoFac and install it.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_773" style="width: 675px">[![Figure J - Package Manager with AutoFac](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493768/Figure-J-Package-Manager-with-AutoFac_dinsoa.png?resize=660%2C498)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493768/Figure-J-Package-Manager-with-AutoFac_dinsoa.png)<figcaption class="wp-caption-text">Figure J – Package Manager with AutoFac</figcaption></figure>First, we will register the OldStatusWriter with AutoFac. To register types with AutoFac, We must create a ContainerBuilder (called builder in the example code). For each type we want to register, we call builder.RegisterType().**** ****
<p>The ContainerBuilder class is used to register all the Interfaces you wish to be controlled by AutoFac. By calling the ContainerBuilder’s “RegisterType()” method, you can tell AutoFac to register classes as instances of interfaces. When you register a class as an interface, AutoFac will then handle the injection of the actual class through the interface at runtime.**** ****</p>
<p>Once registered, how do you actually get the implementation of an interface to use in your code? There are two main ways of doing this. The first way is to let AutoFac inject the implementation into the constructor of the class using it. This method is the most common approach.**** ****</p>
<p>But what if you’re in a situation where you can’t simply inject an implementation into a constructor? In cases like that, you can use the Container we set up earlier to actually resolve the interface to it’s implementation. See Figure K: when we call “builder.Build()”, we are telling AutoFac that we are done registering and wish to start receiving implementations from the container. This is done by calling “container.Resolve()”. When resolved, the container searches its registered interfaces for one that matches the arguments (See Figure K, line 14) and injects whatever implementation is registered for that interface.**** ****</p>
<p>In the snippet below, we have registered the OldStatusWriter as an instance of the IStatusWriter interface. This tells AutoFac to inject a newly created instance of OldStatusWriter anywhere that the code is using IStatusWriter. When you run this code, it will report the status from the OldStatusWriter, as expected.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_1141" style="width: 791px">[![Figure K - Driver using AutoFac](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493660/Figure-K_cbtzjd.png?resize=660%2C304)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493660/Figure-K_cbtzjd.png)<figcaption class="wp-caption-text">Figure K – Driver using AutoFac</figcaption></figure>Now, let’s register our newer type, NewStatusWriter. We will register it in the Driver class directly after the OldStatusWriter, to demonstrate AutoFac’s ability to inject on the fly. We will then print out the status again (See Figure L).**** ****
<figure class="wp-caption aligncenter" id="attachment_1142" style="width: 793px">[![Figure L - AutoFac Injection at runtime](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493659/Figure-L_okp2ji.png?resize=660%2C396)](http://i1.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493659/Figure-L_okp2ji.png)<figcaption class="wp-caption-text">Figure L – AutoFac Injection at runtime</figcaption></figure>When you run this iteration of our project, the console prints out both the old status and the new status. This happens because we first registered OldStatusWriter as IStatusWriter and printed it’s status, and then re-registers NewStatusWriter to IStatusWriter and printed it’s status. AutoFac knows which implementation to inject based on what implementation you register.**** ****
<p>AutoFac allows us to inject whatever implementation of an interface that we want into the code at runtime. One powerful way to leverage this functionality is feature switching. Feature switching is a concept where you use different implementations of things in different environments.Thanks to AutoFac, feature switching is as simple as modifying the registration command. Let’s do a simple example.**** ****</p>
<p>Since we now have some duplication of code, let’s pull out the common code into a shared method.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_1143" style="width: 787px">[![Figure M - Driver with a common Register method](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493658/Figure-M_pd1sum.png?resize=660%2C482)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493658/Figure-M_pd1sum.png)<figcaption class="wp-caption-text">Figure M – Driver with a common Register method</figcaption></figure>As always, let’s test this again to make sure we don’t have any problems. Running the application should result in both status messages printing out to the console.**** ****
<p>While we’re at it, why don’t we use AutoFac to manage our StatusMonitor as well? This is not necessary, but it is good practice because it enforces the concept of what kinds of classes we want to inject versus instantiate. There are three main types of classes in this sense:</p>
<ul>
<li>****Services:****A class that operates on more than one other class or depends on more than one other class. One way to tell if a class falls into this category is if you are instantiating other classes within it. For an example of what a service might look like, see the FAQ section.</li>
<li><strong>Models:</strong> A model is a class that primarily contains properties. A model can have methods, but those methods only operate on members of that class. For an example of what a model might look like, see the FAQ section.</li>
<li><strong>Helpers:</strong> A helper is a class that contains logic, but only performs that logic on data that is passed into the helper. Helpers are typically static classes. See the FAQ section for more examples of helper classes.**** ****</li>
</ul>
<p>Services are usually the most numerous and are the only classes that are candidates for injection. Dependency injection is useful for swapping out implementations; it doesn’t make sense to swap out a model or helper who really only have one implementation of their functionality. For services, simply create an interface for any classes that are necessary dependencies and pass those interfaces into the dependent method as constructor arguments.**** ****</p>
<p>We will implement an IStatusMonitor interface and use that to inject the implementation in at runtime.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_777" style="width: 288px">[![Figure N - IStatusMonitor interface](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493768/Figure-N-IStatusMonitor_ee36tf.png?resize=288%2C115)](http://i2.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493768/Figure-N-IStatusMonitor_ee36tf.png)<figcaption class="wp-caption-text">Figure N – IStatusMonitor interface</figcaption></figure>**** ****
<figure class="wp-caption aligncenter" id="attachment_1144" style="width: 758px">[![Figure O - Driver with IStatusMonitor registered](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493657/Figure-O_odmifg.png?resize=660%2C531)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493657/Figure-O_odmifg.png)<figcaption class="wp-caption-text">Figure O – Driver with IStatusMonitor registered</figcaption></figure>Great! Now we have removed all of the places where we have created a new instance of a class (except for AutoFac classes, of course). This makes our code more maintainable and testable – maintainable because the injection allows us to easily swap out the implementation of components, and testable because we can write unit tests that inject mocked versions of dependencies that we can test against.**** ****
<p>Let’s clean up our Main method a little bit by pulling out the StatusMonitor creation into its own method. We will use the same Container object that we used for setting up the StreamWriter.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_1145" style="width: 767px">[![Figure P - Driver using the Single Responsibility Principle](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493656/Figure-P_x3hk7g.png?resize=660%2C591)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493656/Figure-P_x3hk7g.png)<figcaption class="wp-caption-text">Figure P – Driver using the Single Responsibility Principle</figcaption></figure>Even though this is a very simple and small project, our Main method feels cluttered with all the AutoFac set up happening in it. This is where the concept of a Module shines. A module is an AutoFac construct that is used to handle all the AutoFac set up and keep that set up out of your code’s logic. The power of modules is they can be separated logically with the structure of your project. In this guide, we use one module for the entire project, but it makes sense to split your modules up by purpose. For example, it is common to have one module for every different part of your system. This could mean one module per project, one module per logical segment of code, or anything in between.**** ****
<p>Create a new class called StatusWriterModule, and we will use it to set up our status writer implementation. For the purposes of this example, we will write one module that takes in a status writer type, so that we can injection either kind of status writer.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_780" style="width: 581px">[![Figure Q - AutoFac Module](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493767/Figure-Q-AutoFac-Module_lufkyf.png?resize=581%2C324)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493767/Figure-Q-AutoFac-Module_lufkyf.png)<figcaption class="wp-caption-text">Figure Q – AutoFac Module</figcaption></figure>Notice how the StatusWriterModule implements the Module interface, which is built in to AutoFac. The Module interface requires the implementation of one method called Load. In our case, we use Load to inject one or the other type of stream writer that we have created.**** ****
<p>Finally, let’s call the Load() method from the Driver class so we can take full advantage of AutoFac. In Figure R, you can see that we have significantly simplified our Driver code by calling the StatusWriterModule.**** ****</p>
<figure class="wp-caption aligncenter" id="attachment_1146" style="width: 768px">[![Figure R - Driver using AtuoFac Module](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493655/Figure-R_tnlhex.png?resize=660%2C474)](http://i0.wp.com/res.cloudinary.com/hjprwpt5l/image/upload/v1455493655/Figure-R_tnlhex.png)<figcaption class="wp-caption-text">Figure R – Driver using AtuoFac Module</figcaption></figure>We’ve taken a look at what dependency inversion and dependency injection are, and how they aid in having good code. We’ve also introduced AutoFac and shown how to use it within your code. To get more information, see the Reference section. If you have any questions, see the Contact section. Happy coding!**** ****
<h1 id="faq">FAQ**** ****</h1>
<p>Q: How do I include AutoFac with my project?<br>
A: You can import the AutoFac package to your Visual Studio solution using the package manager console. See Figure I for more information.</p>
<p>Q: How to register an interface / inject it’s implementation<br>
A: To register an interface and it’s associated implementation, you must first create a ContainerBuilder, and use it to register your interface and associated implementation.The code looks similar to the following:</p>
<p>builder.RegisterType<typeofimplementation>(Interface)</typeofimplementation></p>
<p>See Figure K or L for more information.</p>
<p>Q: What might a service look like?<br>
A: Spotting a service is usually as simple as spotting instantiations of new classes and seeing those classes used to perform encapsulated logic. An example of what a service might look like is provided below. Notice how several classes are instantiated (PaymentReceiver and PaymentLogger), and seem to be performing complex logic behind the scenes:</p>
<p>public class ProcessPaymentService { /* Constructor is here */ public bool ProcessPayment() { var paymentReceiver = new PaymentReceiver(); var paymentInformation = paymentReceiver.ReceivePayment(); var paymentLogger = new PaymentLogger(); var logSuccessful = paymentLogger.LogPayment(paymentInformation); return logSuccessful; } }</p>
<p>Q: What might a model look like?<br>
A: Keep in mind that a model is primarily made up of properties and is usually used to carry information rather than perform logic. A model can have methods, but those methods only operate on the properties of the model itself. An example of a model for an individual might look like this:</p>
<p>public class Individual { public string FirstName { get; set; } public string LastName { get; set; } public string FullName { get { return string.Format(&quot;{0}{1}&quot;, FirstName, LastName); } } }</p>
<p>Q: What might a helper look like?<br>
A: Typical helpers are things like string formatters and data type converters. The following code illustrates a date helper that takes in a date string in the MM/DD/YYYY format and converts it into a DateTime object:</p>
<p>public static DateConverterHelper() { public static DateTime ConvertStringToDateTime(string date) { // preform validation to check for MM/DD/YYYY format first return new DateTime(date); } }</p>
<h1 id="reference">Reference</h1>
<p>More information on the SOLID programming principles can be found here:<br>
<a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)</a>**** ****</p>
<p>More information on Dependency Injection can be found here: <a href="http://tutorials.jenkov.com/dependency-injection/dependency-injection-benefits.html">http://tutorials.jenkov.com/dependency-injection/dependency-injection-benefits.html</a>**** ****</p>
<p>More information on AutoFac can be found here:<br>
<a href="http://autofac.org/">http://autofac.org/</a>**** ****</p>
]]></content:encoded></item></channel></rss>