Maximus Alexander wrote: » You'd hate me then, because I'd probably have written:if (.....) <some statement>; else <some statement>; <some statement>;
if (.....) <some statement>; else <some statement>; <some statement>;
Colonel Panic wrote: » No coding standards or coding standards you don't agree with. Which is worse?
Anesthetize wrote: » That's a paddlin'
foreach ($aryLineItems as $lineItemKey => $lineItemVal) { $arySelectedSupplierProducts = array(); if (!empty($lineItemVal['LineItem']['line_item_product_id'])) { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "|") !== false) { $aryLineItemProductIds = explode("|", $lineItemVal['LineItem']['line_item_product_id']); foreach ($aryLineItemProductIds as $lineItemProductQtyId) { if (strpos($lineItemProductQtyId, "::") !== false) { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); } else { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = "1"; } $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } else { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "::") !== false) { $lineItemProductQtyId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } else { $lineItemProductId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductQty = "1"; $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } } if (count($arySelectedSupplierProducts) > 0) { $aryLineItemProducts = $this->Arrangement->LineItem->LineItemProduct->find('all', array( 'recursive' => 0, 'conditions' => array('LineItemProduct.id' => array_keys($arySelectedSupplierProducts)), ) ); $aryLineItems[$lineItemKey]['LineItemSupplierProducts'] = $aryLineItemProducts; $aryLineItems[$lineItemKey]['LineItemSupplierProductsQtys'] = $arySelectedSupplierProducts; } else { if (!empty($lineItemVal['LineItem']['cheque_name'])) { $aryLineItems[$lineItemKey]['LineItemSupplierProducts'][0]['Contact']['company_name'] = $lineItemVal['LineItem']['cheque_name']; } } } $aryData['LineItem'][$sLineItemType] = $aryLineItems; }
Buford T Justice wrote: » One of the many many loops in one method. The old, lets just bring everything back in an SQL query and work it all out in a controller afterwards.foreach ($aryLineItems as $lineItemKey => $lineItemVal) { $arySelectedSupplierProducts = array(); if (!empty($lineItemVal['LineItem']['line_item_product_id'])) { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "|") !== false) { $aryLineItemProductIds = [B]explode[/B]("|", $lineItemVal['LineItem']['line_item_product_id']); foreach ($aryLineItemProductIds as $lineItemProductQtyId) { if (strpos($lineItemProductQtyId, "::") !== false) { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); } else { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = "1"; } $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } else { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "::") !== false) { $lineItemProductQtyId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } else { $lineItemProductId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductQty = "1"; $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } } if (count($arySelectedSupplierProducts) > 0) { $aryLineItemProducts = $this->Arrangement->LineItem->LineItemProduct->find('all', array( 'recursive' => 0, 'conditions' => array('LineItemProduct.id' => array_keys($arySelectedSupplierProducts)), ) ); $aryLineItems[$lineItemKey]['LineItemSupplierProducts'] = $aryLineItemProducts; $aryLineItems[$lineItemKey]['LineItemSupplierProductsQtys'] = $arySelectedSupplierProducts; } else { if (!empty($lineItemVal['LineItem']['cheque_name'])) { $aryLineItems[$lineItemKey]['LineItemSupplierProducts'][0]['Contact']['company_name'] = $lineItemVal['LineItem']['cheque_name']; } } } $aryData['LineItem'][$sLineItemType] = $aryLineItems; } And lets not forget foreach ($aryLineItems as $lineItemKey => $lineItemVal) { $arySelectedSupplierProducts = array(); if (!empty($lineItemVal['LineItem']['line_item_product_id'])) { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "|") !== false) { $aryLineItemProductIds = explode("|", $lineItemVal['LineItem']['line_item_product_id']); foreach ($aryLineItemProductIds as $lineItemProductQtyId) { if (strpos($lineItemProductQtyId, "::") !== false) { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); } else { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = "1"; } $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } else { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "::") !== false) { $lineItemProductQtyId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } else { $lineItemProductId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductQty = "1"; $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } } if (count($arySelectedSupplierProducts) > 0) { $aryLineItemProducts = $this->Arrangement->LineItem->LineItemProduct->find('all', array( 'recursive' => 0, 'conditions' => array('LineItemProduct.id' => array_keys($arySelectedSupplierProducts)), ) ); $aryLineItems[$lineItemKey]['LineItemSupplierProducts'] = $aryLineItemProducts; $aryLineItems[$lineItemKey]['LineItemSupplierProductsQtys'] = $arySelectedSupplierProducts; } else { if (!empty($lineItemVal['LineItem']['cheque_name'])) { $aryLineItems[$lineItemKey]['LineItemSupplierProducts'][0]['Contact']['company_name'] = $lineItemVal['LineItem']['cheque_name']; } } } $aryData['LineItem'][$sLineItemType] = $aryLineItems; } Only about 3K lines of code like that in one controller
foreach ($aryLineItems as $lineItemKey => $lineItemVal) { $arySelectedSupplierProducts = array(); if (!empty($lineItemVal['LineItem']['line_item_product_id'])) { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "|") !== false) { $aryLineItemProductIds = [B]explode[/B]("|", $lineItemVal['LineItem']['line_item_product_id']); foreach ($aryLineItemProductIds as $lineItemProductQtyId) { if (strpos($lineItemProductQtyId, "::") !== false) { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); } else { $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = "1"; } $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } else { if (strpos($lineItemVal['LineItem']['line_item_product_id'], "::") !== false) { $lineItemProductQtyId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductId = substr($lineItemProductQtyId, 0, strpos($lineItemProductQtyId, '::')); $lineItemProductQty = substr($lineItemProductQtyId, (strpos($lineItemProductQtyId, '::') + 2)); $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } else { $lineItemProductId = $lineItemVal['LineItem']['line_item_product_id']; $lineItemProductQty = "1"; $arySelectedSupplierProducts[$lineItemProductId] = $lineItemProductQty; } } } if (count($arySelectedSupplierProducts) > 0) { $aryLineItemProducts = $this->Arrangement->LineItem->LineItemProduct->find('all', array( 'recursive' => 0, 'conditions' => array('LineItemProduct.id' => array_keys($arySelectedSupplierProducts)), ) ); $aryLineItems[$lineItemKey]['LineItemSupplierProducts'] = $aryLineItemProducts; $aryLineItems[$lineItemKey]['LineItemSupplierProductsQtys'] = $arySelectedSupplierProducts; } else { if (!empty($lineItemVal['LineItem']['cheque_name'])) { $aryLineItems[$lineItemKey]['LineItemSupplierProducts'][0]['Contact']['company_name'] = $lineItemVal['LineItem']['cheque_name']; } } } $aryData['LineItem'][$sLineItemType] = $aryLineItems; }
Buford T Justice wrote: » One of the many many loops in one method. The old, lets just bring everything back in an SQL query and work it all out in a controller afterwards. ... Only about 3K lines of code like that in one controller
Buford T Justice wrote: » One of the many many loops in one method. The old, lets just bring everything back in an SQL query and work it all out in a controller afterwards.Some Code And lets not forget More Code Only about 3K lines of code like that in one controller
Some Code
More Code
Itzy wrote: »
/** * this method is not used. * * @param busEntity Business Entity. * @return null */ @Override public BenefitEntity methodName(final BusinessEntity busEntity) { // Not used return null; }
punk_one82 wrote: » /** * this method is not used. * * @param busEntity Business Entity. * @return null */ @Override public BenefitEntity methodName(final BusinessEntity busEntity) { // Not used return null; } Stuff like this drives me mad, but probably not uncommon at all.
Itzy wrote: » You mean stuffing methods in or leaving a bunch of shít hanging around when it's not needed? Working on Application migration and fault finding and have found way too much unnecessary crap in nearly every file I went through.
Wossack wrote: » Database admin decides he needs to save some space on their sql servers, so goes through C:\windows and deletes all files whose filenames are blue (opposed to normal uncompressed black), thinking that meant they were backed up and redundant. Happy with his work, he scripts it, and runs it across another 23 servers before he cops the first one has keeled over.. and, like stars winking out in the night sky, the rest gradually follow suit
BrokenArrows wrote: » Surely noone can be that stupid.
Capt'n Midnight wrote: » Panda antivirus software labels itself as malware
if (some_var < 0) another_var -= abs(some_var); else another_var -= some_var;
Pov06 wrote: » if (some_var < 0) another_var -= abs(some_var); else another_var -= some_var; Kill me now :eek:
Boskowski wrote: » At least the compiler will sort that out.
Pov06 wrote: » The more worrying part is the fact that a developer with such concepts is working on big projects.
not1but4 wrote: » At the risk of asking a very stupid question what is the issue with this? Is it the case if you where to use a 16 bit integer (range being -32768 to + 32767) You'd get the following; abs(-32767) = 32767 abs(-32768) = -32768
another_var -= abs(some_var);