Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 583407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:47:22+00:00 2026-05-13T14:47:22+00:00

i want to mark a method as obsolete, but Delphi 5 doesn’t have such

  • 0

i want to mark a method as obsolete, but Delphi 5 doesn’t have such a feature.

For the sake of an example, here is a made-up method with it’s deprecated and new preferred form:

procedure TStormPeaksQuest.BlowHodirsHorn; overload; //obsolete
procedure TStormPeaksQuest.BlowHodirsHorn(UseProtection: Boolean); overload;

Note: For this hypothetical example, we assume that using the parameterless version is just plain bad. There are problems with not “using protection” – which have no good solution. Nobody likes having to use protection, but nobody wants to not use protection. So we make the caller decide if they want to use protection or not when blowing Hodir’s horn. If we default the parameterless version to continue not using protection:

procedure TStormPeaksQuest.BlowHodirsHorn;
begin
    BlowHodirsHorn(False); //No protection. Bad!
end;

then the developer is at risk of all kinds of nasty stuff. If we force the parameterless version to use protection:

procedure TStormPeaksQuest.BlowHodirsHorn;
begin
    BlowHodirsHorn(True); //Use protection; crash if there isn't any
end;

then there’s a potential for problems if the developer didn’t get any protection, or doesn’t own any.

Now i could rename the obsolete method:

procedure TStormPeaksQuest.BlowHodirsHorn_Deprecatedd; overload; //obsolete
procedure TStormPeaksQuest.BlowHodirsHorn(UseProtection: Boolean); overload;

But that will cause a compile error, and people will bitch at me (and i really don’t want to hear their whining). i want them to get a nag, rather than an actual error.

i thought about adding an assertion:

procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete
begin
   Assert(false, 'TStormPeaksQuest.BlowHodirsHorn is deprecated. Use BlowHodirsHorn(Boolean)');

   ...
end;

But i cannot guarantee that the developer won’t ship a version without assertions, causing a nasty crash for the customer.

i thought about using only throwing an assertion if the developer is debugging:

procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete
begin
   if DebugHook > 0 then
      Assert(false, 'TStormPeaksQuest.BlowHodirsHorn is deprecated. Use BlowHodirsHorn(Boolean)');

   ...
end;

But i really don’t want to be causing a crash at all.

i thought of showing a MessageDlg if they’re in the debugger (which is a technique i’ve done in the past):

procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete
begin
   if DebugHook > 0 then
        MessageDlg('TStormPeaksQuest.BlowHodirsHorn is deprecated. Use BlowHodirsHorn(Boolean)', mtWarning, [mbOk], 0);

   ...
end;

but that is still too disruptive. And it has caused problems where the code is stuck at showing a modal dialog, but the dialog box wasn’t obviously visible.

i was hoping for some sort of warning message that will sit there nagging them – until they gouge their eyes out and finally change their code.

i thought perhaps if i added an unused variable:

procedure TStormPeaksQuest.BlowHodirsHorn; //obsolete
var
   ThisMethodIsObsolete: Boolean;
begin
   ...
end;

i was hoping this would cause a hint only if someone referenced the code. But Delphi shows a hint even if you don’t call actually use the obsolete method.

Can anyone think of anything else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:47:22+00:00Added an answer on May 13, 2026 at 2:47 pm

    What I’ve ended up using was a combination of opting into a system where you agree to not have any deprecated code, with output debug strings and breakpoints otherwise.

    Like strict html, I’ve created a Strict define.

    All the common units have the obsolete code defined out if Strict is defined. That way the developer has agreed that they will not have deprecated code in their project:

    {$IFNDEF Strict}
    procedure TStormPeaksQuest.BlowHaldirsHorn; overload; //obsolete
    {$ENDIF}
    procedure TStormPeaksQuest.BlowHaldirsHorn(UseProtection: Boolean); {$IFNDEF Strict}overload;{$ENDIF}
    
    
    {$IFNDEF Strict}
    procedure TStormPeaksQuest.BlowHaldirsHorn; //obsolete
    begin
       OutputDebugString(PAnsiChar('TStormPeaksQuest.BlowHaldirsHorn is deprecated. Use BlowHaldirsHorn(Boolean)'));
    
       //Don't debugbreak without a debugger attached!
       if DebugHook > 0 then
            Windows.DebugBreak;
    
       ...
    end;
    

    So if the developer wants to have proper code, suffering having to perform code-changes when new things are deprecated, they can:

    {$DEFINE Strict}
    

    If not, then there will always be an OutputDebugString, and anyone with Debug View can see (even customers). It’s funny to see commercial software (even Microsoft’s) with output debug strings left over.

    And finally, if there’s a debugger attached, then they’ll get a debug breakpoint out of nowhere. If anyone asks about, i can take that opportunity to make fun of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 305k
  • Answers 305k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Actually your proposed directory structure is more than appropriate for… May 13, 2026 at 9:00 pm
  • Editorial Team
    Editorial Team added an answer The problem was not with the if statement. Sadly it… May 13, 2026 at 9:00 pm
  • Editorial Team
    Editorial Team added an answer You need to modify the USB host driver to ask… May 13, 2026 at 9:00 pm

Related Questions

Possible Duplicate: How do I mark a method as Obsolete/Deprecated? - C# How do
OK, I know what you're thinking, "why write a method you do not want
In Python 2.x when you want to mark a method as abstract, you can
I have an array that I want to permutate randomly. In Java, there is
I'm trying to create a horizontal 100% stacked bar graph using HTML and CSS.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.