From: gilberto d. s. a. <gs...@gm...> - 2014-09-10 18:26:18
|
+1 from me. 2014-09-09 21:51 GMT-03:00 Pak Ricard <pak...@gm...>: > Hi all: > > Following on Andrew's POV, we calculate the demand of one item 10 times in > webERP and it takes 94 lines of code (if I'm not wrong). > > I think it is a much readable script if we have a function called > CalculateDemandForItem ($StockId, $Location) and we encapsulate the 94 > lines there. > > Sharing Andrew's <OPINION>, we save 9 * 94 lines of repeated code and we > get a much readable script. > > There are dozens of similar situations in webERP, where I think we can > improve readability and reduce the chances of bugs, as 1 fix fixes all. > > Hope we can find a reasonable point where all feel comfortable. > > Regards, > Ricard > > 2014-09-09 3:48 GMT+08:00 Andrew Galuski <aga...@re...>: > >> Would it be any different if the code was copied into an include >> instead of a function and we replaced the lines of code with >> >> include('includes/tablerow.inc'); >> >> >> >> This is what we do with header.inc and footer.inc. We don’t repeat that >> code in every script (Thank goodness). >> >> >> >> <OPINION> >> >> I think a minimal level of abstraction would make changes less daunting. >> If I know I can concentrate on business logic and not formatting I would be >> willing to make more enhancements. >> >> Enhancements might also be done more quickly, tested faster and be more >> stable. An example is a recent change to introduce location based security >> to WebERP that I submitted. I had seen in the forums multiple times people >> looking to restrict access to locations within a particular business >> function. Example Warehouse worked can see inventory levels at Location A >> but not Location B. In order to make this change I had to modify every >> script where there was a location selection list. >> >> I had to modify the code as follows: >> >> BEFORE: $sql = "SELECT loccode, locationname FROM locations >> >> AFTER: $sql = "SELECT locations.loccode, locationname, canview FROM >> locations >> >> INNER JOIN locationusers ON >> locationusers.loccode=locations.loccode AND locationusers.userid='" . >> $_SESSION['UserID'] . "' AND locationusers.canview=1" >> >> >> >> That line alone appears like 50+ times in 50+ files. The same code to >> build the <select> takes around 15 lines of code before and after that SQL >> that is nearly identical in every script. >> >> If all of that code was in an include file or in a function I could have >> added a feature people requested in less than 1 day instead of 5 days. And >> testing it would have been a lot faster. If the logic is in 1 place I can >> test my change in < 5 screens be confident it is working. If I have to >> change 50 scripts I need to test all 50 scripts…Because even the smallest >> typo can make a script break. >> >> >> >> Abstraction and reduced code can be a good thing >> >> </OPINION> >> >> >> >> Best Regards, >> >> Andrew >> >> >> >> *From:* Phil Daintree [mailto:ph...@lo...] >> *Sent:* Tuesday, September 02, 2014 1:25 AM >> *To:* webERP Developers >> *Subject:* Re: [WebERP-developers] TableRows() >> >> >> >> Ricard, >> >> There are many many ways to reduce the amount of code in webERP - we >> really could take loads out... but the sacrifice is readability - I don't >> believe we would gain speed/efficiency. >> If we made the tables a class as per Jonathan's idea we could take out >> buckets of code - this would be the obvious extension of the >> I don't want to change the code to increase abstraction ever - or code >> that does the same thing a different way that could potentially introduce >> new bugs. Nope - the effort should be not to reinvent what we have, but to >> add functionality using the same blocks and structure as we have. >> >> I believe you learnt php from webERP - and are a living example as to why >> the phil-osophy behind webERP's development style is one of it's greatest >> strengths... >> >> Phil >> >> >> >> Phil Daintree >> >> Logic Works Ltd - +64 (0)275 567890 >> >> http://www.logicworks.co.nz >> >> On 02/09/14 13:12, Pak Ricard wrote: >> >> Hi Phil: >> >> >> >> I saw with satisfaction the commit 6859 where Rafael used the TableRows() >> functions in some scripts. Now, I saw this change was reverted, and I can't >> see but good things about it (probably i'm missing something). >> >> >> >> These same 6 lines are repeated over and over webERP (probably over 100 >> times), so if we get a change to reduce the number of lines and still get a >> readable script, I think it's worth it. >> >> >> >> Well just my 2 cents. I would love to know your POV (and any other >> developer's) about it :-) >> >> >> >> Regards, >> >> Ricard >> >> >> >> >> ------------------------------------------------------------------------------ >> >> Slashdot TV. >> >> Video for Nerds. Stuff that matters. >> >> http://tv.slashdot.org/ >> >> >> >> >> _______________________________________________ >> >> Web-erp-developers mailing list >> >> Web...@li... >> >> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >> >> >> >> >> ------------------------------------------------------------------------------ >> Want excitement? >> Manually upgrade your production database. >> When you want reliability, choose Perforce >> Perforce version control. Predictably reliable. >> >> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk >> _______________________________________________ >> Web-erp-developers mailing list >> Web...@li... >> https://lists.sourceforge.net/lists/listinfo/web-erp-developers >> >> > > > ------------------------------------------------------------------------------ > Want excitement? > Manually upgrade your production database. > When you want reliability, choose Perforce > Perforce version control. Predictably reliable. > > http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk > _______________________________________________ > Web-erp-developers mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > -- gilberto dos santos alves +55.11.98646-5049 sao paulo - sp - brasil |