Coding advice from my coworker (Senior Web-Developer)

As some of you know, I have a coworker who was upgraded to “Senior Developer” 2 years ago… As senior developer you might think he knows how to code and solve problems. Not in this case as you will see soon. This is what happens when the wrong persons get power over other people. And no, even if I was a senior dev myself for years and not in my current company, I don’t want to be a senior there but we have devs that fit better for this position. As a senior dev beside good coding skills you are responsible for the team and for the latter thats what I don’t want (at least not in my current company)

So here we go, here are some of the highlights my senior dev coworker came up with… enjoy. 😉

Using variables in CSS

My coworker recommended us to use php to generate CSS with variables. Something like this:

I said there is something like SASS / LESS… but he got angry and said we will only use technologies that we all know about. Like SASS is something difficult to learn, you can learn it in like 10 minutes… but hey, thats senior developer and he knows what he is talking about. And also he says “I don’t have the time to learn it” (And everybody knows he sits on facebook most of the time)

How to use pagination in PHP?

What he is doing: He creates 2 SQL queries: One for the data (with limit) and another one for getting the count… Depending on the filters, we have 2 big queries that look almost the same. They differ only in the beginning / end, one is selecting the columns and the other one is selecting COUNT(*). If you want to modify the query, you need to modify both queries.

He probably never heard anything about SQL_CALC_FOUND_ROWS.

How to write a framework?

Our senior advices us to NOT use object oriented methodologies. He advices us to use procedual code. And we need to code using only one single “functions.php” file. Everything goes inside this file. Database methods, list generation, email sending… In one project that functions.php reached over 10000 lines of code. It is PAIN in the ass to use in phpStorm as it makes it extremly slow.

And, “as this functions.php file is already used on a project, you will need to use it in all new projects” – yes, even if most of it contains unrelevant stuff for the new apps.

Importing data to database

Senior creates a new table named “*_import_<date>”, eg.: persons_import_2018_01_20. OK… The problem here is that he never deletes these tables after the import. We have a shitload of these tables laying around on our production server. It gets even worse when we need to import the data from our production server to our dev server or make a dump.. we automatically import these long forgotten import tables. I could write a script for importing only the relevant stuff but WHY?.. even our boss is pissed of what he is doing.

Working with Javascript in HTML / PHP files.

As web devs we work with JavaScript a lot. Forget about ES6… we are going deeper… back to 1999. Event handling on html elements: His favorite way to handle events is to throw them into the html tag. Not a bad thing you say? what about multiple lines of javascript in one html tag… But what about the quotes? Uh oh… eeeh, “lets escape them”… oh wait, we need also some php values inside the javascript stuff.

How to use Parameters in Functions?

Lets say you need to write a function where you also have parameters.. OK, cool.. lets write it:

but what should we do if the function takes like 20 parameters?… use array instead of parameters? Sure, thats how it should be done. Or using setters / getters in an object oriented app. But what is doing my lovely coworker?

yepp.. thats how he advices us to work with params. At least it has one optional parameter. 😉

Regex? Regex!

This dude is a regex enthusiast… No matter which project, he prefers to do anything in regex.. even simple search / replace stuff.. regex. You open a project and see preg_match, preg_replace everywhere. Not bad you say? I didn’t care, until lately. I extended a function to remove a string from an email text when there was a special condition. A customer calls me few days later that his emails were empty. After hours of Sherlock Holming I figured out that that asshat is using regex to extract some message parts and replacing it with stuff. But now that I removed a certain part from the mail the email was empty. A sourcecode full with regex is like a dangerous mine. Never overuse regex or you will end up with having an unmaintable project.

TBC… (unfortunately)

Please follow and like me:

One Reply to “Coding advice from my coworker (Senior Web-Developer)”

  1. I knew it was bad… But I didn’t know it was this bad 😅 I honestly feel kinda bad for you 😅😂

    And I was wondering why you guys don’t use frameworks 😂

Leave a Reply

Your email address will not be published. Required fields are marked *