Which is worse: awkwardly long or vague/arbitrary variable names?

I'm programming in C++, but that shouldn't matter.
I'm working on a small chunk of code that is a module for a much, much larger project. Part of my code is to make several hundred histograms and then run some statistics over them.
My dilemma is that there are so many, that naming them is becoming difficult. So, I opt for incredibly long, cumbersome names rather than short arbitrary names. Heck, even I wouldn't know what was going on if I just named them "histo1, histo2." Instead I name them things like "MomentumTimesDeltaPhiEta1" which MIGHT make sense to someone who is working on another part of the project.
And actually, that wasn't a real example. Some of my names are longer than that. Is that normal? I have programmed in C++ for a year, but I'm still not good at programming etiquette, so my code looks clumsy.

Local vars can be short, if you find the need to give further explanation, comment. Try to give meaningful names more for class atributes, interfaces, and where a variable name can help documenting the code itself. E.g. (Pseudo-code, as I don't remeber a lot of C++):
Instead of:
z = sqr(a^2 + b^2)
This is better:
// Pythagorean theorem
z = sqr(a^2 + b^2)
This is even better:
hypotenuse = sqr(catheti_a^2 + catheti_b^2)
If you find yourself using incredible long variable names, it's a signal that your program is too flat, and you need to start refactoring it into a function, class, or using a namespace.
So, e.g:
namespace Geometry {
function Hypotenuse(float a, b) {
return sqr(a^2 + b^2)
The code expresses a lot more meaning, while staying concise.
Edit: I forgot square root
Last edited by freakcode (2008-08-06 19:49:58)

Similar Messages

  • Crystal Reports - Problem with too long BEx Query technical variable names?

    Hello!
    I have Crystal Reports 2008 SP3 and the SAP BO Integration Kit XI 3.1 SP3 installed and want to access a BEx query on a BW system within my Crystal Report.
    The problem is that the name of the BEx variable is not displayed correctly (just "[]" is displayed for the variable name) as a parameter within Crystal Reports when I import the query. Furthermore I can't navigate through the fields of the query within Crystal Reports.
    The technical names of the BEx query-variables have a length of 12 characters.
    The interessting thing is that if I change the technical names of the BEx query variables to a maximum length of 8 characters everything works fine.
    I use the SAP toolbar within Crystal Reports 2008 to create the report and have the "MDX-driver"-setting selected.
    Has anyone ever had the same problem? Any suggestions?
    I don't want to change the technical names of the variables of my queries...
    thanks,
    Dominik

    Hi!
    Just fixed the problem: The "Transports" for the Integration Kit had to be imported at the BW-System
    regards

  • I recently uploaded 10.8, but I have a number of VALUABLE old files which I can no longer read because "power PC applications are no longer supported.  How can I retrieve them?

    I recently uploaded 10.8, but I have a number of VALUABLE old files which I can no longer read because "power PC applications are no longer supported.  How can I retrieve them"?

    Here is a post I assembled for another with a similar problem:
    Unfortunately you got caught up in the minor miracle of Rosetta.  Originally licensed by Apple when it migrated from the PowerPC CPU platform that it had used from the mid-1990's until the Intel CPU platform in 2006, Rosetta allowed Mac users to continue to use their library of PPC software transparently in emulation.
    However, Apple's license to continue to use this technology expired with new releases of OS X commencing with Lion (and now Mountain Lion).  While educational efforts have been made over the last 6 years, the fact is that Rosetta was SO successful that many users were caught unaware UNTIL they upgraded to Lion or Mountain Lion.
    Workarounds:
    1. If your Mac will support it, restore OS X Snow Leopard;
    2.  If your Mac will support it, partition your hard drive or add an external hard drive and install Snow Leopard into it and use the "dual-boot" method to choose between your PPC software or Lion/Mt. Lion;
    3. Upgrade to an Intel compatible versions of your software, or find alternatives that will open your data files;
    3.  Install Snow Leopard (with Rosetta) into Parallels:
                                  [click on image to enlarge]
    Full Snow Leopard installation instructions here:
    http://forums.macrumors.com/showthread.php?t=1365439
    NOTE: STEP ONE of the instructions must currently be completed on a Snow Leopard or Lion Mac and the resulting modified Snow Leopard.cdr install file can then be moved over to your Mountain Lion Mac for completion of the remaining steps.
    NOTE 2:  Computer games with complex, 3D or fast motion graphics make not work well or at all in virtualization.

  • How can I cannot access icloud as I have an old email address which i can no longer access and have forgotten password

    How can i access icloud on my phone as the account is an old one which I can no longer access and I have forgotten the password?

    If your Apple ID is the one that you use for making all of your purchases, it should, automatically appear in FaceTime already. How a no longer valid email address got there to begin with is a mystery to me, if in fact you do have, and have been using another Apple ID.
    Go to Settings>FaceTime>Apple ID. Tap the old email address and sign out, sign in with your Apple ID. It should be verified and allow you to select it as the address that you can be reached by for FaceTime.
    If that does not work, time FaceTime off, restart your iPad and then start all over again.

  • I can no longer access my cloud as it is under the original ID which I can no longer access.  How can I change this?

    I can no longer access my cloud as it is under the original ID (email address/password) which I can no longer access.  How can I change this?

    I'm following. I'm having the same problem.

  • How do I transfer a project from someone else's FCPX, version 10.0.9, which I can no longer open, to my FCPX, version 10.1.4?

    How do I transfer a project from someone else's FCPX, version 10.0.9, which I can no longer open, to my FCPX, version 10.1.4?

    You need all the project and event folders associated with the production. They need to be in explicit locations or they will not be seen my the application.
    Start reading here
    http://www.fcpxbook.com/updates/101/
    You use the Upgrade Project and Events function in the File menu when you have the correct folders in the correct location to update the volume you want.

  • I used to be able to see a preview of my scan which i can no longer see only the adobe acrobat symbol I am using Adobe pro 9 can this be changed??

    I used to be able to see a preview of my scan which i can no longer see only the adobe acrobat symbol I am using Adobe pro 9 can this be changed??

    Yes, that appears how Mavericks works right now. However, you can open the Address Panel, select all your contacts, then click the To (or CC, or Bcc) buttons to move the selection to the address field.
    If it is not already in the Toolbar, right-click on the Toolbar and select Customize Toolbar…
    Then, drag the address panel up to wherever you want it.
    You may also want to add it to the New Message window in the same way.

  • HT4644 I'm experiencing a similar problem with an LG Flatron monitor which my MBP no longer recognizes  I've tried installing the updates listed above but have not been succesful. Everytime I get a message saying that this software is not supported on my

    I'm experiencing a similar problem with an LG Flatron monitor which my MBP no longer recognizes.  I've tried installing all the updates listed above but have not been succesful. Everytime I get a message saying that this software is not supported on my system. Can anyone tell me why I can't install the updates?

    Hello Philly,
    I believe that when you reset your ipod(command given from the computer, right?)  touch WHILE the ipod was updating, It cleared the system in the middle of writing files, thus corrupting(equivalent of cutting of in the middle of a sentence) the basic running system.
    I suggest you go to an apple store and ask for a technical diagonosis in person. they may offer to help if the problem is fixable. If your ipod is still under warrenty, i would guess it would be free/low cost.
    ~Remember, I am just giving an educated guess on limited information

  • I am going to start work on computer A.  I have InDesign on Computer B, which I will no longer be us

    I am going to start work on computer A.  I have InDesign on Computer B, which I will no longer be using.  How can I move the CS4 program to my new computer?  I'm hoping this is a simple process and doesn't reqiure me buying a new program or subscribing to the cloud.

    (1)     Explicitly deactivate the software from computer B. This deactivation can be found on the pull-down under Help.
    (2)     Install the software on computer A from your original media. You cannot simply move the software. It must be totally installed. Note that if you have an OS version that is not supported by CS4, then all bets are off!
    (3)     The software will activate on computer A when you install and run it.
              - Dov

  • How can I open and edit files that were developed and published by ftp to my host on my old macbook, which I can no longer access.

    How can I open and edit files that were developed and published via ftp to my host on my old macbook, which I can no longer access. The HD containing the files cannot be accessed. I want to be able to download the published files to be edited in iweb?

    You CAN'T download published files and then edit them in iWeb because iWeb can't open them - it has no import facility so is unable to open any html or css files - a previously published site.
    You can download these files yes, but you'll need to use them as a guide or to cut and paste text from there whilst you re-build your site in iWeb.
    The only other way is to download the files and then open them with an html editor such as TextWrangler or use one of the other web design programmes out there that is capable of importing html and css such as Dreamweaver of Flux 4.
    These are your only alternatives as iWeb can't import and if you want to continue to use iWeb, then you'll have to re-build your site from scratch.  If you do just remember to back up your domain.sites file this time around - it is found under your User/Library/Applicaion Support/iWeb/domain.sites.

  • Copy functionality which did not copy Long Text values causing us an issue

    Two new Master Recipes created in Bathurst by using copy functionality in transaction C201 contained SRC value errors believed to be caused by changes in the copy
    functionality which did not copy Long Text values causing us an issue when creating Process Orders.   Current workaround is to manually edit the
    value fields and re-save the MRs, the issue is then resolved.

    This will resolve the issue
    SAP Note 1452700 - "New" button is disabled after
    displaying text
    Note Language: English Version: 1 Validity: Valid Since 03/25/2010
    Summary
    Symptom
    In display mode you navigate via the text hyperlink to the text view.
    When you navigate back, the "New" button on the "Notes" assignment block is
    disabled.

  • File name in msdb.dbo.backupset no longer matches the actual file name on the storage media. Error 3013 Restore Database is terminating abnormally.

    Thanks in advance for taking the time to read this and comment. Platform: Windows Server 2008 R2 Enterprise Edition SP1 (X64) Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64) Jun 17 2011 00:54:03 Copyright (c) Microsoft Corporation
     Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)Problem Description: The file name recorded in the msdb.dbo.backupset (sans the extension) no longer matches the actual file name written to the backup media which is
    in this case a NETAPP NAS storage share. Example:
    Mohave_backup_2014_03_14_233001_1158878.bak      (from NETAPP NAS filer)
    Mohave_backup_2014_03_16_233001_4167237             (from MSDB.dbo.backupset), as you can see, the last 7 digits (chars) of the file name are different, although the date and time are identical. The
    file names had previously been matching perfectly. The first occurance of this problem occured on 03/13/2014 at 5:00 AM MST. The error generated by the job was:
    Date  3/14/2014 10:29:23 AM
    Log  Job History (Refresh - Restore Mohave_93_DEV AD HOC)
    Step ID  1
    Server  OurDevServer
    Job Name  Refresh - Restore Mohave_93_DEV AD HOC
    Step Name  Restore Mohave_93_DEV
    Duration  00:00:01
    Sql Severity  0
    Sql Message ID  50000
    Operator Emailed  
    Operator Net sent  
    Operator Paged  
    Retries Attempted  0
    Message
    Executed as user: OurDomain\OurNetworkServiceLogin. Restore Mohave Prod to Mohave_93_DEV - ERROR: 3013 RESTORE DATABASE is terminating abnormally. [SQLSTATE 01000] (Message 50000).  The step succeeded.

    Olaf:
    Thanks for your reply. Sorry, my bad. I inadvertently copied wrong [name] form the msdb.dbo.backupset. On 3/13 and 3/14, the two file names did not match. In trying to select another example to show you this morning, I found that the names are now matching!
    What I was doing was to create dynamic t-sql to retrieve the latest prod backup of the database, and then restore it with move to the development server. This is an ad-hoc job that the developers can run by themselves whenever they require a refresh. Unfortunately,
    we only keep 3 days worth of backups for these databases, so the original disk file I was trying to use to restore no longer exists. Researching the original error, one of the error descriptions was that the restore could not find the file requested.
    I thought this very strange since I get the file name directly from the backupset table. Further research did indeed show that the file names were different, but unfortunately, I failed to save the details of the file names. Anyway, in looking for a new example
    to show you this morning, I have found that the file names are indeed matching exactly again. If this error pops up again, I will be sure to save all details and re-post.
    Thanks, regards and best wishes to you and yours, 

  • Select LONG column into CLOB variable

    Hi all,
    I am trying retrieve the data present in a LONG column into a CLOB variable.
    However I am getting an error, pls let me know how I can resolve it.
    DECLARE
    v_text CLOB;
    BEGIN
    SELECT TO_LOB(trigger_body)
    INTO v_text
    FROM
    user_triggers
    WHERE
    ROWNUM <= 1;
    END;
    ERROR at line 8:
    ORA-06550: line 8, column 20:
    PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got LONG
    ORA-06550: line 8, column 5:
    PL/SQL: SQL Statement ignored
    Let me know if there is an alternate to this. I would like to get the data present in the LONG column into a variable.
    The reason why I am not retrieving the LONG column into LONG variable is stated below (from Oracle Website):
    You can insert any LONG value into a LONG database column because the maximum width of a LONG column is 2**31 bytes.
    However, you cannot retrieve a value longer than 32760 bytes from a LONG column into a LONG variable.
    Thanks and Regards,
    Somu

    There are couple of things I did (listed in order):
    1) Create Global Temporary Table containing a CLOB column
    2) Select LONG column and convert to CLOB by using TO_LOB and insert into Global Temporary Table containing a CLOB column
    2) Select from this Global Temporary Table (which already contains data in CLOB) and assign it to a CLOB variable.
    This is done because you can not directly use TO_LOB in a select statement to assign the value to a CLOB variable.
    Stated below is an example:
    -- Create Temporary Table
    CREATE GLOBAL TEMPORARY TABLE glb_tmp_table_lob(
    time TIMESTAMP WITH LOCAL TIME ZONE,
    text CLOB
    ON COMMIT DELETE ROWS;
    -- PL/SQL Block to Execute
    DECLARE
    v_clob CLOB;
    BEGIN
    -- Insert into Temporary Table by converting LONG into CLOB
    INSERT INTO glb_tmp_table_lob (
    time ,
    text
    SELECT
    sysdate ,
    TO_LOB(dv.text)
    FROM
    dba_views dv
    WHERE
    ROWNUM <= 1
    -- Select from the Temporary table into the variable
    SELECT
    gt.text
    INTO
    v_clob
    FROM
    glb_tmp_table_lob gt;
    COMMIT;
    -- Now you can use the CLOB variable as per your needs.
    END;
    /

  • Dynamic Variable name (for int/long) from a String variable

    Hi,
    I want to give a int/long variable name from a String.
    for ex.
    String str = lookup + "Id";
    lookup is a String variable coming from XML. Now, for instance lookup="name". So str = "nameId".
    Now I want to create a int/long variable by nameId.
    Could anybody tell me the way how to do. Please don't tell to use MAP.
    Edited by: Shah on Dec 5, 2007 3:26 PM

    Well you can't. Use a Map.
    The compiler translates variable names into slot numbers, either within an object or withing the local "stack frame" and these slot numbers are assigned names at compile time. No new slots can be created at run time. Java is not Basic.
    Reflection allows you to find existing field names and methods (not local variables), so it's possible to map, for example, XML attribute names to field names or setters in an object but the names have to be known at compile time.

  • How do I remove the (-signed) which Adobe adds to the end of the document name after having signed it?

    Hi there,
    How do I remove the (-signed) which Adobe adds to the end of the document name after having signed it?
    It is not convenient to remove it every time I sign a document. So, is there a way to turn this off?
    Thank you

    I think you cannot, because for many people it is so important to keep the unsigned document, and most do not realise this until it is too late.

Maybe you are looking for

  • What are the best optimization settings for Logic 9....

    Hey guys, I am running Logic 9 on a Macbook Pro 2.53GHz, Intel Core 2 Duo, 4GB RAM, OSX 10.6.4, with a AK1 soundcard. And I was wondering what the best optimization settings for this setup are? I have been having a few issues with drop outs in sound

  • Oracle Portal & BI 10g on Windows XP Professional

    Hi, I'm planning to install 10gAS (Portal, BI) on XP Professional. But while installing it says it is not Certified. Does anyone using it on XP? If I ignore warning and go ahead will it work? Thanks & Regards Santos B

  • Hp pavilion g6

    my hp pavilion's hinge on the left side under the power button is broken and crack. it make me can't start and operate my hp pavilion g6. when I start to open the screen, part on the left corner beside the left hinge open too and the power button  is

  • I can't finish my phone conversation.

    Hey everyone, My problem is that I can't finish my phone conversation in Iphone 6 64GB iOS 8.3. I can't do this in two situation. One of them is that I can't finish despite of clicking on red receiver. I can see that it seems to be 'clicked in' but i

  • How do you rebuild the font database?

    I've been having big trouble with InDesign crashing everytime I print whether to an actual printer, distiller or to my desktop and have found that I need to rebuild my font database but don't know exactly how to do that. Can anyone help? mac pro   Ma