Tag Archives: Delphi

Record Helpers for Intrinsic Types

I guess that most of you already heart about it. With Delphi XE3 EMBT introduced record helpers for intrinsic types. E.g. Marco Cantu and Nick Hodges already blogged about it. Just to explain what record helpers for intrinsic types are … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on Record Helpers for Intrinsic Types

IntraWeb and Session Timeout

This week I had to maintain an IntraWeb application. For those who are not familiar with IntraWeb it allows you to create a web application with Delphi. This means that you can design your web application with components and their … Continue reading

Posted in Tips and Tricks | Tagged , | Comments Off on IntraWeb and Session Timeout

GlobalConsts.pas

Today, I found another example of a common mistake, a unit with global constants. I guess most of you know this situation. There is a value that is used several times in a unit and you declare a constant for … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on GlobalConsts.pas

ObjGuard

Sometimes it happens that I would like to convert a Delphi object to an interfaces. Interfaces offer some advantages. On the one hand you can handle different objects that are not derived from a common hierarchy but share the same … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on ObjGuard

More About Records

Since records offer methods and properties they are often used to replace objects. This is possible if there is no need to use inheritance. But there is a significant difference between both. References to objects are like pointers to a … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on More About Records

TPath.Combine

I guess that everyone already had to solve this small issue. There are two variables, one with a path, the other with the filename and they have to be combined. In the old Delphi world there is the function IncludeTrailingPathDelimiter … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on TPath.Combine

StringOfChar

This week I found a new interesting piece of code. Someone wanted to initialize a string with a special length of the same char.

Come on guys, this is complete rubbish! In short words, a string is a record … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on StringOfChar

(Ab)use of Try..Except

Today I found an example of the abuse of a try.. except block.

The idea is simple. StrToInt converts a string to an integer as long as the string contains an integer value. If not an exception will be … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on (Ab)use of Try..Except

Records

Because of my post about the Switches I would like to mention some things about records. Records are are nice way to do things in an object-oriented way without the overhead of real objects. In the unit System.IOUtils you can … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on Records

Naming of Constants

Normally constants improve the readability and maintainability of your code. One example is the minimum value of a single. You can find it in the unit System.Math:

Instead of writing the float value it is easier and more readable … Continue reading

Posted in Tips and Tricks | Tagged | Comments Off on Naming of Constants