|
pigdog posted:Looks like PHP to me... foreach (my $entry in $options) implies $options to be an array, but unlike in PHP the all $variables in Perl are scalars. Probably because I hosed up writing the code out from memory. This is perl code, and the horror I was pointing out was the developers aversion to the modulo operation.
|
# ? Jan 6, 2013 03:20 |
|
|
# ? May 27, 2024 22:12 |
|
Gazpacho posted:Some people just take comfort in developing the hard way that they know rather than the easy way they could learn.
|
# ? Jan 6, 2013 04:16 |
|
I guess I don't quite understand why a template engine is necessary for that sort of quick-and-dirty script. Obviously, if it was a lot more than it already was, yeah, but otherwise, I find the code readable, the intention is clear, and I see no reason to make it use templates, yet.
|
# ? Jan 6, 2013 04:18 |
|
nielsm posted:Odd, seeing that PHP itself is a templating engine, that has massively grown out of its original purpose. Oops. That's what I get for knowing PHP and not Perl. I just thought the code tags always said "Perl code." I must be misremembering something.
|
# ? Jan 6, 2013 04:19 |
|
Suspicious Dish posted:I guess I don't quite understand why a template engine is necessary for that sort of quick-and-dirty script. Obviously, if it was a lot more than it already was, yeah, but otherwise, I find the code readable, the intention is clear, and I see no reason to make it use templates, yet.
|
# ? Jan 6, 2013 04:35 |
|
I'd usually agree with you both, but maybe I have a bias after using Flask/Jinja and Symphony/Twig for a lot of projects lately. Even for simple html pages, I've always found something like:Python code:
HTML code:
Perl code:
I'm not saying this is the one true way. I just think devs should be less averse to using it for code clarity. But then again, I've only been using them for the past few months, so maybe I'm the horror.
|
# ? Jan 6, 2013 05:28 |
|
Rainbow Pony Deluxe posted:
You're kidding me, right?
|
# ? Jan 6, 2013 05:43 |
|
That particular layout task involves common off-by-one gotchas that a novice is going to struggle with regardless of whether they use a template system. At best the use of a template system will make any bugs stand out better on review.
|
# ? Jan 6, 2013 06:51 |
|
code:
code:
If you want your template system to be obviously correct, this is more like how you'd do it.
|
# ? Jan 6, 2013 09:15 |
|
Rainbow Pony Deluxe posted:Templating stuff While still not perfectly readable, it's possible to use PHP's alternative construct syntax to make something more template-ish: PHP code:
Spades fucked around with this message at 10:55 on Jan 6, 2013 |
# ? Jan 6, 2013 10:40 |
|
Html in code is bad, but code in templates is bad. There's more code than html in all rewrites I've seen - really, what's the point either way?
|
# ? Jan 6, 2013 19:54 |
|
Freakus posted:Html in code is bad, but code in templates is bad. There's more code than html in all rewrites I've seen - really, what's the point either way? For something like alternating row classes for styling, your choices IMO are:
#3 is workable, but either you need to duplicate the templates a bunch, or you need template inheritance, at which point you've just replicated your problem of branching logic, but in a way that is somewhat more opaque than just a straight-up 'if' statement, unless you have a lot of variations that are used in a lot of different ways in a lot of different places in your code. #4 is just dumb. So all in all, I can see very basic logic in templates having its place, though anything approaching even a medium level of complexity would likely be inappropriate.
|
# ? Jan 6, 2013 20:40 |
|
Doctor w-rw-rw- posted:For something like alternating row classes for styling, your choices IMO are: or just use nth-child(odd), nth-child(even)
|
# ? Jan 6, 2013 21:18 |
|
how!! posted:or just use nth-child(odd), nth-child(even) yeah, it's not like anybody needs to support IE8 or IE7
|
# ? Jan 6, 2013 22:02 |
|
Deus Rex posted:yeah, it's not like anybody needs to support IE8 or IE7 You're not rendering the page unusable in 7/8, they just don't get 100% of the styling. Pixel-perfect rendering across browsers is normally not worth the development cost.
|
# ? Jan 6, 2013 22:44 |
|
dexter posted:You're not rendering the page unusable in 7/8, they just don't get 100% of the styling. Pixel-perfect rendering across browsers is normally not worth the development cost. That said, I find django's "cycle" tag pretty useful for those sorts of scenarios. It also supports IE8. Something similar could be done to support nth-child on the server side.
|
# ? Jan 6, 2013 23:03 |
|
A server side integer variable isn't my idea of an exorbitant cost and you are getting sort of hung up on the specifics of an arbitrary example.
|
# ? Jan 6, 2013 23:04 |
|
Yeah, alternating row styling is hardly what I'd consider cosmetic, it actively affects the quality of the user experience when it comes to long tables. Here's a client side alternative though. http://selectivizr.com/
|
# ? Jan 6, 2013 23:06 |
|
Freakus posted:Html in code is bad, but code in templates is bad. There's more code than html in all rewrites I've seen - really, what's the point either way? I'd argue that for debugging purposes, you know exactly where to look. If some HTML renders weird or there's some weird typo, you know that it's something wrong with the presentation logic in the template so you can easily go to that exact point and follow any explicitly mentioned macros from there. When it's in the controller or view logic where you build the HTML, then you need to first find where you build that HTML at, since it could be spread across a lot of other logic before it gets echo'd. There's not much of a difference, but it seems like a good idea to separate controller/view logic from actual presentation logic. And code in templates is a little bit better than interrupting HTML with weird breaks into <?php ?>. Most people don't use the construction syntax and then you get things like: PHP code:
|
# ? Jan 6, 2013 23:14 |
|
Freakus posted:Html in code is bad, but code in templates is bad. There's more code than html in all rewrites I've seen - really, what's the point either way? Code in templates is not bad.
|
# ? Jan 8, 2013 00:29 |
|
shrughes posted:Code in templates is not bad. Moving stuff to the JS model behind it is both cleaner and easier to unit test, I would say.
|
# ? Jan 8, 2013 14:46 |
|
Freakus posted:Doing things such as alternating backgrounds when you have a large list of things is a huge usability difference. As long as you don't actively block IE 7/8, my opinion is pretty much "deal with it."
|
# ? Jan 8, 2013 18:58 |
|
Wheany posted:As long as you don't actively block IE 7/8, my opinion is pretty much "deal with it." I have (in my terms of trade) a clause which says that I'll only support software I build on the last two versions of the few major browsers, and past that I'll just try my best to ensure that the side can still be used in some form. I've had a couple of clients ask me about supporting IE 7 and 8, and my response is generally "If you can find the information/use the application at all on those browsers, then they're supported enough. It's not worth your money chasing pixel-perfect support for browsers that are so out of date"
|
# ? Jan 9, 2013 00:26 |
|
Suspicious Dish posted:I guess I don't quite understand why a template engine is necessary for that sort of quick-and-dirty script. Obviously, if it was a lot more than it already was, yeah, but otherwise, I find the code readable, the intention is clear, and I see no reason to make it use templates, yet. As someone who supports a poo poo ton of "quick-and-dirty" code in production. gently caress developers like think like this. Templates are a good thing, even if the project is simple now. If for some reason down the line things need to change it is a whole hell of a lot easier to modify templates then to try to figure out what that rear end in a top hat 3 developers ago was trying to accomplish.
|
# ? Jan 9, 2013 01:57 |
|
If nothing else, consider it practice
|
# ? Jan 9, 2013 02:20 |
|
Freakus posted:Html in code is bad, but code in templates is bad. There's more code than html in all rewrites I've seen - really, what's the point either way?
|
# ? Jan 9, 2013 11:54 |
|
Found about a bazillion instances of this in a ASP.NET MVC3 projectcode:
|
# ? Jan 9, 2013 13:09 |
|
code:
|
# ? Jan 9, 2013 20:12 |
|
kedo posted:
just a guess, but maybe it's less frustrating for some people to just using divs and replicating the standard p styling instead of figuring out you need to do something like code:
|
# ? Jan 9, 2013 20:21 |
|
Recently inherited a C# codebase of dubious quality. Spent the past few days trying to track down an asinine little error with our streaming app not properly identifying song data. The Test Page absolutely insisted that the metadata service was working properly and was returning info. According to the guy who wrote the system, The Test Page Is Infallible. Let me repeat that, THE TEST PAGE IS INFALLIBLE. It was written by the best .net engineer ever and will instantly detect any problem with services it exercises. Any problems that showed up elsewhere in the system, the first thing he would do is check agains The Test Page. Issue not showing up on The Test Page? Your loving problem, scrub. Stop wasting my time. After beating my head against the problem I finally said fuckit, and fired up Wireshark in the hopes that maybe the mobile devices were doing something stupid like malforming the request somehow. A quick gander at requests from the mobile devices and then The Test Page showed me one interesting discrepancy. A single query string variable, "test=2" that The Test Page was passing, but nothing else was. Hrm, interesting, that gets appended to the request by a piece of javascript hidden 4 layers deep in includes on that page. Almost like someone was trying to hide it. Ok, let's search the handler code for this test variable and see what it does. Again, buried as deep as it can be buried under layers of delegate handlers, I discover this: code:
The Test Page Is Infallible indeed.
|
# ? Jan 9, 2013 21:50 |
|
kedo posted:
It's HTML5. The class="paragraph" makes it a microformat.
|
# ? Jan 9, 2013 22:59 |
|
Verloc posted:
Change it to look for a "3" instead, and then go back to him.
|
# ? Jan 9, 2013 23:09 |
|
dwazegek posted:Found about a bazillion instances of this in a ASP.NET MVC3 project This makes me want to puke.
|
# ? Jan 10, 2013 07:15 |
|
dwazegek posted:Found about a bazillion instances of this in a ASP.NET MVC3 project [Junior dev drops XHTML tag into HTML document] "Why the gently caress am I getting a warning? Stupid Macro$uck!! They can't do anything right!" [Dev changes tag to a string echo, saves day]
|
# ? Jan 10, 2013 14:49 |
|
php:<? function dieGeneric() { die(); } // ... some code ... function suicide() { die(); } // then in another file which is always included function tantrum($message) { die(); } ?> These aren't the only ones in the project, either, and most of them are used somewhere.
|
# ? Jan 11, 2013 06:02 |
|
php:<? function getFarFutureTime() { /* This is used to set a cookie to expire some time in the future. We'll make it 31/12/2025 so that an update to the site should be done before then. This is how Y2K style bugs are started, but if this is site remains unmodified till 2025, i'll do the update pro bono :) */ $thetime = mktime(10,10,10,12,31,2025); return $thetime; } ?> And one more: php:<? function dbError($conn, $message = '', $query = '') { //MailError($message . "\n" . $conn->ErrorMsg() . "\n" . $query); //die($message . "\n" . $conn->ErrorMsg() . "\n" . $query . "<br/>\n"); } /* function dbError($message = '') { global $conn; die($message . $conn->ErrorMsg() . "<br/>\n"); } */ ?>
|
# ? Jan 11, 2013 06:06 |
|
Lucky you — The dev before you commented his "e-mail the error to an alias" code.
|
# ? Jan 11, 2013 06:44 |
|
bobthecheese posted:
This sounds not so much like a horror as a sadly neglected coding masterstroke.
|
# ? Jan 11, 2013 11:40 |
|
Gazpacho posted:Oh, I can just guess: Might've been an intern who initially wrote it like this. But the horror goes a bit deeper than that. The guy who mostly works on this project is definitely not a junior developer, but he does heavily favor the copy-paste style of programming, so, what otherwise might've been a few isolated WTFs, are now repeated dozens or even hundreds of times throughout the code base. For bonus fun, he seems to have realized the stupidity of the aforementioned code, and fixed it on a few pages. By "fixed it" I mean he changed it into this: code:
|
# ? Jan 11, 2013 14:15 |
|
|
# ? May 27, 2024 22:12 |
|
Well if you decide to fix it be really careful and go slow and test everything. In my previous job I rewrote some copy-pasted code to about a tenth of the code size and felt really good about it until a customer site in Japan said they were broken. (I had left one of their copies out of the new version.)
Gazpacho fucked around with this message at 21:18 on Jan 11, 2013 |
# ? Jan 11, 2013 21:15 |