17

HTMLCanvasElement.toDataURL() returns a data URI

HTMLCanvasElement.toBlob() doesnt return anything but instead requires a callback to handle the result.

Who the fuck is making these decisions?

Comments
  • 10
    For one being async and the other is not?
  • 6
    @jespersh yup. Something like this shows that a certain operation is a bit expensive and can affect user experience.
  • 1
    @MrCSharp while I understand that from a practical level, this kind of thing reminds me of why people shit on PHP. Inconsistency is maddening. Either of these could have been named differently in order to clearly depict how they behave. Now every time I want to use one I'll have to look up which one does what.
  • 1
    @CodeMonkeyG Yes, I agree with you. This kind of inconsistency is annoying. In .Net, MS naming convention for methods says that methods which execute asynchronously should have 'Async' as a suffix. This makes it easier to know how to deal with some methods.

    Web Front End languages lack massively in consistency.
  • 1
    .net method naming... I cant put a finger on anything that is named annoyingly.
    Maybe the unsure parts where it is either .Length, .Count, .Length<>() or the like. VS always fixes it to the correct method so, I don't mind
  • 1
    @jespersh i think of it like: .Length for arrays, and .Count for lists. Of course we have the IEnumerable objects which you have to use the .Count() method and it makes sense because it will actually go through the items to count them. So a tip for linq, don't do a .count() on ienumerable then enumerate it with foreach because then you'll evaluate it twice 😁
  • 1
    @jespersh and if you're counting just to see if it has items then a call to .Any() should be enough because it'll only evaluate the first item then it'll stop
Your Job Suck?
Get a Better Job
Add Comment