The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,639 other followers

Archive for May 15th, 2019

How to Design Early Returns in C++ (Based on Procedural Programming) – Fluent C++

Posted by jpluimers on 2019/05/15

One more thing to take away from Procedural Programming: It’s Back? It Never Went Away – Kevlin Henney [ACCU 2018] – YouTube was explained in [WayBack] How to Design Early Returns in C++ (Based on Procedural Programming) – Fluent C++.

Though in C++, it applies to all programming languages that stem from a procedural background (Pascal, C#, Java, golang, to name just a few).

The article is about keeping an if/else-if/else tree, even when they can be removed becomes some of their bodies perform an early return, as

In C++, as well as in other languages, the return keyword has two responsibilities:

  • interrupting control flow,
  • yielding a value.

It basically comes down to this argument:

Essentially, the argument for Code #1 is that you need to know less to understand the structure of the code.

Indeed, if we fold away the contents of the if statements, Code #1 becomes this:

The structure of the code is very clear. There are 4 different paths based on the year, they’re independent from each other, and each path will determine the boolean result of the function (if it doesn’t throw an exception).

Now let’s see how Code #2 looks like when we fold away the if statements:

And now we know much less. Do the if statements contain a return? Maybe.

Do they depend on each other? Potentially.

Do some of them rely on the last return false of the function? Can’t tell.

With Code #2, you need to look inside of the if statement to understand the structure of the function. For that reason, Code #1 requires a reader to know less to understand the structure. It gives away information more easily than Code #2.

–jeroen

via [WayBack] Kevlin Henney – Google+: How to Design Early Returns in C++ (Based on Procedural Programming) – Fluent C++

Posted in .NET, C, C#, C++, Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Google old content posted before a specific date

Posted by jpluimers on 2019/05/15

Steps:

  1. Start with something like https://www.google.com/search?q=”did+you+hear+about+the+man”+”he%27s+0K+now”
  2. Clicking Tools followed by Any Time, then Custom range often does not show a dialog.
  3. Appending &tbs=qdr:y to the URL magically enables that popup:
    https://www.google.com/search?q=”did+you+hear+about+the+man”+”he%27s+0K+now”&tbs=qdr:y
  4. After filling it in, you get a very different URL like https://www.google.com/search?q=”did+you+hear+about+the+man”+”he%27s+0K+now”&tbs=cdr:1,cd_min:,cd_max:01-01-2007

This is how I found the post in Did you hear about the man who got cooled to absolute zero? He’s 0K now.

I think cdr stands for custom date range and qdr for a built in date range as after searching for the abbreviations, I found [WayBack] Google Search URL Request Parameters | DETECTED that discusses tbm and tbo in addition to tbs.

The trick above is the successor of [WayBack] Filter Google Results by Date with a URL Trick which appended &as_qdr=d.

–jeroen

Posted in Google, GoogleSearch, Power User | Leave a Comment »

Need to try this: overloaded default properties

Posted by jpluimers on 2019/05/15

[Archive.is] Need to try this: … multiple default index properties having the same name …getters can be overloads … resolve …by type signature … – Thomas Mueller (dummzeuch) – Google+, thanks to marck for this brilliantly simple example:

private
  function GetColumnValue(const ColumnName: string): string; overload;
  function GetColumnValue(Index: Integer): string; overload;
  procedure SetColumnValue(Index: Integer; const Value: string);
public
  property Values[const ColumnName: string]: string read GetColumnValue; default;
  property Values[ColumnIndex: Integer]: string read GetColumnValue write SetColumnValue; default;
end;

This means:

  • you can have multiple default indexor properties
  • the multiple indexor properties can have the same name e.g., Values
  • the properties getters can be overloads (i.e. have the same name) e.g., GetColumnValue
  • Delphi will resolve the overloads by type signature

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Time capsule opening ceremony today at MIT’s Stata Center after programmers solve MIT’s 20-year-old cryptographic puzzle | MIT CSAIL

Posted by jpluimers on 2019/05/15

[WayBack] Programmers solve MIT’s 20-year-old cryptographic puzzle | MIT CSAIL:

The capsule ceremony will happen Wednesday, May 15 at 4 p.m. at MIT’s Stata Center.

Cool work, with a very cool challenge.

Via/related:

  • a

–jeroen

Posted in Development, Power User, Security, Software Development | Leave a Comment »

 
%d bloggers like this: