The PHP 7 Revolution: Return Types and Removed Artifacts

Way to completely ignore people’s valid criticism. You have all of the experienced programmers here saying your code is poor quality. Objectively it is, it is full of bad practices… not all security but it’s needlessly difficult to maintain. The length of your methods is a serious indicator of problems without even digging deeper[1][2][3][4]. On inspection, it’s quick to see that your code is mixing all kinds of irrelevant logic as pointed out by Jeff Mott earlier. It mixes several concerns that really shouldn’t be. Let’s quickly deconstruct: http://pastebin.com/ujpUuN1r

 $GLOBALS['task_id'] = 'logoff';

There is not even potential for debate about global variables[5][6][7][8][9][10][11][12] so this is an instant and serious red flag.

RDCsingleton::getInstance('mnu_control');

The same is true of singletons[5][13][14][15][16] so that’s another serious design flaw… and we’re only a few lines in!

$this->skip_validation

Presumably the skip_validation property is in the parent class. Inheritance breaks encapsulation[17][18]. While a much more minor infraction than singletons and global state it’s still badly designed code.

if (is_True($external_auth_off)) {

You actually have a function called is_True? Redundant and pointless. I was going to carry on but I feel the more nuanced flaws will go over your head. Many of my second year students would have been able to identify several flaws in this code.

I’ll leave you with this: Ignoring the security flaws and bad practices. It’s impossible to reuse any of that code and use a postgre or mssql database. It’s also impossible to make your login class use OAUTH or similar. It’s inherently inflexible and difficult to change.

Claiming “experience” and “seniority” in your posts above and then admitting to authoring code like this instantly negates any claim you have surrounding skill and understanding.

[1] Fowler, M (2006) CodeSmell, http://martinfowler.com/bliki/CodeSmell.html
[2] Hevery, M (2008) Flaw: Class Does too Much. http://misko.hevery.com/code-reviewers-guide/flaw-class-does-too-much/
[3] Bryton, Sérgio, Fernando Brito e Abreu, and Miguel Monteiro. (2010) Reducing Subjectivity in Code Smells Detection: Experimenting with the Long Method. Quality of Information and Communications Technology (QUATIC), 2010 Seventh International Conference. IEEE.
[4] Carneiro, F., G., Silva, M., Mara, L., Figueiredo, E., Sant’Anna, C., Garcia, A., & Mendonça, M. (2010). Identifying code smells with multiple concern views. In Software Engineering (SBES), 2010 Brazilian Symposium on(pp. 128-137). IEEE.
[5] Sayfan, M (n.d.) Avoid Global Variables, Environment Variables, and Singletonshttps://sites.google.com/site/michaelsafyan/software-engineering/avoid-global-variables-environment-variables-and-singletons
[6] Hevery, M (2008) Flaw: Brittle Global State & Singletons. http://misko.hevery.com/code-reviewers-guide/flaw-brittle-global-state-singletons/
[7] IBM (2012) Avoid modification of global and static variables http://www-01.ibm.com/support/knowledgecenter/SSGU8G_11.70.0/com.ibm.dapip.doc/ids_dapip_0673.htm
[8] Koopman, P (2010) Better Embedded System Software. ISBN: 978-0-9844490-0-2. Drumnadrochit Education LLC.
[9] Svennervberg, G (2012) Global Variables Are Evil http://codecraftingblueprints.com/global-variables-are-evil/
[10] Zakas, N (2006) Global Variables Are Evil http://www.nczonline.net/blog/2006/06/05/global-variables-are-evil/
[11] Ferreira, G (2013) Best C Coding Practices – Global variables http://guilhermemacielferreira.com/2013/06/01/best-c-coding-practices-global-variables/
[12] Crockford, D (2006) Global Domination http://www.yuiblog.com/blog/2006/06/01/global-domination/
[13] Densmore, S (2004) Why Singletons are Evil http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140827.aspx
[14] Radford, M (2003) SINGLETON - the anti-pattern! http://accu.org/index.php/journals/337
[15] Yegge, S (2004) Singleton Considered Stupid https://sites.google.com/site/steveyegge2/singleton-considered-stupid
[16] Hevery, M (2008) Singletons are Pathological Liars http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/
[17] Gamma, E., Helm, R., Johnson, R., Vlissides, J. Design Patterns: Elements of Reusable Object-Oriented Software. ISBN: 0201633612. Addison Wesley. P.19-20
[18] Bloch, J Effective Java. ISBN: 0321356683

1 Like