<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel González García</title>
    <description>The latest articles on DEV Community by Daniel González García (@dgg).</description>
    <link>https://dev.to/dgg</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F27492%2F9f9ae513-1a4e-4185-9e26-6716647ed8a5.png</url>
      <title>DEV Community: Daniel González García</title>
      <link>https://dev.to/dgg</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dgg"/>
    <language>en</language>
    <item>
      <title>.NET Core SDK 2 on Unsupported OS</title>
      <dc:creator>Daniel González García</dc:creator>
      <pubDate>Sat, 23 Sep 2017 18:18:42 +0000</pubDate>
      <link>https://dev.to/dgg/net-core-sdk-2-on-unsupported-os</link>
      <guid>https://dev.to/dgg/net-core-sdk-2-on-unsupported-os</guid>
      <description>

&lt;p&gt;I have been without a “proper development laptop for a while. But that fact did not prevent me from hacking my way around in my old iMac.&lt;/p&gt;

&lt;p&gt;Do you know what would have prevented my hacking? The fact the the newer &lt;em&gt;.NET SDK 2.0&lt;/em&gt; would not install in my non-Sierra system.&lt;br&gt;&lt;br&gt;
But it didn’t, want to know how?&lt;/p&gt;

&lt;h2&gt;
  
  
  Living in the Past
&lt;/h2&gt;

&lt;p&gt;I might be considered a "Windows guy" since that is what I run the most. However my hate for labels and love for different things make me do things like having an iMac as a home computer and a dual-booting (Windows 10 whatever-fancy-name-of-the-version-is and Ubuntu Mate Xenial) second-hand Lenovo laptop as a work laptop for the rest of the family.&lt;br&gt;&lt;br&gt;
The iMac sits on its own desk on a common area of the house, so I tend to use it a lot lately.&lt;/p&gt;

&lt;p&gt;I was upgrading some training material to the current times and few things are more present in the .NET arena than .NET Core and since 2.0 is still fresh and warm off the oven, in my made, made sense to go with it.&lt;/p&gt;

&lt;p&gt;I set off to install the &lt;em&gt;.NET Core SDK 2.0&lt;/em&gt; (&lt;em&gt;SDK2&lt;/em&gt; from now on)in my mid-2010 iMac, when I found out that Yosemite is not supported and therefore, one cannot install the &lt;em&gt;SDK2&lt;/em&gt; in anything older than Sierra on a Mac.&lt;/p&gt;

&lt;p&gt;As it happens, I run Yosemite because anything newer than 10.10 makes my veteran computer crawl and me wanting to murder people in the waiting.&lt;br&gt;&lt;br&gt;
Trust me, I tried newer versions and had to undergo the stupid pain of going back to a previous MacOS version because murder is still uncool.&lt;br&gt;&lt;br&gt;
So Yosemite will endure until the computer either gives-in or it gets sold.&lt;/p&gt;

&lt;h2&gt;
  
  
  Looking at the Future
&lt;/h2&gt;

&lt;p&gt;Would I just fold and run to my laptop, install &lt;em&gt;SDK2&lt;/em&gt; and roll with it admitting defeat? Hell, no!&lt;/p&gt;

&lt;p&gt;I made a simple observation: &lt;em&gt;SDK2&lt;/em&gt; is "just" a bunch of command line utils.&lt;br&gt;&lt;br&gt;
With that observation in the back of my head I wondered: Is there an easy and performant enough way to run those utils outside my unsupported box while still remain local for the file editing?&lt;br&gt;&lt;br&gt;
I'll give you a hint: the answer I chose involves thinking &lt;strong&gt;inside&lt;/strong&gt; a &lt;em&gt;box&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Joining the craze
&lt;/h3&gt;

&lt;p&gt;And by &lt;em&gt;box&lt;/em&gt;, I mean container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.microsoft.com/net/core#dockercmd"&gt;One&lt;/a&gt; of the means to install &lt;em&gt;SDK2&lt;/em&gt; does not involve "installing" it in your system. One can run "something" that has the &lt;em&gt;SDK2&lt;/em&gt; inside so you can open a shell to it and still be able to access your filesystem while using your favorite editor in your box. That "something" is a container.&lt;/p&gt;

&lt;p&gt;By running &lt;em&gt;Docker&lt;/em&gt; in your box, you can download an image with &lt;em&gt;SDK2&lt;/em&gt; (or, basically, whatever) and run &lt;code&gt;dotnet ...&lt;/code&gt; commands in a remote shell, bypassing the fact that the underlying system, my oldie-but-goldie iMac, does not support such software.&lt;br&gt;&lt;br&gt;
And all that without dealing with virtual machines and virtual hard-drives in the size of gigabytes.&lt;/p&gt;

&lt;p&gt;What is not to like?&lt;/p&gt;

&lt;h4&gt;
  
  
  Revealing the (command) lines
&lt;/h4&gt;

&lt;p&gt;First thing one has to do is pull the right image from the &lt;a href="https://hub.docker.com/"&gt;Docker Hub&lt;/a&gt;. From the wealth of &lt;a href="https://hub.docker.com/r/microsoft/dotnet/"&gt;dotnet images&lt;/a&gt; available, since we are building software, we need one labeled &lt;strong&gt;sdk&lt;/strong&gt; and a newer &lt;em&gt;stretch&lt;/em&gt; Linux since I really do not need to target the classic .NET Framework.&lt;br&gt;&lt;br&gt;
For my own sake, I like to tag the image with a shorter name, so that short name can be used in subsequent commands.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker pull microsoft/dotnet:2.0-sdk
&lt;span class="c"&gt;# tag pulled image for easier usage&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker tag microsoft/dotnet:2.0-sdk sdk2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Pulling the image takes some time that depends on your connection speed and your computing power.&lt;/p&gt;

&lt;p&gt;With the image in our system, we need to run the container based on it, interactively with a terminal. If such command is run from the project folder, such folder will be mounted and available from the running container.&lt;br&gt;&lt;br&gt;
The container is also named for convenience.&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;project-folder&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; docker run &lt;span class="nt"&gt;-ti&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; sdk2 &lt;span class="nt"&gt;--mount&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;bind&lt;/span&gt;,source&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="k"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;,target&lt;span class="o"&gt;=&lt;/span&gt;/root/&lt;span class="o"&gt;{&lt;/span&gt;project-folder&lt;span class="o"&gt;}&lt;/span&gt; sdk2
&lt;span class="c"&gt;# this shell is in the running container&lt;/span&gt;
root@container-id#
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once in that terminal, &lt;code&gt;dotnet&lt;/code&gt; commands can be run happily. When done running the commands, the session can be finised with &lt;code&gt;exit&lt;/code&gt;, which will close the container terminal, stop the container and get us back to our shell.&lt;br&gt;&lt;br&gt;
When more commands need to be run, just attach to the container once it is started:&lt;/p&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# close container session (container will stop)&lt;/span&gt;
root@container-id# &lt;span class="nb"&gt;exit&lt;/span&gt;
...
&lt;span class="c"&gt;# reconnect to the stopped container&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$ &lt;/span&gt;docker start &lt;span class="nt"&gt;-a&lt;/span&gt; sdk2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;One less excuse to embrace the command line.&lt;/p&gt;


</description>
      <category>netcore</category>
      <category>docker</category>
      <category>mac</category>
    </item>
    <item>
      <title>A Money value-object implementation in .NET</title>
      <dc:creator>Daniel González García</dc:creator>
      <pubDate>Mon, 21 Aug 2017 10:20:27 +0000</pubDate>
      <link>https://dev.to/dgg/a-money-value-object-implementation-in-net</link>
      <guid>https://dev.to/dgg/a-money-value-object-implementation-in-net</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdj7k49oksrsmczu5r4q.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsdj7k49oksrsmczu5r4q.jpg" alt="money"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's skin the proverbial cat by breaking out the title&lt;/p&gt;

&lt;h1&gt;
  
  
  A money value-object
&lt;/h1&gt;

&lt;p&gt;In this context "money" refers to a quantity that represents a mean of payment in an accepted currency. That is, a monetary quantity is made up of an "amount" that makes sense in the context of a given currency.&lt;br&gt;
Remove the quantity of "five dollars" and saying you have "dollars" won't get you far when buying a car.&lt;br&gt;
Likewise, remove the currency and the number alone makes little or no sense when declaring your wealth.&lt;/p&gt;

&lt;p&gt;According to &lt;a href="https://martinfowler.com/aboutMe.html" rel="noopener noreferrer"&gt;Martin Fowler&lt;/a&gt; (author of the highly recommendable &lt;a href="https://martinfowler.com/books/eaa.html" rel="noopener noreferrer"&gt;Patterns of Enterprise Application Architecture&lt;/a&gt;, a &lt;a href="https://martinfowler.com/eaaCatalog/valueObject.html" rel="noopener noreferrer"&gt;Value object&lt;/a&gt; is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A small simple object whose equality isn't based on identity&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Which is to say two value objects are equal is their values are equal.&lt;/p&gt;

&lt;p&gt;A money value-object is, thus, a small (most likely immutable) type that represents a monetary quantity by specifying its amount and its currency and that allows meaningful and correct operations between instances.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need a money value-object in .NET?
&lt;/h2&gt;

&lt;p&gt;Short answer is &lt;em&gt;because there is none&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Sufferers of &lt;a href="http://wiki.c2.com/?PrimitiveObsession" rel="noopener noreferrer"&gt;primitive obsession&lt;/a&gt; might use raw numbers for formatting. It is unfortunate that such capabilities are mixed up with interesting and complex stuff such as languages, cultures, regions, calendars,...&lt;br&gt;
Using a raw numeric primitive and relying on cultural context might lead to dangerous misunderstandings: is this number in dollars, euros or is it the length of some random king's arm? And that is obviating the fact that a perfectly valid operation between two numbers, such as sum them up, might be totally incorrect as-is between two monetary quantities if they happen to be in different currencies.&lt;/p&gt;

&lt;p&gt;We can discipline our way around with numbers, format providers and good naming but reality is, we are way better off encapsulating money rules and operations in a money type.&lt;/p&gt;

&lt;h2&gt;
  
  
  The need of standardization
&lt;/h2&gt;

&lt;p&gt;Money and countries are a sensitive topic and in order to agree what is what, that International Organization for Standardization &lt;em&gt;ISO&lt;/em&gt; helps by providing a list of current, accepted currencies and their alphabetic and numeric codes.&lt;/p&gt;

&lt;p&gt;This list is active, with new currencies entering the list and old, deprecated currencies coming out and names changing.&lt;br&gt;
Despite the efforts of Microsoft, there is a gap between what is currently accepted by the ISO and what is implemented in the .NET Framework, and framework releases and patches sometimes lag behind the current standard.&lt;/p&gt;

&lt;p&gt;It is easier for a focused, smaller library to stay current than it is for a larger framework.&lt;/p&gt;

&lt;h1&gt;
  
  
  NMoneys to the rescue
&lt;/h1&gt;

&lt;p&gt;For the aforementioned reasons is that &lt;a href="https://github.com/dgg/nmoneys" rel="noopener noreferrer"&gt;NMoneys&lt;/a&gt; exists: to provide a money value-object Open Source implementation that follows the ISO 4217 standard.&lt;/p&gt;

&lt;p&gt;The project is a veteran with a lot of dogfooding on its shoulders and I hope that it will get more exposure and help even more people that has helped so far.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtfxtbu1uqw9wwg7tj08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmtfxtbu1uqw9wwg7tj08.png" alt="nmoneys"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Visit the &lt;a href="https://github.com/dgg/nmoneys" rel="noopener noreferrer"&gt;project site&lt;/a&gt;, read the &lt;a href="https://github.com/dgg/nmoneys/wiki" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;, get its binaries via &lt;a href="https://www.nuget.org/packages/NMoneys" rel="noopener noreferrer"&gt;NuGet&lt;/a&gt; and &lt;a href="https://github.com/dgg/nmoneys/wiki/Contribute" rel="noopener noreferrer"&gt;contribute&lt;/a&gt; if you feel like it.&lt;/p&gt;

&lt;p&gt;You can follow my personal &lt;a href="https://dgondotnet.blogspot.dk/" rel="noopener noreferrer"&gt;blog&lt;/a&gt; for &lt;a href="https://dgondotnet.blogspot.dk/search/label/NMoneys" rel="noopener noreferrer"&gt;updates and new releases&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Enjoy responsibly ;-)&lt;/p&gt;

</description>
      <category>net</category>
      <category>money</category>
      <category>valueobject</category>
      <category>nmoneys</category>
    </item>
    <item>
      <title>Hi, I'm Daniel GonzÃ¡lez GarcÃ a</title>
      <dc:creator>Daniel González García</dc:creator>
      <pubDate>Tue, 25 Jul 2017 20:39:07 +0000</pubDate>
      <link>https://dev.to/dgg/hi-im-daniel-gonzlez-garca</link>
      <guid>https://dev.to/dgg/hi-im-daniel-gonzlez-garca</guid>
      <description>&lt;p&gt;I have been coding for 20+ years.&lt;/p&gt;

&lt;p&gt;You can find me on GitHub as &lt;a href="https://github.com/dgg" rel="noopener noreferrer"&gt;dgg&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Holstebro, Denmark but I am originally from Madrid, Spain.&lt;/p&gt;

&lt;p&gt;I work for Vertica A/S&lt;/p&gt;

&lt;p&gt;I mostly program in .NET (C#) but I dig other platforms.&lt;/p&gt;

&lt;p&gt;I am currently learning about everything I ignore (and that's a lot).&lt;/p&gt;

&lt;p&gt;Nice to meet you all.&lt;/p&gt;

</description>
      <category>introduction</category>
    </item>
  </channel>
</rss>
