Good Coding practice

Example of a nonsense code below
for (int i=0; i < 10; i++)
    int total = i + 1;
System.out.println(total);when excute, total will be redeclared 9 times, compiler doesn't complain. But is this clean?
A better code below?
int total;
for (int i=0; i < 10; i++)
    total = i + 1;
}

My query is whether the "buffer" inside the loop ok?It's fine where it is. The compiler calculates how many slots on a stack
are needed for all local variables. Those slots are allocated from the
stack upon entry of the method and removed when the method returns.
Note that the amount of slots needed is not necessarily the same as
the total number of local variables:void foo() {
   int i; //  slot 1
   for (int j= 0; j < 10; j++) // slot 2
   for (int k= 0; k < 10; k++) // slot 2 again
}kind regards,
Jos

Similar Messages

  • Any usefull examples of good coding practice in large programs

    Hi, ive been writing code for about 10 years now. Know a good bit about labview now lmao! But want to get to know good code practices e.g. in creating large programs, code templates, avoiding race conditions, use of multiple loops and to be able to write code for clients as a contractor. Any one help me??
    Stu
    Solved!
    Go to Solution.

    Check out thelargeapp community and this KB article
    Message Edited by Jeff Bohrer on 06-14-2010 04:49 PM
    Jeff

  • Good coding practice for object init

    We have a code that requires initializing instance of the object for each item in the loop. I have following option in mind. Please advice which one is the best option. TIA
    Option 1
    =======
    public class AThread extends Thread {
    private ObjectA var1 = null;
    private ObjectA var2 = null;
    public AThread() {
    this.var1 = new objectA();
    public void run() {
    while ( ... ) {
    if (var2 != null) {
    var2 = null;
    var2 = var1;
    var2.callmethod();
    Option 1
    =======
    public class AThread extends Thread {
    private ObjectA var1 = null;
    public AThread() {
    public void run() {
    while ( ... ) {
    var1 = new objectA();
    var1.callmethod();
    var1 = null;
    }

    1. If in the future, you post code, you can make it much more readable by enclosing it in the [code][/code] tags.
    2. Why not implement Runnable instead of extend Thread? You're not creating a new type of thread, so it is more "OO"-sensible to create a new Runnable and run it.
    3. In the first Option 1, you might as well just be doing
    while (...) {
      var1.callMethod();
    }Assigning the reference to another variable does not create a new instance of the object, so it is not worthwhile to create a new reference to it just to call its methods.
    4. In option 2, setting the object's reference to null at the end doesn't really help anything, because the object is going out of scope anyway and will be destroyed.
    Your question, really, between the two options, is as follows: should you recreate and destroy the object for every iteration through the loop, or just call the method multiple times?

  • 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?

  • Good programming practice

    There are 2 sets of code which I extracted from a dummy book. The author just want to illustrate 2 ways that we can capture an exception.
    Code set 1_
    import static java.lang.System.out;
    class GoodNightsSleepA {
        public static void main(String args[]) {
            out.print("Excuse me while I nap ");
            out.println("for just five seconds...");
            takeANap();
            out.println("Ah, that was refreshing.");
        static void takeANap() {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                out.println("Hey, who woke me up?");
    Code set 2_
    import static java.lang.System.out;
    class GoodNightsSleepB {
        public static void main(String args[]) {
            out.print("Excuse me while I nap ");
            out.println("for just five seconds...");
            try {
                takeANap();
            } catch (InterruptedException e) {
                out.println("Hey, who woke me up?");
            out.println("Ah, that was refreshing.");
        static void takeANap() throws InterruptedException {
            Thread.sleep(5000);
    }To u guys who are experienced java programmer out there. Which set of code do u think is better coding practice and u'll usually code that way ? I personally would say GoodNightsSleepA is a better practice. Or u guy have some other better suggestion ? Thank you.

    Thank you to everybody who responded to this thread. Can anyone pls point me to a link that talks about proper OOP system analysis and design. I believe I need some foundation on this, otherwise I can't write a proper scalable code. Like some of u has pointed that the GoodNightsSleepB class will be more appropriate coz it provides flexibility to other user who would like to use it as a subclass. I didn't thought of this b4 until u guys have enlighten me.
    To corlettk, I'm totally new to AOP. I just read some of the links from the google search result. I'm still in a very blur stage about AOP. Am I right to assume that we should only code to include basic business requirement functions(primary task) in our class and make use of AOP to do the secondary task(such as data verification/exception capturing) ? Pls correct me if I'm wrong. Thank you in advance, guys.

  • 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 ;)

  • 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

  • Good programming practices:   creating Iterator objects

    Hi,
    This is a question about Good programming practices for creating Iterator objects of ArrayList objects. The following line of code works fine in my program (as ridiculous as it may sound):
            Iterator cheesesIterator = cheeses.iterator();but I was wondering whether Java is automatically inserting the <Type> and new code to make:
            Iterator<String> cheesesIterator = new cheeses.iterator();and therefore whether it is good practice to use these everytime? Thank you. ("full" code shown below:)
    import java.util.ArrayList;
    import java.util.Iterator;
    public class DemonstrateIterator
        private ArrayList<String>  cheeses;
         * constructor:
        public DemonstrateIterator()
            cheeses = new ArrayList<String>();
            cheeses.add("Emmentaler");
            cheeses.add("Cheddar");
            cheeses.add("Stilton");
            cheeses.add("Brie");
            cheeses.add("Roquefort");
        public void listCheeses()
             //make an iterator object of the ArrayList object
            Iterator cheesesIterator = cheeses.iterator();
            while (cheesesIterator.hasNext()) {
                System.out.println(cheesesIterator.next());
            /** Exploring the toString and Super functions. **/       
            System.out.println("\na toString call to Super returns: " +
                                              super.toString() + "\n");
    }

    AJ-Phil wrote:
    Hi,
    This is a question about Good programming practices for creating Iterator objects of ArrayList objects. The following line of code works fine in my program (as ridiculous as it may sound):
            Iterator cheesesIterator = cheeses.iterator();but I was wondering whether Java is automatically inserting the <Type> and new code to make:
            Iterator<String> cheesesIterator = new cheeses.iterator();and therefore whether it is good practice to use these everytime? TFirst, new chesses.iterator() won't compile.
    iterator() is just a method that returns an iterator. It constructs an instance of a private or nested class that implements iterator, and returns a reference to it.
    As for the <T>, when you declare List<String>, that parameterizes that list with type String. The iterator() method returns Iterator<T>. You can look at the source code for yourself. It's in src.zip that came with your JDK download.
    Separate from that is your declaration of that variable as type Iterator, rather than Iterator<String>. Regardless of what you declare on the LHS, the iterator() method returns Iterator<T>. Your bare Iterator is essentially Iterator<Object> or Iterator<? extends Object> (not sure which, or what the difference is), which is assignment compatible with Iterator<T>. If you had declared it Iterator<String>, you wouldn't have to cast after calling next().
    Edited by: jverd on Nov 23, 2008 11:33 AM

  • Good programming practice - Abstract class

    Hi all,
    I have been trying to help another soul in this forum, and came to the conclusion that I don't know good
    programming practice when it comes to abstract classes.
    Is this correct?
    You CAN implement methods in an abstract class, but it's not recommended.
    I have NEVER done this...when is there possibly a need to?
    Regards.
    / k

    Yes, absolutely, you can implement methods in an abstract class. Any method that all subclasses will perform in the same way can be implemented in the abstract base class. If subclasses perform similiar functions depending on their type you declare those as abstract in the base class. Here is a contrived example that I have seen on job interviews.
    Suppose your developing an application that draws on a panel. We want to provide some canned shapes such as a circle, a square and a triangle. We want to be able to draw the shape set or get its color and calculate its area.
    Let's define an abstract base class Shape
    public abstract class Shape{
        private Color myColor;
       //  since color has nothing to do with what kind of shape we're working with, create concrete implementation
       public Color getColor(){
            return myColor;
    public void setColor(Color newColor){
       myColor = newColor;
    // however, drawing the shape and calculation its area are depending on the actual shape.
    public abstract void draw();
    public abstract double getArea();
    // so then Square would be something like
    public class Square extends Shape{
       public double get Area()
          return sideLength * sideLength  // assumes somehow we know sideLength
    public void draw(){
                  // concrete implementation
    }we can do the same things for Circle class and Triangle class.
    And, if you think about it you'll notice that we could have made a Rectangle class and then Square would be a subclass of Rectangle where both dimensions are equal.
    I hope that somewhat strained example helps answer your question.
    DB

  • Good battery practices?

    I got an iphone today....and I love it!!!!!!!!
    I turned it on and have used it today and the battery is almost gone....should I wait until the battery is completely drained before I plug it into the wall socket? Also, is it good for the battery and the phone in general to leave it plugged into the wall all night long, like I did with my old cell phone?
    What are good battery practices in general for the iphone? I want to be able to use it without it dying out on me everyday, especially when I need to call someone. I don't know how to use it much....are there application or web things that I could turn off while they are not in use in order to conserve battery power? (How do I turn off edge? The E is constantly on the top of the screen...if I could turn it off, wouldn't that conserve power?)
    Any other conserving of power practices would be appreciated!
    Thank you!!!

    Apple put together a great page on the iPhone battery, check out the link below
    http://www.apple.com/batteries/iphone.html
    hope this helps

  • Good Battery Practice?

    I've just recently ordered my MacBook-- and though I haven't received it yet, I am still curious about good battery practice. If anything, I really want mine to last, and typically if asking just anybody off the street you'll get everything from "put your battery in the freezer" to "take out your battery, when not in use".
    Any thoughts? Should I charge it fully, then let it run out before I recharge? Should I use the adapter whenever I have the chance, regardless of the battery charge?
    I'm also curious whether I have to charge the battery before first use out of the box-- I looked through manual online, and I didn't see anything on that topic.

    intheam wrote:
    Any thoughts? Should I charge it fully, then let it run out before I recharge? Should I use the adapter whenever I have the chance, regardless of the battery charge?
    It is OK to leave your battery hooked to the charger most of the time. The only time I unhook mine from the charger is when I calibrate or for a few minutes to use in another room. You should calibrate every two months or so to keep the battery fully functioning. If you use your MacBook infrequently, it’s best to re-calibrate the battery at least once a month.
    It is best not to use your battery unless you need to. Some people have hurt their batteries by charging then discharging every time they use the MacBook. This will age a battery very fast and cause you to buy a battery sooner than you should have too. Don't discharge the battery just because you used it. Li-Ion batteries prefer small charges over big ones. Use it and then plug it in as soon as you can. The only time my Battery is ever fully discharged is when I'm doing a calibration.
    The following links have good information about the MacBook and the care of it's battery.
    Apple: Tips for maximizing your Notebook battery charge
    Apple MacBook and MacBook Pro: Reduces processor speed when battery is removed while operating from an A/C adaptor
    Apple portable computer's battery does not show a full charge in Mac OS X
    Look here and here for some good tips about battery care.
    Apple MacBook: How to remove or install the battery
    Apple: Determining Battery Cycle Count
    Apple: Use and cleaning of MagSafe power connector
    I'm also curious whether I have to charge the battery before first use out of the box-- I looked through manual online, and I didn't see anything on that topic.
    No just plug in your power supply and have fun. It will charge whie your using it. If you follow my other tips you should get long life out of the battery.

  • Do IOS app developers follow any good program practices?

    I've had my iPad (original) a little over two years now, and I can say without a doubt, it is the most unstable platform I've used in nearly 30 years of using computers.  Most apps crash routinely, usually while at least one other app is running in the background.  Unloading the crashed app from memory and reopening uually works, but is a huge nuisance (and reason enough to me why iPads are not business-ready, except for specific task applications requiring mobility).  As one trained in both software and systems engineering, with 20 years IT experience mostly in engineering, I have to conclude that IOS app developers use "code and fix" development, with little testing before release.  Of course, in theory it could be that IOS itself isn't well designed to handle multitasking and doesn't provide adequate process isolation.  Either way, it makes for a frustrating experience as a user.
    Has anyone else had similar issues?  Thoughts on why?

    The original iPad does poorly with multiple apps open, the memory is just too small at 256 MB.  The processor is very slow compared to those in the current generation iPads.  And then couple that with developers who are for the most part independent of Apple and merely submit there products to Apple and you get a totally unpoliced set of apps.  Some are true professionals and follow very good programming practices, one that comes to mind is the GoodReader PDF reader.  Very stable and very powerfully built.  then you get into the gamers and Is is almost like they never heard of writing effecient, compact code.
    The issue I see is a tightly controled operating system, with app developers handed a set of specs under which to code, but no real controls other than does the app run and is it free of malicious code.
    Just some thoughts.

  • 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").

  • Examples for good programming practice with multiple DAQmx tasks

    I'm writing a program to continuously log data from 8 counters, 8 encoders, and 8 voltages. The proof of concept VI with a single counter was simple and elegant, but scaling up to all signals resulted in a wiring mess. I've been working through the Labview Core courses, and am currently on Core 3. I still haven't come across a discussion on how to work with multiple DAQmx tasks without making a mess of the block diagram. Can anyone point me in the right direction?
    Also, say I have a state machine that has a configure, idle, and logging states. I need to set the initial values of the encoders during configuration, and keep up with their changes while in the idle state so I have appropriate starting values when entering the logging state. Can anyone point to an example that shows how this might be accomplished?
    Thanks

    I'm very familiar with AE's/Functional Globals - but I have struggled in the past with handling multiple DAQmx tasks - particularly when you're using multiple devices and using different types of measurements which require seperate tasks/handling (e.g. such as thermocouples which require extra compensation).
    I'm not even sure I know whare the requirements are for needing multiple tasks - I know you can need multiple tasks for a single device if the type of measurement is different but can you share an Analogue Input task amongst multiple devices?
    I think in hindsight (and without too much thought now) it looks like a good case for Object Oriented LabVIEW - with a base DAQmx class (initialise, configure, start, acquire, stop, close etc.) and then child classes for each type of measurement (with one task associated with each - and private data unique to that specific class). You then hold an array of objects (one for each task) and iterate through each one with dynamic despatch to get the data.
    I don't know your particular experience level of using LabVIEW (and as such, OO may not be appropriate) - but as a wider discussion of 'best practice' it seems like an appropriate method I would use going forward.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

Maybe you are looking for