? ? Success

User tests: Successful: Unsuccessful:

avatar wilsonge
wilsonge
21 Apr 2014

One way that we could dynamically create a table and key for getting an instance without needing to set up your own JTable class

avatar wilsonge wilsonge - open - 21 Apr 2014
avatar wilsonge wilsonge - change - 21 Apr 2014
Title
Example of new Table stuff
Play around with a way for creating JTable class
avatar wilsonge wilsonge - change - 21 Apr 2014
Title
Example of new Table stuff
Play around with a way for creating JTable class
Labels Added: ? ?
avatar wilsonge wilsonge - change - 21 Apr 2014
Title
Play around with a way for creating JTable class
[RFC] Play around with a way for creating JTable class
avatar wilsonge wilsonge - change - 21 Apr 2014
The description was changed
Title
Play around with a way for creating JTable class
[RFC] Play around with a way for creating JTable class
Description <p>One way that we could dynamically create a table and key for getting an instance without needing to set up your own JTable class</p>
avatar brianteeman brianteeman - change - 21 Aug 2014
Status New Pending
avatar nicksavov nicksavov - change - 21 Aug 2014
Labels Removed: ?
avatar brianteeman brianteeman - change - 2 Sep 2014
Category Libraries
avatar brianteeman
brianteeman - comment - 6 Mar 2015

@wilsonge This is almost 1 year old with absolutely no comments at all (probably because of the complete lack of any meaningful explanation) can this just be closed


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/3483.
avatar brianteeman brianteeman - change - 6 Mar 2015
Status Pending Information Required
avatar wilsonge
wilsonge - comment - 6 Mar 2015

Ahh it was part of an RFC in https://groups.google.com/forum/#!searchin/joomla-dev-cms/table/joomla-dev-cms/AiCOgamjQvQ/yHw_QC4JfM4J which is why explanations are poor. It's a developer feature rather than a user feature. So testing is also pretty hard.

avatar brianteeman
brianteeman - comment - 6 Mar 2015

especially without any description;)

So can it be closed?

On 6 March 2015 at 00:43, George Wilson notifications@github.com wrote:

Ahh it was part of an RFC in
https://groups.google.com/forum/#!searchin/joomla-dev-cms/table/joomla-dev-cms/AiCOgamjQvQ/yHw_QC4JfM4J
which is why explanations are poor. It's a developer feature rather than a
user feature. So testing is also pretty hard.


Reply to this email directly or view it on GitHub
#3483 (comment).

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar wilsonge
wilsonge - comment - 6 Mar 2015

Please don't. I just need the time to reraise it. There were a few recommendations that I had that need tweaking as well.

avatar zero-24 zero-24 - change - 3 May 2015
Labels Added: ?
avatar johanjanssens
johanjanssens - comment - 8 Jul 2015

@wilsonge

It's great to see ideas that I implemented in the very first versions of Nooku making their way into the core. The goal of Nooku has always been to allow developers to do more with less code.

Remarks

  1. Remove the coupling with the FOF::Inflector(). If the Joomla inflector cannot handle what you need it to do, it would be better to optimise the Joomla\String\Inflector. This also reduced dependency on FOF.

  2. The logic you added to find the table name and keyname belongs in the constructor of JTable, not in JTable::getInstance(). getInstance() is a factory method it's sole purpose following the 'factory method design pattern' is to discover the classname and instantiate the object. Configuration of the object should happen during object construction, not before.

Other then that the code suggested is a good addition and will make it easier to instantiate table objects on the fly for any database table that follows naming conventions. It also helps to establish conventions for developers.

Background

The concept you use here is what I did in very early versions of Nooku back in 2007. I further improved upon this by making the objects aware of their own identity using the information in the classname. In early versions (today this has evolved into a Identifier metaobject) of Nooku each object had a getIdentifier() method that returns component name and object name, for example

FooTableBars 

Would return

$component = $this->getIdentifier()->component; -> foo
$type            = $this->getIdentifier()->type; -> table
$name          = $this->getIdentifier()->name -> bars

Based on that information you can then easily create the table name and primary key.

table = '#__'.$component.'_'.$name
key   = '#__'.$component.'_'.toSingular($name)

A getIdentifier() could be implemented using a Trait, which would make it easy to retrofit the codebase and slowly bring in naming based conventions as you did here for table names.

Final note, the primary key is merely a naming convention, you can get the primary key information from the database table metadata too.

avatar roland-d roland-d - change - 20 Aug 2015
Category Libraries Feature Request Libraries
avatar roland-d
roland-d - comment - 8 Nov 2015

Hello @wilsonge

Thank you for your contribution.

The last comment here was on July 8th. So the question is, Are you planning to work on this in the near future? If not, please close and re-open when you are ready to work on it.

If no reply is received within 4 weeks we will close this issue.

Thanks for understanding!

avatar wilsonge wilsonge - change - 8 Nov 2015
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2015-11-08 17:40:09
Closed_By wilsonge
avatar wilsonge wilsonge - close - 8 Nov 2015
avatar wilsonge wilsonge - close - 8 Nov 2015
avatar wilsonge wilsonge - head_ref_deleted - 8 Nov 2015

Add a Comment

Login with GitHub to post a comment