During all study in high school and university I always has been developing a projects. This article is about the most fun my mistakes in them.
webMCRex
webMCRex was the first my product, that found some popularity. During three years of development it got a lot of places for which I am ashamed so far.
Interlayer database class
It was happend when PHP 5.4 came on a lot of hostings and appeared a deprecation warning for function mysql_connect()
, that born a code that looks like:
1 | class DB { |
It breaks the Open Closed Principle of popular SOLID pattern.
Really I’m not a fun of following any rules, but SOLID is basic ruleset and I have no idea about any reason to break it.
If do not think about any reason to create this class, this code anyway sucks.
This code was reused in Metrostroi Database and IssueTracker.
In my defence I’ll say that I had a very bad knowledge about inheritance in PHP, but if do that, more correct will be approach with parent interface and two separate child classes for each connection type.
1 | interface DBProvider { |
WorldsOfCubes
Appearing six months earlier webMCRex, that project has survived a lot.
It was started as an OpenID for Minecraft servers websites and bring players availability to use a one account with skin/cloack for any server.
This project came too late and had no benefits for server admins to use it, that killed it a time later.
Security through obscurity
WoCAuth had a problem: I had no idea how to protect a login agreement page from imitating user actions. So, I added a token that created in this way:
1 | $token = md5(md5($player . $proj['security_key'])); |
That idea sucks, yeah
Metrostroi
Metrostroi site was the first my project that was developed completely by me.
Same auth tokens for different users
Auth was saved with special tokens that was generated as a random string of 128 chars:
1 | $sessionID = Base::randString(128); |
Token was refreshed after any paage load, that brought a big probability of tokens coincidence for different users.
A small time later we stopped token refresh, but that problem stilled unresolved.
it was resolved with an easy way:
1 | $sessionID = $player->steamid . "_". Base::randString(100); |
A lesson: think about random like it makes same result any time
ROFLs in a code
When all was just started I worked in a fun.
In that time in code appeared variables $tox1n_lenvaya_jopa
(from russian: tox1n is a lazy ass), $typical_ple
(from Pleigox, nickname of an one strange player)
or that checks:
1 |
|
That was very unprofessionally. And long names made a work with project a bit harder
So, what I want to tell…
A start of my work was full of code that I am ashamed. But it gave me a lot of unique experience about what I should not to do.
Do not be afraid to make a shitcode - it make you an experience.
It is important to stop writing it in future. And this is not easy.
Alas, even among experienced programmers there are those that ship the shit with cisterns. And that is very bad.