div: discuss browserSession

View: New views
4 Messages — Rating Filter:   Alert me  

div: discuss browserSession

by Franz Holzinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

there is a function browserSession in div:

function browserSession($key, $value = NULL) {
        if($value != NULL)
                $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value);
        return $GLOBALS['TSFE']->fe_user->getKey('ses', $key);
}

Do you consider this as a good style to use a function for setting as
well as getting a value?
IMHO this is rather hard to follow. I would prefer to have setter and
getter functions for all kind of things.

function setBrowserSession

function getBrowserSession



- Franz
_______________________________________________
TYPO3-team-extension-coordination mailing list
TYPO3-team-extension-coordination@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-extension-coordination

Re: div: discuss browserSession

by Bastian Waidelich-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Franz Holzinger wrote:

Hi Franz,

> Do you consider this as a good style to use a function for setting as
> well as getting a value?

Not really. One method should only be doing _one_ thing.

> I would prefer to have setter and
> getter functions for all kind of things.

Yes, much clearer IMHO!

Basti
_______________________________________________
TYPO3-team-extension-coordination mailing list
TYPO3-team-extension-coordination@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-extension-coordination

Re: div: discuss browserSession

by Daniel Bruessler-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Franz and Bastian,

yes, getters and setters are standard. This little bit overhead helps
much in understanding, using and testing.

Cheers!
Daniel


>> Do you consider this as a good style to use a function for setting as
>> well as getting a value?
>
> Not really. One method should only be doing _one_ thing.
>
>> I would prefer to have setter and
>> getter functions for all kind of things.
>
> Yes, much clearer IMHO!
>
> Basti
_______________________________________________
TYPO3-team-extension-coordination mailing list
TYPO3-team-extension-coordination@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-extension-coordination

Re: div: discuss browserSession

by omic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Consider also this code:

tx_div::user()->setKey('ses',$key,$value);

Or:

tx_div::session($key,$value); //setter
tx_div::session($key); //getter


Franz Holzinger a écrit :

> Hello,
>
> there is a function browserSession in div:
>
> function browserSession($key, $value = NULL) {
> if($value != NULL)
> $GLOBALS['TSFE']->fe_user->setKey('ses', $key, $value);
> return $GLOBALS['TSFE']->fe_user->getKey('ses', $key);
> }
>
> Do you consider this as a good style to use a function for setting as
> well as getting a value?
> IMHO this is rather hard to follow. I would prefer to have setter and
> getter functions for all kind of things.
>
> function setBrowserSession
>
> function getBrowserSession
>
>
>
> - Franz
_______________________________________________
TYPO3-team-extension-coordination mailing list
TYPO3-team-extension-coordination@...
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-team-extension-coordination