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,860 other subscribers

Archive for the ‘Delphi’ Category

Delphi XE introduced SafeIntfAsClass to cast back interface to class (via: oop – Delphi – Proxy Design Pattern – interface problem – Stack Overflow)

Posted by jpluimers on 2011/03/23

Delphi XE introduced the SafeIntAsClass to cast back from an interface to a class.

This is one of the things I really started to miss after doing a lot of .NET work (where that worked starting with .NET 1).

Older versions of Delphi did not support safely casting from an interface back to an object.

–jeroen

via: oop – Delphi – Proxy Design Pattern – interface problem – Stack Overflow.

Posted in Delphi, Development, Software Development | 4 Comments »

Delphi Labs: DataSnap XE and jQueryMobile; a Web Frontend accessing DataSnap through a Delphi WebBroker server

Posted by jpluimers on 2011/03/22

[Wayback] Paweł Głowacki recently released two very interesting blog articles, together with 5 (five!) demonstration videos on how to get your mobile device to talk to a DataSnap backend using [Wayback] jQueryMobile so you get a very native look & feel UI on your mobile device without putting a lot of effort in writing a native device app.

  1. [Wayback] Part 1: Delphi Labs: DataSnap XE – WebBroker jQueryMobile Boilerplate – DelphiFeeds.com.
  2. [Wayback] Part 2: Delphi Labs: DataSnap XE – jQueryMobile Web Frontend – DelphiFeeds.com.

Highly recommended!

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, JavaScript/ECMAScript, jQuery, Scripting, Software Development | Leave a Comment »

Ideone.com | Online IDE & Debugging Tool >> C/C++, Java, PHP, Python, Perl and 40+ compilers and intepreters

Posted by jpluimers on 2011/03/18

Really cool stuff; dozens of computer languages are supported, including C# and VB.NET (both on Mono) and a few Pascal flavours.

Briefly about ideone

ideone.com is a… pastebin. But a pastebin like no other on the Internet. More accurate expression would be online mini IDE and debugging tool.

Ideone is an Italian word for great ideas – because ideone.com is a place where your greatest ideas can spring to life.

ideone.com is designed mostly for programmers (but, of course, common plain text can also be uploaded). You can use it to:

share your code (that’s obvious – it is a pastebin, isn’t it? :)) in a neat way,

run your code on server side in more than 40 programming languages (number still growing)

and do it all with your own input data!

ideone.com also provides free Ideone API which is availabe as a webservice. It’s functionality allows you to build your own ideone-like service!

for logged in users Ideone offers possibility to manage their codes, publish multiple submissions at one go, and more.

All codes can be accessed through convenient hash links. Source code pages provide information about the code and its execution: memory usage, execution time, language and compiler version, code itself, input uploaded by the user, output generated by the program and error messages from compilers and interpreters.

–jeroen

via Ideone.com | Online IDE & Debugging Tool >> C/C++, Java, PHP, Python, Perl and 40+ compilers and intepreters.

Posted in .NET, C#, Delphi, Development, Software Development, VB.NET | 4 Comments »

“Try to avoid foreach/for loops”–Over my Dead Body! | Visual Studio Feeds

Posted by jpluimers on 2011/03/16

Zack Owens wrote a nice article comparing various loop constructs.

Summary:
If the semantics are the same, it does not matter if you use foreach, for, while or do while: they all  have equal speed.

So: choose the loop construct that best fits the problem you are trying to solve.

–jeroen

via: “Try to avoid foreach/for loops”–Over my Dead Body! | Visual Studio Feeds.

Posted in .NET, C#, Delphi, Prism, Software Development | 12 Comments »

online: Create a GUID

Posted by jpluimers on 2011/03/10

Don’t you love this kind of sites:

Create a GUID at createguid.com

–jeroen

via Create a GUID.

Posted in .NET, Delphi, Development, Software Development | 14 Comments »

Why is the result of RoundTo(87.285, -2) => 87.28 – Stack Overflow

Posted by jpluimers on 2011/03/08

Programmers on all sorts of platforms get this wrong all the time (I admit having done this in bad ways myself too).

In short: Don’t expect floating point values in a computer to be represented as decimals.

Rob Kennedy wrote a very nice answer on this:

The exact value 87.285 is not representable as a floating-point value in Delphi. A page on my Web site shows what that value really is, as Extended, Double, and Single:

87.285 = + 87.28500 00000 00000 00333 06690 73875 46962 12708 95004 27246 09375

87.285 = + 87.28499 99999 99996 58939 48683 51519 10781 86035 15625

87.285 = + 87.28500 36621 09375

And David Heffernan points to the best link you can get on this topic:

The classic reference on floating point is What Every Computer Scientist Should Know About Floating-Point Arithmetic.

For currency based calculations, if indeed this is, you should use a base 10 number type rather than base 2 floating point. In Delphi that means `Currency`.

–jeroen

via delphi – Why is the result of RoundTo(87.285, -2) => 87.28 – Stack Overflow.

Posted in .NET, Algorithms, C#, Delphi, Development, Floating point handling, Software Development | 14 Comments »

Ask yourself: “are you writing a framework now?” – How (not) to write Factorial

Posted by jpluimers on 2011/03/01

On the Development Choas Theory blog, I bumped into a brilliant blog post titled How (not) to write Factorial in Java.

It is not about Java, or any other programming language, platform or library for that matter.

It equally applies to your favourite programming language and framework (be it shell scripts, assembler, .NET, Delphi, haskell, PHP, ruby, Eiffel, Java or any other).

It is about the question that Neal Ford taught me quite a while ago that you should ask yourself several times a day:
“Am I writing a framework now?”

Developing software is about only developing the things you really need to.

Framework development is in a totally different league than developing ‘just’ software.
It requires even more thought, attention, testing, etc.
And after that, you need to support it on a different level too.

Frameworks are far more costly than you would guess at first sight…

So only develop a framework  for something (*) if you observe that it is actually used in a lot of places and requires a framework.

(*) insert what you are currently working on here.

–jeroen

Via:  Development Chaos Theory » Blog Archive » How (not) to write Factorial in Java

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

Delphi friend in NZ seeks work (preferably remotely)

Posted by jpluimers on 2011/02/25

A seasoned Delphi developer friend in NZ (near Christchurch) seeks work, preferably if he can work remotely.

Please drop me an email to get more information.

–jeroen

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

Supporting Office 2003 from .NET: getting the Office 2003 Primary Interop Assemblies

Posted by jpluimers on 2011/02/22

Often you work with projects not having the latest stuff.
Sometimes that is a good thing: latest stuff is not always best :-)

In this case, the client had Office 2003, and needed to do some Excel automation from .NET.
The development systems however had Office 2007 on it, so importing Excel defaults to the Office 2007 Primary Interop Assembly: Office version 12 in stead of 11. Read the rest of this entry »

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Prism, Software Development, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | Leave a Comment »

Verifying if two hosts are on the same IPv4 network

Posted by jpluimers on 2011/02/17

Recently, I wrote a bunch of code both in C# and Delphi to verify if two hosts are on the same IPv4 network.

Even though the public IPv4 address space is exhausted (IANA recently allocated the final two IPv4 blocks of their primary pool to APNIC, then allocated the five remaning /8 IPv4 blocks to the RIRs, thereby depleting the IPv4 pool), they are still used a lot, especially in private networks.

Over the next couple of weeks, you will see a couple of blog posts explaining:

  • how to get the IPv4 addresses and network masks of network interfaces in your computer
  • how to convert those to and from strings
  • how to convert a host-name to a list of IP addresses
  • how to lookup the current host-name
  • how network masks are related to counting leading/trailing ones and zeros
  • how to compare two IPv4 addresses given they have the same network masks

Those blog posts will have sample code in both Delphi and C#. And there will be unit tests to verify the underlying code.

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Software Development | 2 Comments »