Several instructions exit in a method - good or bad practice

Hi fans of Java,.

I happened to read this article: http://www.theserverside.com/tip/A-return-to-Good-Code on 'theserverside.com' how to have several instructions output in a method is bad programming practices.

However when you glance through the comments on the article, you will find people showering reactions mixed on this statement.

I want to know what should be the right road to take when writing code.
Is there a logic that must decide which method to follow?

Thanking you in advance for your advice.

Google search I found the following links:
http://StackOverflow.com/questions/2939162/is-it-bad-to-have-multiple-return-statements
http://StackOverflow.com/questions/36707/should-a-function-have-only-one-return-statement

Static code analyzers highlight several instructions output as a negative pointer!

815233 wrote:
A great example, I must say. Thanks a lot for this post baftos. And also thank you all for your contributions to it. :-)

And on this subject, an old chestnut that was given to me was: 'not more then 3 levels of conditional logic' (be they ifs, loops or something else).
Like most of the others, it must be applied with the thought; but it has served me quite well for 30 years.

Winston

Tags: Java

Similar Questions

  • Several instructions set-peer - failover behavior

    Hi all

    I would like to confirm the behavior of the use of several instructions of the command "set-peer" under a single sequence of crypto-map for failover to IPSEC tunnel. In particular, what happens when a peer that has been previously unavailable returns to service?

    For example:

    I have two sites; Site 1 and Site 2 have two routers. All are connected by a routed cloud.

    Routers at each site have the following crypto card configured:

    Site1 - the two router A and router b:

    10 encryption ipsec-isakmp crypto map

    defined by peer RouterD
    defined peer RouterC

    Set transform-set 3desMd5
    match address 101

    Site2 - router-C and router D:

    10 encryption ipsec-isakmp crypto map
    defined peer RouterA

    defined peer RouterB

    Set transform-set 3desMd5
    match address 101

    HSRP is used on the side LAN between two routers on each site to prefer the router A and router C respectively as the active device.

    According to the Cisco documentation:

    "you can specify several counterparts by repeating this command (set-peer). The peer who has in fact, packets are sent to is determined by the last counterpart who heard the router (received traffic or a request for negotiation of) for a given stream. If the attempt fails and the first pair, Internet Key Exchange (IKE) tries the next peer on the crypto card list '.

    http://www.Cisco.com/en/us/docs/iOS/Security/command/reference/sec_s2.html#wp1046908

    If RouterA has an IPSEC tunnel to routerD... and router D fails, a tunnel is built between routerA and routerC. When the router D is backup... traffic switches to D from router to router A?

    What sequence of events would be the tunnel does not switch back once the main router has recovered from a failure?

    Thanks in advance.

    OK, that explains the behavior. When the router D returns, he becomes the main HSRP, traffic at the start of site 2 will use router D as point to exist; Router D paraphera session with A router ipsec. It looks like back switch for router D, but it's just because the initial D router to the router ipsec session has once he returns.

    HTH,

    Lei Tian

  • several instructions box in where clause

    Hello

    I'm trying to create report filters using substitution variables in a case statement in a where clause clause. I have several instructions box running on the same column. I don't really know how to write it. Here's what I have so far but I know I'm going in the wrong direction.

    where

    i.compute_zone =

    case

    When: P14_zone is NOT NULL

    then: P14_zone

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_2 is NOT NULL

    then: P14_zone_2

    other: P14_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_3 is NOT NULL

    then: P14_zone_3

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_4 is NOT NULL

    then: P14_zone_4

    of other i.compute_zone

    end

    any suggestions?

    Thank you

    MICAH

    Hi, Micah,

    User12611868-Oracle wrote:

    Hello

    I'm trying to create report filters using substitution variables in a case statement in a where clause clause. I have several instructions box running on the same column. I don't really know how to write it. Here's what I have so far but I know I'm going in the wrong direction.

    where

    i.compute_zone =

    case

    When: P14_zone is NOT NULL

    then: P14_zone

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_2 is NOT NULL

    then: P14_zone_2

    other: P14_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_3 is NOT NULL

    then: P14_zone_3

    of other i.compute_zone

    end

    AND

    i.compute_zone =

    case

    When: P14_zone_4 is NOT NULL

    then: P14_zone_4

    of other i.compute_zone

    end

    any suggestions?

    Thank you

    MICAH

    How get the desired results of your data depends on the desired results and your data.  What do you do?  (I can't tell just by looking at the aat code that do not do).  After CREATE TABLE and INSERT statements for some sample data and a couple of sets of parameters (variables such as p14_zone) and the exact results that your choices in each set of parameters, given the same sample data.

    Check out the Forum FAQ: Re: 2. How can I ask a question on the forums?

    CASE expressions are generally not useful in a WHERE clause.  CASE expressions are a convenient way to IF-THEN-ELSE logic of the places where you can't do anything other than (the SELECT clause), but WHERE the clauses allow IF-THEN-ELSE logic in any case

    Maybe you want something like

    WHERE MERGE (: p14_zone,: p14_zone_2,: p14_zone_3,: p14_zone_4) IS NULL

    OR IN i.compute_zone (: p14_zone,: p14_zone_2,: p14_zone_3,: p14_zone_4)

    It returns TRUE if all 4 parameters are set to NULL.  If 1 or more of them are not NULL, then it will return TRUE if i.compute_zone is equal to one of them.

  • Update ISTAT menus mac is good or bad

    ISTAT Menus Mac update is good or bad for your Mac Book Pro and IMac

    I saw no complaint from any user iStat menus.  It is one of the best available for a Mac commercial follow-up, so I would use it.

    Ciao.

  • Google Chrome good or bad for battery performance?

    I was wondering if Google Chrome's download on a MacBook Pro or if I should just stick with Safari?  I hear that Chrome is good and bad for performance and life of the battery on the MBP machines.  That you have experienced using this browser?  Thank you.

    Try as well as FireFox, and then decide that you prefer. FWIW, I prefer FireFox.

    Did not like the answers in your other thread on the same does Google Chrome tend to use more energy on MacBook Pro?

  • my chart of airport utility is no longer showing how good (or bad), the connection is. It started when I installed el available hotfix captain.any

    My airport extreme is no longer show how good or bad connection lies in the graphical utility from the airport. With the help of 27 "

    iMAC on El Captian.

    It's an El Capitan bug that should be fixed in the 10.11.2 recent update.  That is what you have installed on your Mac?

  • AVG TUNE MY C drive, 10% said stall can be time... Is it good or bad... It was work, but slow

    a AVG TUNE MY desktop hp 500... Last tune up has been the C drive... He stuck on 10% and says can take an hour... Is it good or bad... He

    You can ask either https://support.avg.com/?l=en_US

    and/or

    https://support.Avg.com/answers

  • Re-organization of database every week, it is good or bad?

    We use windows 2003 server and oracle 10.2.0.4, having two databases with 38 GB and another 72 GB. And the recommendation of the application team suggested to the reorganization of the database for each week. So, I want to know wheather do re-organization of complete database for each week is good or bad.

    Uwe Hesse wrote:
    It's bad. No sophisticated response required here. No DBA (Oracle) is supposed to do a "database reorganization' - whatever that means in detail - once a week.

    And if it is indeed a requirement of the team of apps: they built a very bad application :-)

    Uwe,

    I know you have read this before, but for reasons of the constant stream of the beginners

    I remember once more the seller make a ground for its product, kept talking about SQL Server. We informed that we were an Oracle shop. He said (and I quote): "we do not recommend running on Oracle, because we found that the Oracle can't handle more than 5 concurrent connections.

    I started my career 30 years ago as a developer. I am constantly amazed at the current generation of developers who seem to not only know nothing about the technology with which they work, but do not yet seem a curiosity about this. They give without thinking at all made to design anything.

    * I predict this thread will be sleeping in the next 48 hours, but 3 years from now, someone will record this with the forum, do some research on... on what? ... and revive this thread with a useless comment as their very first post.

    Kind regards
    Uwe Hesse

    http://uhesse.WordPress.com

  • Is the indicator parallel use / * + PARALLEL * / good or bad?

    Hello

    I am facing problem in the use of / * + PARALLEL * / hint in SQL Query took his time to run.

    Parallel Hint degrades performance?

    The FCT_TABLE Table is to have clause PARALLEL (DEGREE by DEFAULT DEFAULT INSTANCES).

    We use the suspicion parallel as SELECT / * + PARALLEL (FCT_TABLE 2)

    Any help will be necessary for me.

    Thanks and greetings

    Re: Using parallel Hint / * + PARALLEL * / good or bad?

    Bad news. (in production systems)

    Why? You, when you code this SQL statement with this point in development, have absolutely no idea of what the production will be like in a month. No idea what data will be. What another charging process will run. Or what will be the version of Oracle and hardware will look like.

    Yet, by coding this suspicion in the production of SQL, you claim you know. And not only that, you claim that you are in a position higher than the CBO to make an informed decision on whether to run SQL in parallel. You declare that production DBA knows his work and how to improve performance, and you have decided for them that the SQL should be run in parallel.

    Be very careful with advice in the code that lands in the production. Generally these efforts will simply cause more problems to solve problems.

    So why the parallel indicator then exist if it is so "+ bad +"?

    Very rarely (if ever) there are absolutes in software engineering. And there are exceptions where this indication can be extremely useful. But it's like a hammer in a Toolbox. You use it on the odd nail. You don't use every day to drive screws because the screwdriver is "+ hard +" to use.

  • How to add several lines to the CreateWithParameters method

    Hello
    can someone tell me how to insert several rows in a table by using the CreateWithParameters method, which I use in a taskflow.

    That's why you get a null pointer...
    Add the iterator in this page or call the method in the second page... both should work... :)

  • Several instructions if in conditional actions?

    Hello

    I have a single button on a slide.  Whenever the user clicks on it, a legend of additional text should be.  My original idea was to hide all captions, create a variable to keep track of how many times the user has clicked the button and when the button was clicked, check to see how many times it has been clicked and present the appropriate caption.  This approach would require multiple if statements because according to many times the button has been clicked, a different legend would have shown.

    After my research is preliminary, it was not possible in 2012.

    Someone at - it ideas?

    You cannot nest the IF, but you can achieve this with several decisions. You do not have to nest IF s to achieve this goal, although having a function BOX would make it easier (you can do that with JS). Here is a much simpler application with advanced actions:

    Blog after Posterous? -ClickClick - Captivate blog

    Look at the example of ClickClick please.

  • Why can't put several instructions box here?

    I am currently having a case statement and instruction decode in the same query, and whenever I run it, it gives me the same error-

    KEYWORD not found or planned.

    The query that I am running is.

    Select ctn_nbr, plt_id, locn_brcd, ctrl_nbr, substr(ref_field_1,3,8),
    ship_via, user_id, mod_date_time, TRUNC (sched_dlvry_date), trkg_nbr as tracking_number,
    DECODE (STAT_CODE,
    "10', 'not selected."
    '20', 'printed ',.
    "35', 'in packaging."
    "40", "complete package"
    "70', 'loaded on truck."
    "90', ' delivered/billed."
    "99', 'cancellation."
    'Unknown') THAT the status.
    case
    When SUBSTR (SOLDTO, 0, 6) = "BATH" and "special order".
    else "Standard order"
    end up like "order type".
    Table A

    Is this something ridiculously simple that I'm missing like a comma? I do not understand why this error message keeps coming up. Help, please!

    end as "order type".

  • Qosmio X 770 - 11 c - good or bad experience?

    As a fan of Toshiba products (after my two PC Toshiba: M200, Satellite A200-1DS protégé), decided by a performance plus one.

    So I bought Toshiba Qosmio X 770 - 11 c, I was satisfied with the performance, I use matlab and 3dsmax.
    Then, after 7 months, I started seeing blue screens;

    I thought that it was perhaps with window 8 that the problems will be solved, unfortunately not...
    Call Toshiba, they fixed it (when I received it, indicating windows... blue screen again...)

    so I don't know what they fixed...!)
    Calling again because several times, finally after 3 and a half months they send UPS to fix it... up to now my PC is to toshiba repair...

    For me, it's a good chance with toshiba: I bought my PC... I've used it for 7 months... then... I'm on standby... :(

    I think that this will be my last PC Toshiba...
    Unfortunately, I loved their products before, I'm looking now for Lenovo, anyone has an idea on the performance of the pc. ?

    Sorry to read all this. The Qosmio series is Toshiba's best multimedia machine, but it was always too expensive for me so I m user of Satellite P series. I always use my Satellite P500 in hope Toshiba will again offer a large series of P again. I love the 18.4 screen.

    I put t know which BSODS have you noticed (error code) and what can be the reason. Have you tried to reinstall the recovery image and again test the functionality with the factory settings?

    I rally hope you will get your Qosmio soon and everything will be OK again.

  • TurboYourPC... it's good or bad for IMac?

    Last time I downloaded a 'cleaner', Apple told me that it causes more problems for Apple computers than it solves. Just got an ad recommend TurboYourPC, which is supposed to work for Apple, but also pcs. Is this good?

    No business of this nature "would work for Apple.   Apple is able to take care of its machines for himself.   Regarding general information you don't need to use any kind of System Cleaner, AIDS empowerment or other with an iMac.   If you have a specific problem, post it in these columns in the corresponding theme.  Sorry about the changes.

  • LabVIEW FPGA. Good modular coding practices.

    Hello

    Installation program:

    I have controls in the top vi FPGA communicates the host settings to the FPGA. I also have a sub - vi to generate output based on these settings. I placed the last part in a subvi since I want to reuse the code for several generators.

    Now to the question:

    If you want a sub - vi to run for always on the FPGA would you put you outside while loop within the subvi or in the top vi surrounding the sub - vi?

    First I always placed the while loop inside the subvi to have a cleaner top-vi. Now, I realized that it's probably a bad idea since I can no longer update the settings for the sub - vi because top-vi settings controls are not placed in a while loop. In the top vi I could just read another infinite loop controls the settings and save them in a global variable, only then I read in the sub - vi, but it would force the various sub - vi use the same global variable (and therefore the same settings). Is there a solution to this problem or should I always see just my sub - vi to be used in a loop to outter rather than having the loop in the sub - vi himself?

    For very simple applications, put the while loop in the first level VI will allow you to read/write controls/indicators according to the needs that may be the least amount of code. However, as your design becomes more complex, you really want to modularize and use an approach focused more on the events.

    I'll interpret your application as a processing loop main (i.e. under - reusable VI) with a secondary event loop that monitors updates to the host and RECONFIGURES the system. If this is the case, I would follow the other model you mentioned where I would separate the code into two separate processes (screws) that run independently. To the next level, you can build VI - Defined FIFO, memories or registers which then connect to each of these processes of 'connect' together so that they can communicate. The event host code treatment will be abandoned in a loop on the chart of top level so you can read/write commands/indicators directly, but we hope that most of the code is inside the event processing under VI.

Maybe you are looking for

  • How to recover photos in iPhoto sierra

    I just upgraded to sierra and all my photos in iPhoto are gone! I didn't return, I know, but it needs to be recovered somehow! can you help me please?

  • 4540 proBook s: 4540 Probook s MAXIMUM supported memory?

    Hello I want to upgrade my 4 GB (1600 Mhz, installed by the factory - I mean HP for sure!) memory on my Probook 4540 s 16 GB (or maybe 12 GB - keeping my primary memory installed), but I read so many complains here, portable computer after upgrade!,

  • generation of HTML reports save to the same file VI

    Hi all IM creating a sample html report using labview6.1. My question is I want to save my html report file in the current directory where the vi is instead of giving some path like 'C:\Folder1\Folder2\. '... "etc. My intention is to put the VI in a

  • I really want to get the IMAQ Image IMAQ Arry case to Image.vi files

    Hello! Although already, I installed LabVIEW8.2 and NOR-IMAQ, I don't have IMAQ Image cases and IMAQ Arry Image.vi files. To use the infrared camera, I need them. I really want to get the case Image IMAQ Arry Image.vi files IMAQ. How can I get these

  • How can I add MUIs for my laptop?

    Hello. I have standard Windows Vista on my laptop and said I need to download an additional MUI in order to have the Japanese feature. Help Windows said I should see these MUIs in Windows Updates, but until there was nothing. I read on another answer