From: Pak R. <pak...@gm...> - 2014-09-09 04:31:29
|
Hi Phil: Sorry I didn't understand. Is it finally OK to use functions / includes as in the case of TableRows()? If so, when should we use include or function? Also, I found Tim's proposal for PrintARowOfTable() a really interesing one. I'm particularly lost with html (which is way more cryptic than PHP), so, if we can encapsulate some highly used part of code (as printing a row of a table), I would be really happy. I also think, the shorter the code, the easier it is to understand, if all functions have a clear and long enough name. Regards, Ricard 2014-09-09 9:24 GMT+08:00 <ph...@lo...>: > Preferable for really high use code as the user knows where to find it. > I like to keep includes to a minimum too though. Some repetition of the > code is a consequence ... I accept this of course. > > Phil > > On 2014-09-08 13:48, Andrew Galuski wrote: > > 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 [3] > > > > 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/ [1] > >> > >> _______________________________________________ > >> > >> Web-erp-developers mailing list > >> > >> Web...@li... > >> > >> https://lists.sourceforge.net/lists/listinfo/web-erp-developers [2] > > > > > > > > Links: > > ------ > > [1] http://tv.slashdot.org/ > > [2] https://lists.sourceforge.net/lists/listinfo/web-erp-developers > > [3] http://www.logicworks.co.nz > > > > > ------------------------------------------------------------------------------ > > 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 > |