<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Assert Fail</title>
    <link>https://assertfail.gewalli.se/</link>
    <atom:link href="https://assertfail.gewalli.se/rss.xml" rel="self" type="application/rss+xml" />
    <description>Assert Fail</description>
    <language>en-us</language>
    <pubDate>Mon, 23 Feb 2026 19:11:38 +0000</pubDate>
    <lastBuildDate>Mon, 23 Feb 2026 19:11:38 +0000</lastBuildDate>

    
    <item>
      <title>Hetzner mentioned in a few places</title>
      <link>https://assertfail.gewalli.se/2026/02/23/Hetzner-mentioned-in-a-few-places.html</link>
      <pubDate>Mon, 23 Feb 2026 18:18:11 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2026/02/23/Hetzner-mentioned-in-a-few-places</guid>
      <description>&lt;p&gt;I’ve seen news about &lt;a href=&quot;https://news.ycombinator.com/item?id=31619504&quot;&gt;Lidl’s parent company launching a cloud unit&lt;/a&gt; a few times. Some YouTubers such as &lt;a href=&quot;https://www.youtube.com/watch?v=AMVHnhJ1t_w&quot;&gt;Milan Jovanović&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=Ps3AI1kTIR4&quot;&gt;Tom Delalande&lt;/a&gt; talk about using AWS and Azure alternative Hetzner. Here in Thessaloniki I’ve met people from IONOS (also a German company). I’m somewhat reminded about how &lt;a href=&quot;https://en.wikipedia.org/wiki/Heroku&quot;&gt;Heroku&lt;/a&gt; had a great story about simple deployments. You then had to pay the cost if you got real use, so you would hear about how companies started on Heroku only to shift away because of cost.&lt;/p&gt;

&lt;p&gt;DHH is probably the most famous technologist writing about &lt;a href=&quot;https://world.hey.com/dhh/why-we-re-leaving-the-cloud-654b47e0&quot;&gt;moving away from using cloud providers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There is a cost of moving from one provider to another, especially when you have a more complicated setup that uses many of the platform services. You might have to rewrite your software to match new infrastructure, which is why the competitive advantages are missing for cheaper alternatives due to lock-in.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Prompt injection is the new SQL injection only easier</title>
      <link>https://assertfail.gewalli.se/2026/02/22/Prompt-injection-is-the-new-SQL-injection-only-easier.html</link>
      <pubDate>Sun, 22 Feb 2026 17:36:43 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2026/02/22/Prompt-injection-is-the-new-SQL-injection-only-easier</guid>
      <description>&lt;p&gt;As I try out more and more of LLM assisted coding. The security issues, I feel like, they are taken extremely lightly. The security issue I am referencing right now is that like when you use untrusted input an adversary can take advantage. This is not the only security issue. Sam Altman deflects from the issue by talking about people “Google” for help on building biological weapons using their tools (i.e. that the training corpus contains sufficient information to allow for that). Other people have also expressed that it is a &lt;a href=&quot;https://www.youtube.com/watch?v=MaFTqjYjADw&quot;&gt;deflection from real issues&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using LLMs trains you in becoming desensitized towards getting huge chunks of text pushed in your face. Having software that you cannot vet, because the amount of code has exploded, means that potential issues can be hiding in the snow. In the long term we get to a &lt;a href=&quot;https://embracethered.com/blog/posts/2025/the-normalization-of-deviance-in-ai/&quot;&gt;normalization of deviance&lt;/a&gt; make fertile ground for attackers. Or expressed differently there is a &lt;a href=&quot;https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/&quot;&gt;lethal trifecta for AI agents: private data, untrusted content, and external communication&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using LLM assisted coding has many challenges. The way people use the tools changes as people discover ways that these tools can be made to work for them.&lt;/p&gt;

&lt;p&gt;The interesting parts around security happens in how we use the tools. For instance there is docs around &lt;a href=&quot;https://code.claude.com/docs/en/sandboxing&quot;&gt;sandboxing for Claude&lt;/a&gt;, &lt;a href=&quot;https://developers.openai.com/codex/security/&quot;&gt;sandbox mode for Codex&lt;/a&gt; and &lt;a href=&quot;https://docs.github.com/en/copilot/concepts/agents/coding-agent/about-coding-agent#built-in-security-protections&quot;&gt;security for GitHub Copilot&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For power users there is less focus on security as seen on for instance &lt;a href=&quot;https://web.archive.org/web/20260217153936/https://github.com/Kilo-Org/kilo/security&quot;&gt;Kilo Code&lt;/a&gt; and &lt;a href=&quot;https://web.archive.org/web/20251213140715/https://github.com/RooCodeInc/Roo-Code/security&quot;&gt;Roo Code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When I was but a young boy around 10 years of age (ca 1990), we swapped diskettes. I remember having to reformat my computer due to getting viruses. When I was in my 20ies (2001) I stayed at a landlady’s place in Lund, since I went to the university there. She had a computer that was noticeably full of malware. Later on when I moved to a student room, the local network had so many people with infected computers that if you plugged in a Windows computer that had just been installed, it would get infected before getting enough security patches from the net. I’m guessing that we are in a &lt;a href=&quot;https://www.goodreads.com/quotes/5382-history-doesn-t-repeat-itself-but-it-does-rhyme&quot;&gt;rhyming situation&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>The world and US cloud providers</title>
      <link>https://assertfail.gewalli.se/2026/01/26/The-world-and-US-cloud-providers.html</link>
      <pubDate>Mon, 26 Jan 2026 17:13:39 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2026/01/26/The-world-and-US-cloud-providers</guid>
      <description>&lt;p&gt;For many years we have lived with a move towards the big cloud dragons. In my musings during more than 10 years ago I thought that we would see a move towards national datacenters due to &lt;a href=&quot;https://assertfail.gewalli.se/2013/07/06/national-clouds.html&quot;&gt;security implications&lt;/a&gt;. There did not seem to be a lot pushback from the &lt;a href=&quot;https://en.wikipedia.org/wiki/CLOUD_Act&quot;&gt;CLOUD Act&lt;/a&gt; in other countries.&lt;/p&gt;

&lt;p&gt;The calculations around using US services have changed. &lt;a href=&quot;https://www.techzine.eu/blogs/infrastructure/137963/is-the-aws-european-sovereign-cloud-sovereign-enough/&quot;&gt;AWS is probably feeling some of the heat&lt;/a&gt; from the disruption in the US government.&lt;/p&gt;

&lt;p&gt;A coworker noticed that the integration goes deeper today than it did 10 years ago. You need an online account in order to use your Windows PC or your Mac. Or it might not have been removed right now, &lt;a href=&quot;https://www.reddit.com/r/techsupport/comments/1ak734f/have_microsoft_removed_ability_to_set_up_a_pc/&quot;&gt;it is just difficult&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Service providers (such as &lt;a href=&quot;https://learn.microsoft.com/en-us/graph/migrate-azure-ad-graph-overview&quot;&gt;Microsoft&lt;/a&gt;, &lt;a href=&quot;https://www.atlassian.com/licensing/data-center-end-of-life&quot;&gt;Atlassian&lt;/a&gt;) are trying to move away from offering self hosted services. This could simply be because it is a pain (cost) to maintain old branches for old versions of software compared to offering only one version of the software.&lt;/p&gt;

&lt;p&gt;It could be that as long as there is a high cost (hiring and reeducation) of moving away from the services offered compared to the alternatives makes transitions unlikely. Significantly higher price or &lt;a href=&quot;https://en.wikipedia.org/wiki/Executive_Order_14203&quot;&gt;further cancellations of legitimate business&lt;/a&gt; could change that equation.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Evaluating different programming languages for use with LLMs</title>
      <link>https://assertfail.gewalli.se/2026/01/11/Evaluating-different-programming-languages-for-use-with-LLMs.html</link>
      <pubDate>Sun, 11 Jan 2026 18:52:08 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2026/01/11/Evaluating-different-programming-languages-for-use-with-LLMs</guid>
      <description>&lt;p&gt;If we try to find some idea what language is better or worse for use with an LLM, we need to have some way of evaluating the different languages. I’ve done some small tests using different programming languages and gotten a rough estimate of how well LLMs work.&lt;/p&gt;

&lt;h2 id=&quot;experiences-2025&quot;&gt;Experiences 2025&lt;/h2&gt;

&lt;p&gt;What I’ve seen is that for a bit bigger program:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Haskell takes time and converges slowly but requires less of my effort to fix.&lt;/li&gt;
  &lt;li&gt;F# converges relatively quickly but requires a moderate amount of effort to fix. I.e. requires more effort to fix than Haskell.&lt;/li&gt;
  &lt;li&gt;Rust can converge relatively quickly, requires moderate amount of effort to fix if you go functional, larger amount of effort to fix if you try to be more OOP.&lt;/li&gt;
  &lt;li&gt;C# can converge relatively quickly but requires keywords to be more predictable (for instance “clean architecture” for a web api), requires a bit more effort to to fix than F#. I’ve felt that depending on what keywords you use, you get different results.&lt;/li&gt;
  &lt;li&gt;Erlang can converge relatively quickly, though since I’m kind of rusty on Erlang I don’t know if it works as intended.&lt;/li&gt;
  &lt;li&gt;Python can converge relatively quickly. I have found that it requires more effort to fix than Haskell. I don’t know better keywords to use in order to get better results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that these should be taken as small samples, so not representative of a larger set of tasks.&lt;/p&gt;

&lt;p&gt;Process that I usually follow:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Use a template in the target language for the git repository (this is to ensure that we avoid some security issues and get faster convergence)&lt;/li&gt;
  &lt;li&gt;Give the LLM a very detailed specifications of a feature and have it add tests and code.&lt;/li&gt;
  &lt;li&gt;Have the LLM run tests and iterate on test failures (with some manual intervention)&lt;/li&gt;
  &lt;li&gt;Check that api starts, curl the api.&lt;/li&gt;
  &lt;li&gt;Read through the entire program and fix any obvious mistakes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some of the time I have seen that the LLM goes into a long doom loop where it does not converge towards any solution.&lt;/p&gt;

&lt;h3 id=&quot;convergence&quot;&gt;Convergence&lt;/h3&gt;

&lt;p&gt;My own experience is that using functional architecture help LLMs converge towards correct solution more often. This might be because if you restrict side effects and use immutable data, it is easier to get working code. This aligns with my own experiences writing OOP style code in large code bases have benefited from using functional patterns to avoid hard to diagnose bugs.&lt;/p&gt;

&lt;h3 id=&quot;keywords&quot;&gt;Keywords&lt;/h3&gt;

&lt;p&gt;You might have noticed that I use keywords to influence the LLMs to output code related to a subset the training data. For C# I’ve mostly used “clean architecture”. For F# I’ve gotten C# adjacent solutions unless I’ve specified keywords such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Functional Core, Imperative Shell&lt;/li&gt;
  &lt;li&gt;Pipeline/Data Flow Architecture&lt;/li&gt;
  &lt;li&gt;Event Sourcing and CQRS&lt;/li&gt;
  &lt;li&gt;Redux/Elm Architecture&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve not done any closer comparison on how they compare to each other. I’ve seen that for C#, keywords are a must unless you work in an existing codebase with established patterns.&lt;/p&gt;

&lt;p&gt;It would be interesting to see if we can find better keywords for different languages.&lt;/p&gt;

&lt;h2 id=&quot;swe-bench-multilingual&quot;&gt;SWE-bench Multilingual&lt;/h2&gt;

&lt;p&gt;For a more formal approach we have &lt;a href=&quot;https://www.swebench.com/multilingual.html&quot;&gt;SWE-bench Multilingual&lt;/a&gt;. In this they evaluate different programming languages based on a small sample of open source repositories:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;It’s possible that the difference in resolution rate is because the dataset happens to contain more difficult tasks in some languages.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Note also the limited sample size:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;42 repositories representing 9 programming languages&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The conclusion that Python is the best language, does not align with what I’ve seen (I’ve used a lot of commercial models). I think this means that we could get better benchmarks to evaluate how well LLMs perform on programming languages.&lt;/p&gt;

&lt;h2 id=&quot;token-efficiency&quot;&gt;Token efficiency&lt;/h2&gt;

&lt;p&gt;One interesting question is what programming languages can fit more functionality with less tokens: &lt;a href=&quot;https://martinalderson.com/posts/which-programming-languages-are-most-token-efficient/&quot;&gt;Which programming languages are most token-efficient?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you go to the source for his post: &lt;a href=&quot;https://github.com/acmeism/RosettaCodeData&quot;&gt;RosettaCodeData&lt;/a&gt; you will find that a lot of the problems are not common to see in working software. The token per task graph does not align with my experience for say C# and Go where Go usually requires a lot of extra ceremony compared to C#. I had trouble with keeping Go within the token limit. This lack of semantic density could be due to lack of mature business oriented frameworks compared to Java/C#.&lt;/p&gt;

&lt;p&gt;I have seen that Haskell seem to have nice characteristics for LLMs (converges more often to correct solutions with less need for me to intervene). Perhaps not only the point about token efficiency, but also that Haskell has better type system compared to say Java and C# and can give LLMs a more clearly defined area that it needs to output, a “narrower surface”.&lt;/p&gt;

&lt;h2 id=&quot;we-await-more-benchmarks&quot;&gt;We await more benchmarks&lt;/h2&gt;

&lt;p&gt;I would like to hear other peoples experiences. My feeling is that depending on how you think about programming, influences the process you use to get working solutions from LLMs.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Devaluation of work</title>
      <link>https://assertfail.gewalli.se/2026/01/06/Devaluation-of-work.html</link>
      <pubDate>Tue, 06 Jan 2026 17:55:39 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2026/01/06/Devaluation-of-work</guid>
      <description>&lt;p&gt;I have talked to multiple developers that have told me about getting LLM-generated pull requests. The pain is that we have a situation where you ignore the act of getting code to work and instead focusing on the optics of good enough looking code.&lt;/p&gt;

&lt;p&gt;Instead of talking about how we ensure that the people who are tasked with doing the work, actually do the work, we talk about adding more LLMs as a solution to the problem of unproven LLM generated code.&lt;/p&gt;

&lt;h2 id=&quot;the-point-of-source-code&quot;&gt;The point of source code&lt;/h2&gt;

&lt;p&gt;Another point is that programming is not about having code for the sake of code: Programming language text is to have readable specifications of working software. Using languages like Python, TypeScript, JavaScript, Java or C# does not have any inherent value. The value of using common languages is that you have written text that can be modified and understood. Unreadable code is not a good thing. Machine generated code that no one wants to read, means you have &lt;a href=&quot;https://codemanship.wordpress.com/2025/09/30/comprehension-debt-the-ticking-time-bomb-of-llm-generated-code/&quot;&gt;instant legacy software&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;The amount of lines of code has never been a good &lt;a href=&quot;https://blog.ploeh.dk/2025/09/22/its-striking-so-quickly-the-industry-forgets-that-lines-of-code-isnt-a-measure-of-productivity/&quot;&gt;measure for productivity&lt;/a&gt;. Remember “you get what you measure”.&lt;/p&gt;

&lt;p&gt;I’ve seen indications that &lt;a href=&quot;https://www.theregister.com/2025/07/11/ai_code_tools_slow_down/&quot;&gt;LLM coding tools make developers slower but they think they’re faster&lt;/a&gt;. Besides the indication that even when measurements suggest faster task completion, we get &lt;a href=&quot;https://web.archive.org/web/20240624133953/https://visualstudiomagazine.com/articles/2024/01/25/copilot-research.aspx&quot;&gt;maintenance mess&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;disruption&quot;&gt;Disruption&lt;/h2&gt;

&lt;p&gt;Most software developers that I have worked with have learned by doing (writing code). Having a shift towards mostly reading code, could mean a greater comprehension loss than we expect.&lt;/p&gt;

&lt;p&gt;Rather than an acceleration of software development we see a disruption, that gets hinted in &lt;a href=&quot;https://ferd.ca/software-acceleration-and-desynchronization.html&quot;&gt;Software Acceleration and Desynchronization&lt;/a&gt;. The ways we develop software changes (as it has done before). For instance code reviews in enterprise development was not a thing when I started working. It became more mainstream ca 5 years later (GitHub helped popularize review flow around 2010). We can expect the culture of software development to change in response to this new pressure.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;If we devalue aspects of software delivery pipeline designed to give you working software without a solution to compensate for the loss of quality, we (software professionals) will get the blame for the resulting issues.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Slop bulkheads</title>
      <link>https://assertfail.gewalli.se/2026/01/01/Slop-bulkheads.html</link>
      <pubDate>Thu, 01 Jan 2026 21:47:34 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2026/01/01/Slop-bulkheads</guid>
      <description>&lt;p&gt;How can we ensure that we use the LLM to generate useful code/features and fix bugs?&lt;/p&gt;

&lt;p&gt;I don’t think we can put the same expectations on LLMs as on junior coworkers. You hire junior developers in order to have people that are expected to grow and learn. LLMs come pre-trained (i.e. there is no point in teaching them as they are fixed neural nets after training). But anyway let us take the idea of having a multitude of “agents” to the logical conclusion.&lt;/p&gt;

&lt;p&gt;Say that we have a bunch of teams working on producing a complete system. One reason to use microservices is to split teams into areas where they can iterate without the communication overhead of being fully integrated in the same code. We can argue that the same idea can be applied to isolate agent-contexts so that we treat LLMs as a team or a multitude of teams.&lt;/p&gt;

&lt;p&gt;We know that it is easier to generate new code than to have old code suitable for LLM. Why not embrace this pattern? Create many small services. Can we minimize some of the risks associated with LLM generated code by giving smaller scope and permissions to the code bases that the LLMs are generating?&lt;/p&gt;

&lt;p&gt;When we generate new code with LLMs we do know that LLMs are vulnerable to slop squatting attacks. This is besides all of the other security related issues related to LLMs. My guess is that if you start with a small known template, then iterate on that, you avoid some of the risks. When creating CRUD-approximate applications the amount of libraries that you need are known, why you can start with a good enough template.&lt;/p&gt;

&lt;p&gt;What kind of infrastructure allows us to have fine grained control over the access that networked attached service have? Does this mean that there is a need to go deeper into K8S and similar in order to become more AI friendly?&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Living with a machine ghost</title>
      <link>https://assertfail.gewalli.se/2025/09/17/Living-with-a-machine-ghost.html</link>
      <pubDate>Wed, 17 Sep 2025 06:00:59 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2025/09/17/Living-with-a-machine-ghost</guid>
      <description>&lt;p&gt;LLMs or vibing is one technology in a long row of technologies and products that have promised to make programming more accessible. LLMs from what I’ve read, seem more to be the ghost of a portion of the internet canned into a GPU-ready package.&lt;/p&gt;

&lt;p&gt;Usually the promise is that “Now, you wont need developers anymore, your regular skilled employees will do the programming”. From what I’ve seen, looking at GUI programming it usually means you get a reduced programming environment without the tools programmers expect to use. If the problem or task is simple enough, the tool works well enough. When the complexity of the task gets out of hand, you will have programmers fix workflow or write “code”. If you are lucky, this means that you either don’t need programmers for the task or that you have bought yourself time until the programmers need to write a solution. The “hype” or “marketing” around the tool does not align with reality. Just because the salesman is lying doesn’t mean what he is selling is useless.&lt;/p&gt;

&lt;p&gt;The companies selling LLMs are either telling you or implying that you can use them for everything.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;AI Will Replace You&lt;/li&gt;
  &lt;li&gt;AI-driven automation will continue to eliminate traditional jobs but also create new opportunities and industries we can’t even imagine yet. / Jensen Huang&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it becomes obvious that this is not in line with reality they tell you:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It will be better&lt;/li&gt;
  &lt;li&gt;Artificial intelligence will reach human levels by around 2029. Follow that out further to, say, 2045, we will have multiplied the intelligence, the human biological machine intelligence of our civilization a billion-fold. / Ray Kurzweil&lt;/li&gt;
  &lt;li&gt;The pace of progress in artificial intelligence is incredibly fast. / Jeff Bezos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then comes the next hook:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;AI Won’t Replace You. A Human Using AI Will. / Reece Akhtar&lt;/li&gt;
  &lt;li&gt;AI will not replace humans, but those who use AI will replace those who don’t. / Ginni Rometty&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that unless you live under a rock, you will be fed FOMO and FUD.&lt;/p&gt;

&lt;p&gt;You then seem to have an ecosystem of grifters and scammers that sell you snake oil or LLM services. This would not be a problem had the service been useless. LLMs give you texts that, since they have ingested of huge amounts of content from online sources, should be statistically similar to what a human would have produced. This means that there is a nonzero chance that you can get useful “novel” output that compiles into source code that does what you want it to do. We are in a situation with a mix of disinformation and information. A coworker recently summarized this as “do not trust, verify”.&lt;/p&gt;

&lt;p&gt;How do we navigate this space? My feeling is that in order to use AI generated source code, it is either sufficiently small that you can inspect it, or sufficiently locked down that you can trust it. LLMs are good at producing absolutely insane amounts of texts. This does not mean that they are more productive than a programmer that writes one line per day: you get a perverse incentive to inflate the numbers when lines of code is used as a productivity measure. My feeling is that you need to make sure that the LLMs are constrained by static type system and requirement size. You want the compiler help you verify the source code.&lt;/p&gt;

&lt;p&gt;The best is to use functional programming. You can have programmers reduce their degrees of freedom in source code in order to make the code as easy to audit as possible. Some of the lessons from functional programming can be applied to other languages, so you don’t need to despair. Reduce the potential side effects and mutations. Use types and validations. You would need to figure out ways to constrain the LLM for languages like JavaScript and Clojure.&lt;/p&gt;

&lt;p&gt;Code smells: when using Roo Code or Aider, the LLM generally tries to follow the patterns already in the source. Having complicated patterns or weirdness makes both you and the LLM confused.&lt;/p&gt;

&lt;p&gt;DRY: Don’t repeat yourself takes on a new meaning with LLMs, since many of them like to repeat themselves.&lt;/p&gt;

&lt;p&gt;Architecture and patterns: from what I’ve seen, LLMs perform better on common patterns and common looking source (style of code that looks like what is on GitHub). I’ve seen LLMs do well enough for common architectures. For more obscure patterns or in-house frameworks, the LLMs seem to have a much harder time to produce working code. This is probably the old new thing, as many prefer using common solutions over niche solutions.&lt;/p&gt;

&lt;p&gt;Another way to reduce the potential output of a program is to write tests. The LLMs cannot debug or test the end product in the same way as a human developer or tester, so having tests becomes more valuable in order to verify that the code does what it is supposed.&lt;/p&gt;

&lt;p&gt;These practices, tools and techniques are not new, but gain a new relevance if you want a working solution without unintended side effects.&lt;/p&gt;

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

&lt;p&gt;Some texts I’ve read recently:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.michaelpj.com/blog/2025/04/12/haskell-llm-experiments.html&quot;&gt;Haskell LLM experiments&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.com/@_jba/my-experience-with-cursor-and-clojure-mcp-6e323b90a6f3&quot;&gt;Julien Billes experience with cursor and clojure&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.thoughtworks.com/radar/techniques/ai-friendly-code-design&quot;&gt;AI friendly code design&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.martinfowler.com/articles/pushing-ai-autonomy.html&quot;&gt;Pushing AI autonomy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://mikelovesrobots.substack.com/p/wheres-the-shovelware-why-ai-coding&quot;&gt;Where’s the Shovelware? Why AI Coding Claims Don’t Add Up&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Monorepo conversion continued</title>
      <link>https://assertfail.gewalli.se/2025/05/07/Monorepo-conversion-continued.html</link>
      <pubDate>Wed, 07 May 2025 16:06:37 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2025/05/07/Monorepo-conversion-continued</guid>
      <description>&lt;p&gt;This is a continuation of &lt;a href=&quot;https://assertfail.gewalli.se/2023/02/19/Sample-monorepo-conversion.html&quot;&gt;Sample monorepo conversion&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since then we have learned some lessons. Also note that the monorepo conversions we have done have been of closed source code that we found was either tightly coupled or that we wanted to introduce tighter coupling between components without the overhead of shared libraries.&lt;/p&gt;

&lt;h2 id=&quot;git-subtree&quot;&gt;Git Subtree&lt;/h2&gt;

&lt;h3 id=&quot;subtree-the-good-parts&quot;&gt;Subtree the good parts&lt;/h3&gt;

&lt;p&gt;The good parts about using git subtree is that you can use regular &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git merge&lt;/code&gt; commands from old branches before the code became a monorepo. This is neat if you want to avoid a coordinated code freeze for when the conversion is done.&lt;/p&gt;

&lt;p&gt;In the conversions we wanted to keep the history in order for change tracking to work.&lt;/p&gt;

&lt;h3 id=&quot;subtree-the-bad-parts&quot;&gt;Subtree the bad parts&lt;/h3&gt;

&lt;p&gt;On Azure DevOps the blame feature &lt;a href=&quot;https://developercommunity.visualstudio.com/t/Azure-DevOps-Blame-does-not-show-the-s/10898153&quot;&gt;looks messed up&lt;/a&gt; while on GitHub and in Visual Studio blame shows what you would expect. Some of the links to merges also got messed up because we moved the repositories from the project into separate archive project. The links in Azure DevOps tasks got broken so they show up red. This is not so much a subtree issue as it is that we missed some of the details during the conversion. That Azure DevOps does not handle blame, is not really the fault of subtree.&lt;/p&gt;

&lt;p&gt;You will have huge merge commits done by whoever got tasked with doing the conversion. These show up in history can look kind of ugly if you browse the commit history. Though to be honest, it is not that big of an issue.&lt;/p&gt;

&lt;h2 id=&quot;enter-git-filter-repo&quot;&gt;Enter git-filter-repo&lt;/h2&gt;

&lt;p&gt;By using &lt;a href=&quot;https://github.com/newren/git-filter-repo&quot;&gt;git-filter-repo&lt;/a&gt; you can rewrite the git history to make it look like your files have always been in a conveniently named subfolder of the monorepo.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;sub-project-a
git filter-repo &lt;span class=&quot;nt&quot;&gt;--to-subdirectory-filter&lt;/span&gt; ProjectA
&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;mono-repository
git remote add &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; sub-project-a ../sub-project-a
git merge &lt;span class=&quot;nt&quot;&gt;--allow-unrelated-histories&lt;/span&gt; sub-project-a/master
git remote remove sub-project-a
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;filter-repo-good-parts&quot;&gt;filter-repo good parts&lt;/h3&gt;

&lt;p&gt;We get a nicer looking history. The blame functionality in our current git host works.&lt;/p&gt;

&lt;h3 id=&quot;filter-repo-the-bad-parts&quot;&gt;filter-repo the bad parts&lt;/h3&gt;

&lt;p&gt;After rewriting history, you cannot do a regular git merge with old branches. You might need to recreate your changes by doing format patch in git.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Going towards a monorepo is not without hiccups. The pain points shared above are kind of minor. It did cause some confusion when one person tried looking for the commit when a feature got introduced and found what looked like truncated history in Azure DevOps. In a few years, perhaps this will be fixed by the Azure DevOps team.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean Architecture Comparison continued</title>
      <link>https://assertfail.gewalli.se/2024/11/18/Clean-Architecture-Comparison-continued.html</link>
      <pubDate>Mon, 18 Nov 2024 07:06:35 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2024/11/18/Clean-Architecture-Comparison-continued</guid>
      <description>&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;A year ago I did a &lt;a href=&quot;https://assertfail.gewalli.se/2023/12/02/Clean-Architecture-Comparison.html&quot;&gt;clean architecture comparison&lt;/a&gt; for some clean architecture implementation samples online. One of the conclusions was that I did not look into how much each implementation chooses to marry different frameworks and libraries.&lt;/p&gt;

&lt;p&gt;Since then, we have seen some updates to existing solutions. We see one solution that has been archived &lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnWeb&quot;&gt;eShopOnWeb&lt;/a&gt;, that was deeply influenced by &lt;a href=&quot;https://github.com/ardalis&quot;&gt;@ardalis&lt;/a&gt;, that sample now lives on in &lt;a href=&quot;https://github.com/nimblepros/eShopOnWeb&quot;&gt;nimblepros/eShopOnWeb&lt;/a&gt;. Some are not popular enough that it makes sense to keep them in this comparison. In this post we focus on C#.&lt;/p&gt;

&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Solution&lt;/th&gt;
      &lt;th&gt;Domain/Core&lt;/th&gt;
      &lt;th&gt;Application/UseCases&lt;/th&gt;
      &lt;th&gt;Comments&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/amantinband/clean-architecture/tree/582281115489ac69d048e47c7363c7832e5b425a&quot;&gt;@amantinband&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/SmartEnum&quot;&gt;SmartEnum&lt;/a&gt;, &lt;a href=&quot;https://github.com/amantinband/error-or&quot;&gt;error-or&lt;/a&gt;, &lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt;, &lt;a href=&quot;https://github.com/amantinband/throw&quot;&gt;throw&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;FluentValidation&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/CleanArchitecture/tree/08ddd4f33f87b5f9e388d32c49f4c1d70f3ad24a&quot;&gt;@ardalis&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/SmartEnum&quot;&gt;SmartEnum&lt;/a&gt;, &lt;a href=&quot;https://github.com/ardalis/Ardalis.SharedKernel&quot;&gt;SharedKernel&lt;/a&gt;, &lt;a href=&quot;https://github.com/ardalis/Specification&quot;&gt;Specification&lt;/a&gt;, &lt;a href=&quot;https://github.com/ardalis/Result&quot;&gt;Result&lt;/a&gt;, &lt;a href=&quot;https://github.com/ardalis/GuardClauses&quot;&gt;GuardClauses&lt;/a&gt;, &lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;…&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jasontaylordev/CleanArchitecture/tree/1b0aafdd0d10fda58d48004968343827923fd599&quot;&gt;@jasontaylordev&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;EF, FluentValidation, &lt;a href=&quot;https://github.com/AutoMapper/AutoMapper&quot;&gt;AutoMapper&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;database framework dependency&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/sample-dotnet-core-cqrs-api/tree/2f00e194e72e9288dddd69af499fc97920cba86e&quot;&gt;@kgrzybek&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Dapper, FluentValidation&lt;/td&gt;
      &lt;td&gt;database framework dependency&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ivanpaulovich/clean-architecture-manga/tree/23e3d00555e2f94f7399a21a27a193decace353b&quot;&gt;@ivanpaulovich/clean-architecture-manga&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Not updated&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;If we summarize this table we can note that some of the very popular solutions are dependent on database frameworks in the application layer. Having a database framework dependency is generally frowned upon in Clean Architecture.&lt;/p&gt;

&lt;h2 id=&quot;libraries-in-use&quot;&gt;Libraries in use&lt;/h2&gt;

&lt;p&gt;Many of the popular implementations take a dependency on popular libraries by &lt;a href=&quot;https://github.com/jbogard&quot;&gt;@jbogard&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/AutoMapper/AutoMapper&quot;&gt;AutoMapper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/amantinband&quot;&gt;amantinband&lt;/a&gt; introduces:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/amantinband/throw&quot;&gt;throw&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/amantinband/error-or&quot;&gt;error-or&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/ardalis&quot;&gt;@ardalis&lt;/a&gt; introduces:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ardalis/Result&quot;&gt;Result&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ardalis/Ardalis.SharedKernel&quot;&gt;SharedKernel&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ardalis/SmartEnum&quot;&gt;SmartEnum&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ardalis/Specification&quot;&gt;Specification&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/ardalis/GuardClauses&quot;&gt;GuardClauses&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These libraries are lightweight in that there is not much code or functionality in them.&lt;/p&gt;

&lt;p&gt;We still note that many choose to include such libraries in the domain and or application-layer.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;We see that at least one popular implementation called clean, choose to marry Entity Framework. Most of the implementations choose to include libraries. I would argue that marrying EF is something you need to be very much aware of in a Clean Architecture context. It can still be called clean, though with the addendum that it marries EF. We have a spectrum of clean depending on what &lt;a href=&quot;https://github.com/jasontaylordev/CleanArchitecture/discussions/482?sort=new#discussioncomment-6643279&quot;&gt;is practical for a team to implement&lt;/a&gt;. I interpret this as, that there are missing patterns or language features for C# that makes mainstream implementation of Clean Architecture more of a chore.&lt;/p&gt;

&lt;p&gt;Some of the libraries such as Result, SmartEnum and ErrorOr are needed because of missing language features in C#. These libraries are not needed in an F# solution.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Programmers in the age of Copilot or GPT</title>
      <link>https://assertfail.gewalli.se/2024/07/21/Programmers-in-the-age-of-Copilot-or-GPT.html</link>
      <pubDate>Sun, 21 Jul 2024 19:17:16 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2024/07/21/Programmers-in-the-age-of-Copilot-or-GPT</guid>
      <description>&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;We have seen a rise in the use of non deterministic tools based on machine learning in recent years. Tools such as &lt;a href=&quot;https://github.com/features/copilot&quot;&gt;GitHub Copilot&lt;/a&gt; and &lt;a href=&quot;https://platform.openai.com/docs/overview&quot;&gt;ChatGPT&lt;/a&gt; have brought a change to how some programmers write code.&lt;/p&gt;

&lt;p&gt;We have the following article: &lt;a href=&quot;https://web.archive.org/web/20240624133953/https://visualstudiomagazine.com/articles/2024/01/25/copilot-research.aspx&quot;&gt;New GitHub Copilot Research Finds ‘Downward Pressure on Code Quality’
&lt;/a&gt;. You can find other papers around the impact of relying too much on such tools by searching for research papers.&lt;/p&gt;

&lt;p&gt;My guess is that even though we have changes around tooling, that the impact will not be as large as the hype suggests.&lt;/p&gt;

&lt;h3 id=&quot;terms&quot;&gt;Terms&lt;/h3&gt;

&lt;p&gt;I use the term programmer here broadly to mean anyone that writes code, implying also: software developer, software engineer, software architect et.c.. These terms mean different things depending on context.&lt;/p&gt;

&lt;h2 id=&quot;tools-that-have-had-big-impact-on-programming-in-recent-history&quot;&gt;Tools that have had big impact on programming in recent history&lt;/h2&gt;

&lt;h3 id=&quot;unit-tests&quot;&gt;Unit tests&lt;/h3&gt;

&lt;p&gt;Unit tests ensure code performs as expected, catching errors early and facilitating refactoring. Despite their importance, many overlook their usefulness.&lt;/p&gt;

&lt;p&gt;You need to think about how you write your tests and the impact they have as can be &lt;a href=&quot;https://dhh.dk/2014/test-induced-design-damage.html&quot;&gt;heard from DHH in test induced design damage&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;The introduction of the internet drastically changed the accessibility of information for the average person.&lt;/p&gt;

&lt;p&gt;Before the internet, learning resources were limited to books or physical digital media.&lt;/p&gt;

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

&lt;p&gt;Code completion is considered the norm today. I remember people telling me that it rots your brain. If code completion really rots the brain or not has become moot at this point for many mainstream programmers as the context around how we develop has shifted into making them indispensable.&lt;/p&gt;

&lt;h3 id=&quot;stack-overflow&quot;&gt;Stack Overflow&lt;/h3&gt;

&lt;p&gt;With the introduction of &lt;a href=&quot;https://stackoverflow.com/&quot;&gt;Stack Overflow&lt;/a&gt;, we noticed that some programmers would copy paste “solutions” into their own code without reflection. We see this in the joke around &lt;a href=&quot;https://gkoberger.github.io/stacksort/&quot;&gt;the stacksort algorithm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We know that people copy paste from Stack Overflow into their own source code, as can be seen in &lt;a href=&quot;https://www.sciencedirect.com/science/article/abs/pii/S0950584917303610&quot;&gt;this article&lt;/a&gt;. I’ve seen an example of using Stack Overflow answer that contained desktop style code into a .net framework web application. The code worked when the programmer tested it locally, but failed when more than one person accessed the application. This illustrates the importance of understanding the context and functionality of code snippets before using them.&lt;/p&gt;

&lt;p&gt;What I’ve seen over the years is that Stack Overflow has been a great resource for people to find answers to problems. We tend to forget that &lt;a href=&quot;https://en.wikipedia.org/wiki/Search_engine_optimization&quot;&gt;SEO&lt;/a&gt; made it difficult to find relevant information on the net even before the flood of machine generated content. You could argue that Stack Overflow fixed that since it promoted contributors (since then the &lt;a href=&quot;https://www.youtube.com/watch?v=QDE7B_3jE9M&quot;&gt;site has gone downhill&lt;/a&gt;).&lt;/p&gt;

&lt;h3 id=&quot;github&quot;&gt;GitHub&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/GitHub&quot;&gt;GitHub&lt;/a&gt; has been a big boost to working with software. The main benefit has been that it has been a place where you can read source code and create issues on projects. Untrusted contributors have been given the opportunity to send &lt;a href=&quot;https://en.wikipedia.org/wiki/Fork_and_pull_model&quot;&gt;pull requests&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another side of GitHub is that it is a source of code examples that you can use as a base when you start your projects. The same dangers of downloading and using code from the net applies to source from GitHub as well.&lt;/p&gt;

&lt;h3 id=&quot;copilot&quot;&gt;Copilot&lt;/h3&gt;

&lt;p&gt;The way I use Copilot is often as a base and then modify the result to make it work. Sometimes when I’m lucky (or the problem is simple enough), Copilot will serve up the right answer right away.&lt;/p&gt;

&lt;p&gt;I’ve seen Copilot deliver good enough simple regex, simple unit tests, simple React class components converted into function components, copy pasted code lines turned into function calls. I’ve seen that Copilot does well enough in some cases and fails in other cases.&lt;/p&gt;

&lt;p&gt;Regardless of the tool, you always need to verify the generated code. Writing tests or having a short &lt;a href=&quot;https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop&quot;&gt;REPL&lt;/a&gt; feedback loop can help to confirm that it does what you intended it to do.&lt;/p&gt;

&lt;h4 id=&quot;alternatives&quot;&gt;Alternatives&lt;/h4&gt;

&lt;p&gt;As an alternative to Copilot you can use &lt;a href=&quot;https://platform.openai.com/docs/guides/chat-completions&quot;&gt;ChatGPT&lt;/a&gt; as well as &lt;a href=&quot;https://ollama.com/&quot;&gt;Ollama&lt;/a&gt;. You might also want to look into &lt;a href=&quot;https://github.com/microsoft/autogen&quot;&gt;Agentic AI&lt;/a&gt;. It is yet too early to see how they will be used in the context of software programming.&lt;/p&gt;

&lt;h2 id=&quot;where-do-we-end-up-from-here&quot;&gt;Where do we end up from here&lt;/h2&gt;

&lt;p&gt;You have the same issues with Copilot as when searching for code online and reusing it. You need to verify that the code actually does what you think it does.&lt;/p&gt;

&lt;p&gt;We have seen changes to how people program before. Junior programmers have done silly mistakes because they have tried to run before they could walk. One of the benefits of applying machine learning to programming compared to other areas is that you can get a feedback loop going by compiling and running tests.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean Architecture Comparison</title>
      <link>https://assertfail.gewalli.se/2023/12/02/Clean-Architecture-Comparison.html</link>
      <pubDate>Sat, 02 Dec 2023 18:07:01 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/12/02/Clean-Architecture-Comparison</guid>
      <description>&lt;p&gt;High level image of the clean architecture from &lt;a href=&quot;https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html&quot;&gt;Uncle Bobs blog post&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2023-12-02-Clean-Architecture-Comparison/CleanArchitecture.jpg&quot; alt=&quot;The Clean Architecture image&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Below is a comparison between clean architecture solutions in C# and Java. Most of the samples are in C#.&lt;/p&gt;

&lt;h2 id=&quot;high-level-overview&quot;&gt;High level overview&lt;/h2&gt;

&lt;p&gt;There are some similarities and some key differences between the samples. No general conclusions can be taken from this comparison since:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Closed source clean architectures are not represented (should represent the majority of the implementations).&lt;/li&gt;
  &lt;li&gt;Arbitrary samples based somewhat on GitHub popularity and what I have kept my eyes on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;samples&quot;&gt;Samples&lt;/h2&gt;

&lt;p&gt;Note also that the solutions I’ve picked are somewhat arbitrarily chosen. Some have a lot of attention on GitHub while I’ve kept my eyes on others for a longer time.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Sample&lt;/th&gt;
      &lt;th&gt;Use of Libraries/Structure&lt;/th&gt;
      &lt;th&gt;Grouping/Vertical slice&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/CanerPatir/aspnet-core-clean-arch&quot;&gt;@CanerPatir/aspnet-core-clean-arch&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;WebApi, Infrastructure, Application, Domain libraries&lt;/td&gt;
      &lt;td&gt;Per use case grouping of folders in Application and WebApi&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ivanpaulovich/clean-architecture-manga&quot;&gt;@ivanpaulovich/clean-architecture-manga&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;WebApi, Infrastructure, Application, Domain libraries&lt;/td&gt;
      &lt;td&gt;Per use case grouping of folders in Application and WebApi&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jasontaylordev/CleanArchitecture&quot;&gt;@jasontaylordev/CleanArchitecture&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Web, Infrastructure, Application, Domain libraries&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/mattia-battiston/clean-architecture-example&quot;&gt;@mattia-battiston/clean-architecture-example&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Groups entities and use cases in core project&lt;/td&gt;
      &lt;td&gt;configuration, entrypoints, dataproviders, core libraries&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/CleanArchitecture&quot;&gt;@ardalis/CleanArchitecture&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Web, Infrastructure, UseCases, Core libraries&lt;/td&gt;
      &lt;td&gt;Per use case grouping in Application&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnWeb&quot;&gt;@dotnet-architecture/eShopOnWeb&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Web, PublicApi, Infrastructure, ApplicationCore libraries&lt;/td&gt;
      &lt;td&gt;Aggregate, “Service”&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd&quot;&gt;@kgrzybek/modular-monolith-with-ddd&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;Api, Infrastructure, Application, Domain libraries&lt;/td&gt;
      &lt;td&gt;Per subdomain projects&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h2 id=&quot;comparison&quot;&gt;Comparison&lt;/h2&gt;

&lt;p&gt;There does not seem to be a clear consensus around the naming of layers. Some projects are too simple to get into grouping into slices or subdomains, some of the projects (most notably modular monolith with ddd) shows how a more fleshed out structure could look (in the case that your web api only implements one bounded domain).&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Sample&lt;/th&gt;
      &lt;th&gt;Command handler interface/base class&lt;/th&gt;
      &lt;th&gt;Query handler interface/base class&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/CanerPatir/aspnet-core-clean-arch&quot;&gt;@CanerPatir/aspnet-core-clean-arch&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/CanerPatir/aspnet-core-clean-arch/blob/master/src/Application/ICommandHandler.cs&quot;&gt;ICommandHandler&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/CanerPatir/aspnet-core-clean-arch/blob/master/src/Application/IQueryHandler.cs&quot;&gt;IQueryHandler&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ivanpaulovich/clean-architecture-manga&quot;&gt;@ivanpaulovich/clean-architecture-manga&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;IOutputPort/Named&lt;/td&gt;
      &lt;td&gt;IOutputPort/Named&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jasontaylordev/CleanArchitecture&quot;&gt;@jasontaylordev/CleanArchitecture&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jbogard/MediatR/blob/6baaeef7a16ca75cb905829f870f79c6334ef40e/src/MediatR/IRequestHandler.cs&quot;&gt;IRequestHandler&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jbogard/MediatR/blob/6baaeef7a16ca75cb905829f870f79c6334ef40e/src/MediatR/IRequestHandler.cs&quot;&gt;IRequestHandler&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/mattia-battiston/clean-architecture-example&quot;&gt;@mattia-battiston/clean-architecture-example&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/CleanArchitecture&quot;&gt;@ardalis/CleanArchitecture&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/Ardalis.SharedKernel/blob/c86329bf991bf0c705477b19734c5b5673d1928f/src/Ardalis.SharedKernel/ICommandHandler.cs&quot;&gt;ICommandHandler&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/Ardalis.SharedKernel/blob/c86329bf991bf0c705477b19734c5b5673d1928f/src/Ardalis.SharedKernel/IQueryHandler.cs&quot;&gt;IQueryHandler&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnWeb&quot;&gt;@dotnet-architecture/eShopOnWeb&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;-&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/Specification&quot;&gt;Specification&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd&quot;&gt;@kgrzybek/modular-monolith-with-ddd&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd/blob/cb34be840c72454c633aaec57933602bc75dd8bd/src/Modules/UserAccess/Application/Configuration/Commands/ICommandHandler.cs&quot;&gt;ICommandHandler&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd/blob/cb34be840c72454c633aaec57933602bc75dd8bd/src/Modules/UserAccess/Application/Configuration/Queries/IQueryHandler.cs&quot;&gt;IQueryHandler&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The solutions presented use a couple of different patterns. Most of the solutions use classes per action while some (such as eShopOnWeb) group all of the actions into one class per entity (in this case called service-classes).&lt;/p&gt;

&lt;p&gt;We see that &lt;a href=&quot;https://github.com/jasontaylordev&quot;&gt;@jasontylerdev&lt;/a&gt;, &lt;a href=&quot;https://github.com/kgrzybek&quot;&gt;@kgrzybek&lt;/a&gt;, &lt;a href=&quot;https://github.com/ardalis&quot;&gt;@ardalis&lt;/a&gt; in their samples marries the framework &lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt;. In the case of &lt;a href=&quot;https://github.com/ardalis&quot;&gt;@ardalis&lt;/a&gt; we note that he marries the framework &lt;a href=&quot;https://github.com/ardalis/Ardalis.SharedKernel&quot;&gt;Ardalis.SharedKernel&lt;/a&gt; in his sample. In the case of the dotnet architecture sample eShopOnWeb that solution marries &lt;a href=&quot;https://github.com/ardalis/Specification&quot;&gt;Ardalis.Specification&lt;/a&gt;. We can only echo what Robert C. Martin writes in his book &lt;a href=&quot;https://www.goodreads.com/en/book/show/18043011&quot;&gt;Clean Architecture&lt;/a&gt; on page 292 that you have a extraordinarily asymmetric marriage when you take on a direct dependency on a framework. &lt;a href=&quot;https://github.com/ardalis&quot;&gt;@ardalis&lt;/a&gt; is aware of this fact and write in the about text on his SharedKernel project the following:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Some useful base classes, mainly used with the CleanArchitecture template. Also, a template to make your own SharedKernel nuget package.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Sample&lt;/th&gt;
      &lt;th&gt;Anemic domain entities&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/CanerPatir/aspnet-core-clean-arch&quot;&gt;@CanerPatir/aspnet-core-clean-arch&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/CanerPatir/aspnet-core-clean-arch/blob/431e850fa5811690ad33841984d9dccb3a17bf16/src/Application/UseCases/AddContentToProduct/AddContentToProductCommandHandler.cs&quot;&gt;No&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ivanpaulovich/clean-architecture-manga&quot;&gt;@ivanpaulovich/clean-architecture-manga&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ivanpaulovich/clean-architecture-manga/blob/4fe516c9067e37cb166d1b03b757e0a2104ba9a8/accounts-api/src/Application/UseCases/CloseAccount/CloseAccountUseCase.cs&quot;&gt;No&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jasontaylordev/CleanArchitecture&quot;&gt;@jasontaylordev/CleanArchitecture&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/jasontaylordev/CleanArchitecture/blob/cea275b3c5716fd48e1aaeda231f041f837e9be2/src/Application/TodoItems/Commands/UpdateTodoItem/UpdateTodoItem.cs&quot;&gt;Yes&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/mattia-battiston/clean-architecture-example&quot;&gt;@mattia-battiston/clean-architecture-example&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/mattia-battiston/clean-architecture-example/blob/2335709aebd885a3b39d7a99e64dd6caeb914dfa/application/core/src/main/java/com/clean/example/core/entity/BroadbandAccessDevice.java&quot;&gt;Yes&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/CleanArchitecture&quot;&gt;@ardalis/CleanArchitecture&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/ardalis/CleanArchitecture/blob/3bc14b0ebedeb989ae63fe18e761adf12778dcf1/src/Clean.Architecture.UseCases/Contributors/Update/UpdateContributorHandler.cs&quot;&gt;No&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnWeb&quot;&gt;@dotnet-architecture/eShopOnWeb&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnWeb/blob/f2bb10d5bd8e20bd8c5fc192738090ab33836aec/src/ApplicationCore/Services/BasketService.cs#L80&quot;&gt;No&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd&quot;&gt;@kgrzybek/modular-monolith-with-ddd&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd/blob/ff54f9e6a2f8a672ea0aef5ffe7c163b0b8eb7b8/src/Modules/Payments/Application/MeetingFees/MarkMeetingFeeAsPaid/MarkMeetingFeeAsPaidCommandHandler.cs#L24&quot;&gt;No&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The use of &lt;a href=&quot;https://martinfowler.com/bliki/AnemicDomainModel.html&quot;&gt;anemic domain model&lt;/a&gt; is not uncommon. A dissenting view from what Martin Fowler teaches is that you should embrace manipulating data instead of coupling data and behavior as seen in the book &lt;a href=&quot;https://www.manning.com/books/data-oriented-programming&quot;&gt;Data Oriented Programming&lt;/a&gt;. Note also that even though the domain might be too simple in many cases, I’ve given the authors the benefit of doubt.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;From what I can see, there seems to be some convergence and some differences in naming conventions and patterns. These differences implies that it helps to document the source of your architecture and name conventions.&lt;/p&gt;

&lt;p&gt;We have not gone into the how different samples around how they marry frameworks but simply noted that some of them do couple the domain to a framework. From a clean architecture point of view, being overly dependant on a framework, introduce significant constraints and asymmetries.&lt;/p&gt;

&lt;p&gt;We could improve our understanding of how clean architecture is implemented by reaching out to different organizations implementing clean architecture, but that goes beyond the scope of a simple blog post.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Patch net7 dev container for net8</title>
      <link>https://assertfail.gewalli.se/2023/11/14/Patch-net7-dev-container-for-net8.html</link>
      <pubDate>Tue, 14 Nov 2023 20:17:07 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/11/14/Patch-net7-dev-container-for-net8</guid>
      <description>&lt;p&gt;Since there isn’t an official dev container for net8 yet, you can use the net7 dev container and the setup scripts mention on &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install&quot;&gt;Microsoft Learn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Instead of the base image:&lt;/p&gt;

&lt;div class=&quot;language-dockerfile highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; mcr.microsoft.com/devcontainers/dotnet:0-7.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can add the following to ensure that net8 is installed:&lt;/p&gt;

&lt;div class=&quot;language-dockerfile highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;RUN &lt;/span&gt;wget https://dot.net/v1/dotnet-install.sh &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; dotnet-install.sh
&lt;span class=&quot;k&quot;&gt;RUN &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;chmod&lt;/span&gt; +x ./dotnet-install.sh
&lt;span class=&quot;k&quot;&gt;RUN &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; ./dotnet-install.sh &lt;span class=&quot;nt&quot;&gt;--channel&lt;/span&gt; 8.0 &lt;span class=&quot;nt&quot;&gt;--install-dir&lt;/span&gt; /usr/share/dotnet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>What does SOLID mean</title>
      <link>https://assertfail.gewalli.se/2023/08/19/What-does-SOLID-mean.html</link>
      <pubDate>Sat, 19 Aug 2023 08:32:45 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/08/19/What-does-SOLID-mean</guid>
      <description>&lt;h2 id=&quot;sources&quot;&gt;Sources&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://speakerdeck.com/tastapod/why-every-element-of-solid-is-wrong&quot;&gt;Dan North: Why Every Element of SOLID is Wrong&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/SOLID#SOLID_Principles&quot;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/5577054/solid-for-functional-programming&quot;&gt;SOLID for functional programming&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://softwareengineering.stackexchange.com/questions/165356/equivalent-of-solid-principles-for-functional-programming&quot;&gt;Equivalent of SOLID principles for functional programming&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://blog.cleancoder.com/uncle-bob/2020/10/18/Solid-Relevance.html&quot;&gt;Solid Relevance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;principles&quot;&gt;Principles&lt;/h2&gt;

&lt;h3 id=&quot;single-responsibility-principle&quot;&gt;Single responsibility principle&lt;/h3&gt;

&lt;p&gt;Let us start with &lt;a href=&quot;https://blog.cleancoder.com/uncle-bob/2014/05/08/SingleReponsibilityPrinciple.html&quot;&gt;The single responsibility principle&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Gather together the things that change for the same reasons. Separate things that change for different reasons.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;some see it as:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;do one thing and do it well&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The problem with this principle is that the definition is open for interpretation. The principle assumes sufficient experience around what kind of changes in requirements we can expect (something that depends on the people involved). I’ve worked with people that have a good grasp on how large a class/module or function should be, but the problem is that people have different expectations around what kind responsibility/concern code should have. It is a good thing to keep code focused on one thing, so the principle should be more of a reminder to break out or move code that does not fit. As &lt;a href=&quot;https://sklivvz.com/posts/i-dont-love-the-single-responsibility-principle&quot;&gt;Marco Cecconi in ‘I don’t love the single responsibility principle’&lt;/a&gt; mentions, to avoid making a mess you need balance coupling and cohesion (not something you would expect a developer that has only worked for a few years to know). It can still be good to have it in mind.&lt;/p&gt;

&lt;h3 id=&quot;open-closed-principle&quot;&gt;Open-Closed principle&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;A Module should be open for extension but closed for modification.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Mentioned in &lt;a href=&quot;https://web.archive.org/web/20060822033314/http://www.objectmentor.com/resources/articles/ocp.pdf&quot;&gt;The Open-Closed Principle&lt;/a&gt;.
This is another principle that you need to have experience in order to apply in a good way. The risk is that it becomes as Dan North says&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Cruft Accretion Principle&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I don’t agree with Dan North. If you have smaller code blocks as mentioned in single responsibility principle you can garbage collect old code.&lt;/p&gt;

&lt;p&gt;Perhaps some of the issues around this principle is that it becomes overly ambitious scope if taken out of context. If we pull back on the ambition and instead focus on some of the things he talks about in the article we can summarize as following:&lt;/p&gt;

&lt;p&gt;The reason for the principle is that you want to avoid cascade of changes due to a single change of one code unit. That is&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Allowing you to change behaviors without modifying code&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An example is given how it is brittle to write code that uses “runtime type identification”. Why is that brittle?  The reason it is brittle is because if you have a class that is not &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sealed&lt;/code&gt; in C# or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;final&lt;/code&gt; in Java or C++, someone can easily inherit and break old assumptions.&lt;/p&gt;

&lt;p&gt;My take on the case of OCP is that you either make code:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;closed: i.e. make sure that you cannot inherit by making the class sealed/final having an algebraic datatype&lt;/li&gt;
  &lt;li&gt;open: open for inheritance but have property/method to the class/type so that the you force child classes to take a decision&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My feeling is that this principle makes most sense when talking about&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Clear single responsibility principle violations&lt;/li&gt;
  &lt;li&gt;Inheritance in your business code. Many developers follow &lt;a href=&quot;https://en.wikipedia.org/wiki/Composition_over_inheritance&quot;&gt;Composition over inheritance&lt;/a&gt; why you do not need to worry about open and closed in relation to inheritance in such code bases.&lt;/li&gt;
  &lt;li&gt;When you are developing framework/infrastructure code. It makes more sense to freeze framework/infrastructure behavior than it does to freeze business behavior (since businesses and people change).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;liskov-substitution-principle&quot;&gt;Liskov substitution principle&lt;/h3&gt;

&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Liskov_substitution_principle&quot;&gt;Liskov substitution principle&lt;/a&gt; is not formulated mostly by Uncle Bob, why it has a slightly different feel to it.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;An implementation of an abstraction should be replaceable with other implementations of the same abstraction&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or formulated in a different way&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Code unit that publishes conformance to contract should conform to the contract&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or in this way&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A program that uses an interface must not be confused by an implementation of that interface.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlycollection-1?view=net-7.0#definition&quot;&gt;IReadOnlyCollection&lt;/a&gt; suffers from a violation of Liskov principle as can be seen on &lt;a href=&quot;https://stackoverflow.com/questions/13819058/readonlycollection-vs-liskov-how-to-correctly-model-immutable-representations&quot;&gt;Stackoverflow: ReadOnlyCollection vs Liskov&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We note that IReadOnlyCollection is more about what Dan North says:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;acts-like-a, can-be-used-as-a&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is, if we send in a list to a method that accepts a read-only collection then we assume that the method wont mutate the list and the method assumes that we won’t mutate that list (during the execution of the method). This means that we are back at a more fuzzy interpretation rather than a strict principle. My feeling is that even though it is benign to let lists act like readonly, you are opening yourself up to trouble in the long run since it is a detail that is easy to miss.&lt;/p&gt;

&lt;h3 id=&quot;interface-segregation-principle&quot;&gt;Interface segregation principle&lt;/h3&gt;

&lt;p&gt;From &lt;a href=&quot;https://docs.google.com/a/cleancoder.com/viewer?a=v&amp;amp;pid=explorer&amp;amp;chrome=true&amp;amp;srcid=0BwhCYaYDn8EgOTViYjJhYzMtMzYxMC00MzFjLWJjMzYtOGJiMDc5N2JkYmJi&amp;amp;hl=en&quot;&gt;object mentor article ISP&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Clients should not be forced to depend upon interfaces that they do not use.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or also formulated as&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Keep interfaces small so that users don’t end up depending on things they don’t need.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The intention of this principle is that you should not require your code to depends on “fat” interfaces (or collection of unrelated interfaces).&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Having to implement more methods requires more work. Introduces unnecessary work.&lt;/li&gt;
  &lt;li&gt;It is harder to know what parts of a larger interface is relevant to mock/fake when you are doing unit testing. Having smaller interfaces simplifies testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The problem with this principle is that there isn’t a sufficiently clear definition of when to apply this principle. In many cases depending on C# &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ICollection&amp;lt;&amp;gt;&lt;/code&gt; is better instead of a specialized interface with only the methods that you use. You rarely implement your own collections, rather you usually depend on existing framework implemented collections. If you instead try to limit this principle to business code (instead of infrastructure) you can end up with infrastructure code that makes your code hard to test when there isn’t any provided testing tools for the infrastructure.&lt;/p&gt;

&lt;h3 id=&quot;dependency-inversion-principle&quot;&gt;Dependency inversion principle&lt;/h3&gt;

&lt;p&gt;From &lt;a href=&quot;https://web.archive.org/web/20110714224327/http://www.objectmentor.com/resources/articles/dip.pdf&quot;&gt;object mentor article DIP&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;modules that encapsulate high level policy should not depend upon modules that implement details. Rather, both kinds of modules should depend upon abstractions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;or also formulated as&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Depend in the direction of abstraction. High level modules should not depend upon low level details.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Why? My feeling is that he describes a situation with a solution with a mix of business logic and low level implementation logic. This principle makes most sense when you want to use an architecture such as &lt;a href=&quot;https://blog.ploeh.dk/2016/03/18/functional-architecture-is-ports-and-adapters/&quot;&gt;adapters/hexagonal/clean architecture&lt;/a&gt;. Understanding that type of architecture requires you to be familiar with its culture and purpose.&lt;/p&gt;

&lt;p&gt;If we are talking about two different things such as high level modules or detail being business code and low level modules being databases, integrations and hardware implementation. If we code directly against a specific database/integration/x86 architecture then we know that the code is less portable. Having infrastructure interfaces that includes business details means that the infrastructure is tied to that business domain. That is generally fine for solutions that only caters to one business domain but not fine for general purpose code such as say &lt;a href=&quot;https://learn.microsoft.com/en-us/ef/core/&quot;&gt;Entity Framework Core&lt;/a&gt; or &lt;a href=&quot;https://hibernate.org/&quot;&gt;Hibernate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One of the big question I usually have around clean architecture is if you want to isolate yourself from the external infrastructure (such as Hibernate or Entity Framework Core) or if the usage of such frameworks can be seen as in line with the goal of having a way to isolate yourself from too much details about the database. The previous iteration of Entity Framework, called only Entity Framework instead with the “Core” tacked on, had a &lt;a href=&quot;https://stackoverflow.com/questions/22690877/how-are-people-unit-testing-with-entity-framework-6-should-you-bother&quot;&gt;higher coupling with the database&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We should not design for reuse in our business domain, but rather if we are building software that is intended for many business domains. This means that by misunderstanding this principle it can lead you into writing “reusable” code that should never be reused.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;My feeling is that SOLID makes sense. It does however require you to have worked as a software developer/engineer enough in order to get the experience needed to understand them. Working on complicated code and gaining enough experience will net you a feeling of what is common sense aligned with SOLID. Working in other projects that do not have sufficient complexity and enough business logic may well give you another view. I’ve talked with coworkers that have seen the failure mode of teams trying to apply the principles in a mechanical way. SOLID experiences what what Eric Normand denotes &lt;a href=&quot;https://ericnormand.me/podcast/the-christopher-alexander-effect&quot;&gt;The Christopher Alexander Effect&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Data Specifications in Java and .net</title>
      <link>https://assertfail.gewalli.se/2023/04/07/Data-Specifications-in-Java-and-net.html</link>
      <pubDate>Fri, 07 Apr 2023 14:17:13 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/04/07/Data-Specifications-in-Java-and-net</guid>
      <description>&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;In &lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnWeb&quot;&gt;dotnet-architecture/eShopOnWeb&lt;/a&gt; I noticed the interesting usage of Specification classes. When I did some digging, I found that these are implemented through &lt;a href=&quot;https://github.com/ardalis/Specification&quot;&gt;ardalis/Specification&lt;/a&gt; For those who are more familiar with the Java world we have &lt;a href=&quot;https://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl&quot;&gt;Data Specifications&lt;/a&gt;. If you read Implementing Domain Driven design in the bibliography you find a reference to &lt;a href=&quot;https://martinfowler.com/apsupp/spec.pdf&quot;&gt;Martin Fowlers paper&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;sample-based-on-wikipedia&quot;&gt;Sample based on Wikipedia&lt;/h2&gt;

&lt;p&gt;So if we look at &lt;a href=&quot;https://en.wikipedia.org/wiki/Specification_pattern&quot;&gt;Wikipedia&lt;/a&gt; we can infer the following code:&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;OverDueSpecification&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ISpecification&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;bool&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;IsSatisfiedBy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PayDeadline&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;// ...&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;overDue&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;OverDueSpecification&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;noticeSent&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;NoticeSentSpecification&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inCollection&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;InCollectionSpecification&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sendToCollection&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;overDue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;And&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;noticeSent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;And&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;inCollection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Not&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;higher-level-abstractions&quot;&gt;Higher level abstractions&lt;/h2&gt;

&lt;p&gt;We see that Ardalis Specifications collects &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;System.Linq.Expression&lt;/code&gt; (note the lambda):&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;OverDueSpecification&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Specification&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;OverDueSpecification&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PayDeadline&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This can be seen as an alternative API to the interfaces used by EF like &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/api/system.data.entity.idbset-1?view=entity-framework-6.2.0&quot;&gt;IDbSet&amp;lt;&amp;gt;&lt;/a&gt; and &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/api/system.linq.iqueryable-1?view=net-7.0&quot;&gt;IQueryable&amp;lt;&amp;gt;&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;modules&quot;&gt;Modules&lt;/h2&gt;

&lt;p&gt;Since the point of the pattern is that you should be able to separate the query specification from the data you could argue that the pattern is satisfied by having a module of specifications where you create the specification instances through method calls:&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;InvoiceSpecifications&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IQueryable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;OverDue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;IQueryable&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;entity&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PayDeadline&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;InvoiceSpecifications&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;JPAQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;overDue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;JPAQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;QInvoice&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;QInvoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;where&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;invoice&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;payDeadline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lastname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;lt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;LocalDateTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;now&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The choice of using a class for a single specification or a method depends on how visible you want these specifications to be. By having a class in a separate file with a single specification, it becomes possible to browse in file system viewer. Some might argue that this introduces ceremony, but that depends on the preferences of the team (as can be seen in the eShopOnWeb example).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Running minikube on M1 and K8S tutorial</title>
      <link>https://assertfail.gewalli.se/2023/04/05/Running-minikube-on-M1-and-K8S-tutorial.html</link>
      <pubDate>Wed, 05 Apr 2023 17:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/04/05/Running-minikube-on-M1-and-K8S-tutorial</guid>
      <description>&lt;p&gt;As previously &lt;a href=&quot;https://assertfail.gewalli.se/2023/02/06/Running-SQL-Server-on-Docker-with-an-M1ARM-CPU.html&quot;&gt;mentioned in the blog I use a M1 mac&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to help introduce others to Kubernetes I have done some testing of the &lt;a href=&quot;https://kubernetes.io/docs/tutorials/kubernetes-basics/&quot;&gt;K8S tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to try it out I first tried using the qemu driver for minikube. First gotcha was that the image &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcr.io/google-samples/kubernetes-bootcamp:v1&lt;/code&gt; does not work on ARM natively.&lt;/p&gt;

&lt;h2 id=&quot;let-the-yac-shaving-begin&quot;&gt;Let the Yac Shaving begin&lt;/h2&gt;

&lt;h3 id=&quot;running-minikube-in-docker&quot;&gt;Running minikube in docker&lt;/h3&gt;

&lt;p&gt;In order to get around this limitation you can &lt;a href=&quot;https://minikube.sigs.k8s.io/docs/drivers/docker/&quot;&gt;run minikube in docker&lt;/a&gt;. Either by using &lt;a href=&quot;https://github.com/abiosoft/colima&quot;&gt;colima&lt;/a&gt; or Docker Desktop with experimental Rosetta emulation.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;minikube start &lt;span class=&quot;nt&quot;&gt;--driver&lt;/span&gt; docker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Running the first part part of the tutorial works fine. You can &lt;a href=&quot;https://kubernetes.io/docs/tutorials/kubernetes-basics/deploy-app/deploy-intro/&quot;&gt;create a deployment&lt;/a&gt;, you can &lt;a href=&quot;https://kubernetes.io/docs/tutorials/kubernetes-basics/explore/explore-intro/&quot;&gt;view pods and nodes&lt;/a&gt;. The weird part starts when you forget that minikube is now running in a docker container instance and run:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;kubectl expose deployment/kubernetes-bootcamp &lt;span class=&quot;nt&quot;&gt;--type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;NodePort&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--port&lt;/span&gt; 8080
&lt;span class=&quot;c&quot;&gt;#...&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;NODE_PORT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;kubectl get services/kubernetes-bootcamp &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; go-template&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;{{(index .spec.ports 0).nodePort }}&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;NODE_PORT=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NODE_PORT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then try to do:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl http://&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;minikube ip&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$NODE_PORT&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-intro/&quot;&gt;expose intro&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we are not binding all of the ports for minikube docker instance, the exposed port is not bound.&lt;/p&gt;

&lt;p&gt;Instead you can do:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;minikube service kubernetes-bootcamp &lt;span class=&quot;nt&quot;&gt;--url&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to get the url to the service.&lt;/p&gt;

&lt;h3 id=&quot;using-qemu-and-building-your-own-docker-images&quot;&gt;Using qemu and building your own docker images&lt;/h3&gt;

&lt;p&gt;Since I started out with a simple qemu install I wanted to go all in the next round. I installed socket_vmnet and used:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;socket_vmnet
brew tap homebrew/services
&lt;span class=&quot;nv&quot;&gt;HOMEBREW&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;which brew&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HOMEBREW&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt; services start socket_vmnet
&lt;span class=&quot;c&quot;&gt;#...&lt;/span&gt;
minikube start &lt;span class=&quot;nt&quot;&gt;--driver&lt;/span&gt; qemu &lt;span class=&quot;nt&quot;&gt;--network&lt;/span&gt; socket_vmnet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I then built images that uses both arm and x86:&lt;/p&gt;

&lt;p&gt;First the Dockerfile:&lt;/p&gt;

&lt;div class=&quot;language-Dockerfile highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; node:slim&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;EXPOSE&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; 8080&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;COPY&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; server.js .&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;CMD&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; node server.js&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;based on &lt;a href=&quot;https://github.com/jocatalin/bootcamp/blob/gh-pages/code/docker/Dockerfile&quot;&gt;kubernetes bootcamp Dockerfile&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;server.js:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;http&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;podname&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HOSTNAME&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;startTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;handleRequest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;setHeader&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Content-Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;text/plain&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;writeHead&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Hello Kubernetes bootcamp! | Running on: &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; | v=1&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Running On:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;| Total Requests:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;| App Uptime:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;startTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;seconds&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;| Log Time:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;());&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;www&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;createServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;handleRequest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;nx&quot;&gt;www&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;listen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8080&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;startTime&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;host&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;process&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;HOSTNAME&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;console&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;log&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Kubernetes Bootcamp App Started At:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;startTime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;| Running On: &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;based on &lt;a href=&quot;https://github.com/wallymathieu/k8s-bootcamp/blob/gh-pages/code/docker/v1/server.js&quot;&gt;kubernetes bootcamp server.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My first instinct was to simply build the image and be done with it. But that is not as fun as going deeper. To take it further I wanted to grow the bananas to be used in the smoothie!&lt;/p&gt;

&lt;p&gt;First I tried:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;v1&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;wallymathieu/kubernetes-bootcamp:&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$version&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

docker buildx build &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$name&lt;/span&gt; ./&lt;span class=&quot;nv&quot;&gt;$version&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f&lt;/span&gt; Dockerfile &lt;span class=&quot;nt&quot;&gt;--platform&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;linux/arm64,linux/amd64 &lt;span class=&quot;nt&quot;&gt;--push&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Image &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$name&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; built&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I got &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Error: multiple platforms feature is currently not supported for docker driver&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When running The buildx ls environment looked like it could handle amd64:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; docker buildx &lt;span class=&quot;nb&quot;&gt;ls
&lt;/span&gt;NAME/NODE       DRIVER/ENDPOINT STATUS  BUILDKIT PLATFORMS
default &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;       docker
  default       default         running 20.10.23 linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
desktop-linux   docker
  desktop-linux desktop-linux   running 20.10.23 linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I then found that others had solved this issue by simply creating a &lt;a href=&quot;https://forums.docker.com/t/error-multiple-platforms-feature-is-currently-not-supported-for-docker-driver/124811/11&quot;&gt;new buildx multiarch with docker container driver&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;docker buildx create &lt;span class=&quot;nt&quot;&gt;--name&lt;/span&gt; multiarch &lt;span class=&quot;nt&quot;&gt;--driver&lt;/span&gt; docker-container &lt;span class=&quot;nt&quot;&gt;--use&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I could then build the images and push them to docker hub, as can be &lt;a href=&quot;https://hub.docker.com/repository/docker/wallymathieu/kubernetes-bootcamp/general&quot;&gt;seen here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now I could continue on the kubernetes bootcamp tutorial using the custom images.&lt;/p&gt;

&lt;p&gt;So instead of using the default 7 year old image (gcr.io/google-samples/kubernetes-bootcamp:v1) I wanted my shining new multi platform image built using the same code as in &lt;a href=&quot;https://github.com/jocatalin/bootcamp&quot;&gt;jocatalin/kubernetes-bootcamp&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;kubectl create deployment kubernetes-bootcamp &lt;span class=&quot;nt&quot;&gt;--image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;wallymathieu/kubernetes-bootcamp:v1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And instead of &lt;a href=&quot;https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/&quot;&gt;upgrade your app&lt;/a&gt; using the old image, I used the custom built v2 image:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;kubectl &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;image deployments/kubernetes-bootcamp kubernetes-bootcamp&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;wallymathieu/kubernetes-bootcamp:v2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;side-note&quot;&gt;Side-note&lt;/h3&gt;

&lt;p&gt;One thing that struck me was that why did they use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcr.io/google-samples/kubernetes-bootcamp:v1&lt;/code&gt; instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jocatalin/kubernetes-bootcamp:v1&lt;/code&gt;, I did get my answer when I tried using that image and could not connect to port 8080 on that image since the &lt;a href=&quot;https://github.com/jocatalin/bootcamp/blob/gh-pages/code/docker/v1/server.js#L15&quot;&gt;code assumes port 8081&lt;/a&gt; while the &lt;a href=&quot;https://github.com/jocatalin/bootcamp/blob/gh-pages/code/docker/Dockerfile&quot;&gt;dockerfile says port 8080&lt;/a&gt; perhaps to have a reason to patch the image?&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Successfully shaved the Yak! I got the tutorial working and only had to do a few smallish things in order to finish it.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Sample monorepo conversion</title>
      <link>https://assertfail.gewalli.se/2023/02/19/Sample-monorepo-conversion.html</link>
      <pubDate>Sun, 19 Feb 2023 11:47:28 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/02/19/Sample-monorepo-conversion</guid>
      <description>&lt;h2 id=&quot;project-with-many-repositories&quot;&gt;Project with many repositories&lt;/h2&gt;

&lt;p&gt;This is a continuation of &lt;a href=&quot;https://assertfail.gewalli.se/2021/11/05/Monorepo-versus-Polyrepo.html&quot;&gt;Monorepo versus Polyrepo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is a story about a project I worked on. We had some pain points related to many different source repositories.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Shared business domain library that contained shared business types&lt;/li&gt;
  &lt;li&gt;Shared library with a base parent entity (with common behavior)&lt;/li&gt;
  &lt;li&gt;Many services that dealt with different subdomains that uses a few shared libraries&lt;/li&gt;
  &lt;li&gt;Very complicated requirements with lots of nuances&lt;/li&gt;
  &lt;li&gt;Different persons had different areas of expertise&lt;/li&gt;
  &lt;li&gt;Generally the services are loose coupled&lt;/li&gt;
  &lt;li&gt;Thought out structure for each service and uniform style&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At first, we thought that the shared code would stabilize. This did not happen. This meant a large number of pull requests with only package version changes.&lt;/p&gt;

&lt;p&gt;We wanted to change code in the shared libraries along new core requirements.
We had confusion around package versions due to the sheer amount of package changes.
During retrospectives the team expressed frustration with the amount of unnecessary work.&lt;/p&gt;

&lt;h2 id=&quot;time-to-merge&quot;&gt;Time to merge&lt;/h2&gt;

&lt;p&gt;We decided to merge the repositories into a shared repository for the .net code. This meant that we changed the &lt;a href=&quot;https://en.wikipedia.org/wiki/NuGet&quot;&gt;NuGet packages&lt;/a&gt; to &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-reference&quot;&gt;project references&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We also needed to support work on two major branches. For this particular business, there is a need to get legal to sign off on any major release. When we develop a major version we also bugfix the previous major version.&lt;/p&gt;

&lt;h2 id=&quot;git-magic&quot;&gt;Git magic&lt;/h2&gt;

&lt;p&gt;We looked into using &lt;a href=&quot;https://git-scm.com/docs/git-submodule&quot;&gt;git submodule&lt;/a&gt;. We decided that it was not the right choice for the team: everyone would need to learn how to use it. Git submodule requires the team to learn additional commands to do &lt;a href=&quot;https://stackoverflow.com/questions/1030169/pull-latest-changes-for-all-git-submodules&quot;&gt;pull and checkout&lt;/a&gt; in the main repository.
We noticed was that you can use &lt;a href=&quot;https://www.atlassian.com/git/tutorials/git-subtree&quot;&gt;git subtree&lt;/a&gt; in similar way as git submodule. Difference is that only a few persons need to learn the extra commands.&lt;/p&gt;

&lt;p&gt;You can fetch changes from different repositories into a merged repository.&lt;/p&gt;

&lt;h2 id=&quot;builds-builds-and-builds&quot;&gt;Builds builds and builds&lt;/h2&gt;

&lt;p&gt;Our CI triggered a build for every new branch for every service.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Making changes to shared libraries become easier.
We could use existing tools to make the transition (git subtree).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Running SQL Server on Docker with an M1/ARM CPU</title>
      <link>https://assertfail.gewalli.se/2023/02/06/Running-SQL-Server-on-Docker-with-an-M1ARM-CPU.html</link>
      <pubDate>Mon, 06 Feb 2023 17:46:11 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/02/06/Running-SQL-Server-on-Docker-with-an-M1ARM-CPU</guid>
      <description>&lt;p&gt;In 2021 my aging MacBook Pro (16GB RAM, I7) had issues with a swelling battery. The touch pad sensitivity became an issue. In order to replace that machine I opted for a MacBook Air (8GB, M1). Compilation speed (at least of F# code) on the Air is faster than the old machine, but it is not as responsive when I have a lot of things running at the same time.&lt;/p&gt;

&lt;p&gt;In order to try out and showcase different technologies and services, I usually run Docker. Most images that I used where fine, however the one image that caused trouble was SQL Server as can be seen in the issue &lt;a href=&quot;https://github.com/microsoft/mssql-docker/issues/734&quot;&gt;Does not work on Mac M1 #734&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For some cases I could use &lt;a href=&quot;https://learn.microsoft.com/en-us/azure/azure-sql-edge/disconnected-deployment&quot;&gt;Azure SQL Edge&lt;/a&gt;. The troubles started when at work I started at a project using spatial types. I had the pleasure of getting a new developer machine (MacBook Pro M1) so I ran into the issue not only at home, but also at work.&lt;/p&gt;

&lt;p&gt;To get around the issue I found that you can run container runtime in a different architecture (AMD) using &lt;a href=&quot;https://github.com/abiosoft/colima&quot;&gt;Colima&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I tried out different configurations. What finally worked for me was to run:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;colima start &lt;span class=&quot;nt&quot;&gt;--arch&lt;/span&gt; amd &lt;span class=&quot;nt&quot;&gt;--cpu&lt;/span&gt; 4 &lt;span class=&quot;nt&quot;&gt;--memory&lt;/span&gt; 4
docker context use colima
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This was inspired by a sample start configuration mentioned in the issue &lt;a href=&quot;https://github.com/abiosoft/colima/issues/288&quot;&gt;v0.4.1: x86_64 getting stuck with qemu64 cpu #288&lt;/a&gt;, but slightly different. These settings worked on a M1 MacBook Pro where I fiddled with the CPU and memory until it started working.&lt;/p&gt;

&lt;p&gt;Right now, many months later we see that Docker for Desktop has an experimental Rosetta emulation setting as seen in Recap of issue &lt;a href=&quot;https://github.com/microsoft/mssql-docker/issues/734#issuecomment-1382576843&quot;&gt;Does not work on Mac M1 #734&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I’m still running Colima at work, but I’ve tried the Rosetta emulation at home and it works well enough (after a reboot).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Architecture and functional programming</title>
      <link>https://assertfail.gewalli.se/2023/02/05/Architecture-and-functional-programming.html</link>
      <pubDate>Sun, 05 Feb 2023 10:59:11 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2023/02/05/Architecture-and-functional-programming</guid>
      <description>&lt;p&gt;This post is a continuation of &lt;a href=&quot;https://assertfail.gewalli.se/2022/09/22/Unclean-architecture.html&quot;&gt;Unclean architecture&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;clean-architecture&quot;&gt;Clean architecture&lt;/h2&gt;

&lt;p&gt;From what I understand of &lt;a href=&quot;https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html&quot;&gt;Clean architecture&lt;/a&gt; it’s an iteration of &lt;a href=&quot;https://en.wikipedia.org/wiki/Hexagonal_architecture_(software)&quot;&gt;Hexagonal architecture&lt;/a&gt; also known as Ports and Adapters (see the Wikipedia page).&lt;/p&gt;

&lt;h3 id=&quot;clean-architecture-use-of-oo-and-code-dependency&quot;&gt;Clean architecture use of OO and code dependency&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;OO is the ability, through the use of polymorphism, to gain absolute control over every source code dependency in the system. It allows the architect to create a plugin architecture, in which modules that contain high-level policies are independent of modules that contain low-level details. The low-level details are relegated to plugin modules that can be deployed and developed independently from the modules that contain high-level policies.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Martin, Robert C. . Clean Architecture (Robert C. Martin Series) (p. 47). Pearson Education. Kindle Edition.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As we have seen around functional programming there are &lt;a href=&quot;https://fsharpforfunandprofit.com/posts/dependencies/&quot;&gt;many ways of dealing with dependencies&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;compare-to-pure-and-impure&quot;&gt;Compare to pure and impure&lt;/h3&gt;

&lt;p&gt;Compare &lt;a href=&quot;https://blog.ploeh.dk/2020/03/02/impureim-sandwich/&quot;&gt;Impureim sandwich&lt;/a&gt; with the hexagonal/clean/ports and adapters architecture&lt;/p&gt;

&lt;p&gt;The question then is if the domain is supposed to be free from external code so that you have only code that you yourself understand or if it’s supposed to only be code without external IO/side-effects?&lt;/p&gt;

&lt;p&gt;A clean as in pure functional domain without IO will be:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Testable&lt;/li&gt;
  &lt;li&gt;Independent of DB, external agency, UI&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the same way as a clean architecture. There might be implicit dependency on DB, UI et.c. due to features or flows that implies such. We even have Mark Seemann argue that &lt;a href=&quot;https://blog.ploeh.dk/2016/03/18/functional-architecture-is-ports-and-adapters/&quot;&gt;functional architecture is Ports and Adapters&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;existence-of-clean-code&quot;&gt;Existence of clean code&lt;/h2&gt;

&lt;p&gt;There are people that argue that there is &lt;a href=&quot;https://www.steveonstuff.com/2022/01/27/no-such-thing-as-clean-code&quot;&gt;no such thing as clean code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The problem is that low level vs high level is not a clear enough concept.&lt;/p&gt;

&lt;p&gt;It feels like what Robert Martin is trying to describe is the business domain code without other peoples code (except when you really trust it), without code for IO like http, file access et.c..&lt;/p&gt;

&lt;p&gt;You could perhaps argue that when trying to come up with a clean architecture for Haskell then one way to define such a scheme could be to you isolate your business code from any IO (something quite feasible in Haskell). The benefit of using some of the functional programming concepts is that they at least have a formal definition that can be verified.&lt;/p&gt;

&lt;p&gt;My guess is that the problem is that for many senior developers/programmers clean code is related to feelings of cleanliness, so will be apparent to programmers that have gotten a feeling for it (my guess being that you would teach that through literary workshops).&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;FP concepts have come to have a broad influence over many mainstream core frameworks (see the functional concepts in &lt;a href=&quot;https://www.baeldung.com/java-functional-programming&quot;&gt;Java&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Language_Integrated_Query&quot;&gt;C#&lt;/a&gt; base libraries). We can argue that these concepts give us tools and definitions that help remove the fluff around the definitions. The downside is that the language of functional programming is often unfamiliar and feels foreign to many developers (why it makes sense to &lt;a href=&quot;https://fsharpforfunandprofit.com/about/#banned&quot;&gt;use the concepts without explicitly mentioning them&lt;/a&gt;).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Keeping a library in dotnet binary compatible for several years</title>
      <link>https://assertfail.gewalli.se/2022/12/01/Keeping-a-library-in-dotnet-binary-compatible-for-several-years.html</link>
      <pubDate>Thu, 01 Dec 2022 19:04:52 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2022/12/01/Keeping-a-library-in-dotnet-binary-compatible-for-several-years</guid>
      <description>&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;I’m one of the people contributing to &lt;a href=&quot;https://github.com/fsprojects/FSharpPlus&quot;&gt;F#+&lt;/a&gt;. I got involved in the library around 2017 since I was looking for computation expression builders to clean up my F# code (after a few turns that turned out to be F#+).&lt;/p&gt;

&lt;p&gt;Around 2018 we released the v1 version. Since then we have released minor versions of the library with new features and bug fixes.&lt;/p&gt;

&lt;p&gt;In order to not break any users (such as our own usage) we try as far as possible to be backwards compatible.&lt;/p&gt;

&lt;h2 id=&quot;running-tests-against-an-old-version&quot;&gt;Running tests against an old version&lt;/h2&gt;

&lt;p&gt;How do you do that? We have created a project that compiles a copy of the tests against the v1.0 release. Then we include those tests in the test execution with the current version of F#+. This means that the DLLs will be pulled up to the current version even though the project compiled against an old version.&lt;/p&gt;

&lt;p&gt;The fsproj for the project that references F#+ 1 looks like:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Sdk=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Microsoft.NET.Sdk&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;TargetFrameworks&amp;gt;&lt;/span&gt;netstandard2.0;net461&lt;span class=&quot;nt&quot;&gt;&amp;lt;/TargetFrameworks&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;RootNamespace&amp;gt;&lt;/span&gt;FSharpPlus.One&lt;span class=&quot;nt&quot;&gt;&amp;lt;/RootNamespace&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;PackageReference&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;FSharpPlus&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Version=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;1.0.0&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;While the actual test project will reference the above like:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;Project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Sdk=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Microsoft.NET.Sdk&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;IsPackable&amp;gt;&lt;/span&gt;false&lt;span class=&quot;nt&quot;&gt;&amp;lt;/IsPackable&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;ProjectReference&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;..\..\src\FSharpPlus\FSharpPlus.fsproj&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
      &lt;span class=&quot;nt&quot;&gt;&amp;lt;Private&amp;gt;&lt;/span&gt;True&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Private&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ProjectReference&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;ProjectReference&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Include=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;..\FSharpPlus.1\FSharpPlus.1.fsproj&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note the reference to both the project that references F#+ 1 and a reference to F#+ currently being built (project reference).&lt;/p&gt;

&lt;p&gt;This will allow us to see binary incompatibilities between v1.0.0 and the current version.&lt;/p&gt;

&lt;p&gt;In order to read up on why this works you can read &lt;a href=&quot;https://learn.microsoft.com/en-us/nuget/concepts/dependency-resolution&quot;&gt;NuGet package resolution&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;binary-compatibility-with-statically-resolved-type-parameters-srtp&quot;&gt;Binary compatibility with Statically Resolved Type Parameters (SRTP)&lt;/h2&gt;

&lt;p&gt;Since there is a lot of &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters&quot;&gt;Statically Resolved Type Parameters (SRTP)&lt;/a&gt;, the compiled version of F#+ will actually be binary compatible due to usage of SRTP being erased after compilation.&lt;/p&gt;

&lt;p&gt;Since a lot of the API’s are not used directly by the user, but gets referenced by the compiled code we can declare overloads that are not used (by SRTP) in later minor versions of F#+.&lt;/p&gt;

&lt;p&gt;This means that we can have methods as seen here:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-f#&quot;&gt;type MapIndexed =
    // ...
    // Begin compat members
    // ...
    static member MapIndexed (x: &apos;T []      , f            , [&amp;lt;Optional&amp;gt;]_impl: MapIndexed) = Array.mapi f x
    // ...
    // End compat members
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;but that the new versions have the following signature:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-f#&quot;&gt;    // ...
    static member MapIndexed ((x: &apos;T []      , f            ), [&amp;lt;Optional&amp;gt;]_impl: MapIndexed) = Array.mapi f x
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the extra parenthesis. The compatibility members are referenced by the v1 version, while an updated version with overload fixes uses the lower form. Since user code will reference select the correct overload through SRTP, the compiled code just need to have one of the above.&lt;/p&gt;

&lt;p&gt;Why does it get inlined? It gets inlined due to the fact that we use to select the correct overload is marked with &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/inline-functions&quot;&gt;the keyword inline in F#&lt;/a&gt;. The method that is use to select the correct overload is the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-f#&quot;&gt;    static member inline Invoke (mapping: &apos;K-&amp;gt;&apos;T-&amp;gt;&apos;U) (source: &apos;``Indexable&amp;lt;&apos;T&amp;gt;``) =
        let inline call_2 (a: ^a, b: ^b, f) = ((^a or ^b) : (static member MapIndexed : (_*_)*_ -&amp;gt; _) (b, f), a)
        let inline call (a: &apos;a, b: &apos;b, f) = call_2 (a, b, f)
        call (Unchecked.defaultof&amp;lt;MapIndexed&amp;gt;, source, mapping)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The above code picks either the type &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Indexable&lt;/code&gt; contract from the incoming type or from one of the overloads defined in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MapIndexed&lt;/code&gt; class. In F# you don’t have method overloading for modules. For classes we do have it. The reason why is that F# needs to be compatible with C# parameter overloading for classes.&lt;/p&gt;

&lt;p&gt;This has allowed us to do what normally would mean an incompatible change of the API, but let us keep the compiled binary signature (minus SRTP usage through say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Invoke&lt;/code&gt;).&lt;/p&gt;

&lt;h2 id=&quot;hiding-but-keeping-old-apis&quot;&gt;Hiding but keeping old APIs&lt;/h2&gt;

&lt;p&gt;By adding the attribute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;EditorBrowsable(EditorBrowsableState.Never)&lt;/code&gt; we tell the editor to not show types and methods when using intellisense.&lt;/p&gt;

&lt;p&gt;One of the examples are the v1 Builders module:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-f#&quot;&gt;[&amp;lt;Obsolete(&quot;Compatibility with v1&quot;); EditorBrowsable(EditorBrowsableState.Never)&amp;gt;]
module Builders =
  //..
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Using these facts of F#:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Statically Resolved Type Parameters in F#&lt;/li&gt;
  &lt;li&gt;Inline methods in F#&lt;/li&gt;
  &lt;li&gt;Implementation of C# overloading in F#&lt;/li&gt;
  &lt;li&gt;EditorBrowsable&lt;/li&gt;
  &lt;li&gt;NuGet package resolution&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;we have been able to keep a major version going for way longer than I would have thought possible while still being able to accommodate significant changes.&lt;/p&gt;

&lt;p&gt;This also goes to show that F#+ has been the library that keeps on showing interesting usages of .net that one might not think possible (in .net).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Way of working and method</title>
      <link>https://assertfail.gewalli.se/2022/09/26/Way-of-working-and-method.html</link>
      <pubDate>Mon, 26 Sep 2022 16:24:22 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2022/09/26/Way-of-working-and-method</guid>
      <description>&lt;h2 id=&quot;how-do-we-develop-software&quot;&gt;How do we develop software&lt;/h2&gt;

&lt;p&gt;How do we arrive at working software? Some of the ways I’ve seen are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Use of known working patterns, techniques, language features, libraries: Restrict what everyone does to only the patterns that are known to work. The assumption is also that by using a small subset of tools it is going to be easier for juniors and generally &lt;a href=&quot;https://www.hanselman.com/blog/dark-matter-developers-the-unseen-99&quot;&gt;99% of all programmers&lt;/a&gt; to join.&lt;/li&gt;
  &lt;li&gt;Use logical reasoning based on known properties of written code and the implied effect of changes.&lt;/li&gt;
  &lt;li&gt;Manual testing of business logic by a user or a tester or developer trying to act as a user in order to verify that the solution work.&lt;/li&gt;
  &lt;li&gt;Manual testing with a debugger in order to verify that smaller parts works as intended.&lt;/li&gt;
  &lt;li&gt;Automatic tests: program executes small parts of the program in a somewhat controlled manner to verify that it works as intended (and that no regressions have occurred).&lt;/li&gt;
  &lt;li&gt;Divide and conquer: Split a system into smaller parts in order to make it easier to make the individual parts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not every software shop agrees on how to test software. GUI software is usually dealt with in a different manner compared to server software.&lt;/p&gt;

&lt;h3 id=&quot;restrictions&quot;&gt;Restrictions&lt;/h3&gt;

&lt;p&gt;Developers can be helped in their reasoning by restricting what the code and developers are allowed to do.&lt;/p&gt;

&lt;h4 id=&quot;social-mechanisms&quot;&gt;Social mechanisms&lt;/h4&gt;

&lt;p&gt;Common social methods (that I know of) used to restrict a solution are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Avoiding mutable state : As seen on &lt;a href=&quot;https://learn.microsoft.com/en-us/dotnet/csharp/write-safe-efficient-code&quot;&gt;Microsoft&lt;/a&gt; and &lt;a href=&quot;https://blogs.oracle.com/javamagazine/post/java-immutable-objects-strings-date-time-records&quot;&gt;Oracle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Avoiding hidden side effects (such as through global static variables).&lt;/li&gt;
  &lt;li&gt;Consensus around architecture of a solution&lt;/li&gt;
  &lt;li&gt;Freezing code: avoid any change of parts of the written code. You can employ the pattern for longer than is suggested on the article about &lt;a href=&quot;https://en.wikipedia.org/wiki/Freeze_(software_engineering)&quot;&gt;Freeze on Wikipedia&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Need approval before applying changes. See &lt;a href=&quot;https://en.wikipedia.org/wiki/Distributed_version_control&quot;&gt;Pull requests section on Distributed Version Control&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These methods are not applied in every codebase.&lt;/p&gt;

&lt;h4 id=&quot;mechanical-restrictions&quot;&gt;Mechanical restrictions&lt;/h4&gt;

&lt;p&gt;Common tools to restrict what the code is allowed to do and how it is written are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Statically-typed languages such as C#, Java as opposed to for instance JavaScript. There are &lt;a href=&quot;https://en.wikipedia.org/wiki/Category:Statically_typed_programming_languages&quot;&gt;many such languages&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Static code analysis tools. It is common to use linters for JavaScript and TypeScript, but &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis&quot;&gt;there are others&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Executable tests. For instance &lt;a href=&quot;https://en.wikipedia.org/wiki/Unit_testing&quot;&gt;Unit Testing&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Architectural analysis tools. We have seen the use of specifications as tests in &lt;a href=&quot;https://www.archunit.org&quot;&gt;ArchUnit&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I do mean that not all of these restrictions are applied in every development shop.&lt;/p&gt;

&lt;h3 id=&quot;scientific-method&quot;&gt;Scientific method&lt;/h3&gt;

&lt;p&gt;How does this compare to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Scientific_method&quot;&gt;scientific method&lt;/a&gt;?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Automatic/manual testing is a way to verify behavior of some code given some known state.&lt;/li&gt;
  &lt;li&gt;A known working pattern in programming could perhaps be seen as a hypothesis that has been proven to work for some use cases.&lt;/li&gt;
  &lt;li&gt;The use of logical reasoning seems very much connected to the scientific method.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;existing-code&quot;&gt;Existing code&lt;/h3&gt;

&lt;p&gt;In many cases it takes many years and you have multiple people and involved. The task of keeping software working as intended then also involves knowledge sharing.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;New people (to the software development team) run the software with a debugger and trace logging in order to get an understanding for how the system works or is intended to work. Debugging takes a lot of time, so you would limit yourself to only what you think you need.&lt;/li&gt;
  &lt;li&gt;New people read the written code in order to get an understanding for how the system works. This is a very difficult thing since the amount of code written is usually large enough that people need to develop speed reading skills and be able to summarize huge chunks of text. Different styles and different lingo can make the task even more difficult.&lt;/li&gt;
  &lt;li&gt;Use of written documentation in order to document intended behavior. This is notoriously hard since writing documentation requires writing skills in another language than the programming language. Even if you write documentation in your native language, you might not be a good writer. I could imagine that a good poet or song writer does not automatically become a good novelist. The pressure on delivering can make you ignore some parts (such as the documentation).&lt;/li&gt;
  &lt;li&gt;Use of testing in many ways in order to verify that the system still works after new features have been added. This is sort of like when you add plumbing into an already built house. If you are not careful you might ruin the house while adding the feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What I’m trying to say is that there are many ways that people have been going on writing software.
It is not difficult to arrive at working software that no one can read. I’ve seen it happen due to too much text or written in a language/pattern people are unfamiliar with. Common reasons why that might happen can be:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The person is a junior developer.&lt;/li&gt;
  &lt;li&gt;The code is old. It’s written in a language or in a style no longer in common use.&lt;/li&gt;
  &lt;li&gt;Written in a style from a movement that the person is unfamiliar with.&lt;/li&gt;
  &lt;li&gt;Written in a haphazard way.&lt;/li&gt;
  &lt;li&gt;Wall of text (wall of code). The amount of code/text makes it difficult to grasp.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;literary-methods&quot;&gt;Literary methods&lt;/h4&gt;

&lt;p&gt;This gets us into the question how do you write.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Known language. An example of this is &lt;a href=&quot;https://martinfowler.com/bliki/UbiquitousLanguage.html&quot;&gt;Ubiquitous Language&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Known patterns that help people understand what the program is intended to do.
    &lt;ul&gt;
      &lt;li&gt;map/filter/reduce or select/where/join&lt;/li&gt;
      &lt;li&gt;factory/observable/command et.c. inspired in part by &lt;a href=&quot;https://martinfowler.com/bliki/GangOfFour.html&quot;&gt;Gang of Four&lt;/a&gt;.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Structuring the code in order to be able to be able to find different parts.&lt;/li&gt;
  &lt;li&gt;Strategy around important and less important text.&lt;/li&gt;
  &lt;li&gt;Splitting up the code into smaller chunks that are meaningful on their own.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is mostly my interpretation of written code. I usually try to understand the code and the context it was written in. Many words and patterns make sense if you know the background of the programmers involved.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The point I’m trying to give you is that there are many ways of writing working software. The common parts are related to social methods, formal methods and literary methods.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Unclean architecture</title>
      <link>https://assertfail.gewalli.se/2022/09/22/Unclean-architecture.html</link>
      <pubDate>Thu, 22 Sep 2022 05:08:43 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2022/09/22/Unclean-architecture</guid>
      <description>&lt;p&gt;This post is a continuation of &lt;a href=&quot;https://assertfail.gewalli.se/2022/04/03/small-and-simple-business-applications-using-sql.html&quot;&gt;Small and simple business applications using SQL&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;clean-architecture&quot;&gt;Clean architecture&lt;/h2&gt;

&lt;p&gt;From what I understand of &lt;a href=&quot;https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html&quot;&gt;Clean architecture&lt;/a&gt; it’s an iteration of &lt;a href=&quot;https://en.wikipedia.org/wiki/Hexagonal_architecture_(software)&quot;&gt;Hexagonal architecture&lt;/a&gt; also known as Ports and Adapters (see the Wikipedia page).&lt;/p&gt;

&lt;p&gt;Why would you want architecture? The main purpose is to deliver a working solution to the customer. How do you arrive to that? Architecture is a tool that enables developers to reason about how the system works.&lt;/p&gt;

&lt;h3 id=&quot;sample-code&quot;&gt;Sample code&lt;/h3&gt;

&lt;p&gt;A sample succinct implementation is the
&lt;a href=&quot;https://gist.github.com/akhansari/d4c5a219d22199f151016639e5aa8d8a&quot;&gt;F# : Onion architecture in a nutshell&lt;/a&gt;. You could &lt;a href=&quot;https://gist.github.com/wallymathieu/68b14bcd3e45c4c5b040b60c558a5318#file-onion_1-ts&quot;&gt;translate that into Typescript&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;unclean-architecture&quot;&gt;Unclean architecture&lt;/h2&gt;

&lt;p&gt;It’s nice to have a clean architecture. Though as Uncle Bob says, there is a cost. Some people have argued against these parts. You then arrive at another important architecture pattern that we can call the Unclean/untidy architecture (it’s not totally dirty but not clean as well, I’m unsure if to call it unwashed or unkempt):&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Dependent on some Frameworks&lt;/li&gt;
  &lt;li&gt;Dependent on some Database&lt;/li&gt;
  &lt;li&gt;Dependent on some external agency&lt;/li&gt;
  &lt;li&gt;Somewhat Testable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most important such architecture must be Rails since you write code that is very dependent on framework (Rails), dependent on that there is a SQL-database. As long as you keep it somewhat tidy you can test using sqlite locally and integration test your controllers. You can configure your app to spin up a local db and test against that (even the same type of DB that you use in prod).&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://dhh.dk/2014/test-induced-design-damage.html&quot;&gt;DHH argues&lt;/a&gt; there are too many downsides of using such an architecture.&lt;/p&gt;

&lt;p&gt;As long as you keep your app relatively small, this can be quite OK. For larger solutions, you start feeling the pain. Your milage may vary.&lt;/p&gt;

&lt;p&gt;Another way of writing unclean applications is to use a &lt;a href=&quot;https://assertfail.gewalli.se/2022/04/03/small-and-simple-business-applications-using-sql.html&quot;&gt;thin API wrapper around SQL&lt;/a&gt;. This style of untidy architecture can work well in some cases.&lt;/p&gt;

&lt;p&gt;An example of small dirty app is to write a small service that does a mix of external and internal calls in order to have an app that can be in something like a smallish program wrapped by a docker container. The idea is that having an explicit dependency on one specific DB and no safety net does not matter as long as it’s easy enough to recreate a development experience using containers.&lt;/p&gt;

&lt;h3 id=&quot;accepting-grime-or-dust&quot;&gt;Accepting grime or dust&lt;/h3&gt;

&lt;p&gt;When is it a good idea? Even Uncle Bob says that:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;There are some frameworks that you simply must marry.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Martin, Robert C. . Clean Architecture (Robert C. Martin Series) (p. 295). Pearson Education. Kindle Edition.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Do you consider Rails, EF core as frameworks you wed? As long as the app is still testable with an in memory db using EF core, can it still be considered clean (as long as it follows the other parts)?&lt;/p&gt;

&lt;p&gt;What does it mean to have a totally clean architecture? Is the concept of clean architecture easier to communicate than:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;in order to test you need to have a very custom SQL database up and running (something like backup and restore of an existing DB)&lt;/li&gt;
  &lt;li&gt;in order to compile the code you need to have several libraries installed on your machine (globally installed) and installed in a very specific order&lt;/li&gt;
  &lt;li&gt;in order to run the code you need to have specific versions of a couple of programs installed in specific locations&lt;/li&gt;
  &lt;li&gt;any triggering of payments, causes real invoices to be sent to real business and inventory to be updated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I think such a solution is harder (in some sense) to work on.&lt;/p&gt;

&lt;p&gt;The main benefit of using a dependency directly trickles down to the advantage we get from being able to swap out the dependency (in tests and business code). If a dependency has a complicated contract hard to capture using a simple fake. An example is when the behavior of &lt;a href=&quot;https://en.wikipedia.org/wiki/Object–relational_mapping&quot;&gt;ORM&lt;/a&gt; creates an implicit dependency on using the real thing to verify your business logic. It’s sort of like a &lt;a href=&quot;https://sv.wikipedia.org/wiki/Samboförhållande&quot;&gt;cohabitation relationship&lt;/a&gt;. You are not married, but the practical difference might be minor.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Clean code/architecture probably suffer from what Eric Normand denotes &lt;a href=&quot;https://ericnormand.me/podcast/the-christopher-alexander-effect&quot;&gt;The Christopher Alexander Effect&lt;/a&gt;: that the advice around clean architecture/code is almost obvious to some senior programmers while unhelpful for others.&lt;/p&gt;

&lt;p&gt;In order to know when it’s a good thing to accept an Unclean architecture, you want to have some ideas about what a Clean architecture is. I’m thinking &lt;a href=&quot;https://en.wiktionary.org/wiki/poetic_licence&quot;&gt;poetic license&lt;/a&gt; may apply for architecture as well. The main benefit of a somewhat unclean architecture is the reduced amount of code and ceremony (sometimes a very difficult choice to make).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Small and simple business applications using SQL</title>
      <link>https://assertfail.gewalli.se/2022/04/03/small-and-simple-business-applications-using-sql.html</link>
      <pubDate>Sun, 03 Apr 2022 08:42:31 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2022/04/03/small-and-simple-business-applications-using-sql</guid>
      <description>&lt;p&gt;Say that you want to write a minimal API as seen in &lt;a href=&quot;/2021/11/10/Can-net-compete-with-nodejs.html&quot;&gt;Can .net compete with NodeJS&lt;/a&gt;. How would you structure such an application? You would end up with something like 0-1 layers in your application.&lt;/p&gt;

&lt;p&gt;Some of my previous coworkers embrace these patterns in order to focus on business value. In this post I’ll try to get into how you could make such a system without going into detail (pointing instead to examples).&lt;/p&gt;

&lt;h2 id=&quot;embrace-sql&quot;&gt;Embrace SQL&lt;/h2&gt;

&lt;p&gt;One way to write simple API’s is to embrace SQL when you feel that it’s appropriate. See for instance &lt;a href=&quot;https://rob.conery.io/2015/02/21/its-time-to-get-over-that-stored-procedure-aversion-you-have/&quot;&gt;It’s Time To Get Over That Stored Procedure Aversion You Have&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have need a low ceremony application that does not need much in the way of server side logic, there is no need to over-engineer the application.&lt;/p&gt;

&lt;p&gt;There is a sample in &lt;a href=&quot;https://github.com/dtao/todo-backend-express&quot;&gt;NodeJs&lt;/a&gt; that is also ported to &lt;a href=&quot;https://github.com/wallymathieu/todo-backend-express&quot;&gt;TypeScript&lt;/a&gt;. Just make sure to &lt;a href=&quot;https://owasp.org/www-community/attacks/SQL_Injection&quot;&gt;keep things parameterized&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;sql-and-document-databases&quot;&gt;SQL and Document databases&lt;/h2&gt;

&lt;p&gt;When you read a big object graph and store the same structure in one go, your application logic can be significantly simplified if you store that structure in one go without having to normalize the structure into a SQL view of the world. You could also view &lt;a href=&quot;https://martendb.io&quot;&gt;PostgreSQL as a DocumentDB&lt;/a&gt;, so there might not need to be a hard divide between the SQL and the DocumentDB view of the world.&lt;/p&gt;

&lt;p&gt;Note for instance the &lt;a href=&quot;https://www.mongodb.com/blog/post/getting-started-with-python-and-mongodb&quot;&gt;tutorial from MongoDB&lt;/a&gt; where the JSON is as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JSON&quot;&gt;{
  &quot;first_name&quot;: &quot;Paul&quot;,
  &quot;surname&quot;:&quot;Miller&quot;,
  &quot;cell&quot;: &quot;447557505611&quot;,
  &quot;city&quot;:&quot;Lenden&quot;,
  &quot;location&quot;: [45.123,47.2321],
  &quot;profession&quot;: [&quot;banking&quot;,&quot;finance&quot;,&quot;trader&quot;],
  &quot;cars&quot;:[
    {
      &quot;model&quot;:&quot;Bentley&quot;,
      &quot;year&quot;: 1973,
      &quot;value&quot;: 100000
    },
    {
      &quot;model&quot;:&quot;Rolls Royce&quot;,
      &quot;year&quot;: 1965,
      &quot;value&quot;: 338080
    }]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A decomposition into SQL could be:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-SQL&quot;&gt;create table customers(
  customer_id int identity(1,1),
  first_name nvarchar(255),
  surname nvarchar(255),
  cell nvarchar(100),
  city nvarchar(50),
  location POINT,
  primary key (customer_id));

create table professions(
  profession_id int identity(1,1),
  description nvarchar(255),
  primary key (profession_id)
);
create table customer_professions(
  profession_id int not null foreign key references professions (profession_id),
  customer_id int not null foreign key references customers(customer_id),
  primary key (customer_id,profession_id),
);

insert into customers (first_name,surname,cell,city,
                       location)
               values (&apos;Paul&apos;,&apos;Miller&apos;,&apos;447557505611&apos;,&apos;Lenden&apos;,
                       POINT(45.123,47.2321));
insert into professions (description) values (&apos;banking&apos;),(&apos;finance&apos;),(&apos;trader&apos;)
insert into customer_professions (profession_id, customer_id)
select p.profession_id, c.customer_id
from professions p where p.description in (&apos;banking&apos;,&apos;finance&apos;,&apos;trader&apos;)
from customer c where c.first_name = &apos;Paul&apos; and surname = &apos;Miller&apos; ... -- assuming only one such customer ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The structured nature of SQL also implies that you would need a bit more code in order to deal with the data.&lt;/p&gt;

&lt;p&gt;Both &lt;a href=&quot;https://rob.conery.io/2020/02/05/postgres-for-those-who-cant-even-part-2-working-with-node-and-json/&quot;&gt;Postgresql&lt;/a&gt; and &lt;a href=&quot;https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver15&quot;&gt;Microsoft SQL Server&lt;/a&gt; support the use JSON. You can write views on top of JSON information in order to select the information. For migrating the schema you could take &lt;a href=&quot;https://ayende.com/blog/66563/ravendb-migrations-rolling-updates&quot;&gt;a note from RavenDB&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;testing-it&quot;&gt;Testing it&lt;/h2&gt;

&lt;p&gt;When you write tests for a system that does not shy away from using the database as its core:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Setting up a development DB in a docker container can reduce complexity when setting up a development environment.&lt;/li&gt;
  &lt;li&gt;SQL Migrations makes it easier to keep databases in sync (and will incidentally make it easier to deploy your code).&lt;/li&gt;
  &lt;li&gt;There is an overhead when using a real database for tests. Though that &lt;a href=&quot;https://dhh.dk/2014/slow-database-test-fallacy.html&quot;&gt;overhead can be small&lt;/a&gt;. For systems that span over 200+ tables that overhead should not be underestimated (though such a system should probably be decomposed for &lt;a href=&quot;https://microservices.io/patterns/monolithic.html&quot;&gt;many reasons&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;schema-migrations&quot;&gt;Schema migrations&lt;/h2&gt;

&lt;p&gt;Being more structured when it comes to migrations will (from what I’ve seen) pay off, since it means that you can offload work to computers such as automated deployment, testing and the act of keeping databases in sync.&lt;/p&gt;

&lt;p&gt;Some of the migration frameworks I’ve used (note that all of them allow for raw SQL migrations in some way or another):&lt;/p&gt;

&lt;p&gt;In the .net world:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli&quot;&gt;EF migrations&lt;/a&gt; : These migrations are nice enough if you let the object-model drive your database model.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://fluentmigrator.github.io&quot;&gt;Fluent migrations&lt;/a&gt; : Nice tool that makes it easy to write up and down migrations when you use their API to write simple enough migrations.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dbup.readthedocs.io/en/latest/&quot;&gt;DbUp&lt;/a&gt; : Nice tool when you want to focus on SQL (you write sql-files).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the Ruby world:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://guides.rubyonrails.org/v3.2/migrations.html&quot;&gt;Rails migrations&lt;/a&gt; : Nice migration framework that make it easy write simple reversible migrations when you use their API for simple enough migrations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;abstractions-and-schema&quot;&gt;Abstractions and schema&lt;/h2&gt;

&lt;p&gt;Keeping fewer layers means that there are fewer abstractions that people need to learn. This can help make the development more accessible to newbies. Having 200+ tables does not make for a pleasant experience going into a system. I’ve spent a lot of time at work &lt;a href=&quot;https://github.com/wallymathieu/mejram&quot;&gt;to make sense out of such schemas&lt;/a&gt;. In many SQL implementations you can have multiple schemas in the same database in order to make things easier to understand.&lt;/p&gt;

&lt;h2 id=&quot;the-dreaded-monolith&quot;&gt;The dreaded Monolith&lt;/h2&gt;

&lt;p&gt;In a sense many of the systems that you start to dread start out as small systems. Adding small parts to a system without looking for ways to decompose the system into smaller systems is how you end up with such a mess. There is no need to over-engineer your system until the pain of maintaining the system gets impacted (though note &lt;a href=&quot;https://en.wikipedia.org/wiki/Boiling_frog&quot;&gt;the boiling frog metaphor&lt;/a&gt; when it comes to the gradual increase in technical debt).&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;There are some security implications of embracing SQL, but those can be managed. As long as you keep the system smallish you can have nice enough time for developer written tests. There are as always a challenge around knowing when something has grown too big.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Validation and mediator</title>
      <link>https://assertfail.gewalli.se/2022/03/13/validation-and-mediator.html</link>
      <pubDate>Sun, 13 Mar 2022 11:59:41 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2022/03/13/validation-and-mediator</guid>
      <description>&lt;p&gt;This example is loosely based on how the API looks for aggregates in &lt;a href=&quot;https://docs.axoniq.io/reference-guide/axon-framework/axon-framework-commands/modeling/aggregate&quot;&gt;Axon Framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We also base some of the code around examples of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ValidationBehavior&lt;/code&gt; found online.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/42283011/add-validation-to-a-mediatr-behavior-pipeline&quot;&gt;Stackoverflow&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://code-maze.com/cqrs-mediatr-fluentvalidation/&quot;&gt;CodeMaze&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The reason why I’ve implemented these examples is in order to showcase how you can cut down on some of the ceremony around using a generic mediator interface implementation together with fluent validation logic (pipeline behavior in MediatR parlance).&lt;/p&gt;

&lt;p&gt;Note that I’m not making a value judgement around &lt;a href=&quot;https://cezarypiatek.github.io/post/why-i-dont-use-mediatr-for-cqrs/&quot;&gt;if you should use MediatR or not&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Aspect-oriented_programming#Criticism&quot;&gt;if you should use AOP or not&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h2&gt;

&lt;p&gt;We assume that we want to use some validation API (here we use FluentValidation).&lt;/p&gt;

&lt;p&gt;We assume that the domain have most of the business code in the entities.&lt;/p&gt;

&lt;p&gt;We assume that we want to use MediatR (you could substitute MediatR with a message queue abstraction).&lt;/p&gt;

&lt;p&gt;We assume that we use some sort of unit of work (if we use EF Core that would be DbContext, while it would be session if we use NHibernate).&lt;/p&gt;

&lt;h2 id=&quot;step-1&quot;&gt;STEP 1&lt;/h2&gt;

&lt;p&gt;First step is to create the classes that will implement the MediatR IRequestHandler:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FuncCreateCommandHandler&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;FuncMutateCommandHandler&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You could implement these classes in the following way:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;    class FuncMutateCommandHandler&amp;lt;TEntity, TCommand, TResponse&amp;gt; : IRequestHandler&amp;lt;TCommand, TResponse&amp;gt;
        where TCommand : ICommand&amp;lt;TResponse&amp;gt; where TEntity : IEntity
    {
        private readonly Func&amp;lt;TEntity, TCommand, IServiceProvider, TResponse&amp;gt; _func;
        private readonly IServiceProvider _serviceProvider;

        public FuncMutateCommandHandler(Func&amp;lt;TEntity, TCommand, IServiceProvider, TResponse&amp;gt; func, IServiceProvider serviceProvider)
        {
            _func = func;
            _serviceProvider = serviceProvider;
        }

        public async Task&amp;lt;TResponse&amp;gt; Handle(TCommand cmd, CancellationToken cancellationToken)
        {
            var repository = _serviceProvider.GetRequiredService&amp;lt;IRepository&amp;lt;TEntity&amp;gt;&amp;gt;();
            var keyValueFactory = _serviceProvider.GetRequiredService&amp;lt;IKeyValueFactory&amp;lt;TCommand&amp;gt;&amp;gt;();
            var entity = await repository.FindAsync(keyValueFactory.Key(cmd));

            var r = _func(entity, cmd, _serviceProvider);

            return r;
        }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;See &lt;a href=&quot;https://github.com/wallymathieu/validation-studies/blob/26d8dde728a1fba01edd007f81a349f8717a36da/src/CsMediatR/Infrastructure/CommandHandlers/ApiRegistrationsExtensions/FuncMutateCommandHandler.cs&quot;&gt;FuncMutateCommandHandler&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that the signature of the delegate is:
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Func&amp;lt;TEntity, TCommand, IServiceProvider, TResponse&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The base responsibility for these classes will be to retrieve and store the business entities as well as provide an opportunity to inject validation logic (since we implement a generic interface).&lt;/p&gt;

&lt;p&gt;Since they take a func it’s trivial to create a fluent API in order to register how the entities :&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/wallymathieu/validation-studies/blob/ba74e2cb1128b080282e75071c86720870b617fd/src/CsMediatR/Given_fluent_registration_of_handlers.cs&quot;&gt;Given_fluent_registration_of_handlers&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The setup then becomes the description of how we tie together the business entities (Person).&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;        services.RegisterHandlersFor&amp;lt;Person&amp;gt;()
            .UpdateCommandOnEntity&amp;lt;EditPersonCommand,Person&amp;gt;((entity, cmd, svc) =&amp;gt; entity.Handle(cmd, svc))
            .CreateCommandOnEntity&amp;lt;CreatePersonCommand&amp;gt;(Person.Create)
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;step-2&quot;&gt;STEP 2&lt;/h2&gt;

&lt;p&gt;Since we have the initial classes needed to write automatically created registrations based on attributes we can now create our first such implementation.&lt;/p&gt;

&lt;p&gt;We note that what we need to achieve is to write code that registers the above handlers. Since we want to be efficient we write a Linq Expression that essentially does:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;    new FuncMutateCommandHandler&amp;lt;TEntity,TCommand,TResult&amp;gt;((entity, cmd, svcProvider) =&amp;gt;
        entity.`MethodInfo`(cmd, svcProvider), outerSvdProvider)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This code is not too difficult to write. See &lt;a href=&quot;https://github.com/wallymathieu/validation-studies/blob/master/src/CsMediatR/Infrastructure/CommandHandlers/ApiRegistrationsExtensions.cs#L228-L250&quot;&gt;the implementation&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;resoning-1-2&quot;&gt;Resoning 1-2&lt;/h2&gt;

&lt;p&gt;We have a solution that deals with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IServiceProvider&lt;/code&gt; and a lambda. Since given a service provider we can always get a service, this essentially means that we have the needed building blocks to adjust the solution into taking multiple services.&lt;/p&gt;

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

&lt;p&gt;Since we have the building blocks we need to find places where we have registrations that matches the pattern:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;    [CommandHandler]
    public ... Handle(EditBookingCommand cmd, IAService services, ...) ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In order to find such we can write some simple reflection based code (in the example we scan for instance methods that does not take service provider as a parameter).&lt;/p&gt;

&lt;p&gt;Then the heavy lifting is to write an expression that does:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;    new FuncMutateCommandHandler&amp;lt;TEntity,TCommand, TResult&amp;gt;((entity, cmd, svcProvider) =&amp;gt; entity.`MethodInfo`(cmd,
        svcProvider.GetRequiredService&amp;lt;IAService&amp;gt;()
        ), outersvcProvider)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;See &lt;a href=&quot;https://github.com/wallymathieu/validation-studies/blob/master/src/CsMediatR/Infrastructure/CommandHandlers/ApiRegistrationsExtensions.cs#L177-L211&quot;&gt;the implementation&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I’ve talked to some coworkers that have expressed a feeling that there is too much magic going on with a decomposed solution that uses generic interfaces. This is similar to the criticism around AOP.&lt;/p&gt;

&lt;p&gt;We have around 400 lines of infrastructure glue code to tie the code together. The main difficulty in the implementation is around writing Linq Expressions. The reflection code can be seen as similar to how you would write queries against a database, so might not be so far fetched. The Linq Expression code is somewhat abstract, that might be more difficult to understand.&lt;/p&gt;

&lt;p&gt;If you want to write C# such that you find MediatR useful, then the complexity could be hidden as library or framework code. You cut down on a lot of copy paste and ceremony for implementing command handlers.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Can .net compete with nodejs</title>
      <link>https://assertfail.gewalli.se/2021/11/10/Can-net-compete-with-nodejs.html</link>
      <pubDate>Wed, 10 Nov 2021 06:42:31 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2021/11/10/Can-net-compete-with-nodejs</guid>
      <description>&lt;p&gt;NodeJS applications can be a single file with minimal overhead:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;const express = require(&apos;express&apos;)
const app = express()

app.get(&apos;/&apos;, (req, res) =&amp;gt; { res.send(&apos;Hello World!&apos;) })

app.listen(3000, () =&amp;gt; { })
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;How does this compare to what we have seen in the .net world?&lt;/p&gt;

&lt;h2 id=&quot;for-net-5-c&quot;&gt;For .net 5 C#&lt;/h2&gt;

&lt;h3 id=&quot;helloworldcsproj-1&quot;&gt;HelloWorld.csproj (1)&lt;/h3&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Sdk=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Microsoft.NET.Sdk.Web&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;TargetFramework&amp;gt;&lt;/span&gt;net5.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/TargetFramework&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;programcs-1&quot;&gt;Program.cs (1)&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace HelloWorld
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =&amp;gt;
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =&amp;gt;
                {
                    webBuilder.UseStartup&amp;lt;Startup&amp;gt;();
                });
    }
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)
        {
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }
            app.Map(&quot;&quot;, b =&amp;gt; b.Run(async context =&amp;gt; await context.Response.WriteAsync(&quot;Hello world&quot;)));
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;the amount of ceremony has been reduced significantly compared to &lt;a href=&quot;https://docs.microsoft.com/en-us/aspnet/web-forms/&quot;&gt;asp.net 4&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;net-5-f&quot;&gt;.net 5 F#&lt;/h2&gt;

&lt;p&gt;In the F# space we have seen such libraries as &lt;a href=&quot;https://suave.io/&quot;&gt;Suave&lt;/a&gt;, where you can write an fsx file containing:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;#r &quot;nuget: Suave, 2.6.1&quot;
open Suave

startWebServer defaultConfig (Successful.OK &quot;Hello World!&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note the relatively recent NuGet integration into the F# language that makes for a great scripting experience.&lt;/p&gt;

&lt;p&gt;In &lt;a href=&quot;https://giraffe.wiki/&quot;&gt;Giraffe&lt;/a&gt; there has been a larger fluent configuration due to the  fact that it is implemented using asp.net core as the host.&lt;/p&gt;

&lt;h2 id=&quot;towards-minimal-apis&quot;&gt;Towards minimal APIs&lt;/h2&gt;

&lt;p&gt;For C# the overhead of writing a minimal HTTP API would even more ceremony compared to F#. Perhaps due to the fact that there is competition in a wider world we see initiatives such as &lt;a href=&quot;https://github.com/featherhttp/framework&quot;&gt;Feather HTTP&lt;/a&gt; where you have:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

var app = WebApplication.Create(args);

app.MapGet(&quot;/&quot;, async http =&amp;gt;
{
    await http.Response.WriteAsync(&quot;Hello World&quot;);
});

await app.RunAsync();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This style of application has been adopted into .net 6 where you then can have the following&lt;/p&gt;

&lt;h3 id=&quot;helloworldcsproj-2&quot;&gt;HelloWorld.csproj (2)&lt;/h3&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Project&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Sdk=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Microsoft.NET.Sdk.Web&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;PropertyGroup&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;TargetFramework&amp;gt;&lt;/span&gt;net6.0&lt;span class=&quot;nt&quot;&gt;&amp;lt;/TargetFramework&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;Nullable&amp;gt;&lt;/span&gt;enable&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Nullable&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;ImplicitUsings&amp;gt;&lt;/span&gt;enable&lt;span class=&quot;nt&quot;&gt;&amp;lt;/ImplicitUsings&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;programcs-2&quot;&gt;Program.cs (2)&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;var app = WebApplication.Create(args);

app.MapGet(&quot;/&quot;, () =&amp;gt; &quot;Hello World&quot;);

app.Run();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These templates have been published on the &lt;a href=&quot;https://minimal-apis.github.io/&quot;&gt;minimal api marketing page&lt;/a&gt;. Some of these improvements can also imply improvements for Giraffe.&lt;/p&gt;

&lt;h2 id=&quot;startup-performance&quot;&gt;Startup performance&lt;/h2&gt;

&lt;p&gt;Building and starting a minimal .net API in C# takes a few seconds (around 4 seconds for .net 6 and around 7 seconds for .net 5 on my machine) while starting a minimal nodejs API on Windows takes at most 1 second. These numbers should be taken with a grain of salt. Once you have thousands of lines of TypeScript the performance to parse these can impose a significant overhead.&lt;/p&gt;

&lt;p&gt;F# has the REPL going for it so you might not have the same need for startup performance. &lt;a href=&quot;https://devblogs.microsoft.com/dotnet/introducing-net-hot-reload/&quot;&gt;Hot reload&lt;/a&gt; takes only a few seconds (maybe 2 seconds on my machine) why that makes for a nicer experience.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;In a way the development experience when writing small web services has gotten significantly more along the lines of JavaScript. The experience is naturally different, but you can write code more in the same way.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Monorepo versus Polyrepo</title>
      <link>https://assertfail.gewalli.se/2021/11/05/Monorepo-versus-Polyrepo.html</link>
      <pubDate>Fri, 05 Nov 2021 18:15:31 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2021/11/05/Monorepo-versus-Polyrepo</guid>
      <description>&lt;p&gt;Let us start by defining monorepo&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Keep multiple projects in a single source control system &lt;a href=&quot;#1&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Acquire as many third-party and in-house dependencies as possible for a build from the same source-control repository/branch, and in the same update/pull/sync operation. &lt;a href=&quot;#2&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Keep all teams in agreement on the versions of third-party and in-house dependencies via lock-step upgrades. &lt;a href=&quot;#2&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;plausible-restrictions&quot;&gt;Plausible restrictions&lt;/h2&gt;

&lt;p&gt;The point about keeping third-party binary dependencies in source control was popular in the .net world before the &lt;a href=&quot;https://www.nuget.org/&quot;&gt;NuGet&lt;/a&gt; and in the Java world before &lt;a href=&quot;https://maven.apache.org/guides/introduction/introduction-to-repositories.html&quot;&gt;Maven Repositories&lt;/a&gt;. We have come to the point where it’s preferable to avoid this practice. Let us assume that only source code and similar sources are stored.&lt;/p&gt;

&lt;h2 id=&quot;language--infrastructure&quot;&gt;Language &amp;amp; infrastructure&lt;/h2&gt;

&lt;p&gt;Languages that do not have good package managers naturally lend themselves to creation of monorepos. The main languages that I’ve used that have this property are C and C++.&lt;/p&gt;

&lt;h2 id=&quot;debugging&quot;&gt;Debugging&lt;/h2&gt;

&lt;p&gt;In order to debug binary packages that you don’t have the source for some languages have support for different debug packages and source references. &lt;a href=&quot;#3&quot;&gt;3&lt;/a&gt; Even if these tools are available they might not work with your organization source control or package repository.&lt;/p&gt;

&lt;p&gt;If you write libraries for business code (spread domain knowledge in package artifacts that get referenced from an internal package repository), then having restrictions on how to debug the code can be a pain for developers.&lt;/p&gt;

&lt;h2 id=&quot;pain-points&quot;&gt;Pain points&lt;/h2&gt;

&lt;p&gt;Matt Klein makes us aware about having tight coupling and performance in &lt;a href=&quot;https://medium.com/@mattklein123/monorepos-please-dont-e9a279be011b&quot;&gt;Monorepos: Please don’t!&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;tight-coupling&quot;&gt;Tight coupling&lt;/h3&gt;

&lt;p&gt;You want to homogenize the use of internal or third party libraries. Is it OK for other teams that you refactor their code when they are busy with say a crunch and want to avoid unnecessary merge conflicts?&lt;/p&gt;

&lt;p&gt;Does changes of internal or third party libraries imply a subtle change in behavior? Even if the code is well tested on its own, usage of the code can break. You might want to have a gradual increase in the usage of a new version of a library.&lt;/p&gt;

&lt;p&gt;One reason why you want to transform multiple repositories to fewer repositories is that you have a &lt;a href=&quot;http://morningcoffee.io/monorepos-monoliths-in-disguise.html&quot;&gt;monolith in disguise&lt;/a&gt;. Multiple services and libraries are changed for one issue in what should be one business subdomain.&lt;/p&gt;

&lt;h3 id=&quot;performance&quot;&gt;Performance&lt;/h3&gt;

&lt;p&gt;For very large repositories we see that organizations use source control systems that allow you to do “sparse checkouts” of only a subset of the repository since the amount of code takes too long to clone.&lt;/p&gt;

&lt;h3 id=&quot;focus&quot;&gt;Focus&lt;/h3&gt;

&lt;p&gt;Clear boundaries that you don’t need to cross can increase focus on a single business subdomain.&lt;/p&gt;

&lt;p&gt;Being able to browse the history for the code of a business subdomain can allow people to know what’s going on (too much noise drowns out the team).&lt;/p&gt;

&lt;h3 id=&quot;ownership&quot;&gt;Ownership&lt;/h3&gt;

&lt;p&gt;Everybody has access to everything. Who reviews what?&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Should you have a single repository for a team? I think it makes sense if the team only works on one product/system and the choice suits the system and the team.&lt;/p&gt;

&lt;p&gt;Probably you want to merge and split out repositories as time goes on. It’s best to keep your options open and make a pragmatic choice for your team. Keeping separate repositories can make it clear that the source is supposed to be separate.&lt;/p&gt;

&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;

&lt;h3 id=&quot;1&quot;&gt;[1]&lt;/h3&gt;

&lt;p&gt;Wikipedia &lt;a href=&quot;https://en.wikipedia.org/wiki/Monorepo&quot;&gt;Monorepo&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;2&quot;&gt;[2]&lt;/h3&gt;

&lt;p&gt;trunk based development &lt;a href=&quot;https://trunkbaseddevelopment.com/monorepos/&quot;&gt;Monorepos&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;3&quot;&gt;[3]&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/sourcelink&quot;&gt;sourcelink&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg&quot;&gt;symbol package&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/dotnet/sourcelink/issues&quot;&gt;sourcelink issues&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Using functional programming to optimize frontend code</title>
      <link>https://assertfail.gewalli.se/2021/06/06/Using-functional-programming-to-optimize-frontend-code.html</link>
      <pubDate>Sun, 06 Jun 2021 09:59:41 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2021/06/06/Using-functional-programming-to-optimize-frontend-code</guid>
      <description>&lt;h2 id=&quot;intro&quot;&gt;Intro&lt;/h2&gt;

&lt;p&gt;During 2019 I started on the current project. At this project I’m working on, we are building a enterprise system for a government customer. When I got in significant parts had been developed of the frontend and backend system. My role when I started in the project was in order to help develop test automation software for the system. Since I’ve worked on both frontend and backend parts in other systems, I’m able to help out in various parts of the system.&lt;/p&gt;

&lt;p&gt;I’m going to talk about one particular issue in the frontend code. When I got into the project, the frontend used mainly &lt;a href=&quot;https://formik.org&quot;&gt;Formik&lt;/a&gt; for forms. There is significant complexity in the frontend code. Some of the forms are quite complicated and have a lot of behavior. While debugging we noticed that the frontend started to slow down significantly for the bigger forms. Since the end users was not affected, we hoped that it would be fine. As new requirements got implemented the slowdown during development started to manifest during end user testing.&lt;/p&gt;

&lt;h2 id=&quot;solutions&quot;&gt;Solutions&lt;/h2&gt;

&lt;p&gt;The question was what to do? The first obvious options are the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Change the design and the requirements and rewrite the existing implementation&lt;/li&gt;
  &lt;li&gt;Find a more performant library that does roughly the same thing and rewrite the existing implementation&lt;/li&gt;
  &lt;li&gt;Optimize Formik&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These options are not very palatable. Changing the design and requirements would require stakeholders to agree on new requirements and a new design. Since there has been a lot of politics involved in getting the current design and requirements approved, changes would require significant amount of time.&lt;/p&gt;

&lt;p&gt;We started evaluating different libraries. Problem with that approach is that it requires a lot of changes in the frontend code in order to evaluate if the other library would improve the performance. This could potentially end up eating a significant amount of trial and error (potentially costing weeks of effort).&lt;/p&gt;

&lt;p&gt;While looking at the Formik code base in order to optimize it, we noticed that there is a lot of historical luggage that shows up in the code making optimizations quite difficult.&lt;/p&gt;

&lt;h2 id=&quot;lazy-re-implementation&quot;&gt;Lazy re-implementation&lt;/h2&gt;

&lt;p&gt;Since there is a lot of luggage in Formik, but we only use selected parts, we realized that given around 20 hours work we could implement a library having the API surface that we use but with better performance. Since we could evaluate different implementation options for the existing code we could do some trial and error (using the existing frontend) without having to do extensive rewrites.&lt;/p&gt;

&lt;p&gt;During the implementation I talked to &lt;a href=&quot;https://github.com/davidwincent&quot;&gt;David Wincent&lt;/a&gt; (another developer in the team) about React performance and different approaches. We evaluated the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/avkonst/hookstate&quot;&gt;Hookstate&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://reactjs.org/docs/hooks-reference.html&quot;&gt;React Hooks&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://redux.js.org&quot;&gt;React Redux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Due to the API surface that we used, it did not look as if it was suitable to use hookstate for the implementation (I had some issues getting the API to work using Hookstate). We like Redux, but we wanted to isolate state to avoid changes causing rerenders in unrelated parts of the application ().&lt;/p&gt;

&lt;p&gt;There is a lot of code that gets executed during render instead of in the reducer in Formik. There was some insights into getting more performant code:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;There are posts such as &lt;a href=&quot;https://kentcdodds.com/blog/how-to-use-react-context-effectively&quot;&gt;Kent C. Dodds blog on how-to use react context effectively&lt;/a&gt; talking about how having dispatch and state in the same React context can post impact performance.&lt;/li&gt;
  &lt;li&gt;Code executing during render impacts the user experience more than if it’s executed in the reducer&lt;/li&gt;
  &lt;li&gt;It is significantly easier to implement an existing API surface compared to writing from scratch&lt;/li&gt;
  &lt;li&gt;Existing unit tests can help speed up development by guiding development effort and lowering chances of regressions&lt;/li&gt;
  &lt;li&gt;The fastest thing to do, is to do nothing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;functional-rewrite&quot;&gt;Functional rewrite&lt;/h2&gt;

&lt;p&gt;Since React is heavily inspired by functional programming, we could apply&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We could apply &lt;a href=&quot;https://blog.sigplan.org/2019/12/30/defunctionalization-everybody-does-it-nobody-talks-about-it/&quot;&gt;defunctionalization&lt;/a&gt;: instead of executing code in the Field array we send messages to be executed in the reducer.&lt;/li&gt;
  &lt;li&gt;Immutable data and lenses: Instead of guarding against developers not following React best practices we could assume in the implementation that the data is immutable and reuse an existing lens implementation in order to get a faster copy updates.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;We could get &lt;a href=&quot;https://github.com/Decerno/formik-reimagined&quot;&gt;a library&lt;/a&gt; that performed significantly better than Formik for our purposes. The time it took was around 25 hours to get to a point where the performance did not impact the end users anymore. Functional programming patterns are useful for more than the sake of correctness.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Dependency injection in FSharp</title>
      <link>https://assertfail.gewalli.se/2020/09/05/Dependency-injection-in-FSharp.html</link>
      <pubDate>Sat, 05 Sep 2020 15:11:06 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2020/09/05/Dependency-injection-in-FSharp</guid>
      <description>&lt;p&gt;One of the questions around how to write F# is how do we compose bigger business applications. In C# you generally use constructor injection.&lt;/p&gt;

&lt;p&gt;Let us start by defining some base functions types and environment that we will use in later code samples:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;open FSharpPlus
open FSharpPlus.Data

type IUserRepository =
    abstract GetUser : email : string -&amp;gt; Async&amp;lt;string&amp;gt;

type IShoppingListRepository =
    abstract Add : shoppingList : string list -&amp;gt; string list
type Env() =
    interface IUserRepository with
        member this.GetUser email =
            async { return &quot;Sandeep&quot;}
    interface IShoppingListRepository with
            member this.Add shoppingList =
                shoppingList
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One example is to use ReaderT in to be able to provide a bag of dependencies as seen &lt;a href=&quot;https://gitter.im/fsprojects/FSharpPlus?at=5eba11635a0bc5394637de8e&quot;&gt;on gitter&lt;/a&gt; and &lt;a href=&quot;https://www.youtube.com/watch?v=pxJCHJgG8ws&amp;amp;ab_channel=F%23Online&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;let getUser email =
    ReaderT(fun (env : #IUserRepository) -&amp;gt; env.GetUser email )

let addShoppingList shoppingList =
    ReaderT(fun (env : #IShoppingListRepository) -&amp;gt; async { return env.Add shoppingList })

let addShoppingListM email = monad {
    let! user = getUser email
    let shoppingList = [&quot;s&quot;]
    return! addShoppingList shoppingList
}

ReaderT.run (addShoppingListM &quot;a@a&quot;)  (Env())
|&amp;gt; fun listA -&amp;gt; async {
    let! list = listA
    printfn &quot;%A&quot; list
} |&amp;gt; Async.Start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There is also a post about using &lt;a href=&quot;https://bartoszsypytkowski.com/dealing-with-complex-dependency-injection-in-f/&quot;&gt;reader monad for dependency injection&lt;/a&gt; but without using more advanced techniques such as monad transformers.&lt;/p&gt;

&lt;p&gt;Another way to decompose your program is to use currying as seen on &lt;a href=&quot;https://fsharpforfunandprofit.com/posts/dependency-injection-1/&quot;&gt;F# for fun and profit&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;let getUser (repo:IUserRepository) email = repo.GetUser email

let addShoppingList (repo : IShoppingListRepository) shoppingList = async { return repo.Add shoppingList }

let addShoppingListM (getUser: string -&amp;gt; Async&amp;lt;string&amp;gt;) (addShoppingList:string list -&amp;gt; Async&amp;lt;string list&amp;gt;) email = monad {
    let! user = getUser email
    let shoppingList = [&quot;s&quot;]
    return! addShoppingList shoppingList
}

let composeAddShoppingListM ()=
    let env = Env()
    let getUser = getUser (env :&amp;gt; IUserRepository)
    let addShoppingList = addShoppingList (env :&amp;gt; IShoppingListRepository)
    addShoppingListM getUser addShoppingList

let addToShoppingListC = composeAddShoppingListM ()
addToShoppingListC &quot;a@a&quot;
|&amp;gt; fun listA -&amp;gt; async {
    let! list = listA
    printfn &quot;%A&quot; list
    } |&amp;gt; Async.Start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the above example we reused the same class &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Env&lt;/code&gt; in order to keep the code shorter. You need to have some glue, why it might not be suitable for a solution where you have a lot of functions with a lot of dependencies.&lt;/p&gt;

&lt;p&gt;Since F# allows for nice OO programming you can use dependency injection via constructor injection:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;type Shopping (userRepository:IUserRepository, shoppingListRepository:IShoppingListRepository)=

    let getUser email = userRepository.GetUser email

    let addShoppingList shoppingList = async { return shoppingListRepository.Add shoppingList }

    member __.AddShoppingListM email = monad {
        let! user = getUser email
        let shoppingList = [&quot;s&quot;]
        return! addShoppingList shoppingList
    }

let env = Env()
let shopping = Shopping (env :&amp;gt; IUserRepository, env :&amp;gt; IShoppingListRepository)

shopping.AddShoppingListM &quot;a@a&quot;
|&amp;gt; fun listA -&amp;gt; async {
    let! list = listA
    printfn &quot;%A&quot; list
} |&amp;gt; Async.Start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I usually write F# with a mix of currying and constructor injection and have not tried out using reader monad for service dependencies. The use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ReaderT&lt;/code&gt; lets you remove the amount of parameters you might otherwise need to pass around. One of the neat things about using a monad transformer is that you can then compose it with your base monad that you otherwise use extensively such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;async&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Implicit versus explicit dependencies</title>
      <link>https://assertfail.gewalli.se/2020/05/28/Implicit-versus-explicit-dependencies.html</link>
      <pubDate>Thu, 28 May 2020 16:30:50 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2020/05/28/Implicit-versus-explicit-dependencies</guid>
      <description>&lt;p&gt;These are musings related to the question what kind of libraries resist the test of time. Some of it is related to issues encountered due to &lt;a href=&quot;https://en.wikipedia.org/wiki/Dependency_hell&quot;&gt;Dependency Hell&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;explicit-dependency&quot;&gt;Explicit dependency&lt;/h2&gt;

&lt;p&gt;Let us start out by asking the question, what is an explicit dependency in your software?&lt;/p&gt;

&lt;p&gt;How should we define a dependency? The easiest way to define a dependency would be there is an explicit package reference to a library. If you can remove the package reference, does the code still work? In order to make it clear, let us define it as a reference to a library and explicit usage of the library API.&lt;/p&gt;

&lt;p&gt;How does such an explicit dependency look in C#:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
...
    public class BusinessDbContext : IdentityDbContext&amp;lt;ApplicationUser&amp;gt;
    {
        public BusinessDbContext(DbContextOptions options) : base(options)
        {
        }

        public DbSet&amp;lt;Customer&amp;gt; Customers { get; set; }
        public DbSet&amp;lt;Order&amp;gt; Orders { get; set; }
        public DbSet&amp;lt;Product&amp;gt; Products { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The businessDbContext class is implemented using EF core. There is an explicit dependency on Entity Framework in this case.&lt;/p&gt;

&lt;h3 id=&quot;value-of-explicit-dependencies&quot;&gt;Value of explicit dependencies&lt;/h3&gt;

&lt;p&gt;The benefit of using a specific implementation is that you can leverage the particulars of that implementation.&lt;/p&gt;

&lt;p&gt;The cost of standardisation is the loss of agility when there is value in being able to change implementations.&lt;/p&gt;

&lt;h2 id=&quot;implicit-dependency&quot;&gt;Implicit dependency&lt;/h2&gt;

&lt;p&gt;In order to look for an example of a implicit dependency of code we could look at how different &lt;a href=&quot;https://en.wikipedia.org/wiki/Object-relational_mapping&quot;&gt;ORM&lt;/a&gt; works when using &lt;a href=&quot;https://en.wikipedia.org/wiki/Plain_old_CLR_object&quot;&gt;POCO&lt;/a&gt; or &lt;a href=&quot;https://en.wikipedia.org/wiki/Plain_old_Java_object&quot;&gt;POJO&lt;/a&gt;. When you use a restricted amount of features from Entity Framework, your code will work with other frameworks.&lt;/p&gt;

&lt;p&gt;Since the behavior of any ORM will necessitate that you follow the patterns and conventions assumed by the framework. For instance if you decide to use strongly typed keys, will these work in another ORM? Does your usage of inheritance work with another ORM? These small things tie subsets of your code implicitly to a specific library or framework.&lt;/p&gt;

&lt;p&gt;Another example of implicit dependency is if you follow the advice of &lt;a href=&quot;https://blog.ploeh.dk/2019/06/17/composition-root-location/&quot;&gt;Mark Seeman on composition root location&lt;/a&gt;, you could have used say one specific dependency injection framework only in your composition root. How could that tie your other code to that then? A specific implementation of a dependency injection framework will have sometimes subtle differences in how things are created when you resolve the code. You might have unintentionally created code that works when initialized in a particular way but will break when you switch to another framework. Microsoft has used &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/system.iserviceprovider&quot;&gt;IServiceProvider&lt;/a&gt; as the least common denominator.&lt;/p&gt;

&lt;p&gt;Hiccups could be:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How are concrete classes resolved, do they need to be explicitly registered?&lt;/li&gt;
  &lt;li&gt;What happens when you send an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;typeof(IEnumerable&amp;lt;T&amp;gt;)&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetService&lt;/code&gt; of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IServiceProvider&lt;/code&gt;? Will the same thing happen for all implementations of IServiceProvider? The &lt;a href=&quot;https://github.com/aspnet/DependencyInjection/blob/af08243a95c61dcd2495066763344b0d59a3aa82/src/DI.Abstractions/ServiceProviderServiceExtensions.cs#L98-L118&quot;&gt;assumption is that it should&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;What happens when you have multiple registrations of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;if we look at the previous implementation of &lt;a href=&quot;https://github.com/aspnet/DependencyInjection/blob/af08243a95c61dcd2495066763344b0d59a3aa82/src/DI.Abstractions/ServiceProviderServiceExtensions.cs#L50-L54&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GetRequiredService&lt;/code&gt;&lt;/a&gt; (an extension of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IServiceProvider&lt;/code&gt;) we note some interesting behavior:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;public static object GetRequiredService(this IServiceProvider provider, Type serviceType)
{
    ...
    var requiredServiceSupportingProvider = provider as ISupportRequiredService;
    if (requiredServiceSupportingProvider != null)
    {
        return requiredServiceSupportingProvider.GetRequiredService(serviceType);
    }

    var service = provider.GetService(serviceType);
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The implication is that different implementations of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IServiceProvider&lt;/code&gt; can have different levels of compatibility with each other.&lt;/p&gt;

&lt;p&gt;If your library can avoid a dependency injection framework and instead present a simple API for consumers of the library, it will make it more resilient against future changes. If your target audience is C# enterprise applications, then Microsoft Extensions Dependency Injection could be currently standard enough. That’s at least a decision that was made for libraries at Carable. This turned out that we needed to upgrade some libraries due to breaking changes between major versions.&lt;/p&gt;

&lt;p&gt;We see similar implications around logging frameworks. Say that you have wrapped the logging in your own API surface in order for your library logging to work. The API surface has grown to incorporate various features needed over the years (keeping it in tandem with the logging infrastructure). Say that the organization behind the logging framework goes bust. How much work is it to adapt what is now a fairly large API surface in order to be able to still use old libraries? Since the interfaces you have defined match the features of the old logging infrastructure, you could have trouble adopting a new logging infrastructure (even though you have your own interfaces).&lt;/p&gt;

&lt;h3 id=&quot;fleeting-standards&quot;&gt;Fleeting standards&lt;/h3&gt;

&lt;p&gt;Any organization will take a look at the libraries they maintain and consider if it’s worth the effort of maintaining them. Microsoft is no exception. While we see Microsoft backing, some of the libraries get a huge boon. Question is what happens in 10-15 years? Will there be a new iteration of software in order to deal with the competition from other ecosystems?&lt;/p&gt;

&lt;p&gt;I’ve seen standardizations on logging for .net come and go. In the early parts of my career Log4Net was good enough and useful enough that it made sense to standardize on that. The latest thing I’ve seen is standardizations on SeriLog and Microsoft Extensions Logging (in various mixtures).&lt;/p&gt;

&lt;p&gt;For instance, for libraries there are a couple of logging alternatives in the .net space:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging&quot;&gt;Microsoft Extensions Logging&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/logary/logary#using-logary-in-a-library&quot;&gt;logary&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/TheAngryByrd/FsLibLog&quot;&gt;FsLibLog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that for C#, there is a defacto standard in the form of Microsoft Extensions Logging. For the transition between major versions 1 and 2 there was some breaking changes. For the current iterations 2 to 3 I’ve not seen any breaking changes (around logging). Instead I’ve seen (for internal libraries at work) that for the iteration 2 to 3 EF Core has been source compatible but binary incompatible. This has meant that we had to keep the internal libraries in lockstep.&lt;/p&gt;

&lt;p&gt;If you want to avoid having to upgrade everything at once and instead want to take it gradually, you probably want to avoid coupling your library to a major version of a common library causing dependency issues.&lt;/p&gt;

&lt;p&gt;That’s why preference when it comes to for example library logging to choose the amount of dependencies you feel that you can handle. If you can get away with something like the following for logging:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;using LogError = Action&amp;lt;string, Exception, object[]&amp;gt;;
using LogDebug = Action&amp;lt;string, object[]&amp;gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You don’t really need to worry too much about different future implementations. The above definition might not be enough for your needs (why a larger abstraction is warranted).&lt;/p&gt;

&lt;h2 id=&quot;leaky-abstractions&quot;&gt;Leaky abstractions&lt;/h2&gt;

&lt;p&gt;Leaky abstractions are somewhat related to implicit dependencies in that the abstractions still cause tight coupling to specific implementations.&lt;/p&gt;

&lt;h3 id=&quot;dangers&quot;&gt;Dangers&lt;/h3&gt;

&lt;p&gt;Having a lowest common interface restricts possibilities. Having defined an interface you might tie your software to a specific implementation implicitly (making you pay for the abstraction without giving you ability to swap out implementation).&lt;/p&gt;

&lt;h3 id=&quot;value&quot;&gt;Value&lt;/h3&gt;

&lt;p&gt;In order to decompose a much larger system into smaller parts in order to let people focus on subsets, having boundaries can be helpful. You might not be able to easily swap out the implementation of a complicated part of your system. Letting people ignore a lot of the implementation details can still provide value even though it might be a leaky abstraction.&lt;/p&gt;

&lt;h2 id=&quot;tldr&quot;&gt;TLDR&lt;/h2&gt;

&lt;p&gt;If you want to hedge your bets (in order to be able to swap out small parts) use small abstractions and small interfaces in order to avoid coupling your code to a specific implementations (when there is a reason for it). Taking as few dependencies as possible is usually the best thing for any library, since it helps making it more resilient against other libraries using different versions of the dependency.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Proxy API requests in development</title>
      <link>https://assertfail.gewalli.se/2020/05/07/Proxy-API-requests-in-development.html</link>
      <pubDate>Thu, 07 May 2020 06:38:36 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2020/05/07/Proxy-API-requests-in-development</guid>
      <description>&lt;h2 id=&quot;the-road-towards-frontend-and-backend-separation&quot;&gt;The road towards frontend and backend separation&lt;/h2&gt;

&lt;p&gt;Or at least why you should care about proxies when dealing with web applications.&lt;/p&gt;

&lt;h3 id=&quot;around-2005&quot;&gt;Around 2005&lt;/h3&gt;

&lt;p&gt;I studied computer science at Lund university. One of the professors warned us about two things: JavaScript and Sharepoint. The web programming I got aquatinted with at university was mainly Java servlets and Python CGI apps.&lt;/p&gt;

&lt;p&gt;I started working at MaCom in Denmark as a system developer. The amount of JavaScript needed could easily fit in a small single file. Most of the application was written in asp.net using aspx and C#. Pages written in aspx is a mix of HTML and C# code and composed as into components called “pages” and “user controls”.&lt;/p&gt;

&lt;p&gt;There was no need for a separation of frontend and backend since most of the code executed on the server.&lt;/p&gt;

&lt;h3 id=&quot;around-2010&quot;&gt;Around 2010&lt;/h3&gt;

&lt;p&gt;At Lundalogik I was part of a team writing a web CRM system. The amount of code in the codebase was around half C# and half JavaScript. In order to structure the code we had a large amount of JavaScript files. The server parts was developed in tandem with the client-side parts. As we expanded the team we got a frontend specialist that wanted to focus on JavaScript only. From that persons point of view it was a hassle to be forced to use Visual Studio to edit the frontend code.&lt;/p&gt;

&lt;p&gt;If you instead work on a Windows machine you can use IIS as a proxy. Hanselman has a &lt;a href=&quot;https://www.hanselman.com/blog/ASPNETMVCAndTheNewIIS7RewriteModule.aspx&quot;&gt;nice introduction&lt;/a&gt;. When in a Windows shop you usually go with IIS for webserver and proxy needs. Since there wasn’t any need for any proxy-configuration we used IIS only to rewrite urls.&lt;/p&gt;

&lt;p&gt;Around this time it became clear that it’s impossible to avoid JavaScript (in some form or another). At the same time browser standardization and library adapters made JS more palatable.&lt;/p&gt;

&lt;h3 id=&quot;around-2017&quot;&gt;Around 2017&lt;/h3&gt;

&lt;p&gt;At the startup Boolean &amp;amp; Brace we worked in two teams, backend and frontend. The codebase was split up into backend and frontend. The structure of the frontend was completely separated from the backend. The frontend code was structured into React components where some have routes and some components are used from other components. This mimics more the experience of developing desktop applications and was the goal of aspx (before JavaScript had matured).&lt;/p&gt;

&lt;p&gt;Most of the front-end developers used an Azure hosted test environment. For local dev environment we used NGINX proxy to different services.&lt;/p&gt;

&lt;p&gt;The following nginx configuration illustrates a setup where you bind frontend and backend services to port 8080 on the local machine:&lt;/p&gt;

&lt;div class=&quot;language-config highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;upstream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;api&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;service&lt;/span&gt; {
  &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;	&lt;span class=&quot;m&quot;&gt;127&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;5000&lt;/span&gt;;
}
&lt;span class=&quot;n&quot;&gt;upstream&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;service&lt;/span&gt; {
  &lt;span class=&quot;n&quot;&gt;server&lt;/span&gt;	&lt;span class=&quot;m&quot;&gt;127&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;.&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;:&lt;span class=&quot;m&quot;&gt;3000&lt;/span&gt;;
}

&lt;span class=&quot;n&quot;&gt;server&lt;/span&gt; {
  &lt;span class=&quot;n&quot;&gt;listen&lt;/span&gt;       &lt;span class=&quot;m&quot;&gt;8080&lt;/span&gt;;
  &lt;span class=&quot;n&quot;&gt;server_name&lt;/span&gt;  &lt;span class=&quot;n&quot;&gt;localhost&lt;/span&gt;;


  &lt;span class=&quot;n&quot;&gt;location&lt;/span&gt; / {
    &lt;span class=&quot;n&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;://&lt;span class=&quot;n&quot;&gt;frontend&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;service&lt;/span&gt;;
    &lt;span class=&quot;n&quot;&gt;proxy_redirect&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;off&lt;/span&gt;;
  }

  &lt;span class=&quot;n&quot;&gt;location&lt;/span&gt; /&lt;span class=&quot;n&quot;&gt;api&lt;/span&gt; {

    &lt;span class=&quot;n&quot;&gt;rewrite&lt;/span&gt; ^/&lt;span class=&quot;n&quot;&gt;api&lt;/span&gt;/?(.*) /$&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;break&lt;/span&gt;;

    &lt;span class=&quot;n&quot;&gt;proxy_pass&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;://&lt;span class=&quot;n&quot;&gt;api&lt;/span&gt;-&lt;span class=&quot;n&quot;&gt;service&lt;/span&gt;;
    &lt;span class=&quot;n&quot;&gt;proxy_redirect&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;off&lt;/span&gt;;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can avoid having NGINX installed by using &lt;a href=&quot;https://docs.docker.com/compose/compose-file/&quot;&gt;docker-compose.yml&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;nginx&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;nginx&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;./nginx.conf:/etc/nginx/nginx.conf:ro&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;8080:8080&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Our setup was for the front-end developers to use CORS to be able to develop against remotely hosted API. The main benefit was that they didn’t need to setup services or nginx locally.&lt;/p&gt;

&lt;h3 id=&quot;around-2019&quot;&gt;Around 2019&lt;/h3&gt;

&lt;p&gt;At Decerno I’m again working with teams dealing with React frontend applications. The new thing I’ve seen so far has been the use of an integrated proxy in the frontend code to &lt;a href=&quot;https://create-react-app.dev/docs/proxying-api-requests-in-development/&quot;&gt;proxy API requests in development&lt;/a&gt;. This means that as a frontend developer you only need to install browser, NodeJS and an editor. The nice thing about this setup is that you also get rid of the CORS-requests you otherwise get if you have frontend and backend hosted separately.&lt;/p&gt;

&lt;h2 id=&quot;how-has-it-been-useful&quot;&gt;How has it been useful&lt;/h2&gt;

&lt;p&gt;In most of the recent projects (since 2017) I’ve worked in there isn’t a mix of frontend and backend. Some of the people work as frontend specialists and are more effective when they can work in a known environment (operating system, editor, et.c.). By having a remote hosted test service you can let frontend specialists focus on client-side work. There is a lot of complexity in modern frontend development when writing JavaScript applications with modern styling making it difficult to be master of all. As can be seen you are not forced to adopt one technology to use the concept if you want your pure frontend developers to be happy.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Estimated language popularity in Sweden among companies</title>
      <link>https://assertfail.gewalli.se/2020/02/02/Language-popularity-in-Sweden.html</link>
      <pubDate>Sun, 02 Feb 2020 16:28:01 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2020/02/02/Language-popularity-in-Sweden</guid>
      <description>&lt;h3 id=&quot;raw-numbers&quot;&gt;Raw numbers&lt;/h3&gt;

&lt;p&gt;I’ve written a simple project in F# to read public information from the job agency in Sweden:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Number of listings&lt;/th&gt;
      &lt;th&gt;Language&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;6964&lt;/td&gt;
      &lt;td&gt;java&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;6085&lt;/td&gt;
      &lt;td&gt;JavaScript&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5727&lt;/td&gt;
      &lt;td&gt;C#&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3929&lt;/td&gt;
      &lt;td&gt;python&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3359&lt;/td&gt;
      &lt;td&gt;c++&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2600&lt;/td&gt;
      &lt;td&gt;c&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1360&lt;/td&gt;
      &lt;td&gt;php&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1230&lt;/td&gt;
      &lt;td&gt;golang&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1151&lt;/td&gt;
      &lt;td&gt;TypeScript&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;589&lt;/td&gt;
      &lt;td&gt;matlab&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;442&lt;/td&gt;
      &lt;td&gt;bash&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;420&lt;/td&gt;
      &lt;td&gt;kotlin&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;381&lt;/td&gt;
      &lt;td&gt;r&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;344&lt;/td&gt;
      &lt;td&gt;scala&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;332&lt;/td&gt;
      &lt;td&gt;perl&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;318&lt;/td&gt;
      &lt;td&gt;ruby&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;220&lt;/td&gt;
      &lt;td&gt;ada&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;157&lt;/td&gt;
      &lt;td&gt;erlang&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;118&lt;/td&gt;
      &lt;td&gt;groovy&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;78&lt;/td&gt;
      &lt;td&gt;rust&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;71&lt;/td&gt;
      &lt;td&gt;cobol&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;63&lt;/td&gt;
      &lt;td&gt;tcl&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;61&lt;/td&gt;
      &lt;td&gt;F#&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;49&lt;/td&gt;
      &lt;td&gt;ecmascript&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;48&lt;/td&gt;
      &lt;td&gt;scheme&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;47&lt;/td&gt;
      &lt;td&gt;elixir&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;44&lt;/td&gt;
      &lt;td&gt;haskell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;39&lt;/td&gt;
      &lt;td&gt;clojure&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;the numbers should be read as there has been 6960 unique listings for Java. This does not tell you if its a republished job advertisement. Most companies do not publish source code, why keyword search on job ads offer a way to give an estimate of demand.&lt;/p&gt;

&lt;h3 id=&quot;method&quot;&gt;Method&lt;/h3&gt;

&lt;p&gt;I’ve filtered out some languages since my guess is that without further analysis they are overrepresented due to the fact that they share their name with common words. Such a language is for instance “swift” and “go”. In order to give an estimation of the popularity of golang, I’ve done a crude match of the context that the word Go shows up in. My guess have been that some constructs such as:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;“språket Go”&lt;/li&gt;
  &lt;li&gt;“Go lang”&lt;/li&gt;
  &lt;li&gt;“Go and “&lt;/li&gt;
  &lt;li&gt;” in Go “&lt;/li&gt;
  &lt;li&gt;”, Go,”&lt;/li&gt;
  &lt;li&gt;”, Go.”&lt;/li&gt;
  &lt;li&gt;” on Go “&lt;/li&gt;
  &lt;li&gt;” i Go “&lt;/li&gt;
  &lt;li&gt;”, Go or”&lt;/li&gt;
  &lt;li&gt;” som Go,”&lt;/li&gt;
  &lt;li&gt;“• Go”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;indicate a mention of the language Go. We can estimate how popular Go is.&lt;/p&gt;

&lt;p&gt;I’ve done some adjustments for C# since there are a some aliases such as “csharp” or “c #”.&lt;/p&gt;

&lt;p&gt;You can find the source code for the analysis on &lt;a href=&quot;https://github.com/wallymathieu/arbetsformedlingen&quot;&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Most of the analysis is keyword matching in text corpus.&lt;/p&gt;

&lt;h3 id=&quot;high-level-analysis&quot;&gt;High level analysis&lt;/h3&gt;

&lt;p&gt;Most of the top languages are not surprising. The language that surprised me was Python, since it is considered niche in the subset of companies that I’ve worked in.&lt;/p&gt;

&lt;p&gt;In the mainstream category of languages we see that Java, JavaScript and C# dominate. This should not be surprising since these are used to write business applications and web applications.&lt;/p&gt;

&lt;p&gt;Python is roughly 1/2 as popular as Java or around 2/3 of C#. Python is used for such things as web programming, data analysis and machine learning.&lt;/p&gt;

&lt;p&gt;C++ is roughly 1/2 as popular as Java as well. I’ve heard from people working in the financial industry using C++. I’ve also heard that some games are written in C++ (besides such examples as &lt;a href=&quot;https://github.com/id-Software/DOOM-3-BFG&quot;&gt;Doom 3&lt;/a&gt;). C and C++ are used for embedded application development.&lt;/p&gt;

&lt;p&gt;One of the interesting things found in this list is that PHP seems to be still somewhat prevalent on the market but waning if you compare to for instance Python.&lt;/p&gt;

&lt;p&gt;Typescript is used more widely than I would have assumed. At work we use Typescript in order to make Javascript programming easier when dealing with larger code bases. I’ve seen some confusion around what is runtime types and compile time types when it comes to Typescript programmers. Though Javascript seems to confuse programmers in many different ways. My personal opinion is that you should combine Javascript with heavy use of linters.&lt;/p&gt;

&lt;p&gt;Golang seems to have risen sharply in the Swedish marketplace. Talking with a programmer focused on embedded development, I’ve heard that it’s a nice language for junior embedded developers. Since Golang is very similar to other C style languages it’s probably not hard introduce developers to the language.&lt;/p&gt;

&lt;h3 id=&quot;mainstream-languages&quot;&gt;Mainstream languages&lt;/h3&gt;

&lt;p&gt;If we look at the broad categories of mainstream languages we have a main category that seems popular: C style languages:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;C&lt;/li&gt;
  &lt;li&gt;C++&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Java_(programming_language)#History&quot;&gt;Java&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/JavaScript#Beginnings_at_Netscape&quot;&gt;JavaScript&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/C_Sharp_(programming_language)#History&quot;&gt;C#&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The reason for this seems to be more align with C being popular, then C style syntax being adopted due to that fact.&lt;/p&gt;

&lt;p&gt;Python is the odd duck in this context as it’s not C style. There is some research that suggests that &lt;a href=&quot;https://quorumlanguage.com/evidence.html&quot;&gt;it is better for novices&lt;/a&gt; than C style syntax.&lt;/p&gt;

&lt;h3 id=&quot;niche-languages&quot;&gt;Niche languages&lt;/h3&gt;

&lt;p&gt;Some interesting groups of languages are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Lisp_(programming_language)&quot;&gt;Lisps&lt;/a&gt; such as Scheme and Clojure&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/ML_(programming_language)&quot;&gt;ML style languages&lt;/a&gt; such as Haskell, F# and OCaml&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Logic_programming&quot;&gt;Logic programming&lt;/a&gt; such as Prolog and MiniKanren.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Perhaps we will see some languages such as Rust and ReasonML, where you have some ML style type-system features together with C style syntax, gain popularity? Java was heavily marketed and has huge market adoption. C# has a strong corporate sponsor. My guess is that neither of these languages will be usurped in the medium term (5-10 years). Mozilla and Facebook have not marketed Rust or ReasonML heavily in order to further widespread adoption.&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;New programmers looking for entry level jobs will probably find ample opportunities in mainstream languages such as Java/C#, Javascript and Python. Knowing C style languages seems to be a sure bet short term and long term.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Validations in F# and C#</title>
      <link>https://assertfail.gewalli.se/2020/01/28/Validations-in-fsharp-and-csharp.html</link>
      <pubDate>Tue, 28 Jan 2020 07:21:31 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2020/01/28/Validations-in-fsharp-and-csharp</guid>
      <description>&lt;p&gt;In order to give a nicer developer experience composing validation messages there are broad categories of libraries that either work well in a Java/C# style setting or work well when composing functions.&lt;/p&gt;

&lt;h2 id=&quot;attribute-based-validation-libraries&quot;&gt;Attribute based validation libraries&lt;/h2&gt;

&lt;p&gt;The default style that can be seen in many java and C# projects is the attribute based validation approach.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;public class Person
{
  [MinLength(1,ErrorMessage =&quot;NameBetween1And50&quot;), MaxLength(50,ErrorMessage =&quot;NameBetween1And50&quot;)]
  public string Name{get;set;}
  [EmailAddress(ErrorMessage =&quot;EmailMustContainAtChar&quot;)]
  public string Email{get;set;}
  [Range(0,120,ErrorMessage = &quot;AgeBetween0and120&quot;)]
  public int Age {get;set;}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;it offers some nice advantages. Many frameworks integrate with these style of validations. You are somewhat limited in how you can apply validations, but it can be good enough.&lt;/p&gt;

&lt;p&gt;In F# it looks the following way:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;type Person = {
  [&amp;lt;MinLength(1,ErrorMessage =&quot;NameBetween1And50&quot;); MaxLength(50,ErrorMessage =&quot;NameBetween1And50&quot;)&amp;gt;]Name : string
  [&amp;lt;EmailAddress(ErrorMessage =&quot;EmailMustContainAtChar&quot;)&amp;gt;]Email : string
  [&amp;lt;Range(0,120,ErrorMessage = &quot;AgeBetween0and120&quot;)&amp;gt;]Age : int
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The main downside of this approach is that it is somewhat rudimentary and can require you to write somewhat verbose custom attributes for custom validations.&lt;/p&gt;

&lt;h2 id=&quot;fluent-configuration-based-libraries&quot;&gt;Fluent configuration based libraries&lt;/h2&gt;

&lt;p&gt;We notice that using &lt;a href=&quot;https://github.com/JeremySkinner/FluentValidation&quot;&gt;FluentValidation&lt;/a&gt; we can separate the validation from the type declaration:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;public class PersonValidator : AbstractValidator&amp;lt;Person&amp;gt;
{
  public PersonValidator()
  {
    RuleFor(n =&amp;gt; n.Name)
      .MinimumLength(1).WithErrorCode(&quot;NameBetween1And50&quot;)
      .MaximumLength(50).WithErrorCode(&quot;NameBetween1And50&quot;);
    RuleFor(n =&amp;gt; n.Email).EmailAddress().WithErrorCode(&quot;EmailMustContainAtChar&quot;);
    RuleFor(n =&amp;gt; n.Age).InclusiveBetween(0, 120).WithErrorCode(&quot;AgeBetween0and120&quot;);
    RuleForEach(n =&amp;gt; n.Bookings).SetValidator(new BookingValidator());
  }
}
public class BookingValidator : AbstractValidator&amp;lt;Booking&amp;gt;
{
  public BookingValidator()
  {
    RuleFor(n =&amp;gt; n.Description)
      .MinimumLength(1).WithErrorCode(&quot;DescriptionBetween1And50&quot;)
      .MaximumLength(50).WithErrorCode(&quot;DescriptionBetween1And50&quot;);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In F# this style of validations could look the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;[&amp;lt;AutoOpen&amp;gt;]
module ValidationsMod=
  type IRuleBuilder&amp;lt;&apos;T,&apos;Property&amp;gt; with
    member __.__ = ()
module Person=

  type Person = { name : String
                  email : String
                  age : int }

  type PersonValidator()=
    inherit AbstractValidator&amp;lt;Person&amp;gt;()
    do
      base.RuleFor(fun n -&amp;gt; n.name)
          .MinimumLength(1).WithErrorCode(&quot;NameBetween1And50&quot;)
          .MaximumLength(50).WithErrorCode(&quot;NameBetween1And50&quot;)
          .__
      base.RuleFor(fun n -&amp;gt; n.email)
          .EmailAddress().WithErrorCode(&quot;EmailMustContainAtChar&quot;)
          .__
      base.RuleFor(fun n -&amp;gt; n.age)
          .InclusiveBetween(0,120).WithErrorCode(&quot;AgeBetween0and120&quot;)
          .__
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We add a custom property &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;__&lt;/code&gt; in order to end the fluent chain.&lt;/p&gt;

&lt;p&gt;The fluent validations approach seems like a OK way to express your validations in C#, it’s somewhat less elegant in F#, but looks OK.&lt;/p&gt;

&lt;h2 id=&quot;computation-expression-based-configuration-builders&quot;&gt;Computation Expression based configuration builders&lt;/h2&gt;

&lt;p&gt;The fluent style of building validators is somewhat clunky in F#, why you might want to wrap some of it in computation expression builders as can be seen in &lt;a href=&quot;https://github.com/JamesRandall/AccidentalFish.FSharp.Validation&quot;&gt;AccidentalFish&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;let containsAt (s:string)= s.Contains(&quot;@&quot;)
let validateEmail (property:string) (value:string)=
  if (containsAt value)
  then Ok
  else Errors([{ message=&quot;EmailMustContainAtChar&quot;;errorCode=&quot;EmailMustContainAtChar&quot;; property=property }])
let validatePerson = createValidatorFor&amp;lt;Person&amp;gt;() {
  validate (fun r -&amp;gt; r.age) [
    isGreaterThanOrEqualTo 0
    isLessThanOrEqualTo 120
  ]
  validate (fun r -&amp;gt; r.name) [
    isNotEmpty
    hasMaxLengthOf 128
    hasMinLengthOf 1
  ]
  validate (fun r -&amp;gt; r.email) [validateEmail]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You could also define a CE builder for FluentValidator (though that we leave as an exercise to the reader). We could see the CE approach as an F# specific alternative to using fluent builder pattern.&lt;/p&gt;

&lt;h2 id=&quot;applicative-composition-based-libraries&quot;&gt;Applicative composition based libraries&lt;/h2&gt;

&lt;p&gt;Using applicative composition based libraries such as &lt;a href=&quot;https://github.com/fsprojects/FSharpPlus/&quot;&gt;F#+&lt;/a&gt; you are not limited to the API limitations above. You can have a strict type for validation errors that composes well.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;
type Name = { unName : String }
with static member create s={unName=s}
type Email = { unEmail : String }
with static member create s={unEmail=s}
type Age = { unAge : int }
with static member create i={unAge=i}

type Person = { name : Name
                email : Email
                age : Age }
with static member create name email age={name=name;email=email;age=age }


type Error =
  | NameBetween1And50
  | EmailMustContainAtChar
  | AgeBetween0and120

let mkName s =
  let l = length s
  if (l &amp;gt;= 1 &amp;amp;&amp;amp; l &amp;lt;= 50)
  then Success &amp;lt;| Name.create s
  else Failure  [ NameBetween1And50 ]

let mkEmail s =
  if String.contains &apos;@&apos; s
  then Success &amp;lt;| Email.create s
  else Failure [ EmailMustContainAtChar ]

let mkAge a =
  if (a &amp;gt;= 0 &amp;amp;&amp;amp; a &amp;lt;= 120)
  then Success &amp;lt;| Age.create a
  else Failure [ AgeBetween0and120 ]

let mkPerson pName pEmail pAge =
  Person.create
  &amp;lt;!&amp;gt; mkName pName
  &amp;lt;*&amp;gt; mkEmail pEmail
  &amp;lt;*&amp;gt; mkAge pAge
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The main point comes from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mkPerson&lt;/code&gt; function that composes the different validation functions into a function that either returns &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Success of Person&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Failure of Error list&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The main downside of this approach is that it requires you to accept that you can glue functions together in this way. Since many validation libraries come prepared with some basic validations for strings and numbers, you might also want to define a collection of validation helper functions that suits your needs.&lt;/p&gt;

&lt;p&gt;This approach allows you to strictly define the kind of validation errors that a given part of your code can return. This has some really nice benefits when you want to communicate these to another team.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Validations can be expressed in different ways. There are a few main ways of encoding the validators. For F# we see an additional way of composing functions instead of using builder patterns or gluing attributes to the types that you want to validate. My impression is that it’s not a clear choice unless you add preferences to the mix.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Immutable classes in C#</title>
      <link>https://assertfail.gewalli.se/2020/01/26/Immutable-classes-in-csharp.html</link>
      <pubDate>Sun, 26 Jan 2020 16:42:35 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2020/01/26/Immutable-classes-in-csharp</guid>
      <description>&lt;h2 id=&quot;problems&quot;&gt;Problems&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;How do you create an instance of a given readonly class?&lt;/li&gt;
  &lt;li&gt;How do you get a new instance but with given fields with different values?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;writing-readonly-record-classes-2007&quot;&gt;Writing readonly record classes 2007&lt;/h2&gt;

&lt;p&gt;Around 2007 I wrestled with writing immutable classes in C#. One of the key pain-points was that the constructor parameters for a class representing a database row for a specific table ended up with around 68 parameters.&lt;/p&gt;

&lt;p&gt;Note that we already had code generation of SQL Reader row deserialization based on SQL information tables.&lt;/p&gt;

&lt;p&gt;This was before named parameters. In order to get around these limitations I wrote a small tool that used reflection in order to generate update expressions that could be copied into code (without worrying that a parameter was wrong). Once named parameters showed up, some of the pain went away.&lt;/p&gt;

&lt;p&gt;The main benefit of having immutable classes that could not be modified was that it made the code base easier to reason about. This was a nice feature since the code represented many different aspects of managing, scheduling, teaching and attending schools in Denmark, i.e. there was a lot of code.&lt;/p&gt;

&lt;p&gt;Another benefit is that immutable classes are safe to pass around in a multithreaded application.&lt;/p&gt;

&lt;h2 id=&quot;helper-tools-around-2013&quot;&gt;Helper tools around 2013&lt;/h2&gt;

&lt;p&gt;In order to simplify working with readonly classes I made a library around 2013 named &lt;a href=&quot;https://github.com/wallymathieu/with&quot;&gt;with&lt;/a&gt;. Another approach explored by Andrew Arnott was to create code generator &lt;a href=&quot;https://github.com/AArnott/ImmutableObjectGraph&quot;&gt;Immutable object graph&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You could also implement a t4 template in order to generate code.&lt;/p&gt;

&lt;p&gt;Both of these approaches offered pros and cons. Main con of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;with&lt;/code&gt; was performance (though for I/O bound tasks, it’s not going to be noticeable). The main downside of the code generator was finicky to use.&lt;/p&gt;

&lt;p&gt;Since libraries such as NHibernate supports immutable records, you could benefit from modelling readonly objects.&lt;/p&gt;

&lt;p&gt;It was also fairly obvious that it was much easier to adopt a language that supports these concepts well out of the box (you might not be surprised that the somewhat mainstream language of choice then is F#). T4 templates where restricted to Windows, making some approaches non-portable.&lt;/p&gt;

&lt;h2 id=&quot;there-are-more-options-now-ie-around-2019&quot;&gt;There are more options now (i.e. around 2019)&lt;/h2&gt;

&lt;p&gt;During 2019 I noticed how the implementation of many dependency injection containers where using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;System.Linq.Expression&lt;/code&gt; and compile expression into method. The previous fast implementations of DI containers used IL-emit. IL-emit does not seem to offer the same benefit as it did earlier. Using &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/system.linq.expressions.expression-1.compile?view=netframework-4.8&quot;&gt;expression compile&lt;/a&gt; you can get the performance on par with hand written code.&lt;/p&gt;

&lt;p&gt;Immutable Object Graph is still around and have merged pull requests.&lt;/p&gt;

&lt;p&gt;The new alternative can be found in &lt;a href=&quot;https://github.com/louthy/language-ext&quot;&gt;LanguageExt&lt;/a&gt; CodeGen. The main downside or upside of this collection of libraries is that it is very non idiomatic C#.&lt;/p&gt;

&lt;p&gt;We see that you get immutable objects generated from &lt;a href=&quot;https://github.com/Azure/autorest&quot;&gt;autorest&lt;/a&gt; and &lt;a href=&quot;https://github.com/OpenAPITools/openapi-generator&quot;&gt;OpenAPI generator&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you specify&lt;/p&gt;

&lt;div class=&quot;language-json highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nl&quot;&gt;&quot;readOnly&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Autorest generates a constructor that takes the parameters:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;public partial class TodoItem
{
    /// &amp;lt;summary&amp;gt;
    /// Initializes a new instance of the TodoItem class.
    /// &amp;lt;/summary&amp;gt;
    public TodoItem()
    {
        CustomInit();
    }

    /// &amp;lt;summary&amp;gt;
    /// Initializes a new instance of the TodoItem class.
    /// &amp;lt;/summary&amp;gt;
    public TodoItem(double id, string text)
    {
        Id = id;
        Text = text;
        CustomInit();
    }

    /// &amp;lt;summary&amp;gt;
    /// An initialization method that performs custom operations like setting defaults
    /// &amp;lt;/summary&amp;gt;
    partial void CustomInit();

    /// &amp;lt;summary&amp;gt;
    /// &amp;lt;/summary&amp;gt;
    [JsonProperty(PropertyName = &quot;id&quot;)]
    public double Id { get; private set; }

    /// &amp;lt;summary&amp;gt;
    /// &amp;lt;/summary&amp;gt;
    [JsonProperty(PropertyName = &quot;text&quot;)]
    public string Text { get; private set; }
...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;while openapi-tools generates an empty constructor:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;/// &amp;lt;summary&amp;gt;
/// TodoItem
/// &amp;lt;/summary&amp;gt;
[DataContract]
public partial class TodoItem :  IEquatable&amp;lt;TodoItem&amp;gt;, IValidatableObject
{
    /// &amp;lt;summary&amp;gt;
    /// Initializes a new instance of the &amp;lt;see cref=&quot;TodoItem&quot; /&amp;gt; class.
    /// &amp;lt;/summary&amp;gt;
    [JsonConstructorAttribute]
    public TodoItem()
    {
    }

    /// &amp;lt;summary&amp;gt;
    /// Gets or Sets Id
    /// &amp;lt;/summary&amp;gt;
    [DataMember(Name=&quot;id&quot;, EmitDefaultValue=false)]
    public decimal Id { get; private set; }

    /// &amp;lt;summary&amp;gt;
    /// Gets or Sets Text
    /// &amp;lt;/summary&amp;gt;
    [DataMember(Name=&quot;text&quot;, EmitDefaultValue=false)]
    public string Text { get; private set; }
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We notice that the classes are declared partial.&lt;/p&gt;

&lt;p&gt;This could then be combined with any of the above libraries or a t4 template. These templates now works outside of Windows as well.&lt;/p&gt;

&lt;h2 id=&quot;microservices&quot;&gt;Microservices&lt;/h2&gt;

&lt;p&gt;We have seen a lot of interest around microservices style architectural patterns. Given a smaller size of a service, you have less need for immutable classes.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Writing immutable classes have gotten better support in C# over the years. We see that you now have several options to pick from (without restrictions on operating system or performance).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Working on dotnet core on Mac OS X part 3</title>
      <link>https://assertfail.gewalli.se/2019/12/28/Working-on-dotnet-core-on-Mac-OS-X-part-3.html</link>
      <pubDate>Sat, 28 Dec 2019 17:29:08 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/12/28/Working-on-dotnet-core-on-Mac-OS-X-part-3</guid>
      <description>&lt;p&gt;After writing the &lt;a href=&quot;https://assertfail.gewalli.se/2018/09/05/Working-on-dotnet-core-on-Mac-OS-X-part-2.html&quot;&gt;previous posts&lt;/a&gt; about getting some of the infrastructure working for non Windows systems, I’ve seen better ways of getting it to work. Instead of using a netfx.props file, you can use a &lt;a href=&quot;https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019&quot;&gt;Directory.Build.props&lt;/a&gt; with platform specific configuration as seen &lt;a href=&quot;https://github.com/fsharp/FSharp.Compiler.Service/blob/08daf6d5a0abb62c01a475ea442c2996b0e79335/FSharpBuild.Directory.Build.props#L39-L54&quot;&gt;in for instance FSharp.Compiler.Service&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;Project&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;c&quot;&gt;&amp;lt;!-- mono --&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;PropertyGroup&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(OS)&apos; == &apos;Unix&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;MonoRoot&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(MonoRoot)&apos; == &apos;&apos; and $([MSBuild]::IsOsPlatform(&apos;Linux&apos;))&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;/usr&lt;span class=&quot;nt&quot;&gt;&amp;lt;/MonoRoot&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;MonoRoot&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(MonoRoot)&apos; == &apos;&apos; and $([MSBuild]::IsOsPlatform(&apos;OSX&apos;))&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;/Library/Frameworks/Mono.framework/Versions/Current&lt;span class=&quot;nt&quot;&gt;&amp;lt;/MonoRoot&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;MonoLibFolder&amp;gt;&lt;/span&gt;$(MonoRoot)/lib/mono&lt;span class=&quot;nt&quot;&gt;&amp;lt;/MonoLibFolder&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;MonoPackaging&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;$(TargetFramework.StartsWith(&apos;net4&apos;))&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;true&lt;span class=&quot;nt&quot;&gt;&amp;lt;/MonoPackaging&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net45&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.5-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net451&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.5.1-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net452&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.5.2-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net46&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.6-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net461&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.6.1-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net462&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.6.2-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net47&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.7-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net471&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.7.1-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;FrameworkPathOverride&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;Condition=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&apos;$(TargetFramework)&apos; == &apos;net472&apos;&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;$(MonoLibFolder)/4.7.2-api&lt;span class=&quot;nt&quot;&gt;&amp;lt;/FrameworkPathOverride&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/Project&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Another stumble has been that the nuget version on Ubuntu &lt;a href=&quot;https://stackoverflow.com/a/40209368&quot;&gt;is a bit old&lt;/a&gt;. There are some ways around this, one easy way is to include a NuGet.config with both v2 and v3 feeds:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
 &lt;span class=&quot;nt&quot;&gt;&amp;lt;packageSources&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;c&quot;&gt;&amp;lt;!--To inherit the global NuGet package sources remove the &amp;lt;clear/&amp;gt; line below --&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;clear&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;key=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;nuget&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://api.nuget.org/v3/index.json&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;key=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;nuget v2&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://www.nuget.org/api/v2&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
 &lt;span class=&quot;nt&quot;&gt;&amp;lt;/packageSources&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Commands and services</title>
      <link>https://assertfail.gewalli.se/2019/12/28/Commands-and-services.html</link>
      <pubDate>Sat, 28 Dec 2019 09:13:25 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/12/28/Commands-and-services</guid>
      <description>&lt;h2 id=&quot;command-handlers-are-services&quot;&gt;Command handlers are services&lt;/h2&gt;

&lt;p&gt;If we start from the &lt;a href=&quot;https://ayende.com/blog/159969/design-patterns-in-the-test-of-time-command-redux&quot;&gt;command redux post by Ayende&lt;/a&gt;. In actual shopping scenarios we need to deal with not a clear script of actions that can be executed in a sequential manner. Instead we have a unidirectional wizard-style flow where the customer is redirected from the shopping site to payment provider and back. Let us ignore these complexities and look at the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;  var placeOrderCommand = new CompositeCommand(
    new RegisterOrderCommand(),
    new ReserveStockCommand(),
    new ChargeCardCommand(),
    new ShipOrderCommand()
  )
  {
    Sequential = true,
    StopOnError = true
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;we note that the limitations around using simple compositions of &lt;a href=&quot;https://ayende.com/blog/159873/design-patterns-in-the-test-of-time-command&quot;&gt;commands&lt;/a&gt;. The beauty of the command pattern is more obvious when the entire user action can be encapsulated into a class such as a service class in DDD &lt;a href=&quot;http://gorodinski.com/blog/2012/04/14/services-in-domain-driven-design-ddd/&quot;&gt;could also&lt;/a&gt; be called a command handler.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;  public class PlaceOrderService
  {
    private readonly BusinessDbContext _dbcontext;
    ...
    private readonly ProductSettings _productSettings;
    public PlaceOrderService(
      BusinessDbContext dbcontext,
      ...
      IOption&amp;lt;ProductSettings&amp;gt; productSettings)
    {
      _dbcontext = dbcontext;
      ...
      _productSettings = productSettings.Value ?? throw new ArgumentNullException(nameof(productSettings));
    }

    public Task Execute(PlaceOrderCommand command)
    {
      // register order in DB
      _dbContext.RegisteredOrders.Add(new RegisteredOrder{ ... });
      ...

      await _dbcontext.SaveChangesAsync();
      ...
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Reference:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptions-1?view=dotnet-plat-ext-3.1&quot;&gt;IOptions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/ef/core/index&quot;&gt;DbContext&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since dbcontext in asp.net core Entity Framework implements &lt;a href=&quot;https://www.martinfowler.com/eaaCatalog/unitOfWork.html&quot;&gt;unit of work&lt;/a&gt; the command handler uses only one unit of work context. If you use a sql connection you could instead replicate this behavior with a transaction.&lt;/p&gt;

&lt;p&gt;You can then compose your code as following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TD

Http[Controller/Page/Http handler] --&amp;gt; C[Command handler/Service]
C --&amp;gt; Repository
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Read more about command handler in the &lt;a href=&quot;https://github.com/wallymathieu/entity-framework-studies/tree/2583db455d37ff93230b1a181379ca09ac71b101/src/Web/Commands&quot;&gt;following README&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;separation-of-database-and-domain-logic&quot;&gt;Separation of database and domain logic&lt;/h2&gt;

&lt;p&gt;Even though it is &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/ddd-oriented-microservice&quot;&gt;good design to keep your domain logic ignorant of persistence&lt;/a&gt;, dependency on ORM or a specific database concepts can create an implicit dependency on the persistence technology that you choose. In many simple scenarios it doesn’t make sense to isolate persistence completely from the domain model. In Ruby on Rails the choice is to spin up a &lt;a href=&quot;https://dhh.dk/2014/test-induced-design-damage.html&quot;&gt;sqlite database for small application tests&lt;/a&gt;. The same can be done with many modern ORM.&lt;/p&gt;

&lt;p&gt;An alternative approach is to have a database with the same schema available for testing and then either letting the database become “dirty” or put the entire test under a transaction that is rolled back so that the database is kept clean between tests.&lt;/p&gt;

&lt;p&gt;An alternative view is to avoid using an ORM and instead using a simpler mapper in order to put more of the &lt;a href=&quot;https://rob.conery.io/2015/02/23/embracing-sql-in-postgres/&quot;&gt;domain logic in the database&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TD

Http[Controller/Page/Http handler] --&amp;gt; C[Command handler/Service]
C --&amp;gt; SQL
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You could even skip a layer and let the controller talk SQL directly if the service abstraction is not needed. You can still design your database such that stored procedures match what would otherwise be command handlers.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TD

Http[Controller/Page/Http handler] --&amp;gt; S[Stored procedure]
S --&amp;gt; SQL
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The downside is that such a scheme complicates unit testing. If you have simple domain logic that seldom change, you might less need for an extensive test suite.&lt;/p&gt;

&lt;h2 id=&quot;separation-of-bounded-contexts&quot;&gt;Separation of bounded contexts&lt;/h2&gt;

&lt;p&gt;If you want to go further along the line of modular monolith or microservices you want to decompose parts such that:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TD

Http[?] --&amp;gt; D_A[Domain Service in A]
D_A --&amp;gt; R_A[Repository in A]
D_A --&amp;gt; M[Mediator]
M --&amp;gt; D_B[Domain Service in B]
D_B --&amp;gt; R_B[Repository in B]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In the modular monolith scenario A and B are seen as separate parts but are deployed at the same time.&lt;/p&gt;

&lt;p&gt;There is a cost/benefit of introducing loose coupling. Why a nicer approach could be to:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;flowchart TD

Http[?] --&amp;gt; D_A[Domain Service in A]
D_A --&amp;gt; R_A[Repository in A]
D_A --&amp;gt; M[named interface]
M --&amp;gt; D_B[Domain Service in B]
D_B --&amp;gt; R_B[Repository in B]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The cost of having a mediator pattern is that it makes it harder to follow the system logic.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Domain services map well to command handlers. Embracing SQL can be a fruitful approach. You need to evaluate the need for separation or abstraction as you go.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Configure Airport printer on Windows</title>
      <link>https://assertfail.gewalli.se/2019/12/21/Configure-Airport-printer-on-Windows.html</link>
      <pubDate>Sat, 21 Dec 2019 20:01:46 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/12/21/Configure-Airport-printer-on-Windows</guid>
      <description>&lt;p&gt;Setup &lt;a href=&quot;https://support.apple.com/airport&quot;&gt;Apple Airport&lt;/a&gt; printer on Windows.&lt;/p&gt;

&lt;h2 id=&quot;connect-the-printer-using-usb-directly&quot;&gt;Connect the printer using USB directly&lt;/h2&gt;

&lt;p&gt;Windows will auto install the needed drivers.&lt;/p&gt;

&lt;h2 id=&quot;setup-the-printer-as-a-network-printer&quot;&gt;Setup the printer as a network printer&lt;/h2&gt;

&lt;p&gt;Reconenct the printer into the airport. Select could not find printer among the listed then start going down the printer Wizard flow:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-12-21-printer/print_step2.png&quot; alt=&quot;step 1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-12-21-printer/print_step3.png&quot; alt=&quot;step 2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In order to connect to the printer we add the router IP address as the “port”&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-12-21-printer/print_step4.png&quot; alt=&quot;step 3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then select Custom settings:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-12-21-printer/print_step5.png&quot; alt=&quot;step 4&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Note that the default Port Number is correct and continue:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-12-21-printer/print_step6.png&quot; alt=&quot;step 5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Make sure to use the printer driver for the printer that Windows installed after connecting the printer (Windows will install a range of printers, select the one you use):&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-12-21-printer/print_step_6_2.png&quot; alt=&quot;step 6&quot; /&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Using multiple keyboard layouts on Windows 10</title>
      <link>https://assertfail.gewalli.se/2019/11/24/Using-multiple-keyboard-layouts-on-Windows-10.html</link>
      <pubDate>Sun, 24 Nov 2019 15:01:46 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/11/24/Using-multiple-keyboard-layouts-on-Windows-10</guid>
      <description>&lt;h2 id=&quot;why&quot;&gt;Why&lt;/h2&gt;

&lt;p&gt;C style programming languages are designed in the cultural context of having a English keyboard layout. Programming C style languages on a Swedish keyboard layout is somewhat awkward since you need to exercise finger gymnastics in order to use common characters like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;{}\&lt;/code&gt;. Unless you switch to Python the easiest fix is to use multiple keyboard layouts.&lt;/p&gt;

&lt;h2 id=&quot;how&quot;&gt;How&lt;/h2&gt;

&lt;p&gt;I started out by adding English (US) and then Swedish (Sweden) however, I ended up with a long list of keyboard layouts in the keyboard selection that comes up when you press WIN+space. Among those where layouts I couldn’t figure out how they ended up there. A coworker helped me out by telling me that what I wanted is to use the English (UK) language but with US keyboard, since otherwise you will end up with additional UK keyboard layouts.&lt;/p&gt;

&lt;p&gt;What I wanted was this configuration
 &lt;img src=&quot;/img/2019-11-24-Using-multiple-keyboard-layouts-on-Windows-10/preferred-languages.png&quot; alt=&quot;preferred languages&quot; /&gt;&lt;/p&gt;

&lt;p&gt;but for the UK language you add the US keyboard layout that you prefer:
 &lt;img src=&quot;/img/2019-11-24-Using-multiple-keyboard-layouts-on-Windows-10/language-options.png&quot; alt=&quot;language options&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In my case it was the standard US keyboard layout:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-11-24-Using-multiple-keyboard-layouts-on-Windows-10/expected-output.png&quot; alt=&quot;expected output&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;utf-8-issues-in-git-bash&quot;&gt;UTF-8 issues in git-bash&lt;/h2&gt;

&lt;p&gt;A somewhat related issue is that you can have issues around locale in git bash. Following the &lt;a href=&quot;https://stackoverflow.com/questions/10651975/unicode-utf-8-with-git-bash&quot;&gt;instructions on stackoverflow&lt;/a&gt; should suffice.&lt;/p&gt;

&lt;h2 id=&quot;ok-so-now-windows-has-updated-and-ive-got-three-keyboard-layouts&quot;&gt;Ok, so now Windows has updated and I’ve got three keyboard layouts&lt;/h2&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-11-24-Using-multiple-keyboard-layouts-on-Windows-10/extra-keyboard-in-menu.png&quot; alt=&quot;extra keyboard in menu&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Note the extra keyboard layout and locale, could be for instance “English (United Kingdom)”, and add that locale and keyboard in the Language parts of settings.&lt;/p&gt;

&lt;p&gt;Add the extra keyboard so that you end up with the extra keyboard:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2019-11-24-Using-multiple-keyboard-layouts-on-Windows-10/temporary-english-uk-and-us-keyboard.png&quot; alt=&quot;temporary english UK and US keyboards&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Then go ahead and delete that keyboard while making sure that your currently selected keyboard is not that one.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Masstransit</title>
      <link>https://assertfail.gewalli.se/2019/09/02/Masstransit.html</link>
      <pubDate>Mon, 02 Sep 2019 09:09:59 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/09/02/Masstransit</guid>
      <description>&lt;p&gt;&lt;a href=&quot;https://github.com/MassTransit/&quot;&gt;MassTransit&lt;/a&gt; is a wrapper around message queues, such as &lt;a href=&quot;https://www.rabbitmq.com/&quot;&gt;RabbitMQ&lt;/a&gt;,in order to simplify work on distributed applications using .NET.&lt;/p&gt;

&lt;h2 id=&quot;what-is-it-good-for&quot;&gt;What is it good for&lt;/h2&gt;

&lt;p&gt;One common task is to make sure that services react to relevant events. Instead of polling you can tie your system together using async events.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Put entity/article/object in a search engine once it’s published&lt;/li&gt;
  &lt;li&gt;Update information in data warehouse&lt;/li&gt;
  &lt;li&gt;Trigger information requests from external partners&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another usage is to handle long running tasks without the user waiting on them. Say for instance that you fire off an event or a command once an offer is requested. There might be potentially many integrations involved in a business flow, why it then makes sense to return early with a first message to the potential client “We are processing your request”, then you could send email and server side sent event to the user once you have finished processing.&lt;/p&gt;

&lt;p&gt;Having message queue allows you decouple services. If you publish an event, there isn’t a strict need for a specific receiver. This allows you to start work on “basket” service before a “catalog” service is fully finished (then wire up logic to deal with inconsistencies later on).&lt;/p&gt;

&lt;p&gt;MassTransit wraps common message queues and presents you with an uniform API. This is similar to what we have with entity framework for SQL.&lt;/p&gt;

&lt;h2 id=&quot;what-is-it-not-good-for&quot;&gt;What is it not good for&lt;/h2&gt;

&lt;p&gt;RabbitMQ et.c. throws away the messages after they have been successfully processed. If you want to be able replay old events, then this is not for you.&lt;/p&gt;

&lt;p&gt;MassTransit (and similar wrappers) makes assumptions about how you want to deal with failures, what kind of format and how send vs publish works. This can mean that there are some discrepancies when implementing publishers and receivers in other languages than C#. Going towards a more heterogenous environment you will probably need to invest more into getting to know your message queue. In a previous project there was a need to invest in &lt;a href=&quot;https://github.com/carable/MassTransit.js/pulls?q=is%3Apr+is%3Aclosed&quot;&gt;adjusting an AMQP wrapper&lt;/a&gt; for nodejs since the existing wrapper was out of date and did not implement the correct error handling. There is a &lt;a href=&quot;https://github.com/amhest/MassTransit-CrossTown&quot;&gt;Java port&lt;/a&gt; where the author mentions that he only needed a subset of features available from MassTransit in Java.&lt;/p&gt;

&lt;p&gt;If you want to send out events on a very granular high volume, say each time someone views a page on a very popular site, then this is probably not for you. You should look at alternatives like Kafka.&lt;/p&gt;

&lt;h2 id=&quot;problems-with-distributed-transactions&quot;&gt;Problems with distributed transactions&lt;/h2&gt;

&lt;p&gt;Transaction lock on multiple databases is a known costly affair. There are a couple of options of dealing with this. One way is to have a really large database so that the transaction is over a single database. Another way is to use the &lt;a href=&quot;https://microservices.io/patterns/data/saga.html&quot;&gt;saga pattern&lt;/a&gt; to avoid those issues. Note for instance &lt;a href=&quot;https://github.com/MassTransit/TheCoffeeShop/blob/049e022e49da6060dd1d132bf97b1e86171c21c8/src/TheCoffeeShop.Components/StateMachines/OrderStateMachine.cs&quot;&gt;The Coffee Shop OrderStateMachine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another way is to think about data in a slightly different way: For instance by storing events and later on generate the resulting relational view of data at one point in time.&lt;/p&gt;

&lt;h2 id=&quot;setup&quot;&gt;Setup&lt;/h2&gt;

&lt;p&gt;If you are on Azure then Azure Service bus is simple to setup. There are also NuGet packages to use MassTransit with &lt;a href=&quot;https://www.nuget.org/packages/MassTransit.AmazonSQS&quot;&gt;AmazonSQS&lt;/a&gt; and &lt;a href=&quot;https://www.nuget.org/packages/MassTransit.ActiveMQ&quot;&gt;ActiveMQ&lt;/a&gt; but these are more recent than the &lt;a href=&quot;https://www.nuget.org/packages/MassTransit.RabbitMQ&quot;&gt;RabbitMQ&lt;/a&gt; and &lt;a href=&quot;https://www.nuget.org/packages?q=masstransit+azure&quot;&gt;Azure Service bus&lt;/a&gt; packages. Easiest way to start locally is to use RabbitMQ by writing a docker-compose file:&lt;/p&gt;

&lt;div class=&quot;language-yml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;3.4&apos;&lt;/span&gt;

&lt;span class=&quot;na&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;rabbitmq&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;rabbitmq:3-management-alpine&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;15672:15672&quot;&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;5672:5672&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;cost&quot;&gt;Cost&lt;/h2&gt;

&lt;p&gt;Masstransit is open source and free. RabbitMQ requires hosting. See AWS and Azure for pricing of their offerings.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;MassTransit (and similar) allows you to wire up loosely coupled distributed &lt;a href=&quot;https://en.wikipedia.org/wiki/Mediator_pattern&quot;&gt;mediator&lt;/a&gt;. Since MassTransit allows you to use either RabbitMQ, AWS or Azure native message queues it is fairly easy to have it up and running. It is a leaky abstraction when you are going towards a heterogenous environment (but reimplementing subsets of MassTransit can be good enough).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Is there microservices or is it an architectural dream cloud</title>
      <link>https://assertfail.gewalli.se/2019/08/26/Is-there-microservices-or-is-it-an-architectural-dream-cloud.html</link>
      <pubDate>Mon, 26 Aug 2019 10:22:44 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/08/26/Is-there-microservices-or-is-it-an-architectural-dream-cloud</guid>
      <description>&lt;h2 id=&quot;what-is-a-microservice&quot;&gt;What is a microservice&lt;/h2&gt;

&lt;p&gt;There isn’t a clear definition of microservices architecture unless you pick one persons strongly held belief. This can mean that what someone considers microservices, someone else considers to be something else.&lt;/p&gt;

&lt;p&gt;To summarize a few of the available characterizations and definitions:&lt;/p&gt;

&lt;h3 id=&quot;james-levis-and-martin-fowler&quot;&gt;&lt;a href=&quot;https://martinfowler.com/articles/microservices.html&quot;&gt;James Levis and Martin Fowler&lt;/a&gt;&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;organization around business capability&lt;/li&gt;
  &lt;li&gt;automated deployment&lt;/li&gt;
  &lt;li&gt;intelligence in the endpoints, not the transport&lt;/li&gt;
  &lt;li&gt;decentralized control of languages and data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;jimmy-bogard&quot;&gt;&lt;a href=&quot;https://jimmybogard.com/my-microservices-faq/&quot;&gt;Jimmy Bogard&lt;/a&gt;&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;A microservice is a service with a design focus towards the smallest autonomous boundary.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;gartner&quot;&gt;&lt;a href=&quot;https://www.gartner.com/en/documents/3898871/working-with-data-in-a-microservices-architecture&quot;&gt;Gartner&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The characterization is that microservices are&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;tightly scoped&lt;/li&gt;
  &lt;li&gt;loosely coupled&lt;/li&gt;
  &lt;li&gt;control all access to their data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;sam-newman&quot;&gt;&lt;a href=&quot;https://www.oreilly.com/library/view/building-microservices/9781491950340/&quot;&gt;Sam Newman&lt;/a&gt;&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;Microservices are small, autonomous services that work together.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;smartbear&quot;&gt;&lt;a href=&quot;https://smartbear.com/solutions/microservices/&quot;&gt;Smartbear&lt;/a&gt;&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;focus on building single-function modules with well-defined interfaces and operations&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;rachel-reese&quot;&gt;&lt;a href=&quot;https://www.codemag.com/Article/1611071/Case-Study-Writing-Microservices-with-F&quot;&gt;Rachel Reese&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;She mentions that there are the following guidelines around such services:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Being able to rewrite each service in fewer than six weeks&lt;/li&gt;
  &lt;li&gt;Using DDD, wherein there should be one service per bounded context&lt;/li&gt;
  &lt;li&gt;That each microservice has fewer than 300 lines of code&lt;/li&gt;
  &lt;li&gt;That each microservice is a single function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;She then mentions Jet.com’s guidelines:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It’s a short script file with well-defined inputs and outputs.&lt;/li&gt;
  &lt;li&gt;It should be an application of the Single Responsibility Principle, applied at the service level.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;as-seen-on-github&quot;&gt;As seen on github&lt;/h3&gt;

&lt;p&gt;Note for instance some of the styles presented in the these examples:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnContainers&quot;&gt;Microsoft’s eShop on containers&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/GoogleCloudPlatform/microservices-demo&quot;&gt;Google Hipster shop&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;the-future-of-microservices&quot;&gt;The future of microservices&lt;/h2&gt;

&lt;p&gt;We can expect there to be different types of standardization efforts of microservices solutions. The definition of a service and microservice has deep meaning for the type of solution you can realize. Different people will sell their view of what it is and tell you that “you are doing it wrong” in order to sell consulting/tools/hosting et.c..&lt;/p&gt;

&lt;h3 id=&quot;towards-angular-vs-react&quot;&gt;Towards Angular vs React&lt;/h3&gt;

&lt;p&gt;Some sources have bigger influence than others in certain contexts, that means that different definitions can be considered decided more correct depending on the company.&lt;/p&gt;

&lt;p&gt;Thus one potential possibility is that some organizations decides on bunch of patterns and tools that then becomes extremely popular. Compare with what has happened on the frontend side with Angular and React providing a ready made solution that tells you how you should build your app.&lt;/p&gt;

&lt;p&gt;Kubernetes seems to have made a huge impact on the microservices world and hosting providers. The big question is if we will see any big contenders in the future.&lt;/p&gt;

&lt;h3 id=&quot;towards-modular-monolith&quot;&gt;Towards modular monolith&lt;/h3&gt;

&lt;p&gt;Lets define it as a monolith composed of modular parts in order to structure it in a way to make development clearer. We will probably see more work towards this style of architecture due to pain around one way of defining “microservices”.&lt;/p&gt;

&lt;p&gt;See for instance &lt;a href=&quot;https://github.com/kgrzybek/modular-monolith-with-ddd&quot;&gt;kgrzybek modular monolith&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;towards-functionservices&quot;&gt;Towards functionservices&lt;/h3&gt;

&lt;p&gt;Instead of going towards bigger things we will probably also see a move towards smaller services. Some of the definitions above hint at a microservices view that is more around writing very small things that resemble functions instead of being built around a bounded context. Perhaps &lt;a href=&quot;https://en.wikipedia.org/wiki/Serverless_computing&quot;&gt;serverless computing&lt;/a&gt; solutions will help solidify this style.&lt;/p&gt;

&lt;h2 id=&quot;what-problems-does-microservices-solve&quot;&gt;What problems does microservices solve&lt;/h2&gt;

&lt;p&gt;Note the focus on the following keywords: decentralized, autonomous, loosely coupled, single responsibility.&lt;/p&gt;

&lt;p&gt;Splitting a system into separate parts can help with making it easier for developers to reason about smaller parts (given that they are sufficiently independent). It’s easier to have semantic alignment in a smaller corpus.&lt;/p&gt;

&lt;p&gt;It’s harder to keep a big system consistent with new patterns compared to keeping smaller parts consistent locally. A heterogenous solution can thus imply easier local upgrades.&lt;/p&gt;

&lt;h2 id=&quot;what-problems-does-microservices-not-solve&quot;&gt;What problems does microservices not solve&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;How to split a system into components&lt;/li&gt;
  &lt;li&gt;Scaling or uptime issues&lt;/li&gt;
  &lt;li&gt;Spaghetti code&lt;/li&gt;
  &lt;li&gt;Sliced toast bread&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to solve these problems you need to architect your system[s] in such a way that these issues are feasible to address.&lt;/p&gt;

&lt;h2 id=&quot;comparison-with-soa&quot;&gt;Comparison with SOA&lt;/h2&gt;

&lt;p&gt;I’ve heard people reject some implementations as SOA. This does not make sense since you need to qualify both microservices and SOA and then end up in a straw man argument.&lt;/p&gt;

&lt;p&gt;Note that some SOA vs microservices presentations can be used to sell a migration project from an existing SOA implementation.&lt;/p&gt;

&lt;h2 id=&quot;making-it-clearer&quot;&gt;Making it clearer&lt;/h2&gt;

&lt;p&gt;Since there is no common definition of microservices, you need to define what you mean. One way to make it clearer is to offer one of the known definitions. Another way is to pick parts from others and create your own.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Expect further confusion around the concept as previously &lt;a href=&quot;https://martinfowler.com/bliki/ServiceOrientedAmbiguity.html&quot;&gt;seen around SOA&lt;/a&gt;. We will probably see the emergence of “modular monolith” or other architectural patterns that are defined in opposition of some definition of “microservices”. Some tools and patterns might become very popular creating a few competing solutions.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why do we need microservices</title>
      <link>https://assertfail.gewalli.se/2019/08/20/Why-do-we-need-microservices.html</link>
      <pubDate>Tue, 20 Aug 2019 08:08:49 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/08/20/Why-do-we-need-microservices</guid>
      <description>&lt;h2 id=&quot;polyglot&quot;&gt;Polyglot&lt;/h2&gt;

&lt;p&gt;I’ve found that I’m way more productive in some languages compared to others. This is common enough occurrence according to ThoughtWorks that they mention polyglot programming under their tech radar in &lt;a href=&quot;https://www.thoughtworks.com/radar/techniques&quot;&gt;techniques&lt;/a&gt;. It also allows the use of heterogenous teams that can bring different strengths to the table. Sometimes a language/virtual machine has a library or framework especially suited for your problem/task.&lt;/p&gt;

&lt;h2 id=&quot;code-chunks&quot;&gt;Code chunks&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Shitty code behind nice interfaces&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we look at the group intercommunication formula: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;n(n − 1) / 2&lt;/code&gt;, it should be fairly obvious that having tight coupling between teams without clear interfaces causes increased communication need. By defining nice API with nice enough documentation to communicate between team responsibilities you can ensure that teams can focus. I mean focus in the sense that team members are not led astray by leaky abstractions by exposing internal implementation details causing confusion for the uninitiated. As seen in the previous post, we do not strictly need to use microservices in order to satisfy this goal.&lt;/p&gt;

&lt;p&gt;One of the unintuitive facts of programming is that by restricting the possibilities can lead to improvements. This fact can be seen when it comes to static type systems. The same can be applied to API evolution. By making it harder to evolve an APIs, we can make it easier to be backwards compatible. Having a more focused API for a subdomain also makes it easier to reason about cache-logic and scaling. By keeping API’s backwards compatible you can evolve separate parts of your system at their own pace.&lt;/p&gt;

&lt;h2 id=&quot;cost-and-planning&quot;&gt;Cost and planning&lt;/h2&gt;

&lt;blockquote&gt;
  &lt;p&gt;Measuring software productivity by lines of code is like measuring progress on an airplane by how much it weighs&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Software estimation techniques show that the time and cost of software is closely related to the line count of the system where changes are made (see &lt;a href=&quot;https://www.goodreads.com/book/show/93891.Software_Estimation&quot;&gt;Software Estimation&lt;/a&gt;). This implies that having subsystems that can be reasoned about in isolation means that it’s easier to estimate and plan changes (as well as keep cost reasonable).&lt;/p&gt;

&lt;p&gt;The cost of microservices has in fact decreased over the years. Note for instance that deploying a hosted Kubernetes solution with a light workload can cost you as little as around 30$ per months depending on your vendor. Deploying multiple sites into a single App Service on Azure can be quite cheap as well.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Microservices allows you to build small isolated services in different languages accessible by HTTP requests. The operational cost gives you flexibility. The difficulty and cost of hosting microservices has become more democratized, why it has become more feasible for many workloads.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why we don&apos;t need microservices</title>
      <link>https://assertfail.gewalli.se/2019/08/17/Why-we-dont-need-microservices.html</link>
      <pubDate>Sat, 17 Aug 2019 08:02:01 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/08/17/Why-we-dont-need-microservices</guid>
      <description>&lt;h2 id=&quot;single-deployment&quot;&gt;Single deployment&lt;/h2&gt;

&lt;p&gt;If the system you are developing is intended to be delivered by a single team (or a single backend team), there might be less need for a decomposed solution where parts can be deployed separately. This also applies if you are starting out on something relatively small and don’t have the operations setup for doing microservices.&lt;/p&gt;

&lt;p&gt;If you still will want to structure your code in separate parts with clear API boundaries between them you can define request/response, publish:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;    /// &amp;lt;summary&amp;gt;
    /// Defines a mediator to encapsulate request/response and publishing interaction patterns
    /// &amp;lt;/summary&amp;gt;
    public interface IMediator
    {
        /// &amp;lt;summary&amp;gt;
        /// Asynchronously send a request to a single handler
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;typeparam name=&quot;TResponse&quot;&amp;gt;Response type&amp;lt;/typeparam&amp;gt;
        /// &amp;lt;param name=&quot;request&quot;&amp;gt;Request object&amp;lt;/param&amp;gt;
        /// &amp;lt;param name=&quot;cancellationToken&quot;&amp;gt;Optional cancellation token&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;A task that represents the send operation. The task result contains the handler response&amp;lt;/returns&amp;gt;
        Task&amp;lt;TResponse&amp;gt; Send&amp;lt;TResponse&amp;gt;(IRequest&amp;lt;TResponse&amp;gt; request, CancellationToken cancellationToken = default);

        /// &amp;lt;summary&amp;gt;
        /// Asynchronously send a notification to multiple handlers
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name=&quot;notification&quot;&amp;gt;Notification object&amp;lt;/param&amp;gt;
        /// &amp;lt;param name=&quot;cancellationToken&quot;&amp;gt;Optional cancellation token&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;A task that represents the publish operation.&amp;lt;/returns&amp;gt;
        Task Publish&amp;lt;TNotification&amp;gt;(TNotification notification, CancellationToken cancellationToken = default)
            where TNotification : INotification;
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The above interface is from the &lt;a href=&quot;https://github.com/jbogard/MediatR&quot;&gt;MediatR&lt;/a&gt; framework, but should be fairly trivial to implement on your own.&lt;/p&gt;

&lt;h3 id=&quot;plugins&quot;&gt;Plugins&lt;/h3&gt;

&lt;p&gt;How would you wire up such a solution? My instinct would be to use plugin architecture to be able to load the different parts into a main project:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;In for instance &lt;a href=&quot;https://jenkins.io/&quot;&gt;Jenkins&lt;/a&gt; you have the ability to write &lt;a href=&quot;https://wiki.jenkins.io/display/JENKINS/Plugin+tutorial&quot;&gt;plugins&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/framework/mef/&quot;&gt;MEF&lt;/a&gt; is used by Lucene.net in order to create docs plugins&lt;/li&gt;
  &lt;li&gt;CMS systems usually support plugins in order to extend the functionality. See &lt;a href=&quot;https://wordpress.org/plugins/&quot;&gt;Wordpress plugins&lt;/a&gt; or &lt;a href=&quot;https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/sharepoint-add-ins&quot;&gt;Sharepoint add-in&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we contrast microservices to plugins what do we find?&lt;/p&gt;

&lt;p&gt;Plugins usually need to follow the package versions and language restrictions of the host runtime.&lt;/p&gt;

&lt;p&gt;There isn’t always a natural way to test plugins in isolation, while for a http service you can use curl.&lt;/p&gt;

&lt;p&gt;There is an operations overhead for using several deployments (though that can be negligible depending on your solution).&lt;/p&gt;

&lt;h3 id=&quot;modularized-monolith&quot;&gt;Modularized monolith&lt;/h3&gt;

&lt;p&gt;Another approach is to avoid the plugin style and create a repository with sub-folders for separate modules, then a single delivery project that aggregates all of the modules. You still have questions also seen for plugins. One benefit is that you avoid needing to define extensibility points in order to allow plugin development.&lt;/p&gt;

&lt;p&gt;One example of this approach can be found in &lt;a href=&quot;https://github.com/simplcommerce/SimplCommerce&quot;&gt;SimplCommerce&lt;/a&gt;. Note the use of both frontend and backend parts per module.&lt;/p&gt;

&lt;h2 id=&quot;serverless&quot;&gt;Serverless&lt;/h2&gt;

&lt;p&gt;As we see on &lt;a href=&quot;https://martinfowler.com/articles/serverless.html&quot;&gt;Martin Fowler&lt;/a&gt; this type of solution can be thought of as a style of microservices solution.&lt;/p&gt;

&lt;p&gt;We see that there is vendor specific solutions and open source versions in this space. The most interesting things I’ve seen here are open source implementations of serverless on top of Kubernetes.&lt;/p&gt;

&lt;p&gt;By going serverless you can avoid some of the operations aspects of microservices (especially if you go with a cloud provider solution).&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;There are some pros and cons to going with one architecture over another. Depending on what you build, it doesn’t always make sense to go with a microservices approach why the other styles might be applicable.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why do we need message queues?</title>
      <link>https://assertfail.gewalli.se/2019/08/02/Why-do-we-need-message-queues.html</link>
      <pubDate>Fri, 02 Aug 2019 08:06:01 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/08/02/Why-do-we-need-message-queues</guid>
      <description>&lt;h2 id=&quot;http-might-be-good-enough&quot;&gt;HTTP might be good enough&lt;/h2&gt;

&lt;p&gt;For many systems there isn’t a need for message queues. Regular HTTP-style request/response are often enough. If your system is architected without thinking about events you might have very little need for it.&lt;/p&gt;

&lt;p&gt;A webhook can be good enough. It all depends on your architecture and business scenarios if it makes sense.&lt;/p&gt;

&lt;h2 id=&quot;what-good-is-a-message-queue&quot;&gt;What good is a message queue&lt;/h2&gt;

&lt;p&gt;A message queue is good for dealing with asynchronous messages not expected to be dealt with immediately. You can also use a message queue to create loosely coupled systems.&lt;/p&gt;

&lt;h3 id=&quot;pubsub&quot;&gt;PUB/SUB&lt;/h3&gt;

&lt;p&gt;One of the neat things with having a properly architected publish/subscribe is that you can decouple parts of your system. You can for instance use message systems with routing in order to have many consumers for selected messages or events. Products that fit the bill are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;RabbitMQ&lt;/li&gt;
  &lt;li&gt;Azure Service bus&lt;/li&gt;
  &lt;li&gt;ActiveMQ&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ZeroMQ looks particularly interesting as it doesn’t require a dedicated deployment. Though I’ve never used it.&lt;/p&gt;

&lt;p&gt;The assumption is that some systems are not interested in receiving some events. We see that &lt;a href=&quot;https://github.com/dotnet-architecture/eShopOnContainers&quot;&gt;eShopOnContainers&lt;/a&gt; can use both RabbitMQ and Azure Service bus.&lt;/p&gt;

&lt;p&gt;I’ve found that RabbitMQ style communication can be useful for dealing with longer running tasks generated by user input (not to be confused by cron-jobs). It’s a known type of technology that has been around. Note for instance some of the standardization around &lt;a href=&quot;https://en.wikipedia.org/wiki/Advanced_Message_Queuing_Protocol&quot;&gt;AMQP&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;event-stream&quot;&gt;Event stream&lt;/h3&gt;

&lt;p&gt;If pushing a huge number of messages/events then routing might be less of a concern why you might want to look into systems like:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Kafka&lt;/li&gt;
  &lt;li&gt;AWS Kinesis&lt;/li&gt;
  &lt;li&gt;Azure Event Hub&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We have an example of using Kafka &lt;a href=&quot;https://github.com/redhat-developer-demos/eda-tutorial&quot;&gt;from RedHat&lt;/a&gt;. We have also projects from Jet using Kafka: Note the mention of Kafka for projection in &lt;a href=&quot;https://github.com/jet/equinox&quot;&gt;Equinox&lt;/a&gt;. Kafka is also used &lt;a href=&quot;https://github.com/Netflix/suro/tree/master/suro-kafka-producer&quot;&gt;by Netflix&lt;/a&gt; and &lt;a href=&quot;https://github.com/spotify/docker-kafka&quot;&gt;Spotify&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Kafka has gotten a lot of attention in recent years and is probably still considered hot to work with.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;We might not need message queues for all systems and services, but they can be useful tools for certain use cases. You also need to decide on what style of message queues you need for your system.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>ESB and service mesh</title>
      <link>https://assertfail.gewalli.se/2019/07/28/ESB-and-service-mesh.html</link>
      <pubDate>Sun, 28 Jul 2019 18:58:14 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/07/28/ESB-and-service-mesh</guid>
      <description>&lt;h2 id=&quot;service-mesh&quot;&gt;Service mesh&lt;/h2&gt;

&lt;p&gt;Service mesh looks like an evolution of &lt;a href=&quot;https://en.wikipedia.org/wiki/Enterprise_service_bus&quot;&gt;Enterprise Service Bus&lt;/a&gt; and has similar focus. An ESB is a single point of failure. Since it’s a combination of many concerns, it can be hard to get right. A service mesh tries to mitigate this by focus mainly on HTTP, HTTP2 style communication and being distributed as a deployment (each service has it’s own copy of the mesh software).&lt;/p&gt;

&lt;h3 id=&quot;typical-concerns&quot;&gt;Typical concerns&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Security (restrict traffic between services, use ssl for internal communication)&lt;/li&gt;
  &lt;li&gt;Observability (being able to trace requests and communication between services)&lt;/li&gt;
  &lt;li&gt;Traffic shaping (route traffic to avoid faulty services)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;when-does-it-make-sense&quot;&gt;When does it make sense&lt;/h3&gt;

&lt;p&gt;A service mesh starts to look really attractive once you start get into something like hundreds of services written by several teams. For fewer services it might introduce unnecessary operations overhead. This should be similar to recommendations around ESB. This should also be depending on if your service provider makes it easy to enable such a service. Using a service mesh also looks more attractive than using ESB since some of the issues are mitigated.&lt;/p&gt;

&lt;h3 id=&quot;when-doesnt-it-make-sense&quot;&gt;When doesn’t it make sense&lt;/h3&gt;

&lt;p&gt;If you have mostly things hosted on one type of web server/service host, then collection of web server logging might be enough to satisfy the observability requirement. For instance when your hosting provider makes it easy to enable HTTP log collection. Going towards more dockerized services shifts your needs (as you do not have as homogeneous environment).&lt;/p&gt;

&lt;p&gt;The security requirement could also be satisfied by decent middleware. Many HTTP frameworks have JWT support. Your hosting provider could let you enable &lt;a href=&quot;https://letsencrypt.org/&quot;&gt;let’s encrypt&lt;/a&gt; for sites.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Choose your own adventure in F# 2</title>
      <link>https://assertfail.gewalli.se/2019/07/28/Choose-your-own-adventure-in-fsharp-2.html</link>
      <pubDate>Sun, 28 Jul 2019 13:56:23 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/07/28/Choose-your-own-adventure-in-fsharp-2</guid>
      <description>&lt;p&gt;In the &lt;a href=&quot;https://assertfail.gewalli.se/2019/01/06/Choose-your-own-adventure-in-fsharp.html&quot;&gt;first post&lt;/a&gt; I introduced some alternatives for F# programming. The title alludes at classic roleplaying games. Mattias Brandewinder has written a &lt;a href=&quot;https://github.com/mathias-brandewinder/MonsterVault&quot;&gt;blog post series&lt;/a&gt; about writing DnD logic in F# that should be an interesting read in order to follow up on that lead.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Maven security issues scanning</title>
      <link>https://assertfail.gewalli.se/2019/07/27/Maven-security-issues-scanning.html</link>
      <pubDate>Sat, 27 Jul 2019 05:20:08 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/07/27/Maven-security-issues-scanning</guid>
      <description>&lt;p&gt;There is a mature package management system in the Java world. Maven seems to be quite standard. I’ve made &lt;a href=&quot;https://github.com/wallymathieu/hibernate-studies&quot;&gt;a sample project&lt;/a&gt; with Hibernate and Spring. One of the neat things I found out was that it’s quite easy to integrate &lt;a href=&quot;https://owasp.org/&quot;&gt;OWASP&lt;/a&gt; checks. Following the &lt;a href=&quot;https://jeremylong.github.io/DependencyCheck/dependency-check-maven/index.html&quot;&gt;guide&lt;/a&gt; to setup a simple way to be able to that your closed source system does not have any known vulnerabilities in dependencies.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Decompiling Java binaries</title>
      <link>https://assertfail.gewalli.se/2019/07/26/Decompiling-Java-binaries.html</link>
      <pubDate>Fri, 26 Jul 2019 19:02:44 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/07/26/Decompiling-Java-binaries</guid>
      <description>&lt;p&gt;There are some tools out there to decompile Java binaries. I’ve found that the easiest one to process an entire jar is &lt;a href=&quot;https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine&quot;&gt;Fernflow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In order to build you notice that it’s built using &lt;a href=&quot;https://gradle.org/&quot;&gt;Gradle&lt;/a&gt;. Either install gradle or use existing shell wrappers to build the jar file.&lt;/p&gt;

&lt;p&gt;Once you have built the decompiler you might want to wrap it up with a shell wrapper and put the executable in your path next to the fernflower.jar:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;

java &lt;span class=&quot;nt&quot;&gt;-jar&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;/fernflower.jar &lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Java vs C#</title>
      <link>https://assertfail.gewalli.se/2019/06/15/Java-vs-CSharp.html</link>
      <pubDate>Sat, 15 Jun 2019 17:37:10 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/06/15/Java-vs-CSharp</guid>
      <description>&lt;p&gt;Java started out as a very object oriented language. One of the nice things with Java (as a language) has been that the syntax has been quite stable for a long time. C# competes with Java for mainstream developer mind-share. C# has pushed better tooling and more features but was primarily focused on Windows.&lt;/p&gt;

&lt;p&gt;For the last few years we have seen .net becoming a truer cross platform language with the .net core project and Microsoft’s acquisition of Xamarin. Due to the push towards micro services and Docker this makes a lot of sense since we will probably see more large scale enterprise software use some sort of micro service architecture to allow scaling of development teams.&lt;/p&gt;

&lt;h2 id=&quot;features&quot;&gt;Features&lt;/h2&gt;

&lt;h3 id=&quot;implemented-in-both&quot;&gt;Implemented in both&lt;/h3&gt;

&lt;h4 id=&quot;language-features&quot;&gt;Language Features&lt;/h4&gt;

&lt;p&gt;Some of the features we know and love in C# is nowadays also part of modern Java:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The ability to create a small lambda simplifies many programming tasks why the &lt;a href=&quot;https://www.baeldung.com/java-8-functional-interfaces&quot;&gt;functional interfaces in Java 8&lt;/a&gt; is a nice addition.&lt;/li&gt;
  &lt;li&gt;Many of the bread and butter collection operations seen as &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable?redirectedfrom=MSDN&amp;amp;view=netframework-4.8#methods&quot;&gt;extension methods&lt;/a&gt; in .net are available by using &lt;a href=&quot;https://www.baeldung.com/java-8-streams-introduction&quot;&gt;java.util.stream&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;There is local variable type inference with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;var&lt;/code&gt; in Java 10&lt;/li&gt;
  &lt;li&gt;In more modern Java you can write &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;try (T instance=new ExpensiveResource()){ ... }&lt;/code&gt; to automatically dispose an instance that &lt;a href=&quot;https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html&quot;&gt;implements the AutoCloseable interface&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the C# corner we are waiting on C# 8 for:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://devblogs.microsoft.com/dotnet/default-implementations-in-interfaces/&quot;&gt;Default interface implementation&lt;/a&gt; that we have seen used in Java since Java 8.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We see that Java uses standard generic class &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Optional&amp;lt;&amp;gt;&lt;/code&gt; with methods while C# uses &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?.&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;??&lt;/code&gt; operators and uses &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Nullable&amp;lt;&amp;gt;&lt;/code&gt; for value types.&lt;/p&gt;

&lt;h4 id=&quot;tooling&quot;&gt;Tooling&lt;/h4&gt;

&lt;p&gt;Using Visual Studio Code to develop Java feels very productive. Using Jetbrains Intellij is nicer. I’m not a fan of Eclipse. For C# I usually prefer Visual Studio while Visual Studio Code works and you get some more sweet refactoring in Rider (or through Resharper).&lt;/p&gt;

&lt;p&gt;Both Maven and NuGet are mature and enable decomposition into libraries.&lt;/p&gt;

&lt;h3 id=&quot;missing-features-added-through-extension&quot;&gt;Missing features added through extension&lt;/h3&gt;

&lt;p&gt;The missing part that becomes quite obvious as you start working on any project in Java is the lack of auto properties. However, there is &lt;a href=&quot;https://projectlombok.org&quot;&gt;Project Lombok&lt;/a&gt; that removes a lot of boilerplate from your code.&lt;/p&gt;

&lt;p&gt;You would expect that in C# you’d use &lt;a href=&quot;https://www.hanselman.com/blog/t4-text-template-transformation-toolkit-code-generation-best-kept-visual-studio-secret&quot;&gt;t4 template&lt;/a&gt; (or &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview&quot;&gt;Roslyn Source generators&lt;/a&gt;) to reduce boilerplate.&lt;/p&gt;

&lt;h3 id=&quot;missing-features&quot;&gt;Missing features&lt;/h3&gt;

&lt;p&gt;There isn’t any generic support in the Java runtime. This leads to some weirdness around &lt;a href=&quot;https://www.baeldung.com/java-type-erasure&quot;&gt;type erasure&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There isn’t any &lt;a href=&quot;https://www.baeldung.com/java-anonymous-classes&quot;&gt;anonymous interface implementation in C#&lt;/a&gt;, but there is in Java (and &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/object-expressions&quot;&gt;something similar in F#&lt;/a&gt;).&lt;/p&gt;

&lt;h2 id=&quot;style&quot;&gt;Style&lt;/h2&gt;

&lt;h3 id=&quot;differences&quot;&gt;Differences&lt;/h3&gt;

&lt;p&gt;The style of stream and the usage of words are more in line with many other languages (see for instance Javascript, Ruby, Python). Notice the use of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;map&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;filter&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;reduce&lt;/code&gt; while in C# LINQ is more in line with SQL. This gives the code a slightly different flavor.&lt;/p&gt;

&lt;p&gt;Checked exceptions cause some boilerplate code that becomes a bit more manageable with &lt;a href=&quot;https://doc.rust-lang.org/std/result/&quot;&gt;Result&lt;/a&gt; style error handling.&lt;/p&gt;

&lt;h3 id=&quot;similarities&quot;&gt;Similarities&lt;/h3&gt;

&lt;p&gt;There &lt;a href=&quot;https://hibernate.org/validator/documentation/getting-started/&quot;&gt;is validation in Java&lt;/a&gt; similar to the familiar attribute based validation in .net.&lt;/p&gt;

&lt;p&gt;There are popular MVC frameworks for both. &lt;a href=&quot;https://spring.io/&quot;&gt;Spring&lt;/a&gt; should feel familiar to anyone using asp.net MVC.&lt;/p&gt;

&lt;p&gt;There are some gotchas, but any .net developer or Java developer should be able to work in both. There might be a short term productivity loss.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Both languages have mature editor support. Many of the bread and butter programming tasks have feature support in both languages. There are some stylistic differences between the languages.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>When is Go a nice language?</title>
      <link>https://assertfail.gewalli.se/2019/05/30/When-is-Go-a-nice-language.html</link>
      <pubDate>Thu, 30 May 2019 10:15:09 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/05/30/When-is-Go-a-nice-language</guid>
      <description>&lt;p&gt;I’ve been following Go for a while due to the influence of one of my personal heroes: Ken Thompson (due to his hand in making Unix and C programming language).&lt;/p&gt;

&lt;p&gt;Many years ago I met Douglas Crockford. At that point I was looking into low level implementation of parsers why I suggested a JVM language with more primitive structures in order to simplify implementation of more low level performance critical parts:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If you make a JVM language with goto people will start coding web apps in it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The comment was in a way prophetic since that’s sort of what has happened with Go. In the sense that people started using what is essentially a low level language to write web applications.&lt;/p&gt;

&lt;h2 id=&quot;the-good&quot;&gt;The good&lt;/h2&gt;

&lt;h3 id=&quot;very-procedural&quot;&gt;Very procedural&lt;/h3&gt;

&lt;p&gt;Go fits procedural programmers naturally: Since many programmers start out thinking procedurally and debugging code in order to understand it, it should come naturally to many developers.&lt;/p&gt;

&lt;p&gt;There are few conceptual components of Go. Like C, it’s not really a difficult language to learn (though there are some constructs related to GoRoutines that looks like false friends).&lt;/p&gt;

&lt;h3 id=&quot;simple-reflection&quot;&gt;Simple reflection&lt;/h3&gt;

&lt;p&gt;There are rudimentary reflection capabilities, why you could implement some standard meta programming patterns found in Java/C#.&lt;/p&gt;

&lt;h3 id=&quot;compilation-time&quot;&gt;Compilation time&lt;/h3&gt;

&lt;p&gt;Go has short compilation time. This can improve developer happiness (reduce the code/compile/try cycle). It is also easy to use in non standard editors (as opposed to C#/Java).&lt;/p&gt;

&lt;h3 id=&quot;size-of-docker-deliverables&quot;&gt;Size of docker deliverables&lt;/h3&gt;

&lt;p&gt;Compared to some other more mature languages like C# and Java: Go produces smaller docker deliverables. Though if you really care about the size of your deliverables Go might not be the optimal language (but perhaps good enough).&lt;/p&gt;

&lt;p&gt;If you are concerned about the size of your deliverables, then you could write web apps in c with say &lt;a href=&quot;https://kore.io/&quot;&gt;kore&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;I like that Go comes bundled with a &lt;a href=&quot;https://blog.golang.org/go-fmt-your-code&quot;&gt;code formatter&lt;/a&gt;, since c languages otherwise leans towards bike shedding when it comes to formatting.&lt;/p&gt;

&lt;h3 id=&quot;testing&quot;&gt;Testing&lt;/h3&gt;

&lt;p&gt;There is a &lt;a href=&quot;https://golang.org/pkg/testing/&quot;&gt;nice story around testing&lt;/a&gt; for the language that also could improve developer productivity.&lt;/p&gt;

&lt;h3 id=&quot;structural-types&quot;&gt;Structural types&lt;/h3&gt;

&lt;p&gt;In order to implement an interface you use the fact that Go has a &lt;a href=&quot;https://en.wikipedia.org/wiki/Structural_type_system&quot;&gt;structural type system&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;the-bad&quot;&gt;The bad&lt;/h2&gt;

&lt;h3 id=&quot;missing-parts&quot;&gt;Missing parts&lt;/h3&gt;

&lt;p&gt;One of the notable things in Go is that there are no exceptions. This is however a half truth. There are exception like functionality as can be seen on &lt;a href=&quot;https://medium.com/@mattklein123/exceptional-go-1dd1488a6a47&quot;&gt;Matt Kleins post on Medium&lt;/a&gt;. It’s not used that often, why usage of it may be frowned upon by the designers of the language.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;The error handling and lack of generics require you to write more code. The performance is &lt;a href=&quot;https://www.ageofascent.com/2019/02/04/asp-net-core-saturating-10gbe-at-7-million-requests-per-second/&quot;&gt;comparable&lt;/a&gt; to other statically typed languages. My guess is that you can be productive enough in order to write regular business code in it. It can be used as an alternative to Java and C# for when the team likes Go-style code.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Docker and .net</title>
      <link>https://assertfail.gewalli.se/2019/05/22/Docker-and-net.html</link>
      <pubDate>Wed, 22 May 2019 19:35:44 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/05/22/Docker-and-net</guid>
      <description>&lt;p&gt;I’ve spent half a year on a project to Kubernetes project. During that time we did production deployments of .net core web services to docker.&lt;/p&gt;

&lt;p&gt;My main suggestion would be to follow the &lt;a href=&quot;https://docs.docker.com/engine/examples/dotnetcore/&quot;&gt;example on docker.com&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Kubernetes and distractions</title>
      <link>https://assertfail.gewalli.se/2019/04/15/Kubernetes-and-distractions.html</link>
      <pubDate>Mon, 15 Apr 2019 05:47:14 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/04/15/Kubernetes-and-distractions</guid>
      <description>&lt;p&gt;There are many cool projects you can install into Kubernetes. However before buying into the hype, try to focus on the basics in order to deliver value to the business/customer.&lt;/p&gt;

&lt;h2 id=&quot;start-with-few-components&quot;&gt;Start with few components&lt;/h2&gt;

&lt;p&gt;You can start by following Alex Ellis guide on HowTo &lt;a href=&quot;https://blog.alexellis.io/move-your-project-to-kubernetes/&quot;&gt;move your project to kubernetes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;One thing to take away from &lt;a href=&quot;https://jvns.ca/blog/2018/12/15/new-talk--high-reliability-infrastructure-migrations/&quot;&gt;Julia Evans talk: High Reliability Infrastructure Migrations&lt;/a&gt; is:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;ignore most kubernetes ecosystem software&lt;/p&gt;
&lt;/blockquote&gt;
</description>
    </item>
    
    <item>
      <title>Kubernetes on the cheap</title>
      <link>https://assertfail.gewalli.se/2019/04/09/Kubernetes-on-the-cheap.html</link>
      <pubDate>Tue, 09 Apr 2019 05:32:29 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/04/09/Kubernetes-on-the-cheap</guid>
      <description>&lt;p&gt;You can use the fact that Kubernetes allows you to get a stable environment on unstable hardware, so that you can use a bunch of cheap commodity computers to scale your deployments horizontally. A good starting point would be to build your own test cluster.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Jeff Atwood talks about using co-location in &lt;a href=&quot;https://blog.codinghorror.com/the-cloud-is-just-someone-elses-computer/&quot;&gt;the cloud is just someone elses computer&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Hanselman tells you &lt;a href=&quot;https://www.hanselman.com/blog/HowToBuildAKubernetesClusterWithARMRaspberryPiThenRunNETCoreOnOpenFaas.aspx&quot;&gt;How to Build a Kubernetes Cluster with ARM Raspberry Pi then run .NET Core on OpenFaas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Another approach is to look into where hosted Kubernetes is more affordable than say &lt;a href=&quot;https://aws.amazon.com/eks/pricing/&quot;&gt;EKS&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/cablespaghetti/kubeadm-aws&quot;&gt;kubeadm-aws&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;an example where someone used GKE to get &lt;a href=&quot;https://news.ycombinator.com/item?id=18111665&quot;&gt;hosted Kubernetes for personal projects&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>When does it make sense to use Kubernetes?</title>
      <link>https://assertfail.gewalli.se/2019/04/08/When-does-it-make-sense-to-use-Kubernetes.html</link>
      <pubDate>Mon, 08 Apr 2019 19:14:03 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/04/08/When-does-it-make-sense-to-use-Kubernetes</guid>
      <description>&lt;h2 id=&quot;the-bad&quot;&gt;The bad&lt;/h2&gt;

&lt;p&gt;There is a certain level of complexity associated with Kubernetes. Depending on how you get started, it can be a bit of a chore to get a cluster up and running. There are costs associated with having a stable cluster up and running.&lt;/p&gt;

&lt;h2 id=&quot;the-good&quot;&gt;The good&lt;/h2&gt;

&lt;p&gt;What does Kubernetes give you? It offers an environment for hosting docker services that is more portable between vendors. It allows you to run an environment locally mimicking your production environment. You are able to gradually roll out new versions of services and scale them according to need.&lt;/p&gt;

&lt;h2 id=&quot;my-guess&quot;&gt;My Guess&lt;/h2&gt;

&lt;p&gt;I would guesstimate that if you have a few services (say 5-10) without a network topology and your scaling needs fits a single computer, then kubernetes is probably overkill. While if you want or plan to host a multitude of different services then the complexity looks justified.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You have a lot of service/site/job deliverables that work well as docker images&lt;/li&gt;
  &lt;li&gt;You want the infrastructure to help maintain uptime and roll out deployments&lt;/li&gt;
  &lt;li&gt;You estimate that Kubernetes will be prevalent in the future and want in on it now&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;similar-alternatives&quot;&gt;Similar Alternatives&lt;/h2&gt;

&lt;p&gt;Note however that there are some other alternatives you might want to look into. See for instance &lt;a href=&quot;https://docs.docker.com/engine/swarm/&quot;&gt;Docker Swarm&lt;/a&gt; or &lt;a href=&quot;https://azure.microsoft.com/en-us/services/service-fabric/&quot;&gt;Service Fabric&lt;/a&gt; and &lt;a href=&quot;https://www.openshift.com/&quot;&gt;OpenShift&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Choose your own adventure in F#</title>
      <link>https://assertfail.gewalli.se/2019/01/06/Choose-your-own-adventure-in-fsharp.html</link>
      <pubDate>Sun, 06 Jan 2019 09:32:39 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2019/01/06/Choose-your-own-adventure-in-fsharp</guid>
      <description>&lt;p&gt;When you start out on F# your first thought might be:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-F#&quot;&gt;let square x = x * x

let sumOfSquares n =
   [1..n]
   |&amp;gt; List.map square
   |&amp;gt; List.sum
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;hey, that sort of looks like:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;public static class Utils
{
   public static int SumOfSquares(int n)
   {
      return Enumerable.Range(1, n)
         .Select(i =&amp;gt; i * i)
         .Sum();
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Examples from &lt;a href=&quot;https://fsharpforfunandprofit.com/posts/fvsc-sum-of-squares/&quot;&gt;F# for fun and profit: Sum of squares&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;At a first glance, F# looks sort like slightly different style of C#, where instead of using extension methods you use static methods. Turns out that that’s not all there is to F#.&lt;/p&gt;

&lt;h2 id=&quot;lets-start-from-the-basics&quot;&gt;Let’s start from the basics&lt;/h2&gt;

&lt;p&gt;There is also an excellent source of knowledge about functional programming called &lt;a href=&quot;https://fsharpforfunandprofit.com&quot;&gt;F# for fun and profit&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;overlap-of-c-and-f-coding&quot;&gt;Overlap of C# and F# coding&lt;/h2&gt;

&lt;p&gt;There are some points to being happy in F#. For instance there is an intersection of styles for F# and C# where both languages are nice to use:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Lightly functional style ( &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Select&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;seq.map&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Where&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;seq.filter&lt;/code&gt;, pure functions, named types instead of using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;string&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;int64&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dictionary&amp;lt;string,object&amp;gt;&lt;/code&gt; et.c., lambda expressions)&lt;/li&gt;
  &lt;li&gt;Simple Object Orientated code (i.e. no deep type hierarchies)&lt;/li&gt;
  &lt;li&gt;Mutable constructs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;prefer-f-over-c-in-the-case-when-&quot;&gt;Prefer F# over C# in the case when …&lt;/h3&gt;

&lt;p&gt;Some constructs that are easy to use in F# need more work or make for weird C#.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Immutable constructs ( F# tries to steer you into immutable by default and has constructs to help you). In C# you need something like &lt;a href=&quot;https://github.com/wallymathieu/with&quot;&gt;With&lt;/a&gt; or &lt;a href=&quot;https://github.com/AArnott/ImmutableObjectGraph&quot;&gt;Immutable Object Graph&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Computation expressions (builders that can help you write composable abstractions)&lt;/li&gt;
  &lt;li&gt;Discriminated unions (in C# your best bet is to look at &lt;a href=&quot;https://github.com/mcintyre321/OneOf&quot;&gt;OneOf&lt;/a&gt; or use &lt;a href=&quot;https://github.com/fsprojects/FSharpx.Extras/blob/master/src/FSharpx.Extras/CSharpCompat.fs#L297&quot;&gt;FSharpX&lt;/a&gt;)&lt;/li&gt;
  &lt;li&gt;Type providers (in C# it’s better to generate source code using something like t4 templates, though that can become awkward)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters&quot;&gt;Statically Resolved Type Parameters&lt;/a&gt; (can be used to avoid using reflection)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;prefer-c-over-f-in-the-case-when-&quot;&gt;Prefer C# over F# in the case when …&lt;/h3&gt;

&lt;p&gt;Some constructs that are easy to use in C# need more work or make for weird F#&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Unsafe code, Native pointers (it’s possible in F#, but is more verbose)&lt;/li&gt;
  &lt;li&gt;Goto (generally seen as an anti-pattern but is really useful when writing highly optimized code: think core parts of asp.net MVC)&lt;/li&gt;
  &lt;li&gt;Deep type hierarchies (generally seen as an anti-pattern and in F# the language tries to steer you away from these patterns, though in certain cases they can be useful)&lt;/li&gt;
  &lt;li&gt;Code generation (due to type providers, there is less need for it in F#)&lt;/li&gt;
  &lt;li&gt;Implicit type conversions (generally seen as an anti-pattern, you can explicitly use &lt;a href=&quot;https://github.com/fsprojects/FSharpPlus/blob/35eb4c1b0646e4e07701c48ea4b2bdef2067caa5/src/FSharpPlus/Operators.fs#L717-L718&quot;&gt;implicit operator&lt;/a&gt; in F#)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is also a certain mainstream appeal of c style languages, why you might choose to code in C# despite being fluent in F#. I’m not fluent enough in VB.net to know when to use that language.&lt;/p&gt;

&lt;h2 id=&quot;so-you-have-choosen-f&quot;&gt;So you have choosen F#?&lt;/h2&gt;

&lt;p&gt;Let’s say that you go start with a server or service (and worry about client or web code later).&lt;/p&gt;

&lt;h3 id=&quot;web-framework-overview&quot;&gt;Web framework overview&lt;/h3&gt;

&lt;p&gt;There is a smörgåsbord of web frameworks to choose from.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://suave.io&quot;&gt;Suave&lt;/a&gt; : Oldie but goodie. Some old idiosyncrasies. Need some love and major version with breaking changes removing cruft.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/giraffe-fsharp/Giraffe&quot;&gt;Giraffe&lt;/a&gt; : in the style of Suave but with better performance (not as composable due to usage of Task over Async)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://freya.io&quot;&gt;Freya&lt;/a&gt; : Using custom computation expressions as builders. Based on webmachine. Need some love and new major version removing cruft.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/panesofglass/frank&quot;&gt;Frank&lt;/a&gt; : Recently overhauled. Frank together with Freya and Suave are the oldest F# web frameworks. Using computation expression as builder.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://saturnframework.org&quot;&gt;Saturn&lt;/a&gt; : Relatively new to the block. Using custom computation expressions as builders. Based on Pheonix and MVC patterns.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/aspnet/AspNetCore&quot;&gt;asp.net MVC&lt;/a&gt; : MVC is the most common .net run of the mill object oriented web MVC framework.&lt;/li&gt;
  &lt;li&gt;based on &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.builder.iapplicationbuilder?view=aspnetcore-2.1&quot;&gt;IApplicationBuilder&lt;/a&gt; or OWIN: OWIN is considered dead at this point, but it played an essential role in influencing some of the work that went into asp.net core. You can compose your API in a slightly rough style by leveraging these abstractions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The question about web framework can also be phrased as, what kind of style do you like? Roughly there are five categories.&lt;/p&gt;

&lt;h3 id=&quot;function-composition-based--suave-giraffe&quot;&gt;Function composition based : Suave, Giraffe&lt;/h3&gt;

&lt;p&gt;My personal favorite. I like being able to compose API out of function building blocks. It’s both abstract and low level at the same time. Might not be appropriate for larger teams, but fits well with microservices.&lt;/p&gt;

&lt;p&gt;Giraffe is bundled with &lt;a href=&quot;https://www.newtonsoft.com/json&quot;&gt;Newtonsoft.Json&lt;/a&gt; for serialization. Suave uses &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.json.datacontractjsonserializer?view=netframework-4.7.2&quot;&gt;DataContractJsonSerializer&lt;/a&gt; for serialization. Both of the libraries make it very easy to plug in your own choice of Json framework.&lt;/p&gt;

&lt;p&gt;Personally I prefer to plug in &lt;a href=&quot;https://github.com/mausch/Fleece&quot;&gt;Fleece&lt;/a&gt; with &lt;a href=&quot;https://www.nuget.org/packages/Fleece.FSharpData/&quot;&gt;FSharp.Data&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;bring-your-own-abstractions-iapplicationbuilder&quot;&gt;Bring your own abstractions: IApplicationBuilder&lt;/h3&gt;

&lt;p&gt;Another one of my favorites. You can create your own abstractions on top of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Map&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MapWhen&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Run&lt;/code&gt;. You can also choose to be more to the metal in order to avoid abstractions. This can be excellent in order to teach programmers about how the details of web services (or when there is little need of abstractions).&lt;/p&gt;

&lt;h3 id=&quot;webmachine-based--freya&quot;&gt;Webmachine based : Freya&lt;/h3&gt;

&lt;p&gt;Focus here is on being true to the HTTP spec. The &lt;a href=&quot;https://github.com/webmachine/webmachine/wiki/Diagram&quot;&gt;webmachine diagram&lt;/a&gt; is used by people to teach themselves about HTTP.&lt;/p&gt;

&lt;p&gt;The Freya tutorial points you in the direction of &lt;a href=&quot;http://github.com/xyncro/chiron&quot;&gt;Chiron&lt;/a&gt; (from the same github organization).&lt;/p&gt;

&lt;h3 id=&quot;ce-as-builders--frank-saturn&quot;&gt;CE as builder[s] : Frank, Saturn&lt;/h3&gt;

&lt;p&gt;Frank is a kind of small library that is probably good enough for many use cases. Saturn strives to be a batteries included framework.&lt;/p&gt;

&lt;h3 id=&quot;object-oriented--aspnet-mvc&quot;&gt;Object oriented : ASP.NET MVC&lt;/h3&gt;

&lt;p&gt;Even though you need some attributes to configure endpoints, you can get a lot of mileage from &lt;a href=&quot;https://github.com/rspeele/TaskBuilder.fs&quot;&gt;TaskBuilder.fs&lt;/a&gt; and the fact that you need less code to take in dependency injection parameters. F# shows that it can be a nice object oriented language.&lt;/p&gt;

&lt;p&gt;The default for asp.net mvc is to use Newtonsoft.Json. It’s not hard to plug in another serializer.&lt;/p&gt;

&lt;h2 id=&quot;what-about-testing-your-code&quot;&gt;What about testing your code?&lt;/h2&gt;

&lt;h3 id=&quot;main-branches&quot;&gt;Main branches&lt;/h3&gt;

&lt;p&gt;There are two main paths of F# testing (that I’ve seen). One is the *Unit style testing frameworks, the other is composable testing frameworks.&lt;/p&gt;

&lt;h4 id=&quot;unit&quot;&gt;*Unit&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://nunit.org&quot;&gt;NUnit&lt;/a&gt; classic unit testing framework for .net.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://xunit.github.io&quot;&gt;XUnit&lt;/a&gt; is rearchitected testing framework by some of the original team from NUnit made to make unit testing more accessible and safe (i.e. trying to steer away from anti-patterns).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you go down this path you should check out &lt;a href=&quot;https://fsprojects.github.io/FsUnit/&quot;&gt;FsUnit&lt;/a&gt; that provides some extensions to make testing in F# more enjoyable.&lt;/p&gt;

&lt;p&gt;XUnit will feel very familiar due to the popularity of *Unit style libraries.&lt;/p&gt;

&lt;h4 id=&quot;composable-testing&quot;&gt;Composable testing&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/mausch/Fuchu&quot;&gt;Fuchu&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/haf/expecto&quot;&gt;Expecto&lt;/a&gt; forked from Fuchu and re-architected. This style of testing framework is based on lists of functions/methods instead of attributes. This makes it easier to compose your test code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m somewhat ambivalent to XUnit vs composable testing.&lt;/p&gt;

&lt;h3 id=&quot;going-further-down-the-test-track&quot;&gt;Going further down the test track&lt;/h3&gt;

&lt;h4 id=&quot;property-based-testing&quot;&gt;Property based testing&lt;/h4&gt;

&lt;p&gt;In property based testing you define the conditions for test data and let generators create that data to check your code against. These style of testing frameworks are excellent to combine with your existing testing.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://fscheck.github.io/FsCheck/&quot;&gt;FsCheck&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/hedgehogqa/fsharp-hedgehog&quot;&gt;Hedgehog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it comes to then add property based testing I’ve mostly used FsCheck.&lt;/p&gt;

&lt;h2 id=&quot;going-deeper-down-the-rabbit-hole&quot;&gt;Going deeper down the rabbit hole!&lt;/h2&gt;

&lt;p&gt;Say that you have gotten your feet wet and tasted some of the functional goodness of F#. Going further down you want to start to use some library to remove some of the copy paste. There are a couple of different libraries that can help you reduce your own infrastructure code.&lt;/p&gt;

&lt;h3 id=&quot;fx-extras&quot;&gt;&lt;a href=&quot;https://github.com/fsprojects/FSharpx.Extras&quot;&gt;F#X Extras&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Contains a lot of helpful various utilities. Note monoid as &lt;a href=&quot;https://github.com/fsprojects/FSharpx.Extras/blob/d51ce763762b1e277f679d01b76504da00a67b6b/src/FSharpx.Extras/Monoid.fs#L11-L12&quot;&gt;an abstract class&lt;/a&gt;. It’s under the stewardship of &lt;a href=&quot;https://github.com/fsprojects/&quot;&gt;fsprojects&lt;/a&gt; so accepts pull requests even though the original authors are not as involved.&lt;/p&gt;

&lt;h3 id=&quot;extcore&quot;&gt;&lt;a href=&quot;https://github.com/jack-pappas/ExtCore&quot;&gt;ExtCore&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;ExtCore contains among other things combinations of computation expressions.&lt;/p&gt;

&lt;h3 id=&quot;yolo&quot;&gt;&lt;a href=&quot;https://github.com/haf/yolo&quot;&gt;YoLo&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;YoLo isn’t really a library, it’s really a small file that gives you a bit of extra useful methods. Used by Suave to provide some common utilities for base components of F# like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Option&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Result&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Choice&lt;/code&gt;.&lt;/p&gt;

&lt;h3 id=&quot;f&quot;&gt;&lt;a href=&quot;https://github.com/fsprojects/FSharpPlus&quot;&gt;F#+&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;My personal favorite. It’s a rejection of the assumption that &lt;a href=&quot;https://forums.fsharp.org/t/does-f-have-a-future/237&quot;&gt; F# cannot express higher level of abstractions&lt;/a&gt;. By using for instance monad transformers you can get the same functionality (combinations of computation expressions) as in ExtCore but without having to manually code it.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;F# has a rich eco system of tools and frameworks. It can be a useful tool in order to deal with complexity or just to write something quick using some F# scripts. There are many paths that you can take to get where you need to go.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Is there a value in having diversity when it comes to solutions?</title>
      <link>https://assertfail.gewalli.se/2018/10/26/Is-there-a-value-in-having-diversity-when-it-comes-to-solutions.html</link>
      <pubDate>Fri, 26 Oct 2018 11:01:51 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/10/26/Is-there-a-value-in-having-diversity-when-it-comes-to-solutions</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;Monoculture in agriculture has some definite downsides (lack of resilience, soil depletion, over reliance on fertilizer)&lt;/li&gt;
  &lt;li&gt;Monoculture in buildings can cause people to feel lost. Once you move in, you want to change your house to fit your family and your interests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A suburb that started out with lots of very similar houses can end up with divergent colors, additions suited for different people, gardens with personal style. This should not be seen as a negative thing, it shows the history of the area and give a sense of identity to the neighborhood.&lt;/p&gt;

&lt;p&gt;In programming we often have a drive towards standardization.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;perhaps in order to increase the industrial or engineering nature of it?&lt;/li&gt;
  &lt;li&gt;To make it easy to get people from other teams to understand the code due to similarities in style&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;having-different-stylesarchitecturesprogramming-language&quot;&gt;Having different styles/architectures/programming language&lt;/h2&gt;

&lt;p&gt;Since different software components suite different purposes, they should have style suited for different application / purpose.
When you use components from different companies and open source initiatives, they will not fit your style but they will help you deliver.&lt;/p&gt;

&lt;h3 id=&quot;one-language-to-rule-them-all&quot;&gt;One language to rule them all&lt;/h3&gt;

&lt;p&gt;There is talk about having a single language for frontend and backend. This type of talk has been going on for as long as I’ve been a developer. I’ve worked in such solutions: C#, Java or C++ as the single language. I’ve seen JavaScript on both client and server. This can be very helpful for people starting out. They use the same language that they are very familiar with in both settings. For one team this can be a good thing and help them deliver.&lt;/p&gt;

&lt;p&gt;However compiling Java or C# to JavaScript have had some interesting challenges. The debugging experience, error handling, diagnosing errors. Source maps and other tools have helped make this less of an issue. Though since most frontend web libraries are written in JavaScript, it is often better to be familiar with JavaScript.&lt;/p&gt;

&lt;p&gt;Writing JavaScript on the backend has had some challenges. The developers I’ve worked with have had it easier to work with C# (when it comes to deliver stable features). For simple services, JavaScript can be a good choice. There are also more mature libraries for Java and C# that fits more of server side development (for historical reasons).&lt;/p&gt;

&lt;p&gt;Limiting yourself to one language also means limiting your recruitment base. Once people have started working, they usually pick up the other commonly used languages (in order to be able to modify other parts).&lt;/p&gt;

&lt;h2 id=&quot;hiring-different-style-of-programmers&quot;&gt;Hiring different style of programmers&lt;/h2&gt;

&lt;p&gt;Developers will find their own style of coding as they mature. Different people will work in different ways. Some write text then code, some draw diagrams then code, some tests then code, et.c.. When you hire people, most probably they will not be familiar with your domain and your standards. Just because they are not familiar with your preferred style, they can still prove useful (to your organization).&lt;/p&gt;

&lt;h3 id=&quot;consider-frontend-vs-backend&quot;&gt;Consider frontend vs backend&lt;/h3&gt;

&lt;p&gt;When I started out, I didn’t hear about this distinction, while today it’s a big division. JavaScript was a loathed niche language. I think the primary reasons was that it was very difficulty to write working code. One big reason was due to browser differences between versions and vendors. Another reason was that linters was not in use. There are some gotchas that can be difficult to track down (unless you use linter). Then came jQuery (to smooth out the differences). Then came browser standardization.&lt;/p&gt;

&lt;p&gt;Note however, if you write mobile apps or desktop applications, you can do that fully in C#.&lt;/p&gt;

&lt;h3 id=&quot;hiring-people&quot;&gt;Hiring people&lt;/h3&gt;

&lt;p&gt;How do you hire ok frontend web people? You go with JavaScript (since that’s the mainstream web frontend language right now).&lt;/p&gt;

&lt;p&gt;How do you hire ok backend people? You go with Java, Python, C# or even PHP (since they are the mainstream backend languages right now).&lt;/p&gt;

&lt;p&gt;How do you find great developers? One way is to go a bit niche. Interested developers will want to learn new things. If you have ‘cool’ tech you can &lt;a href=&quot;https://blog.ploeh.dk/2015/12/03/the-rules-of-attraction-language/&quot;&gt;attract interested developers&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;niche-language&quot;&gt;Niche language&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;possible to hire great developers who have sought out the language in order to level up&lt;/li&gt;
  &lt;li&gt;harder to convince other people that they can work in such a language&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;very-common-language&quot;&gt;very common language&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;easier to recruit people directly from school (since it’s common, schools target the language)&lt;/li&gt;
  &lt;li&gt;easier to recruit people from other parts of the industry&lt;/li&gt;
  &lt;li&gt;normal people, going to work and then going home, also called 9-5:ers or &lt;a href=&quot;https://www.hanselman.com/blog/DarkMatterDevelopersTheUnseen99.aspx&quot;&gt;dark matter developers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;where-should-you-have-homogeneity&quot;&gt;Where should you have homogeneity&lt;/h2&gt;

&lt;p&gt;You need people to make sure that components (libraries/services) have internally uniform style. Having a good structure will make it easier to read the code. What kind of structure? I would say that it depends on the project and people working on it.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why I prefer React over Angular</title>
      <link>https://assertfail.gewalli.se/2018/09/09/Why-I-prefer-React-over-Angular.html</link>
      <pubDate>Sun, 09 Sep 2018 08:18:42 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/09/09/Why-I-prefer-React-over-Angular</guid>
      <description>&lt;ul&gt;
  &lt;li&gt;React has a smaller scope than Angular.&lt;/li&gt;
  &lt;li&gt;I’ve found that my coworkers have an easier time grokking React than Angular: React contains fewer concepts than Angular.&lt;/li&gt;
  &lt;li&gt;Angular can sometimes make implementation of custom behaviors require a lot of deep knowledge (of Angular). For instance when implementing a custom dropdown or a checkbox.&lt;/li&gt;
  &lt;li&gt;If you are cheeky, you could say:
    &lt;blockquote&gt;
      &lt;p&gt;Angular is a somewhat over engineered platform, while React is sometimes used to create over engineered apps.&lt;/p&gt;
    &lt;/blockquote&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My personal opinion is that as long as you can use the existing behavior of the standard components (buttons, checkboxes, dropdowns et.c.), Angular can be a good choice. I’ve yet to have been in a situation where management will settle on not implementing something just because it will create additional complexity: Why my feeling is that if you are given the choice, you should go for React.&lt;/p&gt;

&lt;p&gt;I’ve used knockout for several years as well (and still like it as a library). My biggest issue is that I’ve found that the documentation (and the API) leads people into using computed properties when they don’t need to. I would say that knockout is more well thought out than Angular (due to the smaller scope of the project). Due to the popularity of React compared to Knockout, I would guess that React would be a more natural choice.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>F# 2 years later</title>
      <link>https://assertfail.gewalli.se/2018/09/08/fsharp-2-years-later.html</link>
      <pubDate>Sat, 08 Sep 2018 19:30:26 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/09/08/fsharp-2-years-later</guid>
      <description>&lt;h2 id=&quot;whats-the-lure-of-f&quot;&gt;What’s the lure of F#?&lt;/h2&gt;

&lt;p&gt;The main lure of F# is that it’s a surprisingly competent &lt;a href=&quot;https://en.wikipedia.org/wiki/ML_(programming_language)&quot;&gt;ML&lt;/a&gt; style language that transcends some of the limitations of &lt;a href=&quot;https://en.wikipedia.org/wiki/Common_Intermediate_Language&quot;&gt;CIL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;From my point of view, the main distinguishing feature for F# is &lt;a href=&quot;https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters&quot;&gt;Statically Resolved Type Parameters&lt;/a&gt;. It’s a feature you don’t want to see in business code (same as reflection in C#), but something that enables libraries to take F# to &lt;a href=&quot;https://github.com/fsprojects/FSharpPlus&quot;&gt;the next level&lt;/a&gt;. Compare this to &lt;a href=&quot;http://learnyouahaskell.com/types-and-typeclasses&quot;&gt;type classes&lt;/a&gt; in Haskell and what is called &lt;a href=&quot;https://v1.realworldocaml.org/v1/en/html/functors.html&quot;&gt;functors&lt;/a&gt; in OCaml.&lt;/p&gt;

&lt;h2 id=&quot;what-has-delighted-me&quot;&gt;What has delighted me?&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;The editor tooling for F# has grown more stable.&lt;/li&gt;
  &lt;li&gt;That F# has another perspective (compared to C#).&lt;/li&gt;
  &lt;li&gt;Type providers can simplify one-off “scripting”.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-has-been-annoying&quot;&gt;What has been annoying?&lt;/h2&gt;

&lt;p&gt;Personally most of the pain points have been in dealing with .net core.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Type providers have recently (2018/05/08) &lt;a href=&quot;https://blogs.msdn.microsoft.com/dotnet/2018/05/08/f-language-and-tools-update-for-visual-studio-2017-version-15-7/&quot;&gt;been fixed to work in .net core&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Using libraries intended to be consumed in C# that uses &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Microsoft.Extensions.DependencyInjection&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Microsoft.Extensions.Options&lt;/code&gt; requires ceremony to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are minor things. For the most part I don’t need dependency injection heavy code in the F# I’ve been writing.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>What about Identity Server?</title>
      <link>https://assertfail.gewalli.se/2018/09/06/What-about-Identity-Server.html</link>
      <pubDate>Thu, 06 Sep 2018 05:52:29 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/09/06/What-about-Identity-Server</guid>
      <description>&lt;h2 id=&quot;my-experience-using-identityserver4&quot;&gt;My experience using IdentityServer4&lt;/h2&gt;

&lt;p&gt;See &lt;a href=&quot;https://github.com/IdentityServer/IdentityServer4&quot;&gt;Identity Server&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’ve (and others in my team) have worked on a project using Identity Server 4 since early 2017.&lt;/p&gt;

&lt;h3 id=&quot;what-lead-us-there&quot;&gt;What lead us there?&lt;/h3&gt;

&lt;p&gt;The main reason why we started to consider it was due to the main business goals:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;To have a JWT provider that enables a single page application to communicate with a plethora of micro services&lt;/li&gt;
  &lt;li&gt;To use an existing solutions. The reasoning being that if the company used existing software, that would create a dependency on that software instead of senior developers.&lt;/li&gt;
  &lt;li&gt;To have a single provider of identity and accounts.&lt;/li&gt;
  &lt;li&gt;To have the provider of identity and accounts as a micro service.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We noticed that asp.net identity together with Identity Server satisfies a lot of the specific business requirements.&lt;/p&gt;

&lt;h3 id=&quot;initial-experience&quot;&gt;Initial experience&lt;/h3&gt;

&lt;p&gt;We got something working quite fast that satisfied the requirements. We had an login, authentication and OAuth solution within days.&lt;/p&gt;

&lt;h3 id=&quot;what-happened-next&quot;&gt;What happened next&lt;/h3&gt;

&lt;p&gt;Our first stumbling block was that there was a need for a JSON API to use with a back-office GUI that needed to be able to display accounts. Part of the trouble was that we needed mixed authentication: JWT and cookies. That turned out to be somewhat difficult with asp.net core mvc 1, but we eventually solved it. In asp.net core mvc 2 this has become much easier to configure.&lt;/p&gt;

&lt;p&gt;Our next stumbling block was that there was a requirement that we could have a sign in flow from the single page application without disrupting the shopping experience. That requirement turned out to be more difficult to satisfy than the other requirements. In order to satisfy that we needed to dive deep into Identity Server in order to bend the opinions of Identity Server to the requirements.&lt;/p&gt;

&lt;h3 id=&quot;conclusions&quot;&gt;Conclusions&lt;/h3&gt;

&lt;p&gt;The assumption that we didn’t need senior developers was faulty. Once we deviated from the assumptions made by Identity Server, we had to involve senior developers in order to implement the business requirements using a mix of OAUTH and other protocols.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Working on dotnet core on Mac OS X part 2</title>
      <link>https://assertfail.gewalli.se/2018/09/05/Working-on-dotnet-core-on-Mac-OS-X-part-2.html</link>
      <pubDate>Wed, 05 Sep 2018 18:48:47 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/09/05/Working-on-dotnet-core-on-Mac-OS-X-part-2</guid>
      <description>&lt;p&gt;After writing the &lt;a href=&quot;https://assertfail.gewalli.se/2018/02/17/Working-on-dotnet-core-on-Mac-OS-X.html&quot;&gt;previous post&lt;/a&gt; about getting some of the infrastructure working for non Windows, I’ve seen better ways of getting it to work. In particular we have seen the use of &lt;a href=&quot;https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/master/netfx.props&quot;&gt;netfx.props&lt;/a&gt; as seen in &lt;a href=&quot;https://github.com/fsprojects/FSharp.TypeProviders.SDK&quot;&gt;FSharp.TypeProviders.SDK&lt;/a&gt;. Then you add the following to your csproj or fsproj file:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-XML&quot;&gt;&amp;lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&amp;gt;
  &amp;lt;Import Project=&quot;..\netfx.props&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;as can be seen in &lt;a href=&quot;https://github.com/fsprojects/FSharp.TypeProviders.SDK/blob/master/src/FSharp.TypeProviders.SDK.fsproj&quot;&gt;FSharp.TypeProviders.SDK.fsproj&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>What makes for happy C#?</title>
      <link>https://assertfail.gewalli.se/2018/03/16/What-makes-for-happy-c.html</link>
      <pubDate>Fri, 16 Mar 2018 10:51:45 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/03/16/What-makes-for-happy-c</guid>
      <description>&lt;p&gt;One of the questions I’ve started asking myself is what makes for happy C#? After a few years getting a bit more understanding of ML like languages like F# I’ve started to realize that C# is not built to write the kind of code that you write in an ML. Instead, you are happier when you embrace the Ruby-like patterns in C#. If you look at C# sort of like a typed Ruby like language: Object orientation, mutability first and meta programming using reflection. When you see that this is shared between the two languages then more things make sense. I’ve noticed that good Ruby code translates very easily to good C# (although &lt;a href=&quot;https://github.com/wallymathieu/csharp_ukanren&quot;&gt;not always&lt;/a&gt;). Same is not true for good F# or Haskell.&lt;/p&gt;

&lt;p&gt;Good Ruby code tries to keep a nice clean programming surface for the user (of a library).&lt;/p&gt;

&lt;p&gt;Ruby is very object oriented. C# shares this trait since it is very adamant in that you need to have a class in order to have any code. Extension methods can be used to make a sort of monkey patching in C#. Monkey patching in Ruby can be dangerous, but applied right can help clean up your code. Same is true for extension methods. I would call a nice extension method to be polite: It only uses the extended type and any parameters sent in.&lt;/p&gt;

&lt;h2 id=&quot;architecture-that-fits-c-and-ruby&quot;&gt;Architecture that fits C# and Ruby&lt;/h2&gt;

&lt;p&gt;Having smaller libraries with their own solution means that it’s easier for people to reason about the code. There are some downsides of this approach though: You need to keep libraries in lockstep when introducing breaking changes during a larger refactoring. You need to be careful about what kind of public API surface you accidentally introduce. It’s easy to introduce leaky concepts (concepts and abstracts that require you to write code to deal with a specific concept in many different places).&lt;/p&gt;

&lt;p&gt;Writing micro services is another way of splitting up your code base. However, you need to know when it’s worth putting something in a separate library and when it’s useful to have it in a service. A service can easily introduce latency and give you bad performance. If you try to follow &lt;a href=&quot;https://martinfowler.com/bliki/BoundedContext.html&quot;&gt;Martin Fowlers advice&lt;/a&gt; and apply that to your microservices, you can have relatively separate services (that they don’t cause performance issues because of hard coupling requiring many buss events or http calls to complete actions).&lt;/p&gt;

&lt;p&gt;Having relatively small services (but not to small), means that it can be easier to reason about mutable first procedural code. I find it very difficult to try to reason about large a large code base with mutable instances.&lt;/p&gt;

&lt;h2 id=&quot;deviations&quot;&gt;Deviations&lt;/h2&gt;

&lt;p&gt;Since we have static analysis available through the compiler, we can use that to define value types and wrap strings, integers, et.c. when dealing with many different small id-types or values that are easy to mix up. I.e. value types of a single value. In Haskell you call this a &lt;a href=&quot;https://wiki.haskell.org/Newtype&quot;&gt;Newtype&lt;/a&gt;. In C# you need to do a bit &lt;a href=&quot;https://github.com/NewtonsoftJsonExt/Saithe/blob/master/CSharpTypes/ProductId.cs&quot;&gt;more work&lt;/a&gt;. If you have many of these types, you might want to create a &lt;a href=&quot;https://en.wikipedia.org/wiki/Text_Template_Transformation_Toolkit&quot;&gt;t4-template&lt;/a&gt; for it. In Ruby you would (due to the dynamic nature of the language) not need a template for it.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Working on dotnet core on Mac OS X</title>
      <link>https://assertfail.gewalli.se/2018/02/17/Working-on-dotnet-core-on-Mac-OS-X.html</link>
      <pubDate>Sat, 17 Feb 2018 12:13:55 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/02/17/Working-on-dotnet-core-on-Mac-OS-X</guid>
      <description>&lt;p&gt;One thing I neglegted to mention was that there isn’t really out of the box editor support for targeting both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;net45&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstandard1.6&lt;/code&gt; (or higher versions).&lt;/p&gt;

&lt;p&gt;My standard workaround for this have been to only target netstandard1.6 or lower for most of the relevant assemblies that I work on a day to day basis on. This works for most of the internal libraries since we deploy either &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netcoreapp1.1&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netcoreapp2.0&lt;/code&gt; to Azure.&lt;/p&gt;

&lt;p&gt;For libraries that are supposed to be &lt;a href=&quot;https://github.com/gusty/FSharpPlus/blob/master/src/FSharpPlus/FSharpPlus.fsproj#L4&quot;&gt;consumed by a wider set&lt;/a&gt; that has been a bit of a pain to edit on Mac OS X.&lt;/p&gt;

&lt;p&gt;If you try to open a .net core project that uses paket, the workaround to edit projects in Visual Studio for Mac is to &lt;a href=&quot;https://developercommunity.visualstudio.com/content/problem/189500/visual-studio-for-mac-can-not-build-net-core-proje.html?childToView=191340&quot;&gt;disable automatic package restore&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The final workaround to be able to work &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;net45&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstandard1.6&lt;/code&gt; dotnet core project on Mac OS X is to apply &lt;a href=&quot;https://github.com/enricosada/dotnet-proj-info/blob/master/.travis.yml#L6-L8&quot;&gt;@enricosada’s fix&lt;/a&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bash_profile&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;FrameworkPathOverride&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;which mono&lt;span class=&quot;si&quot;&gt;))&lt;/span&gt;/../lib/mono/4.5/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This has made it possible to open for instance &lt;a href=&quot;https://github.com/giraffe-fsharp/Giraffe&quot;&gt;Giraffe&lt;/a&gt; without doing any &lt;a href=&quot;https://github.com/wallymathieu/Giraffe/tree/mono&quot;&gt;other workaround&lt;/a&gt; to have it working.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Dotnet core a year later</title>
      <link>https://assertfail.gewalli.se/2018/01/19/Dotnet-core-a-year-later.html</link>
      <pubDate>Fri, 19 Jan 2018 20:21:06 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2018/01/19/Dotnet-core-a-year-later</guid>
      <description>&lt;p&gt;We asked the other developers in December 2016 what they wanted to work on. They said that they wanted to work on &lt;a href=&quot;https://github.com/dotnet/core/blob/master/release-notes/1.0/1.0.0.md&quot;&gt;dotnet core&lt;/a&gt; and &lt;a href=&quot;https://github.com/aspnet/Mvc&quot;&gt;MVC&lt;/a&gt;. I was a bit hesitant at first since that would imply using something relatively new to base the business on. &lt;a href=&quot;https://github.com/tfsjohan&quot;&gt;A coworker&lt;/a&gt; at the time did inject that he was using it in production already.&lt;/p&gt;

&lt;p&gt;It has been an interesting journey. From json + xproj to a new csproj format. The nice thing about the new format is that it includes packages in the csproj. The file format has been cleaned up (so that we no longer need to use &lt;a href=&quot;https://github.com/Albacore/albacore/wiki/ProjectLint&quot;&gt;albacore&lt;/a&gt; scripts to detect csproj issues. Using NuGet is less painful compared to previously (I feel less of a need for &lt;a href=&quot;fsprojects.github.io/Paket/&quot;&gt;paket&lt;/a&gt; but NuGet still have catching up to do). Though, there is still a bit of weirdness that make it difficult for people. I’m helping a dev get into asp.net Mvc 2. Due to lots of different blogs about asp.net Mvc, asp.net Mvc Core 1, asp.net Mvc Core 2. This is similar to what we see on for instance differences between different minor versions of Angular. As the documentation for Mvc on microsoft sites is quite good, it becomes less of an issue than for NG.&lt;/p&gt;

&lt;p&gt;We have used &lt;a href=&quot;https://docs.microsoft.com/en-us/ef/core/&quot;&gt;EF Core 1-2&lt;/a&gt;. I’ve previously used &lt;a href=&quot;http://nhibernate.info/&quot;&gt;NHibernate&lt;/a&gt;. EF does not perform as well as NHibernate but is easier to start out with. I wish we had used &lt;a href=&quot;https://github.com/StackExchange/Dapper&quot;&gt;Dapper&lt;/a&gt; since it’s easier to get performant and having to write SQL discourages the use of more complicated schemas. EF migrations doesn’t feel as elegant as some of the other &lt;a href=&quot;https://github.com/fluentmigrator/fluentmigrator&quot;&gt;migration frameworks&lt;/a&gt;, it does however work well enough due to the fact that it can be used on the command line.&lt;/p&gt;

&lt;p&gt;What has worked well has been to use &lt;a href=&quot;https://github.com/domaindrivendev/Swashbuckle.AspNetCore&quot;&gt;Swashbuckle.AspNetCore&lt;/a&gt;. It helps with keeping documentation in sync and cuts down on the need for hand written API cruft.&lt;/p&gt;

&lt;p&gt;A lot of the API’s have been improved in asp.net core. Default dependency injection and logging abstraction, et.c. has made the C# code more pleasant to work with. That the configuration is using dependency injection instead of global values makes it easier to reason about configuration.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Running dotnet core 1.1 on appveyor and travis</title>
      <link>https://assertfail.gewalli.se/2017/01/29/Running-dotnet-core-11-on-appveyor-and-travis.html</link>
      <pubDate>Sun, 29 Jan 2017 08:05:29 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2017/01/29/Running-dotnet-core-11-on-appveyor-and-travis</guid>
      <description>&lt;p&gt;I wanted to see the state of EntityFramework on core. Turns out that it works on other platforms than Windows! NHibernate worked on mono as well as Windows, and now Entity Framework has caught up with that. However, EF Core is still somewhat limited as a ORM. This should not matter much if you are writing relatively simple SQL (LINQ) and have few relationships (so that you have less of a need for more advanced constructs). Many business apps do fall into this category if the requirements are made simple and clear (one source of complexity is fuzzy requirements leading to confused code).&lt;/p&gt;

&lt;h2 id=&quot;appveyor&quot;&gt;appveyor&lt;/h2&gt;

&lt;p&gt;Running .net core on appveyor turned out to be quite easy. They have already installed .net core 1.1 on their servers. All you need to do is to run the dotnet commands.&lt;/p&gt;

&lt;h2 id=&quot;net-core-official-travis-documentation&quot;&gt;.net core official .travis documentation&lt;/h2&gt;

&lt;p&gt;The first thing I tried was to try out a configuration based on the &lt;a href=&quot;https://docs.travis-ci.com/user/languages/csharp/#Choosing-runtime-and-version-to-test-against&quot;&gt;travis documentation&lt;/a&gt; about running .net core on travis. This should work for a 1.0.0 version, however, I had dependencies on core 1.1.0. Note that this type of configuration is also used by &lt;a href=&quot;https://github.com/dotnet/docs/blob/master/.travis.yml&quot;&gt;Enrico Sada in the dotnet docs&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;dotnet &lt;span class=&quot;nb&quot;&gt;test
&lt;/span&gt;Project Tests &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;.NETCoreApp,Version&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;v1.1&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; was previously compiled. Skipping compilation.
The specified framework &lt;span class=&quot;s1&quot;&gt;&apos;Microsoft.NETCore.App&apos;&lt;/span&gt;, version &lt;span class=&quot;s1&quot;&gt;&apos;1.1.0&apos;&lt;/span&gt; was not found.
  - Check application dependencies and target a framework version installed at:
      /usr/share/dotnet/shared/Microsoft.NETCore.App
  - The following versions are installed:
      1.0.0
  - Alternatively, &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;the framework version &lt;span class=&quot;s1&quot;&gt;&apos;1.1.0&apos;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;trying-other-versions-of-dotnet-core-on-travis&quot;&gt;Trying other versions of dotnet core on travis&lt;/h2&gt;

&lt;p&gt;I tried with a later travis dotnet version:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dotnet: 1.0.0-preview2.1-003155
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This resulted in:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;dotnet &lt;span class=&quot;nb&quot;&gt;test
&lt;/span&gt;Project Tests &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;.NETCoreApp,Version&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;v1.0&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; was previously compiled. Skipping compilation.
The specified framework &lt;span class=&quot;s1&quot;&gt;&apos;Microsoft.NETCore.App&apos;&lt;/span&gt;, version &lt;span class=&quot;s1&quot;&gt;&apos;1.1.0&apos;&lt;/span&gt; was not found.
  - Check application dependencies and target a framework version installed at:
      /usr/share/dotnet/shared/Microsoft.NETCore.App
  - The following versions are installed:
      1.1.0-preview1-001100-00
  - Alternatively, &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;the framework version &lt;span class=&quot;s1&quot;&gt;&apos;1.1.0&apos;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;trying-the-scripts-from-ef-core&quot;&gt;Trying the scripts from EF Core&lt;/h2&gt;

&lt;p&gt;I tried to run a setup based on the &lt;a href=&quot;https://github.com/aspnet/EntityFramework/blob/dev/.travis.yml&quot;&gt;.travis.yml in the EF repository&lt;/a&gt;. The scripts failed while running locally, so I abandonded that attempt early (perhaps they need environment in the repository that I’m missing).&lt;/p&gt;

&lt;h2 id=&quot;trying-out-scripts-from-blog&quot;&gt;Trying out scripts from blog&lt;/h2&gt;

&lt;p&gt;I tried running scripts found on &lt;a href=&quot;http://andrewlock.net/adding-travis-ci-to-a-net-core-app/&quot;&gt;Andrew Locks blog&lt;/a&gt;. These failed with:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/home/travis/build/wallymathieu/entity-framework-studies/.dotnetcli/sdk/1.0.0-rc4-004706/NuGet.targets&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;210,5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: warning MSB3202: The project file &lt;span class=&quot;s2&quot;&gt;&quot;/home/travis/build/wallymathieu/entity-framework-studies/Web/Web.xsproj&quot;&lt;/span&gt; was not found. &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;/home/travis/build/wallymathieu/entity-framework-studies/entity-framework-studies.sln]
/home/travis/build/wallymathieu/entity-framework-studies/.dotnetcli/sdk/1.0.0-rc4-004706/NuGet.targets&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;210,5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: warning MSB3202: The project file &lt;span class=&quot;s2&quot;&gt;&quot;/home/travis/build/wallymathieu/entity-framework-studies/Tests/Tests.xsproj&quot;&lt;/span&gt; was not found. &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;/home/travis/build/wallymathieu/entity-framework-studies/entity-framework-studies.sln]
/home/travis/build/wallymathieu/entity-framework-studies/.dotnetcli/sdk/1.0.0-rc4-004706/NuGet.targets&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;97,5&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: warning : Unable to find a project to restore! &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;/home/travis/build/wallymathieu/entity-framework-studies/entity-framework-studies.sln]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/home/travis/build/wallymathieu/entity-framework-studies/Tests/Tests.xproj&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;7,3&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;: error MSB4019: The imported project &lt;span class=&quot;s2&quot;&gt;&quot;/home/travis/build/wallymathieu/entity-framework-studies/.dotnetcli/sdk/1.0.0-rc4-004706/Microsoft/VisualStudio/v14.0/DotNet/Microsoft.DotNet.Props&quot;&lt;/span&gt; was not found. Confirm that the path &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the &amp;lt;Import&amp;gt; declaration is correct, and that the file exists on disk.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Probably due to being for a previous version of dotnet core.&lt;/p&gt;

&lt;h2 id=&quot;trying-out-install-instructions&quot;&gt;Trying out install instructions&lt;/h2&gt;

&lt;p&gt;Instead of trying out travis specific instructions I tried to copy the &lt;a href=&quot;https://www.microsoft.com/net/core#linuxubuntu&quot;&gt;instructions found for installing net core on ubuntu&lt;/a&gt;. Since these instructions are probably maintained, they worked without a glitch. I ended up with this version of .travis.yml:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;csharp&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;required&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;dist&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;trusty&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;addons&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;apt&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;packages&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;gettext&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;libcurl4-openssl-dev&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;libicu-dev&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;libssl-dev&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;libunwind8&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;zlib1g&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;global&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;DOTNET_SKIP_FIRST_TIME_EXPERIENCE&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;true&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;DOTNET_CLI_TELEMETRY_OPTOUT&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;mono&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;latest&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;linux&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;before_install&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo sh -c &apos;echo &quot;deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main&quot; &amp;gt; /etc/apt/sources.list.d/dotnetdev.list&apos;&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 417A0893&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo apt-get update&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;install&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo apt-get install dotnet-dev-1.0.0-preview2.1-003177&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;dotnet restore&lt;/span&gt;
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;update&quot;&gt;Update&lt;/h2&gt;

&lt;p&gt;Note that the version I referenced while trying out the install documentation is higher than the version I tried out. Trimming the yml resulted in the following travis yml:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;csharp&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;sudo&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;false&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;dist&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;trusty&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;dotnet&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;1.0.0-preview2.1-003177&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;mono&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;latest&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;os&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;linux&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; 
&lt;span class=&quot;nn&quot;&gt;...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>The usefulness of generalized regular expressions</title>
      <link>https://assertfail.gewalli.se/2016/10/12/The-usefulness-of-generalized-regular-expressions.html</link>
      <pubDate>Wed, 12 Oct 2016 18:30:07 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/10/12/The-usefulness-of-generalized-regular-expressions</guid>
      <description>&lt;p&gt;It’s not obvious at first thought that there are applications for generalized regular expression engines. During my career, the regular kind has been the most prevalent kind. For certain problems, there is a simple pattern matching, that regular expressions excel at. For instance, in the case when you have a matrix with relatively regular content, it can be thought of as a general type of expressions. I’ve created the library &lt;a href=&quot;https://github.com/wallymathieu/Zander&quot;&gt;Zander&lt;/a&gt; to help with that type of problem.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Should you work with old technologies?</title>
      <link>https://assertfail.gewalli.se/2016/08/15/Should-you-work-with-old-technologies.html</link>
      <pubDate>Mon, 15 Aug 2016 05:49:37 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/08/15/Should-you-work-with-old-technologies</guid>
      <description>&lt;h2 id=&quot;why-should-a-coder-avoid-old-technologies&quot;&gt;Why should a coder avoid old technologies?&lt;/h2&gt;

&lt;h3 id=&quot;large-complicated-systems-are-often-written-in-older-technologies&quot;&gt;Large complicated systems are often written in older technologies&lt;/h3&gt;

&lt;p&gt;Newer technologies can mean assignments with fewer lines of code and more greenfield development. Since the amount of code is proportional to the amount of time and people spent working on that code. Greenfield development is easier than working with millions of lines of code. It can however be an interesting challenge to &lt;a href=&quot;https://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052&quot;&gt;rewrite an older system&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;market-value&quot;&gt;Market value&lt;/h3&gt;

&lt;p&gt;In order to sell consulting services, many people will push for new tech.&lt;/p&gt;

&lt;p&gt;Since the market value of a coder is related to experience with the current technologies in use, knowing and working with new technologies is a good policy to stay competitive. This means that even regular employees will push for new technologies.&lt;/p&gt;

&lt;p&gt;New tech may shift how you develop. For instance JavaScript performance improvements have made it feasible to run more logic browser side, causing a drive towards writing code more like regular server side code using ko, angular, react et.c.. Virtual machines performance that is close to native performance (&lt;a href=&quot;https://en.wikipedia.org/wiki/Java_virtual_machine&quot;&gt;JVM&lt;/a&gt;, &lt;a href=&quot;https://en.wikipedia.org/wiki/Common_Language_Runtime&quot;&gt;CLR&lt;/a&gt;) and the use of GC can simplify a lot of code (easier to work with) and create demand for different skills.&lt;/p&gt;

&lt;h3 id=&quot;writing-new-libraries&quot;&gt;Writing new libraries&lt;/h3&gt;

&lt;p&gt;Working in mature technologies can mean that the trailblazers have solved many of the problems. What’s left is to try to get patches for potentially unmaintained libraries. If you are one of the trailblazers you can increase your market value by providing a library that many people use (thus people get to know your name). You will need to market the library in order to gain attract developers to write pull requests and contribute issues. Good way of marketing a library is to present it during meetups or conferences.&lt;/p&gt;

&lt;h2 id=&quot;why-should-a-coder-avoid-untested-technologies&quot;&gt;Why should a coder avoid untested technologies?&lt;/h2&gt;

&lt;h3 id=&quot;stability&quot;&gt;Stability&lt;/h3&gt;

&lt;p&gt;New code without tests or insufficient test coverage has a greater probability of bugs. As development of new things progress, the API’s will change until they mature. The maintainers may wish to iron out quirks from the API’s.&lt;/p&gt;

&lt;h3 id=&quot;learning-overhead&quot;&gt;Learning overhead&lt;/h3&gt;

&lt;p&gt;If the new technology is radically different from the old (angular vs jQuery), the amount of time spent learning impacts your ability to deliver. This cost can be sufficiently small if you know that you will have a lot of things to deliver (i.e. you know that you will spend enough time on the code). In order to avoid information overload you might want to have a mixture of known and unknown. Some developers are better at grokking new libraries and languages than others, but you still need to think about the team.&lt;/p&gt;

&lt;h3 id=&quot;trailblazer-moving-on-to-greener-pastures&quot;&gt;Trailblazer moving on to greener pastures&lt;/h3&gt;

&lt;p&gt;A trailblazer might want to move on to the next language after creating a few new library. Or if the technology becomes somewhat popular (without people that want to help out) the maintainer might not have enough time on their hands to support the library. This means that some libraries might become abandoned. Talk with the original author, sometimes they can be convinced to pass on the keys to NuGet, github et.c. as long as you are willing to help maintain the lib and review pull requests.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>What does technical debt mean for a project?</title>
      <link>https://assertfail.gewalli.se/2016/07/02/What-does-technical-debt-mean-for-a-project.html</link>
      <pubDate>Sat, 02 Jul 2016 06:20:29 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/07/02/What-does-technical-debt-mean-for-a-project</guid>
      <description>&lt;p&gt;Technical debt is a concept that suggests that the cost of developing software has been postponed. For instance it can be the conscious act of delivering features while taking shortcuts (in order to get them delivered at a certain date).&lt;/p&gt;

&lt;h2 id=&quot;cost-in-time-related-to-technical-debt&quot;&gt;Cost in time related to technical debt&lt;/h2&gt;

&lt;p&gt;When changing a component, the amount of bugs introduced is often related to technical debt of that components. Higher technical debt means greater likelihood of bugs.&lt;/p&gt;

&lt;p&gt;The time to resolve various issues is related to the technical debt. Technical debt will express itself in the sense that some tasks that should be simple to complete take a lot of time to finish.&lt;/p&gt;

&lt;p&gt;Estimation: There is a risk that after something looks implemented, there are Y number of bugs to be found. It may mean that after one task seems to be done, issues and bugs related to the component will crop up where each issue take on average X amount of time to resolve.&lt;/p&gt;

&lt;p&gt;If nothing is done to pay off technical debt, you have a situation where after an issue A1 you have Y bugs. Each bug takes an average X amount of time to resolve. After each bugfix there is a risk of a new bug. Since the technical debt is not repaid, we see that the average time X will increase. It means that you have a similar situation as when a person with a loan allows the interest rate to accumulate (ie debt increases).&lt;/p&gt;

&lt;h2 id=&quot;how-do-you-achieve-profitability-in-a-project-with-high-technical-debt&quot;&gt;How do you achieve profitability in a project with high technical debt?&lt;/h2&gt;

&lt;p&gt;Lower customer requirements in existing parts of the system. If you lack people that can hold off customer demands for changes in existing parts (requirements that entail greater complexity), customer requirements will drive increased costs.&lt;/p&gt;

&lt;p&gt;Build separate modules where technical debt can be kept low. However, this can mean that the greatest cost (time spent) will be related to integration code (code to connect between things) between to connect modules of low technical debt with modules of high technical debt. However as long as you avoid changing modules with high technical debt, you can avoid cost increases.&lt;/p&gt;

&lt;p&gt;Hire people that take a long term view (see the section about how to handle technical debt) in order to pay of the loan over time. Together with the developers, make sure that they create a long term plan for how to reduce the debt.&lt;/p&gt;

&lt;h2 id=&quot;what-does-technical-debt-mean-for-people-working-in-the-project&quot;&gt;What does technical debt mean for people working in the project?&lt;/h2&gt;

&lt;p&gt;The complexity and difficulties to deliver, can along with demands for quick deliveries create severe stress: Morality is reduced. This means that the probability of people leaving the project increases. The likelihood that people within the project burnout increases. What does this cost? &lt;a href=&quot;http://www.dn.se/ekonomi/400-000-kronor-kostnaden-for-en-utbrand-medarbetare/&quot;&gt;According to DN&lt;/a&gt;, it can end up at about 400 000 SEK (ca 40 000 EUR).&lt;/p&gt;

&lt;h2 id=&quot;how-do-you-handle-technical-debt&quot;&gt;How do you handle technical debt?&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Doing code reviews with experienced developers&lt;/li&gt;
  &lt;li&gt;Automatic testing to reduce the likelihood of regression&lt;/li&gt;
  &lt;li&gt;Requirements management: ensure that the requirements reduce complexity (eg by having a dialogue to arrive at simpler solutions)&lt;/li&gt;
  &lt;li&gt;By identifying the problem through different tools and working to isolate or remove the parts of the code that need to be changed due to customer requirements&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://martinfowler.com/books/refactoring.html&quot;&gt;Refactor&lt;/a&gt; parts that are covered by tests&lt;/li&gt;
  &lt;li&gt;Create new modules that &lt;a href=&quot;http://www.martinfowler.com/bliki/StranglerApplication.html&quot;&gt;strangle old parts of the system&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;how-do-you-identify-the-problem&quot;&gt;How do you identify the problem?&lt;/h3&gt;

&lt;p&gt;Static code analysis can help identify problem areas. For example .net are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.ndepend.com/&quot;&gt;NDepend&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.sonarqube.org/&quot;&gt;sonarqube&lt;/a&gt; is able to analyse C# code (with some effort).&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.jetbrains.com/resharper/features/command-line.html&quot;&gt;Resharper&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Selected rules in StyleCop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Test coverage percentage can give you a picture of the areas where changes have higher probability of regression (ie can result in extra work).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Common enterprise architectures</title>
      <link>https://assertfail.gewalli.se/2016/06/03/Common-enterprise-architectures.html</link>
      <pubDate>Fri, 03 Jun 2016 18:24:52 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/06/03/Common-enterprise-architectures</guid>
      <description>&lt;p&gt;Some patterns I’ve usually encountered while working code bases written by .net developers. You can also read more on &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ee658117.aspx&quot;&gt;msdn&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;domain-driven-design-inspired&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Domain-driven_design&quot;&gt;Domain driven design&lt;/a&gt; inspired&lt;/h2&gt;

&lt;p&gt;Usually you find classes with postfix name like:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Repository : List like interface for working with persisted data. Usually state of fetched objects is tracked, so you can do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customerContext.Save()&lt;/code&gt; to persist changes to objects.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Service_(systems_architecture)&quot;&gt;Service&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;related-concepts&quot;&gt;Related concepts&lt;/h3&gt;

&lt;p&gt;People are often confused by “Unit of work” also mentioned in connection to these patterns. Many OR-mappers implement the repository pattern. Popular libraries include &lt;a href=&quot;http://www.asp.net/entity-framework&quot;&gt;Entity Framework&lt;/a&gt;, &lt;a href=&quot;http://nhibernate.info/&quot;&gt;NHibernate&lt;/a&gt; and &lt;a href=&quot;https://ravendb.net/&quot;&gt;RavenDB&lt;/a&gt; (library and database).&lt;/p&gt;

&lt;h3 id=&quot;key-concept&quot;&gt;Key concept&lt;/h3&gt;

&lt;p&gt;The key point of DDD is ubiquitous Language. Being able to have roughly the same type of concepts as the users can be very helpful.&lt;/p&gt;

&lt;h2 id=&quot;dal&quot;&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/library/ee658127.aspx&quot;&gt;DAL&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;This type of architecture is quite simple. The main benefit of it is that it’s easy for people to grok. This type of architecture is not as popular anymore because it increases the amount of code you have to write.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Manager : An object that does things by using other managers and accesses the data using DAL&lt;/li&gt;
  &lt;li&gt;DAL : Data access layer. State for fetched objects is not tracked. You have to make the DAL aware of changes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customerDAL.Update(customer);&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;DTO : Data transfer object.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this type of architecture it’s not uncommon to have an additional layer in the database implemented by stored procedures.&lt;/p&gt;

&lt;h2 id=&quot;message-queue--service-bus&quot;&gt;Message queue &amp;amp; Service Bus&lt;/h2&gt;

&lt;p&gt;Popular choices I’ve encountered are &lt;a href=&quot;https://en.wikipedia.org/wiki/RabbitMQ&quot;&gt;RabbitMQ&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/Microsoft_Message_Queuing&quot;&gt;MSMQ&lt;/a&gt;. A popular library is &lt;a href=&quot;https://github.com/MassTransit/MassTransit&quot;&gt;MassTransit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Provides a way to lower cohesion between components. Can also be helpful if you want to &lt;a href=&quot;http://www.rabbitmq.com/tutorials/tutorial-two-python.html&quot;&gt;distribute work&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Merging in svn</title>
      <link>https://assertfail.gewalli.se/2016/05/29/Merging-in-svn.html</link>
      <pubDate>Sun, 29 May 2016 11:46:21 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/05/29/Merging-in-svn</guid>
      <description>&lt;p&gt;While working as a consultant at a company that uses svn, I needed to keep a branch in sync with the master branch. This turns out to be a lot of work.&lt;/p&gt;

&lt;p&gt;Problem was that it was not possible to just clone the repository using git svn. The clone failed after a while (I think due to the long connection time). First you might want to read up on it from &lt;a href=&quot;http://andy.delcambre.com/2008/03/04/git-svn-workflow.html&quot;&gt;this blog post&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The command I used was something like:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git svn clone &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; 10327 &lt;span class=&quot;nt&quot;&gt;--username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;oskar.gewalli http://company.com/scm/svn/Project project  &lt;span class=&quot;nt&quot;&gt;--stdlayout&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--prefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;svn/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In order to fetch changes I did:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git svn rebase
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And to push changes:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git svn dcommit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Since I could not clone the repository and get the full branches, I had to add branches manually. It took little bit of work but was described on &lt;a href=&quot;http://stackoverflow.com/questions/296975/how-do-i-tell-git-svn-about-a-remote-branch-created-after-i-fetched-the-repo&quot;&gt;stackoverflow&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The value of this work is that merging branches is far easier in git compared to svn.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Going deeper into angular</title>
      <link>https://assertfail.gewalli.se/2016/04/12/Going-deeper-into-angular.html</link>
      <pubDate>Tue, 12 Apr 2016 17:32:58 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/04/12/Going-deeper-into-angular</guid>
      <description>&lt;p&gt;After getting to know details about ng for the last months, I’ve come to appreciate some of the features of angular. You can write quite clean looking code if you know enough ng. From my personal point of preference, &lt;a href=&quot;https://docs.angularjs.org/api/ng/type/$rootScope.Scope&quot;&gt;“scope”&lt;/a&gt; is a bit all over the place. I remember using angular for small project in 2012 not thinking much of it (angularjs shines for projects with a limited complexity).&lt;/p&gt;

&lt;h3 id=&quot;before-trying-to-write-an-angular-app&quot;&gt;Before trying to write an angular app&lt;/h3&gt;

&lt;p&gt;In order to get sort of a grasp of it there are things that you should read like &lt;a href=&quot;https://github.com/johnpapa/angular-styleguide/tree/master/a1#controlleras-view-syntax&quot;&gt;ng patterns&lt;/a&gt;. Some of these things won’t make sense until you understood some ng weirdness:
&lt;a href=&quot;http://jimhoskins.com/2012/12/14/nested-scopes-in-angularjs.html&quot;&gt;nested scopes in angularjs&lt;/a&gt;
You may also need read up on the opposition: &lt;a href=&quot;https://larseidnes.com/2014/11/05/angularjs-the-bad-parts/&quot;&gt;angularjs the bad parts&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;understanding-angularjs&quot;&gt;Understanding angularjs&lt;/h3&gt;

&lt;p&gt;Once you have read these things, you should be able to make some sense of the &lt;a href=&quot;https://github.com/angular/angular.js&quot;&gt;ng1&lt;/a&gt; and &lt;a href=&quot;https://github.com/angular/angular&quot;&gt;ng2&lt;/a&gt; code bases. There is quite a lot of documentation mixed in with the source (used to generate the api docs). It’s probably better to start to read the code from the point of the api docs (if you know what area you’re interested in), since &lt;a href=&quot;https://github.com/angular/angular.js/blob/a4e60cb6970d8b6fa9e0af4b9f881ee3ba7fdc99/src/ngCookies/cookieStore.js&quot;&gt;some of the code&lt;/a&gt; has more documentation than code. If you are planning to write something bigger (&amp;gt;10k lines) in TypeScript, it can be worth to take a look at the ng2 code base since it’s an open source example of a large TypeScript code base and &lt;a href=&quot;https://github.com/angular/angular/blob/df1f78e302e75244a71045e02ec76b7a7d8b8e8f/modules/angular2/src/common/directives.ts&quot;&gt;scripting language usage of files&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;There is a lot of focus on &lt;a href=&quot;https://docs.angularjs.org/guide/component&quot;&gt;components&lt;/a&gt; in angular2. In earlier versions (prior to ng 1.5) you can achieve similar type of code by creating directives composed of template and controller.&lt;/p&gt;

&lt;p&gt;My guess is that angularjs will have a sort of stable position (but it’s definitely not hip anymore).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Clean your work area!</title>
      <link>https://assertfail.gewalli.se/2016/01/24/Clean-your-work-area.html</link>
      <pubDate>Sun, 24 Jan 2016 06:34:44 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/01/24/Clean-your-work-area</guid>
      <description>&lt;p&gt;When in the kitchen, how are you behaving to old dishes? Do you make space in order to have space to cook the food? After finished cooking the food, do you leave dirty dishes to the next day?&lt;/p&gt;

&lt;p&gt;I’ve worked in a couple school kitchen. When I worked, it would be in the form:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;make sure that there are nothing cluttering the kitchen that shouldn’t be there&lt;/li&gt;
  &lt;li&gt;make sure that the kitchen is clean&lt;/li&gt;
  &lt;li&gt;prepare food and put food and milk in place for the children&lt;/li&gt;
  &lt;li&gt;do dishes&lt;/li&gt;
  &lt;li&gt;clean up the kitchen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve worked a few months in a mechanical workshop. My boss told me how to work:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;make sure that the area where you are going to work is uncluttered and clean&lt;/li&gt;
  &lt;li&gt;work&lt;/li&gt;
  &lt;li&gt;make sure to put back all the tools&lt;/li&gt;
  &lt;li&gt;put any unused materials back to storage&lt;/li&gt;
  &lt;li&gt;clean up the work area&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My grandfather (engineer and architect) told me how to behave in his workshop:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;clean up the table, make sure you have space to work&lt;/li&gt;
  &lt;li&gt;work&lt;/li&gt;
  &lt;li&gt;clean up the table&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In his mind, if you go for lunch, then work is considered finished (so you need to clean up before going to lunch).&lt;/p&gt;

&lt;p&gt;In software development it’s not unusual to try to ignore the cleaning part of the job. Why is this considered OK? Will the job be easier if you have to slog through:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;commented out code&lt;/li&gt;
  &lt;li&gt;comments that are unmaintained&lt;/li&gt;
  &lt;li&gt;debug code&lt;/li&gt;
  &lt;li&gt;dead code&lt;/li&gt;
  &lt;li&gt;uncommunicative function names&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and the list goes on.&lt;/p&gt;

&lt;p&gt;Why do you avoid to follow even the boy scout rule of leaving it a little better than you found it? Perhaps it’s because you have no sense of &lt;a href=&quot;http://blog.codinghorror.com/code-smells/&quot;&gt;code smell&lt;/a&gt;? Perhaps it’s because you’re stressed? You’re a junior developer?&lt;/p&gt;

&lt;p&gt;The thing about code is that once you have a clean working area (clean part of the code base where you are working), is that changes and additions will become easier to implement. Fewer things to keep in mind will keep your &lt;a href=&quot;https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two&quot;&gt;working memory&lt;/a&gt; focused.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Divide and conquer</title>
      <link>https://assertfail.gewalli.se/2016/01/16/Divide-and-conquer.html</link>
      <pubDate>Sat, 16 Jan 2016 12:06:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2016/01/16/Divide-and-conquer</guid>
      <description>&lt;p&gt;This approach to programming is not only useful for algorithms, it’s also a recurring architectural theme. The current version is called microservices. In unix you have the small command line tools that does one thing well. On a smaller scale it’s about splitting your code into several files and then folders. When you have identified a need for a library you might create a nuget, gem, maven or npm package (see &lt;a href=&quot;http://www.modulecounts.com/&quot;&gt;modulecount&lt;/a&gt;).&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Inheritance in JavaScript</title>
      <link>https://assertfail.gewalli.se/2015/12/11/Inheritance-in-javascript.html</link>
      <pubDate>Fri, 11 Dec 2015 16:06:44 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/12/11/Inheritance-in-javascript</guid>
      <description>&lt;h2 id=&quot;how-do-you-inherit-from-a-class-in-javascript&quot;&gt;How do you inherit from a “class” in JavaScript&lt;/h2&gt;

&lt;p&gt;Especially if you have a class that is a mix of constructor function and prototype methods and properties.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;&quot;use strict&quot;;
function getSeq(start){
 return function next(){
   return start++;
 };
}
var getId = getSeq(1);

function Mammal(name){
    var self = this;
    var id = getId(); // private variable
    this.getId = function(){
        return id;
    };
    Object.defineProperty(this, &apos;name&apos;, { // we want name to be mutable
        get:function (){ return name; },
        set:function (value) { name = value; }
    });
    this._old_name = name; // this value will be immutable

    // we want for the object to implement the same interface
    // this is a way to make objects more like java or C# objects
    Object.freeze(this);
}

Mammal.prototype.says = function(){ // but we can still add functions by adding to the prototype
    return this.saying || &apos;&apos;;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;some-notes-about-the-above-code&quot;&gt;Some notes about the above code&lt;/h3&gt;

&lt;p&gt;We (me and &lt;a href=&quot;https://github.com/2hdddg/&quot;&gt;Peter Wilhelmsson&lt;/a&gt;) have found that the usage of “use strict” together with Object.freeze and Object.defineProperty can some JavaScript confusion (accidentally setting a new variable when you want to set an existing, hard to find initialization of objects). Usually as with many old languages with many features (c++, perl) you should choose a subset of that language to simplify for other developers.&lt;/p&gt;

&lt;p&gt;By modifying the prototype you can always add methods even if the object itself is frozen.&lt;/p&gt;

&lt;h3 id=&quot;how-do-you-create-an-instance-of-this-class&quot;&gt;How do you create an instance of this “class”?&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;var m = new Mammal(&apos;Missan&apos;);
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;how-do-we-inherit-from-this-class&quot;&gt;How do we inherit from this “class”?&lt;/h3&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;&quot;use strict&quot;;
function Feline(name){
    var self = this;
    this.saying = &apos;&apos;
    // the last thing we do is call the base class in order to inherit and freeze this class
    Mammal.call(this,name);
}

Feline.prototype = Object.create(Mammal.prototype); // we want the methods and properties added through prototype
Feline.prototype.constructor = Feline; // but still have the correct constructor

function Cat(name){
    var self = this;
    Feline.apply(this,arguments);
}

Cat.prototype = Object.create(Feline.prototype);
Cat.prototype.constructor = Cat;
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;naming-of-javascript-classes&quot;&gt;Naming of JavaScript classes&lt;/h3&gt;

&lt;p&gt;Note that when you write:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;namespace.Name = function (){ }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This becomes an anonymous function (in many browsers). In order to give it a name we need to write it like:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;namespace.Name = function namespace_Name(){ }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This can be done as a post processing step in your grunt or gulp with logic similar to the following:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;&quot;namespace.FunctionName = function() {};&quot;.replace(
 /namespace.([^ ]+) *\= *function *\(/, function (str, gr){
   return &quot;namespace.&quot;+gr+&quot; = fucntion namespace_&quot;+gr+&quot;(&quot;;
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;using-pure-prototype-inheritance&quot;&gt;Using pure prototype inheritance&lt;/h3&gt;

&lt;p&gt;If you are using a library that does the right thing when it comes to “this”, then you can add methods to the prototype instead of “this” as a captured variable named “self”.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>webforms and confusion</title>
      <link>https://assertfail.gewalli.se/2015/10/30/webforms_and_confusion.html</link>
      <pubDate>Fri, 30 Oct 2015 11:41:16 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/10/30/webforms_and_confusion</guid>
      <description>&lt;h2 id=&quot;webforms-and-3000-lines-of-code-behind&quot;&gt;webforms and 3000 lines of code-behind&lt;/h2&gt;

&lt;p&gt;I’ve noticed that the common failures while using asp.net webforms is related to people getting confused about the asp.net page and control life cycle. Since there are so many different events to keep in mind, it’s easy to place code in the wrong place and get something that sort of works (but does not work in all cases). If you are stressed, you might add a small if statement to fix this problem in the special case, increasing complexity in the code behind file. This then turns into 1000-3000 lines of hard to read C#. I’ve found that building small user controls that are built according to how you should build user controls, can help you avoid this mess (the technical lead at Macom when I worked there pushed for this). This requires you to learn how to write user controls though.&lt;/p&gt;

&lt;p&gt;I get the feeling that it’s not unusual for developers have a hard time understanding how to interact with different components written in different files. Maybe this is why junior developers using this type of code can create a hard to change architecture: large files with a lot of interconnected logic inside each file.&lt;/p&gt;

&lt;h2 id=&quot;mvc-and-javascript&quot;&gt;mvc and JavaScript&lt;/h2&gt;

&lt;p&gt;Writing asp.net mvc is conceptually easier (there are fewer things to learn, since the focus is different). However, if you want the same functionality you might have to add some JavaScript in order to get an app (as you get in asp.net). I have found that most developers get confused when reading and writing JavaScript (unless they have enough experience using it). This confusion can be mitigated by using a subset of JavaScript or a transpiler (problem is that you need someone in the team that knows JavaScript in order to be able to make informed decisions about it). In some cases you might write more JavaScript in order to reduce the overall complexity.&lt;/p&gt;

&lt;h2 id=&quot;javascript-maturity&quot;&gt;JavaScript maturity&lt;/h2&gt;

&lt;p&gt;I find that the difference between C# and java is relatively minor right now. The main feature I missed in java has been lambdas (or lambda like syntax). Ruby, python and php all are similar in the sense that they have sort a class concept and that you can inherit from other classes. There is something like “this”, so that you can access the object. In JavaScript however, “this” does not mean the current object (it can be, but it’s not always the case). However, since most server-side developers are forced to learn JavaScript in order to complete most assignments, I would imagine that many developers know JavaScript and one of the other languages that are more similar.&lt;/p&gt;

&lt;p&gt;We see many concepts that have been promoted server-side entering client-side applications as well. When working with a larger JavaScript codebase then the problems that you face will be familiar to working with a large server-side codebase.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;conclusion&lt;/h2&gt;

&lt;p&gt;What could the conclusion be from this? If we see es6 with classes and modules and the adoption of frameworks that work with objects that use this their functions to access the object itself, then programming JavaScript compared to server side will feel less different. Some of the JavaScript frameworks out there require you to learn many things (and are then compared to webforms). My feeling is that it’s probably better to avoid larger frameworks like angular and extjs (unless you and your team is prepared to learn a lot of things). It’s better to use well known small and stable libraries (I’ve heard the same opinion being voiced by others so this is nothing new).&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>ruby on windows</title>
      <link>https://assertfail.gewalli.se/2015/10/16/ruby-on-windows.html</link>
      <pubDate>Fri, 16 Oct 2015 05:57:52 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/10/16/ruby-on-windows</guid>
      <description>&lt;p&gt;I’ve had some trouble installing gems on windows instances using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bundle install&lt;/code&gt;. I had this problem first at ~2009. The problem is &lt;a href=&quot;https://gist.github.com/luislavena/f064211759ee0f806c88&quot;&gt;missing certificates&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While this fix is correct, a quick and dirty approach is to make sure that your gem files have source http instead of https:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# A sample Gemfile&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;http://rubygems.org&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;albacore&apos;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;nuget_helper&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This means that the communication to download gems from rubygems is not private.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Mono and OS X El Capitan</title>
      <link>https://assertfail.gewalli.se/2015/10/16/Mono-and-OS-X-El-Capitan.html</link>
      <pubDate>Fri, 16 Oct 2015 05:32:05 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/10/16/Mono-and-OS-X-El-Capitan</guid>
      <description>&lt;p&gt;After installing OS X El Capitan on my computer I noticed that fsharp interactive failed to start because it failed to locate mono:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/Library/Frameworks/Mono.framework/Versions/4.0.4/bin/fsharpi: line 24: &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt;: mono: not found

Session termination detected. Press Enter to restart.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we look at the file at that position we find that it assumes that mono is in the path. I checked /etc/paths, and it looked correct (i.e. based on the paths file, mono should have been in the path):&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mathieu&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;which mono
/usr/local/bin/mono
mathieu&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-la&lt;/span&gt; /usr/local/bin/mono
lrwxr-xr-x  1 mathieu  admin  48 Sep 12 21:56 /usr/local/bin/mono -&amp;gt; /Library/Frameworks/Mono.framework/Commands/mono
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’ve found that there is a &lt;a href=&quot;http://stackoverflow.com/questions/32806615/xamarins-f-interactive-pad-cannot-find-mono&quot;&gt;stackoverflow answer&lt;/a&gt;. I opted for a somewhat different approach and created a file in my ~/bin folder with essentially the same fix (this was before the stackoverflow answer, so it’s not exactly alike). You can find it &lt;a href=&quot;https://gist.github.com/wallymathieu/99d20a5090f9691e38e0&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;After that I changed the xamarin studio F# interactive settings so that the path is ~&lt;del&gt;/Users/mathieu/bin/fsharpi&lt;/del&gt;~.&lt;/p&gt;

&lt;p&gt;I’m thinking that later on I want to change the settings for fsharpi and fsharp to point to a local nuget repository (containg a paket.dependencies file) with &lt;a href=&quot;https://www.nuget.org/packages/FSharp.Compiler.Tools&quot;&gt;FSharp.Compiler.Tools&lt;/a&gt; installed.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Using owin to implement an api</title>
      <link>https://assertfail.gewalli.se/2015/08/31/Using-owin-to-implement-an-api.html</link>
      <pubDate>Mon, 31 Aug 2015 15:52:32 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/08/31/Using-owin-to-implement-an-api</guid>
      <description>&lt;p&gt;I tried implementing the same customer service xml api that I’ve implemented in sinatra, rails, C# webhandler, nancy etc. I was pleasantly surprised how easy it is to get it up and running. There is a story for how you write tests: &lt;a href=&quot;https://msdn.microsoft.com/en-us/library/microsoft.owin.testing.testserver(v=vs.113).aspx&quot;&gt;TestServer&lt;/a&gt;, that you install by referencing &lt;a href=&quot;https://www.nuget.org/packages/Microsoft.Owin.Testing/&quot;&gt;Microsoft.Owin.Testing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Previous times that I’ve tried using Owin on mono, there has been some problems getting it to run (I think it was something related to a missing dll). Now it works fine. :)&lt;/p&gt;

&lt;p&gt;You can find the code here: &lt;a href=&quot;https://github.com/wallymathieu/CustomerService/tree/master/owin&quot;&gt;CustomerService/Owin&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>path unshift dirname of file</title>
      <link>https://assertfail.gewalli.se/2015/08/31/path-unshift-dirname-of-file.html</link>
      <pubDate>Mon, 31 Aug 2015 12:17:46 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/08/31/path-unshift-dirname-of-file</guid>
      <description>&lt;p&gt;Instead of using:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;vg&quot;&gt;$:&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;unshift&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dirname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kp&quot;&gt;__FILE__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to add a folder to the path, a better way inside your ruby code is to use:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require_relative&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;subfolder/file&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;in order to require files. You can also use a relative path in require (i.e. ‘./subfolder/file’).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>BDD style testing in qunit</title>
      <link>https://assertfail.gewalli.se/2015/08/31/BDD-style-testing-in-qunit.html</link>
      <pubDate>Mon, 31 Aug 2015 08:52:38 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/08/31/BDD-style-testing-in-qunit</guid>
      <description>&lt;p&gt;Before the vacation I was working with &lt;a href=&quot;https://twitter.com/HerrAdriansson&quot;&gt;Karl Adriansson&lt;/a&gt; on a project as the front end programmer. I helped get a front end JavaScript parts back on track. While doing this, Karl and one of the testers supplied me with specifications from the requirements. Since the specifications where very detailed, It was very easy to transform them into sort of BDD style tests:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;test(&quot;PROJ-783&quot;, function (){
  var ctx = given_a_customer_previously_bought(black_sweater());
  and_I_currently_have_X_of_Y_in_stock(ctx, 3, black_sweater());
  when_he_returns_product_X_for_refund(ctx, black_sweater());
  then_I_should_have_X_of_Y_products_in_stock(ctx, 4, black_sweater());
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that I’ve taken the specification from &lt;a href=&quot;https://en.wikipedia.org/wiki/Behavior-driven_development&quot;&gt;wikipedia&lt;/a&gt; in order to have a meaningful sample. We used the convention of writing the jira id as the test name in order to know from where the specification came.&lt;/p&gt;

&lt;p&gt;Since we are using ordinary language constructs (methods that take parameters), the level of abstraction here is relatively low. Many of the helper methods can in many cases be reused since you might have many specifications related to the same subdomain. Some of the helper methods will only be used once. In some cases you might want to drop some of the prefixes in order to avoid to much duplication.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Build tools and package managers for .net</title>
      <link>https://assertfail.gewalli.se/2015/08/27/Build-tools-and-package-managers.html</link>
      <pubDate>Thu, 27 Aug 2015 10:49:54 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/08/27/Build-tools-and-package-managers</guid>
      <description>&lt;h2 id=&quot;what-criteria-do-i-use&quot;&gt;What criteria do I use&lt;/h2&gt;

&lt;p&gt;I prefer for the build tool to work on both *nix and windows. I do some of the .net coding on os x. The build systems mentioned here are all related to working with .net (and all except psake work in *nix).&lt;/p&gt;

&lt;h2 id=&quot;if-you-are-coding-net&quot;&gt;If you are coding .net&lt;/h2&gt;

&lt;h2 id=&quot;what-package-manager-to-use&quot;&gt;What package manager to use?&lt;/h2&gt;

&lt;p&gt;Right now there is NuGet. There is no good reason why you should deviate from using that format. However, you can choose to use NuGet.exe, NuGet in visual studio with packages.config files or use &lt;a href=&quot;https://github.com/fsprojects/Paket&quot;&gt;paket&lt;/a&gt; with ‘paket’ files.&lt;/p&gt;

&lt;p&gt;Paket assumes that you want to have the same version of a package in all your projects in a solution. There is also a bootstrapper so that you don’t need to install NuGet.exe on you build environment or add it to the repository (the paket.bootstrapper is only 27.5KB). Paket and &lt;a href=&quot;http://fsharp.github.io/FAKE/&quot;&gt;FAKE&lt;/a&gt; makes a nice package (an example can be found &lt;a href=&quot;https://github.com/wallymathieu/CustomerService/tree/master/suave&quot;&gt;here&lt;/a&gt;).&lt;/p&gt;

&lt;h3 id=&quot;what-build-tool-to-use&quot;&gt;What build tool to use?&lt;/h3&gt;

&lt;p&gt;I would generally unless there is some good reason avoid writing msbuild files. They are better suited to describe projects (csproj).&lt;/p&gt;

&lt;h4 id=&quot;gulp-its-grunt&quot;&gt;Gulp it’s Grunt&lt;/h4&gt;

&lt;p&gt;Since there is a lot of tools available for web developers that leverage grunt, many .net developers use grunt. It works, the api is a bit odd (json can be used to configure tasks). If you code js for other reasons, then the callbacks will probably not bother you. Note that there is another js build tool called gulp. Gulp is smaller and more focused on streaming builds (if you have looked at the ideas from reactive extensions you will find it familiar).&lt;/p&gt;

&lt;p&gt;I’ve tried to use grunt. Node is quite easy to install on windows.&lt;/p&gt;

&lt;h4 id=&quot;rake&quot;&gt;Rake&lt;/h4&gt;

&lt;p&gt;I prefer to use ruby’s make like tool rake for building open source C# apps since I usually have ruby installed wherever I work. Rake has some nice syntax that looks quite clean. It requires you to know some ruby though.&lt;/p&gt;

&lt;p&gt;Usually when using ruby you will want to use &lt;a href=&quot;http://bundler.io/&quot;&gt;bundler&lt;/a&gt; to manage dependencies.&lt;/p&gt;

&lt;h4 id=&quot;faking-it&quot;&gt;Faking it?&lt;/h4&gt;

&lt;p&gt;Fake is a build tool where you write F# scripts. For F#-project this feels like a nice way to go. Fake is delivered by NuGet (so you won’t need anything extra installed). It requires you to know some F#.&lt;/p&gt;

&lt;p&gt;It works well under mono. I’ve not had any troubles with it.&lt;/p&gt;

&lt;p&gt;The syntax is a bit unfamiliar, but that can be the case with F# written APIs (using operators like ==&amp;gt; or  »=).&lt;/p&gt;

&lt;h4 id=&quot;psake&quot;&gt;PSake&lt;/h4&gt;

&lt;p&gt;Writing build scripts in powershell. This makes a lot of sense. Many times when you write build scripts, you are scripting windows servers as well; so you will have some experience using powershell. However, powershell is a bit of an odd language compared to many other common languages.&lt;/p&gt;

&lt;p&gt;If you are doing windows only work, then this tool is valid.&lt;/p&gt;

&lt;h4 id=&quot;the-cake-is-alive&quot;&gt;The Cake is alive?&lt;/h4&gt;

&lt;p&gt;There are many different C# build tools. The most popular right now looks to be &lt;a href=&quot;https://github.com/cake-build/cake&quot;&gt;Cake&lt;/a&gt;. You don’t have to install cscript in order to &lt;a href=&quot;https://github.com/cake-build/cake&quot;&gt;Cake&lt;/a&gt; or &lt;a href=&quot;https://github.com/yevhen/Nake&quot;&gt;Nake&lt;/a&gt;, but can download a .net exe from NuGet. You can use this exe to execute build script files. &lt;a href=&quot;https://github.com/sakeproject/sake&quot;&gt;Sake&lt;/a&gt; is installed via chocolatey. Cake-files are actually a different language: a superset of C#. This means that visual studio and monodevelop etc wont work as expected. It will let you write build scripts in a C#-y syntax.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>FSharpx.Extras</title>
      <link>https://assertfail.gewalli.se/2015/08/23/FSharpxExtras.html</link>
      <pubDate>Sun, 23 Aug 2015 18:44:46 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/08/23/FSharpxExtras</guid>
      <description>&lt;p&gt;Turns out that there is a simpler way of dealing with optional values in C#.&lt;/p&gt;

&lt;p&gt;Include FSharpx.Extras to your C# project and then you can do the following:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;optionalValue.Match(
    ifSome: value =&amp;gt; ProcessValue(value),
    ifNone: () =&amp;gt; NoValueToProcess()
);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Thanks to extension methods in this library. There are extension methods for other common discriminated unions as well.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>F# 2 weeks later</title>
      <link>https://assertfail.gewalli.se/2015/08/21/fsharp-2-weeks-later.html</link>
      <pubDate>Fri, 21 Aug 2015 15:17:39 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/08/21/fsharp-2-weeks-later</guid>
      <description>&lt;p&gt;Since I’ve been without an assignment I’ve had the time to look into F# more.&lt;/p&gt;

&lt;h2 id=&quot;where-did-i-find-material&quot;&gt;Where did I find material?&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://fsharpforfunandprofit.com/&quot;&gt;fsharpforfunandprofit&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://fpchat.com/&quot;&gt;functional programming on slack&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;stackoverflow&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;why-did-i-start-looking-into-f-again&quot;&gt;Why did I start looking into F# again?&lt;/h2&gt;

&lt;p&gt;I share the office with &lt;a href=&quot;https://github.com/wastaz&quot;&gt;Fredrik Forssen&lt;/a&gt;. I find his love of F# inspiring.&lt;/p&gt;

&lt;h2 id=&quot;things-ive-found-that-delighted-me&quot;&gt;Things I’ve found that delighted me:&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Less ceremony to declare classes, records, methods and functions (when you get used to how you write it)&lt;/li&gt;
  &lt;li&gt;Easier to compose things (for instance if you want to create a chain in order to use many different classes together for an import)&lt;/li&gt;
  &lt;li&gt;Monad support (and yes, I know that these things can very easily be abused)&lt;/li&gt;
  &lt;li&gt;Package manager and Build tool that works well together (&lt;a href=&quot;https://github.com/fsprojects/Paket&quot;&gt;paket&lt;/a&gt; and &lt;a href=&quot;https://github.com/fsharp/FAKE&quot;&gt;fake&lt;/a&gt;).&lt;/li&gt;
  &lt;li&gt;Records defined in F# are like hand coded readonly classes with IEquatable and IComparable implemented&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;ive-previously-found-the-following-sweet-when-looking-at-the-language&quot;&gt;I’ve previously found the following sweet when looking at the language:&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Immutable by default&lt;/li&gt;
  &lt;li&gt;Language construct to create a clone of a record but with different values for some fields&lt;/li&gt;
  &lt;li&gt;Language construct to match more than hard coded strings, enums and integers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;what-is-kind-of-annoying-about-the-language-and-tools-related-to-it&quot;&gt;What is kind of annoying about the language (and tools related to it)&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;If you forget to add an equals sign to a type or module declaration you get weird compiler errors&lt;/li&gt;
  &lt;li&gt;Gui tooling is still a bit alpha (the command line version works great)&lt;/li&gt;
  &lt;li&gt;It’s easy to create a F# project where you need to manually edit the fsproj file in order to get it to work on mono and windows (this was a problem in the early days of NuGet)&lt;/li&gt;
  &lt;li&gt;Almost all the library methods in .net becomes a tuple parameter in F#, this is a bit confusing since it looks like an ordinary function call in C#&lt;/li&gt;
  &lt;li&gt;Exposing F# Option on your types makes it harder to interact with your F# code from C#&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;    using OptionalUrl = Microsoft.FSharp.Core.FSharpOption&amp;lt;Customers.Url&amp;gt;;
    ...
       var customer = new Customer(
          ...
          pictureUri: OptionalUrl.Some(new Url(&quot;http://someurl.com/something?some=asd&quot;))
       );
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>Working with spreadsheets</title>
      <link>https://assertfail.gewalli.se/2015/06/07/Working-with-spreadsheets.html</link>
      <pubDate>Sun, 07 Jun 2015 20:42:15 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/06/07/Working-with-spreadsheets</guid>
      <description>&lt;h2 id=&quot;excel-html-table-hack&quot;&gt;Excel html table hack&lt;/h2&gt;

&lt;p&gt;I’ve used the classic web hack where you send an html file with excel mime type (and file ending) containing a table. I’ve had trouble with excel being more particular about allowing this hack nowadays. Another problematic aspect is if a user sends you such a file without re-saving it. Since we have open xml based formats for spreadsheets, there is no need for this hack.&lt;/p&gt;

&lt;h2 id=&quot;csv&quot;&gt;CSV&lt;/h2&gt;

&lt;p&gt;I’ve used different csv-like formats. These have the con of being dependant on the language settings (one partial fix is to detect the user language settings and render different formats). If you are using more than ascii you might also need to do a binary comparison of an excel generated csv and what you generate. Since csv looks fairly simple, many write a short regex to parse it. This has a tendency to devolve due to the different ways that you can implement csv. You can get into trouble when you are begin to support character escaping and newlines. I prefer if you can keep this kind of messy logic out of your otherwise relatively clean domain code (for instance by &lt;a href=&quot;https://github.com/Lundalogik/go_import/&quot;&gt;using a different language&lt;/a&gt; ). By using a different deliverable to transform data into predefined format you have an easier time to use many different libraries to parse weird formats.&lt;/p&gt;

&lt;h2 id=&quot;xml-based-xlsx&quot;&gt;Xml based (.xlsx)&lt;/h2&gt;

&lt;p&gt;Due to the popularity of JavaScript we have some libraries that you can use to generate xlsx files on the client-side. I’ve tried &lt;a href=&quot;https://github.com/stephenliberty/excel-builder.js&quot;&gt;excel-builder&lt;/a&gt; and have been able to use it. From a programmer friend I’ve heard that he has used &lt;a href=&quot;https://github.com/guyonroche/exceljs&quot;&gt;exceljs&lt;/a&gt; in order to generate excel files on nodejs. The documentation of excel-builder is lacking, but it was easier to get it to work than &lt;a href=&quot;https://github.com/SheetJS/js-xlsx&quot;&gt;js-xlsx&lt;/a&gt;. In order to work with excel-builder I read the excel-builder source and compared excel-generated .xlsx files with what the program generated. Most of my problems was due to the client specifying how the excel file should be styled.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Lots of deliverables</title>
      <link>https://assertfail.gewalli.se/2015/06/06/Lots-of-deliverables.html</link>
      <pubDate>Sat, 06 Jun 2015 19:31:41 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/06/06/Lots-of-deliverables</guid>
      <description>&lt;p&gt;The use of many assemblies has an appeal from an architectural standpoint. In order to separate dependencies you want different parts of your code to be able to load even though a certain version of visual studio sdk is not installed. To have a fixed api implemented by adapter assemblies for many different versions of a hard to install library dependency is a way to allow work on code without having to install every single version of the dependency.&lt;/p&gt;

&lt;p&gt;The problem is if you separate your code into many assemblies to early before you know the interdependencies between different subdomains. You can easily get a lot of code and extra assemblies due to subdomains that need to know much about each other. I like the reasoning in &lt;a href=&quot;http://martinfowler.com/bliki/MonolithFirst.html&quot;&gt;Martin Fowlers post&lt;/a&gt;: That you should wait until you know more.&lt;/p&gt;

&lt;p&gt;Sometimes, the best thing is to start with a new library or dll. Starting out a bit greenfield when you start develop something new (something of sufficient size and with sufficiently small amount of knowledge about the existing code). It’s like applying the single responsibility principle on a larger scale.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Thoughts on using Angularjs</title>
      <link>https://assertfail.gewalli.se/2015/06/06/Thoughts-on-using-Angularjs.html</link>
      <pubDate>Sat, 06 Jun 2015 17:06:11 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/06/06/Thoughts-on-using-Angularjs</guid>
      <description>&lt;p&gt;I’ve done some minor work using angularjs. Angular looks like a promising direction for certain type of applications.&lt;/p&gt;

&lt;p&gt;There is a lot of drama surrounding ng2. Some of is due to the fear that ng1 applications will become obsolete when ng2 comes around without a good migration path. Jon Skeet recently blogged: &lt;a href=&quot;http://codeblog.jonskeet.uk/2015/06/03/backwards-compatibility-is-still-hard/&quot;&gt;backwards compatibility is still hard&lt;/a&gt;. It will be interesting to see if the ng team manages to create a nice migration path from ng1 to ng2. Perhaps we will see ng1 having a continued existence due to the proliferation of applications written in ng1. The python community has struggled for years with python3 and the migration from earlier python versions. However, the complexity of most languages far exceeds the complexity of ng framework (but the differences between the versions looks more prominent).&lt;/p&gt;

&lt;p&gt;You can be productive working with ng (as with many other frameworks). This type of framework will probably stick around for a few years until someone comes up with a better way of doing client applications in JavaScript. I’ve heard criticism from Eisenberg regarding ng2, but find that Aurelia looks very &lt;a href=&quot;http://eisenbergeffect.bluespire.com/porting-an-angular-2-0-app-to-aurelia/&quot;&gt;similar to ng&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What I’ve heard from people that have done more consulting on ng is that for complicated code the ng model of detecting changes can cause performance issues. For many business type of applications you don’t need that much calculations or complicated business logic. Some people have found ng to be &lt;a href=&quot;https://news.ycombinator.com/item?id=7522520&quot;&gt;hard to grok&lt;/a&gt;. I’ve talked to a former coworker who has started working with backbone. Backbone is easier to learn. You can read the entire &lt;a href=&quot;http://backbonejs.org/docs/backbone.html&quot;&gt;annotated source&lt;/a&gt; of backbone. This is only natural since ng has a lot more code. You might notice how ng compares to backbone is similar to the difference between rails and sinatra. Rob Conery &lt;a href=&quot;http://herdingcode.com/herding-code-169-tom-dale-and-rob-conery-on-the-emberjs-angularjs-cage-match-at-ndc/&quot;&gt;compares ng to rails&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, should you use ng on your next project? As always, it depends. For some applications a rails type of frameworks on the server-side is the best fit (big opinionated frameworks that tell you how you should structure you code). For others, a more sinatra like approach (smaller framework focusing on fewer things). Being stuck in a predefined mould can be stifling if your domain does not lend itself to that shape. If it does, you can be fairly productive.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>travis supports csharp</title>
      <link>https://assertfail.gewalli.se/2015/03/22/travis-supports-csharp.html</link>
      <pubDate>Sun, 22 Mar 2015 19:16:19 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/03/22/travis-supports-csharp</guid>
      <description>&lt;p&gt;I’ve used travis to test C# projects for a few years now. It has been a bit of a pain to get it working (read custom ppa or setting language to objective c and downloading and installing package intended for xamarin studio).&lt;/p&gt;

&lt;p&gt;I &lt;em&gt;feel&lt;/em&gt; that good things happen because people have more confidence in mono.&lt;/p&gt;

&lt;p&gt;How do you test your projects on travis? Read the &lt;a href=&quot;http://docs.travis-ci.com/user/languages/csharp/&quot;&gt;travis documentation&lt;/a&gt; or look at how I have done it in &lt;a href=&quot;https://github.com/wallymathieu/with/blob/master/.travis.yml&quot;&gt;for example with&lt;/a&gt;. I’m using ruby to build C# since it’s cross-platform. You &lt;a href=&quot;https://github.com/csainty/Veil/blob/master/Build/gruntfile.js&quot;&gt;can substitute&lt;/a&gt; rake for grunt if you prefer nodejs.&lt;/p&gt;

&lt;p&gt;Another way is to use that bash has some nice filename expansion. This means that you can probably write:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mono ./src/packages/NUnit.Runners.*/tools/nunit-console.exe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to avoid hard coding the version of the runner.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Kibana vs Elmah like gui</title>
      <link>https://assertfail.gewalli.se/2015/03/13/Kibana-vs-Elmah-like-gui.html</link>
      <pubDate>Fri, 13 Mar 2015 22:05:13 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/03/13/Kibana-vs-Elmah-like-gui</guid>
      <description>&lt;p&gt;The nice thing about using &lt;a href=&quot;https://www.elastic.co/products/kibana&quot;&gt;Kibana&lt;/a&gt; for your logs is that you get nice custom filtering. Thus it’s very easy for  others to only view errors they feel that are relevant to them.&lt;/p&gt;

&lt;p&gt;If you have a many systems (gui’s, services, etc) where you pipe a lot of log data into the same log database, then it can be beneficial to to filter out systems that you’re not coding anything in.&lt;/p&gt;

&lt;p&gt;The downside of having easy filters is that it’s really easy to ignore errors. A screen with the graph of all errors could perhaps mitigate that.&lt;/p&gt;

&lt;p&gt;It would be nice to have &lt;a href=&quot;https://code.google.com/p/elmah/&quot;&gt;Elmah&lt;/a&gt; like formatting of stacktraces. Perhaps a chrome plugin could fix that. Perhaps port the stacktrace parsing from &lt;a href=&quot;https://github.com/wallymathieu/ElasticElmah&quot;&gt;ElasticElmah&lt;/a&gt; to js.&lt;/p&gt;

&lt;p&gt;The nice thing about having your logs in elastic is that you don’t need to just use kibana to query your logs. It’s really easy to use &lt;a href=&quot;http://nest.azurewebsites.net/&quot;&gt;Nest&lt;/a&gt; to do queries. Unless you have huge amount of logs you can do groupings in memory.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Event sourcing and in memory database</title>
      <link>https://assertfail.gewalli.se/2015/03/03/Event-sourcing-and-in-memory-database.html</link>
      <pubDate>Tue, 03 Mar 2015 20:38:37 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/03/03/Event-sourcing-and-in-memory-database</guid>
      <description>&lt;p&gt;Trying out &lt;a href=&quot;https://github.com/wallymathieu/origodb-studies&quot;&gt;OrigoDb&lt;/a&gt;, I found it interesting to try out a more raw &lt;a href=&quot;https://github.com/wallymathieu/filedb-studies&quot;&gt;file store approach&lt;/a&gt; and &lt;a href=&quot;https://github.com/wallymathieu/nevent-store-studies&quot;&gt;NEvent Store&lt;/a&gt;. Why the connection Event Sourcing and In memory databse? Mostly because I tried out OrigoDb first. In memory database feels like a nice fit for Event Sourcing (since the log that can restore the database can be persisted in an append only manner).&lt;/p&gt;

&lt;p&gt;Many of us have heard or read Martin Fowlers &lt;a href=&quot;http://martinfowler.com/eaaDev/EventSourcing.html&quot;&gt;Event Sourcing&lt;/a&gt;. He mentions in memory databases in the article as well.&lt;/p&gt;

&lt;p&gt;OrigoDb is a bit easier to setup compared to NEvent store. NEvent store is more mature. I like that you don’t need to inherit from a base class in NEvent Store. It does mostly what it says it does: Persists events. This means that it if you want to use it for an in memory situation you probably should make the objects readonly. The OrigoDb approach of using inheritance gives you fewer lines of code (since you don’t get command and handler types). NEvent store is more talkative and requires more code to handle events.&lt;/p&gt;

&lt;p&gt;Since OrigoDb assumes that you want help with making absolutely sure that your in memory data is not corrupted by a assignment of on an object you need to interact with the it in a slightly different manner (from &lt;a href=&quot;https://github.com/wallymathieu/origodb-studies/blob/master/Tests/CustomerDataTests.cs#L28&quot;&gt;OrigoDb CustomerDataTests&lt;/a&gt; ):&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;        [Test]
        public void CanGetCustomerByFirstname()
        {
            var customers = _engine.Execute(m=&amp;gt;
                m.QueryOverCustomers()
                .Where(c =&amp;gt; c.Firstname == &quot;Steve&quot;)
                .ToList());
            Assert.AreEqual(3, customers.Count);
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Storing your events in an append manner on the filesystem is the easiest approach. Use of readonly objects simplifies things (easier to make sure that the data does not diverge). Perhaps a use-case for &lt;a href=&quot;https://github.com/wallymathieu/with/blob/master/src/Tests/With/Clone_an_instance_into_the_same_type.cs&quot;&gt;With&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;The problem with using the filesystem directly is that it’s not ACID. However, you get ACID &lt;a href=&quot;http://dev.origodb.com/docs/transactions/&quot;&gt;using OrigoDb&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Goto considered harmful</title>
      <link>https://assertfail.gewalli.se/2015/02/22/Goto-considered-harmful.html</link>
      <pubDate>Sun, 22 Feb 2015 23:30:11 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/02/22/Goto-considered-harmful</guid>
      <description>&lt;p&gt;Dijkstra wrote the &lt;a href=&quot;http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html&quot;&gt;following&lt;/a&gt;. I agree with his reasoning.&lt;/p&gt;

&lt;p&gt;However, goto is useful in certain lower level domains.&lt;/p&gt;

&lt;p&gt;The difficulty of reading code with goto statements is that it’s hard to follow the program flow.&lt;/p&gt;

&lt;p&gt;The reasoning can also be applied to programming where you do not use goto.&lt;/p&gt;

&lt;p&gt;Consider the following code:&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;someMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// some state&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;doStuff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;goto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;condition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;goto&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doOtherStuff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;goto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;doSomeDifferentThings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;goto&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;nl&quot;&gt;end:&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;How do you emulate the above code in a language without goto? You could use a while and a switch.&lt;/p&gt;

&lt;div class=&quot;language-c highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;n&quot;&gt;someMethod&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// some state&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;going&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;going&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;going&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
              &lt;span class=&quot;n&quot;&gt;doStuff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;going&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;condition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
                  &lt;span class=&quot;n&quot;&gt;going&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;doOtherStuff&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;goin&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
              &lt;span class=&quot;n&quot;&gt;doSomeDifferentThings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
          &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;How do you emulate the above goto in a language with objects but without switch?&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ThatDoesSomeThing&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// some state&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;someMethod&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;line_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;line_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;doStuff&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;line_2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;condition&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;line_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doOtherStuff&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;l_3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;doSomeDifferentThings&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;From &lt;a href=&quot;http://stackoverflow.com/questions/1487124/translate-goto-statements-to-if-switch-while-break-etc&quot;&gt;stackoverflow&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;someMethod&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;){&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doSomething&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doSomethingElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doSomethingDifferent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;goTo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;continue&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;;&lt;/span&gt;
          &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This translates into:&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;nc&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ThatDoesSomeThing&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;// some state&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;someMethod&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;line_0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

        &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;line_0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doSomething&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;line_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;line_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doSomethingElse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;line_2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;private&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;line_2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;doSomethingDifferent&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;line_1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The main thing is the usage, not the keyword. Goto is an easy target because it’s famous for being bad. This is cargo cult programming. It’s easy to write an unreadable mess in many ways. In the above examples it might be due to the fact that it’s difficult to follow how the state of the context will be for any line.&lt;/p&gt;

&lt;p&gt;The important thing to ask yourself is why is some code harder to read? How do you write readable code? How do you write good texts?&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Looking at ORM a few years later</title>
      <link>https://assertfail.gewalli.se/2015/02/22/Looking-at-ORM-a-few-years-later.html</link>
      <pubDate>Sun, 22 Feb 2015 11:20:38 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/02/22/Looking-at-ORM-a-few-years-later</guid>
      <description>&lt;p&gt;When I first started using entity framework (one of the earlier versions) it was not ready yet (some serious performance issues). A few years later I hear good things about it from other developers.&lt;/p&gt;

&lt;p&gt;In order to try to get a feel for how the state of entity persistance is today I’ve ported an old &lt;a href=&quot;http://nhibernate.info/&quot;&gt;nhibernate&lt;/a&gt; test &lt;a href=&quot;https://github.com/wallymathieu/nhibernate-studies&quot;&gt;project&lt;/a&gt; to a test &lt;a href=&quot;https://github.com/wallymathieu/entity-framework-studies&quot;&gt;project&lt;/a&gt;
 for &lt;a href=&quot;https://msdn.microsoft.com/en-us/data/ef.aspx&quot;&gt;entity framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I initially had some trouble due to my choice of sql express to test the mappings. Once I managed to get EF to use sqlite the testing got much easier.&lt;/p&gt;

&lt;p&gt;Both ORM’s support auto-mapping of POCO objects to the database entities. The fluent auto-mapping for NHibernate looks like it can figure out many to many relations.&lt;/p&gt;

&lt;p&gt;The setup of NHibernate is a bit easier since you are not dependant on that web or app config factory settings. You get less confusion in the documentation for the NHibernate xml configuration. It looks like the people behind EF is aware of the problem and &lt;a href=&quot;https://msdn.microsoft.com/en-us/data/jj680699.aspx&quot;&gt;working on it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Both frameworks can require some getting used to.&lt;/p&gt;

&lt;p&gt;Note that both frameworks works well with &lt;a href=&quot;https://github.com/schambers/fluentmigrator&quot;&gt;fluent migrator&lt;/a&gt; to test against a sql-ish database. One way of getting a nice development flow could perhaps be to use sqlite on dev machines for integration testing and letting the CI machine run the tests against what you’re using on production.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why global installation of packages?</title>
      <link>https://assertfail.gewalli.se/2015/02/07/Why-global-installation-of-packages.html</link>
      <pubDate>Sat, 07 Feb 2015 07:35:37 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/02/07/Why-global-installation-of-packages</guid>
      <description>&lt;p&gt;What do I mean when I say?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;System level package / Global package: Package installed so that it is available for every program on the system&lt;/li&gt;
  &lt;li&gt;Local package: Package installed into sub folder of project and only available to that project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Timeline&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://anonscm.debian.org/gitweb/?p=dpkg/dpkg.git;a=blob;f=scripts/perl-dpkg.pl;h=ba70fc5f570ed2cd3661a505f642aa85d2295ab5;hb=1b80fb16c22db72457d7a456ffbf1f70a8dfc0a5&quot;&gt;dpkg 1994&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://web.archive.org/web/20000816230719/http://www.cpan.org/modules/01modules.index.html&quot;&gt;cpan, uploaded packages from 1995&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://en.wikibooks.org/wiki/Java_Programming/History&quot;&gt;jar 1996&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://dictionary.sensagent.com/advanced+packaging+tool/en-en/&quot;&gt;debian release with apt 1999&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://cpansearch.perl.org/src/MURRAY/PPM-2.1.9/Changes&quot;&gt;perl package manager goes back to 1999&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/rubygems/rubygems/blob/master/History.txt&quot;&gt;rubygems 2004&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://rubygems.org/gems/bundler/versions&quot;&gt;ruby bundler 2010, git history from 2010, ruby gem from 2009&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/npm/npm/releases/tag/v0.0.1&quot;&gt;npm 2010&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://nuget.codeplex.com/wikipage?version=1&quot;&gt;nuget 2010&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is just a sampling of when different packaging solutions appeared. My impression is that the first solutions where focused on system level package management. RubyGems and similar package managers came out of that context. I don’t know if it’s a coincidence but it looks like local package management tools started to appear first around 2010.&lt;/p&gt;

&lt;p&gt;Global installation of packages probably dates back to system level packages. Since disk space is cheaper, there is no longer the same need to share packages among programs and services.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Render xml as html</title>
      <link>https://assertfail.gewalli.se/2015/02/07/Render-xml-as-html.html</link>
      <pubDate>Sat, 07 Feb 2015 07:20:01 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2015/02/07/Render-xml-as-html</guid>
      <description>&lt;p&gt;Sometimes when working with xml you have more information in the xml file than you know what to do with in your code. It could be new tags or attributes. A way to use the xml you have not anticipated in your code. A simple way to present that information to the user (so that they can inform you when you’re doing wrong) is to apply a &lt;a href=&quot;https://gist.github.com/wallymathieu/8dcc3055b36422d3a504&quot;&gt;general xml stylesheet&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First part of the trick is to tell xml that you intend to output html:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:output&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;...&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;html&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;omit-xml-declaration=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;yes&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next step is to create a root html (in order to be able to add style and scripts). In order to apply the rest o our xsl templates we need to apply the other templates:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:template&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;match=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
...
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:apply-templates/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To render all the child-nodes we do the following:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:template&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;match=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;node()&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Any attributes? By using @* we can pick out the xml attributes. If they show different intent it could be that we want to style them differently.&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:if&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;test=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;@*&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Any child nodes?&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:if&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;test=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;node()&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;One thing you could do is to pass along the nesting as a parameter to the templates. Then you can add a different class to depending on how deep the element is.&lt;/p&gt;

&lt;p&gt;If you want to call a template with parameters:&lt;/p&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:call-template&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;some-template&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:with-param&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;value&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;select=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;.&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/xsl:call-template&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:template&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;some-template&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;xsl:param&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;value&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
    ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Xml style sheets are a bit weird to work with. They should probably be avoided for many tasks. However, for some problems they can be quite useful.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Short talk about source control</title>
      <link>https://assertfail.gewalli.se/2014/11/30/Short-talk-about-source-control.html</link>
      <pubDate>Sun, 30 Nov 2014 11:30:35 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/11/30/Short-talk-about-source-control</guid>
      <description>&lt;p&gt;This is a rewrite of an earlier talk about source control.&lt;/p&gt;

&lt;h2 id=&quot;what-is-source-control-and-why-use-it&quot;&gt;What is source control? And why use it?&lt;/h2&gt;

&lt;p&gt;In order to track changes of your code you use source control. In the simplest setup, source control answers what your source code looked like before you accidentally broke but it looked like it was working.&lt;/p&gt;

&lt;p&gt;In a similar sense you might want to store data about your customers in order to find it again. Who had a sale with customer A?&lt;/p&gt;

&lt;h2 id=&quot;why-use-sourcesafe-or-cvs&quot;&gt;Why use Sourcesafe (or CVS)?&lt;/h2&gt;

&lt;p&gt;If you are a single dev.&lt;/p&gt;

&lt;h3 id=&quot;why-not&quot;&gt;Why not?&lt;/h3&gt;

&lt;p&gt;Technical answer:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Does the single file based database accessed using file system sound scary when hosted on network share? It is!&lt;/li&gt;
  &lt;li&gt;Sourcesafe is not &lt;a href=&quot;http://blogs.msdn.com/b/ukmsdn/archive/2011/01/04/end-of-support-for-visual-sourcesafe.aspx&quot;&gt;supported&lt;/a&gt; anymore.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Less technical answer:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Problem when working more than one person.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;why-use-svn-or-similar-with-revision-history-only-on-server&quot;&gt;Why use SVN (or similar with revision history only on server)?&lt;/h2&gt;

&lt;p&gt;The dev team are familiar with SVN and have an effective work flow in that tool.&lt;/p&gt;

&lt;h2 id=&quot;why-not-use-svn&quot;&gt;Why not use SVN?&lt;/h2&gt;

&lt;p&gt;When you branch. It’s actually simpler to merge using git svn … but that adds the additional complexity of having to use git svn with svn. This can be ok if someone on the team can be assigned as an integrator that does the merges.&lt;/p&gt;

&lt;h2 id=&quot;why-use-git-or-mercurial-etc&quot;&gt;Why use Git (or mercurial et.c.)?&lt;/h2&gt;

&lt;p&gt;Can be an easy Sourcesafe like experience if you are a single developer. If you have lots of developer, it’s easier to work together using git.&lt;/p&gt;

&lt;p&gt;When mentioning git, you cant avoid mentioning github. Git is version control. Github is hosting for that version control. Github has added some nice features as well.&lt;/p&gt;

&lt;h3 id=&quot;distributed-source-control&quot;&gt;Distributed source control?&lt;/h3&gt;

&lt;p&gt;Not connected to the corporate network at the moment? Do you work on a laptop (not connected to internet 100% of the time)? Do you like to continue browse the history and create commits? If yes, then consider using a dcvs.&lt;/p&gt;

&lt;h3 id=&quot;open-source-and-github&quot;&gt;Open source and github&lt;/h3&gt;

&lt;p&gt;Many open source projects have migrated over to github since it enables easier collaboration with untrusted developers. The mechanism at work is called Pull request.&lt;/p&gt;

&lt;p&gt;In many closed source project you pay for support and eventual bug fixes. In an open source project you pay with developer time. Sometimes you have a mixed model (you pay for fixes and support but it’s open source).&lt;/p&gt;

&lt;h3 id=&quot;fork&quot;&gt;Fork!&lt;/h3&gt;

&lt;p&gt;Any public library hosted on github can be forked if you have a github account.&lt;/p&gt;

&lt;p&gt;Why is this sweet? Most of the time the devs behind the library does not care that much about fixing stuff relevant for you. If you fork the library and fix the problem you can send a Pull request with the changes. They might be rejected. They might be ignored. If you are lucky the devs will give you hints to improve the code (this improves the code and your skills).&lt;/p&gt;

&lt;h2 id=&quot;usability-of-git&quot;&gt;Usability of git?&lt;/h2&gt;

&lt;p&gt;The command line version of git can be a bit complicated. However, when used by a single dev you can use &lt;a href=&quot;http://windows.github.com/&quot;&gt;Github for windows&lt;/a&gt; in order to work in a manner similar to Sourcesafe (simple gui).&lt;/p&gt;

&lt;p&gt;A more advanced gui is the &lt;a href=&quot;http://www.sourcetreeapp.com/&quot;&gt;Atlassian SourceTree&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;hosting-your-code&quot;&gt;Hosting your code&lt;/h2&gt;

&lt;p&gt;There are several providers of git hosting. The ones I’ve been using are the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/&quot;&gt;Github&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://blogs.msdn.com/b/mvpawardprogram/archive/2013/11/13/git-for-tfs-2013.aspx&quot;&gt;TFS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://bitbucket.org&quot;&gt;BitBucket&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.codeplex.com/&quot;&gt;CodePlex&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Versioning for development code on &lt;a href=&quot;http://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively&quot;&gt;Dropbox&lt;/a&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But there are several others. You could also self host with &lt;a href=&quot;http://gitblit.com/&quot;&gt;Gitblit&lt;/a&gt; or &lt;a href=&quot;https://about.gitlab.com/&quot;&gt;GitLab&lt;/a&gt; or others.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Installing build server</title>
      <link>https://assertfail.gewalli.se/2014/11/28/Installing-build-server.html</link>
      <pubDate>Fri, 28 Nov 2014 09:11:37 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/11/28/Installing-build-server</guid>
      <description>&lt;p&gt;So, for the N-th time I’m helping out by configuring a build server. This time it was a bit different since we where restoring an old build teamcity server and agent from a crashed server.&lt;/p&gt;

&lt;p&gt;There where some gotchas as usual.&lt;/p&gt;

&lt;p&gt;In order to restore teamcity we had to do some digging to find the data directory .&lt;/p&gt;

&lt;h2 id=&quot;teamcity-data&quot;&gt;TeamCity data&lt;/h2&gt;

&lt;p&gt;If you look in the “teamcity-server.log” you can find how the server was started last time. From that we could conclude the old TEAMCITY_DATA_PATH.
We took that directory and zip:ed it. Minus the cache, since windows zip freaked out about one the name of one of our coworkers: Michał Łusiak.&lt;/p&gt;

&lt;p&gt;We made sure to set the system Environment variable:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;TEAMCITY_DATA_PATH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;to where we want teamcity to keep the data.&lt;/p&gt;

&lt;h2 id=&quot;sql-server&quot;&gt;SQL server&lt;/h2&gt;

&lt;p&gt;From the teamcity configuration we could deduce how it connected to SQL server.&lt;/p&gt;

&lt;p&gt;SQL server was installed with only database engine and management studio.&lt;/p&gt;

&lt;p&gt;When SQL was installed we only enabled windows authentication. Since teamcity connects through a tcp port, it started complaining about not being able to connect even though we had attached the old database added the expected user.&lt;/p&gt;

&lt;p&gt;If we tried to connect the same was as teamcity through the command line tool “sqlcmd” we could more quickly iterate over the configuration.
The first problem was that sqlcmd could not connect to the expected port.
In SQL Server configuration manager we had to enter the sub section “SQL server network configuration” and enable tcp.
This got us a bit further. Now our problem was that the user could not connect with the user.
We had created a user under main security in SQL server with the correct password. Problem was that the attached database still had a user with the same name. We removed that user and did “associate user with database”. We also needed to make sure that that user had the same permissions set as before.&lt;/p&gt;

&lt;p&gt;Ok, so now we could log on to teamcity using our old accounts. Great!&lt;/p&gt;

&lt;p&gt;The builds are failing because teamcity could not access the source control!&lt;/p&gt;

&lt;p&gt;Easy fix, just need to add the private ssh keys to the correct folder so that teamcity can access private repositories.&lt;/p&gt;

&lt;h2 id=&quot;msbuild&quot;&gt;Msbuild&lt;/h2&gt;

&lt;p&gt;So a lot of the builds where failing because msbuild was not installed. How do you install msbuild without visual studio? Turns out stackoverflow knows the answer:
http://stackoverflow.com/questions/2567018/installing-msbuild-4-0-without-visual-studio-2010&lt;/p&gt;

&lt;p&gt;You need the SDK.&lt;/p&gt;

&lt;p&gt;I noticed that some of the builds where failing due to missing AL.exe (assembly linker). I installed the SDK associated with the version of windows installed Win2008. I forgot to check the error message closer. It was complaining about not finding “v8.0A” if you look at the error message. I had installed an earlier version if you look at the registry settings.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2863,5): error MSB3086:
  Task could not find &quot;AL.exe&quot; using the SdkToolsPath &quot;&quot; or the registry key &quot;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86&quot;. Make sure the SdkToolsPath is set and the tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So I needed to install another SDK, the one called “Windows 8 SDK”.&lt;/p&gt;

&lt;p&gt;The names of the SDK’s are a bit confusing.&lt;/p&gt;

&lt;p&gt;Another project tried to build a web site. It was failing due to missing an imported msbuild targets file.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;WebSite.csproj(190,3): error MSB4019: The imported project &quot;C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets&quot;
 was not found. Confirm that the path in the &amp;lt;Import&amp;gt; declaration is correct, and that the file exists on disk.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The common solution here is to copy the targets for web applications from a developer machine in order to get these targets. They really should be part of a nuget package or available as a separate download.&lt;/p&gt;

&lt;h2 id=&quot;next-day&quot;&gt;Next day&lt;/h2&gt;

&lt;p&gt;Next day we ran into trouble with using port 80 for teamcity. Probably because the machine had slept during the night ;) . Turns out “system” is binding on port 80:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-Powershell&quot;&gt;netstat -anbo  | where {$_.contains(&quot;80&quot;)}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When we searched to find some answer we found &lt;a href=&quot;http://stackoverflow.com/questions/12492025/windows-8-nt-kernel-and-system-using-port-80&quot;&gt;stackoverflow&lt;/a&gt;.
Turns out “World Wide Web Publishing Service” is listening on port 80.
Why? It looks like it installs when adding “.net 3.5.1” as a feature to windows. We removed the web server role.&lt;/p&gt;

</description>
    </item>
    
    <item>
      <title>Thoughts on using knockout for the last years</title>
      <link>https://assertfail.gewalli.se/2014/11/18/thoughts-on-using-knockout.html</link>
      <pubDate>Tue, 18 Nov 2014 20:11:43 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/11/18/thoughts-on-using-knockout</guid>
      <description>&lt;p&gt;It feels very much like the next step after jquery+templates. The nice part is that this enables you to choose your own strategy. For instance only using small amounts of code and regular forms. It requires a lot of decisions about structure decided already in a lot of js mvvm frameworks. These frameworks look like rails for client-side coding. Great for certain types of problems, but requires learning how to use it. Like always, if you can accept the limitations you get a boon. The big problem is that it’s hard to know such things in advance. For small apps jquery might be best. For larger single page like applications you should evaluate the larger frameworks.&lt;/p&gt;

&lt;p&gt;Having a lot of knockout computed observables requires that you dig down into the Ko code base. This will probably improve with the maturity of Ko. A lot of computed observables can be created implicitly using a function in the view. On the knock me out blog there is some required reading &lt;a href=&quot;http://www.knockmeout.net/2014/10/knockout-cleaning-up.html&quot;&gt;Cleaning Up After Yourself in Knockout.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There might be improvements of IOC in JavaScript. Dispose and life cycle could be very useful for some single page apps. For knockout this amplified if you need long living objects. Need to evaluate the different IOC containers out there. Problem is that there is no dispose only a delete in plain JavaScript (how do you clean up from X?).&lt;/p&gt;

&lt;p&gt;Having a proper url simplifies a lot of things. You have to do a lot of complicated code when your user interface creates a view that can’t be navigated to in the ordinary sense. Adding things like filter or navigation context can help you avoid hard to answer customer answers why certain things won’t work. Having the routing primarily server side can also simplify testing.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Bundler uses man files</title>
      <link>https://assertfail.gewalli.se/2014/06/26/Bundler-uses-man-files.html</link>
      <pubDate>Thu, 26 Jun 2014 16:13:24 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/06/26/Bundler-uses-man-files</guid>
      <description>&lt;p&gt;Turns out bundler does have documentation related to Bundler.with_clean_env. You just have to read the &lt;a href=&quot;http://bundler.io/v1.6/man/bundle-exec.1.html&quot;&gt;bundler.io man pages&lt;/a&gt; or the man pages for bundler exec.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Bundler.with_clean_env</title>
      <link>https://assertfail.gewalli.se/2014/06/25/Bundlerwithcleanenv.html</link>
      <pubDate>Wed, 25 Jun 2014 05:36:52 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/06/25/Bundlerwithcleanenv</guid>
      <description>&lt;p&gt;Using ruby is kind of easy in the beginning. We started by having a folder of loose scripts. This turned a bit messy after a while. By moving these to separate gems we got some needed structure. Many of the programmers complained about globally installed gems (i.e. our local gems). In order to get a predictable executing environment we started to leverage bundler more and more. Turns out that there is a gotcha: Executing a bundle exec script inside a bundle exec script. The inside script will inherit the environment from the outer script. In order to avoid this you can use:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Bundler.with_clean_env do
    ...
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This method is not documented, but it really should be (I’ll do it if I find time).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Big news for .net</title>
      <link>https://assertfail.gewalli.se/2014/04/09/Big-news-for-net.html</link>
      <pubDate>Wed, 09 Apr 2014 22:39:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/04/09/Big-news-for-net</guid>
      <description>&lt;p&gt;Big news. Microsoft releases the next C# and vb.net compiler as &lt;a href=&quot;http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx&quot;&gt;open source&lt;/a&gt;. Miquel de Icaza &lt;a href=&quot;http://tirania.org/blog/archive/2014/Apr-09.html&quot;&gt;speaks of&lt;/a&gt; making it work on mono as well. It’s licensed under Apache license.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Memory management in knockout</title>
      <link>https://assertfail.gewalli.se/2014/02/21/Memory-management-in-knockout.html</link>
      <pubDate>Fri, 21 Feb 2014 20:21:50 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/02/21/Memory-management-in-knockout</guid>
      <description>&lt;h2 id=&quot;explicit-use-of-computed&quot;&gt;Explicit use of computed?&lt;/h2&gt;

&lt;p&gt;What does a computed expression like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;this.isBusy = ko.computed(function() {
    return self._isBusy() || self._queryIsBusy();
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;have to do with&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;data-bind=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;visible: _isBusy() || _queryIsBusy()&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Internally knockout creates a computed out of an expression in a binding handler. Ko does not parse the expression in the html above to register the variables _isBusy or _queryIsBusy.&lt;/p&gt;

&lt;h2 id=&quot;consequences&quot;&gt;Consequences&lt;/h2&gt;

&lt;p&gt;What does this mean for your code?&lt;/p&gt;

&lt;p&gt;If you have something below but want to move the logic to your class from the view:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;data-bind=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;visible: _isBusy() || _queryIsBusy()&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You have two main options:&lt;/p&gt;

&lt;p&gt;Option 1&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;Object.defineProperty(self, &apos;isBusy&apos;, {
    get: function() {
           return _isBusy() || _queryIsBusy();
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;data-bind=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;visible:isBusy&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Option 2&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;this.isBusy = function() {
    return _isBusy() || _queryIsBusy();
};
&lt;/code&gt;&lt;/pre&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;div&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;data-bind=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;visible:isBusy()&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Notice ‘()’&lt;/p&gt;

&lt;h2 id=&quot;life-cycle&quot;&gt;Life cycle&lt;/h2&gt;

&lt;p&gt;How long does the computed that knockout creates live?&lt;/p&gt;

&lt;p&gt;A bit simplified if you read the code for KO you find that knockout makes new computed (internally dependent observable) with option:
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;disposeWhenNodeIsRemoved&lt;/code&gt;
This means that knockout will remove the list of references to observables that the computed depends on when the DOM-node that the computed is associated with have been removed.&lt;/p&gt;

&lt;h2 id=&quot;when-is-it-safe-to-use-a-computed&quot;&gt;When is it safe to use a computed?&lt;/h2&gt;

&lt;p&gt;When you know the life span of the computed you have created.&lt;/p&gt;

&lt;h2 id=&quot;why-is-it-generally-bad-to-use-computed-willy-nilly&quot;&gt;Why is it generally bad to use computed willy nilly&lt;/h2&gt;

&lt;p&gt;It is generally hard to reason about when they will be disposed. It is easy to access exposed ko.computed from different objects in the system with different life span.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Self and the gc</title>
      <link>https://assertfail.gewalli.se/2014/02/06/self-and-the-gc.html</link>
      <pubDate>Thu, 06 Feb 2014 17:59:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2014/02/06/self-and-the-gc</guid>
      <description>&lt;p&gt;For many projects I’ve been using the pattern:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;nx&quot;&gt;ns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CtorFunction&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doStuff&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// do stuff and use self in order to get the object variables&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Turns out that this pattern is good for small sites with jQuery (that makes use of this in other ways). For larger code bases where you have lots of code this construction sometimes makes it difficult for the garbage collector. If you have a large single page app, then this might be an issue.&lt;/p&gt;

&lt;p&gt;What other patterns are available?&lt;/p&gt;

&lt;p&gt;For a knockout js site you could use the pattern:&lt;/p&gt;

&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;nx&quot;&gt;ns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CtorFunction&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;doStuff&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
            &lt;span class=&quot;c1&quot;&gt;// do stuff and use this in order to get the object variables&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Knockout sends the appropriate context to callbacks from the view (for instance the DOM click handlers). This makes the above construction work mostly fine. This depends of course of the scope of the knockout view (changed by “with”).&lt;/p&gt;

&lt;p&gt;This might not be true for every app. My coworker &lt;a href=&quot;https://github.com/2hdddg&quot;&gt;Peter&lt;/a&gt; found that it depends on the amount of objects. It might be that the browser (chrome) have some limits to the amount of graph traversal that is allowed to identify entities to be garbage collected.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Writing rubyish C# or porting ruby code to C#</title>
      <link>https://assertfail.gewalli.se/2013/10/27/writing-rubyish-c-or-porting-ruby-code.html</link>
      <pubDate>Sun, 27 Oct 2013 14:41:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/10/27/writing-rubyish-c-or-porting-ruby-code</guid>
      <description>&lt;p&gt;Since I liked the ruby version for parsing &lt;a href=&quot;https://github.com/sstephenson/global_phone&quot;&gt;phone numbers&lt;/a&gt;, I ported it to C#. In order to avoid having to rewrite to much I did the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;To begin with, the entire project was using ruby name convention. This simplifies things.&lt;/li&gt;
  &lt;li&gt;Whenever there is a missing method where the behavior of the method is not the same as the C# one, I added an extension method. For instance I implemented a variant of gsub. The behavior of this gsub uses $1 for matching groups (since it’s more natural to remove a bit of code than make a full port).&lt;/li&gt;
  &lt;li&gt;I tried to translate different ruby constructs into C#. For instance the lazy pattern found in the library &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@variable ||= init_variable&lt;/code&gt; I had to replace with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_variable ?? (_variable=InitVariable())&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;After all the tests became green and I had checked in the initial version, it was quite simple to change name convention using ReSharper.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The finished version is available on &lt;a href=&quot;https://github.com/wallymathieu/GlobalPhone&quot;&gt;github&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Using values in expression</title>
      <link>https://assertfail.gewalli.se/2013/10/20/using-values-in-expression.html</link>
      <pubDate>Sun, 20 Oct 2013 09:47:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/10/20/using-values-in-expression</guid>
      <description>&lt;p&gt;I’ve done some small tests while writing the library to handle &lt;a href=&quot;https://www.nuget.org/packages/With/&quot;&gt;readonly objects in C#.&lt;/a&gt; Turns out that getting the value of a sub expression can be costly (since you have to compile the expression and execute). When just setting one property there can be a performance benefit of using the following syntax:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;new MyClass(1, “2”).With(m =&amp;gt; m.MyProperty, 3)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;There might be some way of optimizing the code in order to get better performance for the form:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;new MyClass(1, “2”).With(m =&amp;gt; m.MyProperty == 3)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If there are only a few usages then the performance hit is probably negligible.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Using readonly objects in C#</title>
      <link>https://assertfail.gewalli.se/2013/10/18/using-readonly-objects-in-c.html</link>
      <pubDate>Fri, 18 Oct 2013 17:39:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/10/18/using-readonly-objects-in-c</guid>
      <description>&lt;p&gt;One thing I like about F# is the ability to use readonly objects in a way that does not require a lot of code. I’ve done a small lib inspired by this ability of F#: &lt;a href=&quot;https://github.com/wallymathieu/with&quot;&gt;with&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The syntax is a bit special since I assume that the properties have a private set.&lt;/p&gt;

&lt;h2 id=&quot;versions-prior-to-5&quot;&gt;versions prior to 5&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;myobject.With(m =&amp;gt; m.Property1 == 3 &amp;amp;&amp;amp; m.Property2 == &quot;3&quot;)
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;with-5&quot;&gt;With 5+&lt;/h2&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;using With;
...
public class SomeClass
{
    private static readonly IPreparedCopy&amp;lt;MyClass, int, string&amp;gt; PreparedCopy =
        Prepare.Copy&amp;lt;MyClass, int, string&amp;gt;((m,v1,v2) =&amp;gt; m.Property1 == v1 &amp;amp;&amp;amp; m.Property2 == v2);
    public async Task&amp;lt;MyClass&amp;gt; Handle()
    {
        // fetch instance of MyClass, say:
        var myObject = await _storage.Load(someId);
        // change the name of that customer:
        var copy = PreparedCopy.Copy(myObject, 3, &quot;3&quot;);
        // ...
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The reason for this style of syntax is due to the fact that compiling expressions are potentially expensive, why you’d want to have a similar pattern as compiled regex.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Writing build scripts in C#</title>
      <link>https://assertfail.gewalli.se/2013/10/13/writing-build-scripts-in-c.html</link>
      <pubDate>Sun, 13 Oct 2013 06:42:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/10/13/writing-build-scripts-in-c</guid>
      <description>&lt;p&gt;I went to &lt;a href=&quot;http://leetspeak.se/&quot;&gt;leetspeak&lt;/a&gt; yesterday. &lt;a href=&quot;https://github.com/jrusbatch&quot;&gt;Justin Rusbatch&lt;/a&gt; had a talk about scriptcs. In that talk he mentioned that several people wanted to write build scripts in C# and thought that it would be nice to use scriptcs to do that. I started trying out to write build scripts in C#. Turns out that many of the classes that are available in .net are not supposed to be used by users of .net. It’s cleaner and simpler to execute the command line tools from C#. I started writing some code to try it out. I called it &lt;a href=&quot;https://github.com/wallymathieu/shake&quot;&gt;shake&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Problem running NuGet on Ubuntu</title>
      <link>https://assertfail.gewalli.se/2013/10/06/problem-running-nuget-on-ubuntu.html</link>
      <pubDate>Sun, 06 Oct 2013 21:19:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/10/06/problem-running-nuget-on-ubuntu</guid>
      <description>&lt;p&gt;I had some trouble running NuGet on ubuntu. I’m running an Ubuntu server. Turns out that you need to install certificates:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mozroots –import –sync
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Otherwise NuGet will fail to decode the results when fetching packages over https.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Skånetrafiken</title>
      <link>https://assertfail.gewalli.se/2013/09/21/skanetrafiken.html</link>
      <pubDate>Sat, 21 Sep 2013 18:41:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/09/21/skanetrafiken</guid>
      <description>&lt;p&gt;I dusted off some &lt;a href=&quot;https://github.com/wallymathieu/skanetrafiken&quot;&gt;old code&lt;/a&gt; that I’ve written to query the API provided by &lt;a href=&quot;http://www.labs.skanetrafiken.se/&quot;&gt;Skånetrafiken&lt;/a&gt;. I’ve also published it to &lt;a href=&quot;https://rubygems.org/gems/skanetrafiken&quot;&gt;rubygems&lt;/a&gt;. It’s quite nice to work with soap using ruby.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Isop infers parameters</title>
      <link>https://assertfail.gewalli.se/2013/09/21/isop-infers-parameters.html</link>
      <pubDate>Sat, 21 Sep 2013 07:13:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/09/21/isop-infers-parameters</guid>
      <description>&lt;p&gt;Command line tools should do what people expect. It’s a bit chaotic to navigate how to parse command line parameters since there are many conventions.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;A single - to indicate a short parameter, that is: -a&lt;/li&gt;
  &lt;li&gt;Two – to indicate a long parameter, that is: –alpha&lt;/li&gt;
  &lt;li&gt;A single / to indicate a parameter, that is: /alpha&lt;/li&gt;
  &lt;li&gt;A single - to indicate a parameter, that is: -alpha&lt;/li&gt;
  &lt;li&gt;A parameter followed by a space and then a value for that parameter: /alpha value&lt;/li&gt;
  &lt;li&gt;A parameter followed by a = and then a value for that parameter: –alpha=value&lt;/li&gt;
  &lt;li&gt;The position of the parameter (the ordinal position) to indicate simply a value&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve added code to try to infer value for a parameter using it’s ordinal position when there are no ordinary parameters present before the inferred parameter value.&lt;/p&gt;

&lt;p&gt;This simply means that it should be possible to write:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;my.exe --param1=something --param2=someother
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and also:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;my.exe something someother
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>What&apos;s wrong with spreadsheets?</title>
      <link>https://assertfail.gewalli.se/2013/09/10/whats-wrong-with-excel.html</link>
      <pubDate>Tue, 10 Sep 2013 18:23:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/09/10/whats-wrong-with-excel</guid>
      <description>&lt;h2 id=&quot;whats-good-about-spreadsheets&quot;&gt;Whats good about spreadsheets?&lt;/h2&gt;

&lt;p&gt;Spreadsheet applications offers a lot of usability. The concept of using a grid of variables that are easy to reference is a surprisingly powerful  concept.&lt;/p&gt;

&lt;p&gt;Many applications can be prototyped in spread sheet applications. I use google drive in order to have a powerful and flexible time reporting solution. I quickly realized that in order to have a software that exceeds these benefits, I would have to spend a lot of time writing it.&lt;/p&gt;

&lt;h2 id=&quot;what-can-be-improved&quot;&gt;What can be improved?&lt;/h2&gt;

&lt;p&gt;A few days ago I was about to do something that is usually simple in code, but turned out to be hard in excel. The functions available have not evolved very much since the introduction of spreadsheet applications. This is probably due to the fact that the people expected to work with these type of applications are not expected to learn new concepts (Excel looks very different from the early spreadsheet programs). During that time, commonly used programming languages have evolved. Perhaps it’s time to put the lessons learned in programming to use in spreadsheet applications.&lt;/p&gt;

&lt;p&gt;There are some difficulties in applying concepts from programming to spreadsheets. There is not a natural way of assignment for functions that return multiple results, structs or objects. This puts a limit on what type of functions can be used. However, I do believe that it’s possible to use functions that return a single string or number variable to increase the usefulness of the concept.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Refactoring in ruby</title>
      <link>https://assertfail.gewalli.se/2013/09/04/refactoring-in-ruby.html</link>
      <pubDate>Wed, 04 Sep 2013 20:07:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/09/04/refactoring-in-ruby</guid>
      <description>&lt;p&gt;We have written a lot of ruby code in the project I’m currently working in. There is a lot of code to help manage, build and schedule the program. We started out simple enough. Just one folder with helper scripts. After 2 years we have built up support for a wide variety of tasks.&lt;/p&gt;

&lt;h3 id=&quot;command-line-tools&quot;&gt;Command line tools&lt;/h3&gt;

&lt;p&gt;We have used and abused &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$:.unshift File.dirname(__FILE__)&lt;/code&gt; and similar constructs far to much. This makes it hard to get a good overview of dependencies between files.&lt;/p&gt;

&lt;p&gt;In order to get islands of related code we have turned to making local only gems. The gem structure helps to cut down on weird manipulations of the load path. It’s easier to get an overview by having related files and their tests in a separate folder.&lt;/p&gt;

&lt;h3 id=&quot;bundler&quot;&gt;Bundler&lt;/h3&gt;

&lt;p&gt;Bundler turns out to have a lot of nice tasks (a coworker told me about it):
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;require &apos;bundler/gem_tasks&apos;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Looking at the bundler code helps when using the &lt;a href=&quot;https://github.com/bundler/bundler/blob/master/lib/bundler/gem_helper.rb&quot;&gt;GemHelper&lt;/a&gt; class. If we look at gem_tasks.rb we find:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;bundler/gem_helper&apos;&lt;/span&gt; 
&lt;span class=&quot;no&quot;&gt;Bundler&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;GemHelper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;install_tasks&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The standard format for gemspecs usually make use of git ls-files. We got a lot of error messages from bundler and switched to use Dir.glob.&lt;/p&gt;

&lt;h3 id=&quot;rails-app-turns-into-gem&quot;&gt;Rails app turns into gem&lt;/h3&gt;

&lt;p&gt;I’ve written a rails-app for a specific task. I started out with having most of the code in models, helpers in the rails app folder. This turned a bit sour after a while. In order to alleviate the code smell, I started moving the functionality into the lib folder. It turned out that we wanted to use the code in a different setting than as a web app. I moved the relevant tests and code from the lib folder into a new package/gem and added a dependency on this gem from the rails app.&lt;/p&gt;

&lt;p&gt;We have since stopped maintaining the rails app, and it has been removed.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>National clouds</title>
      <link>https://assertfail.gewalli.se/2013/07/06/national-clouds.html</link>
      <pubDate>Sat, 06 Jul 2013 20:15:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/07/06/national-clouds</guid>
      <description>&lt;p&gt;We first heard of the Australian government getting &lt;a href=&quot;http://delimiter.com.au/2012/04/13/us-slams-australias-on-shore-cloud-fixation/&quot;&gt;fallout&lt;/a&gt; from the US because of voiced concerns about using offshore cloud providers. Some technologists I have talked with thought it obvious that the US government would use &lt;a href=&quot;http://www.guardian.co.uk/world/2013/jun/30/nsa-leaks-us-bugging-european-allies&quot;&gt;available means&lt;/a&gt; to get accurate information given the obsolesce of certain &lt;a href=&quot;http://en.wikipedia.org/wiki/ECHELON&quot;&gt;infrastructure&lt;/a&gt;. This might spell an increased demand for local alternatives for business software. Another way is to start deploying software in a more security conscious manner. For instance encrypting the stored information so that the cost of espionage increases.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Listening to traffic</title>
      <link>https://assertfail.gewalli.se/2013/05/20/listening-to-traffic.html</link>
      <pubDate>Mon, 20 May 2013 10:58:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2013/05/20/listening-to-traffic</guid>
      <description>&lt;p&gt;While developing a web app, it’s easy to inspect the traffic in the browser (chrome, IE and firefox have all the ability to show traffic related to the page you are debugging). I recently refactored a lib to remove a library and use a raw web-request. This was a move to remove dependencies. In my tests I added machine name instead of localhost and got the traffic in Fiddler. An easy way to remove the abstraction and start accessing the real json api.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Test your update scripts</title>
      <link>https://assertfail.gewalli.se/2012/12/13/test-your-update-scripts.html</link>
      <pubDate>Thu, 13 Dec 2012 15:14:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/12/13/test-your-update-scripts</guid>
      <description>&lt;p&gt;This is a lesson I should have learned. It comes back to bite me and my coworkers ever so often. Running a script to update data without test is always quick and dirty. SSIS is a wonderful tool, but there are fundamental flaws to this tool as it’s really hard to test SSIS packages. The beauty of using ruby or some other language (powershell, python, et.c.) is that you can write tests for the code. So, when you’re doing yourself the favor of using ruby, write tests!&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Writers and readers</title>
      <link>https://assertfail.gewalli.se/2012/12/04/writers-and-readers.html</link>
      <pubDate>Tue, 04 Dec 2012 21:51:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/12/04/writers-and-readers</guid>
      <description>&lt;p&gt;Reading source code is hard. One way of dealing with this is rewriting what is not understood. This can help focus on some parts of the code, but can be detrimental since it’s easy to overlook functionality in files that are not touched or files that look too complex (throwing away functionality). One way of doing this is to create a fork to rewrite one, in order to be able to throw away the changes made essentially to read the code.&lt;/p&gt;

&lt;p&gt;It’s usually harder to &lt;a href=&quot;http://gamedevwithoutacause.com/?p=1329&quot;&gt;read code than to write it&lt;/a&gt;. Trying to read a 700 line method can be to hard, thus it may need some &lt;a href=&quot;https://github.com/kytrinyx/therapeutic-refactoring&quot;&gt;therapeutic refactoring&lt;/a&gt; in reduce the components to pieces that can be understood.&lt;/p&gt;

&lt;p&gt;Among several programmers, one reason why there is a tug o war between them can be because of non orthogonal and different best practices: They keep rewriting each others code because they have different ideas on what tradeoffs to prefer.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Type matching in C#</title>
      <link>https://assertfail.gewalli.se/2012/11/22/type-matching-in-c.html</link>
      <pubDate>Thu, 22 Nov 2012 18:27:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/11/22/type-matching-in-c</guid>
      <description>&lt;p&gt;I was thinking about how nice you have it in some languages where you can do a case statement for types. Thing is, we have a lot of &lt;a href=&quot;https://gist.github.com/4132433&quot;&gt;compiler goodness in C# already&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;By being explicit about the type and using type inference we can have a generic Case statement of a maximum length (depends on how many if else you think are ok to add).&lt;/p&gt;

&lt;p&gt;I find it pretty sweet to write code like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;TypeMatch.Case(exception,
  (GnarlyType e) =&amp;gt; { HandleGnarly(e); },
  (FuncyType e1) =&amp;gt; { HandleFunky(e1); },
  () =&amp;gt; { Explode(); });
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Instead of:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;var e = exception as GnarlyType;
if (e!=null){ HandleGnarly(e); }
else {
  var e1 = exception as FunkyType;
  if (e1!=null){
    HandleFunky(e1);
  }else{
    Explode();
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&quot;small-note&quot;&gt;Small note&lt;/h3&gt;

&lt;p&gt;This type of feature is now part of C# proper as:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;switch (exception)
{
  case GnarlyType e: HandleGnarly(e); break;
  case FunkyType e1: HandleFunky(e1); break;
  default: Explode(); break;
}
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>Debugging fuzzy coding</title>
      <link>https://assertfail.gewalli.se/2012/11/10/debugging-fuzzy-coding.html</link>
      <pubDate>Sat, 10 Nov 2012 17:11:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/11/10/debugging-fuzzy-coding</guid>
      <description>&lt;p&gt;As a programmer it is easy to adopt a view of the world in light of our experience. The workings of the world starts to look as something out of the matrix. This has some funny consequences:
While listening to a person reasoning about the complicated events today from the point of view of famous thinkers; You can get the feeling of hearing a formalized thought pattern executed by a very complex machine. This sort of meta thinking naturally can be attributed to the formalization of execution that you work with, i.e. it is a view of programmable minds from the view of a mind programmed by thinking about programming.&lt;/p&gt;

&lt;p&gt;This kind of thinking is useless unless it can be applied.&lt;/p&gt;

&lt;p&gt;In the terms of a programmer: We are looking into how to debug the domain. The most important aspect of getting to know a domain is learning the language of that domain. The meaning of words inside that discussion context.&lt;/p&gt;

&lt;p&gt;How do we reduce the task to something manageable? Simply learning all the language and statements associated with a given domain a huge undertaking. What is it that we want to learn? One of the interesting aspect of the domain is the grammar and the macro expansion of that domain. If we apply this to the world of programming, what kind of form of statements and what kind macros are we thinking in?&lt;/p&gt;

&lt;p&gt;Most programmers work with the following concepts (I’m trying to simplify it):
methods, classes (and instances of the classes), variables
The most important execution constructs are:
if, for&lt;/p&gt;

&lt;p&gt;Naming methods, classes and variables turns the execution into a meaningful flow. Mostly we are working with details surrounding execution of our concepts. A programmer is working a lot with detail management (much like a weaver of a tapestry have to manage the the threads in order to get a working picture). A very serious problem is that it’s hard to find the right level of detail and abstraction to work with. The concepts above can be used to create detail at arbitrary levels. Kind of like Lego versus Duplo.&lt;/p&gt;

&lt;p&gt;For the most part, many tend to prefer immutable constructs: Specified classes that do not change their behavior after initialization. This greatly simplifies reasoning.&lt;/p&gt;

&lt;p&gt;Since programmers are working so much with abstractions, we tend to overdo abstraction.&lt;/p&gt;

&lt;p&gt;What kind of conclusion can I draw from this? I’m not sure. It reads like the exact opposite of statistics. Mostly we program in predictable ways that get unpredictable due to the complexity rather than randomness of the input. Do we expect people to behave in this manner? Well, they sometimes behave similarly at a cursory glance. The big question would be what kind of programming we would write for people?&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>The code I wrote is a mess</title>
      <link>https://assertfail.gewalli.se/2012/11/06/the-code-i-wrote-is-mess.html</link>
      <pubDate>Tue, 06 Nov 2012 23:14:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/11/06/the-code-i-wrote-is-mess</guid>
      <description>&lt;p&gt;Many times when you return to code that you have written you will swear and be annoyed with your lack of foresight.&lt;/p&gt;

&lt;p&gt;We have been using a library since a while back. There is a definite strength to having a simple way of exposing actions from a console application. The code for the library and runner &lt;a href=&quot;https://github.com/wallymathieu/isop&quot;&gt;Isop&lt;/a&gt; is a mess. A mess designed to avoid having to code a messy console application in order to do quick interactions with your code (.net code to be specific). The focus of the lib has always been to cater to the needs of business applications. I’ve not spent time cleaning up the code since it satisfies the criteria: If it works, why fix it?&lt;/p&gt;

&lt;p&gt;It annoys me that I don’t have the time and energy to write beautiful code. This instinct is both healthy and dangerous. It helps you create maintainable applications, but it can also get you mired down into polishing. Ultimately it goes down to the fact that different structure caters to different intent and intent often changes (thus the unpleasant hindsight). Sometimes it’s that you had something simple to begin with, but as you fill in the gaps it becomes complicated.&lt;/p&gt;

&lt;p&gt;What I’m trying to say is that it’s really hard to avoid the problem of complicated code or code that does not fit your intent. What you need is to refactor. This is the skill to use.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why should you make your new developers use ruby?</title>
      <link>https://assertfail.gewalli.se/2012/10/08/why-should-you-make-your-new-developers.html</link>
      <pubDate>Mon, 08 Oct 2012 22:42:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/10/08/why-should-you-make-your-new-developers</guid>
      <description>&lt;p&gt;The impression I’ve gotten from working with ruby is that it’s generally fun to work with. One of my coworkers who has about a year of experience told me:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;You become happy from working with ruby.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also, for many tasks it can provide a easier experience than some of the alternatives. Consider the tasks:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Manage builds or server&lt;/li&gt;
  &lt;li&gt;Simple web app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tools like rake and sinatra are simple enough to help green developers complete the task without drowning in the complexity.&lt;/p&gt;

&lt;p&gt;It’s the same reasoning behind webmatrix. In webmatrix there is a lot &lt;a href=&quot;http://stackoverflow.com/questions/5953394/is-there-a-unit-testing-capability-with-webmatrix&quot;&gt;less focus on unit testing&lt;/a&gt;. It’s a slightly different perspective, but still centered around &lt;a href=&quot;http://blog.wekeroad.com/microsoft/someone-hit-their-head&quot;&gt;simple fun stuff&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Dark-room development</title>
      <link>https://assertfail.gewalli.se/2012/10/03/dark-room-development.html</link>
      <pubDate>Wed, 03 Oct 2012 06:24:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/10/03/dark-room-development</guid>
      <description>&lt;p&gt;One of the fears is that &lt;a href=&quot;http://www.codinghorror.com/blog/2012/10/the-pc-is-over.html&quot;&gt;the days of PC is considered over&lt;/a&gt;. That we there will be a massive shift towards a reduction of the interface. Some have pointed out that the start screen on &lt;a href=&quot;http://www.youtube.com/watch?v=X0fsyb-ttcw&quot;&gt;Windows 8: It’s Almost Not Terrible&lt;/a&gt;. Gartner sums it up &lt;a href=&quot;http://www.theregister.co.uk/2012/07/23/gartner_windows_8_review/&quot;&gt;in a word: Bad&lt;/a&gt; for desktops (however he also says that it’s very fine on touch device).&lt;/p&gt;

&lt;p&gt;This all sounds very odd. However, the negativity mostly centered around how to use the start screen on a desktop might not be such a big deal. &lt;a href=&quot;http://www.hanselman.com/blog/Windows8ProductivityWhoMovedMyCheeseOhThereItIs.aspx&quot;&gt;Hanselman&lt;/a&gt; among others assures that you just have to learn the new keyboard shortcuts and that it’s just a matter of getting used to. Our IT-boss (a small company so he does a lot of the IT-operations) tells me that a power user will hardly use the start screen.&lt;/p&gt;

&lt;p&gt;As long as the two separate entities desktop and xbox/tablet interface live side by side there might not be cause for alarm for programmers using multiple windows side by side (editor, library documentation, tests, powershell, command prompt et.c.). Other programmers may in fact welcome the one window approach. Some have already used visual studio as the one program to do all things. Also for writers of text there are a few programs for &lt;a href=&quot;http://they.misled.us/dark-room&quot;&gt;windows&lt;/a&gt; and &lt;a href=&quot;http://www.hogbaysoftware.com/products/writeroom&quot;&gt;mac&lt;/a&gt; that focus on full-screen to avoid distractions and get things done. It’s exciting to see where Windows 8 goes.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>TypeScript</title>
      <link>https://assertfail.gewalli.se/2012/10/02/typescript.html</link>
      <pubDate>Tue, 02 Oct 2012 19:38:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/10/02/typescript</guid>
      <description>&lt;p&gt;Coffeescript has been heralded as a way to avoid some of the nastiness of JavaScript. Now &lt;a href=&quot;http://channel9.msdn.com/posts/Anders-Hejlsberg-Introducing-TypeScript&quot;&gt;Anders Hejlsberg introduces&lt;/a&gt; a new addition to the story: TypeScript. I read this from a pal that &lt;a href=&quot;http://tirania.org/blog/archive/2012/Oct-01.html&quot;&gt;linked to a blog post&lt;/a&gt;. The geist of the post is a slight positive note, but the author notes that &lt;a href=&quot;http://en.wikipedia.org/wiki/IntelliSense&quot;&gt;IntelliSense&lt;/a&gt; is missing for editors other than Visual Studio. If the license is good (it’s &lt;a href=&quot;http://typescript.codeplex.com/license&quot;&gt;in Apache license&lt;/a&gt;), the language additions are relevant, there might be people that get some of it to work in &lt;a href=&quot;http://blogs.msdn.com/b/interoperability/archive/2012/10/01/sublime-text-vi-emacs-typescript-enabled.aspx&quot;&gt;another editor&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Funky xml log</title>
      <link>https://assertfail.gewalli.se/2012/09/25/funky-xml-log.html</link>
      <pubDate>Tue, 25 Sep 2012 06:13:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/09/25/funky-xml-log</guid>
      <description>&lt;p&gt;I had some trouble where a simple parser would take a bit of time. Turns out that there were many ways of improving this performance. I rewrote it to use the xml reader instead to be able to do &lt;a href=&quot;http://www.hanselman.com/blog/XmlAndTheNametable.aspx&quot;&gt;these improvements&lt;/a&gt;. Some funky bugs got squished. The reader is a bit low level compared to niceties such as &lt;a href=&quot;http://nokogiri.org/&quot;&gt;Nokogiri&lt;/a&gt; (in hindsight, maybe I should have been using). By using this class I could avoid some funkiness of XmlDocument having to cope with weird xml at the expense of having less appealing code: &lt;a href=&quot;https://github.com/wallymathieu/log4net-logviewer/blob/master/Core/LogEntryParser.cs&quot;&gt;LogEntryParser&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Whats right with windows 8?</title>
      <link>https://assertfail.gewalli.se/2012/09/24/whats-right-with-windows-8.html</link>
      <pubDate>Mon, 24 Sep 2012 17:42:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/09/24/whats-right-with-windows-8</guid>
      <description>&lt;p&gt;Imagine the user experience of a gaming console. It’s very focused on a selected few tasks: starting games, playing movies… An ipad is conceptually a similar device. You can surf, run certain applications, watch movies, listen to music. The user interface is simple. Most users have no need for the fuss.&lt;/p&gt;

&lt;p&gt;To imagine an operating system where you focus on what normal users want to do, you start looking in the windows 8 direction. The start screen reminds of the Xbox.&lt;/p&gt;

&lt;p&gt;I got skeptical and confused when I tried windows 8, looked at videos about it. The reason why it felt wrong: Windows 8 is not intended for me. I’m not part of the 95% that abhors complexity. Ordinary user dislike the “to much information” syndrome present for most desktop operating systems.&lt;/p&gt;

&lt;p&gt;I have a suspicion that it’s not there yet. Maybe when windows 8.3 or windows 9 is released, my mom can use it without getting frustrated. There are just a few things she wants to do:
Surf the web, pay the bills, read her email, manage spreadsheets, write documents, manage her photos and keep the gigabytes of photos backed up.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Always attaching debugger when starting a program in windows</title>
      <link>https://assertfail.gewalli.se/2012/09/24/always-attaching-debugger-when-starting.html</link>
      <pubDate>Mon, 24 Sep 2012 09:20:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/09/24/always-attaching-debugger-when-starting</guid>
      <description>&lt;p&gt;So, Im using &lt;a href=&quot;http://technet.microsoft.com/en-us/sysinternals/bb896645&quot;&gt;Process Monitor&lt;/a&gt; to hunt down some permission or anti virus problems in windows. I notice  a query to a registry key “Image File Execution Options”. I get curious. Turns out that you can &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/desktop/ff190925(v=vs.85).aspx&quot;&gt;turn on a debugger&lt;/a&gt; when starting a program. Someone used it to &lt;a href=&quot;http://blogs.technet.com/b/marcelofartura/archive/2006/10/24/a-virus-infection-contolling-the-outbreak-tip.aspx&quot;&gt;control a virus outbreak&lt;/a&gt;, but it could be handy for other things as well.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Visual studio 2012 all caps</title>
      <link>https://assertfail.gewalli.se/2012/08/16/visual-studio-2012-all-caps.html</link>
      <pubDate>Thu, 16 Aug 2012 15:43:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/08/16/visual-studio-2012-all-caps</guid>
      <description>&lt;p&gt;We are waiting for VS2012. What will impact work experience most will probably be the user interface changes as described in: &lt;a href=&quot;http://blogs.msdn.com/b/visualstudio/archive/2012/05/08/visual-studio-11-user-interface-updates-coming-in-rc.aspx&quot;&gt;Visual Studio 11 User Interface Updates Coming in RC&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing I don’t understand is the preference for all caps. The interface is riddles with them. However Richard Banks describes &lt;a href=&quot;http://www.richard-banks.org/2012/06/how-to-prevent-visual-studio-2012-all.html&quot;&gt;how-to prevent VS2012 ALL CAPS menus&lt;/a&gt;, so there might be hope yet.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Spending hours on trying to figure out why it does not check</title>
      <link>https://assertfail.gewalli.se/2012/07/31/spending-hours-on-trying-to-figure-out.html</link>
      <pubDate>Tue, 31 Jul 2012 07:36:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/07/31/spending-hours-on-trying-to-figure-out</guid>
      <description>&lt;p&gt;Yesterday I spent hours trying to figure out why a checkbox did not get checked (visually). When debugging the knockout code, it was clear that the DOM elements got checked. They did not update visually until another checkbox got checked. I tried other methods of checking the checkbox (both setAttribute and jquery) to no affect. What was even weirder is that it works the same in both chrome and IE.&lt;/p&gt;

&lt;p&gt;To reproduce, click on the first checkbox and then the second in &lt;a href=&quot;http://jsfiddle.net/ozzymcduff/xpk3Y/&quot;&gt;this fiddle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I got the question if I had a click event handler from &lt;a href=&quot;http://www.stealmycode.se/&quot;&gt;steal my code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Turns out that the reason for this behavior is that I had a click event handler on a parent DOM element. By having the click handler return true the problem &lt;a href=&quot;http://jsfiddle.net/ozzymcduff/xpk3Y/1/&quot;&gt;was resolved&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I still don’t understand why it works like this.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Is philosophy relevant for programmers?</title>
      <link>https://assertfail.gewalli.se/2012/07/24/is-philosophy-relevant-for-programmers.html</link>
      <pubDate>Tue, 24 Jul 2012 18:30:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/07/24/is-philosophy-relevant-for-programmers</guid>
      <description>&lt;p&gt;Many programmers and engineers I’ve met say when asked about philosophy:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;I don’t really care for it. It’s obsolete because of science.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Could it be that it’s the engineering point of view? The view that some scientist (tool maker) cooks up the tools that the engineers use? Thus: truth and reality is simply handed down from a more trustworthy source.&lt;/p&gt;

&lt;h4 id=&quot;science-picks-up-the-tab&quot;&gt;Science picks up the tab&lt;/h4&gt;

&lt;p&gt;Science ( trademark of modern civilization ) has thus replaced philosophy ( funny thoughts by bearded old men ). However, the philosophy taught in schools is mostly focused on aggregating history into manageable chunks. It’s simplified history about thoughts spanning circa 2500 years.&lt;/p&gt;

&lt;p&gt;I like the below explanation of philosophy:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Anthony Quinton, in T. Honderich (ed.), The Oxford Companion to Philosophy (Oxford University Press, 1995), p. 666: “Philosophy is rationally critical thinking, of a more or less &lt;a href=&quot;http://en.wikipedia.org/wiki/Systematic&quot;&gt;systematic&lt;/a&gt; kind about the general nature of the world (metaphysics or theory of existence), the justification of belief (epistemology or theory of knowledge), and the conduct of life (ethics or theory of value). Each of the three elements in this list has a non-philosophical counterpart, from which it is distinguished by its explicitly rational and critical way of proceeding and by its systematic nature. Everyone has some general conception of the nature of the world in which they live and of their place in it. Metaphysics replaces the underlying assumptions embodied in such a conception with a rational and organized body of beliefs about the world as a whole. Everyone has occasion to doubt and question beliefs, their own or those of others, with more or less success and without any theory of what they are doing. Epistemology seeks by argument to make explicit the rules of correct belief formation. Everyone governs their conduct by directing it to desired or valued ends. Ethics, or moral philosophy, in its most inclusive sense, seeks to articulate, in rationally systematic form, the rules or principles involved.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;From the &lt;a href=&quot;http://en.wikipedia.org/wiki/Philosophy#cite_note-&quot;&gt;wikipedia article about philosophy&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;do-you-really-need-it&quot;&gt;Do you really need it?&lt;/h4&gt;

&lt;p&gt;Thing is, you still need to think on your own. You still need to determine what you want to do with your life. What reality or world view you want to have. As programmers we use language and abstractions as tools. In order to use these in a “&lt;a href=&quot;https://patchwork.kernel.org/patch/705751/&quot;&gt;constructive way&lt;/a&gt;” (not jiggle things randomly until they work), you need to think and learn.&lt;/p&gt;

&lt;h4 id=&quot;evaluating-software&quot;&gt;Evaluating software&lt;/h4&gt;

&lt;p&gt;In many cases you need to evaluate things on your own. You will encounter different entities that try to get you to use different tools and different libraries. Or will you blindly let companies shove their solutions down your throat?&lt;/p&gt;

&lt;p&gt;What kind of shift of reality do you experience when you change environment? For instance change:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Programming language&lt;/li&gt;
  &lt;li&gt;Web framework&lt;/li&gt;
  &lt;li&gt;Between desktop and web programming&lt;/li&gt;
  &lt;li&gt;Between server and client programming&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When shifting between these environments, it’s also a shift in how you solve problems. Different programmers value different writing experiences. Compare the static typing of java to write client applications in Google Web Toolkit to scripting using JavaScript. It’s a reflection of how you think about programming.&lt;/p&gt;

&lt;p&gt;How do you evaluate a library? If it’s commercial, you try to guess how long it will be maintained by the company making it. If it’s open source, you try to ascertain how well maintained it is. If it is currently maintained et.c.. You try to guess the quality of the library. Also there is such aspects as cost and license. Can you afford to use the library? Does the library have a licence so that you can use it together with your proprietary code base?&lt;/p&gt;

&lt;h4 id=&quot;you-are-not-a-simple-consumer-of-tools&quot;&gt;You are not a simple consumer of tools&lt;/h4&gt;

&lt;p&gt;As a programmer, you should be willing to write your own library if that’s what you need. You should be able to evaluate what tools to use when doing your work. Programming is the act of creating text that can be used as tools. You are a toolmaker and a tool consumer. Builder and toolmaker. You are an author and a reader. It helps to think.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Web versus native app login</title>
      <link>https://assertfail.gewalli.se/2012/07/13/web-versus-native-app-login.html</link>
      <pubDate>Fri, 13 Jul 2012 14:53:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/07/13/web-versus-native-app-login</guid>
      <description>&lt;p&gt;What are the most important differences between native applications and web applications (for mail, rss et.c.) when it comes to login?&lt;/p&gt;

&lt;p&gt;Native applications usually store login information. For web applications this is dependant on the browser in order to store login form. Depending on application, there can be days between resubmission of credentials.&lt;/p&gt;

&lt;p&gt;For unix applications there are alternatives like ssh shared keys. It enables connection from one machine (login) to another. It would be interesting if this approach could be reused for browser to web server communication. That is: generating a shared key for a single browser/machine. If you could generate a one time use string from the phone company in order to anonymize the identity? The identity of the user would still be transparent to ISP and other infrastructure providers. The setup to use a site from a new machine/login would be a hassle. For single use scenario: Maybe one session tokens sent to the phone when you are at an internet cafe?&lt;/p&gt;

&lt;p&gt;Currently the alternatives are reduced to form fillers and password managers. Some browsers implement these features.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Refusing to work with a technology or a tool</title>
      <link>https://assertfail.gewalli.se/2012/06/10/refusing-to-work-with-technology-or.html</link>
      <pubDate>Sun, 10 Jun 2012 12:21:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/06/10/refusing-to-work-with-technology-or</guid>
      <description>&lt;h2 id=&quot;refusing&quot;&gt;Refusing?&lt;/h2&gt;

&lt;p&gt;As a developer, assume that you are given technology or tool X and told that you need to create Y using it. Sometime it’s just getting down to business and getting it done. Sometimes you realize that using said technology is a mistake. It could be that the technology isn’t appropriate for the task. It could be that there are simpler cheaper solutions (things that take less of your time). It could also be that you feel that it’s outside of your job: Like asking an accountant to do the floors.&lt;/p&gt;

&lt;h3 id=&quot;what-do-you-do&quot;&gt;What do you do?&lt;/h3&gt;

&lt;p&gt;What you feel as professional, refusal to waste money and resources, could be interpreted as unprofessional. Your refusal could be interpreted by your manager as &lt;a href=&quot;http://programmers.stackexchange.com/questions/84332/how-to-deal-with-the-developers-refusing-to-use-certain-technologies-or-tools&quot;&gt;behaving as a child&lt;/a&gt;:
“Developers who act like children (refusing to use a tool mandated by a customer!) are not good developers no matter what their coding skills. …”
The above answers sounds a bit childish: Since my parents refuse to let me eat candy, they are not good parents.
Another answers deals with the role of a developer (slightly rewritten):
“you hired developers and you are trying to get them to do something else”&lt;/p&gt;

&lt;h4 id=&quot;if-its-not-your-job&quot;&gt;If it’s not your job&lt;/h4&gt;

&lt;p&gt;A more experienced coworker told me that the best action is to endure. If you get to do more interesting things later on, then it could be worth hanging in there. If your manager starts to give you more of the same work, since you have done so well before, then it might be time to look for a new job. It could be that your skills as a developer are less valued than work with technology or tool X at that company.&lt;/p&gt;

&lt;h4 id=&quot;creating-shoddy-solutions&quot;&gt;Creating shoddy solutions?&lt;/h4&gt;

&lt;p&gt;Developers are usually driven to do a good job. I’ve done things I’m not proud of. I’ve helped create solutions that are shoddy because the underlying technology is wrong for the customer. But I’ve done it since the customer wanted it. I’ve tried to do the best job I can. I’ve informed my superiors about the problems. It could be that the shoddy solution is good enough for the customer. It could be that you realize that technology or tool X is really good when used specifically to do the things it’s designed for. You can then help customers use X when it’s appropriate.&lt;/p&gt;

&lt;h4 id=&quot;try-to-offer-alternatives&quot;&gt;Try to offer alternatives&lt;/h4&gt;

&lt;p&gt;It could be that the request to work with technology or tool X is simply the request to get work Y done. If that’s the case, then you can reason with your manager about not involving technical terms when talking about what needs to be done.
It could be that a change of requirements can make the technology or tool a better fit. In that case, you should try to get your manager to steer the customer in the right direction.&lt;/p&gt;

&lt;h3 id=&quot;what-should-you-avoid&quot;&gt;What should you avoid?&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Making it personal or emotional. This will only make it harder in the future to work together.&lt;/li&gt;
  &lt;li&gt;Refusing in front of others. This might require your manager to save face.&lt;/li&gt;
  &lt;li&gt;Talking about the technical reason to a non technical manager or customer. This will sound like an excuse to a non technical person. You should give an easy to understand summary.&lt;/li&gt;
  &lt;li&gt;Fooling yourself into believing that technology Y, that you have not tried yet, is better. It might be better in some aspects. It might also be that it’s got different problems.&lt;/li&gt;
  &lt;li&gt;Fooling yourself into believing that technology Z, that you usually use, is better. If you don’t know technology X, then an outright dismissal of it is without grounds. That said, you should be skeptical of any technology that you hear fearful rumours about.&lt;/li&gt;
  &lt;li&gt;Fooling yourself into believing that you can roll your own framework that does it better.&lt;/li&gt;
  &lt;li&gt;Fooling yourself into believing that you need a framework when all you need is a bit of code.&lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>Technology and music</title>
      <link>https://assertfail.gewalli.se/2012/06/03/technology-and-music.html</link>
      <pubDate>Sun, 03 Jun 2012 19:08:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/06/03/technology-and-music</guid>
      <description>&lt;h4 id=&quot;we-dont-even-know-how-old-instruments-are&quot;&gt;We don’t even know how old instruments are&lt;/h4&gt;

&lt;p&gt;The earliest type of instrument is thought to be flutes. According to wikipedia this technology could be as old as 43,400 and 67,000 years. Simple devices for making rhythm where probably made: drums, rattles. But since they are usually composed of organic matter, they would decompose leaving little trace. Without knowing much I would guess that humans developed stringed instruments relatively early. My unscientific guess is that these kinds of instruments developed alongside bow and arrow. Making them perhaps 18,000 years old. Maybe even older. Or perhaps the use of instruments as a musical tool is more recent (maybe 9,000 years old). I’m very much colored by my perception of human artistic expression.&lt;/p&gt;

&lt;h4 id=&quot;metal-working&quot;&gt;Metal working&lt;/h4&gt;

&lt;p&gt;As technology advanced, so would the potential for musical instruments advance. With metal working cymbals, sistrum, bells as well as gongs can be made. Trumpets could be made in metal to produce new sounds.&lt;/p&gt;

&lt;h4 id=&quot;hydraulic-andpneumatic&quot;&gt;Hydraulic and pneumatic&lt;/h4&gt;

&lt;p&gt;The use of a mechanical power source enabled the hydraulic organ. The church organs must have been expensive technological marvel. It is a huge and impressive instrument. Probably one of the must awesome noisemakers before the invention of electric instruments.&lt;/p&gt;

&lt;h4 id=&quot;ca-18th-century&quot;&gt;Ca 18th century&lt;/h4&gt;

&lt;p&gt;The invention of the piano is around the late 17th and the beginning of 18th century. It’s an amazing technological advancement: A key operated string instrument.&lt;/p&gt;

&lt;h4 id=&quot;the-19th-century&quot;&gt;The 19th century&lt;/h4&gt;

&lt;p&gt;One specific piece of technology are behind some of the brass instruments: Valves. A recent tech, developed in the 19th century. An older technique was to use keys to open holes in a wind instrument.&lt;/p&gt;

&lt;h4 id=&quot;early-20th-century&quot;&gt;Early 20th century&lt;/h4&gt;

&lt;p&gt;In the 20th century electric instruments where developed. An excellent example of this is the electric guitar. The solid body electric guitar embodies the advent of modern industry. Produced with a wooden solid body and a bolt on neck together with magnetic pickup. It’s industrial design! A continuation of the old stringed instruments into the modern era.&lt;/p&gt;

&lt;p&gt;An exciting development is the theremin. An instrument totally unlike older instruments. Two metal antenna to sense the position of the hands to control frequency and amplitude.&lt;/p&gt;

&lt;p&gt;We have the telharmonium from just before the 20th century. It’s a musical instrument made with &lt;a href=&quot;http://en.wikipedia.org/wiki/Tonewheel&quot;&gt;tone wheels&lt;/a&gt;. It is an instrument that was made to generate musical sound from an electric signal. The instrument never caught on since it required immense amounts of power and weighed almost 200 tons. It was an impressive technological achievement since it could reproduce the sound of common woodwind instruments. Hammond created an affordable instrument, using tone wheels, called the Hammond organ.&lt;/p&gt;

&lt;h4 id=&quot;later-instruments&quot;&gt;Later instruments&lt;/h4&gt;

&lt;p&gt;With digitally generated sound, there are huge possibilities. There are enormous possibilities for advancing the usability of tone/sound generation. Another important factor is the price of instruments. A simple flute is very cheap. More complex instruments like an electric guitar or a keyboard are very affordable instruments. A keyboard has excellent usability: The keys maps to the chromatic scale.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Github for windows</title>
      <link>https://assertfail.gewalli.se/2012/05/25/github-for-windows.html</link>
      <pubDate>Fri, 25 May 2012 12:22:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/05/25/github-for-windows</guid>
      <description>&lt;p&gt;We had a small problem with one of the open source components that we use. One of my coworkers had to make a small alteration to that component (he isn’t using git at work). The &lt;a href=&quot;http://windows.github.com/help.html&quot;&gt;github for windows&lt;/a&gt; program makes interacting with github very easy on windows. All he had to do was to install the program (easy installation) and clone his fork. Really useful for this kind of work.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Regarding JavaScript namespaces</title>
      <link>https://assertfail.gewalli.se/2012/04/07/regarding-javascript-namespaces.html</link>
      <pubDate>Sat, 07 Apr 2012 07:22:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/04/07/regarding-javascript-namespaces</guid>
      <description>&lt;p&gt;There seems that the there is a shift from the Crockford style global variables to lower case namespaces or mixed case.
Older libraries use the Crockford style all caps.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://yuilibrary.com/yui/docs/event/basic-example.html&quot;&gt;YUI&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/douglascrockford/JSON-js/blob/master/json2.js&quot;&gt;JSON&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Probably this is influenced by Crockford’s &lt;a href=&quot;http://javascript.crockford.com/code.html&quot;&gt;thoughts about global variables&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Newer libraries use a less screamy namespace name:
jQuery, Prototype, Ext, dojo, ko&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Domain analysis of an application database</title>
      <link>https://assertfail.gewalli.se/2012/03/18/domain-analysis-of-application-database.html</link>
      <pubDate>Sun, 18 Mar 2012 12:32:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/03/18/domain-analysis-of-application-database</guid>
      <description>&lt;p&gt;A relational database is not only a source of content. It can also be used as a mine for domain information related to domain of an application that uses that database. The schema, if it is well maintained, will give you an overview of the problem domain. If the schema is not well maintained, you can factor out the conventions used in that particular database for relations and create a patched schema with the real relations. As you generate a graph of the database you can start filtering out some of the details (important for business logic) but not for the big picture. Some of the things you can get from the graph will be trivial. It might also give you a better understanding of the big picture. By plotting this graph, you can get a overview helpful for identifying subdomains.&lt;/p&gt;

&lt;p&gt;Maybe if we have a sufficiently large body of text describing the domain we can use a statistical approach to identify words relevant to the domain. The identification of these words will probably be easier if we have some larger body of text to use as for comparison of the frequencies of sentence construction words in that language (that is to filter out words like: ‘the’, ‘for’, ‘he’, ‘she’ et.c. in english).&lt;/p&gt;

&lt;p&gt;By combining the above simple domain mining techniques and talking to people fluent in the domain you can get a shallow technical understanding of the domain. This can be helpful for understanding the details of the domain.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Project Roslyn</title>
      <link>https://assertfail.gewalli.se/2012/03/17/project-roslyn.html</link>
      <pubDate>Sat, 17 Mar 2012 10:57:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/03/17/project-roslyn</guid>
      <description>&lt;p&gt;In some settings you might need to access more of the language than available through reflection and System.Linq.Expressions. You might want to look into &lt;a href=&quot;http://msdn.microsoft.com/en-us/hh543916&quot;&gt;project Roslyn&lt;/a&gt; or &lt;a href=&quot;https://github.com/icsharpcode/NRefactory/&quot;&gt;NRefactory&lt;/a&gt;. These will let you access the C# parser. This can be useful in many settings. For instance, to refactor C#. To render the code to another language.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Language</title>
      <link>https://assertfail.gewalli.se/2012/03/08/language.html</link>
      <pubDate>Thu, 08 Mar 2012 07:31:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/03/08/language</guid>
      <description>&lt;p&gt;Make sure that the environment variable LANG is set to “us_EN.UTF-8”. Otherwise you might get the translated versions.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Chocolatey</title>
      <link>https://assertfail.gewalli.se/2012/02/28/chocolatey.html</link>
      <pubDate>Tue, 28 Feb 2012 18:56:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/02/28/chocolatey</guid>
      <description>&lt;p&gt;Thanks to &lt;a href=&quot;http://geekswithblogs.net/robz/Default.aspx&quot;&gt;Fervent Coder&lt;/a&gt; we have &lt;a href=&quot;http://chocolatey.org/&quot;&gt;Chocolatey&lt;/a&gt;. It can be used to setup a development machine with new software. Installing java, notepad++ becomes as easy as:&lt;br /&gt;
&lt;a href=&quot;http://chocolatey.org/packages/javaruntime&quot;&gt;cinst javaruntime&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>File upload</title>
      <link>https://assertfail.gewalli.se/2012/02/22/file-upload.html</link>
      <pubDate>Wed, 22 Feb 2012 20:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/02/22/file-upload</guid>
      <description>&lt;p&gt;The alternatives right now (2012-02-22):&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Standard html: File select together in a form that is submitted to a page. (firefox, chrome, IE)&lt;/li&gt;
  &lt;li&gt;Iframe hack: File select together with hidden iframe used to upload file. (firefox, chrome, IE)&lt;/li&gt;
  &lt;li&gt;Flash (all flash enabled browsers)&lt;/li&gt;
  &lt;li&gt;FileReader (firefox, chrome)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;##&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Drag and drop together with FileReader and ajax post.&lt;/li&gt;
  &lt;li&gt;File select together with FileReader and ajax post.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When building ordinary web applications then the first alternative is definitely the best. It’s simple and works well. If you are building a more JavaScript intense application you are in a different mess. If you are supporting IE 7-9 then alternative 2 and 3 is what you are looking for. To enable the best experience you could sniff if the browser handles FileReader (since IE10 might support it) and enable a better experience in that case.&lt;/p&gt;

&lt;p&gt;Note: I’ve only considered firefox, chrome and IE.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Continuous code coverage</title>
      <link>https://assertfail.gewalli.se/2012/02/19/continuous-code-coverage.html</link>
      <pubDate>Sun, 19 Feb 2012 16:54:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/02/19/continuous-code-coverage</guid>
      <description>&lt;p&gt;What if we could do a continuous code coverage? That is, while debugging and testing the app, storing the coverage information. A first version would consider lines that are not changed as covered if they have been executed during previous runs. This could be a sort of blunt tool to help isolate code that should be flagged either for removal, for code review, automatic or manual testing.&lt;/p&gt;

&lt;p&gt;It should be simple enough to &lt;a href=&quot;https://github.com/wallymathieu/js_codecover_reporting&quot;&gt;send information&lt;/a&gt; about code coverage when running JavaScript code. The challenge is to map the coverage information with source lines and keeping some sort of data structure that represents the code and coverage information that can be updated with the old coverage information form previous versions of the code.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Avoid batch files</title>
      <link>https://assertfail.gewalli.se/2012/02/17/avoid-batch-files.html</link>
      <pubDate>Fri, 17 Feb 2012 19:36:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/02/17/avoid-batch-files</guid>
      <description>&lt;p&gt;When programming on windows, you will sometimes need to execute batch files. It might seem like a good idea to do something simple in a batch file. This is the time you should realize that it it’s a slippery slope. Dont go there.&lt;/p&gt;

&lt;p&gt;There are excellent alternatives! Powershell works well for scripting (as long as you accept the signing or set-execution-policy). Ruby is sweet for scripting. There are alternatives that will let simple things be simple.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Metro style revolution</title>
      <link>https://assertfail.gewalli.se/2012/01/29/metro-style-revolution.html</link>
      <pubDate>Sun, 29 Jan 2012 13:14:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2012/01/29/metro-style-revolution</guid>
      <description>&lt;p&gt;The more I think about the &lt;a href=&quot;http://msdn.microsoft.com/en-us/windows/apps/br229512&quot;&gt;metro style&lt;/a&gt;, it sounds really revolutionary for microsoft design. I’ve started looking at how the new windows phone style looks. It looks more modern than the other themes for smart phones. Probably because it’s not been used as much.&lt;/p&gt;

&lt;p&gt;I feel that &lt;a href=&quot;http://en.wikipedia.org/wiki/Windows_Aero&quot;&gt;windows aero&lt;/a&gt; was to bloated in visual space. It looks sweet on a machine with high enough resolution and screen space, but looks to bulky on other things. The default margins take to much space. The &lt;a href=&quot;http://en.wikipedia.org/wiki/Windows_XP_themes#Windows_Classic_theme&quot;&gt;classic gray theme&lt;/a&gt; has been my preferred theme when working in windows. When working, it’s nice to have a theme that does not require attention.&lt;/p&gt;

&lt;p&gt;So the conclusion is that I’m excited about the possible metro theme for windows.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Using backbone routes together with knockout</title>
      <link>https://assertfail.gewalli.se/2011/12/13/using-backbone-routes-together-with.html</link>
      <pubDate>Tue, 13 Dec 2011 11:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/12/13/using-backbone-routes-together-with</guid>
      <description>&lt;p&gt;We have &lt;a href=&quot;https://github.com/SteveSanderson/knockout/wiki/Scott%27s-method&quot;&gt;Scott’s method&lt;/a&gt;. He uses backbone together with knockout. You might want to read the following &lt;a href=&quot;http://groups.google.com/group/knockoutjs/browse_thread/thread/9a7ad2b44885cf5a?pli=1&quot;&gt;google group posts&lt;/a&gt;. I like how you declare your setup on the app object. The problem with using only knockout for creating js app’s is that it only focused on view to modelview binding. Also Derick Bailey has made &lt;a href=&quot;http://lostechies.com/derickbailey/2011/11/22/backbone-vs-knockout/&quot;&gt;a comment&lt;/a&gt; about the curious idea that you choose either knockout or backbone.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>MVVM Plus Conductor with Knockout js</title>
      <link>https://assertfail.gewalli.se/2011/12/01/mvvm-plus-conductor-with-knockout-js.html</link>
      <pubDate>Thu, 01 Dec 2011 16:34:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/12/01/mvvm-plus-conductor-with-knockout-js</guid>
      <description>&lt;p&gt;A better fit in the browser world for knockout than MVC is to have something like a controller. A class responsible for being an endpoint for routes. This is naturally coupled with the responsibility of changing between screens. Since controller is such a loaded word, lets simply call it conductor.&lt;/p&gt;

&lt;p&gt;That gives you the following components: Model view, view-model and conductor. In order to implement the pattern you can use crossroads js or something similar.&lt;/p&gt;

&lt;p&gt;That means that crossroads will route to different conductors that marries view-models and views and sends them off. When the view-model changes in such a way that it needs to update the url, it tells the conductor to change the url. Anyone can also ask a conductor to present an object (thus changing the url and updating the screen).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>using underscore filter in IE 7 &amp; 8</title>
      <link>https://assertfail.gewalli.se/2011/11/09/using-underscore-filter-in-ie-7-8.html</link>
      <pubDate>Wed, 09 Nov 2011 20:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/11/09/using-underscore-filter-in-ie-7-8</guid>
      <description>&lt;p&gt;Array.prototype.filter seems to be slightly off in IE7-8. It looks like they have added support for standard array functions. That is, it looks like there is a prototype for this in IE7-8 mode in IE9. The problem is that the filter prototype does not work exactly as expected in underscore.&lt;/p&gt;

&lt;p&gt;If we look at the documentation for this method on &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/ff679973(v=vs.94).aspx&quot;&gt;msdn&lt;/a&gt; you find that this is probably a bug.&lt;/p&gt;

&lt;p&gt;It is simple to patch the prototype implementation you find using F12 in IE. Otherwise you could use the prototype described in the &lt;a href=&quot;http://stackoverflow.com/questions/2790001/fixing-javascript-array-functions-in-internet-explorer-indexof-foreach-etc&quot;&gt;stackoverflow&lt;/a&gt; post (i.e. Mozilla’s Array filter implementation):
&lt;a href=&quot;https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter&quot;&gt;https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Press play on tape</title>
      <link>https://assertfail.gewalli.se/2011/10/17/different-controllers.html</link>
      <pubDate>Mon, 17 Oct 2011 08:31:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/10/17/different-controllers</guid>
      <description>&lt;p&gt;Lovely geekery when &lt;a href=&quot;http://www.youtube.com/watch?v=hLWw1OpDrpI&quot;&gt;press play on tape plays cannon fodder&lt;/a&gt; with old game controllers. Why not &lt;a href=&quot;http://www.youtube.com/watch?v=mYZXNVHVfhc&quot;&gt;monkey island&lt;/a&gt; :).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>dotnet-console is now Isop</title>
      <link>https://assertfail.gewalli.se/2011/10/08/dotnet-console-is-now-isop.html</link>
      <pubDate>Sat, 08 Oct 2011 21:28:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/10/08/dotnet-console-is-now-isop</guid>
      <description>&lt;p&gt;I’ve renamed the dotnet-console project on github to &lt;a href=&quot;https://github.com/wallymathieu/isop&quot;&gt;isop&lt;/a&gt;. Isop is the swedish name for hyssop. Like any spice it is intended to give flavor to the development of command line apps in .net.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Using msysgit in cygwin</title>
      <link>https://assertfail.gewalli.se/2011/10/07/using-msysgit-in-cygwin.html</link>
      <pubDate>Fri, 07 Oct 2011 09:21:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/10/07/using-msysgit-in-cygwin</guid>
      <description>&lt;p&gt;There are some pitfalls. One for instance is that it starts the editor wrong when running msysgit in the cygwin shell. Naturally I tried specifying different paths and ended up with the following configuration of gitconfig:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;c:\\cygwin\\home\\wallymathieu\\.gitconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;div class=&quot;language-ini highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nn&quot;&gt;[core]&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;py&quot;&gt;editor&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;/c/Program Files (x86)/Vim/vim73/gvim.exe&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\\&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
    </item>
    
    <item>
      <title>Command line option parsing</title>
      <link>https://assertfail.gewalli.se/2011/10/07/command-line-option-parsing.html</link>
      <pubDate>Fri, 07 Oct 2011 05:58:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/10/07/command-line-option-parsing</guid>
      <description>&lt;p&gt;I’ve updated the &lt;a href=&quot;https://github.com/wallymathieu/isop&quot;&gt;dotnet-console&lt;/a&gt; to enable help. It’s not finished, but it’s looking better. Still needs a lot of refactoring though. The tests document the more stable fluent interface. The stuff behind the fluent interface is more prone to change.
It’s an interesting experience to code the tests against a higher level api that is relatively stable (as an interface) and have an underlying changing implementation.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Having at least 2 monitors?</title>
      <link>https://assertfail.gewalli.se/2011/10/02/having-at-least-2-monitors.html</link>
      <pubDate>Sun, 02 Oct 2011 21:37:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/10/02/having-at-least-2-monitors</guid>
      <description>&lt;p&gt;Why so &lt;a href=&quot;http://www.hanselman.com/blog/TheSweetSpotOfMultipleMonitorProductivityThatMagicalThirdMonitor.aspx&quot;&gt;many monitors&lt;/a&gt;? I used to have the same kind of layout on my home computer while at the university by using X11. You have virtual desktops (not to be confused with the software) or workspaces.&lt;/p&gt;

&lt;p&gt;The same concept on mac os x differs significantly from how it works on linux.&lt;/p&gt;

&lt;p&gt;Part of the problem might be technological: When I’ve tried out virtual desktops on windows, the programs become extremely unstable.&lt;/p&gt;

&lt;p&gt;User friendly: The concept of virtual desktop is probably not very conceptually friendly for a person without a lot of experience with computers. Since power users are assumed to have enough money to buy enough big monitors.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Simple noise on the arduino</title>
      <link>https://assertfail.gewalli.se/2011/10/02/simple-noise-on-arduino.html</link>
      <pubDate>Sun, 02 Oct 2011 19:04:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/10/02/simple-noise-on-arduino</guid>
      <description>&lt;p&gt;Inspired by the &lt;a href=&quot;http://www.motherboard.tv/2011/9/29/minimalism-worship-these-sweet-loops-were-made-with-only-one-line-of-code&quot;&gt;minimalists&lt;/a&gt; I tried this out on the arduino:&lt;/p&gt;

&lt;div class=&quot;language-c++ highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;speakerPin&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  
  
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;outp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;byte&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;analogWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;speakerPin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;delayMicroseconds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;200&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  
  
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pinMode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;speakerPin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;OUTPUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
  
  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Set up Timer 2 to do pulse width modulation on the speaker  &lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// pin.  &lt;/span&gt;
  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Use internal clock (datasheet p.160)  &lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ASSR&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;EXCLK&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AS2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;  
  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Set fast PWM mode  (p.157)  &lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TCCR2A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WGM21&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WGM20&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TCCR2B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WGM22&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// Do non-inverting PWM on pin OC2A (p.155)  &lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// On the Arduino this is pin 11.  &lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TCCR2A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TCCR2A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COM2A1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COM2A0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TCCR2A&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COM2B1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;COM2B0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt;  
  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// No prescaler (p.158)  &lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;TCCR2B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TCCR2B&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CS12&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CS11&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_BV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CS10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
  
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  
  
&lt;span class=&quot;kt&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;loop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;int&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;  
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;outp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;\&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;12&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;63&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;));&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It does sound somewhat similar. So right now it’s just a hack in order to try it out.&lt;/p&gt;

&lt;p&gt;Note:&lt;br /&gt;
The code above is corrected with a little help from &lt;a href=&quot;http://forskningsavd.se/&quot;&gt;Davey at forsken&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Implementing Dispose method in .net</title>
      <link>https://assertfail.gewalli.se/2011/09/25/implementing-dispose-method-in-net.html</link>
      <pubDate>Sun, 25 Sep 2011 19:30:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/09/25/implementing-dispose-method-in-net</guid>
      <description>&lt;h3 id=&quot;dispose&quot;&gt;Dispose&lt;/h3&gt;

&lt;p&gt;In order to release unmanaged resources you need to use or implement the dispose method.&lt;/p&gt;

&lt;h3 id=&quot;unmanaged-resource&quot;&gt;Unmanaged resource&lt;/h3&gt;

&lt;p&gt;So what is an unmanaged resource? It is simply resources that the CLR does not manage for you. For example: File streams, database connections, P/Invoked api:s.&lt;/p&gt;

&lt;h3 id=&quot;how-to-implement-dispose&quot;&gt;How to implement Dispose?&lt;/h3&gt;

&lt;p&gt;Msdn gives a rather clear &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx&quot;&gt;answer&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You need to implement the IDisposable interface.&lt;/li&gt;
  &lt;li&gt;If you have implemented a finalizer as well then you need to add a call to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GC.SuppressFinalize&lt;/code&gt; inside the dispose method. This is to avoid that the finalize method is called for the object.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;when-is-it-unsafe-to-call-both-dispose-and-finalize&quot;&gt;When is it unsafe to call both dispose and finalize?&lt;/h3&gt;

&lt;p&gt;One reason could be that you’re dealing with a P/Invoked api. Telling the unmanaged code to clean up the resources associated with a particular pointer twice can cause unintended consequences. Using closed handles is a security risks since windows recycles handles. Another reason is performance: A finalize is costly to perform.&lt;/p&gt;

&lt;h3 id=&quot;alternative-to-using-intptr&quot;&gt;Alternative to using IntPtr&lt;/h3&gt;

&lt;p&gt;In order to simplify the use of operating system handles you can use “Safe Handle”.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Windows 8</title>
      <link>https://assertfail.gewalli.se/2011/09/19/windows-8.html</link>
      <pubDate>Mon, 19 Sep 2011 20:26:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/09/19/windows-8</guid>
      <description>&lt;p&gt;I like the look of windows 8. For touch devices it will be sweet. What confounds me is that the start menu is replaced by the “Metro” application launcher. That sounds exceedingly annoying when on standard hardware. Where is the love for an ordinary PC?&lt;/p&gt;

&lt;p&gt;The reason for the weird usability is that it is intended for touch enabled computers:
&lt;a href=&quot;https://www.youtube.com/watch?v=ntSdfGzF60M&quot;&gt;&lt;img src=&quot;https://img.youtube.com/vi/ntSdfGzF60M/0.jpg&quot; alt=&quot;iPad iOS 5 vs Windows 8 Slate&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m confused about the talk about the name Windows 8. Is it supposed to be a general windows?&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>WinRT replaces win32</title>
      <link>https://assertfail.gewalli.se/2011/09/19/winrt-replaces-win32.html</link>
      <pubDate>Mon, 19 Sep 2011 20:21:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/09/19/winrt-replaces-win32</guid>
      <description>&lt;p&gt;Sounds interesting to hear about the new WinRT api:s for windows. Reading up on it WinRT are COM objects in contrast to the Win32 architecture.
One of the exciting things about this is the promise of being able to use xaml in c++.&lt;/p&gt;

&lt;p&gt;An overview of WinRT by Marius Bancila:
&lt;a href=&quot;http://mariusbancila.ro/blog/2011/09/15/windows-runtime/&quot;&gt;Windows Runtime&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s quite interesting to read the list on Msdn:
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/windows/apps/hh464945(v=VS.85).aspx&quot;&gt;Windows Runtime and the Windows API&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right now it’s probably to early to get a good idea of how everything will look and exactly what features will be accessible for Metro style apps.&lt;/p&gt;

&lt;p&gt;Replacing the Win32 api:s is probably an overstatement. I would guess that for some things you might be forced to use older api:s.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Running Rake under cygwin</title>
      <link>https://assertfail.gewalli.se/2011/09/01/running-rake-under-cygwin.html</link>
      <pubDate>Thu, 01 Sep 2011 13:14:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/09/01/running-rake-under-cygwin</guid>
      <description>&lt;p&gt;I had some problems with running rake under cygwin. I get the following error while trying to execute rake:&lt;br /&gt;
C:\Ruby192\bin\ruby.exe: No such file or directory – /cygdrive/c/Ruby192/bin/rake (LoadError)&lt;/p&gt;

&lt;p&gt;Could it be that the problem is that the first line in rake:&lt;/p&gt;

&lt;div class=&quot;language-rb highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#!/usr/bin/env ruby&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Will return C:\Ruby192\bin\ruby.exe&lt;/p&gt;

&lt;p&gt;By being more explicit about what to run you can avoid the problem:&lt;br /&gt;
rake.bat&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Writing code without tests</title>
      <link>https://assertfail.gewalli.se/2011/05/11/writing-code-without-tests.html</link>
      <pubDate>Wed, 11 May 2011 14:58:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/05/11/writing-code-without-tests</guid>
      <description>&lt;p&gt;Suppose that you write code without tests that compile. Suppose that those parts do not have any user interface or tests. Then what you’re doing is actually pushing development cost over to other parts of the project that make use of the code. This will probably mean that any cost/time estimates concerning dependent code needs to be adjusted in order to be able to pay for the additional cost.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Command line option parsing</title>
      <link>https://assertfail.gewalli.se/2011/04/24/command-line-option-parsing.html</link>
      <pubDate>Sun, 24 Apr 2011 18:10:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/04/24/command-line-option-parsing</guid>
      <description>&lt;h2 id=&quot;ndesk-options&quot;&gt;NDesk Options&lt;/h2&gt;

&lt;p&gt;I started writing an argument parser without knowing about:
&lt;a href=&quot;http://www.ndesk.org/Options&quot;&gt;NDesk.Options&lt;/a&gt;
Where you have the following kind of syntax:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;string data = null;
   bool help   = false;
   int verbose = 0;

var p = new OptionSet () {
    { &quot;file=&quot;,      v =&amp;gt; data = v },
    { &quot;v|verbose&quot;,  v =&amp;gt; { ++verbose } },
    { &quot;h|?|help&quot;,   v =&amp;gt; help = v != null },
   };
   List extra = p.Parse (args);
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id=&quot;fubucore&quot;&gt;FubuCore&lt;/h2&gt;

&lt;p&gt;Since this post, there is a new option: &lt;a href=&quot;http://lostechies.com/chadmyers/2011/06/06/cool-stuff-in-fubucore-no-6-command-line/&quot;&gt;Command line in FubuCore&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;powershell&quot;&gt;Powershell&lt;/h2&gt;

&lt;p&gt;If you’re using powershell it just might be simpler to load your program as an assembly and invoke the classes directly. Looking at &lt;a href=&quot;http://stackoverflow.com/questions/3360867/add-reference-to-dll-in-powershell-2-0&quot;&gt;stackoverflow&lt;/a&gt; there is a command &lt;a href=&quot;http://technet.microsoft.com/en-us/library/dd315241.aspx&quot;&gt;Add-Type&lt;/a&gt;. Otherwise you could use standard .net assembly load.&lt;/p&gt;

&lt;h2 id=&quot;isop&quot;&gt;Isop&lt;/h2&gt;

&lt;p&gt;All of the solutions above are not really what I’m after. Thus I’ve written another argument parser loosely based on &lt;a href=&quot;http://simpleconsole.rubyforge.org/&quot;&gt;SimpleConsole&lt;/a&gt; :
&lt;a href=&quot;https://github.com/wallymathieu/isop&quot;&gt;Isop&lt;/a&gt;
I didn’t really think views in an console app was that useful. Instead I’ve tried to do some of the plumbing in order for you to write console applications more like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-C#&quot;&gt;static void Main(string[] args)
{
   new Build()
      .Parameter(&quot;server&quot;,arg=&amp;gt;server=arg)
      .Recognize(typeof(CustomerController))
      .Parse(args)
      .Invoke(Console.Out);

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There is some simple syntax to extend this. To Set culture, TypeConverter et.c.&lt;/p&gt;

&lt;p&gt;So you would invoke the method “Add” on the class “CustomerController” with the arguments id and name:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;CustomerConsoleApp.exe Customer Add --id 1234 --name Arne
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
    <item>
      <title>Testing SQL database</title>
      <link>https://assertfail.gewalli.se/2011/04/17/testing-sql-database.html</link>
      <pubDate>Sun, 17 Apr 2011 13:40:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/04/17/testing-sql-database</guid>
      <description>&lt;p&gt;What strategies do I know of on how to test your code depending on a database?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Using &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx&quot;&gt;TransactionScope&lt;/a&gt; so that you can roll back any changes done by tests.&lt;/li&gt;
  &lt;li&gt;Setting up a fresh database with the same schema.
    &lt;ul&gt;
      &lt;li&gt;Using NHibernate SchemaExport(cfg).Execute to export an existing schema onto the new database.&lt;/li&gt;
      &lt;li&gt;Run your migrations to set the database in the correct state.&lt;/li&gt;
      &lt;li&gt;Use Code First, auto migrations or whatchamacallit call it. That is, let the ORM generate the tables and columns based upon your data objects. For instance Entity Framework Code First or Subsonic Auto Migrations. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What are the pros and cons of these approaches?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;TransactionScope:
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;Pros&lt;/strong&gt;: Very easy to setup. If you have a local version of the database, it’s very easy to get started.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Running everything under a transaction can be very costly. You need to tweak the configuration of the transaction coordinator. If you forget to use TransactionScope, there is a danger that you get rubbish data in your test database making your tests brittle.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Fresh database with the same schema:
    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;Pros&lt;/strong&gt;: By having migrations that are well tested, it can be considerably easier to create new installations. &lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Cons&lt;/strong&gt;: Using a slightly different schema for your tests (for instance if you have sql scripts to do changes to the database and turn on Code First in your tests) can lead to unexpected behavior. If your logic depends on database specific functionality you might want to use migrations in order to have a fully working schema. It can also be a bit harder to setup. If you use a different database (for instance SQLite), database specific behavior may be an issue. Same vendor but different collation might also give you a headache.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
    <item>
      <title>Build/test time</title>
      <link>https://assertfail.gewalli.se/2011/04/16/buildtest-time.html</link>
      <pubDate>Sat, 16 Apr 2011 21:17:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/04/16/buildtest-time</guid>
      <description>&lt;h2 id=&quot;keep-solutions-simple-and-think-about-your-deliverables&quot;&gt;Keep solutions simple and think about your deliverables&lt;/h2&gt;

&lt;p&gt;Chad Myers at Los Techies tries to get a discussion about why it’s bad to have to many projects:
&lt;a href=&quot;http://lostechies.com/chadmyers/2008/07/16/project-anti-pattern-many-projects-in-a-visual-studio-solution-file/&quot;&gt;Project anti-pattern: Many projects in a Visual Studio Solution File&lt;/a&gt;
Some of the consideration is about build performance. He is referencing microsoft blog posts… I know the lure of getting to drink coffee while waiting for builds, but you’re not getting paid for coffee ;)
There is an article on O’Reilly about the cost of long development cycles:
&lt;a href=&quot;http://www.oreillynet.com/onjava/blog/2006/03/dead_time_code_compile_wait_wa.html&quot;&gt;Dead Time (…code, compile, wait, wait, wait, test, repeat)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is also reflected in the documentation on team development:
&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/bb668953.aspx&quot;&gt;Msdn: Team Development with Visual Studio Team Foundation Server: Chapter 3 – Structuring Projects and Solutions in Source Control&lt;/a&gt;
They recommend you to keep it simple:&lt;/p&gt;

&lt;p&gt;Keep the following considerations in mind when designing a project and solution structure:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Each project generates an assembly at build time. Start by determining what assemblies you want to create and then use this to decide what projects you need. Use this to determine how to factor your codebase into projects.&lt;/li&gt;
  &lt;li&gt;Start with the simplest single solution structure. Only add complexity to your structure when it is really necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;…&lt;/p&gt;

&lt;p&gt;From Brad Adams msdn blog:
&lt;a href=&quot;http://blogs.msdn.com/b/brada/archive/2004/05/05/126934.aspx&quot;&gt;Perf trade off: lots of small assemblies or fewer bigger assemblies??&lt;/a&gt;
Puts it like this:
fewer bigger assemblies are better&lt;/p&gt;

&lt;p&gt;But he is talking about the performance of your applications. He mentions that they optimize for bigger assemblies. This is probably why visual studio is optimized this way as well.&lt;/p&gt;

&lt;h2 id=&quot;why-writing-unit-tests-and-not-only-integration-tests&quot;&gt;Why writing unit tests and not only integration tests?&lt;/h2&gt;

&lt;p&gt;Integration tests are immensely useful. However, the amount of time you spend on running tests is part of the above mentioned coffee time. If you are writing unit tests when testing your C# code this means less time spent being bored waiting.&lt;/p&gt;

&lt;h2 id=&quot;about-why-build-time-is-important&quot;&gt;About why build time is important&lt;/h2&gt;

&lt;p&gt;Note that they are even factoring in the time it takes you to run the tests. Imagine the Dead Time if you need to test manually. Not to rant, but the Dead Time ratio would be even higher. It’s simple economics that by writing tests as part of your development cycle will make you more productive. &lt;/p&gt;

&lt;p&gt;How often do you execute a build per day? Lets say that you do it every 30 minutes ca. If your build time is 1 minute. That gives you a 31 minute cycle. Divide 8 hours by this cycle and you get: 15.5. If the build time is 5 minutes that gives you: 13.7. That means you will be 12% less effective per day.&lt;/p&gt;

&lt;p&gt;The above mentioned number is actually misleading. An experienced developer working with well known tools may be able to work in longer cycles thus avoiding a lot of the Dead Time. However, when working in areas you are relatively inexperienced in (only worked with for a few years) you will benefit from the possibility to do explorative coding if your build/test cycle is short. Michael Feathers touches on this issue in his post about &lt;a href=&quot;http://michaelfeathers.typepad.com/michael_feathers_blog/2011/04/the-urge-to-repl-the-urge-to-test.html&quot;&gt;the Urge to REPL, the Urge to test&lt;/a&gt;. REPL is simply read-eval-print-loop. It’s why you can be very productive when you use scripting languages. You can do explorative coding and get instant feedback without waiting for builds.&lt;/p&gt;

&lt;p&gt;The numbers also suggests that monitoring your build time, test time can lead to greater productivity. Maybe not running all of the integration tests but letting a continuous integration server let you know if any of them fails.&lt;/p&gt;

&lt;p&gt;Another important factor is: Instant gratification. The joy of seeing the result of your action in a short amount of time.&lt;/p&gt;

&lt;h2 id=&quot;also-you-might-want-to-read&quot;&gt;Also you might want to read&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://www.simple-talk.com/dotnet/.net-framework/partitioning-your-code-base-through-.net-assemblies-and-visual-studio-projects/&quot;&gt;Partitioning Your Code Base Through .NET Assemblies and Visual Studio Projects&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://mikehadlow.blogspot.com/2011/06/i-dont-have-time-for-unit-tests.html&quot;&gt;I Don’t Have Time for Unit Tests&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>When to use mocks?</title>
      <link>https://assertfail.gewalli.se/2011/04/16/when-to-use-mocks.html</link>
      <pubDate>Sat, 16 Apr 2011 07:27:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/04/16/when-to-use-mocks</guid>
      <description>&lt;p&gt;You use mocks when you want to test &lt;a href=&quot;http://martinfowler.com/articles/mocksArentStubs.html#CouplingTestsToImplementations&quot;&gt;how the code interacts with the mocked objekts&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you care mostly about the end result, the final state, then it’s easier and less brittle to use fakes.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Migrations</title>
      <link>https://assertfail.gewalli.se/2011/04/15/migrations.html</link>
      <pubDate>Fri, 15 Apr 2011 19:49:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/04/15/migrations</guid>
      <description>&lt;p&gt;Listening to &lt;a href=&quot;http://herdingcode.com/?p=233&quot;&gt;herding code on fluent migrator&lt;/a&gt; is quite interesting.&lt;/p&gt;

&lt;p&gt;You could read &lt;a href=&quot;http://lostechies.com/seanchambers/2011/04/02/fluentmigrator-getting-started/&quot;&gt;Getting started with fluent migrator&lt;/a&gt;. If you feel the need to contribute there is &lt;a href=&quot;https://github.com/schambers/fluentmigrator&quot;&gt;fluent migrator on github&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>HOWTO write something FAST that works!</title>
      <link>https://assertfail.gewalli.se/2011/04/03/howto-write-something-fast-that-works.html</link>
      <pubDate>Sun, 03 Apr 2011 13:18:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/04/03/howto-write-something-fast-that-works</guid>
      <description>&lt;h2 id=&quot;focus&quot;&gt;Focus&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Make sure that you’re always doing the right thing (Erik Arnwald). Try to understand as much as possible of the domain you’re working on.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Trim furiously in the specifications and in the code. Make sure to identify the key benefit for the customer and focus solely on implementing this part. Additional wishes and demands tends to change rapidly and might not be necessary at all. The most common reason to break of deadlines and malfunctions is too complex specifications which are changed after the project has been started. (Carsten Hersom)&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;avoid-coding&quot;&gt;Avoid coding&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Sometimes you do not need to any custom code but can use standard components coupled with some education of the customer. For instance a standard CMS module. (Carsten Hersom)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Make sure to use stable and well tested third party tools and libraries for your core effort.  For instance. The guys maintaining NHibernate have extensive test coverage of the library. Avoid any tool that is not either really stable and old (and is used by many) or has a good test coverage.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The same criteria as for other tools apply to JavaScript frameworks and libraries.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;avoid-breaking-your-own-things&quot;&gt;Avoid breaking your own things&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Make sure that everybody uses database versioning tool. Preferably some form of migrations. It’s trivially easy to get into a inconsistent database state otherwise.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Make sure to have test coverage of any part of the code you’re unsure of how it works or any brittle parts. Things that are brittle is for instance the use of SqlCommand against stored procedures (SP). As the SP’s are changed code may stop to work without you knowing it. Make sure to have tests of the connection between C# and the sql database. Make sure that your tests are as terse as possible. Don’t be afraid to throw old tests away that are wrong and not needed. You can read about tests in the post: &lt;a href=&quot;/2011/03/31/why-automated-tests.html&quot;&gt;why automated tests&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Be really careful of hiding exceptions (catch the right exception). If something goes wrong, &lt;a href=&quot;http://ferd.ca/the-zen-of-erlang.html&quot;&gt;it should explode&lt;/a&gt;. It’s really hard to find errors if you have written something like: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;try{ ... } catch(Exception){}&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Use static analysis to your benefit. Turn off most of the crap (for instance fxcop style rules). Make sure that fxcop only reports relevant information. If unsure, avoid using this tool. Javascript lint is your annoying Besserwisser friend. Change the rules according to your need. You can download an integrated version for visual studio. Make sure to change what it reports (and that it does not complain about third party js libraries).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In order to avoid the time spent running integration tests, you might want setup a &lt;a href=&quot;http://en.wikipedia.org/wiki/Continuous_integration&quot;&gt;CI&lt;/a&gt; environment like &lt;a href=&quot;http://www.jetbrains.com/teamcity/&quot;&gt;team city&lt;/a&gt;. Make sure that you instill the value of tests in the developers you are working with.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;on-writing-tests&quot;&gt;On writing tests&lt;/h3&gt;

&lt;p&gt;You may ask: Why writing tests if time is short? The reason for this is that the time spent manually debugging and testing can be considerable. I’ve read estimates of the time spent in software development is mostly fixing bugs: Thus debugging and manually testing.&lt;/p&gt;

&lt;p&gt;Some people can write a working program really fast without tests and structure and with mostly duct tape and spit to keep it together. These people are few. Of the programmers I’ve met only a handful have this skill. For most of us it’s not quick and dirty, it’s just dirty. As one of my former coworkers (Mads) told me: Writing quick and dirty code is like taking a loan. There is always an interest that you need to pay. The longer you wait before refactoring the higher the cost.&lt;/p&gt;

&lt;h2 id=&quot;feedback&quot;&gt;Feedback&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Start by making a small part of your program that can be shown to people for feedback.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Release as soon as possible so that others (customers and domain experts) can give you feedback. It’s always better to have complete workflows in the gui (even if some of the functionality is faked). It helps the users and customers to visualize and provide better feedback. (Erik Arnwald)&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;In order to get people to contribute feedback on the current site/app you might want to consider automated deployments. This can help you when you need to deploy quickly for some reason (bugs). It can also help people unfamiliar with all the intricacies of a projects deployment to help with this activity.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;mentality&quot;&gt;Mentality&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Don’t be afraid. If the functionality is to complex, try to understand the problem the functionality is supposed to solve. It might be that you can solve it with less complexity. If you’re afraid of stuff breaking, write tests.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Avoid having people around that stress you or your coworkers. It might be better to have stressed managers or customers interact with only one person from the team. Productivity slows to a crawl if people get to stressed.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You need to talk and listen. The first thing that happens to me and others are that you stop listening when you’re stressed.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If you are in many projects that stress you out, you burn out or make an ass of yourself (burn yourself in the eyes of others).&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
    <item>
      <title>Why automated tests?</title>
      <link>https://assertfail.gewalli.se/2011/03/31/why-automated-tests.html</link>
      <pubDate>Thu, 31 Mar 2011 21:14:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/03/31/why-automated-tests</guid>
      <description>&lt;ol&gt;
  &lt;li&gt;Work is more fun when the things you create mostly works.&lt;/li&gt;
  &lt;li&gt;When fixing bugs, the probability of introducing new bugs is reduced.&lt;/li&gt;
  &lt;li&gt;Specifications of program behavior expressed as tests are easier to maintain than tutorial code or a word document specification.&lt;/li&gt;
  &lt;li&gt;In order to be able to write unit tests easier you are forced to simplify your classes.&lt;/li&gt;
  &lt;li&gt;Switching underlying technology or infrastructure. For example: If you have integration tests on your database repositories or data access layers it is easier to switch the underlying implementation. You have a way of verifying that important behavior is intact.&lt;/li&gt;
  &lt;li&gt;If you are writing code that:
    &lt;ul&gt;
      &lt;li&gt;Requires the use of the debugger frequently.&lt;/li&gt;
      &lt;li&gt;After you have written it, you fear to change.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;Do you really consider yourself a professional developer?&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some of it is in relation to having to work late at night and during weekends. Tests can help you with your definition of done, thus alleviating the need for late night coding sessions.&lt;/p&gt;

&lt;p&gt;Effective coding means to use the tools available when they are appropriate.&lt;/p&gt;

&lt;p&gt;Sometimes it’s about doing something simple:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Is the bug to complex to find using tests? The flow of the application is wrong…&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Maybe you could find it easier if you use a logger to trace the behavior?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You have written a test that recreates the problem, but you cant figure out why it doesn’t work.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Maybe putting breakpoints and debugging your test will help you find what’s wrong.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re a beginner. How do you start writing tests?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;If you’re writing C# then you want to read &lt;a href=&quot;http://www.amazon.com/Art-Unit-Testing-Examples-Net/dp/1933988274&quot;&gt;“the art of Unit Testing”&lt;/a&gt; by Roy Osherove.&lt;/li&gt;
  &lt;li&gt;If you’re unsure about how to write tests. Try using &lt;a href=&quot;http://www.typemock.com/test-lint&quot;&gt;test lint&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;Search posts done by &lt;a href=&quot;http://martinfowler.com/&quot;&gt;Martin Fowler&lt;/a&gt;, &lt;a href=&quot;http://www.threeriversinstitute.org/blog/&quot;&gt;Kent Beck&lt;/a&gt;, &lt;a href=&quot;http://cleancoder.posterous.com/&quot;&gt;Robert C. Martin (Uncle Bob)&lt;/a&gt;, &lt;a href=&quot;http://michaelfeathers.typepad.com/michael_feathers_blog/&quot;&gt;Michael Feathers&lt;/a&gt; .&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;How do you do when you test your code manually?&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;You set up the state of the program relevant before the method/procedure to test. In NUnit it’s called SetUp. You use this attribute to mark the method that sets up the state.&lt;/li&gt;
      &lt;li&gt;You fill in a form and click on a button, browse to a page with the right parameters in the url, et.c. When testing this is the actual test. You mark a method that does this by the Test attribute.&lt;/li&gt;
      &lt;li&gt;You look at the result from the action. In NUnit you use the static helper class Assert that contains methods to help you write the expected values.&lt;/li&gt;
      &lt;li&gt;After you’re finished testing, you may need to clean up. In NUnit this is accomplished by marking the a method with the attribute CleanUp.&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you are structured in your testing of your app you may know some of the domain of automatic testing. You can read about this in the above book by Roy Osherove.&lt;/p&gt;

&lt;p&gt;Also, writing tests is not a reason not to test what you’ve written manually. It is a way to make sure that you don’t have to do as much manually testing as before.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Role Playing games</title>
      <link>https://assertfail.gewalli.se/2011/03/31/role-playing-games.html</link>
      <pubDate>Thu, 31 Mar 2011 19:47:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/03/31/role-playing-games</guid>
      <description>&lt;p&gt;In real life you choose what parts to level, what to learn.&lt;/p&gt;

&lt;p&gt;As a developer do you choose to level up or are you stuck fighting the same kind of problems without gaining XP?&lt;/p&gt;

&lt;p&gt; As a developer do you choose to spend your experience:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Learning to talk to customers&lt;/li&gt;
  &lt;li&gt;Learning to work with others&lt;/li&gt;
  &lt;li&gt;Learn patterns, how to write prose&lt;/li&gt;
  &lt;li&gt;Learn new technologies&lt;/li&gt;
  &lt;li&gt;Learn how to write tests&lt;/li&gt;
  &lt;li&gt;Learn how to automate tasks (build, installation, et.c.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is just a short list. What I mean is that you have a possibility to choose certain skills. Probably you will ignore some of them. You will be mistaken if you think that the rest of the skills does not matter. Knowing what customers talk about matter! Being able to write correct software matter (that is, being able to write tests)! If you have chosen not to learn one of the skills, know that you will need other persons to lean on. You need to treat these people with respect. They are not dumb just because they are focused on parts you have not chosen to focus on.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>log4net</title>
      <link>https://assertfail.gewalli.se/2011/03/23/log4net.html</link>
      <pubDate>Wed, 23 Mar 2011 21:08:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/03/23/log4net</guid>
      <description>&lt;p&gt;For parsing log4j files there are some alternatives:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://logging.apache.org/chainsaw/index.html&quot;&gt;Chainsaw&lt;/a&gt; (java gui). If the links dead, note that it should be part of log4j.&lt;/li&gt;
  &lt;li&gt;Similar to chainsaw but in .net: &lt;a href=&quot;http://github.com/wallymathieu/log4net-logviewer&quot;&gt;logviewer&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://log2console.codeplex.com/&quot;&gt;Log2Console&lt;/a&gt; looks pretty sweet. It has some positive comments.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;On the logviewer page you find a sample configuration for using “log4net.Layout.XmlLayoutSchemaLog4j”. Note that the log4net xmllayout should be parse:able by logviewer as well.&lt;/p&gt;

&lt;p&gt;Both &lt;a href=&quot;http://nlog-project.org/&quot;&gt;NLog&lt;/a&gt; and &lt;a href=&quot;http://logging.apache.org/log4net/&quot;&gt;Log4Net&lt;/a&gt; can log to the log4j layout.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Logging for Commerce Server 2009</title>
      <link>https://assertfail.gewalli.se/2011/02/08/logging-for-commerce-server-2009.html</link>
      <pubDate>Tue, 08 Feb 2011 20:23:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/02/08/logging-for-commerce-server-2009</guid>
      <description>&lt;p&gt;You might want to start off by reading the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd451660(v=cs.90).aspx&quot;&gt;documentation from Microsoft&lt;/a&gt;. The short version of this text is that in the new CS2009 there is tracing and it is done through system.diagnostics. I don’t know the entire story, but it looks like the exception handling is piped through the trace.&lt;/p&gt;

&lt;p&gt;So in order to configure the logging for commerce server you will need to read up on the system.diagnostics tracing.You will need to add a source ”Microsoft.Commerce.Exceptions”. There you can choose your &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.aspx&quot;&gt;TraceListener&lt;/a&gt; and specify the information you need by reading up on &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/a10k7w6c.aspx&quot;&gt;TraceOptions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The default trace configuration can be found in SystemDiagnostics.xml in the Extensibility kit. You should be aware of that the default configuration logs to the Event handler. This is not always appreciated by your customers since they may want to have Medium Trust for the site.&lt;/p&gt;

&lt;p&gt;Note that this means that you can also write your own log-handler for these tracing events by inheriting from   &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener.aspx&quot;&gt;TraceListener&lt;/a&gt;.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Whats wrong with Commerce Server 2009</title>
      <link>https://assertfail.gewalli.se/2011/01/26/whats-wrong-with-commerce-server-2009.html</link>
      <pubDate>Wed, 26 Jan 2011 18:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2011/01/26/whats-wrong-with-commerce-server-2009</guid>
      <description>&lt;p&gt;Whats wrong with Commerce Server 2009 from a developer perspective?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Configuration: There is no single source of object mapping configuration. Multiple places to insert properties.&lt;/li&gt;
  &lt;li&gt;FaultException does not include the original exception.&lt;/li&gt;
  &lt;li&gt;The CS2009 api’s look very dynamic… It promises a lot more than it can deliver since it is based upon CS2007 API and thus quite limited.&lt;/li&gt;
  &lt;li&gt;No transactions for some of the entities. For instance profiles and catalog. &lt;/li&gt;
  &lt;li&gt;Integration with SharePoint by putting the configuration in SharePoint web.config. That’s not the way to go.&lt;/li&gt;
  &lt;li&gt;Granular permissions for all the web services, for all the databases. There is a lot of work just setting up CS.&lt;/li&gt;
  &lt;li&gt;Pipelines….&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How do you improve the experience?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Configuration: Just try to write integration tests to catch any errors due to configuration.&lt;/li&gt;
  &lt;li&gt;Problem with FaultException is fixed in &lt;a href=&quot;http://social.msdn.microsoft.com/Forums/en/commserver2009/thread/e33de899-3768-4fea-a914-641485291ef7&quot;&gt;CS2009 r2 CTP&lt;/a&gt; … Until an actual release, you might need to write your own logging for operation sequences (theres an extension point for this, just look at &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd451660(v=cs.90).aspx&quot;&gt;Microsoft.Commerce.Common.TextLoggingExceptionHandler&lt;/a&gt; and the configuration). I’ve not tried this, so I have had to look in the console output or Event log.&lt;/li&gt;
  &lt;li&gt;You could, if you had the time, write a different implementation of the operation sequence that does the queries for the basket or any other CS entity. I don’t know what level of the API the pipelines depend on. Probably easier to just ignore this issue and write some code that searches the CS database.&lt;/li&gt;
  &lt;li&gt;This is a serious issue. This means that you will need to clean up manually after any integration test. Just keep your integration tests small and write fake implementations of the CS entities repositories so that you can write unit tests.&lt;/li&gt;
  &lt;li&gt;If you’re not using default configuration and don’t need any serious modification of the web parts distributed with CS2009 then try to as early as possible,  put CS within it’s own web site and implement your web service wrapper around the methods using CS. Could be a bit tricky, but might save you a lot of work. It’s simple math, one big product configuration inside another big product with a lot of configuration equals a lot of work if you’re unlucky. I’ve heard rumors that Microsoft is implementing a service oriented version of CS (but until then, you’ll have to implement it yourself).&lt;/li&gt;
  &lt;li&gt;Permissions: &lt;a href=&quot;http://www.microsoft.com/downloads/en/details.aspx?FamilyID=8344d2bc-142a-4609-abab-db7f9a1e0f65&amp;amp;displaylang=en&quot;&gt;RTFM&lt;/a&gt;! To install CS you need to make sure that everything is setup correct.&lt;/li&gt;
  &lt;li&gt;Pipelines: If possible try to avoid using them.&lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
    <item>
      <title>Refactoring multiplicity, synchronous versus asynchonous</title>
      <link>https://assertfail.gewalli.se/2010/12/18/refactoring-multiplicity-synchronous.html</link>
      <pubDate>Sat, 18 Dec 2010 12:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/12/18/refactoring-multiplicity-synchronous</guid>
      <description>&lt;p&gt;Sometimes change hurts.&lt;/p&gt;

&lt;p&gt;You know what I’m talking about if you need to change the multiplicity of a relationship (let’s assume you talk about an ordinary sql database). For instance: From
&lt;em&gt;1 to 1&lt;/em&gt;
To
&lt;em&gt;1 to many&lt;/em&gt;
For instance, say it’s an address. The assumptions made when there is only one address permeates throughout the applications. For instance a person must have bills sent to a different address (his/her accountant or something &lt;a href=&quot;http://sv.wikipedia.org/wiki/God_man&quot;&gt;similar&lt;/a&gt;). However, when contacted, any mail needs to be sent to the home address. The code changes alone could be many. If there are a lot of reports based on the data (accessing the information without any layer) then these could be based on assumptions out of sync with reality. If you’re unlucky that might mean that you need to manually go through all the reports in the system and look for discrepancies. If you’re lucky the report will simply fail. If unlucky, it will show a random address.&lt;/p&gt;

&lt;p&gt;Synchronous versus asynchronous execution and parallel execution
jQuery has popularized asynchronous programming. Reactive extensions will perhaps simplify your tasks. Parallel LINQ (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd460688.aspx&quot;&gt;PLINQ&lt;/a&gt;) and the Task Parallel Library (&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/dd460717.aspx&quot;&gt;TPL&lt;/a&gt;) might even make the tasks even simpler. But what if your program assumes execution in a consecutive manner? That the parts that you need to make parallel or asynchronous are buried deep within layers of layers … It might be that your program design needs to be restructured.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Why git or mercurial?</title>
      <link>https://assertfail.gewalli.se/2010/12/10/why-git-or-mercurial.html</link>
      <pubDate>Fri, 10 Dec 2010 22:21:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/12/10/why-git-or-mercurial</guid>
      <description>&lt;p&gt;I’ve played around with branching and merging in git. It looks like a useful tool.&lt;/p&gt;

&lt;p&gt;In the current project we are maintaining two different branches right now. I can see that it would be useful to be able to use the functionality in git/mercurial to help me merge and cherry pick.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://herdingcode.com/?p=288&quot;&gt;HERDING CODE 96: ERIC SINK ON VERACITY AND DVCS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.hanselman.com/blog/HanselminutesPodcast231EricSinkOnDistributedVersionControlSystems.aspx&quot;&gt;Hanselminutes Podcast 231 - Eric Sink on Distributed Version Control Systems&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>What&apos;s wrong with SharePoint</title>
      <link>https://assertfail.gewalli.se/2010/11/26/whats-wrong-with-sharepoint.html</link>
      <pubDate>Fri, 26 Nov 2010 23:17:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/11/26/whats-wrong-with-sharepoint</guid>
      <description>&lt;p&gt;Whats wrong with SharePoint
from a developer point of view?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Packages
    &lt;ul&gt;
      &lt;li&gt;It’s somewhat unreliable in it’s deployment of files.&lt;/li&gt;
      &lt;li&gt;Takes a lot of time to install/uninstall a package.&lt;/li&gt;
      &lt;li&gt;Not a modern approach to package management. Its basically a cab file with files and xml describing it.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Configuration
    &lt;ul&gt;
      &lt;li&gt;How do you test the deployment of configuration?&lt;/li&gt;
      &lt;li&gt;How does it work exactly? You have to observe the result … It only works when you use it the right way and you don’t get much in error messages.&lt;/li&gt;
      &lt;li&gt;Deploying the right way is frikkin hard. But, if you expect the tools for sp to work without crashing your site, you better do it the right way.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;From line of code to result. Could this be described as lead time of changing a line of code to viewing the results of it in the interface?&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;10 min or more if you’re unlucky. This means that the roundtrip is not comparable to a clean site in asp.net.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Not even a mediocre web platform. Its written for intranet. This shows.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Running code in SharePoint context can be up to 10 times slower for the same dll.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Security. Some of the problems with SharePoint are related to security. It adds to the complexity.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;You need to mark your controls as SafeControls.  &lt;/li&gt;
  &lt;li&gt;Can get you thinking that GAC deployment is a good idea. Also you need to be aware of asp.net security configuration and what you may do. If you put things in GAC without very good reason do not complain if visual studio crashes, your projects use obsolete versions of your code, your build crashes.&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Identity Impersonate… &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Huge. There looks like there at least 3 ways of doing things, and they are all for slightly different scenarios. This is an issue. You have to learn a lot of SharePoint concept in order to get the job done. You have to do extra work to introduce for instance an asmx.
  This is not helped by asp.net being a leaky abstraction for producing web sites/apps. It can work well if you accept the behavior and limitations of of asp.net. Problem is that it’s not often that people are satisfied with this. Thus it may help to move to asp.net mvc for a simpler more web centric view.&lt;/li&gt;
  &lt;li&gt;If you’re supposed to develop web, it’s not a good experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Compare this to a regular asp.net web app/ site.&lt;/p&gt;

&lt;p&gt;How do you improve the experience?&lt;/p&gt;

&lt;p&gt;Conventional wisdom apply:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Testing your logic using automatic tests is valuable. Even more so since any changes take a lot of time to enter into SharePoint.&lt;/li&gt;
  &lt;li&gt;If you can simplify by faking SharePoint functionality
    &lt;ul&gt;
      &lt;li&gt;Writing web in regular web and move it using merge or generation&lt;/li&gt;
      &lt;li&gt;Write simpler versions of SharePoint classes.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
  &lt;li&gt;Use fewer dlls. Use ilmerge or consider fewer projects in your solution. Good idea anyway since its good practice to have few projects in visual studio. In .net its best practice to have few dll:s. In visual studio it’s &lt;a href=&quot;http://stackoverflow.com/questions/1828309/does-having-more-projects-in-your-visual-studio-increase-compile-time&quot;&gt;better&lt;/a&gt; to have few projects in your solution. You can solve this by having good build scripts and small sub solutions (may not be a good idea if you do not have a lot of code).&lt;/li&gt;
  &lt;li&gt;If possible avoid putting things in the GAC. It can be useful, but not for everything. You can put dll:s in the &lt;a href=&quot;http://stackoverflow.com/questions/1754006/is-sharepoint-local-bin-deployment-possible&quot;&gt;bin folder of SharePoint&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Automate as much as possible.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Write build scripts.&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;There is a &lt;a href=&quot;http://stackoverflow.com/questions/1000104/visual-studio-configure-debug-to-attach-to-process&quot;&gt;sample macro&lt;/a&gt; for attaching to a process.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;If there are no logs or anything to help you with what’s going wrong: You might need to use advanced tools like &lt;a href=&quot;http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx&quot;&gt;Process Monitor&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some other helpful tips may be:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;http://wspbuilder.codeplex.com/&quot;&gt;Wspbuilder&lt;/a&gt; can be a good starting point. It can help you by automatically registering safe controls. Ms commerce extendability project can show you how to do it without the tool. Some of the uses for this tool might become obsolete with the introduction of Visual Studio 2010 and SharePoint 2010 (might not save your bacon though). I’ve not tried this, only read it on blogs. It might help you to understand what the tools generate.&lt;/li&gt;
  &lt;li&gt;Be pragmatic when it comes to configuration. Don’t hesitate to use a merge program when your configuration feature fails. Unless of course your client will use the wsp on a SharePoint farm.&lt;/li&gt;
  &lt;li&gt;Put your code behind wcf services so that the configuration and context is outside of SharePoint. Less configuration helps. Also the separation of your code and the executing context in SharePoint help you configure security easier.&lt;/li&gt;
  &lt;li&gt;Don’t be stressed if it takes time. Read up on the things your working with (try to ignore the rest).&lt;/li&gt;
&lt;/ol&gt;
</description>
    </item>
    
    <item>
      <title>XML build files are obsolete</title>
      <link>https://assertfail.gewalli.se/2010/11/20/xml-build-files-obsolete-are-obsolete.html</link>
      <pubDate>Sat, 20 Nov 2010 16:59:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/11/20/xml-build-files-obsolete-are-obsolete</guid>
      <description>&lt;p&gt;Why using a build system like Ruby rake or some other next generation tool (&lt;a href=&quot;https://github.com/JamesKovacs/psake&quot;&gt;psake&lt;/a&gt; looks promising) to build your .net application or library?&lt;/p&gt;

&lt;p&gt;A) Builds are not data.
Xml is for data. It may be that the files or configurations are stored as xml, but does your build program need to be in xlm?
B) Custom tasks are easy to write. Take a look at &lt;a href=&quot;http://albacorebuild.net/&quot;&gt;albacore&lt;/a&gt; for instance.
C) It is easy to manage nontrivial tasks.
D) It’s readable.
Write your build in rake or something similar. Write it in msbuild. You will see that as usual there is a cost to writing it in xml: It adds cruft and that angle-bracket tax.&lt;/p&gt;

&lt;p&gt;Or you might like the xml files for some reason:
&lt;a href=&quot;http://www.jprl.com/Blog/archive/development/2010/Apr-26.html&quot;&gt;Jonathan Pryor: Defending XML-based Build Systems&lt;/a&gt;
He is arguing for the use of xml-basked build files. One reason is that xml is easily parsed and can be used in custom tools.&lt;/p&gt;

&lt;p&gt;Personally I feel that coding should be done mostly by writing code. Sure, there might be nifty code generation tools that can be used to simplify some tasks, but at the end of the day you still need to get your hands dirty and make sure that it does what it’s supposed to do.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Simple object oriented JavaScript</title>
      <link>https://assertfail.gewalli.se/2010/07/30/simple-object-oriented-javascript.html</link>
      <pubDate>Fri, 30 Jul 2010 07:48:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/07/30/simple-object-oriented-javascript</guid>
      <description>&lt;p&gt;The jQuery approach is to avoid object orientation. This is an excellent way of avoiding bloat for small JavaScript hacks. If you’re starting to build JavaScript heavy applications then you might need to start organizing your code. The first thing you should learn is how to write jQuery plugins. Later on you will need to learn some simple object orientation. Here’s how:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;function TigerType(name){
    var that = this; this.name = name; this.sound = &quot;growl!&quot;;
    this.roar = function(){ return that.sound; };
}
var tigerInstance = new TigerType();
alert(tigerInstance.roar());
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that I’m declaring a variable “that”. If you work with jQuery you know that this will be set to something else. By using a scoped variable you will avoid this problem.
So what about inheritance? The simple solution is to use call or apply.&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;function TigerWithTeethType(name){
    var that = this;
    TigerType.call(this,name);
    this.bite = function(){ /*some code to bite the programmer ;)*/ };
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Since TigerType is a function, call and apply can be used to execute it with the “this” of TigerWithTeethType. This way has the advantage of being simple and jQuery safe.
You might also want to look into:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://ejohn.org/blog/simple-javascript-inheritance/&quot;&gt;http://ejohn.org/blog/simple-javascript-inheritance/&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.crockford.com/javascript/inheritance.html&quot;&gt;http://www.crockford.com/javascript/inheritance.html&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://bolinfest.com/javascript/inheritance.php&quot;&gt;http://bolinfest.com/javascript/inheritance.php&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try to avoid object orientation when writing JavaScript. If you’re doing small things then there is no need for the added complexity of object orientation (in JavaScript).&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Different breed of programmers</title>
      <link>https://assertfail.gewalli.se/2010/07/19/different-breed-of-programmers.html</link>
      <pubDate>Mon, 19 Jul 2010 19:46:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/07/19/different-breed-of-programmers</guid>
      <description>&lt;p&gt;After talking to a few of my colleges I’m thinking of the different kind of programmers needed for different projects, for different aspects of projects.&lt;/p&gt;

&lt;p&gt;Duct tape programmer:
&lt;a href=&quot;http://www.joelonsoftware.com/items/2009/09/23.html&quot;&gt;http://www.joelonsoftware.com/items/2009/09/23.html&lt;/a&gt;
Writing code that ships. Does not necessarily need to look clean. Will probably not write any unit-tests. No fancy abstractions, no patterns or anything.&lt;/p&gt;

&lt;p&gt;Maintenance programmer:
&lt;a href=&quot;http://www.codinghorror.com/blog/2006/06/the-noble-art-of-maintenance-programming.html%20&quot;&gt;http://www.codinghorror.com/blog/2006/06/the-noble-art-of-maintenance-programming.html&lt;/a&gt;
Have had every sort of wrench imaginable thrown right in the face. This guy will be very skeptic of dirty code. It’s about pragmatic programming and excelling at making sure that old stuff works.&lt;/p&gt;

&lt;p&gt;The thing is: Different type of programmers are good for different things in a project. A maintenance programmer (or a programmer in that mode) will not necessarily be any good at writing new applications FAST (like really, really fast). Maybe the sales force needs something done within a week or a few days. Then you’re looking for a duct tape programmer. But don’t kid yourself. Finding people good at this kind of skills is hard. Problem is, you might loose time by pressuring the other programmers into writing code fast. People might think that they are duct tape programmers. But seriously, few of us are.&lt;/p&gt;

&lt;p&gt;Duct tape programming, the term that comes to mind is Quick &amp;amp; Dirty
As a coworker said:
- When you do it quick and dirty you have actually taken a loan. If you take additional loans to do small fixes, sooner or later any change will take horrendous &lt;strong&gt;time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Where do I stand in this mix? Maybe I’m a mix of a few of these. Frankly I’m not very good at duct tape programming. I try to mix maintenance and duct taping. Doing integration testing and unit testing in order to make sure that the server bits are done until the time that I start coding the GUI. Making sure that the GUI interacts with a decent API instead of doing the logic directly will make it easier if you have a lot of complicated server logic. The pro of this approach is that you do not need to be a pro at the tool you’re using. As the requirements change, you will still have something that works.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Dojo RTE editor (dijit Editor)</title>
      <link>https://assertfail.gewalli.se/2010/05/02/dojo-rte-editor-dijit-editor.html</link>
      <pubDate>Sun, 02 May 2010 09:43:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/05/02/dojo-rte-editor-dijit-editor</guid>
      <description>&lt;p&gt;Finished upgrading an old site to use dojo and codeignite. In order to simplify things I added the RTE editor in order to simplify the code. There is no need to add logic related to the content on the page so html-content is preferable.&lt;/p&gt;

&lt;p&gt;excerpt from the content/editor.js:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;dojo.require(&quot;dijit.Editor&quot;);
dojo.require(&quot;dijit.form.TextBox&quot;);
dojo.require(&quot;dijit._editor.plugins.FontChoice&quot;);
dojo.require(&quot;dijit._editor.plugins.LinkDialog&quot;);
dojo.addOnLoad(function(){
    dijit.byId(&apos;bodyeditor&apos;).setValue(dojo.byId(&apos;body&apos;).value);
    dojo.query(&apos;[name=&quot;submit&quot;]&apos;).onclick( function(evt) {
         dojo.byId(&apos;body&apos;).value = dijit.byId(&apos;bodyeditor&apos;).getValue();
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and from the view editor.php:&lt;/p&gt;

&lt;fieldset&gt;&lt;legend&gt;$actiontitle&lt;/legend&gt;
&lt;p&gt;&lt;label for=&quot;title&quot;&gt;Titel:&lt;/label&gt;
&lt;input type=&quot;text&quot; id=&quot;title&quot; dojotype=&quot;dijit.form.TextBox&quot; name=&quot;title&quot; required=&quot;true&quot; value=&quot;&amp;lt;? echo set_value(&apos;title&apos;,$title) ?&amp;gt;&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;label for=&quot;body&quot;&gt;Body:&lt;/label&gt;
&lt;textarea type=&quot;text&quot; id=&quot;body&quot; name=&quot;body&quot;&gt;&lt;? echo set_value(&apos;body&apos;,$body) ?&gt;&lt;/textarea&gt;
&lt;div dojotype=&quot;dijit.Editor&quot; extraplugins=&quot;[{name:&apos;dijit._editor.plugins.FontChoice&apos;, command:&apos;fontName&apos;, generic:true},{name:&apos;dijit._editor.plugins.LinkDialog&apos;,command:&apos;createLink&apos;}]&quot; id=&quot;bodyeditor&quot; required=&quot;true&quot;&gt; &lt;/div&gt;
&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;buttons&quot;&gt;&lt;button type=&quot;submit&quot; class=&quot;positive&quot; name=&quot;submit&quot;&gt;Ok&lt;/button&gt;&lt;/div&gt;&lt;/p&gt;
&lt;/fieldset&gt;

&lt;p&gt;Note the dojoType attribute of the editor div:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dojoType=&quot;dijit.Editor&quot;
extraPlugins=&quot;[
    {
    name:&apos;dijit._editor.plugins.FontChoice&apos;,
    command:&apos;fontName&apos;,
    generic:true
    },{
    name:&apos;dijit._editor.plugins.LinkDialog&apos;,
    command:&apos;createLink&apos;
    }]&quot;
id=&quot;bodyeditor&quot; required=&quot;true&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;As you can see, I opted for the more declarative way.&lt;/p&gt;

&lt;p&gt;There were some pitfalls. I could not use the editor directly for instance. I had to define a hidden element for the content and post that element. Also, the declarative statement looks kind of ugly since we have to add the full name of the editor plugins.&lt;/p&gt;

&lt;p&gt;The first thing you notice of dojo is that the api isn’t as slick as jquery. That is expected since dojo spans more functionality. dojo shines however in one position: dojo.require. Like the import statement in java and python or the using statement in C#.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Playing around with mongo db in .net</title>
      <link>https://assertfail.gewalli.se/2010/04/05/playing-around-with-mongo-db-in-net.html</link>
      <pubDate>Mon, 05 Apr 2010 13:51:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2010/04/05/playing-around-with-mongo-db-in-net</guid>
      <description>&lt;p&gt;Ever since I heard of the NoRM driver for MongoDB I had to try my hands on it. You can find it here:
&lt;a href=&quot;http://github.com/atheken/NoRM&quot;&gt;NoRM&lt;/a&gt; , &lt;a href=&quot;http://www.mongodb.org/&quot;&gt;mongodb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first thing is setting up the server. I dropped the binaries into&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\\MongoDb\\
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next thing I created two batch files.
To start the db: start.bat&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\\MongoDb\\bin\\mongod.exe --dbpath C:\\MongoDb\\data --port 27000 --logpath C:\\MongoDb\\log\\mongodb.log --logappend
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The other to access the mongo shell: shell.bat
C:\MongoDb\bin\mongo.exe –port 27000&lt;/p&gt;

&lt;p&gt;Next thing is creating a simple asp.net MVC app that uses MongoDB for storage.&lt;/p&gt;

&lt;p&gt;My object of choice is Product:&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;partial&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Product&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Product&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;NewObjectId&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Column&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsPrimaryKey&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;virtual&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ObjectId&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Id&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;}&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt; The attribute is for the editor template. Next thing is the controller. Here is the helper for connecting to the database:&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ServerHelper&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mongo&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;GetServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Mongo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;mongodb://localhost:27000/MongoMvc&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;MongoCollection&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;Collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;GetServer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;GetCollection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;products&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt; &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that you don’t need to do a create database or collection.&lt;/p&gt;

&lt;p&gt;Insert is straightforward. In order to list all “products” I used an empty Find on the collection. To update I did the following:&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;HttpPost&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ActionName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Edit&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ActionResult&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;EditPost&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectId&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ServerHelper&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;Collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;product&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;FindOne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;UpdateModel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;UpdateOne&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;product&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;     &lt;/span&gt; &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;RedirectToAction&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Index&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;err&quot;&gt;   &lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Looks interesting. I’ve not delved into any deeper parts than this yet. I could probably have done this without the additional configuration.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Debugging JavaScript in IE8</title>
      <link>https://assertfail.gewalli.se/2009/07/18/debugging-javascript-in-ie8.html</link>
      <pubDate>Sat, 18 Jul 2009 19:55:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2009/07/18/debugging-javascript-in-ie8</guid>
      <description>&lt;p&gt;How do you debug JavaScript in IE? Before IE 8 you could use fiddler and the visual studio debugger.&lt;/p&gt;

&lt;p&gt;There was a plugin for IE so that you could get a developer toolbar with some extended script debugging. As of IE8 a toolbar is built in and can be reached by pressing F12.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Debugging JavaScript in Firefox</title>
      <link>https://assertfail.gewalli.se/2009/07/18/debugging-javascript-in-firefox.html</link>
      <pubDate>Sat, 18 Jul 2009 18:17:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2009/07/18/debugging-javascript-in-firefox</guid>
      <description>&lt;p&gt;How do you debug code in Firefox? The answer is that you use one of two eminent plugins:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;http://betterexplained.com/articles/how-to-debug-web-applications-with-firefox/%20&quot;&gt;Firebug&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;a href=&quot;https://addons.mozilla.org/en-US/firefox/addon/216&quot;&gt;Venkman&lt;/a&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
    </item>
    
    <item>
      <title>web api&apos;s</title>
      <link>https://assertfail.gewalli.se/2009/07/18/web-apis.html</link>
      <pubDate>Sat, 18 Jul 2009 18:00:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2009/07/18/web-apis</guid>
      <description>&lt;h3 id=&quot;local-procedure-calls&quot;&gt;Local procedure calls&lt;/h3&gt;

&lt;p&gt;Given the scripting nature of the web non-obfuscated JavaScript code presents itself to the technical user almost as a public API. You can try it out yourself by writing:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&quot;language-JavaScript&quot;&gt;for (x in document){console.log(x);}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;in your browser JavaScript console. For more persistent changes to a sites behavior tools like Greasemonkey can be used. Last.fm and Spotify have done some integration by releasing a &lt;a href=&quot;https://www.spotify.com/blog/archives/2008/12/18/spotify-scrobbles/&quot;&gt;Greasemonkey script for last.fm&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;remote-procedure-calls&quot;&gt;Remote procedure calls&lt;/h3&gt;

&lt;p&gt;By using &lt;a href=&quot;http://www.fiddler2.com/fiddler2/&quot;&gt;fiddler&lt;/a&gt; or Firefox Firebug you can watch the client/server interaction (ajax calls made by a modern web app). The stateless nature of the web and ajax calls promotes a simple design of this “API”. This means that programming/scripting against your site can be easily done by, hopefully authorized, users.&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;Modern web applications have a natural interface for that might yield a plugin-like api unintended by the applications developers. If you’re developing/maintaining a web app, try searching for it on &lt;a href=&quot;http://userscripts.org/&quot;&gt;userscripts&lt;/a&gt;. If your app is used by a wide group of people, then you might be surprised with what you find.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Programming JavaScript</title>
      <link>https://assertfail.gewalli.se/2009/07/18/programming-javascript.html</link>
      <pubDate>Sat, 18 Jul 2009 16:40:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2009/07/18/programming-javascript</guid>
      <description>&lt;p&gt;In the first course in computer science we (students) received the following words of wisdom from the lecturer:&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;Above anything avoid JavaScript.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;pure-javascript&quot;&gt;Pure JavaScript&lt;/h3&gt;

&lt;p&gt;A few years later I started working as a programmer (late 2005). Some small that we could things arose impossible without the use of JavaScript. One of my coworkers showed me how to add some bits of extra functionality that the users needed (easier user interface). Later on there was a need for drag and drop in the browser. I implemented this by using code from another coworker. I updated an editor for presenting study programs. I feel that that experience is a failure. It took me at least 2-3 weeks to get something that wasn’t decent enough. I tried to write good code, but failed. Both the server-side and client-side code is a mess. Fortunately this code is rendered obsolete by the fact that the system I worked on contains more information and therefore can generate such presentations without any manual  editing. What I am trying to say: That coding experience sucked.&lt;/p&gt;

&lt;h3 id=&quot;javascript-library-jquery&quot;&gt;JavaScript library: jQuery&lt;/h3&gt;

&lt;p&gt;Fast forward to 2009. I’ve started working in a team developing what can best be described as an advanced editor (specialized for one purpose) on the web. Enter jQuery: Rich text editing, ajax, items that can be saved without the whole form being submitted, et.c.. The weirdness of developing JavaScript almost gone:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Doing manipulations on the HTML using jQuery yields more predictable results.&lt;/li&gt;
  &lt;li&gt;Navigating the DOM via jQuery works the same way across different browsers.&lt;/li&gt;
  &lt;li&gt;Events encapsulated by jQuery work the same in different browsers.&lt;/li&gt;
  &lt;li&gt;The terse syntax of jQuery reduces the amount of code.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because of the above the quality of the code increases.&lt;/p&gt;

&lt;h3 id=&quot;lint&quot;&gt;Lint&lt;/h3&gt;

&lt;p&gt;Since there is no compilation of JavaScript there is a need to use some form of lint on the code to catch syntax errors, legal JavaScript but bad syntax et.c.. There are two JavaScript lint implementations that I know of: &lt;a href=&quot;http://javascriptlint.com/&quot;&gt;JavaScript lint&lt;/a&gt; and &lt;a href=&quot;http://www.jslint.com/&quot;&gt;jslint&lt;/a&gt;. I use both. Jslint is a bit harder to set up in visual studio, but is stricter and finds more errors (out of the box). I might not have read enough of the documentation for JavaScript lint in order to use it efficiently. With the use of lint hard to find bugs and errors can be found in a matter of minutes instead of days, makes these tools invaluable.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>jquery</title>
      <link>https://assertfail.gewalli.se/2009/04/08/jquery.html</link>
      <pubDate>Wed, 08 Apr 2009 22:17:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2009/04/08/jquery</guid>
      <description>&lt;p&gt;I’ve come to admire the simplicity and style of jquery. There are some cons to it’s approach of using context (as can be seen as this in the for instance “each”):&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;#table tr&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;jQuery&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DoStuffPlugin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This wreaks havoc with some object oriented programming techniques that uses &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;this&lt;/code&gt; for the object reference:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ClassSmurf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;smurfette&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SmurfAround&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Smurf: &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is a simple example broken by jquery’s use of context (that jQuery binds this). There is a simple work around:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;ClassSmurf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;smurfette&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;that&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SmurfAround&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;alert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;Smurf: &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;that&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that we capture the object instance as a private variable. We do get some additional boilerplate in order to have jQuery safe “classes”. Don’t take me wrong. I love that we have jquery.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>Modelbinding a complex entity framework/Linq to Sql model to asp.net mvc</title>
      <link>https://assertfail.gewalli.se/2009/03/14/modelbinding-complex-entity-framework.html</link>
      <pubDate>Sat, 14 Mar 2009 05:41:00 +0000</pubDate>
      <author>webmaster@gewalli.se (Oskar Gewalli)</author>
      <guid>https://assertfail.gewalli.se/2009/03/14/modelbinding-complex-entity-framework</guid>
      <description>&lt;p&gt;For a couple of days now I’ve been trying to “ModelBind” a more complex model (based on the Entity framework)  to a controller action. The problems I’ve been having are mostly related to the amount of code for this task. I’m therefore thinking of ways to reduce the complexity. The main problem is that it’s not directly possible to bind to ordinary EF/LS-graphs.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;Separate object graph.&lt;/em&gt; One solution could be to have a separate object graph for use in with the view. That seems more than wasteful since we want to edit everything on this page and thus end up having to maintain extra objects when we have the EF/LS ones.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;em&gt;A revised binding to the EF/LS objects.&lt;/em&gt; If my model-binder treated the EF/LS objects in the correct manner then my problems would be solved. Problem is though that I need connected objects in the binding. That implies a UpdateModel pattern with the object context visible from the controller. Not a beautiful solution though.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve written a small asp.net mvc application with a simple (complex model). I’ve a main entity Smurf. The Smurf entity has several SmurfChild records related to it:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/2009-03-14-modelbinding-complex-entity-framework_model.gif&quot; alt=&quot;smurf model&quot; height=&quot;320px&quot; width=&quot;278px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The model binding I’m trying to do is the following:&lt;/p&gt;

&lt;div class=&quot;language-c# highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ActionResult&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;EditAll_CustomBinder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ModelBinder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;typeof&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SmurfListBinder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;IList&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Smurf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;smurfs&lt;/span&gt;
        &lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’m editing a list of smurfs and the related smurf children in the view.&lt;/p&gt;
</description>
    </item>
    

  </channel>
</rss>
