• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making a method a public alias of another method  RSS feed

 
Adrienne Peck
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a project where the designer changed a method then told me to make the old method a public alias of the new one.

The new method is:

public synchronized Statement exec(String qy) {
lastException = null;
try {
System.out.println(qy);
stmt = getConn().prepareCall(qy);
stmt.execute();
//return stmt;
}catch (SQLException e) {
reportError("Problem executing query " + qy, e);
}
return stmt;
}



The old method is:

public synchronized void execProc(String qy) {
lastException = null;
try {
stmt = getConn().prepareCall(qy);
stmt.execute();
// boolean execute method
} catch (SQLException e) {
reportError("Problem with execProc " + qy, e);
}


What is a public alias? What is the advantage of making one method a public alias of another?



 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

"Public alias" doesn't have a meaning to me. Do you suppose he just means make the old signature call the new method? That would avoid breaking any clients using the old method.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stan James:
... "Public alias" doesn't have a meaning to me. Do you suppose he just means make the old signature call the new method? ...

That would be my guess too. I'm not familiar with that term.
[ July 10, 2006: Message edited by: marc weber ]
 
Adrienne Peck
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK...I'll ask what he means. When my research didn't bring up anything on 'public alias', I thought I just didn't know where to go. Now that I've heard from you guys, I can approach him with a bit more confidence. Thanks!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If that's the case, ask if the old signature shouldn't be deprecated. Having two similarly named methods that do the very same thing except one returns a value and the other doesn't is sure to confuse future generations of coders who use this thing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!