Best coding practice

Not a big deal here but I'm curious what others think about
this. A fellow programmer and I were talking about this and
couldn't come to a conclusion.
Basically is it better to use a NOT EQUAL TO or an EQUAL TO?
For instance if you have a list of names and you want all
"BOB"s to be treated one way and all others to be treated another.
Would it be better to say
<cfif FNAME EQ "BOB">
blah blah
<cfelse>
woo woo
</cfif>
or
<cfif FNAME neq "BOB">
woo woo
<cfelse>
blah blah
</cfif>

quote:
Originally posted by:
MaryJo
quote:
Originally posted by:
MikerRoo
Good grief, you are ALL wrong --
especially Mary Jo for introducing a barely relevant tangent
to the thread and getting it wrong to boot!
First of all, when someone asks what is best for a string
comparison, mentioning Compare and CompareNoCase is *hardly*
irrelevant. Second, I was NOT wrong. Since the discussion was
revolving around performance that was just what I mentioned. That
doesn't make me
wrong just because there are reasons to use it other than
just that. If you want to debate if there's any performance gains,
well that comes right out of the CFMX coding guidelines at
Livedocs, which say it is "significantly faster". I'm assuming Sean
is correct in stating this, I'm not really in the mood to test it
myself, but feel free to add your comments there and tell him he's
wrong if you disagree.
http://livedocs.macromedia.com/wtg/public/coding_standards/performance.html
Of course, you can debate if the gain is that big a
deal...which is why I phrased it the way I did (i.e. "If it's
processing time you care about....") Again, that's what the bulk of
the debate was on, so that was what I was addressing.
No one asked what was the best for string comparison. YOU
raised that issue.
Your stated reason, (for performance) has not been true since
CF5.
Up until then, the question seems to be as much about style
as anything else.
That page you linked says that
CompareNoCase() is "faster" than "is not".
(1) If you actually run the tests, you'll see that the
difference is less than the test variation (but statistically
real).
(2) This says nothing about compare() vs "IS". Here the
performance is the same.
(3) CompareNoCase is not functionally the same as the most
commonly needed string comparison (case tolerant), so that is
irrelevant for most uses anyway.
Run the tests yourself and see that I'm right.
In fact,
Sean even admits, that the real reason to use compare() is
accuracy, at the bottom of that page!
So, my assessment was right. You were right mostly for the
wrong reason and the post was barely relevant.
Ironically, if you had found and linked that page to begin
with, it would have made one more case for avoiding negative logic
("IS NOT").

Similar Messages

  • How to follow best coding practices and make this code runable.

    How to change this code to make it work and follow best coding practices.
    This code is to add fields to internal table LIST which already exist.
    In the loop are all the selections which are to be made.
    But i am new to ABAP and not sure how to make this work.
    please help me.
    DATA: wa_list LIKE LINE OF list,
          l_v_index TYPE i.
    DATA: t_price_result1 TYPE STANDARD TABLE OF komv WITH HEADER LINE INITIAL SIZE 0.
    DATA: wa_result LIKE LINE OF t_price_result1.
    LOOP AT list INTO wa_list.
      l_v_index = sy-tabix.
    *GET MATERIAL DOCUMENT(MBLNR) AND DELIVERY NUMBER(XBLNR)
      SELECT  mkpf~mblnr
              mkpf~xblnr
       into (wa_list-mblnr, wa_list-xblnr )
    *            INTO i_list
       from mkpf inner join mseg
    *   up to 1 rows
        on mkpf~mandt = mseg~mandt
        and mkpf~mblnr = mseg~mblnr
        and mkpf~mjahr = mseg~mjahr
        where mseg~matnr = wa_list-matnr
         and mseg~charg = wa_list-charg
         and mseg~kunnr = wa_list-kunnr
         and mseg~sobkz = wa_list-sobkz
         and mseg~werks = wa_list-werks
         and mkpf~budat in budat.
                                                                "RFC3762
      ENDSELECT.
      wa_list-mblnr = list-mblnr.
      wa_list-xblnr = list-xblnr.
    * GET POSNR FROM TABLE LIPS
      SELECT posnr
      FROM lips
      INTO list-posnr
      up to 1 rows
      WHERE vbeln = wa_list-xblnr AND
                 matnr = wa_list-matnr.
      ENDSELECT.
      wa_list-posnr = list-posnr.
    * GET SALES ORDER #
      SELECT vbelv
      FROM vbfa
      INTO list-vbelv
      up to 1 rows
    *        INTO wa_list
      WHERE vbeln =  wa_list-xblnr.
      ENDSELECT.
      wa_list-vbelv = list-vbelv.
    *GET PO
      SELECT bstkd
      FROM vbkd
      INTO list-bstkd
      up to 1 rows
      WHERE vbeln =  wa_list-vbelv
          AND posnr = 0.
      ENDSELECT.
      wa_list-bstkd = list-bstkd.
    *get serial number
      SELECT SINGLE obknr
       FROM ser01
       INTO list-obknr
       WHERE lief_nr = wa_list-xblnr
           AND posnr = wa_list-posnr.
    wa_list-obknr = list-obknr.
    SELECT sernr
    FROM objk
    INTO list-sernr
    up to 1 rows
    WHERE obknr = wa_list-obknr.
    ENDSELECT.
    wa_list-sernr = wa_list-sernr.
    *get date
    SELECT budat FROM mkpf
    INTO list-budat
    up to 1 rows
    where mblnr = wa_list-mblnr.
    ENDSELECT.
    wa_list-budat = list-budat.
    *get CLP
    SELECT   vkorg vtweg spart
    INTO (list-vkorg, list-vtweg, list-spart)
    up to 1 rows
    FROM vbak WHERE vbeln = wa_list-vbelv.
    ENDSELECT.
    wa_list-vkorg = list-vkorg.
    wa_list-vtweg = list-vtweg.
    wa_list-spart = list-spart.
    SELECT pstyv
    INTO list-pstyv
    FROM  vbap
    up to 1 rows
    WHERE vbeln = wa_list-vbelv AND posnr = wa_list-posnr.
    ENDSELECT.
    wa_list-pstyv = list-pstyv.
    CALL FUNCTION 'Z_SD_PRICING_CONDITION'
    EXPORTING
    i_organization                  = wa_list-vkorg
    i_dist_channel                  = wa_list-vtweg
    i_division                      = wa_list-spart
    i_customer                      = wa_list-kunnr
    i_plant                         = wa_list-werks
    *      i_pricng_date                   = sy-datum
    i_material                      = wa_list-matnr
    *   I_SALES_UNIT                    = 'EA'
    *   I_QUANTITY                      = '1.000'
    i_stor_loc                      = '0001'
    i_item_cat                      = 'TAN'
    *   I_AUART                         =
    *   I_REFRESH                       = 'X'
    *   I_KOMP                          =
    *   I_KOMK                          =
    * IMPORTING
    *   E_MES_TYPE                      =
    *   E_MES_NUMBER
    *   E_MESSAGE                       =
    TABLES
    t_price_result                  = t_price_result1
    * EXCEPTIONS
    *   CUSTOMER_NOT_FOUND              = 1
    *   PLANT_NOT_FOUND                 = 2
    *   MATERIAL_NOT_FOUND              = 3
    **   PLANT_MATERIAL_NOT_FOUND       = 4
    *   SALES_DATA_NOT_FOUND            = 5
    *   ORG_UNIT_NOT_FOUND              = 6
    *   UNABLE_TO_CALCULATE_PRICE       = 7
    *   UNABLE_TO_FORMAT_PRICE          = 8
    *   MANDATORY_INFOR_MISSING         = 9
    *   OTHERS                          = 10
    LOOP AT t_price_result1.
      IF  t_price_result1-kschl = 'ZPR2'.
        wa_list-kbetr = t_price_result1-kbetr.
      ELSE.
        wa_list-kbetr = 0.
      ENDIF.
    ENDLOOP.
    MODIFY list FROM wa_list INDEX l_v_index.
    ENDLOOP.

    Hi,
    Lets first start from your Select Statement.....Replace your SELECT ....ENDSELECT by SELECT Into Internal Table
    Your program is having a SELECT...ENDSELECT within LOOP...ENDLOOP........One should avoid doing this as far as possible.
    SELECT  mkpf~mblnr
                  mkpf~xblnr
    INTO itab
    for all entires i_list
    from    mkpf inner join mseg
        on   mkpfmandt = msegmandt
        and mkpfmblnr = msegmblnr
        and mkpfmjahr = msegmjahr
        where mseg~matnr = i_list-matnr
           and mseg~charg = i_list-charg
           and mseg~kunnr = i_list-kunnr
           and mseg~sobkz = i_list-sobkz
           and mseg~werks = i_list-werks
           and mkpf~budat in budat.
    Restructure youe complete code with this approach and Share your Finding's.
    You can also think of using a SAP Standard FM.
    Anyway..What is the objective/Output of this report?

  • Best Coding Practices

    Hi
    are there any best coding practices for EP development?can anybody suggest the material?
    Prasad

    EP, as in Enterprise Portal?
    James

  • What are the best coding standards for ADF 11g?

    Hi,
    Do we have any link that will suggest the best coding standard practices used for ADF 11g?
    I am looking out from the perspective of some standards that can be defined before starting my project to know the team on how to
    1. Minimize Duplicity and max reusability of code
    2. Package the code
    3. Resource bundle usage and its calls
    4. Maintainning format consistency eg. date display format, number format
    5. Exception handling
    6. Logging
    7. Namiing conventions
    Also then we might have standards on
    1. Task flow dev.
    2. EO and VO creation standards
    3. UI development standards [purely ADF component based]
    Thanks in advance
    Edited by: user8925296 on May 26, 2010 3:24 PM

    The ADF Enterprise Methodology Group has a page on standards that gives you a starting point on many of your questions: http://groups.google.com/group/adf-methodology/web/adf-coding-standards
    John

  • What are the best coding technics which will avoid performance problems

    Hi Experts
    What are the best coding technics which are avoiding memory problems and performance problems
    Some times one of few reports are taking too much time to executing while handling large data.
    1.What are the best way to declare a internal table to avoid performance problems.
    2.what is the best way to process data.
    3.what is the best way to clear memory.
    Can you guys help me give some good suggestions for  writing better programs  to avoid performance problems.
    Thanks
    Sailu

    Hi,
    Check this link..[Please Read before Posting in the Performance and Tuning Forum Updated |Please Read before Posting in the Performance and Tuning Forum;
    Which will be the first thread in the Performance and Tuning Forum.
    Search the SCN first.

  • What are the best security practices for your forms and databases

    What are some of the best security practices to follow to
    ensure your database isn't attacked with injections, forms abused
    with snippets of code, and mass spam DB inserts on your
    forms?

    On Sat, 29 Mar 2008 17:17:01 +0000 (UTC), "jsteinmann"
    <[email protected]> wrote:
    >What are some of the best security practices to follow to
    ensure your database isn't attacked with injections, forms abused
    with snippets of code, and mass spam DB inserts on your forms?
    David Powers books on php for Dw give detailed advice on how
    to do
    forms, first with html, and then validate them with secure
    php
    scripts.
    http://foundationphp.com/
    ~Malcolm N....
    ~

  • Best Business practice document for FI.

    Hi All,
    where i can get the Best Business practice documents for FI. please give me Link.
    Regards
    Manohar

    hi
    pls go through this link
    http://help.sap.com/bp_bblibrary/600/BBlibrary_start.htm
    Thanks & Regards
    phaneendra

  • Best/Easiest Practice for Distribution of Webhelp files for Fat(ish) Client Application

    So another in my long line of questions in trying to change the implementation of the help systems at my new employer.
    So, the pressure is to convince the existing guard to toss out the old method and go with a new method... One of the issues has come up for CSH Webhelp (via RH10)...
    Apparently, in the old method (where every help topic was it's own CHM - no, I'm not kidding).  They kept it that way so that any time a help file was updated, they could just send out that one chm to update that one topic.
    Now they are worried that if we switch to webhelp using topics in one single big project that we can't just send out a single updated file any more...
    So I'm trying to get ammunition as to how updates to the help can be distributed without it being a big hassle...
    We do have small updates that go out about every week, and they are afraid that going to the webhelp (1 project with lots of topics) method will require more time and effort for the techs because they will have to complete the update of a huge help system every time.
    One solution we have suggested is that we only update help files on major releases and add any changes to help procedures in the Release Notes or in a separate PDF and also include a note that the help files "will be updated to reflect this change in the XX/2015 XYZ Release).
    Does ANYONE have any other ideas of how distribution could be done efficiently so that we don't have to continue this "project per topic" fiasco?
    HELP!!! PLEASE!!!!

    Amebr - you hit the nail on the head... i want to apologize to everyone for all this mass hysteria...but this has been a freaking rollercoaster... one day they are happy with the plan, the next day they decided they want to complicate it more... So now my job is to find out how viable and how tricky and perhaps how dangerous it will be to send out JUST the files that have been changed.  Especially for CSH! 
    Anyone have any experience with this or have any advice?  Peter?  I suspect you might know how this might work... are they any pitfalls to watch out for.. I just have this fear of sending out a few files from an entire project... Altho, it appears when I publish, ONLY the files that have been edited in some way show a new date.. that includes non-topic files - so i'm assuming sending all those will keep the TOC, Index, and Search features working properly... as well as incoming and outgoing links from an edited topic?
    Another question would be how to handle new images in a project... as the image folder tends to be the largest, i don't want to have to send the entire image folder... Thoughts...????  Advice?  Jeff? Peter? Amebr? Bueller?  Bueller?  Bueller....?
    THANKS!Best/Easiest Practice for Distribution of Webhelp files for Fat(ish) Client Application
    OH... and Jeff... my apologies for the misnomer of using the term "Fat-ish" client in reference to this... I totally misspoke and should have said Mobile App... but in my mind, any time you have to download something to use it, it's a fat client... sorry!  :-/

  • Orcle inventory-is it integrated and does it capture best busness practics

    Hello all,
    I have a basic but imp qn , for which I have tried to find a comprehensive answer but in vain
    I would like to know what features in oracle apps make you say that it is integrated and captures best business practices..
    provide your views or help me to find resources that will clear my query....
    Thanks a lot
    Anand

    Anand,
    Your question is not clear for me to provide an answer. Basically, the shared entities like item, SOB etc provides the integration of various models and Security, Validation Rules provide the security for the data.
    Make your question clear, I will try to answer.
    Thanks,
    Saravanan

  • Oracle inventory-does it capture best business practices

    Hello all,
    I have a basic but imp qn , for which I have tried to find a comprehensive answer but in vain
    I would like to know what features in oracle apps make you say that it is integrated and captures best business practices..
    provide your views or help me to find resources that will clear my query....
    Thanks a lot
    Anand

    Anand,
    Your question is not clear for me to provide an answer. Basically, the shared entities like item, SOB etc provides the integration of various models and Security, Validation Rules provide the security for the data.
    Make your question clear, I will try to answer.
    Thanks,
    Saravanan

  • Whats the BEST Deployment Practice for appsTier (2 Node) with RAC Database

    Hi All,
    Whats the BEST Deployment Practice for appsTier on Shared APPL_TOP between two application tier Nodes and a RAC Database.
    Regards
    Satish

    Satish,
    Could you elaborate; are you looking for how to distribute the tiers(forms, web, conc., etc.); are you asking about PCP (parallelt concurrent processing)..
    Regards,

  • 2 Questions How to use join() and Which is best coding pratice.

    Hi All,
    I have 2 Question:
    I have a MultipleThread class and when I try to use join method of thread class I get compile time error(so i commented it out).I also wanted to know is the best approch to write a threaded program.I also wanted to know about the best coding pratice for threadand also do I need to declare Instance variable thread and name(Is it possible to create multiple thread with out declaring instance variable thread and name , if yes which one is the better way 1> with instance variable 2> with out instance variable)

    Sorry here is the code.
    package javaProg.completeReferance;
    public class MultipleThread implements Runnable
         Thread thread;
         String name;
         MultipleThread(String nam)
              this.name=nam;
              thread = new Thread(this,name);
              thread.start();
         public void run()
              try
                   for (int i=1;i<=10;i++ )
                        Thread.sleep(1000);
                        System.out.println("Thread "+name+" "+i);
              catch (InterruptedException e)
                   System.out.println(""+e);
         public static void main(String [] args)
              try
                   MultipleThread t1=new MultipleThread("One");
                   MultipleThread t2=new MultipleThread("Two");
                   MultipleThread t3 =new MultipleThread("Three");
                   //t1.join();
                   //t2.join();
                   //t3.join();
                   for (int i=1;i<=10;i++ )
                        Thread.sleep(1000);
                        System.out.println("Parent Thread "+i);
              catch (InterruptedException e)
                   System.out.println(" "+e);
    }

  • Need help regarding mm best purchasing practices..

    hi
    could any one tell me about the sap mm best purchasing practices.

    Here find below for the best practices that can be considered in General
    1) Master Data
    a) Central Master data with uniform naming convention
    b) Master Maintenance tool (MDM) with workflow for approval
    2) Collection of Requirements from User departments and Approval-
    a) Creation of PR in SAP and Release strategy with work flow
    b) PR creators and PR Release authorities (work flow) are linked with HR org structure.
    c) Approval/Notifications for in action/Reminders can be routed with the help of workflow.
    3) Budget Control for PR-
    a) By activating Funds Management OR
    b) By Internal Order OR
    c) Customer Exit to validate The PR value/Price according to allocated budget
    4) Buyer activity
    a) Automatic source determination and automatic creation of PO with release strategy.
    b) PO creation with reference to Long term contract (Release orders) for regular vendors plus Global contract
    c) Uniform way of raising PO with terms and conditions
    c) RFQ for Bidding Process plus release strategy.
    d) Vendor rating
    e) PO Price Difference Tolerance check/Validation in comparison with PR.
    5) GRN
    a) Central warehouse
    b) Acceptance of Materials subject to quality check
    c) Normal Service Procurement with Service Master 
    d) Service entry sheet with release strategy.
    5) Invoice
    a) Invoice Block parameters/Tolerances
    b) Invoice Approval work flow
    c) GR based invoice Verification for Normal Purchase.
    d) Activate Material Ledger to overcome the disadvantages of posting Invoice with Price difference in terms of valuation
    e) Uniform way of Invoice Posting/Payment
    f) ERS

  • Coding Practice for Bound Property Names

    I think this simply an issue over coding practices, but if I am right then all the tutorials and documentation on how to write Beans are promoting poor coding practices. Speicifcally, it bugs me that String literals are always used in all the code I see. As in the following code:
    class MyBean  {
       public void setValue(value newValue) {
          beansupport.firePropertyChange("value", oldValue,  value);
    }the practice that I have starting using is:
    class MyBean  {
        public static final String propertyValue = "value";
       public void setValue(value newValue) {
          beansupport.firePropertyChange(propertyValue, oldValue,  value);
    }This way, a PropertyChangeListener can refererence MyBean.propertyValue instead of using the literal "value" -- eliminating the chance for error and also there don't have to be multiple literals floating around using up space. Is there any reason this isn't commonly accepted practice or did I miss something?

    Strings appearing in source code can be reduced to a constant, like an enum. So it is likely that the code with strings is actually faster, as the value is known before compilation. It is easier to read. Keep in mind that strings get interned every now and then and thus get reduced to this equivalency:
    public method blah( "value", some stuff )...
    public method nah(*){ do stuff; let x = "value"; more stuff with "zoiks!" }
    ends up like
    key k1 = "value"
    key k2 = "zoiks!"
    what the jvm sees;
    public method blah( key1, some stuff )...
    public method nah(*){ do stuff; let x = key1; more stuff with key2 }
    The string values get "inlined" and can be checked during compilation, allowing for many optimisations not otherwise possible.
    Hope that helps a little.
    Andrew

  • Coding Practice(GV$SESSION)

    Hi
    Recently there was an issue of 1 procedure running in parallel through 2 different sessions and causing some irregular results.
    So, I changed the code in such a way that when the procedure runs then it sets the module and action in the GV$SESSION view.
    exec DBMS_APPLICATION_INFO.SET_MODULE ('MOD', 'ACT3000');
    So whenever the procedure runs it first checks in GV$SESSION whether ACTION with the name ACT3000 is running or not, if not it runs,else it exits.
    The question I have here is that is it a bad coding practice to select from the view GV$SESSION or any other system views in a procedure or an anonymous block?
    Regards
    Ankit

    The question I have here is that is it a bad coding practice to select from the view GV$SESSION or any other system views in a procedure or an anonymous block?Probably there's no general answer to this. Sometimes it is just necessary to to query system views, sometimes you might think it over again - in particular for performace reasons.
    In your case you also have the alternative of querying sys_context to get the information you wanted:
    SQL> select sys_context('userenv','module') module, sys_context('userenv','action') action from dual;
    MODULE                         ACTION
    SQL*Plus
    SQL>..whereby dual itself is a system view/table ;)

Maybe you are looking for

  • Financial Reporting 11.1.1.3 Client "Access Denied" connecting to HFM

    Hi, I have installed Financial Reporting 11.1.1.3 Client on a PC running Windows Vista 32 bit SP1. When I try to access to a report created form another PC that connects to HFM, it says "Error connectiong to server" and "Cannot connect to database "X

  • How to encrypt file on linux using Gnupg command in Java Embedding in BPEL.

    Hi All, I am trying to invoke a command script using the java embedding in BPEL Process.I am using the below code to execute the particular command to encrypt the file :- try {             Runtime rt = Runtime.getRuntime();     Process pr = rt.exec(n

  • Slideshow with border

    Hello, i am using iphoto and created a slideshow (with iphoto6, macmini, cinema display 23"). The slideshow works fine but there is a border about 1-2inches on each side around every picture. the resolution of the pictures is high enough for the scre

  • /mnt/etc instead of /etc when configing in install

    So, I get this really weird problem.. I'm installing ARch on a computer for dual boot use, with ubuntu. Everything works fine up until the configuration.. The problem here is that that nano is looking for all config files under /mnt/etc/... but they

  • New motion tween cs4

    Hi there, Whenever I try to add a new motion tween to an object that has completed a motion tween, they get combined together, meaning that at a particular frame the object is no longer exactly where I want it. Is there a way to be explicit that this