<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ody Mbegbu on Medium]]></title>
        <description><![CDATA[Stories by Ody Mbegbu on Medium]]></description>
        <link>https://medium.com/@odytrice?source=rss-8dca7f25ef6d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mxTw9ZDOIPrbAHvMnwG1gQ.jpeg</url>
            <title>Stories by Ody Mbegbu on Medium</title>
            <link>https://medium.com/@odytrice?source=rss-8dca7f25ef6d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 24 May 2026 02:29:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@odytrice/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Seven Tips to be a more Effective Software Engineer]]></title>
            <link>https://medium.com/@odytrice/seven-tips-to-become-a-more-effective-software-engineer-1e117e86981e?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e117e86981e</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Sun, 04 Feb 2024 13:44:09 GMT</pubDate>
            <atom:updated>2024-02-04T17:07:18.434Z</atom:updated>
            <content:encoded><![CDATA[<p>In my experience as a software engineer, I’ve had to learn and imbibe a few things, some of them from personal experience, others from watching other successful engineers closely.</p><p>In this article, I will give you the tips that helped me the most, working as a software engineer. These are tips I wish someone would have told me earlier.</p><h3><strong>Read Effectively</strong></h3><figure><img alt="A Man Reading from an IPad" src="https://cdn-images-1.medium.com/max/1024/1*K2LlXs_u-L1l5PeEHO-AVQ.jpeg" /></figure><p>It’s important that you learn how to read and more importantly comprehend written media like books, documentation, notes, articles, etc. Videos and tutorials are great, but due to their nature, they can’t be “detail dense” like books or technical documentation. Reading effectively is a skill you can develop. Paying attention to details and properly absorbing text while making mental models, in a way that doesn’t take too much time, is an invaluable skill.</p><p>One great way to start is to look at sites like Medium or Reddit. One can start there and then progress to technology books.</p><h3><strong>Write Effectively</strong></h3><figure><img alt="A Man writing while using his laptop" src="https://cdn-images-1.medium.com/max/1024/1*m0BQ31O_ugYCkrBuFMXSRA.jpeg" /></figure><p>Knowledge transfer during the software development lifecycle requires scalability. If you are going to work with others, you need to be able to share your ideas. Writing is one of the most effective ways of sharing deep technical knowledge.</p><p>When working for medium to large tech companies, because there is so much information it’s impractical to verbally explain things whether in person or through videos.</p><p>Learning to write effectively also expands your sphere of influence in those places and improves your visibility on the internet which improves your odds of getting found by recruiters.</p><p>Writing also helps you to properly crystallize your thoughts, forces you to streamline concepts in your mind and sharpens your thinking.</p><p>To get started, you can start with writing technical articles on Medium or for personal ideas, Note-taking apps like <a href="https://obsidian.md/">Obsidian</a>. Writing in a way that is easy to read is also very important. Proper spacing, Paragraphs, Use of Diagrams, etc. These things go a long way in making your writing pleasant to read, which is one of the goals of writing.</p><h3><strong>Plan Everything</strong></h3><figure><img alt="An man thinking while there is a white board with sticky notes behind him" src="https://cdn-images-1.medium.com/max/1024/1*SrrwlpWwkueVInUfml_VtA.jpeg" /></figure><p>Make plans for everything. Plan your Standups, Sprints, One-on-Ones, Workdays, etc. Planning helps you look for signals in all the noise of working day to day. Hopefully, you’ve been writing things down at this point so you should have enough information written down to come up with effective plans.</p><p>The plan doesn’t need to be perfect. Just have a plan. There’s a chess saying, “A poor plan is better than no plan at all”. Planning also means that everything you say or do is more impactful because there is some thought behind it. Stop improvising!</p><h3>Improve your Time Management</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gmFtWxLBNLB4itTDyD4xQ.jpeg" /></figure><p>As a Software Engineer, your time is by far your most valuable resource. As you grow in your career, this value grows exponentially. Accompanying this growth, the demand for your time also grows exponentially, from Peers, Junior Devs, PMs, Managers etc. You must manage your time effectively so that you not only have time to pour into these areas but also into personal development. Here are some tools to improve your time management skills.</p><h4>Schedule</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-3cTYudYold5KG8fyoosQ.jpeg" /></figure><p>A Schedule is very important to prevent conflicts in meeting times and help you plan your day/week accordingly. Knowing what you have scheduled in the future allows you to plan properly for them. It’s pretty common practice in the industry now for companies to have a shared calendar so you can just use whatever your company uses.</p><h4>Routine</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eEaqTYh2FUSZafJ08aeq0Q.jpeg" /></figure><p>Having a set routine gives you a structure to manage the chaos that comes with the increase in demand for your time. Routines also help you to build good habits that will pay off big in the long run. For example, when I was in Lagos, Nigeria. I used to have 2-hour commutes to work. I made it a routine to read a book or listen to a podcast on my way to work and in a Year, I had learned so much and read so many books, it was unreal.</p><p>A routine also allows you to properly disconnect without feeling guilty. Your nervous system will thank you for it.</p><h4>Prioritize</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*biKqr_DX-PqlTCvBtNKv-w.jpeg" /></figure><p>Knowing how to properly prioritize your time is critical. Often developers create a schedule for the day like Wishlist. This happens especially during standups or sprint planning. They try to shove everything they wish to accomplish into the plan. But the reality is that you probably will only complete some of it. Now, you have probably made commitments based on your “Wishlist” and then must go back on your word when it’s too late.</p><p>To be more effective, your plan should not be a “Wishlist”. It should only contain the things you can ACTUALLY finish. If you are not consistently finishing the items in your schedule, then reduce the scope of your schedule. <a href="https://todoist.com/productivity-methods/eisenhower-matrix">Avoid the “Urgency” trap</a>. This advice also applies to teams as well, not just individual developers. Bringing one task/idea to completion on time beats having 5 tasks constantly spinning and delivering them late.</p><p>Completing Tasks also has the added benefit of producing a Dopamine/Morale boost. Constant Context Switching on the other hand is a terrible punishment and it robs you of a sense of accomplishment and that quickly leads to severe burnout.</p><h3>Build and Maintain Focus/Momentum</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwcQKJK2NdjM9Hqcvxkwbg.jpeg" /></figure><p>It’s very easy to think that our mental resources are infinite. We think we can summon motivation, focus, determination, etc. at will. We think these things just appear out of the ether. So, there must be an infinite supply. This is categorically false. We have a very finite amount of these resources and paying attention whenever we feel motivated to build is critical.</p><p>Entering a state of flow as a developer is like getting a multiplier in a video game. A Higher multiplier makes it easier to reach a higher score. In the same vein getting into a state of flow makes accomplishing bigger and bigger tasks easier.</p><p>The sad part is this state of flow is a very fragile thing. Distractions, Context Switching, and Interruptions can kill this state. One reason Planning and Time management skills are important is so you can get into this state of flow quickly and maintain it for longer periods.</p><p>It is also important to remember that motivation and flow state are connected to momentum. So, motivation is never going to come to you in a state of rest. JUST... GET... STARTED and the motivation will meet you along the way as you gain momentum.</p><p>Once you have this momentum, Protect it. Make a conscious effort to minimize distractions and then push as much as you can. Pay attention every time you enter the flow state. Pay attention to the things that helped you get into that flow state as well. For me, coffee and music help me get into flow quickly.</p><h3>Learn to Dig Deep</h3><figure><img alt="“The Magic you’re looking for is in the work you’re avoiding” — Chris Williamson" src="https://cdn-images-1.medium.com/max/736/1*GaFlLL0kP3DRYYE0WUny_A.jpeg" /></figure><blockquote>“The Magic you’re looking for is in the work you’re avoiding” — Chris Williamson</blockquote><p>There’s no better way to put this. To become an effective software developer, you must be willing to dig deep into the technologies you use. You need to understand the nitty-gritty of how your technology stack is put together.</p><p>How well do you understand the frameworks you use daily? Do you understand how they work on an intricate level? Have you browsed through their code/documentation?</p><p>This is important because when you hit novel problems or get into situations where your application is producing unexpected behavior, your deep understanding of the technology is what will get you through those humps.</p><p>There’s no easy workaround to obtain deep knowledge, you have to plan and make time to dig deep and research to gain that knowledge.</p><h3>Know When and How to Seek Help</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*yQijTULKwxLU5x5eY5KYTA.jpeg" /></figure><p>In the beginning, when you are learning to code, it is mostly a solo effort. However, in the real world, Programming is a Team sport. Like I said earlier, Great things are rarely done by individuals. Collaboration is key. One area of collaboration is knowing when you need the help of others and how to ask for that help.</p><h4>Know when to ask for help.</h4><p>It is not wise to spend weeks on a problem that a colleague can easily unblock you on. Being able to identify when you are spinning wheels on a particular problem or when you start spiraling into despair. In that moment it is important to keep your Ego aside and seek help.</p><h4>Exhaust all the options you can think of first.</h4><p>But there is a balance here. You need to be respectful of our colleagues’ time. You must first exhaust all the obvious remedies or troubleshooting steps before asking for help, that way you make it easier for them to solve your problem because they can skip the obvious steps.</p><p>A second reason for this is that at times, trying the obvious thing might solve the problem and you are now better off for it.</p><h4>Always include all the relevant context</h4><p>Don’t just ask questions that lack context like <em>“I ran the build locally and it was crashing with XYZ Exception”</em>. This is a terrible way to seek help because it lacks all the necessary context the reader might need to help you.</p><p>A Better way is to add not just the context of what you are trying to achieve, but what steps you’ve taken and their outcomes and then the specific part where you are stuck for example.</p><p><em>“I am trying to reproduce the checkout bug and I ran the latest build locally. However, I am getting XYZ Exception at the GetCartItems method. I tried passing in valid sample data, but I am still getting the same exception. Here is the full stack trace and here is the link to the logs.”</em></p><p>This makes it easier for the reader to help diagnose the issue and the context helps them know if your entire approach is wrong in the first place.</p><h4>Leverage existing Resources.</h4><p>Tools like Stackoverflow, Internal Technical Docs, troubleshooting guides, or even AI like ChatGPT (use wisely) are great ways of getting help on very common use cases. More often than not, someone else has experienced the same problem you are stuck on, and these resources are great for quickly getting you unblocked without requiring the time of your colleagues</p><h3>Conclusion</h3><p>These tips are things that I not only do myself but see most high-achieving software engineers doing that easily sets them apart.</p><p>There are more tips but those are mostly subjective and depend on the level/character of the individual. However, If you can do these 7 things, I assure you that you will see results in how well you can deliver value as a Software Engineer</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e117e86981e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Continuous Integration with Type Providers]]></title>
            <link>https://medium.com/real-world-fsharp/continuous-integration-with-type-providers-6ddf40ee31b3?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ddf40ee31b3</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[type-providers]]></category>
            <category><![CDATA[fsharp]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 09:41:31 GMT</pubDate>
            <atom:updated>2018-03-29T02:53:16.209Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56g-1KZ4f5tw3IJ1sA-5IA.png" /></figure><p>One of the most underrated features of F# is Type Providers. The “magical” tool that creates types on the fly using information that the compiler has pulled from a data source.</p><h4>Why Type Providers?</h4><p>For example, Imagine you are to consume a REST endpoint that returns JSON. Typically in a statically typed language, you’d have to physically inspect the JSON returned from the endpoint and then create classes that correspond to the schema. After that, you can then make the call and deserialize the response into the corresponding types that you created.</p><p>This is a lot of work for just consuming a data source. In a dynamic language, those steps are avoided altogether and you just access properties directly. The downside is you don’t have any guarantees or safety about your code that calls that endpoint. Add that to the fact that IDEs and tools can’t help you here and you just have to trust that you wrote the code correctly. If not, you’ll find out at runtime.</p><p>Type Providers give the best of both worlds. The compiler does all the creation of classes and also does the deserialization for you. That way, you can just access data the same way dynamic languages do but still have the type safety that comes with static languages.</p><h4>The Problem — Continuous Integration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*hCghnSn7eIJerWW8d20BFg.png" /><figcaption>Continuous Integration</figcaption></figure><p>Type Providers are awesome until you want to do continuous integration. Where you want a build server to build your code in isolation. It may or may not have access to your database or API endpoint. Even if you could get that to work somehow. It violates one of the key principles of Continuous Integration which is the idea of having <a href="https://www.sicpers.info/2011/02/on-repeatable-builds/"><strong>Repeatable Builds</strong></a><strong>.</strong></p><blockquote>“Repeatable Builds” is the idea that given the same source code and build environment, the build output/outcome should remain the same.</blockquote><p>This becomes a problem because our compiler just used data from somewhere other than our source code in order to build our code.</p><p>Luckily, there is a workaround for simpler type providers like the JSON Type-Provider where you can copy a sample output to a JSON file and then point the type-provider to that one instead.</p><p>However, it becomes tricky when dealing with a database. How do you encode the database schema into a file? I had this problem when I set up continuous integration for one of my projects. In the project, I used the <em>SqlDataConnection </em>Type Provider which is based on LINQ to SQL behind the scenes.</p><p>After inspecting the Type Provider API, I noticed that it takes a DBML file (Database Markup Language). This is a description of the database in XML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*L5cfWjd172Ru1mL3sDqNsQ.png" /><figcaption>Sample DBML</figcaption></figure><p>The new challenge is now generating a DBML file because there’s no way I’m crafting it by hand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*wuhil5dHn7k-RYG7JW3Uqw.gif" /><figcaption>Ain’t nobody got time for that</figcaption></figure><p>Well it turns out there is a tool called <a href="https://docs.microsoft.com/en-us/dotnet/framework/tools/sqlmetal-exe-code-generation-tool">SQLMetal</a> that comes with the .NET SDK</p><h4>The Solution</h4><p><strong>Step 1: Copy SQL Metal</strong></p><p>Go to “C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools” or similar directory, copy out sqlmetal.exe into a folder in your project and also check it into source control. In the case of the <a href="https://github.com/odytrice/Dumia">Dumia project</a>, I put it in “./utils/sqlmetal.exe”</p><p><strong>Step 2: Invoke it during migrations</strong></p><p>Because it dumps the schema of the database as a DBML file, you need to invoke it whenever the schema changes. Luckily I use <a href="https://github.com/fluentmigrator/fluentmigrator">FluentMigrator</a> so, in my migration script, I added the call to SQL Metal as follows</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/875375a3a8bcb0e3cff979a96ba29940/href">https://medium.com/media/875375a3a8bcb0e3cff979a96ba29940/href</a></iframe><p>This dumps the DBML file in the Infrastructure project</p><p><strong>Step 3: Point the Type Provider to the schema file</strong></p><p>Next, we need to make our type provider point to the schema file (DBML) that we’ve generated so that it can take our types from that file. This means that we can change the file, the compiler will use that version of the file to build. which pretty much ensures that we’d have repeatable builds.</p><p>To do this we simply pass it as an extra type parameter</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7e71beac5925450c567468cfd86a8dc/href">https://medium.com/media/a7e71beac5925450c567468cfd86a8dc/href</a></iframe><p>and Voila! you are done. Now when the application is built on a build server, it will use the dbml however at run-time it will the connection string instead.<br>The full source code is available at the <a href="https://github.com/odytrice/Dumia">Dumia project github repo</a></p><h3>Conclusion</h3><p>This might feel like you are losing some of the flexibility of Type Providers but not necessarily. First of all, you can easily generate the schema data whether by dumping a JSON file or generating a DBML. Secondly, changes to the schema file are much simpler than changing raw source code.</p><p>Ultimately, if you are experimenting and exploring data then you will get the most out of using Type Providers the way it is out of the box. But if you are writing production level code that needs to be reliable, then you need to have someway of codifying the schema because it should be part of your source control and built by your CI/CD Pipeline.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ddf40ee31b3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/continuous-integration-with-type-providers-6ddf40ee31b3">Continuous Integration with Type Providers</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eight reasons to learn F#]]></title>
            <link>https://medium.com/real-world-fsharp/eight-reasons-to-learn-f-fcb2bef64d7a?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcb2bef64d7a</guid>
            <category><![CDATA[fsharp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Tue, 30 Jan 2018 19:55:52 GMT</pubDate>
            <atom:updated>2018-02-17T23:27:24.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5fpP_tsEJYifDo_fL8R5Sw.jpeg" /></figure><p>Happy New Year! Its been over a year since I started working with F#, Learning the language and improving my skills, looking back I realize that I’ve come a long way from being totally puzzled about the language to now understanding it intuitively and even contributing to the <a href="https://medium.com/real-world-fsharp/contributing-to-the-f-compiler-service-b950264bc84d">Visual F# Compiler</a>. That said, I decided to write this blog post about things that I wished I knew or that I wished someone had told me before <a href="https://medium.com/real-world-fsharp/my-journey-into-f-de3770b5f530">I started this Journey</a>.</p><h4>1. It is easy to learn</h4><p>Right off the bat. This is by far the biggest misconception about F#. The idea that F# is difficult to learn. But that’s simply not true. F# strives for symmetry. This means that the language is built on very few powerful low-level constructs/abstractions and the advanced ideas are derived from those.</p><p>For example in F#, The <em>let</em> keyword allows you to perform what is called a binding. Once you fully understand the <em>let</em> keyword, you can create functions, values, perform basic pattern matching e.t.c. With the knowledge of the let keyword alone, you can get A LOT of things done. That’s true for a lot of fsharp. Once you learn a few keywords/constructs in F# you can get a lot of things done. Or at the very least it’s easy to understand a lot of things.</p><p>In PDC 2008 Luca Bolognese did just that. He taught what is probably the 40% of F# that you’ll use 80% of the time in roughly an hour.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDfnr05mgGzE%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDfnr05mgGzE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDfnr05mgGzE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e64433ddaece0c8c454d24bd98f23a58/href">https://medium.com/media/e64433ddaece0c8c454d24bd98f23a58/href</a></iframe><h4>2. It is VERY typesafe</h4><p>It all boils down to one thing. How much confidence do you have in “Build Succeeded”?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*fnhMx6sTJTed8PzouMqOYQ.png" /><figcaption>Build Succeeded</figcaption></figure><p>Here’s an analogy. Imagine implementing a really complicated algorithm. Now Imagine having to implement the said algorithm in raw JavaScript. The refactoring nightmare, having to write tests to make sure the right parameters are passed. Imagine all the defensive code you have to write to separate null/undefined.</p><p>Then Imagine the amount of relief you’d get moving from raw JavaScript to Typescript. And the sanity/safety that it gives you. The fact that you can now focus on writing more targeted tests and leaving off the mundane things. Imagine all the tooling upgrades you get with that.</p><p>Now imagine re-implementing the said algorithm on the back-end with something like C# with stronger type-safety and much less unpredictable run-time behavior. F# is the next evolution in that chain.</p><p>The F# compiler checks for missing cases in logic. With the magic of Type Providers, It can even check and validate connection strings, SQL statements, application settings e.t.c. This almost gives the feeling of “If it builds, either what you are trying to accomplish is wrong or it will work correctly”. The chances of having runtime errors are even smaller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*Yx2zixAuhkn7QC46Xttbww.jpeg" /><figcaption>Never put off until runtime what you can do at compile time — David Gries</figcaption></figure><h4>3. It encourages experimentation</h4><p>F# comes from a rich history of functional languages. These languages came from Academia as a result, they are designed to be exploratory or should I say “Scripty”. In other words, they encourage experimentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fIRRDf0SP5nX6l2w-miD7g.png" /><figcaption>Experimentation</figcaption></figure><p>F# has a tool called FSharp Interactive (FSI). It’s an environment where the line between compile-time and runtime is blurred. It’s very similar to something like LinqPad in the sense that you can quickly write code and execute them immediately. However, unlike LinqPad, FSI is an interactive space. You run some code, create objects and functions and these things stay in memory. You add some more code and run them and see the results. It’s a very different way of thinking.</p><p>In some ways, it’s taking the good ideas behind Test Driven Development (TDD) to their logical conclusion. That’s because when you are done experimenting with the code, you can easily extract the code you’ve “tested” into your application and take the running logic into your tests and then you can repeat the cycle.</p><p>Granted, C# now has this feature in what is called C# interactive but in my opinion, it is not as effective as FSI. That’s because F# was designed from the ground up to be used this way. In F# EVERYTHING is an expression, therefore, every piece of an F# program can be evaluated. This is common in scripting languages and it’s interesting to note that F# retains all this while being very strongly typed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*s5NU2OxhIYIIWdQybcrGEA.png" /><figcaption>Examples of F# Interactive in action. Entire blocks of code can be evaluated/tested in real-time</figcaption></figure><h4><strong>4. It can be very intuitive</strong></h4><p>The real reason F# looks cryptic at first is that its coming from a different family of languages and we aren’t used to writing code that way. If you are coming from any of the other functional languages like Haskell, OCaml or even python, F# will be very intuitive. Its akin to moving from C++ or Java to C#. The only reason it looks cryptic is that it’s not part of the C-Like Family which has dominated our industry for decades. After about a month of learning, It didn’t seem cryptic at all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*AW5qU3lDl7R150WTjeZ9JA.jpeg" /><figcaption>Intuition</figcaption></figure><p>The Symbols in F# have almost universal meanings in the world of functional programming like (&gt;&gt; or |&gt;). It is no more cryptic than !=, == or &lt;&gt;. After the initial “syntax shock” (which is normal by the way) you’ll start to see that a lot of ideas can be expressed in F# quite intuitively.</p><p>Also, some problems are much easier to come up with functional solutions because it’s closer to the way we humans think.</p><p>Take binding for example, When you say to a layperson that “x = 3”. To them, it means that x is actually 3. Not assigning 3 to x. Another example would be repetition. To “repeat” means to “do again” not increment a variable and check for a condition... Do you see what I mean?</p><h4>5. It shuns ceremony</h4><p>In addition to F# encouraging experimentation, the F# language also shuns ceremony. The language was designed to be tight, concise and straight to the point. Unlike “C-like” languages, it shuns curly braces, semi-colons and superfluous keywords like <em>new.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UknHdZ6HJJQTatSFTyBeVQ.jpeg" /><figcaption>Straight to the Point</figcaption></figure><p>A simple C# program contains a namespace, class and a static method, F# shuns all those and makes them optional. In C# you typically want classes to be <em>public</em>, so in F# they made <em>public</em> the default. That way you don’t need to type <em>public </em>all the time.</p><p>At the language level, little things like tuples, records and discriminated unions dramatically cut down the amount of code it takes to express common ideas and concepts.</p><p>At a higher level of implementing specific features, F# uses the Type Provider language feature to cut down the amount of ceremony it takes in connecting to a database and using it. Or even fetching data from a REST API amongst other things.</p><p>At an architectural level, F# shuns the ceremony of creating an Interface/Implementation pair just to have the ability to hide implementation details. You can simply just pass functions rather than creating an interface that has only one method in it. In other words, the method signature IS the interface. It typically tells you everything you need to know about the function</p><h4>6. Easier to Test</h4><p>There is a deeper difference between the Object Oriented and Functional Paradigms. It boils down to Encapsulation vs Composition. I wrote about this in the post “<a href="https://medium.com/real-world-fsharp/f-series-fitting-the-pieces-together-8e1f0a2d3919">Fitting the pieces together</a>”</p><p>Long story short, Functional programming in general focuses on combining smaller <em>isolated</em><strong> </strong>things into bigger things.</p><p>If you look at the <a href="https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID principles of Object Oriented Design</a> at a very high level, you’ll see that it’s trying to <em>isolate</em> Object Oriented code so that you can test them. The idea of having rich domain objects that had every functionality that we wanted leads to an untestable clog of code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hz5yYtUkCy772Hz6smIxRg.png" /><figcaption>Think Isolation</figcaption></figure><p>Functional programming by default lends itself to be easily testable. Partly because every component is already isolated to begin with as opposed to hiding things behind interfaces and having to mock everything.</p><p>Mark Seemann did a talk on this “<a href="https://www.infoq.com/presentations/mock-fsharp-tdd">Look, No Mocks! Functional TDD with F#</a>”</p><p>That said, Encapsulation is still good for some problems.. an example is building GUIs or Abstract DataTypes (ADT) but we took the encapsulation hammer and used it to knock every problem.</p><h4>7. VERY Friendly Community</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAMz-8qMyQeGJjTpHijB2Q.jpeg" /></figure><p>I’ve been part of several communities from Ruby, Angular, NodeJS, C# e.t.c. and so far the F# community has become the gold standard for me in terms of community. They are welcoming and always happy to help. For example, there is the F# mentorship program where an experienced developer will volunteer time to help you get a better grasp of the language and I have benefited immensely from it. Like seriously, can you show me any community that does this?</p><p>There’s also the Slack community where you can meet and discuss with other community members.</p><h3>Jorge Fioranelli on Twitter</h3><p>fsharp heroes at #OpenFSharp conference: @kot_2010 @enricosada @_cartermp @isaac_abraham &amp;amp; @TRikace congratulations to all!</p><h4>8. It will open your mind to possibilities</h4><p>F# has a lot of tools in its toolbox. For example, Something as simple as a discriminated union has no direct mental translation in C# and Java. The closest explanation is a class hierarchy. But that doesn’t explain much. However, It is a very powerful tool when modeling domains. If you haven’t used it, It’s difficult to show you the value the same way it’s difficult to show a Pascal/C programmer the value of a class in Java.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wRqD6r1ptvX0_VNmz5dTvA.jpeg" /></figure><p>Learning F# will help make you a better programmer overall not just in C# or Java. You will see new patterns for solving problems and it helps you to mature your skills.</p><h4>Conclusion — Don’t be Afraid</h4><p>Ultimately the most important thing I wished someone had told me is.. “Don’t be afraid”. Being a self-taught developer, I don’t consider myself a Maths wizard. I’ve always had the idea that F# is good for Mathematicians. But in the end, It’s just a .NET Language like Powershell.</p><p>PS — Speaking of Powershell, I had absolutely no problems learning Powershell. That’s funny because F# and Powershell share A LOT in common. Its also a functional, scripting language with similar features like pipelining, shadowing, composition e.t.c. and yet I was able to pick it up in very little time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcb2bef64d7a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/eight-reasons-to-learn-f-fcb2bef64d7a">Eight reasons to learn F#</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contributing to the F# Compiler Service]]></title>
            <link>https://medium.com/real-world-fsharp/contributing-to-the-f-compiler-service-b950264bc84d?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b950264bc84d</guid>
            <category><![CDATA[fsharp]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[tools]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Fri, 29 Sep 2017 09:19:03 GMT</pubDate>
            <atom:updated>2017-09-29T15:24:03.910Z</atom:updated>
            <content:encoded><![CDATA[<p>Following my previous Blog Post on the <a href="https://medium.com/real-world-fsharp/the-f-community-f2d29d1a776">F# Community</a>. I promised to show how to setup and build the F# Compiler locally on your machine. This walk through is just for windows users. I have absolutely no idea how to contribute from a Mac. You could use something like Parallels to run windows in a Mac and contribute that way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wq8bVGi1kXHo4sRX99smlA.png" /><figcaption>Your Contributions will be made directly to the Visual F# Compiler Repo</figcaption></figure><h4>Step 1 — Get Visual Studio + Tools</h4><p>So to get started you need to get <a href="https://www.visualstudio.com/vs/">Visual Studio 2017</a>. There is a Community Edition which is absolutely free. But if you already have Professional or Enterprise, that will work too.</p><p>You need to install</p><ul><li>F# Language Support</li><li>Visual Studio Extension Development Workload</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X_Ca8Wo8yu3NDPXIYfy83A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rAqVab4HQ27hBprN89V1Bg.png" /><figcaption>F# Language Support</figcaption></figure><p>Its a web setup so it might take a while. But once it’s done, you can now move on to the next stage</p><h4>Step 2 — Clone the Visual F# Repository</h4><p>The next step is to clone/fork the <a href="https://github.com/Microsoft/visualfsharp">Visual F# Repository</a> After cloning, you can checkout any branch you wish. For the sake of this walk-through, I will checkout <em>feature/fmt</em> branch which adds Auto Formatting to the Visual F# Editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OC-dxSAMBASehJcdj0OctQ.png" /><figcaption>Cloned Visual F# Repository</figcaption></figure><h4>Step 3 — Restore and Build Repository</h4><p>Contrary to what you might think, you can’t just jump in and open one of the Solution Files and start Hacking away. You will need to build it from the command line.</p><p>However, the way to reliably build it is to Build it from the “Developer Command Prompt for VS 2017” just search for that from the Start Menu and You’ll see it. Also you need to right-click and run it as administrator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*g7_8RUbh0BATzIsK2Zdafw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*qVr71UfznFJKFJDxua0jhA.png" /></figure><p>Its from this prompt that you should navigate to the directory that you cloned and then run</p><pre>build.cmd vs debug</pre><p>This will restore all the packages and run all build scripts. So.. It going to take a while. When it’s done, you’ll see something like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*yTossFciKKknmihpERuEDQ.png" /><figcaption>Build Succeeded!</figcaption></figure><h4><strong>Step 4: Run Visual Studio Tools</strong></h4><p>You can now Launch Visual Studio open the <em>VisualFsharp.sln</em> file and setup <em>VisualFSharpOpenSource</em> as your default project and you are good to go. You could also just right-click and debug and it will launch a new instance of Visual Studio which has the your custom build of the Visual FSharp vsix loaded and you can debug the Visual F# Compiler and Tools.</p><p>If you have Visual Studio Enterprise, you could use Code Map tool to look at the projects and see they way they all fit together. I have created a snapshot I have removed the unnecessary projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*C6glSbIIsm3NZ8kGYiDHiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fiZ2_hLBZnbG_9HRylwmZw.png" /><figcaption>Code Map of the F# Compiler Service</figcaption></figure><h3>Conclusion</h3><p>I hope this post has been helpful in showing the steps to building and running the F# Tools. Its no where as scary as I thought it. If you want to help out you start by looking at the issues marked <a href="https://github.com/Microsoft/visualfsharp/labels/Up%20for%20Grabs">“Up for Grabs”</a> and sending pull requests. If you still have any problems with the Steps mentioned above, you can reach me on twitter <a href="https://twitter.com/Odytrice">@odytrice</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b950264bc84d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/contributing-to-the-f-compiler-service-b950264bc84d">Contributing to the F# Compiler Service</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The F# Community]]></title>
            <link>https://medium.com/real-world-fsharp/the-f-community-f2d29d1a776?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2d29d1a776</guid>
            <category><![CDATA[community]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[fsharp]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Wed, 20 Sep 2017 17:25:04 GMT</pubDate>
            <atom:updated>2017-10-01T11:41:55.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zg7Xl2yzdFZirVi8FZC4qA.jpeg" /><figcaption>Belarus F# Community Logo</figcaption></figure><p>It’s been over a year since I started my <a href="https://medium.com/real-world-fsharp/my-journey-into-f-de3770b5f530">Journey into F#</a>. In this time, I have gained a lot of Experience in both the language and the community. I have also finished what is now one of my favorite Technical Books — <a href="http://www.apress.com/us/book/9781484207413">Expert F#</a>. I can now say that I have a good grasp of the Language. I’ve even been on a few podcasts like <a href="https://www.functionalgeekery.com/episode-81-ody-mbegbu/">Functional Geekery</a> and <a href="https://dev.to/developeronfire/episode-263--ody-mbegbu--shipping-value">Developer on Fire</a>.</p><p>F# is not like C# in many ways but more importantly the F# Community and Ecosystem is different from the C# Ecosystem. There are definitely overlaps because they are both part of the .NET Ecosystem. However, The F# Ecosystem has a strong emphasis on Open Source and community</p><p>The F# Community is mainly a group of passionate people of all skill levels that come together to develop the platforms, tools, libraries.. Everything. Microsoft for the most part isn’t directly involved in F#</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ad6c2QiaX3x3s6-obJaZEw.png" /></figure><p>This distinction means that F# is for the community and owned by the community. Historically, It put the F# Ecosystem in a awkward middle position. Most Non-Microsoft folks saw the Language as too “Microsofty” and even the “Microsofties” saw it as “Fringe” and were only interested in what Microsoft blessed which is C#.</p><p>However, things are changing rapidly.. starting from Microsoft. The current change that is the shift away from their “Windows-only” focus has rippled from the head across the company to the ecosystems that they play in. Now you have Microsoft as a Member of the Linux Foundation, Google joining the .NET Foundation, .NET becoming Cross platform and open source with .NET Core, Powershell running on Linux, SQLServer running on Linux. We are in a crucial moment in .NET.. nay Software Development history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8et0Zt0awJdlNEi9Tickw.jpeg" /><figcaption>Linus Torvalds drinking Coffee with Microsoft Folks at a Microsoft Stand in a Linux Conference.. Hell is officially Frozen</figcaption></figure><p>All this is causing a .NET Renaissance and many people both non-.NET and traditional .NET Developers like myself are starting to notice. Add the current wave of interest in functional programming and you find that many people are now looking at F# than ever before</p><p>As one of the people who has a deep love for the F# Language. It makes me sad when I don’t see support for something in F# and that’s normal because we expect Microsoft to push F#. After all its part of the .NET Ecosystem especially when we are coming to it from C#.</p><p>However, It’s also an opportunity! We should stop complaining and build what we want to see. Create what we want and contribute back to the community that’s how this great language was started and that’s how we will sustain it. There are already many awesome examples of this like <a href="http://fable.io/">Fable</a> which is an F# to JavaScript compiler or even <a href="https://github.com/dustinmoris/Giraffe">Giraffe</a> which is a Native Functional ASP.NET Core Framework</p><h4><strong>Where do I start from?</strong></h4><p>The F# compiler is an awesome piece of software. Every time Its excellent type system kicks in, I’m in awe. It feels a bit like having a conversation with an AI about your code. It will infer things you didn’t think of ahead of time. In fact, You could stumble your way to a solution and the Compiler will guide you. That said, I assumed that I would not be able to comprehend the code talk less of contribute to it.</p><p>I have been feeling this strongly about it for a while now and have always desired to contribute to it somehow. When the <a href="http://fsharp.org/mentorship/">F# mentorship</a> program started I was eager to get someone from the community to help me understand the F# Compiler and Tools. And thankfully, I was paired with <a href="https://github.com/AviAvni">Avi Avni</a> and he was gracious enough to help get the compiler development tool chain setup so that I can run a local build of the compiler and editor. I was able to Launch VS in VS and debug the local build of the Tools</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*WplMtABC3M9nLf4MbUjQiw.jpeg" /></figure><h4><strong>Get Involved</strong></h4><p>It might seem daunting and it’s a big commitment. However, irrespective of your skill level, there is a Project on Github (Like <a href="https://github.com/bizmonger/Nikeza">Nikeza</a>) you can help with even if it’s just issue triaging. And by contributing we not only improve our skills, we also make the F# Ecosystem what we want it to be. There is no “Company” we have to wait for to build functionality/framework we want. It’s very busy people like you and me who have lives that are giving this labor of love. For the love of Language, For the love of Ecosystem, For the love of the Community.</p><p>PS - In my next blog post which is coming soon, I will show how to contribute to the F# Compiler/Tools. And maybe.. Just maybe.. I could build cool stuff like the <a href="https://github.com/dkholod/FsiSlackBot">Slack FSI bot</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2d29d1a776" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/the-f-community-f2d29d1a776">The F# Community</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[.NET Core 1.0 Update for F# Tooling]]></title>
            <link>https://medium.com/real-world-fsharp/net-core-1-0-update-for-f-tooling-2dd6d833227b?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dd6d833227b</guid>
            <category><![CDATA[fsharp]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Mon, 17 Apr 2017 10:35:00 GMT</pubDate>
            <atom:updated>2017-04-17T14:18:11.107Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mEnLZwbP9F4jLOnF1hWcA.png" /><figcaption>.Net Core 1.0 with Ionide in VS Code</figcaption></figure><p>Back in October, I blogged about <a href="https://medium.com/real-world-fsharp/using-f-with-net-core-aa6cfc9ef547">Using F# with .NET Core</a> The tooling at the time was still a release candidate. Well a lot of things under the hood have changed about the tooling. There was the move from project.json to MsBuild which caused <a href="https://github.com/aspnet/Home/issues/1433">quite a bit of controversy</a>.</p><p>That said, there were significant changes to the tooling. All the application models and frameworks are exactly the same.</p><p>To demonstrate the changes, I’ve made this short video to show some of the changes that were made to the .NET Core Tooling.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F2xG31sUsCdc%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D2xG31sUsCdc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F2xG31sUsCdc%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/74a7724ecb8da59c9b680329708d475b/href">https://medium.com/media/74a7724ecb8da59c9b680329708d475b/href</a></iframe><h3>Highlights</h3><h4>No More Project.json</h4><p>Project.json was meant to be a new project system/file format. It was quite awesome. However, It was designed for a strictly web server environment and didn’t play well with the existing .NET codebases. Here are some reasons:</p><ul><li>A project.json class library from a regular .NET Application, you had to first compile it into a Nuget package and then host said package on Nuget. Referencing exisiting .NET DLLs required the same hassle which was too much to ask.</li><li>Project.json wasn’t extensible and lacked some of features like including settings from other files and incremental compilation. Features that were already in MsBuild</li><li>It would mean a complete re-write of a lot of build systems and tooling not just for Microsoft but for the ecosystem as a whole.</li></ul><p>That said, the team decided to overhaul MsBuild with all the nice features of project.json and they were able to come up with in what is in my opinion the best of both worlds.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89ec2ad801859a1e2753beb98de62926/href">https://medium.com/media/89ec2ad801859a1e2753beb98de62926/href</a></iframe><p>All the cruft has been tucked away leaving only the really important bits</p><h4>Welcome back, Solution Files</h4><p>One of the advantages of moving back to MsBuild is that we now have the ability of build and restore multiple projects simultaneously. We can accomplish this by creating a solution file and registering our project files (fsproj) in it. That way, when you use <em>dotnet restore </em>at the solution file level it will restore all packages in that solution without you having to do it for each project.</p><p>Typically we use Visual Studio to manage solution files but now a command line utility helps us manage them.</p><ul><li><strong><em>dotnet new sln</em></strong> — Creates a new Solution file</li><li><strong><em>dotnet sln add </em></strong><em>path/to/fsproj</em><strong><em> </em></strong>— Adds a new F# project to the solution</li><li><strong><em>dotnet sln remove </em></strong><em>path/to/fsproj</em> — Removes an F# project from the solution</li><li><strong><em>dotnet sln list</em></strong> — Shows list of projects registered in the solution</li></ul><h4>Project Referencing</h4><p>Referencing other projects is pretty much the same with the regular MsBuild. Except that MsBuild now supports referencing Nuget Packages directly</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a56a0aff939267610eab37a7eb1076a2/href">https://medium.com/media/a56a0aff939267610eab37a7eb1076a2/href</a></iframe><p>Again, you can also add packages or projects from the command line. Note that you need to be in the project directory (directory with fsproj)</p><ul><li><strong>dotnet add package</strong> NugetPackageId — Adds a new Nuget Package to a project</li><li><strong>dotnet add reference</strong> path/to/fsproj — Adds a project reference to another project file</li></ul><h3>Conclusion</h3><p>Like I said in the <a href="https://medium.com/real-world-fsharp/using-f-with-net-core-aa6cfc9ef547">last post</a>, All the .NET Core tools for building real world applications using F# are available and ready. You can use all the existing frameworks and libraries and tools without much friction.</p><p>We are even starting to see innovation from the community like the <a href="https://github.com/dustinmoris/Giraffe"><strong>Giraffe </strong>framework</a>, which is an F# web framework for asp.net core. It replaces the Object Oriented Asp.Net Core MVC with a Functional framework. But still plugs in to the already existing eco-system of middleware and tools available for .NET Core. He also has a <a href="https://dusted.codes/functional-aspnet-core">blog post</a> detailing the rationale/tutorial for the framework. Its worth checking out</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dd6d833227b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/net-core-1-0-update-for-f-tooling-2dd6d833227b">.NET Core 1.0 Update for F# Tooling</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parsing iTunes XML Data with F#]]></title>
            <link>https://medium.com/real-world-fsharp/parsing-itunes-xml-data-with-f-b0cdf4c601fe?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0cdf4c601fe</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[itunes]]></category>
            <category><![CDATA[fsharp]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Thu, 19 Jan 2017 07:09:59 GMT</pubDate>
            <atom:updated>2017-01-21T08:15:19.055Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzdcyVrtpnu6-N-dMBUzow.png" /><figcaption>iTunes</figcaption></figure><p>I’m kind of a music nerd and I’m a fan of all kinds of music from Hip-Hop to Classical music. As a developer, I always listen to music while I work. And I strive for the highest music quality and seek out the best listening experience.</p><h4>Context</h4><p>I am currently living in Lagos, Nigeria. And as music services go, We don’t have Spotify or Google Play Music. We have only Apple’s iTunes and Microsoft’s Groove Music. That said iTunes is my Go-To service for purchasing and listening to music.</p><p>Recently, Nigeria entered into a recession and the <a href="https://en.wikipedia.org/wiki/Dynamic_currency_conversion">Dynamic Currency Conversion (DCC)</a> was banned. Some banks put a $100 limit on debit cards for native dollar transactions while others ban it completely. Apple recently switched to using DCC which means that I can not pay for my iTunes subscription anymore (Talk about having a first-world problem in a third-world country. *laughs*)</p><p>All this lead to Apple cancelling my subscription and with it, yanking off tracks from my playlists automatically. However, I was able to extract my original playlist data from one of my systems by not connecting to the internet and then using the export function in iTunes.</p><h4><strong>Problem</strong></h4><p>I was able to export all of my iTunes data but to put it lightly, <strong>it is the most horrendous piece of XML ever created</strong>. Doubt it? Let’s take a look shall we?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*Mji8aaAzq0WfsP_yNXPqZQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*ps4HvNTWy6r9YAVKUsPIaQ.png" /><figcaption>Really Bad XML</figcaption></figure><p>Explaining all the flaws of this XML format is worthy of it’s own blog post. However, what I will say is that enforcing the order of child elements in XML is (to quote James Gosling) <a href="https://youtu.be/9ei-rbULWoA?t=1170">“the work of the Devil”</a></p><p>My Goal was simply to extract all of my playlist information from the XML. That way I could figure out how to migrate to another Music Service or even roll out my own.</p><h4>Domain Modelling</h4><p>Any experienced programmer will tell you that data structures are very important in solving problems. In fact Linus Torvalds once said</p><blockquote>I will, in fact, claim that the difference between a bad programmer and a good one is whether he considers his code or his data structures more important.</blockquote><p>This fact couldn’t get any clearer after I botched the initial domain model by trying to model the tags rather than the data structures they represented.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb4aec0510b585c498a97725ac706ef1/href">https://medium.com/media/cb4aec0510b585c498a97725ac706ef1/href</a></iframe><p>For starters, I called the Discriminated Union <em>PList</em> which was wrong because <em>Integer</em>, <em>Date</em>, <em>String</em>… aren’t types of <em>PList</em>. <em>None</em> was my way of describing any Tag I could not understand which is a lazy way of trying to model the Domain. A Domain model should be as exhaustive as possible. Also <em>Key </em>isn’t exactly part of the domain. It isn’t a type of value.</p><p>Because of this, coming up with a algorithm to parse the document ended up becoming more difficult than I imagined. Using this domain I had the following implementation for parsing the data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/667f1af4e1a50884eee3941bb1dc13b5/href">https://medium.com/media/667f1af4e1a50884eee3941bb1dc13b5/href</a></iframe><p>Suffice to say, I was heading no where fast. However, it had a few clever ideas like using pattern matching on line 13 to pick the child elements in twos. I also tried treating <em>dict </em>and <em>array </em>as special PLists with their own match cases which was just plain wrong.</p><h4>Solution</h4><p>One of the reasons that I decided to model the elements rather than the domain was because of the complexity of dict and arrays. Dictionaries contain key value pairs. And these values could also be other Dictionaries. The second image really shows this point</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*ps4HvNTWy6r9YAVKUsPIaQ.png" /><figcaption>Dictionaries could contain Arrays that Contain Dictionaries that Contain Arrays…</figcaption></figure><p>That’s when it clicked that Arrays and Dictionaries are simply Values not <em>PLists</em>. Hence the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c621bfd35487a372f512ee4f4ca36df/href">https://medium.com/media/4c621bfd35487a372f512ee4f4ca36df/href</a></iframe><p>With my data structure now nailed down, I couldn’t think of a way of solving the value parsing problem without thinking of the dictionary/array parsing and vice-versa. I immediately recognized that this was a <a href="https://strategicthinker.wordpress.com/chicken-and-egg-problems/">chicken and egg problem</a>.</p><h3>Ody Mbegbu on Twitter</h3><p>The solution to the Chicken and Egg problem is to lazily evaluate the Chicken #functionalprogramming #FSharp</p><p>In F# you can model this kind of chicken and egg problems using <a href="https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/functions/recursive-functions-the-rec-keyword">mutually recursive functions</a>. That way, I can delay the implementation of parsing the Dictionary (<em>toDict</em>) and then recursively call (<em>toValue</em>) in it’s implementation. And it worked like a charm!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35be7a5bc002fc5fce45d28e9961cf67/href">https://medium.com/media/35be7a5bc002fc5fce45d28e9961cf67/href</a></iframe><p>Line 10 shows where I call <em>toDict </em>whose implementation doesn’t exist yet and then in its implementation on Line 17 I can now call <em>toValue </em>for each of the children elements.</p><h4>Conclusion</h4><p>It might seem obvious but I’ll say it anyway. Your choice of data structures and how you design your domain is crucial when writing code in F# (or in any other language). Screw it up, and you will be walking around in circles. Nail it, and your implementation will be concise, straightforward and probably even trivial.</p><p>Here is the final Source Code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/971cf6978834259a06d3c8faacb1c66b/href">https://medium.com/media/971cf6978834259a06d3c8faacb1c66b/href</a></iframe><p>The full source with a sample xml file is also available on <a href="https://github.com/odytrice/iTunesParser">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0cdf4c601fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/parsing-itunes-xml-data-with-f-b0cdf4c601fe">Parsing iTunes XML Data with F#</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Monads]]></title>
            <link>https://medium.com/real-world-fsharp/understanding-monads-db30eeadf2bf?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/db30eeadf2bf</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[monads]]></category>
            <category><![CDATA[fsharp]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Wed, 23 Nov 2016 12:55:44 GMT</pubDate>
            <atom:updated>2016-11-23T15:10:58.381Z</atom:updated>
            <content:encoded><![CDATA[<p>It is said that there’s a curse with Monads.. When you finally understand it, you’ll lose the ability to explain it to others. This curse is made worse by the fact that after you understand it, you’ll begin to see it everywhere</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*10Qg5lrDQqZcSevYff9w1g.jpeg" /></figure><p>Well I am going to try and break that curse. This blog is dedicated to people who just want to build real world applications and aren’t exactly interested in Academic Exercises. So I’m going to save you all the mystery and try to explain it in three simple things.</p><ol><li>Type Amplification</li><li>Chaining Computation</li><li>Chaining Computation on Amplified Types</li></ol><h4><strong>Type Amplification</strong></h4><p>Type amplification is the “lifting” of types into a context. It’s sort of a Type wrapper. See the example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc7bf86f5d5aeb46ddd89b2198238ce2/href">https://medium.com/media/cc7bf86f5d5aeb46ddd89b2198238ce2/href</a></iframe><p>You can then say that the <em>Monad&lt;T&gt;</em> is an amplified type. But for this to be useful, we need some way/function that will allow us to convert values of any type into values of the Monad. This function is called the <strong>Unit Function.</strong> Let’s see some examples.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1aafe4a161367dfb2aa4a5fd155b65d/href">https://medium.com/media/c1aafe4a161367dfb2aa4a5fd155b65d/href</a></iframe><blockquote>The rule goes that once you’ve lifted a type, you can’t get the original value back.</blockquote><p>An analogy would be paying cash to the bank. Once the cashier takes the money from you and credits your account, you can’t get the original cash back.</p><p>But then how do I spend my Monad if I can’t get my value back?</p><h4>Chaining Computations</h4><p>The same way banks give you credit cards to spend your money, Monads provide a way of doing stuff with your values. This is the <strong>Map </strong>function. This function allows you to do with the Monad whatever you would have done with the original value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7c69738ad9a05947adbae95513d7ec5/href">https://medium.com/media/f7c69738ad9a05947adbae95513d7ec5/href</a></iframe><p>This is really cool because we can perform all our computations on amplified types which gives us a lot of flexibility. “So can we now replace all references to raw values with their Monad counterparts?”.. Erm.. Not quite. We currently have no way to perform computation on two Monads.</p><h4>Chaining Computation on Amplified Types</h4><p>From the last example, what if I wanted to subtract <em>result1</em> from <em>result2</em>? I have no way of getting at their internal value. So what’s next? Well that’s where the <strong>Bind</strong> method comes into play</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac9ec432facfc5a7101508c9b53abf8b/href">https://medium.com/media/ac9ec432facfc5a7101508c9b53abf8b/href</a></iframe><p>That’s it! Bind is typically called the “God Function”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1A1m644whmzEdc2ruGuvw.jpeg" /><figcaption>God Function</figcaption></figure><p>That’s because in conjunction with the <em>Unit </em>function, you can express/do just about anything. For example, you can re-create the Map function by calling bind on a function that take the Monad’s value and amplifies the result of the computation. See below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97a64f0936a7e8a1c4d52d01992ce4b5/href">https://medium.com/media/97a64f0936a7e8a1c4d52d01992ce4b5/href</a></iframe><h4><strong>This is really Cool Stuff.. But what’s the value of all this?</strong></h4><p>This principle of performing computations on amplified types isn’t new and it might even be familiar. As a matter of fact, you’ve used them.. A LOT</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*E8x1qLN0I7u6JFjAWs-ZIg.jpeg" /></figure><p>Your favorite things like <em>Seq/IEnumerable, Task, Observable</em> and <em>Option</em> are all monads. Think about it, <em>IEnumerable and Observable </em>have <em>SelectMany</em>, <em>Seq</em> has <em>collect, Task </em>has<em> ContinueWith, </em>and<em> Option </em>has<em> bind. </em>IEnumerable amplifies values by having zero or more values<em>, </em>Task amplifies a value by resolving the value in the future. Option amplifies a value by letting you know it might be null, Observable amplifies types by firing multiple values as events. When you finally get to this realization, It fundamentally changes your perspective.</p><h4>Monads and Purely functional Languages</h4><p>Pure functional languages like <a href="https://www.haskell.org/">Haskell</a> use this trick to isolate impurity (side effects). Any function that talks to the outside world will return an <a href="https://wiki.haskell.org/Introduction_to_IO">IO Monad</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/1*m6r_nVy9j854VDH7YYl6VA.png" /><figcaption>Haskell</figcaption></figure><p>That way you can only chain computation on the monad but you never have direct access to the impure value and that keeps all your functions pure. It might seem like a hassle but the language has a <em>bind</em> operator and some other syntax sugar to make things simple.</p><p>F# provides what is called a <a href="https://fsharpforfunandprofit.com/posts/computation-expressions-intro/"><strong>Computation Expression</strong></a> to make things simpler. You have definitely used it before. e.g.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6dca3859e6205c3e76f319b21c01ba3e/href">https://medium.com/media/6dca3859e6205c3e76f319b21c01ba3e/href</a></iframe><p>In fact, <em>seq</em> is not hard coded into the compiler. You can just as easily create your own expressions and the compiler does all the calls to bind for you.</p><p>Believe it or not, C# also provides something similar. And that‘s the <em>LINQ Syntax</em>. Anders Hejlsberg, Eric Meijer and co dressed a wolf in sheep clothing. Contrary to what you might think, the LINQ Syntax isn’t just for writing LINQ queries, you can use it to do Monad Computations (although in a limited manner). .</p><h4>Conclusion</h4><p>I really hope I was able to explain it in a way that almost anyone can understand. This pattern isn’t exclusive to functional languages like F#. You can use it in many mainstream languages like C#. I even wrote a library using the Monad pattern in C# (<a href="https://github.com/odytrice/Operation">Operation Extensions</a>) long before I started coding F#.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db30eeadf2bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/understanding-monads-db30eeadf2bf">Understanding Monads</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using F# with .NET Core]]></title>
            <link>https://medium.com/real-world-fsharp/using-f-with-net-core-aa6cfc9ef547?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa6cfc9ef547</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[fsharp]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[aspnetcore]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Fri, 14 Oct 2016 18:26:38 GMT</pubDate>
            <atom:updated>2017-05-01T10:52:46.743Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*lizGB_nNFF-vuRqPZcZntQ.png" /></figure><p><strong>Update</strong>: The examples in this post used the <a href="https://docs.microsoft.com/en-us/nuget/schema/project-json"><em>project.json</em></a> tooling. for information about using the newer <em>fsproj, </em>see this <a href="https://medium.com/real-world-fsharp/net-core-1-0-update-for-f-tooling-2dd6d833227b">blog post</a>.</p><p>.Net Core was released a few months ago and since then they have released just an update (1.0.1). Its still early days but even though the platform is still at it’s infancy, It’s been gaining momentum.</p><p>In the past series of blog post, I examined building applications with F# using the regular .Net Framework. The sample application <a href="https://github.com/odytrice/Dumia">Dumia</a> had reached prototype stage but <a href="https://medium.com/real-world-fsharp/f-series-creating-web-applications-191d0afdd037#.6x6f4z6ca">I wasn’t happy with the web development experience</a> from a Pure F# perspective and had to make architectural sacrifices. I also couldn’t figure out an easy way to do database migrations without having to type everything from scratch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJl9YSY1eCgujGX6MA7Pww.png" /><figcaption>Dumia E-Commerce Web Application</figcaption></figure><p>This was around the time .NET Core tools were in development so I decided to jump on the bleeding edge. After all.. what could possibly go wrong? *smile*.</p><p>Anyway, from the little I played around with, I quickly realized that the personality and design of .NET Core better suits F# development. The fact that they detached “the tooling” from “the editing” (Visual Studio) means that it levels the playing field across all of the dotnet ecosystem and the CLR is much less “C# Language Runtime” and more “Common Language Runtime”</p><p>I was so excited and pumped that I’ve decided to port the existing Dumia Prototype to .NET Core using F# exclusively (Almost.. Technically Razor Templates are C#). The Project Manager in me cringes at the thought of changing technology in the middle of a project, especially one that just got released. But I’m doing this because in my mind, the Pros are much greater than the Cons and hopefully, this will serve as a blueprint for my future projects.</p><h3>Let’s Do This!</h3><p>I knew before I could start the port, I needed to know that I could tackle these three scenarios using .NET Core</p><ol><li>Creating Web Applications</li><li>Creating and Referencing Class Libraries</li><li>Data Access (Including Database Migration Strategy)</li></ol><h3>Getting Started</h3><p>First you need to download and install the Tools. Head over to <a href="http://dot.net/core">dot.net/core</a> and follow the instructions. Its the same for Windows, Mac and Linux. The only thing you’d do differently is to use the F# Language switch.</p><p>As for Editors/IDEs, Currently VSCode is the editor with the most .NET Core support. Everything is cross-platform and free so bring your Macs and Linux Machines along.</p><p>Here are the full instructions</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FpF9fScjCwRI%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DpF9fScjCwRI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FpF9fScjCwRI%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/af6d09cb534fcefdd0834e23646f3a70/href">https://medium.com/media/af6d09cb534fcefdd0834e23646f3a70/href</a></iframe><h3>Creating Web Applications</h3><p>In .NET Core web applications are just console applications that host a Webserver inside them just like Ruby’s Rack or NodeJS. All you need to do is add the necessary packages and you are off to the races.. Except that its a lot of boiler plate to write. Thankfully, there are now yeoman generators available for these. Just install <a href="https://nodejs.org/en/download/">NodeJS</a> (You’ll need it anyway to do front end work) and then run</p><p><strong>npm install -g yo generator-aspnet</strong></p><p>After that all you need to do is enter <strong>yo aspnet</strong> in the command line and you’ll see a kind of Command Line Interface you can use to pick the project type you want.. kind of like File &gt; New Project. Something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KycK76SHRoACo5w0JYuslA.gif" /><figcaption>Yeoman Generator for ASP.NET</figcaption></figure><p>The yeoman generator for ASP.NET currently supports scaffolding .NET Core F# Projects. In addition, there are plugins for VS Code and Atom so that you don’t need to type the commands yourself.</p><h3>Creating and Referencing Class Libraries</h3><p>Now that we have the ability to create and run web applications, the next step is layering and project separation.</p><p>In theory, a .NET Core dependency is just a dependency so the project doesn’t care if it depends on a Nuget Package or Source Folder. Its transparent to the build system. The beauty of this is that you could download the source for a Nuget Package and compile/debug against that without touching your code, which is pretty neat.</p><p>However you might want to restrict dependency to the Project Folder of dependent libraries. For this, all you need to do is create the project in the adjacent to the current project and and add the following line</p><p><strong>“Project.Library”: { “target”: “project” }</strong></p><p>This tells the .NET Core run-time to depend directly on the project folder adjacent to the current project. Technically, it could be anywhere on your machine, all you need to do is add the location to a <a href="https://docs.microsoft.com/en-us/dotnet/articles/core/tools/global-json#projects">global.json</a> file</p><h3>Data Access (Including Database Migration Strategy)</h3><p>Data Access is an area of strength for F#. Type Providers are the idiomatic way to get access to data from F# and they are totally awesome.</p><p>However, when it comes to having managing changes over time to the schema of the database, There isn’t a good, easy way to do so. This is an example of an area where even though C# isn’t as good, the tooling helps give a better overall experience. Using C#, the tooling (typically Visual Studio) could look at you data access objects and create what is essentially a migration script but in code which you can check in to source control and at runtime the application can upgrade the database by itself. This saves you from mucking about with server credentials and writing update schemas. Unfortunately, this workflow hasn’t supported F# projects in the past.</p><p>To be clear, There are libraries like the <a href="https://github.com/schambers/fluentmigrator">Fluent Migrator</a> that you could use. but you’d have to write the migration scripts in code by hand. Aside from being tedious initially, computing diffs between migrations is error prone if done by hand. Not to mention that it hasn’t been ported to .NET Core. Which leaves us with one option..</p><h4>Entity Framework Core</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*PdYwXcnUAgeaAZ2aFcbekg.png" /><figcaption>Entity Framework Magic Unicorn</figcaption></figure><p>Entity Framework Core is a complete rewrite from scratch of the popular Entity Framework or as it’s affectionately called “Entity Framework Magic Unicorn Edition”. I could go on and on but the key takeaway is that it’s tooling doesn’t depend on Visual Studio anymore.</p><p>To figure out how this would work with F#, I took Julie Lerman’s course on Pluralsight (<a href="https://app.pluralsight.com/library/courses/play-by-play-ef-core-1-0-first-look-julie-lerman/table-of-contents">Play by Play: EF Core 1.0: First Look</a>) but the twist was to try and do everything using only F#. I sensed that it would be a difficult undertaking and so that I couldn’t talk myself out of it, I tweeted</p><h3>Ody Mbegbu on Twitter</h3><p>Watching @julielerman EF Core Course and following along using F# :D</p><p>She was kind enough to respond (which blew my mind btw) and I promised that I would create an FSharp equivalent of her demo code and send her a pull request.</p><p>And boy was I in for a wild ride! Yes a lot of it went as expected. However, migrations were a bit tricky as the tool would emit C# code and I had to convert them by hand to F#. I also ran into problems trying to use quotations, I had to import a library and then trick the .NET core runtime to accept portable class libraries… and later realized that the F# compiler can automatically convert F# function expressions <strong>(fun x -&gt; x.id) </strong>into <strong>Expression&lt;Func&lt;T&gt;&gt;</strong> just like C#.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*h_irTWexRMCGR4I5LYEsYw.gif" /><figcaption>Mega Facepalm</figcaption></figure><p>After that huddle, I was able complete the translation of the migration code and execute it against the database. Here is a sample of the migration. Full source is available <a href="https://github.com/odytrice/PluralsightDownloads/tree/master/PlaybyPlayEFCore10/FSharp">here</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8458f123b7a8dc76210e27a628d456d1/href">https://medium.com/media/8458f123b7a8dc76210e27a628d456d1/href</a></iframe><h3>Verdict</h3><p>All in all, my experience with .NET Core has been exciting. I hope, I’ve been able to show that all the tools are in place to build real world applications using F# and .NET Core and I’m also excited for the future of the platform. A good size of the F# community isn’t eager to make the jump yet (and for good reason) but the support is growing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa6cfc9ef547" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/using-f-with-net-core-aa6cfc9ef547">Using F# with .NET Core</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fitting the Pieces Together]]></title>
            <link>https://medium.com/real-world-fsharp/f-series-fitting-the-pieces-together-8e1f0a2d3919?source=rss-8dca7f25ef6d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e1f0a2d3919</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[fsharp]]></category>
            <dc:creator><![CDATA[Ody Mbegbu]]></dc:creator>
            <pubDate>Sun, 18 Sep 2016 23:06:35 GMT</pubDate>
            <atom:updated>2016-10-19T12:29:16.751Z</atom:updated>
            <content:encoded><![CDATA[<p>This is part of the Series: <a href="https://medium.com/@odytrice/f-series-building-real-world-applications-in-f-b45b62ac653d#.anudh7446">“Building Real-World Applications in F#”</a></p><p>Thinking about how to and where to put pieces together for the Dumia Application is easily the hardest part of putting this application together. Coming up with a nice repeatable way to piece together an application using Functional Language like F# requires a real change of thinking.</p><h3>Paradigm Shift — Encapsulation vs Isolation</h3><p>Before we go into the details of assembling an Application with F# or any other true functional language for that matter, We need to understand the fundamental difference in philosophy between the Object Oriented world and the Functional World. This can be distilled down to two concepts.. Encapsulation and Isolation</p><h4><strong>Encapsulation</strong></h4><p>You see in OOP Land, you had a Box of tools (Classes) that had specific uses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FV-grxor-emr9ZOM2OsaQw.jpeg" /><figcaption>Object Oriented Programming</figcaption></figure><p>Each tool had inner workings and behavior that you the user is not meant to see. Sort of like a black box. The user needed to know</p><ul><li>How to instantiate it</li><li>What method(s) to call</li><li>What order to do the above</li></ul><p>We would then assemble an application by connecting objects together either by letting objects create other objects or calling other objects. Because of this the user’s behavior depended on the expectation of the Objects it depended on. As a result of this, In practice, they were difficult to isolate which by definition meant that they were difficult to test because you needed to isolate code to test it.</p><p>To solve this, we relied on using Interfaces and Mocks to simulate not just the behavior but the character of the dependent object. These set of solutions led to the SOLID Principles of OOP Design. These exist primarily to make OOP code testable.</p><h4><strong>Isolation</strong></h4><p>With functional programming, You are dealing with Functions as the basic building block. Each function can be thought of as a lego brick</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xtNlljx7FJVcKGFeN-dPqQ.jpeg" /><figcaption>Functional Programming</figcaption></figure><p>A pure function is by definition isolated. Unlike Encapsulation where an Object is trying to hide things from you, a pure function can not do anything It did not declare in its interface (or signature). You could say that a Pure function is “honest”</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fz0N1aZ6SnBk%3Ffeature%3Doembed%26start%3D751%26end%3D921&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dz0N1aZ6SnBk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fz0N1aZ6SnBk%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/112f21d53a64ce6282514e977082f0c9/href">https://medium.com/media/112f21d53a64ce6282514e977082f0c9/href</a></iframe><p>This causes a paradigm shift because You need to think of solving problems by breaking them down into these small isolated functions and then re-assembling them at your application entry point.</p><p>This might seem counter-intuitive at first but then when you open you mind to the possibilities, It fundamentally changes how you think about building software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*58eJUJv-UxKhnNG4QR77Cw.jpeg" /><figcaption>Lego Mega Structures built one brick at a time</figcaption></figure><p>Because of my extensive background in Object-Oriented Languages, this paradigm shift produced so much <a href="https://en.wikipedia.org/wiki/Cognitive_dissonance"><em>Cognitive Dissonance</em></a> about how to structure the <a href="https://github.com/odytrice/Dumia">Dumia Application</a> that I literally had a sleepless night trying to resolve my old habits with the new paradigm</p><p>At Several Points in the design, I had to step back and think:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*0EVmjh59zGjkjC6OwgLNuQ.jpeg" /><figcaption>Everything is a Function</figcaption></figure><p>By taking this approach to application architecture, a lot of complexities fall away. You no longer need Interfaces, Mocks, Managers, Services, Presenters, Controllers and the list goes on. In fact, this image by Scott Wlaschin pretty much hits the nail on the head.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*JupqLvJk0pdOjQRYaQJkPw.jpeg" /><figcaption><a href="https://fsharpforfunandprofit.com/fppatterns/">Taken from F# for Fun and Profit</a></figcaption></figure><p>Having this in mind, I came up with a very simple functional architecture.</p><p>I was able to categorize functions into two camps and as such put them in two assemblies</p><ul><li><strong>Domain </strong>— This contains functions that are “pure” business logic (or rules) which means that they don’t depend on the application environment (Web, Console, Mobile etc). These functions are typically pure and they just deal with transforming inputs and producing outputs. You should be able to take this code and move it from one environment to another easily</li><li><strong>Infrastructure </strong>— This group contains functions that need to either talk to the external world (e.g. DataAccess functions or SMS/Email functions) or work with external dependencies. (e.g. Cryptography library)</li></ul><p>The beauty of functional programming is that you can plug these two together using just their function signatures as the interface between them.</p><p>An example of this is using Higher-Order functions (functions that take other functions as parameters) as a form of Polymorphism rather than interfaces.</p><p>For example instead of having an <em>IEncryption </em>interface that has an <em>Encrypt </em>function that takes a string and returns a string, It will be replaced with a function that takes a string and returns a string. This function is passed into any function that needs to encrypt strings.</p><p>See.. No IOC Containers/Interfaces needed.</p><p>Doing these, I ended up with something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*fxkL_CfjR0zWmq6JjWVrrw.png" /><figcaption>New Project Structure</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e1f0a2d3919" width="1" height="1" alt=""><hr><p><a href="https://medium.com/real-world-fsharp/f-series-fitting-the-pieces-together-8e1f0a2d3919">Fitting the Pieces Together</a> was originally published in <a href="https://medium.com/real-world-fsharp">Real World F#</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>