Long confusing lines of code.

Whats the longest most confusing line of code you can think of...
Very small Example:
instead of
int a = 7;
double b = 14.0;
int c = a - (int)b;
int x = 1 + c;
int y = 2;
Point p = new Point(x,y);
jScrollPane.getViewport().setViewPosition( p );it would be
jScrollPane.getViewport().setViewPosition( new Point( 1 + 7 - (int)14, 2 ) );Well..you get the gist.

ivGrossProfitPercentage = caseRetail.subtract(cost).multiply(new BigDecimal(100)).divide(caseRetail, GROSS_PROFIT_PERCENTAGE_DECIMALS, BigDecimal.ROUND_HALF_UP);This is only long and confusing because it's written in Java.
If it were written in a language with proper decimal arithmetic, it would look like this:ivGrossProfitPercentage = (caseRetail - cost) * 100 / caseRetail;

Similar Messages

  • How to break down long lines of code

    Is there a way to break a long line of code so that it will fit on an A4 sheet?

    You can break on most dots between variable name and method name, between spaces in operators, after a comma that separates parameter names, etc. Just about the only thing you can't break is a long literal String--though you could type it on multiple lines by breaking it into pieces and putting a + in between the pieces.

  • How can long lines of code be cut / separated into multiple short

    In Java, How can long lines of code be cut / separated into multiple short lines?
    Example
    System.out.printf( "%d\t%d\t%s\t%s\t%s\t%s\t\t%s\n", arrayIndex ,  part[ arrayIndex ], name[arrayIndex], units[arrayIndex], price[arrayIndex], units[arrayIndex] * price[arrayIndex], total[ arrayIndex ]   );Thanks

    System.out.printf( "%d\t%d\t%s\t%s\t%s\t%s\t\t%s\n",
    arrayIndex , 
    part[ arrayIndex ],
    name[arrayIndex],
    units[arrayIndex],
    price[arrayIndex],
    units[arrayIndex] * price[arrayIndex],
    total[ arrayIndex ]   );P.S. It looks to me like you have an array for each attribute of something. This is not OO and you should consider creating a class holding the information about each 'Part' or whatever it is. You will then just need a collection of Parts.

  • Is it too much lines of code inside a class file?

    Hi,
    I was wondering about how many lines can be considered too much in a java class file. I saw some class files with more the two thousand lines of code and even more than three thousand lines. When we have so many lines in the code I've realized that the file becomes slow for edition and it's not readable as it should be. So, as a best practice, or even due to technical issues, in average how many lines of code we'd write in order to keep the readability and avoid compile and build issues? How many lines a class should have without putting our code and performance at risk ?
    thanks a lot

    My general rule of thumb--in a class everything shold be very consistent, that is to say: you should be focusing on 1 idea in your class. IMO: If you have a class for users, you need to consistent in just what that class does. When the class becomes large, then look for related themes that run through methods of that class, and if here are many, you should make a "related class" that does satelite functions of the "core" offered in the main user class.
    Thousands of lines do not a good class make, I break in to related categories of classes long before then, and as a rule I keep under 500 lines in a class--usually under 300. In any case, no more lines of code need go into a class than that to implement the core features in the main idea for that class--and no less lines of code than is needed too, don't religate a method to another class just becasue you feel it would make the class it belongs too big.
    Along the idea of the user class:
    Storage for the user data
    Home information
    Work information
    physical information
    tastes and preferences
    family
    and etc
    all of these could be a class in and of themselves, but definetely are closely related to the user class.

  • To print  a long vertical line

    My requirement is to simply print a long vertical line in the output.
    If you do this fav you will be rewarded with more points.
    regards
    Posh

    Hello,
    try this code
    DATA: itab LIKE mara OCCURS 0 WITH HEADER LINE.
    SELECT * FROM mara UP TO 50 ROWS INTO CORRESPONDING FIELDS OF TABLE itab.
    SKIP 2.
    ULINE AT /1(54).
    WRITE:/
    sy-vline,
    AT (19)  'MATNR' COLOR COL_HEADING INTENSIFIED NO-GAP,
    sy-vline,
    AT 23(13)  'ERNAM' COLOR COL_HEADING INTENSIFIED NO-GAP,
    sy-vline,
    AT 38(17)  'PSTAT' COLOR COL_HEADING INTENSIFIED NO-GAP,
    54 sy-vline.
    ULINE AT /1(54).
    LOOP AT itab.
      WRITE:/
      sy-vline,itab-matnr,
      sy-vline,
      23 itab-ernam,
      sy-vline,
      38 itab-pstat,
      sy-vline.
    ENDLOOP.
    ULINE AT /1(54).

  • "A long distance company access code is required"

    I just spent half an hour on the phone (the landline) to fix an issue with the DSL setup, and during that time the call was a bit fuzzy. The customer support agent tested the line after we hung up and called back to let me know she didn't find any problems, so I tried putting a different filter on the line in case that was a problem. I called my wife's cell phone so that we could check clarity and then got this message: "a long distance company access code is required". Ok, weird. I called my own cell phone, which has the same area code as the landline, and got the same message. I thought I had nationwide calling? What's the deal? I tried calling customer support again, but the automated support said I would need to have someone come out and check the line at the risk of having to pay charges if the problem was on our side- since I'm not sure the computer knew what my problem actually was, I didn't want to risk it. 
    We just activated everything today. Anyone have a clue what'd going on?

    A little-known secret is that the Verizon Access Code (dialed before the number) is 1016963 .
    Out-of-state (but expensive), try the AT&T Access Code -- 1010288  .
    For DSL-service without a dial-tone, ask for "Dry-loop Service".
    With DSL, try paying Verizon $7.99 per month for "Inside Wire Maintenance" -- otherwise, when there is a problem with the flaky DSL and a service-call is necessary, they may claim that the problem is in your inside wiring, and charge you $100 for each Service Call !
    DSL degrades the further your location is from the "hub-facility".
    The maximum distance from the DSL "hub-facility" is about 18,000-feet (as the wire-travels) -- anything beyond that, and you may experience frequent drop-outs !

  • 3000+ lines of code Computer Useless while text editting HELP!

    Ive posted here a little bit ago and hadnt found any help but
    now its at a point were I cant type anymore. I have reached the max
    allowable text in one single .mxml file. No where does it say there
    is a max but when I try to type one line of code now it maxes out
    my 2.4 Ghz proc and 1.5 gigs of ram and stops 'buffering' my text
    input so it doesnt catch up with me anymore, it just scraps it so
    it really takes me longer. I am WAY beyond dissatisfied since I
    spent 700 bux on this p.o.s. and now its 1/3 the price!! =o The
    problem is that I have an entire app in this and to change now is
    not an option, so im stuck, I need to know how to disable all the
    functionality in the editor!
    Ive also tried Flex 3 but it has the same problems. Can
    someone PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE!!!! HELP!!!!!
    PLEAS#E!

    First thing I'd probably start off with is separating it out
    into separate files. And the easiest way you could do this is by
    taking everything you have inside of your script blocks and putting
    those into .as files. Then once you have your all of your
    actionscript within .as file(s). Inside of your mxml do.
    <!-- Include External AS File -->
    <mx:Script source="externalAsFile.as" />
    This should at least get ya onto the right start to getting
    things out of the one file but not breaking your
    application.

  • After recently installing itunes on my new PC running windows 8, the CD/DVD drives no longer works, gives a code 19 message. Seems itunes is impacting the registry of the DVD drive. What is best solution to keep running itunes

    After recently installing itunes on my new PC running windows 8, the CD/DVD drives no longer works, gives a code 19 message. Seems itunes is impacting the registry of the DVD drive. What is best solution to keep running itunes normally in the future & get the CD/DVD drive working again? if I delete the upper / lower registry keys what other functions are impacted? I see others say itunes asks for a reinstall...then same problem all over again! THX

    Have you revieved this support document?
    TS2308: iTunes for Windows: Optical drive is no longer recognized, or "Disc burner or software not found" alert after install.
    tt2

  • Saving Outlook eMail to a hard drive folder with long subject lines

    I'm using Outlook 2010 on a WIN7 machine. I drag and drop eMails to folders on my desktop quite often and in the past (earlier version
    of Outlook) I would receive a warning that the file did not copy if the subject line was too long. When I drag and drop eMails with long subject lines now there is no visual warning or indication that the operation failed. I am aware of the file name/path
    character count limitation. My issue is the lack of a warning when the operation fails requiring me to have to check the length of the subject line before the operation or double check if the file is present after the operation. Checking after the operation
    is quite exacerbating when you are copying 15 - 20 files at a time. Is there a patch or something that can be done about this?

    Hi,
    We can also consider to get support about macro from MSDN forum:
    http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • HT1208 After updating my iphone 5C, the screen was black but had the itune logo in the center, a white arrow pointing to the logo, and what seemed like a white lock, but it had a long white line leading to the bottom of phone.  Phone is now frozen.  What

    After adding the latest update to my 5c iphone, the screen was black, with the itune logo in the center, a white arrow below it point to the logo, and below that, what seemed to be a white lock, but it had a long white line reaching the bottom of the screen.  I can't get the phone to start.  The white apple appears and then I get the same logo, arrow, etc.  What can I do to fix this?  Thanks for any assistance.

    i m also put passcode in my iphone...but i dont know that how i know that my passcode is crack by someone???and same as police is not interested to find out it..
    i want ma iphone backkk...........

  • Activating Subscript For Inspection characteristic Long Text in T-code QE11

    Hello All
    I have maintained the inspection characteristic long text in QP01 as " H2O" where 2 is in Subscript.
    No when I see the inspection characteristic long text in T-Code (QE11, QE12 & QE13) it appear as (H2O) & here "2" is not shown in the subscript.
    So please tell how can we activate subscript for T-Codes (QE11,QE12 & QE13) so that it is displayed correctly.
    Regards
    Rahul Bhardwaj

    Hello All
    can anyone please help me out on this.  I am there must be a solution for the same.

  • Typelag happens in big projects. AKA 38,325 lines of code.

    My machine runs very fast in all other applications, it is a gaming computer that runs Starcraft 2 smoothly on the highest settings.
    I'm writing a very big application in Flash.  It is well on its way to being a MMORPG.  I have hundreds of classes, but my biggest class has really off the charts type lag.  My biggest class is 38,325 lines of code.
    Now every time I type, it tries to highlight words in grey for some reason.  I think every letter I type, it searches the entire 38,325 lines of code for that word in order to highlight all cases of it.
    take a look at this picture and how "hud" is highlighted
    LINK: http://www.goodnewsjim.com/images/slowdown_FB4.png
    As I move the cursor around and edit, I often times get 1-5 seconds of slowdown, sometimes I even get 20 seconds of type lag where the Flash Builder temporarily says "Not Responding in the window bar".  This happens all of the results of me typing letters, moving arrow keys or pressing delete or backspace.
    For small edits, I can wait 20 seconds to edit one word, but when I work a lot on my code, I have to open an external editor like Scite, but the alt-tabbing consumes time, and there is a mouseclick to reload the .as file.  I would like to use Flash Builder 4 for editing my code, after all that is what an IDE should be able to do if anything.  An IDE should at the very least be no worse than a generic text editor.
    Please tell me how I can disable Flash Builder 4 from trying to highlight words in grey. I think this is what is causing my typelag.  I've turned off code hints.

    Anirudh,
    Thank you again for your quick response.
    1) I already disabled Code assist completely in Window -> Preferences -> Flash Builder -> Editors.
    2) Ok, I did toggle mark occurances off.
    The problem still persists.  I still have type lag. 
    ,Jim

  • Total number of lines of code in a  project

    Hi All,
    We had developed a project in oracle adf using jdeveloper Version 11.1.1.4.0.Is there any way to find how many lines of code we had wriiten in the entire project.
    Regards,
    Smaran

    Hi,
    NOS stands from Number Of Statements and is a bit different than nloc (line of codes) that is count the statements rather than lines, thus independent from coding styles. As for V(G), it's the cyclomatic complexity, also known as McCabe.
    Regards,
    ~ Simon

  • Total number of lines of code in a class.

    Dear Experts,
    Given a class, I want to find out the total number of lines of code in all of its methods.  Following sub-parts are derived.
    1.  Find out all the methods of the class
    2.  Find out the number of lines for each of these methods and finally add the total number.
    Can you kindly let me know how I can do this?  Thanks a lot !
    Best Regards, Vikram

    Be aware that a 2D array is an array of arrays, which don't necessarily have to be the same length. e.g.int[][] a = new int[2][];
    a[0] = new int[10];
    a[1] = new int[20];
    /* a.length == 2
       a[0].length == 10
       a[1].length == 20*/

  • White lines of code on black background upon starting up

    I recently sent my Macbook in due to problems with the screen going dark for no reason. Upon recieving the laptop back, I noticed problems upon starting. When I restart my laptop, there are white lines of code on a black background. I called in to support, but my support expired and here I am searching for help. They told me that I needed to try and reset my drivers, or my HDD is bad. To reset my drivers they gave me a combination of keys to press upon restarting, but I don't remember the combination of keys. I have repaired my disk using the install CD, but still am having problems.
    It's crazy that I send my laptop in and get it back with other problems... Any help is appreciated becuase Apple surely isn't helping.
    Macbook   Mac OS X (10.4.8)   Core Duo w/ Bootcamp

    Turn the computer off. Wait one minute. Restart. If you are still booting into single-user mode (black screen with white print) then at the prompt enter:
    reboot
    Then press return. If this does not start you up into OS X then there's a system problem. You will need to reinstall OS X. You can do this using the Archive and Install option that does not require you to erase the hard drive. Your old system will be archived in a Previous System Folder at the root of the hard drive.
    Before performing the Archive and Install you should do the following:
    Repairing the Hard Drive and Permissions
    Boot from your OS X Installer disc. After the installer loads select your language and click on the Continue button. Then select Disk Utility from the Installer menu (Utilities menu for Tiger.) After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list. In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive. If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported then quit DU and return to the installer. Now proceed with the OS X installation.
    If DU reports errors it cannot fix, then you will need Disk Warrior (4.0 for Tiger) and/or TechTool Pro (4.5.2 for Tiger) to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    Why reward points?(Quoted from Discussions Terms of Use.)
    The reward system helps to increase community participation. When a community member gives you (or another member) a reward for providing helpful advice or a solution to their question, your accumulated points will increase your status level within the community.
    Members may reward you with 5 points if they deem that your reply is helpful and 10 points if you post a solution to their issue. Likewise, when you mark a reply as Helpful or Solved in your own created topic, you will be awarding the respondent with the same point values.

Maybe you are looking for