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,762 other followers

Archive for the ‘Conferences’ Category

Tech Debt by MonkeyUser

Posted by jpluimers on 2019/11/07

[WayBack] Tech Debt (by MonkeyUser: Software development satire) is one of the best images on Tech Debt I ever encoutered (via[WayBack] Tech Debt by @ismonkeyuser https://www.monkeyuser.com/2018/tech-debt – ThisIsWhyICode – Google+):

–jeroen

Posted in Agile, Conference Topics, Conferences, Development, Event, Software Development, Technical Debt | Leave a Comment »

How to convert a Delphi enum or set to a JSON value, with different specific values…

Posted by jpluimers on 2019/11/07

As I will probably need this one day: [WayBack] How does one convert a Delphi enum to a JSON value, with different specific values? – CHUA Chee Wee – Google+:

eg, TEnum1 = (test1, test2, test3)

TSomeClass.FEnum := test1;

When converted to JSON, I’d like to see maybe
{"Enum": "Value1"} instead of test1

and test2 to "Godzilla", test3 to "Tiburon"

The solution is in his repository: github/chuacw/EnumJson:

After initially suggesting to look into [Archive.is] Serializing User Objects – RAD Studio, he based his solution on a set of clever tricks circumventing Delphi compiler limitations and bugs:

Later he extended the solution to include sets in additions to enums: [Archive.is] Persisting enumeration and sets to JSON – Chee Wee’s blog: IT solutions for Singapore and companies worldwide (via [Archive.isMade my JSON interceptor demo public. Now you can save your enum and sets to JSON, with customized output to boot! – CHUA Chee Wee – Google+)

Clever!

Hopefully this got Lars Fosdal some ideas to solve [WayBackJSON in Berlin – Can I persuade TJSon to treat “params” as it was a string and not an object for the TJsonRPC class? – Lars Fosdal – Google+

Enums with Delphi

Enums with Delphi and their mapping is a repeating topic, see for instance [WayBack] What’s the easiest (ie., least coding) way to map an enum to a const string and vice versa? (Can attributes be used on enum values yet?) eg., type TMyColor… – David Schwartz – Google+

It shows how much the Delphi language is in need of language enhancements as right now there are way too many open source libraries struggling with the same issues each working around them or providing solutions in slightly different way.

Three things immediately come to mind:

  • the NameOf that – analogous to TypeOf – gets the name of an identifier as a string
  • expose all RTTI for all enum types (especially the ones with non-contiguous values or starting at another value than ordinal zero)
  • allow for attributes on enum values

Some examples of libraries providing enumeration support:

Some more thoughts from a different perspective: [WayBackWhat’s New in Edge Rails: Active Record enums

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

The Delphi System.Exit “Function”

Posted by jpluimers on 2019/10/17

Still wrongly documented as System.Exit Function [WayBack], most people think it is a statement.

However, it is a compiler intrinsic procedure in the System unit that – when called inside a real function – optionally accepts a parameter with the same type as the encompassing function because it is a compiler intrinsic. It kind of acts as an overloaded procedure, but in fact translate to machine code via an intermediate parse tree.

The parameterless version has been there since at least Turbo Pascal 3.0, but the parameterised version is more recent: I think it was introduced around Delphi 7.

It then stops executing that function after first executing any explicit or implicit finally blocks.

I’ve seen various projects that used their own Exit procedure. This is a very bad habit: Since the System unit is always further away in scope, the introduced one is called which can severely confuse programmers not being aware of this.

The code generation for the parameterless and parameterised  “overloads” of System.Exit is slightly different:

  • The parameterless one can often be optimised away, for instance folding multiple calls to them into one, or rearranging code execution so a jump isn’t needed any more. This means you cannot always put a breakpoint on them.
  • The parameterised one always needs code to load the function result, so you can always put a breakpoint on them.

Stefan Glienke explained the above in [WayBack] The advantage of using Exit() instead of a plain Exit? You can place a breakpoint! – Uwe Raabe – Google+

–jeroen

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »

How to debug small programs

Posted by jpluimers on 2019/10/17

As a follow up of SSCCE, MWE and MCVE are basically the same: provide code people can use to reproduce a problem, I found [WayBackHow to debug small programs which is starts as

One of the most frequent categories of bad questions I see on StackOverflow is: I wrote this program for my assignment and it doesn’t work. [20 lines of code]. And… that’s it.

Then it goes on how to debug those pieces of code, trim them into an SSCCE/MWE/MCVW to form the base of a question which you can ask on StackOverflow/SuperUser/ServerFault/StackExchange, forum, group/community or even your co-worker.

The really cool thing about the techniques used there are that they also apply to bigger pieces of code, heck even large code bases.

They force you to trim down your problem in to manageable pieces that are easy to explain and write concise documentation and tests around them to assist you in the process.

Below are the steps in a short list. Be sure to read the original article How to debug small programs | Fabulous adventures in coding after going through the list.

  1. Turn on compiler warnings, inspect all of them, resolve or explain them
  2. Rubber duck to an imaginary person or even a live one explaining each part in simple terms
  3. If the bug is still there, break up the code into pieces
  4. Write technical specifications for all the pieces
  5. Verify the pieces against the specifications, for instance by adding pre- and postconditions to them
  6. Add assertions in the pieces for all the specifications
  7. Write test cases for the pieces
  8. Write down on paper the expected behaviour for all the lines of code
  9. Use a debugger to step through all the lines of code and verify the expected behaviour you wrote down
  10. While debugging, listen to all your doubts (gut feeling is a good thing!)

This sounds like a lot of work. It is. All good programming is.

If you apply these before writing any logic code, then your life becomes easier because you will spot bugs sooner:

  • specification
  • test cases
  • preconditions
  • postconditions
  • assertions

Does this again sound like a lot of work?

Then remember: taking a shortcut will make the actual work longer. The reason is that hunting for bugs is a tedious and time consuming process scaling very badly with complexity.

–jeroen

Posted in Conference Topics, Conferences, Debugging, Development, Event, Software Development | Leave a Comment »

SSCCE, MWE and MCVE are basically the same: provide code people can use to reproduce a problem

Posted by jpluimers on 2019/10/16

Many times I see people asking questions about problems in their source code, it goes like this:

  1. Question is asked formulating the problem, but without any source code
  2. A comment asks for source code
  3. Either the response is “the source code is too big”, or the response contains a really big blob of (compressed) code that

If you have such questions (I still often have them), then you need to do just two things (which you often can combine in one step):

  1. Condense down the code into a small bit that others can use to reproduce the problem.
  2. Talk to an (imaginary) person explaining the problem you have and the condensed code.

The second is called Rubber Ducking after a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck.

The first is known under at least three terms:

They all come down to the following:

Provide a small piece of working code that is readable anyone can use to reproduce a problem without much effort.

via: Can we create a Help Center topic that outlines what a SSCCE / MWE means for Stack Overflow?

–jeroen

Posted in Conference Topics, Conferences, Development, Event, Software Development | Leave a Comment »

 
%d bloggers like this: