The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

  • 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,651 other followers

Archive for the ‘C++’ Category

Design Patterns & Refactoring

Posted by jpluimers on 2019/07/16

Design Patterns and Refactoring articles and guides. Design Patterns video tutorials for newbies. Simple descriptions and full source code examples in Java, C++, C#, PHP and Delphi.

Source: [WayBackDesign Patterns & Refactoring.

And indeed a lot of examples in Delphi too; few sites have that: Delphi site:sourcemaking.com.

–jeroen

Via: [WayBack] I stumbled upon this yesterday, very informative, accessible and also with Delphi examples – among other languages. – Steffen Nyeland – Google+

Posted in .NET, C, C#, C++, Delphi, Design Patterns, Development, Java, Java Platform, PHP, Scripting, Software Development | Leave a Comment »

It was all Greek to me: Iota · golang/go

Posted by jpluimers on 2019/05/21

Context is king!

Being Dutch, my association with iota was the phrase “Ik snap er geen iota van” (English: “It’s all Greek to me”), basically indicating iota is extremely small, similar to [WayBack] Iota | Definition of Iota by Merriam-Webster:

1an infinitesimal amount jot  (did not show an iota of interest)
2the 9th letter of the Greek alphabet — see alphabet table

But the first time, I saw iota used in golang, I actually confused it with [WayBack] itoa – C++ Reference, because I am more than slightly wordblind.

So code like this was all Greek to me at first, not understanding the conversion from integer to ASCII**, and slightly later, not understanding iota to be extremely small either. Heck, its usage indicates it is small from infinitesimal:

const (
    _           = iota // ignore first value by assigning to blank identifier
    KB ByteSize = 1 << (10 * iota)
    MB
    GB
    TB
    PB
    EB
    ZB
    YB
)

So it took me a bit of thought to realise that it actually had to mean something completely different, so I found

It makes me wonder why they named it like this.

Slightly related:

–jeroen

Read the rest of this entry »

Posted in C++, Development, Go (golang), Software Development | Leave a Comment »

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 »

Value types not having parameterless constructors…

Posted by jpluimers on 2019/03/27

The list below is based on a G+ discussion in a single language, but has way broader aspects.

It’s on value types, mutability, parameterless constructors and expectations of compiled code.

I’ve bitten myself in the foot with mutable types in too many languages too often, so I started advocating this years ago at clients, and now in this blog-post.

TL;DR:

  • some languages disallow parameterless constructors: C++, C# and Delphi are examples
  • this historically stems from the C++ and C# background
  • it has to do with them not wanting to automatically call them upon array initialisation taking a lot of CPU time
  • most languages do not stop you from making mutable value types, but in practice your value types should be immutable as otherwise you will open a can of worms, for instance you will have a hard time:
    • preventing threading issues
    • making code following functional patterns
    • scaling your code by making your algorithms supporting parallel execution
  • parameterless constructors include constructors with parameters having default values

Some links that explain this in more depth:

The “just pass them as reference” often seen as reason to explain “mutable value types are OK” is exactly describing why they are not OK.

–jeroen

Posted in .NET, C#, C++, Delphi, Development, Software Development | 2 Comments »

gdbgui – browser based debugger for C, C++, go, rust, Fortran. Modern gdb frontend.

Posted by jpluimers on 2019/03/05

[WayBack] gdbgui – browser based debugger for C, C++, go, rust, Fortran. Modern gdb frontend.: gdbgui (gnu debugger graphical user interface)

Via: [WayBack] Browser-based debugger for C, C++, go, rust, and more – written in Python with Flask. https://github.com/cs01/gdbgui Easy installation via PyPI: pip i… – Joe C. Hecht – Google+

–jeroen

Posted in C, C++, Debugging, Development, Fortran, GDB, Go (golang), Python, Scripting, Software Development | Leave a Comment »

 
%d bloggers like this: