|
Java code:
public class Account
{
...
public String type;
public String acctNumber;
public String balance;
...
}
public class CreditCardAccount extends Account
{
...
}
public Account getAccount(String id)
{
...
}
public void transferMoney(Account account, double amount)
{
...
if (<credit card transfer>)
{
CreditCardAccount cca = (CreditCardAccount)account;
...
}
...
}
Looks okay so far, but I got a ClassCastException when I did:
Account account = getAccount("12345");
...
transferMoney(account, amount);
It turns out, transferMoney *never* returns a CreditCardAccount object, but instead returns an Account object, with the type member set to "CreditCardAccount". The engineer who wrote this told me that I should change my code to:
Account account = getAccount("12345");
if (account.type.equals("CreditCardAccount"))
{
CreditCardAccount cca = new CreditCardAccount();
cca.type = account.type;
cca.acctNumber = account.acctNumber;
cca.balance = account.balance;
...
transferMoney(cca, amount);
}
|
|
|
|
|
I hope you told him to change his.
|
|
|
|
|
Leisuresuit Larry wrote: The engineer who wrote this told me that I should change my code to
I think you meant:
The "engineer" who wrote this told me that I should change my code to
That's wrong on so many different levels. I hope you aren't dealing with a system where this kind of thing is rampant. If so, run, run far away.
This blanket smells like ham
|
|
|
|
|
He don't deserve the "engineer"... He can be named "mess-professional"...
But honestly - it's really really bad to work with such people who create mess themself and then argue when someone telling them that they're wrong...
------------------------------------------------------------
Want to be happy - do what you like!
|
|
|
|
|
He's obviously object-disoriented.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
God is the only being who, to rule, does not need to exist. -- Charles Baudelaire
|
|
|
|
|
I m really speechless on this..
<br />
string strQuery = "Select * from tblExtension where UserType = " + _UserType;<br />
int _Count = 0;<br />
OleDbDataReader drExtension = OleDbHelper.ExecuteReader(Utility.ConnectionString, CommandType.Text, strQuery);<br />
using(drExtension)<br />
{<br />
while(drExtension.Read())<br />
{<br />
++_Count;<br />
}<br />
}<br />
return _Count;<br />
ny comment??
Vikas Salvi
Programmer Analyst
|
|
|
|
|
I'm flabbergasted !!?!
No really I am!
codito ergo sum
|
|
|
|
|
Version 1.0 probably used a DataAdapter to Fill a DataTable and then counted the Rows. This is an improvement.
|
|
|
|
|
using a Count(*) query is much simple n straightforward i suppose
Vikas Salvi
Programmer Analyst
|
|
|
|
|
And depending upon the database, count(ROWID) might be even better.
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Well, yeah, but we have to save that for the next version... if anyone complains about performance that is. Or, if we're very lucky, we'll get to buy new servers to improve performance, and that makes us very happy.
|
|
|
|
|
The gay guy that rated your post with a 2, obviously didn't catch the sarcasm in it... Some things are too subtle I guess
Asynchronously daydreaming...
|
|
|
|
|
Gold Canyon, AZ ... where OpenSource means far too much of a reduction in profit margins!
|
|
|
|
|
Alright, who are you and how do you know where I live?
|
|
|
|
|
http://profiles.yahoo.com/piebaldconsult
|
|
|
|
|
Ah, yes. I do wish CP allowed more than simply "U.S.", it's a big damn country.
|
|
|
|
|
I was just poking to find out where my next resume should go, if one needs to be sent out.
|
|
|
|
|
We are looking to replace a developer who left recently.
|
|
|
|
|
Check the MFC docs for CRecordset. They specifically advise that the record count isn't known until you've scrolled to the last record and then recommend you do just that if you need the count. A colleague, many years ago, followed that advice. It worked fine on his test databases but when it hit the real world and a recordset containing 3 million records it didn't work quite so well. Interestingly enough, the customer put up with the shocking performance (> 40 minutes for a form refresh). Go figure!
|
|
|
|
|
Rob Manderson wrote: Interestingly enough, the customer put up with the shocking performance (> 40 minutes for a form refresh). Go figure!
Now that's the true WTF.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
add a little spinny thing while it refreshes... they'll wait for hours
|
|
|
|
|
Of course a good way to speed that up was to use the MoveLast method after the recordset was opened. The count call would then be really responsive, but you'd be scratching your head over why was the count always 2.
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Yes but it should not apply if the query uses "count(*)" becuase the sql server will do the "counting" and return 1 row with the result.
Mauro Leggieri.
|
|
|
|
|
It verifies whether SQLServer is doing a correct job or not.
|
|
|
|
|
The programmer should have done away with the where clause and check UserType in the while loop.....
|
|
|
|