Rant: Over complicating things
- TheoSqua
- Next Gen Wart
- Posts: 8951
- Joined: April 22 06, 6:53 pm
- Location: St. Louis
- Contact:
Rant: Over complicating things
I get a lot of programming code I have to use from other people for different problems. It seems that a lot of programmers like to way over complicate things.
So i'm going over this code for a selector that will choose either A or B based upon some page parameters. It's never going to be more than A or B. Two functions, two outputs.
The programmer wrote this nice fancy nested function that that detects if value A or B is used via regular expressions and then uses global variables to allow one function to work with both A and B. This would be a great idea if there were 300 different options. But no, there's only two. There will always only be two. This program is Yes or No, black and white, there will never be a maybe or a gray area.
The amount of lines to write the fancy flexible function that uses regular expressions and global variables: 20. The amount of lines to just manually write two seperate functions based on A or B: 20. The amount of time it takes to write and modify the second option: way way way way less.
It's like renting a dump truck to move 50 pounds of dirt 100 feet when you have a wheel barrel in the garage. I don't get it.
So i'm going over this code for a selector that will choose either A or B based upon some page parameters. It's never going to be more than A or B. Two functions, two outputs.
The programmer wrote this nice fancy nested function that that detects if value A or B is used via regular expressions and then uses global variables to allow one function to work with both A and B. This would be a great idea if there were 300 different options. But no, there's only two. There will always only be two. This program is Yes or No, black and white, there will never be a maybe or a gray area.
The amount of lines to write the fancy flexible function that uses regular expressions and global variables: 20. The amount of lines to just manually write two seperate functions based on A or B: 20. The amount of time it takes to write and modify the second option: way way way way less.
It's like renting a dump truck to move 50 pounds of dirt 100 feet when you have a wheel barrel in the garage. I don't get it.
- cards2468
- Hall Of Famer
- Posts: 14745
- Joined: October 28 06, 11:10 pm
- Location: LOVE IT OR LEAVE IT
Re: Rant: Over complicating things
is there a possibility he dug up code he wrote for a more complex issue and then just tweeked it to fit this situation?
- TheoSqua
- Next Gen Wart
- Posts: 8951
- Joined: April 22 06, 6:53 pm
- Location: St. Louis
- Contact:
Re: Rant: Over complicating things
nope. completely custom code.cards2468 wrote:is there a possibility he dug up code he wrote for a more complex issue and then just tweeked it to fit this situation?
- cards2468
- Hall Of Famer
- Posts: 14745
- Joined: October 28 06, 11:10 pm
- Location: LOVE IT OR LEAVE IT
Re: Rant: Over complicating things
maybe he likes the smell of his own fartsTheoSqua wrote:nope. completely custom code.cards2468 wrote:is there a possibility he dug up code he wrote for a more complex issue and then just tweeked it to fit this situation?
- TheoSqua
- Next Gen Wart
- Posts: 8951
- Joined: April 22 06, 6:53 pm
- Location: St. Louis
- Contact:
Re: Rant: Over complicating things
It's a she, guess so.cards2468 wrote:maybe he likes the smell of his own fartsTheoSqua wrote:nope. completely custom code.cards2468 wrote:is there a possibility he dug up code he wrote for a more complex issue and then just tweeked it to fit this situation?
- wart57
- just can't quit you.
- Posts: 25076
- Joined: April 18 06, 4:33 pm
- Location: Lost
Re: Rant: Over complicating things
There is your answer, women always make things more difficult than they have to be.TheoSqua wrote:It's a she, guess so.cards2468 wrote:maybe he likes the smell of his own fartsTheoSqua wrote:nope. completely custom code.cards2468 wrote:is there a possibility he dug up code he wrote for a more complex issue and then just tweeked it to fit this situation?
-
Arthur Dent
- Hall Of Famer
- Posts: 12542
- Joined: April 25 06, 6:43 pm
- Location: Austin
Re: Rant: Over complicating things
If she used global variables, then there is nothing nice about her coding.TheoSqua wrote:The programmer wrote this nice fancy nested function that that detects if value A or B is used via regular expressions and then uses global variables to allow one function to work with both A and B.
- TheoSqua
- Next Gen Wart
- Posts: 8951
- Joined: April 22 06, 6:53 pm
- Location: St. Louis
- Contact:
Re: Rant: Over complicating things
It wasn't really global variables i just said that for simplicity of the rant. It was a function that changed the vlaues based on variables that were input into the function from the regular expression filter. That way the function could be used for either option.Arthur Dent wrote:If he used global variables, then there is nothing nice about his coding.TheoSqua wrote:The programmer wrote this nice fancy nested function that that detects if value A or B is used via regular expressions and then uses global variables to allow one function to work with both A and B.
It just makes it much harder to review because instead of having two variables (option a and option b) you now have five (option a, option b, the value to filter through regular expressions, the value to input option a and b into the function, the secondary function value to pass a or b's value into a cookie).
The second way is solid coding if you have 15-20 variables. But when you're writing a complex function to save yourself from writing two simple functions it's a bit of a waste of time that I don't understand.
I think programmers just like to use the skills they have. When I first started getting good at actionscript I wanted everything in Flash to use actionscript. I'd take a piece of flash that was loading the menu and use an array to put the name of each link into the flash. Looking back it would have been much simpler to just manually write in every name value, putting them into an array added absolutely no benefit. But hey, I knew how to do arrays and they looked cool so that's what I did.
- cards2468
- Hall Of Famer
- Posts: 14745
- Joined: October 28 06, 11:10 pm
- Location: LOVE IT OR LEAVE IT
Re: Rant: Over complicating things
I used to hate coding, but as each class forced me to do more projects with it involved, I got a lot better and started enjoying it. I had a project in my Heat Transfer class where given a 2d object with given thermal properties and various boundary conditions, I had to generate a color plot representing temperature. I did all sorts of fancy things with the coding so that I could re-use it in later projects if needed. The plots were perfect. I copy and pasted the code into Microsoft Word so that I could write my report with it. Somehow I managed to delete a parenthesis in the first line of code. Professor caught it and said it was impossible for the code to run with that and so he gave me a C.
Sad part is this professor is 1 of my good friends, and because of that he was always harder on me than anybody else... so I ended up with a C+ for the course.
So to bring this back to the original post. I [expletive] hate coding.
Sad part is this professor is 1 of my good friends, and because of that he was always harder on me than anybody else... so I ended up with a C+ for the course.
So to bring this back to the original post. I [expletive] hate coding.
- Popeye_Card
- GRB's most intelligent & humble poster
- Posts: 31094
- Joined: April 17 06, 11:25 am
Re: Rant: Over complicating things
Mods, can we merge with the Ichiro thread?
