Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Development
Flashback PHP - A Habbo CMS written in vanilla PHP
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Markshall" data-source="post: 465300" data-attributes="member: 1872"><p>I understand you. I just feel as the application grows and other parameters are required, it gets hard to keep track of which should be in which order. With an array of dependencies for example, you can pass them in any order. I’m not suggesting creating the constructor method and only have 1 parameter be the dependency array, I’m suggesting that if he needs to pass in 7 parameters, 4 of which being dependencies, then perhaps passing 3 parameters and the array of dependencies would be a better and tidier option.</p><p>I try to follow a convention of where there are more than 4 parameters required to a method, then passing via object/array is better and tidier.</p><p>[code=php]$User->userLogin($username, $password, $hash, $redirectUrl, $DBclass, $anotherClass, $anotherClassAgain);[/code]</p><p>...vs...</p><p>[code=php]$User->userLogin($username, $password, $hash, $redirectUrl, [</p><p> 'db' => $DBclass,</p><p> 'anotherClass' => $otherClass,</p><p> 'anotherClassAgain' => $anotherClassAgain</p><p>]);[/code]</p><p></p><p>No problem. I kind of went beyond the scope of what you were asking. Guess I just got carried away with what I was typing as I was going along lol.</p><p>Good luck with your project nonetheless. Would be cool to see it on GitHub either way.</p></blockquote><p></p>
[QUOTE="Markshall, post: 465300, member: 1872"] I understand you. I just feel as the application grows and other parameters are required, it gets hard to keep track of which should be in which order. With an array of dependencies for example, you can pass them in any order. I’m not suggesting creating the constructor method and only have 1 parameter be the dependency array, I’m suggesting that if he needs to pass in 7 parameters, 4 of which being dependencies, then perhaps passing 3 parameters and the array of dependencies would be a better and tidier option. I try to follow a convention of where there are more than 4 parameters required to a method, then passing via object/array is better and tidier. [code=php]$User->userLogin($username, $password, $hash, $redirectUrl, $DBclass, $anotherClass, $anotherClassAgain);[/code] ...vs... [code=php]$User->userLogin($username, $password, $hash, $redirectUrl, [ 'db' => $DBclass, 'anotherClass' => $otherClass, 'anotherClassAgain' => $anotherClassAgain ]);[/code] No problem. I kind of went beyond the scope of what you were asking. Guess I just got carried away with what I was typing as I was going along lol. Good luck with your project nonetheless. Would be cool to see it on GitHub either way. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Development
Flashback PHP - A Habbo CMS written in vanilla PHP
Top