|
zootm posted:This is not a good example of bad naming in Java, and there are lots of good examples. May I please get some? Been using it for so long, I've never had a problem with Runnable->run, Thread->start, Cloneable->clone (even tho clone is part of Object). And I don't remember ever seeing a bad naming example in Java. Anyhow, back to the topic, here is my code that I found in an application I was tasked to maintain (fix bugs): code:
Anyhow, the rest of the code was just as bad. I want those 2 wasted months in my life back.
|
# ¿ May 13, 2009 18:31 |
|
|
# ¿ May 10, 2024 10:13 |
|
Avenging Dentist posted:Or you could use something called "namespaces" and allow people to apply using declarations to minimize verbosity. A radical idea, I know. Am I weird for not finding those names...bad? I don't see the problem with a 20 character long class name. I mean, I would have had such a problem back in Borland C++ 3.1 days, but today, with today's IDE's, its all a CTRL+space away.
|
# ¿ May 14, 2009 00:57 |
|
Avenging Dentist posted:Yes. You are weird. It's not even about typing them, it's about reading them. Anything nontrivial with any of those functions (and given Java's propensity for verbosity, that's 99% of things) is going to be spread out on multiple lines or will just scroll horizontally off the screen. A good sign that your code is poo poo is when a majority of the individual statements have to wrapped to fit on the screen. Aha , I see it now. So at the end of the day its just a matter of taste. I hate it when I see cryptic code, even if it has comments. I love it when I can "read" the code, even without comments. And no, don't give me the 80 columns crap. Nobody nowadays has an 80 col limitation, upgrade your drat monitor if you do, so no, there is no need to wrap on multiple lines most of the statements. If you can't upgrade your monitor and are forced to use an 80x25 screen...don't do Java. Plain and simple. Most likely the stuff you're doing (with those limitations) is not appropriate for Java. It is just a matter of taste. Even though I program in C just as much as I do in Java, I like the Java style more. I like to comment the algorithm used, not the fact that I just wrote in one line the most complicated code ever. So , sorry sir, those class names are fine.
|
# ¿ May 14, 2009 01:43 |
|
biznatchio posted:So what advantages would I have for choosing Perl 6 for a new project being started today over, say, a language that exists? As usual, the answer to that is: depends on your project. Perl is a language suited for certain tasks (and here i'm looking at its legendary strong point: regular expressions), and probably not so suited for others. Can you build a GUI app with it? Of course. Should you? I doubt it. Especially since PERL-compatible regex libraries have been created for other languages as well (java, c/c++, python i think) So, at the end of the day, the questions to be asked are: - Does my project require certain features that PERL would be a perfect solution? - Who will code it? Do those people know PERL?Do they wanna know PERL? - Who will maintain it? Does that team know PERL ?Do they wanna know PERL?
|
# ¿ May 15, 2009 15:38 |
|
Powerful Two-Hander posted:Not so much a coding horror but some bright spark apparently decided to do some "tidying" on a production db and tried to rearrange columns in a live table using a gui in a db tool. The only reason I can imagine needing to rearrange columns in a table is so that "select * from table" returns the columns in the desired order, which is a coding horror in and of itself. A simple "select col5, col1, col10 from table" would have accomplished the same thing.
|
# ¿ Apr 15, 2015 20:01 |
|
kitten smoothie posted:From what I gather the generators use the engines to provide power to the plane in flight, and at issue is software in some computer units that manage those generators. I imagine if the engines are powered off maybe there's some battery power unit, or shore power if parked at a gate, that keeps the computers hot. I imagine (I'm not a pilot and I have no idea what I'm talking about) that is more a question of economics. These planes do not turn off. They land on an airport, get the people and luggage off, they board new people and luggage, then they take off. To shut them down would mean to lose money and they only make money while in the air. Given the price tag for one, it would not be surprising that these kind of planes would be (ab)used for 248 days non-stop.
|
# ¿ May 1, 2015 23:46 |
|
IT BEGINS posted:It's not particularly offensive, but we're adding a new feature to this code so we were having to move this stuff around anyway. 'enabled ISNULL' was making things unclear, as well as a few repeated nullchecks for "$enabled != 'n'". Think about it this way: if you make it a boolean, then it can only ever have two values (should be not nullable, of course). If you keep it varchar, then you have TRUE, FALSE and FileNotFound at a later date. What can be more beautiful than that? If it's limited to only one char in length, then you will be limited to 26 states, hopefully you can manage that.
|
# ¿ May 6, 2015 00:26 |
|
In a java web application (spring based), one developer thought that when an administrator updates a user information (including password), that administrator should enter the original password of the user. That is a WTF in and of itself, but it gets better. So, how do we check if the password entered is the same as the one in the database? You wouldn't believe it (comments are mine):Java code:
Java code:
|
# ¿ Jul 25, 2015 00:28 |
|
Suspicious Dish posted:I believe it. The dude doesn't know about this.passwordEncoder and instead writes fairly clear and understandable code to check the password instead. You should have just laughed and said "oh, you don't have to write this, Spring injects a service for us that does this" and CR failed it. Then he would have said "oh cool, that makes things easier" and fixed it. And then you wouldn't have tried to make fun of him on an internet forum for him not knowing literally everything about the massive 500,000 LOC Java Enterprise framework he's using. code:
|
# ¿ Jul 25, 2015 18:15 |
|
Soricidus posted:can't we just be impressed that this codebase is actually using a non-terrible method for storing passwords in the first place? Heh...until 3 weeks ago that codebase stored passwords in javascript. Literally code:
|
# ¿ Jul 25, 2015 18:27 |
|
Ender.uNF posted:Programming languages never die, they just run in/on javascript. And it's not even the only one: quote:There are several other implementations of Tcl in Javascript ...
|
# ¿ Feb 5, 2016 01:03 |
|
Holy poo poo, is the payoff that big that its worth it? This screams "runaway little girl, run away" from kilometers ahead. I mean, to build one's entire stack on something like javascript is incomprehensible to me but understandable when the promised payoff is bigger than the investment. But when that ugly lie is showing its big ugly head ... why go on? The entire show is built on a house of cards anyway. Kill it, shove a stake through its heart and walk away never looking back.
|
# ¿ Feb 20, 2016 04:12 |
|
JS like JS. It's a language, it has its quirks and .. oh well, you learn to live with them. But the developers... that's the real WTF. The kids that run the npm showshit, the contributors, the lego "programmers" who write that horrifically wrong line of code that gets published without any oversight and gets used over and over again (because nobody knows any better), that's the real WTF. And they call themselves developers. Full stack developers. They put that poo poo on the server-side where things like is_int or _is_array should have never been even questions, and yet they are. But .. I'm the old-fashioned one. Why are they even allowed anywhere close to a computer?
|
# ¿ Apr 2, 2016 01:05 |
|
Which brings us to the second "flag" you need to know: "man echo" . For more detailed information, you can always check the info pages as well.
|
# ¿ Aug 15, 2016 19:41 |
|
There are, yes, numerous verbosity complaints about Java, but the IDEs have largely fixed all/most of them. Any half-decent IDE would automatically generate the ActionListener boilerplate, or the setters/getters or toString/hashCode/equals methods. Java 8's lambdas are, in my opinion, even more dependent on the IDE, since it is not clear from the code what type of argument the lambda gets. As for reading it, that comes down only to practice. I find reading Python code quite the workout, for example. Is this line belonging to this block or the one above it? Is that a space or a tab or are my settings messed up? Did you mean to put that space in there or was it a mistake? What does this module do? Just like in Java 8: "lambda event: do something", what is that event? What members does it have and what can it do for me? Without an IDE I am completely lost.
|
# ¿ Aug 16, 2016 17:05 |
|
feedmegin posted:Doesn't help with the complaint about reading the code though. Plus, to my mind a language that requires an IDE to generate massive chunks of code for you to be usable is not a very good language. You'd hate C++ then. Or, not to mention, C. Scala ... eh, is an interesting language, but when reading some gibberish code and then trying to google for it to see WTF is that thing doing and the search returns no results, what does that say about that language then? And about the IDE hate: what year are you living in? Without syntax coloring or some modicum of autocompletion or at least helpers and hints every now and then ... it sucks, doesn't matter the language. I wrote code in Turbo C++ on a monochrome monitor back in early 90s, I don't wanna do that again.
|
# ¿ Aug 16, 2016 20:59 |
|
feedmegin posted:My day job is writing C++ and it doesn't involve an IDE generating anything, nor is the codebase I work in excessively verbose. Why would you think it did? If you think that Java is more verbose than C++, well, I don't know what to say. Though, is it true, code generation in C++ from an IDE is even now in infancy, compared to Java/C#, so you can't do that even if you wanted to.
|
# ¿ Aug 17, 2016 12:43 |
|
leper khan posted:Lolwhatareyouonabout. It doesn't have variadic templates, but it does have variable arguments: void iSeeYourPoint(int... noneedfor100methods) { }
|
# ¿ Aug 17, 2016 14:41 |
|
NihilCredo posted:Speaking of Java boilerplate, am I the only one who sees this as a coding horror? I hope not. That's simply stupid.If it contains "extreme" in the name ... its probably safe to not follow.
|
# ¿ Aug 17, 2016 15:37 |
|
necrotic posted:Good point... I've been targeting senior so I'm in that mindset. And we do not do crypto. To be fair it's not an immediate no but a good indicator for most folks. Unless your entire job is writing a crypto library/toolset. And the position you're hiring for is a crypto expert that can help you get "to the next level" (whatever that may be). In that case, "don't roll your own" is obviously the wrong answer.
|
# ¿ Aug 25, 2016 03:42 |
|
canis minor posted:Taken from SO What? How? How does that even remotely work? JS is full of lovely "magic-tricks" but this one takes the cake (and I'm aware of the truth table).
|
# ¿ Oct 24, 2016 18:32 |
|
xzzy posted:As long as javascript remains a dominant player json ain't going anywhere. Isn't this more about how garbage the parsers are and less about how lovely json itself is? While I haven't read the RFC, in common usage json doesn't come as being inherently flawed, unlike yaml, where the tiniest mistake (wrong space or tab) breaks the entire thing. And about JS: are the existing JS engines so performant that nobody wants to replace them? Even chrome doesn't come with a native Dart engine (it did in a developer edition). Or Edge with Typescript. Everyone just compiles to JS, like is the holy loving grail of languages.
|
# ¿ Oct 27, 2016 16:13 |
|
All this voice recognition stuff ... Bullshit. What we need is the ability to just think and the computer to just do: https://en.wikipedia.org/wiki/Brain%E2%80%93computer_interface . With a bit more research we can overcome whatever barriers exist right now in BCI to be commercialized. That's where the future is.
|
# ¿ Nov 18, 2016 02:06 |
|
99 is XCIX in roman numerals since you're not supposed to have more than 2 levels of difference between letters. IC, while shorter, breaks that rule since you have 4 levels between I and C.
|
# ¿ Jan 1, 2017 17:34 |
|
QuarkJets posted:I've been forced to work with some project that uses the Matlab compiler to create a standalone executable for running on some batch nodes, and randomly about 1% of the time the executable just crashes as it's launched. I assumed it was some issue with the code, but the crash occured suspiciously fast and didn't leave behind any useful information so I began to wonder if maybe I was using the compiler wrong. The solution is that Matlab should not be used in production. It's awesome for the research phase, but when the research is over, implementation for the product should be done by a developer in whatever language the product is going to use.
|
# ¿ Jan 6, 2017 14:53 |
|
New Yorp New Yorp posted:DI is a method of implementing IoC. It's just a way of solving the problem "I want to test a thing that gets data from a web service/database/other complex component without actually involving the web service/database/other complex component" or, "I want this thing that gets data from something else to be able to get data from any number of something elses based on some set of criteria, without altering the logic of the thing". My way of looking at it is as follows: "In order to do my job I need an instance of X. Someone give that to me." In the example presented above, Foo needs a Bar to be able to do its work. It explicitly asks for it in the constructor, and Main provides it when it makes a Foo. What DI frameworks do is provide that automatically (via the magic that is also known as reflection). All that Main has to do is tell the DI framework: whenever anyone requests an IBar give them an instance of this Bar object. That's all there is to it. But then, you can't go and say "new Foo()" anymore. You have to go to the DI framework and ask it to make a Foo for you. Then the DI framework will take care of providing all the required dependencies that Foo asks for.
|
# ¿ Mar 17, 2017 20:37 |
|
RandomBlue posted:Frankly I hate "magic" things that just happen. It obfuscates what's actually going on and makes it much harder for someone unfamiliar with that type of magic or a particular code-base to actually understand what's happening for very little actual gain. You've saved yourself having to pass in a constructor parameter? It shouldn't obfuscate anything in a properly designed library. But I agree about .Net. I had the "pleasure" to work with it in the last 6 months or so. Coming from C++ and Java, C# looks like a better Java. It is a better language no question about it. But (and here is when the fun comes in), everything in the .Net ecosystem, the tools, the libraries, the frameworks, look like an undernourished child from Somalia with Down syndrome that was just rescued by a compassionate person when compared with your normal, healthy and properly fed (almost obese) Western boy (Java). It's not even funny. Why do developers subject themselves to that abuse? C#'s superiority over Java at the language level is not maintained everywhere else. Not to mention Microsoft's almost comical tendency to make everything 100 times more complicated than it needs to be, then turning around and instead of fixing the old library, just releasing a brand new one with different (but just as bad) problems than the one before.
|
# ¿ Mar 18, 2017 00:02 |
|
RandomBlue posted:Overall though, Java is pretty nice for cross-platform work since JavaFX was made available, but Java seems to have a huge image problem with the public perception of it still based on how things were 10+ years ago when Java apps used Swing and looked horrible and the performance wasn't great. Oh, you're talking about java desktop. That's not its strong point, it never was. I've done my share of swing and javafx applications in the last 20 years (and they're really nice and fast frameworks once you get to understand them and learn how to use them) but my advice would be to just not do it if you can help it. The image perception is not something you can change overnight, and the expectations change daily. Use java for the server, let it stay there and use "whatever" for the client(s). A bit of web, a bit of native, it all helps.
|
# ¿ Mar 18, 2017 03:32 |
|
Bognar posted:The point is, be judicious in how you apply DI. Be judicious how you design and write code. Never make blanket rules (such as "all classes have an interface") unless you know you're working with people that require them, never say "never do X" unless it's followed by "unless", do use common sense and best practices to solve the problem at hand.
|
# ¿ Mar 19, 2017 18:09 |
|
TooMuchAbstraction posted:Don't forget the platforms being historically garbage. Needing, effectively, three different versions of your website, or just flat-out saying "this website is not compatible with $browser", used to be super-common. Hell, it may still be common in some limited capacity, but not to the scale I remember it being like back in the mid-2000s. Now, instead of Netscape or IE is Chrome. There are way too many websites out there that only work on chrome, using some non-standard feature of the browser. It's back to where we started, just different actors.
|
# ¿ Mar 24, 2017 21:01 |
|
raminasi posted:There's only one good FizzBuzz implementation and I don't know how anyone could argue differently Amazing indeed. But now, to learn tensorflow just to be able to properly solve fizzbuzz seems a bit much. A solution with 4 interfaces and 8 implementations and 20 unit tests could be a bit more down to earth, don't you think?
|
# ¿ Apr 7, 2017 01:06 |
|
ZHamburglar posted:Should I just post my code from when I was learning Javascript? Or would that be considered gore? You can post the Javascript code you're writing now. Or would that be considered gore?
|
# ¿ Apr 13, 2017 16:16 |
|
RandomBlue posted:Restarted my dotnet core service ~12 hours ago and checked it this morning: I don't think they have any QA anymore. You are the tester, enjoy.
|
# ¿ Apr 14, 2017 18:48 |
|
Eela6 posted:The fact that Javascript still doesn't have integers is loving mind-boggling. The fact that Javascript still exists is loving mind-boggling.
|
# ¿ Apr 19, 2017 00:29 |
|
NtotheTC posted:My life as a developer was infinitely easier when the backend was where the logic went and the front end just handled displaying content. But as a user I've gotta say I much prefer it when a site pre-warns me that a form field is invalid before I send it. Why can't you have both? Why having in the frontend is that much harder?
|
# ¿ Apr 24, 2017 13:22 |
|
nielsm posted:The actual hard part is keeping validation at both ends in sync, or ideally making a solution to use a single code base for both. This is one of the arguments in favor of having javascript on the server. Sorry, that's just insane. Is just an object validation. Even if you have 1000 of them, their business rules don't change that often (or shouldn't) to actually be a burden to keep in them sync in different languages/platforms. And like someone pointed out earlier, validation on the client is optional (if it's wrong ... meh, the QA will let you know, not big deal either way). The server is what matters.
|
# ¿ Apr 24, 2017 17:29 |
|
eschaton posted:You use something like a predicate object to specify your validation rules, so that you can generate client-side JS from it on the server, and the code generator can do its best to guarantee the client-side JS and the business logic and the generated SQL all behave the same. That's one way for sure. It will add an additional "compilation" (transpilation, shittyzation) step, but it would certainly be worth it if it's such a big pain to manually keep them in sync. In my book, this is at most a "meh, whatever" problem.
|
# ¿ Apr 25, 2017 23:51 |
|
leper khan posted:It's nonstandard True, but pretty much everyone supports it: https://en.wikipedia.org/wiki/Pragma_once . And you can't deny its benefits (over the standard include guards). But now that I think about it, the only time I used #pragma once was when I used Visual Studio and the IDE itself wrote that for me.
|
# ¿ May 31, 2017 17:16 |
|
Soricidus posted:I'm the giant block of preprocessor macros to copy/paste into all your header files in order to determine, unreliably, whether or not #pragma once is supported, and if so, to use it completely redundantly in addition to #ifdef guards. This definitely belongs in an encyclopedia If you even remotely suspect that your code will need to be compilable on compilers written in 3000BC, then using the guards is the right thing to do, no question about it. Is not even worth it otherwise. You deserve my compassion and condolences.
|
# ¿ May 31, 2017 18:24 |
|
|
# ¿ May 10, 2024 10:13 |
|
NihilCredo posted:I don't know either Haskell or Go (but would loving suck it up and learn either if critical to my company). Go is a trivial language to learn for anyone. Haskell ... let's just say is has a bit steeper learning curve. Not insurmountable, of course, if you put your mind to it, but you need to want to put your mind to it.
|
# ¿ Jun 27, 2017 12:16 |