|
.....wat!?
(04-01-2011, 02:37 PM)
|
#101
I was once forced by design specs to do the following:
function int doSomething(int enableOption) { if (enableOption == 0) optionEnabled; } Why the fuck would someone design something such that 0 = true?!!?! Especially in C++ where NULL == false == FALSE == 0. Thing I hate most about my current job is the fact that higher ups want everything done yesterday which means half the things we do are temporary 'hacks' which work perfectly but make absolutely no sense. Maintainability, as expected, is now a nightmare. :( |
|
|
|
Member
(04-01-2011, 02:39 PM)
|
#102
Originally Posted by ronito:
|
|
Member
(04-01-2011, 02:39 PM)
|
#103
Originally Posted by ronito:
|
|
Corporate Apologist
(04-01-2011, 03:53 PM)
|
#104
While not the right topic, I figure someone should know the answer.
How would I use both an 'and' and a 'or' in a single while loop in C, or can I? Something along the lines of Code:
While (struct != NULL && (strcmp(FirstName,struct->First) || strcmp(LastName,struct->Last))) |
|
Scary Euro Man
(04-01-2011, 03:57 PM)
|
#105
Originally Posted by ThoseDeafMutes:
|
|
Member
(04-01-2011, 04:00 PM)
|
#106
Originally Posted by nickcv:
Also just got new desktops and triple displays to replace our ageing laptops. Quite novel having visual studio on one screen, SQL server 2008 on one and your web app on the third. |
|
Member
(04-01-2011, 04:02 PM)
|
#107
Originally Posted by Drkirby:
Example, if X is less than 5 AND Y = true OR if X is greater than 5: Code:
int x
bool y
if ( ( ( x < 5) && (y == true)) || (x > 5) )
{
//Then do shit
}
|
|
Member
(04-01-2011, 04:07 PM)
|
#108
Originally Posted by Feep:
Comments are also for you. I know there's no way I would understand the code on my thesis at first glance if I were to look at it today. |
|
Corporate Apologist
(04-01-2011, 04:07 PM)
|
#109
So, just use parentheses to make sure the statements are evaluated like I intend to, right?
A lot of times my comments are on why a formula works or just what is being used. Like I am not going to be able to spot the fact that that I am using the formula (X1+X2)^2 + (Y1+Y2)^2 < (R1+R2)^2 off hand, but if I write. Code:
//"Two circles overlap if the sum of there radii is greater than the distance between their centers." //(x1-x2)^2 + (y1-y2)^2 < (r1+r2)^2 //http://www.euclideanspace.com/maths/geometry/elements/intersection/twod/index.htm
Last edited by Drkirby; 04-01-2011 at 04:15 PM.
|
|
got my tag in the OT
(04-01-2011, 04:09 PM)
|
#110
Originally Posted by mantidor:
"Who was the idiot that did this?!" Then proceeded to take it out and have everything fall apart. Then realize that not only was it you that wrote it, but you were pretty clever for doing so? |
|
Member
(04-01-2011, 04:36 PM)
|
#113
I remember back in school we had a PHP project. I was in a group with a couple of dudes, and one of them was always sleeping in class because he stayed up late to play WoW. So we gave him some coding assignments and sent him home. He comes back a few days later with code that had variables named Paladin, Mage, Warlock, Rogue and shit like that.
The report came back with a lot of red question marks. |
|
Member
(04-01-2011, 05:13 PM)
|
#114
Originally Posted by ronito:
the most stupid mistake i made when i started studying programming was when it took me about 30 minutes to notice that the reason because my query wasn't working was because i didn't start the db connection |
|
Member
(04-01-2011, 07:39 PM)
|
#115
Originally Posted by ronito:
haha more than once. Since we use SVN you can use the blame function and it immediately tells you who wrote each line and in what revision. Nothing worse than doing blame and seeing your name on the line that is driving you nuts. |
|
Member
(04-01-2011, 07:43 PM)
|
#116
Originally Posted by ronito:
|
|
ὁ αἴσχιστος παῖς εἶ
(04-01-2011, 08:37 PM)
|
#117
Originally Posted by iapetus:
|
|
got my tag in the OT
(04-01-2011, 08:41 PM)
|
#118
Originally Posted by nickcv:
Mine was really dumb. I was supposed look for all the data files within a directory. Then for every data file I was supposed to create two more files (1 log file, 1 error output file) then for every line in the data file (each data file had several hundred thousand rows) I was supposed to examine, do a bunch of stuff and output the results in the log file. But I put the While in the wrong place. Instead of creating 2 new files for every data file I created 2 new files for every line in the data files. The server crashed trying to create hundreds of thousands of files. |
|
Member
(04-01-2011, 08:44 PM)
|
#119
We have a whole bunch of unit conversions we have to do for figuring out the Green House Gas emissions of things.
Where would be a good place to store these numbers? In a database? Naaaah. Let's just make a switch statement with 149 cases for half of them and hardcode the other half directly into the queries. And naturally these queries are copy and pasted into the code of 4 different pages. *swears at everything* |
|
got my tag in the OT
(04-01-2011, 08:46 PM)
|
#120
Originally Posted by ultron87:
|
|
Member
(04-01-2011, 08:56 PM)
|
#122
I am kind of the lead of the Android team where I work (I took on an Android project because nobody else here knew it and I was like hey, new platform, cool), and we're now trying to hire up on Android developers. We get TONS of applications from just general Javaheads. A depressing amount, when being phonescreened, fail the fizzbuzz test. :(
|
|
Member
(04-01-2011, 09:02 PM)
|
#124
Originally Posted by Halycon:
Even if you don't know what modulo is it is still incredibly simple. |
|
Member
(04-01-2011, 09:05 PM)
|
#125
I think there are a lot of people have just spent so long connecting enterprise components that they can no longer do simple logic/math, and there are also a lot of people who aren't programmers but need a job and are like "I bet I could do that shit" and apply, hoping to bluff their way through an interview.
|
|
Will use d3doverrider to force triple buffering instead of complaining about mouse lag in every PC game thread ever
(04-01-2011, 09:13 PM)
|
#126
Originally Posted by ronito:
|
|
Member
(04-01-2011, 09:21 PM)
|
#127
Originally Posted by TheExodu5:
|
|
Member
(04-01-2011, 09:32 PM)
|
#128
Originally Posted by ronito:
|
|
Member
(04-02-2011, 05:48 AM)
|
#129
Even though I am a really good programmer, I would probably get fired where most of you guys work as I'm most certainly never ever going to commit to working a 14 hour day let alone to spending the night in the office. I've never had a job where I had to work consistently over 50 and most of my jobs I was out the door a little over 40 most weeks. Perhaps it's the type of coding I do, but what you guys are describing is bullshit...
|
|
Member
(04-02-2011, 06:29 AM)
|
#130
He he he... newbies, real men program WITH THIS:
Code:
1 H EXAMP7 2 H* 3 H* UPDATE STUDENT MASTER WITH GRADE INFORMATION 4 H* 5 FGRADES IPEAF2080 104 TAPE S 6 FSTMASTR USEAF 250 250 7KI 2 DISK14 S 7 FREPORT O F 132 132 OF LPRINTER 8 LREPORT 101 6012 9 IGRADES 011 01 10 I 1 7 GIDENT M1 11 I 9 140C1N 11 12 I 16 192C1G 13 I 21 260C2N 12 14 I 28 312C2G 15 I 33 380C3N 13 16 I 40 432C3G 17 I 45 500C4N 14 18 I 52 552C4G 19 I 57 620C5N 15 20 I 64 672C5G 21 I 69 740C6N 16 22 I 76 792C6G 23 I 81 860C7N 17 24 I 88 912C7G 25 I 93 980C8N 18 26 I 100 1032C8G 27 ISTMASTR 011 02 1 CA 28 I OR 92 1 CD 29 I 2 8 SIDENT M1 30 I 9 43 NAME 31 C* 32 C* COUNT RECORDS PROCESSED FOR SUMMARY AT END OF REPORT 33 C* 34 C 01 GCOUNT ADD 1 GCOUNT 30 35 C 02 SCOUNT ADD 1 SCOUNT 30 36 C 02 MR UCOUNT ADD 1 UCOUNT 30 37 OSTMASTR D 02 MR 38 O C1G 144P 39 O C2G 153P 40 O C3G 162P 41 O C4G 171P 42 O C5G 180P 43 O C6G 189P 44 O C7G 198P 45 O C8G 207P 46 OREPORT H 201 1P 47 O OR OF 48 O 43 'STUDENT MASTER' 49 O 29 'GRADES TO ' 50 O 19 'POST COURSE ' 51 O D 11 01 52 O N14 C4G 111 ' 0. ' 53 O N14 C4N 105 '0 - - ' 54 O N13 C3G 95 ' 0. ' 55 O N13 C3N 89 '0 - - ' 56 O N12 C2G 79 ' 0. ' 57 O N12 C2N 73 '0 - - ' 58 O N11 C1G 63 ' 0. ' 59 O N11 C1N 57 '0 - - ' 60 O NMR 45 'STUDENT MASTER ***' 61 O NMR 27 '*** NO MATCHING ' 62 O GIDENT 11 63 O D 1 01 64 O N18 C8G 111 ' 0. ' 65 O N18 C8N 105 '0 - - ' 66 O N17 C7G 95 ' 0. ' 67 O N17 C7N 89 '0 - - ' 68 O N16 C6G 79 ' 0. ' 69 O N16 C6N 73 '0 - - ' 70 O N15 C5G 63 ' 0. ' 71 O N15 C5N 57 '0 - - ' 72 O D 1 02 73 O MR 57 'UPDATED' 74 O NAME 47 75 O SIDENT 11 76 O T 31 LR 77 O GCOUNTZ 7 78 O 26 'GRADE RECORDS READ' 79 O T 1 LR 80 O SCOUNTZ 7 81 O 23 'STUDENT MASTER ' 82 O 35 'RECORDS READ' 83 O T 1 LR 84 O UCOUNTZ 7 85 O 22 'STUDENT MASTER' 86 O 38 'RECORDS UPDATED' Working for a bank... from time to time I have to fix 40k+ lines programs with 30+ years of patches over patches, referencing dozens of other equally long, old and poorly made programs. Lots of those programs lack any kind of documentation, proper coding practices (it's old RPG!) and were made by people who should face charges of crimes against humanity. I have to follow tons and tons of retarded normative. I'm also in the worse place of the entire office with super restricted internet access, 0 privacy and other crap I don't want to think about. Every single day I wonder what the hell am I doing in this place. Maybe is because of this situation that I get sick with the simple thought of writing some code at home. |
|
Member
(04-02-2011, 08:01 AM)
|
#132
I'm to blame for bad method and variable names. Typically it's just to ward code snoopers. :D
Case in point: http://userscripts.org/scripts/review/89544 I could see someone getting a little lost. |
|
Member
(04-02-2011, 10:39 AM)
|
#133
here's an article about how to write unreadable code i found some time ago.
The best part about writing code impossible to understand comes from your ability (well, it's more like a form of art) of finding crazy names for your variables, functions and methods. Those names don't mean anything to the computer so you have the opportunity to use any possible technique to make the programmer feel stupid. 1. Use the Book of Names (ISBN-13: 978-0684039992) Buy one right now and you'll never have to worry about finding a name for your variables. "Cathie" is a great name, it's short, you can write it fast and gives you a bunch of other options (Cathy, Kathi, Kathie, Kate, Katee...) all similar and easy to mistake for each other. If you are looking for easy "names" use "adsf" or "aeou" 2. Grammatical errors If you are going to use descriptive names for your variables and functions forget about grammars and how to spell words. 3. Abstraction Use heavy abstraction ("how" "that" "data" "manage" "do") and numbers: how32, that19, data927 4. A.C.R.O.N.Y.M.S use acronyms to clean your code. Always remember that real men never, NEVER, explain an acronym: they understand thanks to their genes. 5. Synonyms and Contraries Avoid monotony and use a nice vocabulary. If you have a bunch of functions and variables whose meaning is the same using synonyms you'll imply that there is a difference between each other, but if you have functions that have some crucial difference between each other make sure to use always the same name. ie: use "print" for a function that print a document with a printer, for one that writes on a file and for one that print some text on screen. 6. Use foreign languages. "this script keep trace of the many statil returned by vaxen". Esperanto, Klingon, Sindarin all qualify for this purpose 7. uPpeR caSE Use upper case letters to identify single words into a long string, but do it randomly 8. Reuse names Make sure to use the same variable for at least 3 different purpose and in multiple scopes in the same script. You have to make sure that is someone search for that variable as many result as possible will be returned. 9. Accented (stressed) letters use accents for variables names. ie: typedef struct {int i;} ìnt; if you didn't notice the "i" of the last "int" is accented. 10. Take advantage of variables max length. if your compiler supports just 8 character always use longer names, just changing the last part of it. ie: var_unit_dimension and var_unit_expression look different, but for your compiler they are the same thing. 11. Underscore is your friend use both _ and __ as identifiers 12. Mix languages Use as many languages as possible in your comments. Who read it cannot say that you didn't comment but may be wondering why some of them are in german while others are in Thai. 13. ASCII code is made of 255 characters and almost all of them can be used for variable names (§, ¿). 14. Use common names for variables Choose the most common names for your variables, but make sure they are not related to what those variables are for: marypoppins = (julieAndrews + starship) / mailbox; In this way whoever read it will have an hard time trying to disconnect that name from it's usual context. 15. Typical variables Never use "i" in a loop, use any varible but "i" 16. Ignore implicit conventions If your language (ie Java) has some implicit conventions for name (classes start with upper case letters while variables don't) ignore them! Make up your own conventions and rant about no one else using them. 17. 'l' (L) looks similar to '1' (one) Two names like def1ab and deflab are similar but different. 18. Be creative with your function's arguments. If you have a function named F that makes a call to function G passing an argument that inside F is named A, in G use a different name that's present inside F but not in G. This will make much harder to understand what exactly G is doing and how is used it's returned value. ie: if you have a function CalcWidth(height, size), use height to contain the value that will be used as size into the elaboration. 19. Usng abbrvtn (Using abbreviations) There's not just one way to abbreviate a word: be creative. 20. Under-estimate functions Use for your functions names that won't give a precise idea of what the function exactly does. If someone makes questions just tell them that the function got improved across time and you didn't change the name. ie: isValid( x ) should validate X but also converts it in binary and save it inside the database. 21. Hungarian Notation Hungarian notation is the perfect weapon in the hands of the evil programmer. If you don't know what hungarian notation is, it's the practice of prepending to the name of the variable a prefix that identify what that variable is for. ie: intValue, strText, objObject and so on. all you have to do is use identical prefix with different meanings across the code. ie: intXXX = Integer not trusted... intXXX = index number of transactions intXXX = information not translated... strXXX = status to remember... 22. Hungarian Notation part 2 Follow Microsoft example: the variable type changes but the name doesn't. 22. Recycle If you defined a structure to contain data from a callback, define the structure in every single module of the program assigning to it always the same name. That will drive crazy the debugger (especially the VC++ one), so when you'll request the content of a structure in the observation window the debugger will have no idea about which one to show and will pick up a random one. 23. Use names that look similar to instructions Null, cOnst, For and stuff like that. 24. Use names that don't have anything to do with whatever you are showing on screen. Who said that a field named "Name" on screen must correspond to a variable named "Name"? 25. Be creative with your constants who said you can't have a constant named FALSE contianing a boolean true value?
Last edited by nickcv; 04-02-2011 at 11:02 AM.
|
|
Second-hand Citizen
(04-02-2011, 10:46 AM)
|
#134
Originally Posted by mantidor:
|
|
Member
(04-02-2011, 01:20 PM)
|
#135
I havent had any rant-worthy issues since I've graduated college (aside from the disaster that was parsing the old MA Legislature site files), but every so often coding in assembly comes up and people are amazed that I enjoy it. My intro CS course in college started us coding in binary (literally 0's and 1's) before switching to the corresponding assembly and then later to C, and so when we did assembly in my architecture course it was easy and fun. The project I remember most fondly was recursive Towers of Hanoi in MIPS assembly. The project was fun to do, and hearing people bitch about it was wonderful.
Also, fuck Powerbuilder. I have to learn it for my job, and while it isnt terrible (pretty good for certain things, really), all I'm thinking the entire time is how much better this would be in a .Net environment. Using it is awkward as hell, I'm told it is similar to VB (never used that though) and the IDE is shit compared to wonderful Visual Studio/Eclipse/etc. If you google a problem and google just gives you the finger instead of helping to find an answer, odds are you shouldn't be using that language; there is fuck-all out there for learning this shit. |
|
Hang out with Steve.
(04-02-2011, 01:33 PM)
|
#136
Originally Posted by Feep:
The point is that you should treat all code as if someone unfamiliar with it will be working with it at some point in the future. It's better to always be in that mindset. Proper code documentation, kept up to date, is the responsibility of every programmer. |
|
Second-hand Citizen
(04-02-2011, 01:41 PM)
|
#137
Originally Posted by SteveMeister:
Properly documenting my code would have wasted up to 200 hours of my life, for no reason other than both make myself feel good about "practices" and to open myself up to code theft or personnel replacement. No thanks. |
|
Member
(04-02-2011, 02:07 PM)
|
#138
Originally Posted by Feep:
doing it your way it would take you a couple of days to prepare the sample code to send. |
|
Second-hand Citizen
(04-02-2011, 03:03 PM)
|
#139
Originally Posted by nickcv:
You guys are overblowing the problem. |
|
Hang out with Steve.
(04-02-2011, 03:17 PM)
|
#140
Originally Posted by Feep:
What do you mean by "personnel replacement"? Are you coding obscurely for job security? |
|
(04-02-2011, 03:21 PM)
|
#141
Originally Posted by nickcv:
|
|
Black Canada Mafia
(04-02-2011, 03:45 PM)
|
#142
Originally Posted by ThoseDeafMutes:
Was that first year or first day? Damn this thread is interesting, finishing up my first year right now. I'm loving the hell out of it. |
|
Will use d3doverrider to force triple buffering instead of complaining about mouse lag in every PC game thread ever
(04-02-2011, 03:57 PM)
|
#143
Originally Posted by Feep:
Also, you're going to save others a lot of time by documenting your code. If someone has to waste an hour analyzing a bit of code to figure out what it's doing, then you've failed at your job. Of course, it's likely many people may have to go through your code in the future, and the problem is then compounded. |
|
Second-hand Citizen
(04-02-2011, 10:37 PM)
|
#145
Originally Posted by TheExodu5:
I understand this is a rare circumstance, but that's how it is. I would document my code properly in a larger, team-oriented project. But for now, there's no point. |
|
Member
(04-02-2011, 10:50 PM)
|
#148
Originally Posted by ronito:
I've done this too. I wrote such bad code when I first came out of school...
Originally Posted by ultron87:
|
|
Member
(04-02-2011, 10:55 PM)
|
#149
Originally Posted by Andrex:
|
|
Member
(04-02-2011, 11:02 PM)
|
#150
How do you guys plan before starting a new project (to an existing project or a completely new project, w/e)? Simple 5 minute pencil and paper design, or do you go as far as UML diagrams?
Also, this describes my programming career, and it's currently KILLING me: http://en.wikipedia.org/wiki/Analysis_paralysis |