Deprecate a Function

in Programming

I was porting over some code today and had an apostrophe moment. (You know… when lighting strikes your brain?)

In order to deprecate a function in your code, you can leave the function intact, but basically have it shout out that it is deprecated and exit.

Here’s an example from the PHP script I’m working on.

public function import_dumps_into_staging_tables(){
$this->logerror(__FUNCTION__ . " deprecated!");
return false;
...
}

This is great because it basically logs that the function is deprecated and leaves the function.

In the abstract, this concept made it clear to me how Rails sends their deprecation warnings first. And then how they could use this concept (in Ruby syntax of course) to fully deprecate a method, without it causing some “No Method” error.

0 Comments

Leave a Reply

You must be logged in to post a comment.

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>