Page 4 of 4

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:01 am
by rph
affect wrote:
Out of curiosity, why do you think this is an issue? The only time I can see this adding work is if you want to make a change outside the extension.
Not really outside, mostly when splitting module config into parts. Let's say I have a module that has multiple logical configuration parts, for example it has some configuration variables, positions (layouts) and beside that it lists and allows adding/removing records from the database.
Why not just break it into tabs like OpenCart does for products or store settings?

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:16 am
by SapporoGuy
I don't think that this idea is about layout but rather how the database is actually setup (not sure if this is the right word).

[setup? designed?
Basically trying to find the word that describes how you actually decide what database type and if use indexes, and/or foreign keys.]

Something like this comes across as very minor and actually non-relevant in most cases but this is being caused by a much larger issue of how the mysql db class and database is designed.

However, I can see that fixing this would be a huge undertaking! Thereby, loosing the ability to replace is a very fair trade off.

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:27 am
by JAY6390
The word you're looking for is database SCHEMA

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:32 am
by SapporoGuy
ugh!

Thanks! 8)

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:35 am
by Qphoria
yea.. universal model functions would be good

Code: Select all

function updateTable($table, $column, $value, $clause) {
    $this->db->query("UPDATE " . DB_PREFIX . "$table SET `" . $column . "` = '" . $value . "' WHERE " . $clause);
}

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:35 am
by affect
rph wrote:Why not just break it into tabs like OpenCart does for products or store settings?
Actually I haven't looked at how tabs are coded yet, but that might be a great idea (if it doesn't split the module into even more files. It was a pain for me coding modules in the OC mvc+l way, actually, got used to Presta's way of separating modules from the core architecture and making it available to put all belonging files in one folder).

I'll check tabs out when I return from my trip next week, thanks.

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:36 am
by JAY6390
Tabs are one file, with the content of each tab in <div>'s generally

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:38 am
by Qphoria
tabs are just dhtml ocular trickery
its really just one single page and one single form

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:40 am
by SapporoGuy
Tabs will help you organize your pages better, but I don't seem to recall them being individual entities within the main section. So, you still need to do delete and add.

MVC vs monolithic is another topic on it's own.
Personally, monolithic is like php3 :bang:
However, a monolithic structure does allow you to do plugins relatively easy. But then again, this can be done with MVC if the bootstrapper/main controller was built that way.

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:48 am
by affect
Personally, monolithic is like php3
However, a monolithic structure does allow you to do plugins relatively easy. But then again, this can be done with MVC if the bootstrapper/main controller was built that way.
Yep, that's kind of how it's done in Presta. Modules are still mvc-like, although the files are stored in a same folder which makes it easy to develop and add/delete. Really convenient.

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 3:54 am
by Qphoria
affect wrote:
Personally, monolithic is like php3
However, a monolithic structure does allow you to do plugins relatively easy. But then again, this can be done with MVC if the bootstrapper/main controller was built that way.
Yep, that's kind of how it's done in Presta. Modules are still mvc-like, although the files are stored in a same folder which makes it easy to develop and add/delete. Really convenient.
Agreed, hence my restructure proposal in OpenCart 2.0
http://forum.opencart.com/viewtopic.php?t=28787

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 5:59 am
by rph
The problem with that is it pretty much kills any practical sharing of functions. You'd end up putting duplicate code in all over the place.

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 18, 2011 12:00 pm
by Qphoria
rph wrote:The problem with that is it pretty much kills any practical sharing of functions. You'd end up putting duplicate code in all over the place.
Well this doesn't really cover core libraries, only had Extensions in mind for this. Extensions are self-contained anyway. If it is done right, extensions would not even be in the same area as core libraries and they could be structured however they like.

And don't get me started on duplicate code..considering the mess of dupe code we have already. Trust me that's the last thing I want.

Re: Coding Standards Improvement Proposal

Posted: Thu Aug 25, 2011 10:35 pm
by boriscm
Hi,

Was thinking about the OpenCart release cycle, and i think this model would greatly benefit the process.

HotFixes are go :)


http://nvie.com/posts/a-successful-git-branching-model/
https://github.com/nvie/gitflow

What u guys think?
Greetings
boriscm

Re: Coding Standards Improvement Proposal

Posted: Wed Aug 31, 2011 4:30 pm
by daemonsy
Hi guys,

Sorry I'm a new programmer trying to write my own modules. I'm trying to learn more about Opencart's setting table and saw this line of code.

Code: Select all

	$this->db->query("DELETE FROM " . DB_PREFIX . "setting WHERE store_id = '" . (int)$store_id . "' AND `group` = '" . $this->db->escape($group) . "'");

	foreach ($data as $key => $value) // Code for inserting continues here.
I don't know if I understood the code correctly. Does this mean that everytime you save the settings, the old settings are deleted before the new settings are entered?

Is there a possibility that this will cause a scenario where after the delete is done, the insert fails due to some reason and you lose the settings?