Is this bad?

Just going thru some code and I found this line (real names removed to protect the innocent). Suffice to say that setCount() takes an int and someList is a java.util.List.
setCount(someList.toArray().length);
I'm trying beyond hope to believe that there's some legitimate reason for doing it that way, but I'm drawing a blank. I can't seriously believe that calling List.size() isn't faster then creating an array copy of the list first.

Just going thru some code and I found this line (real
names removed to protect the innocent). Suffice to
say that setCount() takes an int and someList is a
java.util.List. Well java.util.List is an interface not a class. What is the implementation class of someList ?
setCount(someList.toArray().length);
I'm trying beyond hope to believe that there's some
legitimate reason for doing it that way, but I'm
drawing a blank. I can't seriously believe that
calling List.size() isn't faster then creating an
array copy of the list first.It unusual enough ideom that I'm thinking it may well have been done on purpose.
It could be that the size() was/is unimplemented in actual class.
Or It could be that if the programmer also implemented the Class he has some knowledge about the implementation class and the toArray method.
Can you post more of the code in context ?

Similar Messages

  • Is this bad: g.drawImage(img, 0, 0, null);

    Is this bad: g.drawImage(img, 0, 0, null);
    I don't know if I need an ImageObserver "reference"(?) in this method. I see know need for it.
    Thank you.
    Joshua

    The last parameter is the observer that will be
    notified when the image has been completely loaded -
    recall that loading of images is asynchronous and
    lazy. If the parameter is null no one is told when the
    data is complete and you might end up showing no image
    at all until the next update or repaint.
    That means that it is fine in an animation loop when
    you are drawing images whose data is immediately
    accessible.I had a feeling it would be okay since I had already loaded my images with MediaTracker. Thanks.

  • PCI-5114 clicks when the trigger is changed---is this bad?

    Hi everyone,
    I'm working with a PCI-5114, using several triggers in a LabVIEW program that loops every second.  In the program, I first trigger off of channel 0, then I reset the trigger to collect different information, this time triggering off of the trigger channel, and reading out channel 1.  This works, and I get the data that I want (hooray!), but every time the trigger changes (once per second), I hear a loud click from the PCI-5114.  Is this bad?  Will switching like this eventually harm my digitizer? 
    If it's not bad, I'm happy to endure the clicking.  If it is bad, then I need to figure out a new way to read out my card.  
    Thanks in advance!
    Solved!
    Go to Solution.

    Hello Karl,
    Some scope cards, such as the PCI-5114, have active switches in them.  The noise you are hearing is the switching anytime you change your analog trigger from one channel to another.  These switches will eventually go bad after extended usage, so I highly recommend that you stop switching the analog trigger back and forth each iteration of your loop.  Once the switch goes bad, your card will have to be sent in for repair.  Instead, you may want to look into using one of the PFI lines as a trigger instead.  
    Regards,

  • I forgot my ipad on charge after 100%,is this bad for ipad battery?

    I forgot my ipad on charge after 100%,is this bad for ipad battery?

    Once the battery was fully charged, the smart circuitry stops charging the battery.  Power is then used just for running the device, and the charging circuits will not cut back in until the battery has spontaneously drifted down by 5%-10% of a full charge (which should take days with a normal, healthy battery).
    You cannot over charge any Apple device.

  • Toshiba E55 exausts heat from rear, is this bad?

    The heat heats up the screen allot. Is this bad? Would a laptop cooler help?

    I see it's just odd the exaust lands on the screen. I've bought those little clear rubber riser pads you get at target or wallmart. I hope this allows it to "breath" more and keep the screen bottome center from getting hot. I actually preffer th exause to left not the rear. At least it wont touch anything.
    Also, when I remove the cover to change the ram(add) can you clean the fans out?

  • I can't open my gallery after i migrate the iphoto! How can i fix this bad problem?

    HI,
    I can't open my gallery after i migrate the iphoto! How can i fix this bad problem? Flz help me!!

    Try repair permissions with Disk Utility
    Regards
    TD

  • Where to populate/update Reason code of BSEG in this BADI?

    Hello
    Under 'Dispute Management' our requirement is that when user creates a dispute case document (UDM_DISPUTE), user also inputs the 'Reason code', so this reason code should reflect on its associated accounting doc (BSEG-RSTGR), in this process i found one BADI - FDM_AR_DISP_COMPLETE with COMPLETE_DISPUTE method, this BADI is having code of pure OOPS, i don't know how to update the reason code, which structure i have to use, where should i set or populate the reason code? do i need to set any flags as well? how to declare and there by access the IMPORT structures data?  pls. let me know
    Thank you.

    Hi,
    In the IMG check the documentation for the following node:
    FI->AR & AP->SAP FI SCM->Disput Management Integration-> Customer Enhancemnets->Completion Dispute case.
    Copied the text below:
    Completion of Dispute Case
    Functionality
    You use the method COMPLETE_DISPUTE to include customer-specific BOR objects, attributes, or notes in the dispute case.
    Parameters
    I_ACTION
    The parameter I_ACTION specifies which action is carried out on a dispute case:
    I_ACTION = 1
    The disputed item is included in a new dispute case.
    I_ACTION = 2
    An existing dispute case is changed (by a clearing transaction).
    I_ACTION = 3
    The disputed item is triggered from an existing dispute case and transferred to a new dispute case (splitting a dispute case).
    I_ACTION = 4
    A dispute case is created in Dispute Management. Open items are then selected and added using the relevant functkon keys.
    T_DOCUMENTS
    This table of the line structure FDM_AR_DOCUMENTS contains the keys of the line items that are included in the dispute case or (for clearing transactions) reassigned to the dispute case record. The classification enables you to recognize the target nodes in the record:
    DISP... indicates disputed (open) items
    SOLV... resolved (cleared) items
    The table also specifies the change in value to the item that is carried out in the dispute case.
    T_OBJECTS
    This table of the line structure FDM_AR_OBJECTS contains the BOR keys of the linked objects in the dispute case but without the disputed or resolved line items.
    The business partner that is directly involved in the dispute case is entered under the clasification BUPA, the other objects are informative (INFO...), for example, the underlying FI invoice and SD billing document or the account statement.
    T_ATTRIBUTES
    This table of the line structure FDM_ATTRIBUTE contains the values of the dispute case attributes for the technical names. For a list of the technical names, see the fields of the database tables SCMG_T_CASE_ATTR and UDMCASEATTR00 in the Repository Information System (ABAP Dictionary) of Dispute Management.
    T_NOTES
    This table of the line structure TLINE contains the dispute case notes. Each line of text consists of the usual format column in SAPscript texts and the actual (unformatted) text.
    C_ADDITIONAL_OBJECTS
    The table C_ADDITIONAL_OBJECTS can be filld with the customer- specific additional BOR objects in the BAdI. Make sure that you have set up the derivation of the element type in Customizing for this BOR object type.
    C_ADDITIONAL_ATTRIBUTES
    Table C_ADDITIONAL_ATTRIBUTES can be filled with the customer- specific additional attributes in the BAdI. You can only set standard attributes if they have not already been defined by the system. For customer-specific attributes, you must add these to the attribute profile first.
    C_ADDITIONAL_NOTES
    Table C_ADDITIONAL_NOTES can be filled with customer-specific notes in the BAdI. They are added to the existing notes.
    Notes
    If you want to add BOR objects or attributes when you create a dispute case with user dialog, use the Business Add-In FDM_USER_SCREEN.
    If however, you want to add BOR objects, attributes, or notes derived from the FI data with no dialog when you create a dispute case, use this BAdI.
    When you change a dispute case (by clearing open items, I_ACTION = 2) only additional BOR objects are included in the dispute case. Attributes and notes are only transferred if the parameter E_EXTENDED_CHANGE_MODE has been set.
    When you create a dispute case from Dispute Management (I_ACTION = 4), only additional BOR objects and attributes are included in the dispute case.
    See also
    Kind regards,
    Robert
    PS. I have had no exposure to this BADi before but looking at it I would believe that you need to populate the T_ATTRIBUTES table with your reason code:
    ATTR_ID             'REASON_CODE'  -> type group FDMCO
    ATTR_VALUE    <your reason code value>
    XDELTA             'X'   indicating it is a change.
    PPS.  Re-reading your post maybe alos check the node in the IMG Customer Specific Default Values for Reason (FDM_AR_DEF_REASON) if this one serves your purpose.
    Edited by: RJ. Schamhart on May 31, 2011 4:30 PM

  • Is the X1 hardware really this bad?

    I have been a very long standing Comcast triple bundle customer, one who really doesn't have major issues with the company..until now. I recently signed up for the x1 service as it would save me money and I'd pick up a few channels as well...but so far it has been an unmitigated disaster. I am wondering if all their equipment and service is this bad, or am I the exception... First, I had a lot of trouble installing the cable modem/gateway. It should be plug and play, but it took an hour on the phone with tech support. Next came the x1 dvr install...which didn't happen. The supplied box would not accept input from the remotes I was sent (we tried both the 'master' remote as well as the 'slave' remote. So, back on the phone with support. They decided to overnight me another x1 dvr. Much to my surprise, instead of another x1 dvr, I received an old remote that doesn't even work with x1 box. So now I have to wait another week to get another shipment, hopefully this time the right equipment. So I have invested hours of time, and I still have no x1 tv set up..But at least I have a huge pile of junk comcast xfinity hardware sitting around! 

    All flat screen TV's emit IR interference of some sort. Some are much worse than others. While admittedly I am a huge plasma TV fan, they are known to be more notorious culprits of this issue, especially older plasma TVs. It can be bad enough to interfere with IR remote control performance. I have seen it many times.
    HOWEVER some set top boxes are MUCH more susceptible to this kind of interference. I clearly remember a day not that long ago when you could not have a Pace legacy HD box in the same room with a Panasonic plasma TV. I am sure many Comcast techs would remember this.
    Having to set X1 remotes to RF mode is a well known solution and is discussed in this forum almost daily. Sorry your tech or anybody else didn't make the connection. I guess we were not on site and we simply did not have enough information to help you more. That being said, many of us do not use the Comcast remotes and we need IR to work.
    cohenfive, I am glad you solved your issues. However please know it is not new. Switching X1 remotes to RF is well known. Comcast boxes having issues with IR signals is also well known. I have written about it before. Some of the X1 boxes appear to have overly sensitive IR receiver windows and they are easily "flooded" which makes the box seem to be locked up. Here is just one thread I wrote: http://forums.xfinity.com/t5/X1/A-Fix-for-the-Search-Box-Popping-Up-By-Mistake/m-p/2355227#M36634

  • Urgent--When will trigger this Badi:SD_CIN_LV60AU02 in vf01 Transaction.

    Hi Experts ,
      Please tell me When will trigger this Badi:SD_CIN_LV60AU02 in vf01 Transaction.
    Regards
    Pratap.M

    Hi,
    Create an implementation for the badi and put a break-point inside it. The system will break at that point if the badi triggers.
    Regards,
    Renjith Michael.

  • Please help me Remove this bad file program DefaultTab

    please help me to delete this bad file/program DefaultTab.
    i tried to delete it on program files but it keep saying i dont have permision, 
    I try to search it on regedit but i can find it there,
    im using HP Pavilion p6140d Desktop PC, windos vista 32bit, 
    please help me to fix this problem

    Hi,
    As this is a permissions issue, try the following.
    This is a useful utility that will add 'Take Ownership' to the right click context menu.  The download is on the following link.
    Take Ownership
    This is a zipped file.  If you don't have an extraction utility installed, download and install 7-Zip which can be used to open this so that you can run the installer.
    Once you've installed 7-Zip, just right click the zipped 'Take Ownership' folder, select 7-Zip and select Extract Files and click Ok.  When done, open the newly extracted folder and you will find the utility to add 'Take Ownership' to the right click menu.  Just double click it to install and then close the Window. 
    Now go into your Program files, right click on DefaultTab and select Take Ownership.  Now right click it again and see if you can now delete it.
    Let me know.
    Best regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • K8N neo2 first time ocing this bad boy

    I have had my computer setup for about three months now and I am ready to start ocing it finally after messing around with my watercooling and everything else.
    My stats are in my sig and this is what I have done so far.
    I have my sATA drives in a raid0 array on sata ports 3+4 (locked)
    I have my agp frequency set to 67 to lock it ( I have read this at several other different places)
    I lowered my htt multi to 4x. My vcore is at default 1.5 I am using 1.4 bios
    I upped the fsb in 5mhz increments
    I posted so far at
    205
    210
    215
    220 currently running at 11x multi for 2420 mhz, HTT frequency 880mhz
    I have not messed with anything else so far. I posted and I am running fine right now while I type this with prime95 torture test running.
     I am new to ocing a64's after making the transition from an old 2500+xp chip. I have a lot of data on my raid array that I do not want to lose by corrupting my windows installation. I did this when I was ocing my 2500+ and I lost a ton of data.
    I was thinking of just letting prime95 torture run for 10-12 hours and then raising the fsb another 5mhz.
    I have heard that this board does not like ocz eb but I have never had a single problem with it.
    Where should I go from here to be on the safe side without corrupting my windows install to find my highest overclock?
    I also noticed that when I turn on my computer my cpu temp sticks at 43c and won't move unless I restart the computer and then I get a temp reading of 37c idle and at load I hit about 44c. I have a tdx installed on my cpu and I doubt that the temps are even reading right.  I am using mbm5; does anyone know just how off the temps are for this board?
    Thanks a bunch

    I have had this machine running about one week now... and in my sig is the results...  
    I think this 2600mhz HTx4 is not too bad with these cheap mems... apacer running at 216mhz with 2,5-3-3-6 settings  
    I have stock cooling in cpu, and temps are about 40 on idle and watercooling is still waiting for an isnpiration... and then i am going to try overclock this winchester  

  • What should I do? Has other people's Support been this bad?

    My name is Mile Marjanovich and I am an unhappy Verizon Wireless customer.
    I have been a customer since October 2004 and finally after 7 years I think it's time to call it quits with this company. Their network may have been one of the most reliable in the past compared to the competition but in the end it was the customer service and the literal lies that their employees have told me which made me call it quits.
    And here's how it ended keep in mind none of the details have been exaggerated nor embellished this is the actual situation and times in which this has transpired.
    On September 7th 2011 at 2130 me and the wife bought 2 Motorola Droid Bionics using our last "New Every Two" sale, we purchased 2 Bionics, 1 Lapdock, 1 Car Dock, 1 Bluetooth Earpiece, 1 Car charger, roughly totalling $1200 in purchases, with our rep telling us there would be $100 rebate for the lapdock and that our existing Droid 1 & Droid 2 could be turned in for even more credit to offset the cost. Expecting these phones to live up to the standards of quality that motorola had given us with both the Droid 1 (2 purchased December 2009) and the Droid 2 (1 purchased in June 2010) we were excited. We were not new to the Android family nor to Motorola products before purchasing these so it's not a first time bad experience situation.
    On September 12th 2011 at 1200 the phones arrived, to start with they wouldn't activate, through 2 calls of technical support and excuses along the longs of "its such a popular phone right now our activation servers are busy so just keep trying" we finally got them activated in about an hour and a half later.
    On September 15th (our billing cycle date) we noticed that the $100 credit for the lapdock had still not been applied nor had we received a $100 Verizon gift card yet.
    On September 22nd I called Verizon opting to finally use the 14 day no worries hassle free guarantee and return the phones which in the first 9 days experienced, 3g/4g service interupts, applications uninstalling themselves, missed calls, dropped calls, extraordinarily short bettery lifes (under 4 hours with little to moderate usage). We I talked to Verizon they informed me that it was past the 14 day mark and we could not exchange, as it started from the time we ordered the phones not the time we received the phones. So the 5 days it took to get the phones was part of our "Testing time".
    In late September 2011, I had finally received the boxes and prepaid shipping labels to send the Droid 1 & Droid 2 into Verizon for the credit program and sent them the phones.
    In October 15th, 2011 (Billing cycle date) we had still not received and credit for the lapdock, the droid 1 or the droid 2, and our phones were replaced the first time after my wife's Bionic developped a strange clicking noise in the speakers anytime any audio was played and my Bionic had began to drop calls regularlly.
    In late October 2011, the first Bionic that arrived to replace the wife's was faulty, the Power Switch wouldn't depress and you couldn't turn the phone on.
    A couple days later in October 2011 another bionic arrived and besides the 3g/4g data issues at least turned on.
    Throughout November 2011 our phones were replaced for the following reasons, 1 the external speaker didn't work, 1 the sim card slot didn't work, 1 had a charge that lasted only 22 minutes from full to shutdown, 1 constantly crashed no matter which google app you tried to use, 1 the gps didn't work, 1 the Wifi/Bluetooth/LTE services didn't work, 1 arrived with a metal sliver sticking outta the bezel in the upper left hand corner of the phone which actually cut my finger open when I went to turn the unit on once, 1 only had 3g functuality and the Verizon rep said that the database on their end showed it as a "Unknown Device" and thus he couldn't fix it. During all of these repairs, returns, etc each "Factory Certified Like New Device" showed up with glitches, errors and other non-working features and with an average of 60 minutes a call to tech support each day for Activation issues and troubleshooting, Verizon kept telling me that when Motorola would release "The Patch" it would all fix itself.
    November 15th (Billing Cycle) still no rebate/credit for lapdock, or traded in phones, after a couple calls and them "Researching the problems" they figured out that the $100 lapdock rebate was only from September 8th-October 15th, and although the Verizon website on the 7th of September showed the deal and the Verizon rep that sold me the phones told me about the offer I was not elligible since I ordered the phones 2 1/2 hours early. Through a pile of additional calls they finally said sorry and credited me $100 for the lapdock. So issue #1 of 5 had been solved (3 rebates, 2 broke phone) 20% progress.
    December 15th, 2011 - Received a $70 credit on my account (Droid 1?)
    Continuing into December of 2011, we continued to replace phones and battle customer service, even went to far as to actually post a review of the phone on Verizon's websites with the issues we've had and awarded the phone a single star (The review was deleted) as well as an additional 2 bad reviews (always deleted after being posted to their website) and then one day things changed...
    On December 16th around 1800, I spoke with Mark (Technical Support Supervisor) for Verizon and he made me and my wife and offer, he looked at the notes and the logs and the troubles we had been having with the phones and offered to replace the device with a comparable model. My only request was ANYTHING but another Motorola phone. He offered the HTC Rezound and the Samsung Galaxy Nexus. I told Mark, since I have only ever had Motorola Droid Products I don't know which one of those were better and asked him, what HE would get as he was going to know Verizon's product line better than myself. He said the Nexus, he hadn't received any calls on it, it was a new phone, great reviews, etc. I agreed to the offer, he told me that since it was going to be a warranty replacement the phones would be certified like new and that the most difficult part in getting used phones is usually locating the batteries and the battery backs. After another 10 minutes or so of him looking things up he told me the phones had been ordered and we would be receiving 3 boxes from fedex, 2 boxes would each contain one Nexus and one box would have the batteries and the backs. I asked Mark how to ship the phones and what should I do with the incompatible accessories (1 Bionic Lapdock & 1 Bionic Car Dock) seeing as verizon does not accept accessories for trade in credit. He advised me to sell the parts on Ebay or Craigslist or something to buy the new parts for the Nexus.
    On December 17th (Saturday) I managed to sell the parts for enough to get the Nexus Dock.
    On December 19th (Monday) I received 4 packages from Fedex, 3 Bionics, and one box containing 2 Samsung Galaxy Nexus Batteries, and 2 Samsung Galaxy Nexus Battery Backdoors. I called Verizon to figure out where the Nexus's are and why I had a 3rd bonus bionic here and was informed that Mark never actually ordered it and they were confused as to why he would offer it when there is no used inventory. The double checked the notes on their system and verified he did actually offer it and Alice (an amazing CS rep) said that she would check inventory every tuesday and thursday and send me a text message with the inventory status (and to this day she still does, like she promised).
    On December 20th (Tuesday) Mark called me to appologize and say he cannot order the phone as there is no inventory and sorry for making the offer. He said he was shipping me 2 Motorola Droid Razr's that would be here on Wednesday, and that these were great phones, no issues, never have to be replaced, etc. After I got off the phone with him I immediatly called Customer Service back and tried to figure out how my one request had been ignored again and why they couldn't fufill the offer. Michelle (another very nice rep) said sorry, she doesn't know why he offered and then retracted but told me to "Just give the Motorola Razr's a chance" there great phones and seriously no issues.
    On December 21st (Wednesday) 1400, I received 2 Motorola Droid Razr's, as my wife was working I didn't want to try and activate her's while she was at work and mess with her service I went through the invoices and grabbed the one attached to my line and tried to activate it. The Razr sent to me had a couple issues, #1 It kept getting a "Sim Card Authorization Error, please contact customer service" #2 Wifi wouldn't work #3 LTE service wouldn't work #4 the phone would randomly restart itself every couple of hours, #5 it fluctuated between no service for literally hours at a time to "Unknown Carrier" messages. I made 6 calls over the 24 hours I had the phone and the issues were still not resolved, and remember this was "The phone with no issues, trust us, you'll love it, just give it a chance". My wife's line on the other hand after 30 minutes of customer service and resetting the IMEI in the database and the reinputting the SIM card on verizon's end they finally got her's working and what do ya know it's great... Mine on the other hand was still not functional.
    On December 22nd (Thursday) I contacted the West Region Executive Management team, and technical support explained 3 months of history, issues, number of replacements etc, and my rep said they were sending out a HTC Rezound, finally listening to my "Anything but a Motorola" request and that I would receive it on Friday (Dec 23rd)
    On December 23rd (Friday) I spoke with Liz, West Region Executive Management Team representative, who after looking at my account for last couple months, looked into the HTC Rezound I was going to receive later today and said good news, it looks like it was a unit returned after just one day, so it wasnt a defective unit or anything, should be great... feeling reassured that Verizon had finally sent me a good working unit I waited. At 1800 hours I received my fedex shipment and opened the box to find... a Motorola Razr, I have had the Razr now for 3 hours and 7 minutes... it will not activate, it keeps failing, it has been reset twice, i have swapped SIM cards, still not activating...
    ... at least my wife is working... too bad for me apparently 12 Motorola Droid Bionics, and 3 Motorola Droid Razr's are just the beginning of this game...

    Unfortunately, most of my advice is in the "hindsight is 20-20" category.
    First off, I would never have purchased the peripheral accessories until the 14 day return period had expired. Second, you learned the hard way what the "14 days" really means.
    Too bad you didn't do any homework, reading this and other forums and tech sites. Even word of mouth from others. That, more than anything could have steered you towards different phone choices from the get-go and I will leave that there with no further comment other than to say most of the issues you described have been discussed in this forum, ad nauseam.
    Once you got into the refurbished phone exchanges, that is where things really went haywire. What someone tells you over the phone is a sketchy proposition, and when it comes down to it, it's your word against theirs.
    I think Verizon tried to make it right, though. Remember, they don't make the phones. Don't throw the baby out with the bathwater.
    You stated yourself you were a satisfied Verizon customer before this. Had the first two phones performed as they should, you would still be a satisfied Verizon customer.
    Doubt any of that will make you any happier, but after you went through the effort of writing such a long post, I thought I'd try.

  • Is this bad or w

    CL is turning in to how China rules their people, I was told by daniel to watch my langauge for this.....READ
    FROM: Daniel-CL Add User to Friends List ? Add User to Ignore List
    SENT: 06-2-2006 0:5 AM
    Forum Post
    http://forums.creative.com/creativelabs/board/message?board.id=soundblaster&message.id=65537#M65 537
    I do not want to see this kind of response here again. I understand you are having a disagreement with Creative and the supervisor you worked with, but your point can be made without the attitude and foul language.
    Daniel
    People all I want is money back and at this point do not care about a fix. But I responded to a thread which I did not say anything bad except customer support sucks and Daniel sends me this. Read what I said and you will see that I said nothing wrong, hey does'nt china watch what their people say....they do, but this is america I li've in and free speach is what I was given.
    I want my $200.00 dollars and as the attorney has stated, I can say anything I want as long as I do not make threats or threaten anyone and I have not done either one.

    SkullCracker,
    If you want to post up your experience it's fine just as Daniel told you but leave out vulgarism like those that's being removed by the forum swear filter. This is a public forum and not just a forum solely used by you. Not everyone that read here like to see bad language and some other peers migh feel offended by those words. Also, I believe that's not the only post by you with those swearing. We do understand some people are frustrated with certain things so we tend to give alittle more leeway to these sort of things/post but that doesn't mean going over those leeway. The forum has it's own rules to abide and follow, as simple as that. If you want to post, keep the language clean.
    Jason

  • Is this bad practice?

    Consider the follwing two classes:
    public class Widget
    public class CustomWidget extends Widget
    }Now consider another class that has a Widget class member:
    public class OrdinaryClass
      private Widget w = new Widget();
      public Widget getTheWidget()
        return w;
    }Now suppose I were to subclass OrdinaryClass as follows:
    public class SpecialClass extends OrdinaryClass
      private CustomWidget cw = new CustomWidget();
      public CustomWidget getTheWidget()  // violate LSP?
        return cw;
    }My questions are:
    1) does SpecialClass violate Liskov's Principle in that the getWidget return type has changed?
    2) if it's not in violation, is it bad practice anyway? Or is this some polymorphic trick that is not only acceptable, but very useful (and encouraged)?
    Please advise.

    A custom model was subclassd from AbstractListModel.
    One of the getter methods from ALM has a return of
    f type Object. The custom model used the same
    getter, but returned the toString() of the Object (a
    property) instead of the Object in its entirety.Given this specific class hierarchy, you're into territory for design lawyers. A list mode maintains data that's used by a JList[i/]. The contract, as a result, is fairly open, and you could define the model as maintaining string representations for an object. The purists would respond with "no, the view should decide the representation," and I'd probably agree with them.
    By comparison, the contract for a [i]java.util.List is much more explicit: you put objects into the list, and you get the same objects out. If your colleague was creating a List implementation that returned toString() of an object rather than the object itself, then your argument would have much more force.
    It seems as if changing the return type of a method
    in a subclass seems wrong, even if the new return
    type is a sub of the original return type.
    I have nothing against returning the subclass, mind
    you. Just keep the contract (i.e, the return type)
    the same.However, the "contract" is not defined just by method signature. If that were the case, then this would be a perfectly valid implementation of List.get():
    public Object get(index i)
        return new Integer(i);
    }Instead, the "contract" is defined by the class as a whole, and furthermore is defined by your application for each instance of a class that it creates (eg, "this List is used to pass strings between these two methods").

  • How did Apple screw up the maps app this badly?

    I am normally not a complainer, but rather appreciate great technology.
    However, I am shocked beyond description about how badly Apple screwed up the maps application in IOS 6.
    The maps application is the by far the most frequently used and most useful iphone application for me.
    I rely on it all the time.  It WAS so incredibly easy to use, and almost always dependable.
    Yes, turn-by-turn directions would be nice, but not at the cost of screwing up so many other critical features.
    I have now had 2 extremely frustrating experiences.
    The other night, I was driving home from work and using the maps application to route to a store.  I was using the voice instruction mode.  There was heavy traffic so I wanted to zoom out / around to look for alternate routes.  Well, this is almost impossible to do, and furthermore, there is much less accurate and detailed information about traffic conditions.  This would have been a piece of cake with the old maps application.
    Yesterday, I had to make a trip to Pacific Sales in San Jose.I tried "Pacific" with the mapped zoomed to the general area, and it could not find it.Then I tried "Pacific sales", again no luck.  Its an appliance store, so I tried "appliances", and again no luck.
    Finally, I had to log into the web, go to google maps, and find it there.
    It was slow, but it worked!
    1 month ago, I had the highest confidence in Apple due to their track record of deliverying great stuff that works and is easy to use.
    I would never have considered an android phone.
    However, this problem with the maps app has so shaken my confidence in Apple, that I will go today to look at a Samsung Galaxy III.
    Maybe its not going to be my thing, but I hope Apple realizes how big they screwed up.
    The Apple of Steve Jobs would never, ever, ever have let this happen.
    The old Apple would have stayed with Google Maps for another year, and made this new maps app better, more reliable, and more user friendly than Android BEFORE releasing it.  It would have been revolutionarily good and would have surprised us with how good it was.
    I really truly love Apple and its products.
    But this is a really bad mistake and I am so fearful that its an omen of whats to come in future from Apple.
    I would not be surprised if this very deeply damages Apple at a time when the competition is getting tougher & tougher.
    Of all the functions on the Apple Iphone, the maps are the heart and soul.  Apple is probably right to go its own way eventually, but not like this!
    It is just going to drive people into the arms of Android.
    I am just curious, did Apple actually test this thing thoroughly before releasing it?
    I mean, it took me only a few days to figure out this thing is total crap.
    How did Apple not know this (which is a very scary thought), or maybe even more scary, maybe they did know but feel they have enough market power to get away with it?  I can't think of any other explanations. So, which is it?  Either way, its very bad news for Apple fans.

    Ok, 3 more wonderful IOS 6 maps experiences to share!
    When out shopping for paints, decided to visit Kelly Moore.
    Used the maps app and used it to take me to the nearest store, except it was not where maps said it would be!
    I called the Kelly Moore store, and they told me the maps app has the wrong town, and they have had many customers with the same problem!
    Next up, I was looking for a Sherwin Williams store in San Jose, so maps took me to El Camino Real, except it took me to the wrong end of El Camino Real in Santa Clara, about 15 minutes from the right destination in Mountain View!  In fact, the app took me to Santa Clara University!
    Last up, I was looking for a Chevron station.  Apps routed me to the location, but no gas station. 
    So, I finally decide to use google maps through the browser, and it ends up it was again the right address but wrong city!!!! 
    Unbelievable!  My confidence in Apple has been further shaken, to where I am about to give up.
    I just can't trust their app, which is something I depend on every day to save me time, money and gas.
    So disappointed in Apple right now...  It makes antenna gate look like a minor incident, which it was in my opinion!

  • Is this bad usage of the applet sound player

    I have this class for playing audio for my application.
    currently it is a game the is presented in a JFrame but when trying to play audio i kept coming across the use of java.applet.AudioClip for playing audio.
    what i want to know is what i am doing really bad use of this class?
    and if so where should i look to find tips on how to make a better audio class for my game?
    import java.applet.AudioClip;
    import java.applet.Applet;
    public class SoundPlayer {
         public static final int WALL_HIT_SOUND = 1,  BRICK_HIT_SOUND = 2,  POWER_UP_SOUND = 3;
         private static boolean setUp = false;
         private static AudioClip wallHit = null,  brickHit = null,  powerUp = null;
         public void play(int clipID) {
              if (!setUp) {
                   setUp();
              AudioClip clip;
              switch (clipID) {
                   default:
                   case WALL_HIT_SOUND:
                        clip = wallHit;
                        break;
                   case BRICK_HIT_SOUND:
                        clip = brickHit;
                        break;
                   case POWER_UP_SOUND:
                        clip = powerUp;
                        break;
              if (clip != null) {
                   clip.play();
         public void setUp() {
              wallHit = loadClip("wallHit");
              brickHit = loadClip("brickHit");
              powerUp = loadClip("powerUp");
              setUp = true;
         public AudioClip loadClip(String name) {
              try {
                   return Applet.newAudioClip(getClass().getResource("/sound/files/" + name + ".wav"));
              } catch (Exception e) {
                   System.err.println("Cannot open Audio File: " + name + ".wav will not play this sound");
                   return null;
    }Thanks Scott.

    To respond to your first question (Is it bad to use)
    java.applet.AudioClip isn't part of the JavaSound API, so this isn't really the correct forum to ask this question.
    You should go check out a generic applet forum for the question...
    To respond to your second question (What should I use if it's bad)
    javax.sound.sampled.Clip is probably what you should be using for an application to play short sounds.
    /*  To load a clip */
    AudioInputStream ais = AudioSystem.getAudioInputStream(new File("bang.wav"));
    Clip c = AudioSystem.getClip();
    c.open(ais);
    /* To play a clip */
    c.start();
    /* To stop */
    c.stop();
    /* To stop & reset to beginning */
    c.stop();
    c.setFramePosition(0);

Maybe you are looking for

  • Lose Internet connection when I change the SSID

    Hi everyone! well, i bought a WRT160N router, and i have a problem that is annoying me. I connected the Router to the modem, and all the wired connected PCs were working perfectly. But then, i went to the setup page to configure the Wireless settings

  • Desktop Manager 6.10 (b034) & 7.0 won't open after install!!!

    Hey, I run a windows 7 box that has run Desktop Software now without issues for about 3 years. All of a sudden, whenever I go to load it, the system tells me "it's encountered an error, closing program now" so I can't ever use the dam thing. I've re-

  • Is there "Shuffle mode" in L8 like in PT ?

    HI, I am the new in L8, work with PT HD everyday, I wonder if there is something like +Shuffle mode+ of PT in L8 and where can I find it. Thanks for your help.

  • JD Edwards E-delivery download errors

    I have been looking at JD EdwardsOne windows 32bit downloads for learning and training issues. Specifically Supply chain and Inventory. I do not know which media pack to download. I have tried to download smaller packages but I get an error or a requ

  • I broke my iTouch and want music from it. possible?

    It fell and broke the screen. It worked for a few days, then shut off. It doesn't register on my laptop. I was wondering if there's any way to get music off of it? Maybe take it apart? Or is it hopeless?