The Big Programming Thread - Page 549
Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
Catch]22
Sweden2683 Posts
| ||
Manit0u
Poland17041 Posts
Controllers: there's this giant class called Base, everything is there. There are also 2 other classes, which are similarly large and all they do is override methods in the Base and provide hacks for it... Great code: $something = $someObject->someMethod == 'something' ? $someOtherObject->someOtherMethod : $yetAnotherObject->yetAnotherMethod; repeated 27 times within the same scope... Some super long password encryption/decryption method with $salt = '12345678'; (when will people finally discover password_hash and password_verify?) Standards: PSR? Never heard of it. SOLID? Can you do me one? And some of the methods in the base/hack classes? They're overriding parts of methods and invoke the same method from parent in random places (as in: function func() { parent::func(); }). Now I'm trying to fix a bug which should be super simple but I have 3 methods that try to do the same stuff, each one does it differently though and they're bouncing it back and forth between each other. Also, fuck WordPress. Thank you for hearing my woes. It helps immensely. | ||
nunez
Norway4003 Posts
| ||
Blisse
Canada3710 Posts
| ||
nunez
Norway4003 Posts
And some of the methods in the base/hack classes? They're overriding parts of methods and invoke the same method from parent in random places (as in: function func() { parent::func(); }). is this really a hack though? thought that was the decorator pattern or something regardless seems like it could be a useful technique in many scenarios. oh, but if it's just overriding and then not adding any new functionality, then yeah, i don't get that. small example with a nice c++11 feature: inherited constructor. #include<iostream> [jeh@gimli work]$ ./workbench | ||
Blisse
Canada3710 Posts
:3 nunez can you write an astyle config file so i can copy your styling? i like it (except for the lack of space before {'s alsooo how do you guys feel about namespaces in c++? not worth it to do for personal projects? | ||
nunez
Norway4003 Posts
astyle, ooh, this looks useful. i'll take a look. i think namespaces are pretty sweet, f.ex. when you want a place to put implementation details, however you can achieve same thing with prefixing or postfixing. but if you want to create a metastructure with a more meaningful semantic than "implementation detail", like say a type and a set of functions to manipulate the type, and you're into autocompletion, then postfixing is obviously a bad choice. i tend to favor namespaces. equivalent ex: using partial template specialization of a class template to count the template arguments of the template argument a function template was instantiated with (after reading this you will be more inclined to forgive the following syntax). + Show Spoiler [example] + #include<iostream> #include<iostream> when writing library stuff (header only, template stuff) i intend to use later i always put whatever is in its interface in a namespace (f.ex jeh for general stuff, or a dedicated one if there number of things in the library is big enough, and their names are collission prone enough), to avoid namespace pollution. i have yet to write a binary complex enough for a namespace to be meaningful though. | ||
phar
United States1080 Posts
use unnamed namespaces (e.g. namespace { my code in here ... .... }) when you won't need to refer to stuff elsewhere. don't use 'using', always put the proper namespace in front of calls (std:: instead of using std) | ||
Manit0u
Poland17041 Posts
This becomes a hack when you have something like that:
And then those global settings (which were set in PHP) get overriden by JS (since they store it in the cookies). It's like several people were working on the same issue, each with a different idea on how to approach it and now I have to clean up the mess... I could understand it if each new class set some new settings and called the parrent to handle others, but each one of them is doing exactly the same thing, but in a different way (the actual result is different as various checks are performed at different times). Like they couldn't just make a method getGlobalSettings() in one place and use it... | ||
Manit0u
Poland17041 Posts
| ||
Deleted User 101379
4849 Posts
On November 25 2014 21:34 Manit0u wrote: Great, now I've found a switch that spans over 300 lines :/ Soon you are ready to join the club of the legacy code programmers | ||
Manit0u
Poland17041 Posts
On November 25 2014 21:41 Morfildur wrote: Soon you are ready to join the club of the legacy code programmers 270 warnings found. 248 weak warnings found. 479 typos found. And it's just one class... | ||
bangsholt
Denmark138 Posts
On November 25 2014 21:41 Morfildur wrote: Soon you are ready to join the club of the legacy code programmers There will be many tears. And lost hair. And lost sanity. But in the end... Right, there's no end. My bad. | ||
spinesheath
Germany8679 Posts
Be happy it's not the same switch in 30 places. | ||
Manit0u
Poland17041 Posts
On November 26 2014 02:28 spinesheath wrote: The hack is the global. Be happy it's not the same switch in 30 places. Haha, thankfully there are no 30 places, just classes that are 5k lines long... | ||
Ben...
Canada3485 Posts
On November 25 2014 02:12 nunez wrote: the big programming thread is a reliable shoulder to cry on. Can I vent at it too? The crying has already passed. I just did about ~45 hours of operating system programming over a 4 day period because my partner for my OS class decided that working on our assignment was no longer in her best interest. She had told me that she would start working on it mid last week after finishing another assignment. After that it was radio silence. Not a single response to my emails or texts, no commits. She did one small commit on Saturday that mostly involved undoing all my work, which I then promptly overwrote (and she sent me a passive aggressive email about). Then yesterday, around 6 hours before it was due, she starts working on it. I'd rather she hadn't. She did maybe 5% of the assignment, and everything she contributed was broken because she didn't understand how to do things (all the stuff we were doing had to be passed through a different function which then deals with userland stuff) or do anything remotely right (keep in mind this person is a full time software developer who is being paid to go to school). Things she didn't do: - testing. As in see if her code even compiles. She did a huge commit around 30 minutes prior to the assignment being due that had around 2 screens worth of errors (most because of the point below this one but others because she used -> when she shouldn't have or because of points 4 and 5 below this one). I ended up commenting all of it out. Our prof stated he would rather our code compile and run but be incomplete over being complete and not compiling/running. I was about to just revert back and remove her changes but I got everything working again so I didn't. I told her quite clearly that no major changes were allowed to the OS any time 4 hours before the thing was due so we would be guaranteed to have a compiling and running OS. She obviously didn't listen. She tried swapping out the default scheduler for her own, which didn't compile or wasn't even known to work. I undid that too. - include headers. She literally didn't include a single header in any of her stuff. I had to do that all myself. - finish include guards. Every header she made was missing #endif in the include guard - include said headers in the files that need them. Again, not a single include. - declare variables. This one baffled me. I would guess she didn't declare maybe half of the variables she used. - declare function signatures. I can see forgetting to do the void part for declaring a function with no inputs( say something like int foo(void); ) in a header, but forgetting to add in the input parameters in a function that needs them. I mean what? - understand how extern works. The few times she did declare variables she almost always used extern. In 2 different files she called extern on things that either didn't exist or were structures(?). Every time she would use "struct foo" she would add extern in front, even though she was declaring a local variable of that struct. - follow the course style guide. Ever. At all. Not even once. We already lost marks on two assignments because of it and she still won't adapt. Things she did do: - use what appear to be macros without declaring them (really, I'm not exactly sure what they were supposed to be. grepping the source code came up with nothing other than her stuff. They weren't in any other files or documentation) - attempt to use built in macros but use them all wrong - signed and unsigned comparison in vital system code (as in our process scheduler and a few other things). Most of them by default failed. - overwrite function signatures for stuff I was working on "because it doesn't match the man pages" despite the fact that we aren't going by the man pages, and are instead going by the spec outlined in a file within the OS that I sent her an email about - COMMITS WITHOUT EVER DOING UPDATES FIRST TO CHECK FOR CHANGES (this is partly because we had to use svn but still, it's common sense. In git, from what I remember, it runs an update when doing commits) I did a whole bunch of fault/error fixes to a commit she did in that 6 hour period prior to submission, I would guess she did that commit around 5 hours before the thing was due. When she did her second commit a half hour before submission, none of those fixes were there anymore. No svn updates were run in 5 hours with the knowledge that another person was working on the file to. Apologies for the long ranty post, but seriously if you do any of the stuff outlined above, please think about the other people working with you and maybe change your ways. I just needed to get this off my chest. I hope you guys understand. | ||
Alzadar
Canada5005 Posts
| ||
Pirfiktshon
United States1072 Posts
Is there any space here for a penetration tester(white hat hacker)? | ||
Isualin
Turkey1903 Posts
| ||
Alzadar
Canada5005 Posts
On November 26 2014 06:23 Pirfiktshon wrote: Your first tip off should have been it was a she hahaha. If she's pretty you were pretty much screwed the moment you partnered up LOL wtf what an awful thing to say. Please inform yourself on the terms "confirmation bias" and "stereotype threat" and try not to perpetuate the stereotype about male programmers while you're at it. | ||
| ||