Git Product home page Git Product logo

ploeh.github.com's Introduction

ploeh blog

This repository contains the templates and data for my blog at blog.ploeh.dk. It is powered by Jekyll-Bootstrap.

Comments

Comments for a particular post are kept as part of the post itself.

If you wish to comment on a particular post, send me a pull request for that post. If you're in doubt about the format, just look at how previous comments are formatted. For an example of a post with comments, see e.g. the very first post on this blog.

If you're using Visual Studio Code, you may use the included code snippets if you like:

  • addcomment
    Adds a single comment but not the surrounding comment section. Use snippet "addcommentsection" for that.
  • addquote
    Adds a quote, using your clipboard as the initial text.
  • addcommentsection
    Adds the comment section. ctrl+space for quickly adding a comment

If you only wish to comment, you don't have to read on, but if you're curious, here follows some background.

Why is the comment system implemented this way? Partly, it's for historical reasons, but increasingly, it's also for longevity reasons.

Legacy

From its inception in 2009 to 2013 the blog ran on blogging software called dasBlog, which had its own comment system. When I decided to migrate to Jekyll, I had to figure out what to do with the existing comments.

While it would have been easier to ignore the existing comments, I felt an obligation to the readers who had engaged with the blog. Throwing the comments away didn't seem like a proper course of action.

The most popular comment system at the time was Disqus, and I did investigate whether I could import the existing comments into that system. It did strike me as a bit proprietary, though, which made me reflect further on the problem. Migrating the comments to Disqus would effectively trap them there. Would I be able to get them out again if I decided to migrate to yet another system?

Thus, I decided (at first, as an experiment) to embed the comments directly in the article. It's not ideal, but the trade-off I've identified.

Longevity

The web site at https://blog.ploeh.dk is the second blog I've authored. Before it, I wrote a blog on MSDN. When I stopped at Microsoft, I could no longer update it, which I found less than ideal.

When I started this incarnation of ploeh blog, having full control of the entire life cycle of it was a major priority. For the first four years, I ran the blog off a server in my home office. Before moving to Jekyll and GitHub pages, I specifically investigated whether that would lock me into GitHub, either technically or legally. That, fortunately, turned out not to be an issue.

Including the comments in the source code for the blog minimises dependencies on other systems. Should I need to move the blog to another platform in the future, the comments are right here, along with everything else.

I find it telling that since I migrated to Jekyll, Disqus is no longer the leading comment platform. What else will come and go?

ploeh blog has been around since 2009. Ponder the time involved. Services come and go, but I'm here for the long haul. I plan to do this for many more years, and I don't want to take a dependency on something that may become a problem in the future.

That means every third-party comment platform, including GitHub.

Readers occasionally write to suggest some service based on GitHub issues or the like. GitHub may last for a long time, but who knows about the code that drives such integration? And even a dependency on GitHub is not something I'm keen to accept.

GitHub is only a host and a publishing channel for the blog. The web site runs perfectly well on my laptop as well. It'll run fine somewhere else, too. After all, it's just static HTML files.

My time perspective is measured in decades. Few things last that long in software, so I'm taking a conservative stance.

Contributions

While ploeh blog is my personal blog, I'm happy to accept contributions such as:

  • Comments (see above)
  • Corrections of typos and the like
  • Look and feel enhancements (better CSS, etc.)

On the other hand, I don't intend to turn ploeh blog into a site with 'guest bloggers', so don't bother sending an unsolicited pull request for a completely new post.

ploeh.github.com's People

Contributors

anthonylloyd avatar antmdvs avatar aszan avatar bartelink avatar bbsaxo avatar benjamin-hodgson avatar cmeeren avatar dominikjeske avatar farlee2121 avatar feo2x avatar ghostsquad avatar giuseppepiscopo avatar groundh0g avatar lumirris avatar mark-wiemer avatar marshallshen avatar moodmosaic avatar pellared avatar ploeh avatar plusjade avatar qujck avatar rdeneau avatar richardlitt avatar spocweb avatar srogovtsev avatar studiomohawk avatar thaoden avatar tysonmn avatar xdadaveshaw avatar ymassad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ploeh.github.com's Issues

Enforce HTTPS

Several people have, with accumulated effort, convinced me that I should turn on HTTPS for the blog.

Currently, the blog is hosted by GitHub pages, which it has been for a long time, so unless I want to move it, I'm able to do whatever GitHub pages allow me to do.

For some time now, HTTPS has already been enabled as opt-in. Thus, https://blog.ploeh.dk actually works. On the other hand, HTTPS isn't enforced. It probably should be.

One critical requirement is that old links must still work. There's quite a few links to various articles on the blog, from various sources that I don't control, and those should still work. If I read the GitHub pages documentation on enabling HTTPS correctly, this should automatically work with redirects. It remains to be seen, though.

Before I turn on that feature, however, the source for the blog should be scanned for mixed content, as also outlined in the above documentation. That could be a non-trivial task.

Permalinks for comments

Comments currently don't have permalinks. It'd be nice if they had; preferably using a fragment identifier containing a GUID.

How to set up AutoDataAttribute(Func<IFixture> fixtureFactory) syntax?

I was following the instructions here... http://blog.ploeh.dk/2010/10/08/AutoDataTheorieswithAutoFixture/ ...for setting up the AutoMoqDataAttribute like this:

  public class AutoMoqDataAttribute : AutoDataAttribute
 {
     public AutoMoqDataAttribute()
         : base(new Fixture()
             .Customize(new AutoMoqCustomization()))
     {
     }
 }

Everything works great, but I get warning CS0618 when compiling: 'AutoDataAttribute.AutoDataAttribute(IFixture)' is obsolete: 'This constructor overload is deprecated because it offers poor performance, and will be removed in a future version. Please use the AutoDataAttribute(Func<IFixture> fixtureFactory) overload, so fixture will be constructed only if needed.'

I understand what the warning means, but I'm having a difficult time figuring out the correct syntax. Could you provide an example of how this constructor would look using Func<IFixture>? Thanks!

More tags

The tag cloud on the blog is becoming increasingly useless, since everything I write today basically just gets shoved into the Software Design tag, which, at the time I'm writing this, has 172 entries. This is clearly not an aid to readers who try to navigate the blog.

While I'll keep the tags that are already present, I'd like to add some more tags that could offer more granular navigation. The intent is to retrofit such tags unto existing articles.

I can't figure out which tags to create, though!

With this issue, I hereby solicit suggestions.

New tags ought to cover more than a pair of articles. I admit that I've made some mistakes when I originally created some of the tags. For example, I thought I'd be writing more on WPF than I ultimately did; that tag only has two entries, but at least that's better than the Sync and Albedo tags.

New tags should have more entries than that (at least 5-10). Additionally, any new tags should be distributed across articles that aren't otherwise natural clusters. For example, one could easily invent a Monoid tag and add it to all the articles in the Monoids article series, but if that tag doesn't apply outside of that article series, then what value would it add? That's the reason I haven't already added Monoid, Functor, or Category Theory tags.

If you have an idea for one or more tags that could be added to the blog, please add your suggestion below, preferably with some suggested articles that'd belong to the new tag.

Better yet, send your suggestion as a pull request 😉

File name containing either-bifunctor post "wrong"

The file containing your Either bifunctor post has the "wrong" file name. Instead of 2018-01-07-either-bifunctor.html it should be 2019-01-07-either-bifunctor.html (i.e. the year should be 2019 instead of 2018).

Translation

I recently read through your DI posts and it helps me a lot. Thanks for the great articles.

I want to translate these posts to Korean and post it into my personal blog, haruair.com. I couldn't find any policy of translation or redistribution. May I translate these posts and post it? I will put the reference URL clearly. Please let me know if there is any guidance for it.

Hope you have a good day.

Favicon

The blog should have a favicon...

Change copyright

Currently, the copyright notice on all pages simply uses the current year, so it says something like © Mark Seemann 2017 even on articles from 2009.

Clearly, such an article's copyright extends back to 2009, and the notice should reflect that accordingly.

dependency injection in javascript using composition root

Hello,

I would to thank you for your great writing on composition root design pattern
and I'll be glad If you could add the content of this link
https://plus.google.com/108617450837535451203/posts/HXUKtQ2nSNg
as a comment for
http://blog.ploeh.dk/2011/07/28/CompositionRoot/

I wrote my own JavaScript Dependency Injection Framework called Di-Ninja wich is, as I know, the only one in javascript that implement the Composition-Root design pattern and it's documentation could be another good example to demonstrate how it works.
https://github.com/di-ninja/di-ninja

Clarification of some magic in Configuration binding

I read your post https://blog.ploeh.dk/2019/11/25/timespan-configuration-values-in-net-core/ and it was extremely helpful but left me wanting to know more, since I had run into something similar with Uris (you can just bind strings to Uri properties implicitly). After a bit of spelunking, I found https://github.com/dotnet/extensions/blob/master/src/Configuration/Config.Binder/src/ConfigurationBinder.cs#L508-L513, which shows that TypeDescriptor.GetConverter(targetPropertyType).ConvertFromInvariantString(stringProperty) is actually what does the magic here (GetConverter(typeof(TimeSpan)) returns a System.ComponentModel.TimeSpanConverter, which unsurprisingly is doing a pretty straightforward parse: https://github.com/dotnet/runtime/blob/master/src/libraries/System.ComponentModel.TypeConverter/src/System/ComponentModel/TimeSpanConverter.cs

Since your post is the first result (for me) on "iconfiguration timespan" in google, could you update it with this information? I have also created a doc issue here: dotnet/AspNetCore.Docs#17151

Comment on title: "Code readability hypotheses" could not push a new branch.

I could not push a new branch for this comment.

<div class="comment" id="fef627676986467bbbee0f60cb38707d">
	<div class="comment-author"><a href="https://www.clearlaunch.com/meet-the-team/">Arturo Hernandez</a></div>
	<div class="comment-content">
		<p>
			There is a huge problem in the way that we evaluate software quality. Karsten, is naming many of the reasons that make it difficult. But given that it is difficult, The only rational way to solve it without relying as heavily credentials, personality and repetition. Is to establish guidelines and have multiple opionins/measurements of code samples. 
		</p>
		<p>
			I think we overvalue experience in evaluating code. And in the contrary, there are real issues with expert bias, particularly of older programmers who have good credentials but are more financially and emotionally invested in a particular technology. In general, it is much more difficult to write good code, than to read it. Therefore, most programmers can read, understand and appreciate good code. While they may not have been able to write from scratch themselves. The only exception would be for true neophytes (which there may be ways to exclude). We also need to be leary about software qualities that are hard to grasp and evaluate. Unexplainable or unclear instinct can lead to bad outcomes.
		</p>
		<p>
			There is real oportunity here to more scientifically quantify aspects of code quality. I wish more people devoted time to it.
		</p>
	</div>
	<div class="comment-date">2019-02-14 17:36 UTC</div>
</div>

Tweet button

Each article/blog post should have an easy-to-use Tweet button, that enables a user to tweet a link to it using his or her Twitter account.

Twitter cards

Given how much I tweet links to my posts, the pages ought to support Twitter cards. Summary cards are probably the ones that best fit.

While the twitter:description tag isn't required, I'd like to add it, since most of my posts do have suitable texts. For years, I've introduced each post with a single italicised paragraph. As an example (simply picking the newest post as I'm writing this), Church-encoded natural numbers starts:

Natural numbers don't have to be built into programming languages. An introduction for object-oriented programmers.

In HTML, this is formatted as:

<p>
  <em>Natural numbers don't have to be built into programming languages. An introduction for object-oriented programmers.</em>
</p>

Perhaps it'd be better to promote that first paragraph to metadata; i.e. make it part of the page's front matter, and then use the page variable to render the HTML. This would enable me to reuse it for Twitter Card markup as well.

It'd also be worthwhile to consider what to do about images. Far from all posts have images, but for those that do, it'd be nice to include them. Perhaps the most pragmatic solution here is simply to add an optional variable to the front matter that duplicates the required image data.

Bouding box picture is incorrect

In the Bounding box semigroup post one commenter convinced you to changed a sentence to

Just pick any other BoundingBox y outside of x.

I think that you did not change the picture, though, as it shows a bounding box that's partially outside of the candidate (actually, partially outside of some of the candidates, since there are many).

Autofilling properties using Moq - example code doesn't compile

Hi there,

I was following your blog post here

http://blog.ploeh.dk/2013/04/08/how-to-automatically-populate-properties-with-automoq/

but I can't get it to compile, it states PropertiesOnlySpecification is assignable to parameter type System.Type

Any ideas what could be wrong ?

This is the code, but its copied from the blog post

    public void Customize(IFixture fixture)
    {
        fixture.Customizations.Add(
            new PropertiesPostprocessor(
                new MockPostprocessor(
                    new MethodInvoker(
                        new MockConstructorQuery()))));
        fixture.ResidueCollectors.Add(
            new Postprocessor(
                new MockRelay(),
                new AutoPropertiesCommand(
                    new PropertiesOnlySpecification())));
    }

Compelling Builder example

This issue isn't an actual issue with the blog, but a request for ideas.

I'd like to write a couple of articles about the Builder design pattern, but I need a compelling code example. I have one already, but I'd like one more.

You don't have to supply any code; just a good idea.

If you have a good idea, just write a response here.

In the following, I'll outline what I've already considered, and what I'm looking for

What I'm looking for

I'm looking for a problem that can be used for a code example. I want to present it in an article, so neither the problem nor the code can be too complicated. It must be something that a reader can grasp without too much effort.

The problem must also be a good fit for the Builder pattern. In other words, it must solve the problem of separating construction of an object from it representation.

GoF Maze

For a while, I considered (re)using the Maze example from Design Patterns, but once you start working with that example code, it's really odd. It seems to assume a rectangular layout, but as a client of the MazeBuilder API you have no way to indicate relative position. This seems to make it impossible, or at least awkward, to implement the implied CommonWall method. If anyone could suggest a reasonable way out of this conundrum, then perhaps I could use that as my example.

As far as I can tell, another problem with the Maze example is that it doesn't deliver on the book's own stated intent. It offers two polymorphic implementations of MazeBuilder, where StandardMazeBuilder seems tightly coupled to the Maze representation. The other alternative, CountingMazeBuilder, is neither compelling nor uses the Maze representation at all - it just returns a null pointer.

Typical examples

I've searched the internet for other examples, but they're most in the form of build a car from parts, build a computer from parts, or even compose a breakfast from parts. Sometimes, when 'ordinary programmers' complain that they have a hard time relating design patterns to their day-to-day work, I can't blame them.

Those are not examples of problems one runs into in ordinary enterprise software development settings.

Examples of Builder that are useful in real code, but not for an article

My troubles with coming up with a compelling examples isn't due to the pattern's lack of utility. You often see it employed by various frameworks' configuration systems. For example, the ASP.NET Core configuration system seems to me to be an example of the Builder pattern, albeit with a twist. Such configuration systems are just a tad too complicated to make an easy-to-understand example.

Cleaner examples are the UriBuilder and ConnnectionStringBuilder classes. These, on the other hand, I have to rule out because I'd like to include some refactorings in my article, and I can't easily refactor a published class.

Make blog layout more responsive

I did a quick experiment with upgrading to bootstrap 3 and using a responsive layout, making it easier to read on various mobile devices.

It seems to be fairly straight forward. Are you interested in this enhancement?

F# centric controller API

Not strictly a blog question, but still feel it relates to the previous "issue" I opened, and that this is as good a communication channel as any (especially wrt that you can add code). Since you've obviously worked a good bunch with Web API and F#, and have made practices and found challenges, if you could imagine a F# first controller API, how would it look like? Basically, I'm asking how would you like to define your controllers (if you could)?

Currently my thinking for the "ultimate" controller goes something like this (note, I don't remember the correct attribute names, but it should be enough to paint the picture):

[<Controller; PathPrefix("/users")>]
module MyCtrls

[<HttpGet>]
let getUsers = (userService: UserService) () =
  Ok <| UserService.getUsers userService

[<HttpGet; Path("{id}")>]
let getUser = (userService: UserService) (id: int) =
  match UserService.findUser id userService with
  | None   -> NotFound
  | Some u -> Ok u

In this case, a "controller" (in the Web API/MVC sense) is a simple F# function taking two tuples. The first one is the DI arguments, the second one is model binding arguments. In cases where you would need access to the request body (or similar) I would return a HttpRequestMessage -> Async<MyResponseType> by way of a custom computational expression ala

[<HttpGet>]
let echo = () () = handler {
  let! body = Request.getBody
  return Raw body
}

or something like that. handler here is basically a combination of the state monad (holding the HttpContext), and the async monad, allowing you to use let! on both custom functions like the getBody above that operates on the state, as well as on Async values (for seamless API interop). What do you think? Do you have any suggestions? Improvements?

Do we make up comment/heading IDs ourselves?

When sending a PR for adding a comment, are we supposed to randomly make up the comment ID (and any comment heading IDs) ourselves?

Also, is there a simple way to format code with syntax highlighting?

Type parameters reversed

On this line, I think the type parameter names in IResult<S, E> are in the opposite order than how you described them:

Right is equivalent to SuccessResult, and Left corresponds to ErrorResult.

Add 'FsCheck' tag

I think I ought to add an FsCheck tag.

Appropriate existing posts should have that tag added.

Make changes easier to detect

A blog post is, in many ways, anchored in time. Sometimes, however, I feel that I need to make changes to a post.

For some time, I've made use of the semantic markup elements del, ins, and so on. Deletions are fairly easy for the reader to detect, because they're decorated with the strikethrough style, but I explicitly removed the underline decoration from inserts because I thought it made the text harder to read.

Since I started to use those semantic markup elements, I've made an effort to include the datetime attribute.

It'd be nice if any semantic element that comes with a datetime element would display a tool tip when you hover over it. Something like added December 18, 2019, 11:27 UTC.

For additions (<ins>), it'd also be nice if there was some none-intrusive hint that this text is a bit different. Perhaps a slightly shaded background colour...

Correct Mark Seemann comment author links

#457 converted all URLs to relative URLs, which unfortunately also converted all my comment author links to empty hrefs.

<div class="comment-author"><a href="">Mark Seemann</a></div>

These links should, as before, point to the front page of the blog.

Asking about ports and adapters

Hi!
I did not want to pollute your blog with my thoughts, so I rather created an issue. I will refer to this blogpost: http://blog.ploeh.dk/2013/12/03/layers-onions-ports-adapters-its-all-the-same/

You wrote, that I have to invert the dependencies between the domain library and the data access library, but I don't understand why is that necessary, or how to implement that in a reasonable way. Currently I just define a storage interface between the business logic and the database, and I inject the storage implementation into the business logic, so the business logic does not depend on the implementation of the storage, just the interface... Why isn't this enough?

Smaller RSS feed

The RSS feed is getting longer and longer, and is currently at over 4 MB. This is not long-term sustainable, as the size will just keep growing.

Unlike Atom, I'm not sure if RSS enables pagination. If it does, the RSS feed should be paged like the Atom feed. If it doesn't, I think the most common approach is to truncate the feed so that it only lists the n latest posts.

Broken link to Pluralsight course

This post ends with a broken link to one of your Pluralsight courses. Maybe this is a temporary problem. In any case, here is the error message that I get.

The link is not currently active.

There are a number of reasons that you may have received this message. The most common is that the merchant who was advertising is temporarily not-actively promoting that program. If, however, you feel you have reached this page in error, please let us know. Shareasale.com does not tolerate or send any SPAM mail to anyone. If you feel you have been targeted by a SPAM message, we would appreciate if you could forward the message to us at abuse at shareasale.com.

Shareasale.com manages the relationships between advertisers and affiliates, which is why you were directed to our site. Since the link that you clicked is not currently active, you were not redirected to the site.

If you are a new affiliate, your links will not be active until Shareasale.com gets a chance to review your account - you will receive an email when your account is approved and links are activated. This process generally takes around 24 business hours.

broken atom/rss links for type and properties equals software series

Hi,
I follow your blog through an RSS reader, and I remarked that the feed links for posts of the latest series (which is pretty interesting by the way) all give a 404.
I made a quick check, and this seems to be an issue with url generation: actual reachable urls are all made with single dashes between words, while RSS-exposed ones have double dashes replacing the plus sign and equal sign of your titles.
reachable url: http://blog.ploeh.dk/2016/02/12/types-properties-software-properties-for-the-advantage-state/
ATOM/RSS item url: http://blog.ploeh.dk/2016/02/12/types--properties--software-properties-for-the-advantage-state
I don't know if you're aware of the issue or not, so I wanted to let you know.
Regards.

Change published date to appear on top for mobile

I find it helpful to know when a post was published when I start reading it. This is easy to determine when viewing on my laptop via either the URL at the top or the published date on the right.

Screenshot on laptop:
2020-01-11_08-51-56_28_chrome

However, I normally read posts via my Android phone. In that case, the URL is not visible (and hard inspect) and the published date appears at the bottom of the page.

Screenshot on iPhone X as simulated by Google Chrome:
2020-01-11_08-53-01_29_chrome

Would you consider moving the published date between the title and body of your posts?

Paged Atom feed

The Atom feed is becoming longer and longer, and is currently at more than 4 MB. This is not long-term sustainable.

The Atom specification enables paged feeds, and Jekyll also enables pagination, so it would be nice to split the Atom feed into multiple, smaller pages.

One challenge, though, is that ideally, once a page is filled up, it should retain its unique ID, but I'm not sure if that's a practical concern...

Idiomatic F# for applicatives.

I read your latest article about applicatives and FSharp, it made me wonder what a good way to use this would be. It wasn't obvious to me how to rewrite chained application in a readable way so instead I used the off menu "butterfly operator". |>f<| which lets you essentially treat any two argument function as a two argument operator. This lets you also get around the weirdness in .Net around operator overloading, while still getting the left to right way of reading. Now you can have an apply function for any container type and use them in a way that is mentally similar to <*> .

module List = 
  let apply fs l = fs |> List.collect (fun f -> l |> List.map f)

module Option = 
  let apply f o = function
    | Some f, Some o -> Some (f o)
    | _ -> None

type Suit = Diamonds | Hearts | Clubs | Spades

type Face =
    |  Two | Three | Four | Five | Six | Seven | Eight | Nine | Ten
    | Jack | Queen | King | Ace

type Card = { Face: Face; Suit : Suit }

// Face list
let allFaces = [
    Two; Three; Four; Five; Six; Seven; Eight; Nine; Ten;
    Jack; Queen; King; Ace]

// Suit list
let allSuits = [Diamonds; Hearts; Clubs; Spades]

// Card list
let fullDeck = 
  [fun f s -> { Face = f; Suit = s }] 
  |>List.apply<| allFaces 
  |>List.apply<| allSuits

Real paragraph headings

Currently, I use <p><strong>Heading</strong></p> for paragraph headings, which is readable, but lacks features.

For one, perhaps it'd be better to use proper HTML tags for this, but more importantly, I think each heading should have an ID (GUID?) so that it'd be possible to link to a particular section on a page.

The style should look similar to the current style.

This involves retroactively changing all existing posts.

Better code rendering on mobile devices

I've noticed that when viewed on my Android phone (with Chrome for Android), recent posts have suboptimal code listings. While code snippets are rendered with appropriate colours, they aren't rendered in a monospaced font.

As far as I can tell, the last one that looked good on my phone was REST efficiency:

screenshot_2016-02-23-17-22-57

The next article that shows code is How to use FSharp.Core 4.3.0 when all you have is 4.3.1:

screenshot_2016-02-23-17-24-26

Both articles look fine (that is, code fonts are monospaced) on my laptop when viewed in Chrome.

My theory is that this change is cause by my shift from CopySourceAsHTML (which doesn't work with modern versions of Visual Studio) to Visual Studio Power Tools.

Dim code body unless mouse hovers over it

There's been a bit of confusion about my article Zone of Ceremony. My intention was to discuss the ceremony required with various languages, i.e. what you have to do before you get to do what you really want to do.

Creating files for classes, defining classes, and declaring types is, as I see it, a big part of this. How the actual implementation code looks was never my point.

I debated with myself whether to even show any code. My point was the Zone of Ceremony concept and the idea about trans-ceremonial languages. I thought, however, that if I didn't show any code, the article would be too abstract.

I also debated whether to just show method/function declarations without the implementation code. For example, I could have showed the C# example like this:

public static class Enumerable
{
    public static IEnumerable<int> Consume(
        this IEnumerable<int> source,
        int quantity)
    {
        // Implementation goes here...
    }
}

I was concerned, however, that this would also confuse some readers. Particularly, when you'd reach the F# and Haskell examples, you be presented with a Haskell example like this, which looks almost disingenuous to the uninitiated:

consume quantity = -- Implementation goes here...

So I decided to include all of the code.

I also decided to go with what I considered most idiomatic for the language in question. I wrote the C# code as a for loop, while I wrote the F# and Haskell examples using a fold. (I've no idea what's idiomatic in JavaScript, but I used a for loop there as well.)

The result of those decisions was that some readers interpreted the article as extolling the virtues of folds over for loops, which wasn't my point at all.

I'd like to de-emphasise the implementation code while still keeping it around. Ideally, I'd like the method/function bodies to be greyed out by default, like this:

image

If you want to see the method body, you'd mouse over the pre element, and it'd light up with all the colouring that it currently has.

I'd like this implemented with the least amount of new 'code' for the site, i.e. not too much new JavaScript or CSS. It's basically an ad-hoc adjustment for this particular article.

Incorrect 'next' link on page 2

Steps to reproduce

  1. Go to http://blog.ploeh.dk/page2
  2. Scroll down to the bottom
  3. Click Next

Expected behaviour

The link takes you back to the 'first' page, which is, implicitly, http://blog.ploeh.dk

Actual behaviour

The link points to http://blog.ploeh.dk/page1, which doesn't exist, resulting in a 404 Not Found result.


IIRC, this once worked, but I may be wrong about that. If, on the other hand, I remember correctly, this bug may have been introduce by the infamous Jekyll update some time ago.

Design patterns book suggestion

Regarding your blog http://blog.ploeh.dk/2017/10/04/from-design-patterns-to-category-theory/ , if you haven't read Jason Smith's Elemental Design Patterns (https://www.amazon.com/Elemental-Design-Patterns-Jason-Smith/dp/0321711920) then I highly suggest you do. It's all about deconstructing design patterns into more elementary parts (basically the relationships between objects), and I think it fits perfectly with your series.
One thing to note is that it is based on the notion of objected oriented programming, so I would be very interested in seeing a similar breakdown on more functional programming patterns. I suspect there's another dimension of relationships that can be gleaned from a functional lens but I haven't given it much thought myself.

Definitely looking forward to your series.

PS. PR's are too much effort to try to leave a comment (although I imagine it would cut down on useless posts). Just a suggestion but providing an input box on each page and automatically posting a PR through a button (requiring logged in github users), may lower the barrier to entry and allow more discussion on these topics.

Print version

Would it be possible to get a better print.css? Currently the print version includes extraneous sections (comments/buttons/footers).

Issues with post: A reusable ApiController Adapter

I didn't want to figure out your crazy commenting system, so I added this as an issue that you may or may not ignore at your own discretion :). I just figured this was information you might want to know.

I find a few issues with your blog post. Technically, I don't think anything you write in it is wrong, but there are a few of the statements I find problematic in the sense that people will probably read the blog post and conclude that "this is the only solution because of X" when in fact X is trivial to circumvent.

The main issue I have with your post is the following:

You'd think you could easily refactor the code by turning the identical pattern matches into a reusable function. Unfortunately, it's not so simple, because the methods used to return HTTP responses are all protected (to use a C# term for something that F# doesn't even have). You can call this.Ok () or this.NotFound () from a derived class, but not from a 'free' let-bound function.

As stated earlier, there is nothing in your statement that is technically wrong, but I'd argue that you've reached the wrong conclusion due to lack of data. Or in this case familiarity with Web API and it's source code. If you go look at the source for ApiController, you will notice that while true, the methods are protected, they are also trivial one-liners (helper methods) calling public APIs. It is completely possible to create a helper ala:

// NOTE: Untested
let handle (ctrl: ApiController) = function
  | Success of result -> OkNegotiatedContentResult (result, ctrl)
  | Failure RouteFailure -> NotFoundResult (ctrl)
  | Failure (ValidationFailure msg) -> BadRequestErrorMessageResult (msg, ctrl)
  | Failure (IntegrationFailure msg) -> ExceptionResult ((InvalidOperationException msg), ctrl)

Another thing you can do is implement IHttpActionResult on your discriminate union, so you can just return it directly from you controller, in which case you'd end up with code like this:

member this.Post (portalId : string, req : PaymentDtr) = imp portalId req

It's definitely a bit more work, but in no way is it undoable. Thirdly, Web API (and especially the new MVC Core which has taken over for it) is incredibly pluggable through it's DI. You don't have to use the base ApiController class if you don't want to. You can override the resolution logic, the handing of return types, routing, you name it. It should for instance be entirely doable to write a handler for "controllers" that look like this:

[<Controller>]
module MyController =
  [<AllowAnonymous>]
  // assume impl is imported and in scope here - this controller has no DI
  let post (portalId : string) (req : PaymentDtr) = impl portalId req

This however would probably be a bit of work requiring quite a bit of reflection voodoo. But somebody could definitely do it and put it in a library, and it would be nuget-installable for all.

Anyways, I hope this shows you that there are more options to solve the problem. And who knows, you may have considered all of them and concluded them unviable. I've personally dug through the source code of both MVC and Web API a few times which is why I know a bunch of this stuff, and I just figured you might want to know some of it too :).

Total post count

Mostly for my own gratification, I'd like a count of the total number of posts on the blog.

In order to make this as unintrusive as possible, this could simply go in the bottom of the Archive page.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.