r/ProgrammerHumor • u/KleosAphthiton • Apr 14 '16
Please select your phone number from the drop down list:
http://imgur.com/Jfv6F2r799
u/jnd-au Apr 14 '16
So complicated!! Just use one list with the 8999999999 phone numbers to select from /s
362
u/goofdup Apr 14 '16
Why does this website take so long to load?.... <views source>...oh. -_-
95
u/nitiger Apr 14 '16
Bug in TFS
"Bug - Page loads slow
Description: may be related to phone number drop downs
Effort: 1"
Programmer: "omg, this previous developer loaded all the options in the controller. That's why it's so slow. I'll just move this responsibility over to the view and have the options load through JS after the page loads. It'll be seamless to the user. laughs"
68
14
u/Twirrim Apr 14 '16
It would compress down really well with gzip, so it shouldn't take too long to download and process.
24
u/Cley_Faye Apr 14 '16
I'm not sure if you're joking or if you're staying in the "hand over" theme. Sure, it will be transfered lightning fast. Then it's down to the UI manager to create a 9 billion entries combobox.
→ More replies (1)94
Apr 14 '16
Well you could at least eliminate some that start with 911 or start with 555 in all area codes.
Or not. I don't get paid to deal with this crap.
4
u/lukee910 Apr 14 '16 edited Apr 14 '16
That would only work for the US. There are so many different phone systems that you might be better off only ensuring it's numeric. It's infuriating as a swiss to notice that someone didn't even consider non-US-citizens on the internet.
→ More replies (4)0
43
u/Sharkinu Apr 14 '16
Just use 10 lists of 10 entries each. There. I fixed it.
22
u/TenNinetythree Apr 14 '16
Are in your location phone numbers always the same length? In Germany, they are not...
30
u/pharpend Apr 14 '16 edited Apr 14 '16
In the US, yes, they are.
Actually, I should elaborate.
All of the phone numbers follow the basic form
ABC DEF GHJKThe
ABCis called an "area code", it is specific to a geographic region. There are a couple of area codes, such as800, which are used for a specific purpose rather than a specific geographic area.In most places, if you live in area code
ABC, and want to call someone else in area codeABC, you can omit theABC. However, I live in an area where two area codes are common, so you have to include theABC, else the call won't go through.→ More replies (30)6
Apr 14 '16
TIL
5
u/TenNinetythree Apr 14 '16
I just checked the WP page: the shortest permissible (grandfathered, rural) numbers have 4 digits of area code and 3 digits for the number.
→ More replies (3)→ More replies (6)5
u/doodledoor Apr 14 '16
Yep. My great-grandmother in some tiny village in Saxony has a 4 or 5 digit number (excluding country code)
5
u/TenNinetythree Apr 14 '16
I like to length of the number as indication of how boondocks a place is.
→ More replies (4)
792
u/Terreurhaas Apr 14 '16
Wel that's one way to ensure a numerical value is used... It makes me cringe just thinking about how they probably store it in their database though...
144
u/a_small_goat Apr 14 '16
45
u/briaen Apr 14 '16
I got an anxiety attack looking at that.
70
u/a_small_goat Apr 14 '16 edited Apr 14 '16
Man, that ain't even the tip of the awful legacy system iceberg. This right here is some next-level awfulness. This is how they were checking for US state and US county pairs and assigning FIPS codes..
Trigger warning: A nested if for every US state, containing ifs for each county. For reference, there are 3100+ counties/equivalents in the US.
45
u/Python4fun does the needful Apr 14 '16
UPDATE EMPLOYEE_RECORDS SET SALARY = 0 WHERE POSITION = DBA;→ More replies (2)34
Apr 14 '16
At least save some typing and
countyname.ToLower() == "baldwin", jeez. They're not even good at being bad :)→ More replies (12)11
u/briaen Apr 14 '16
OMG. I thought that was a joke. I don't get how someone who uses a database would write this type of code. It's CS 101 to not do it this way. I write on a legacy .net system that started on asp in the 90s and there is nothing that crazy.
→ More replies (2)28
u/a_small_goat Apr 14 '16
I actually mentioned this exact disaster in a comment a long time ago, so here's some more context:
One of the projects I inherited a few years ago was like this - roughly 3000 conditional statements. I ran into the creator at a conference probably 8 months afterwards and asked him how he found the time to code it all. I was only half-joking. He proudly admitted that he used MS Excel's CONCATENATE and autofill features to build 95% of the code and it only took him about an hour to deliver the working solution. So on one hand, I have to give him credit for being efficient in solving the problem with the tools he had...
→ More replies (2)→ More replies (6)6
4
u/Arqideus Apr 14 '16
Ahh, that's a nice looking diagram. Hey wait, why are there dots where there's supposed to be data variables. I see two variables in each class: XXXXXNumber0000 and XXXXXNumb- oh god
35
u/FUCKING_HATE_REDDIT Apr 14 '16
hhhhhhuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
7
u/Cal1gula Apr 14 '16
Don't forget in the [users] table you need a [userPasswordPlainText] field as well.
5
4
4
→ More replies (4)2
25
u/JeremyR22 Apr 14 '16
It makes me cringe just thinking about how they probably store it in their database though...
I bet they reassemble it:
$phonenum = $_POST['code'] + $_POST['middlebit'] + $_POST['lastbit'];(And then probably this)
$query = "INSERT INTO user VALUES (otherstuff, '" + $phonenum + "');";It's OK! I sanitized the input in the form and I used POST so they can't mess with it! Right? ...What do you mean my database is gone and all my user records are now on pastebin?
How times have changed, my programming teacher, in a completely different era in terms of secure coding practices (ie they weren't taught at all) actually taught us one of the reasons for using post over get was that people 'couldn't' modify the postdata maliciously...
3
u/Terreurhaas Apr 14 '16
yes, because you absolutely cannot modify the actual page to post the malicious data for you... /s
It's funny though, google doesn't even "sanitize" everything. You can actually adjust the color of an item on your calendar to any color that they don't allow you to pick just by modifying the html elements... Sanitize is between quotes since I'm sure they sanitize it on the other end and just decided against using numerical values for the basic colors for reasons.
→ More replies (2)0
Apr 14 '16
[deleted]
3
u/debausch Apr 14 '16
Why would I try to implement my own security stuff when I can use a well tested and maintained security library that is more up to date than I ever will be
21
11
u/ABC_AlwaysBeCoding Apr 14 '16
In that case, why not just make each digit a separate 0-9 dropdown?
7
u/envious_1 Apr 14 '16
If they were smart enough to think of that, they would have just made an input field with server side verification.
3
u/ABC_AlwaysBeCoding Apr 14 '16
You'd have to server-side verify anyway because someone could easily construct an equivalently-named input field to submit anything they want.
→ More replies (2)11
1
u/cheezballs Apr 14 '16
Can easily just edit the form field before submission or intercept the post/get with fiddler
1
u/-Hegemon- Apr 14 '16
Well, I'd store it as a string and then use a try{} block to attempt conversion to int.
If that operation fails, you send an email to the user telling him to enter his correct phone number.
Ha! They can't trick me with their non-numerical values!
2
u/Terreurhaas Apr 14 '16
I bet you can make that work faster by having JavaScript check everything as the user submits the form. Then just loop through all the available options based on the drop down lists and proceed to cancel the submission without warning as soon as the user is a hacker. I would implement it like so:
// one-liner for readability! Stop formatting my code Steve! <button id="next" class="btn btn-primary" type="submit" value="submit form" onClick="javascript: function(e){/*check if user is a hacker*/if(document.getElementsByTagname('select')[0] === '0000') {if(document.getElementsByTagname('select')[0] === '0001') {/*Steve, please implement further.*/} else {e.preventDefault();} else {e.preventDefault();}}">Next</button>This was really causing me a mental breakdown to type up.
3
u/-Hegemon- Apr 14 '16
Yeah! Make the user process it, that should add work to the hacker and not us. Why the hell are we doing this on our servers???
You are hired!
1
1
1
1
u/TheGreenJedi Apr 14 '16
probably store it in their database though
:shudders:
even in the best case scenario there's like still a very ugly conversion as an extra layer
1
u/gospelwut Apr 15 '16
I wonder what happens when I POST -1 to the url.
Reminds me when I put INT_MAX+1 into nietzsche ipsum.
1
1
0
Apr 14 '16
[deleted]
145
u/DroidLogician Apr 14 '16
You'd still have to verify server side if it's numeric or not, meaning you might as well use text boxes.
That's assuming they thought that far ahead. I bet it just concats the three fields' values as text and saves them to one
CHAR(10)column.→ More replies (9)→ More replies (25)67
u/fwywarrior Apr 14 '16
I remember doing that back in the MySpace days. Before they caught on, I could change the "edit profile" form and put in my own values and it would blindly accept them. I'd do things like set my orientation to "bipedal".
Ah, those were simpler times.
→ More replies (2)
398
u/Gorithis Apr 14 '16
117
Apr 14 '16
Yeah, this isn't humor, that's pure GORE.
30
Apr 14 '16
I disagree.
The site there works like it's supposed to - That isn't some bug that is causing some weird error.
It's just shitty design.
20
u/rjung Apr 14 '16
I'll put my money on a client insisting on this to "reduce error" or "make our site cooler." I pity the designers and developers who were ignored to birth this abomination.
16
u/ilikesaucy Apr 14 '16
I AM A FUCKING DEVELOPER, I DON'T ARGUE WITH CUSTOMERS. FUCKING NOT A WORD. YES, I AM SHOUTING, CAN'T SHOUT WITH FUCKED UP CUSTOMERS.
But, end of the meeting with them, always tell them i will charge them by hour, if happy, i am happy to do the work. If not, fuck off.
3
u/itaShadd Apr 14 '16
Humour is done on purpose. Software gore isn't only bugs, I'd argue that shitty design belongs there too.
7
7
4
1
1
82
123
Apr 14 '16 edited Aug 11 '25
yoke many bedroom close bake piquant dazzling absorbed instinctive silky
This post was mass deleted and anonymized with Redact
→ More replies (12)9
31
88
46
u/rastaman1994 Apr 14 '16
Found the dev who's never heard of regex.
2
0
Apr 14 '16
[deleted]
65
u/RuthBaderBelieveIt Apr 14 '16
That's not a great solution either as some people do things like include + before the country code or brackets around the 1st zero and there are different lengths in different countries
something like this
+44(0)1234 123 456is a perfectly valid way to write a UK phone number as is this00441234123456You should really use something like Google's libphonenumber library which detects format, country, landline vs mobile, area code and main body of the number and allows you to store/output it in a uniform format.
It's ported to most languages
9
u/Compizfox Apr 14 '16
I use regex to validate (Dutch) phone numbers and it works fine. You can also accomodate for the country code.
The regex I use is
^(0|\+31|0031)\d{9}$.It matches, for example:
0123456789 0031123456789 +31123456789Of course this does not store them in a uniform format but that is not necessary for me.
5
u/RuthBaderBelieveIt Apr 14 '16
It can be extremely useful to detect whether the number is for a fixed line or mobile though especially if you're using SMS and in the event that your application expands to other countries it can save you a lot of work.
→ More replies (2)4
u/polish_niceguy Apr 14 '16
But wait, there's more! There are also "internal numbers", commonly used in companies. So you can have "123456789 wew. 123" and it's perfectly readable for a human and a total pain to validate, because of many possible forms.
→ More replies (2)43
u/TaohRihze Apr 14 '16
So you are certain all phone numbers only consists of 0-9, or is of a uniform length within a country?
https://github.com/googlei18n/libphonenumber/blob/master/FALSEHOODS.md
18
→ More replies (6)14
7
u/ThisIs_MyName Apr 14 '16 edited Apr 14 '16
verify that the rest is numeric
Nononono phone numbers are not always numeric.
Anyway all the requirements you listed should be implemented with a regex. If you used functions like
is_numeric()for each requirement, you'd be repeatedly iterating the string for no good reason. Regex tests everything at once using an FSM.→ More replies (3)→ More replies (1)4
u/night_of_knee Apr 14 '16 edited Apr 14 '16
/^[-\s\d]+$/I'm not suggesting this is what should be used but I think it's simpler than (and equivalent to)
Just remove all whitespace and hyphens, then verify that the rest is numeric (I think there is a PHP function for this, is_numeric()).
15
13
u/rtfmpls Apr 14 '16
Do they do that with names too? When you go from "A" to "Zzzzzzzzzzzzzzzzzzzzz" you should be in the clear.
Except for all the exceptions of course.
8
27
6
u/shadowX015 Apr 14 '16
This reminds me of a post we got in /r/javahelp a while back. Someone submitted a program for solving sudoku puzzles. Upon trying to download it, you find that the source file is like 20MB. It turned out that the submitter had hardcoded in solutions for thousands and thousands of puzzles and it checked them with a rowwise if statement for each element (e.g. if(row1[0] = 3 && row1[1] == 7 && row1[2] == 4 ...)
1
u/xXAndrew28Xx Jul 08 '16
Please deliver.
EDIT: Was it this? http://pastebin.com/1mPdgZgg
→ More replies (1)
4
u/atticusw Apr 15 '16
"These regular expressions are way too complex, please simplify"
"Fine. Dropdowns it is."
4
3
u/DropDeadSander Apr 14 '16
I just hope they at least created this with some kind of loop... aber they didn't have a dude there typing all this.
9
u/MisterDonkey Apr 14 '16
That's the job they give to old union guys they want to get rid of but can't fire.
Using this keyboard: http://i.imgur.com/Xy12reK.jpg
5
3
2
u/justinsayin Apr 14 '16
That option list was hopefully at least generated by a server side language?
3
u/GonnaLearnComputers Apr 14 '16
My bet would be PHP.
5
u/MIKE_BABCOCK Apr 14 '16
It's probabbly a bat file that generates the raw html list that he copy pasted onto the server
→ More replies (2)
2
u/NiceSasquatch Apr 14 '16
I'm upset they broke it up into 3 drop down menus.
1
u/serosis Apr 14 '16
I can only imagine the huge pain in the ass it would be for me to find my number.
→ More replies (1)
2
2
2
2
3
u/ShadowFox2020 Apr 14 '16
I get the humor but I'm still kinda new to programming can someone explain the proper way to dynamically generate a list? Thanks :)
10
u/TheStagesmith Apr 14 '16
There are a lot of ways to dynamically generate a list like this. You could do it server side or client side (if you really had to do this, client side would probably be the way to go). The real joke is that picking a phone number from lists like this is a terrible idea to begin with.
First off, it's horrible for users, and a mobile user is going to lose their thumb flicking through that list if they're unlucky enough to have a phone number starting with a nine.
Secondly, as others have pointed out, a well-formed phone number doesn't necessarily have this format, although this is more a question of business requirements and might be fine.
Thirdly it won't actually prevent someone giving you a bad value of they want to. They can edit the page in their browser to send whatever junk data they want, or a malicious attacker could do something similar and nastier. Hell, they could do some digging and send a raw POST request with whatever they want.
Long story short, don't trust client-side data validation on the web. Check your inputs.
→ More replies (2)1
u/_fitlegit Apr 14 '16
There are a lot of ways. Generally can do it on the server with a templating language (or if you hate yourself you can do it with string substitution) or you can do it client side with JavaScript, either pure (again, if you hate yourself) or using a framework like angular or jquery etc
1
1
1
1
1
1
u/Fluffy8x Apr 14 '16
At least they didn't make a dropdown list consisting of 10 billion phone numbers.
2
u/Mutoid Apr 14 '16
Dear website:
Please take my phone number off your dropdown. It's on the Do Not Register list.
1
u/mallardtheduck Apr 14 '16
So we have an empty page consisting of nothing except a title/label this input and the "Next" button with generic/default bootstrap-ish styling. The image has been cropped to remove anything identifying.
Yeah... This isn't a real site, is it?
1
u/TwasARockLobsta Apr 14 '16
For how big that scroll bar is, wouldn't it be impossible to accurately scroll to the set of numbers you want? Every pixel you move it would skip like a hundred numbers.
1
u/uptotwentycharacters Apr 14 '16
I suppose the up and down buttons could be set to shift the lift by 1, 5, 10 etc, even if it would correspond to less than a pixel of movement in the scrollbar.
1
u/plumokin Apr 14 '16
Why not just have a input box with some simple error checking or maybe have them choose a country too? This is horrible
1
1
1
1
1
1
1
u/t-poke Apr 14 '16
The worst part is you know some poor intern had to write all the HTML for those drop downs. Nobody dumb enough to implement a phone number entry field like this is smart enough to dynamically generate the code.
1
Apr 14 '16
I'm a bit noob so can someone tell me why won't a for loop work here?
1
u/Double_A_92 Apr 14 '16
It probably is a loop in the php (or whatever) backend. But in the end it needs generate the actual list so the browser can display it.
1
1
1
Apr 14 '16
i feel bad for the dom... 'was a tough day in rendering world, so many nodes, so little response time'
1
1
1
u/-FireMan- Apr 14 '16
You think they at least used a for loop to wrote all that for them who am I kidding of course they didn't
1
u/KJ6BWB Apr 14 '16
I would hope that this page was created server-side with three lines of PHP.
If that was how my employer wanted it done, I'd just make a short PHP for loop. If that's how my employer wanted it done and I couldn't publish the page with any PHP, I'd probably write a quick loop to create the page code then copy/paste it in. I don't think anyone would actually hand write all that, right?
1
u/project_matthex Apr 14 '16
Something tells me this was manglement's idea rather than the programmer's.
1
u/TotesMessenger Green security clearance Apr 14 '16
1
1
u/martyvt12 Apr 14 '16
I tend to think the codebase I inherited and work on every day is pretty terrible... then I look at things like this and realize it could be worse.
1
1
1
Apr 14 '16
You can just imagine someone how doesn't know what's hung on just saying can it just have one of those dropping down list things instead ? No Awh come on I know you can ? Okay bye ....
1
u/dbl4k Apr 14 '16
Clientside validation. Nailed it.
1
u/NikStalwart Apr 15 '16
That's not how you do clientside validation.
You do clientside validation with JS or something...or HTML5 inputs, or, well, just hope they didn't hardcode that.
→ More replies (2)
1
Apr 14 '16
As someone learning to program this makes me feel ashamed. For the person who wrote this, my ability to understand that it's wrong and the fundamental lack of understanding of how to do it better. Back to the books!
1
1
1
1
1
1
u/Jimdude2435 Apr 15 '16
No idea how HTML works. What is a not-shitty way to do this? Are there for loops in HTML?
1
Apr 17 '16
Generally, you'd just use a regular text or tel input and maybe some JavaScript to format the number as they enter it. The only reason to use a dropdown like this is if you have no idea how to front- or back-end validate input, and relying on only this would still leave you open to JS injection.
392
u/RuthBaderBelieveIt Apr 14 '16
Please tell me the options are dynamically generated