(03-05-2014, 01:40 PM)Exsonqu_Qu Wrote: [ -> ]webERP has 4 goals to keep. The introduction of class View at least broken 2 of them---Keep webERP fast and make it readable and modifiable for business man (IMHO).
webERP try to avoid abstract whenever possible since it add overhead and make the logic not so clear. Moreover, it also a overhead for some businessman to learn it.
Hi Exson,
I am not sure why you think the view classes will have an impact on performance. I agree jquery does, but do not see why you think the view classes themselves will.
Readability is an incredibly subjective thing. We all believe our own work (whether its code, prose, or rhyming couplets) to be the most readable. Because we wrote it, we intuitively understand exactly what it means.
Here is the account sections data using the new table view class:
while ($myrow = DB_fetch_array($result)) {
$tablerow = array();
$tablerow[] = $myrow['sectionid'];
$tablerow[] = $myrow['sectionname'];
$editRow['content'] = _('Edit');
$editRow['link'] = htmlspecialchars($_SERVER['PHP_SELF'] . '?SelectedSectionID=' . urlencode($myrow['sectionid']), ENT_QUOTES, 'UTF-8');
$tablerow[] = $editRow;
if ($myrow['sectionid'] == '1' or $myrow['sectionid'] == '2') {
$tablerow[] = '<b>' . _('Restricted') . '</b>';
} else {
$delRow['content'] = _('Delete');
$delRow['link'] = htmlspecialchars($_SERVER['PHP_SELF'] . '?SelectedSectionID=' . urlencode($myrow['sectionid']) . '&delete=1', ENT_QUOTES, 'UTF-8') . '&delete=1';
$tablerow[] = $delRow;
}
$accountSectionsTable->addRow($tablerow);
} //END WHILE LIST LOOP
and here using the current code:
while ($myrow = DB_fetch_array($result)) {
if ($k==1){
echo '<tr class="EvenTableRows">';
$k=0;
} else {
echo '<tr class="OddTableRows">';
$k++;
}
echo '<td>' . $myrow['sectionid'] . '</td><td>' . $myrow['sectionname'] . '</td>';
echo '<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'] . '?SelectedSectionID=' . urlencode($myrow['sectionid']), ENT_QUOTES, 'UTF-8') . '">' . _('Edit') . '</a></td>';
if ( $myrow['sectionid'] == '1' or $myrow['sectionid'] == '2' ) {
echo '<td><b>' . _('Restricted') . '</b></td>';
} else {
echo '<td><a href="' . htmlspecialchars($_SERVER['PHP_SELF'] . '?SelectedSectionID=' . urlencode($myrow['sectionid']) . '&delete=1', ENT_QUOTES, 'UTF-8') . '">' . _('Delete') . '</a></td>';
}
echo '</tr>';
} //END WHILE LIST LOOP
Which is more readable? Well I guess if you asked around some would say the first, others will say the second. It's a very subjective thing.
I think the first thing to do is to put programming jargon such as mvc etc out of your mind, and concentrate on the code. The view class certainly makes the creation of data tables easier and in a more standard way, but the trade off is a level of abstraction (remember we already have lots of abstraction in webERP).
Tim