This gem was unearthed while performing some maintenence on an old application from a long-departed developer. Apparently, managing access via user permissions was a bit too subtle for his taste....
This gem was unearthed while performing some maintenence on an old application from a long-departed developer. Apparently, managing access via user permissions was a bit too subtle for his taste....
@morbiuswilters said:
@lscharen said:@morbiuswilters said:
@DrPepper said:Concur. The point is not the speed of the thing; it's the readability. It takes a long time to figure out what the first one is doing; the second one takes a fraction of a second.The most readable would just be using the date library's "format as 2-digit year" option..
What date library do you use that has a built in function to return an integer value representing the 2-digit year?
Why would it have to return an integer? Most languages easily convert strings to integers..
Because that's what this code needed
int.Parse(DateTime.Now.Year.ToString().Substring(2));
It was converting an integer to a string, chopping off the last two charaters and then parsing the string back to an int.
@The_Assimilator said:
Meh, I've been writing code for a decade and I would've probably used the first one. Assuming speed isn't an issue here (and if it is, you've got bigger problems) then it's a case of six of one/half a dozen of the other.
Well, since I only have 230% of your experience, I will take this comment under advisement.....
@morbiuswilters said:
@DrPepper said:Concur. The point is not the speed of the thing; it's the readability. It takes a long time to figure out what the first one is doing; the second one takes a fraction of a second.The most readable would just be using the date library's "format as 2-digit year" option..
What date library do you use that has a built in function to return an integer value representing the 2-digit year?
Well, when you have to interoperate with legacy mainframe applications, you do what you gotta do. Would I like to replace it with a DateTime.UtcNow and call it a day? Yes. Yes I would.
Not the worst WTF I've seen in my current project, but it is a bit facepalm worthy:
var recordYear = int.Parse(DateTime.Now.Year.ToString().Substring(2));
This got replaced with a more sensible
var recordYear = DateTime.Now.Year % 100;
@drobnox said:
@lscharen said:Ok, so it's a very complicated way of doing a simple thing,but....
If I actually needed a thread-safe, named counter in my code, what's a better alternative?
Redis
For some bizarre reason, I would not consider replacing an integer counter with a server to be "better".
Ok, so it's a very complicated way of doing a simple thing,but....
If I actually needed a thread-safe, named counter in my code, what's a better alternative?
@Medinoc said:
I know what "QA" is, but what does "BA" mean?
Business Analyst. A genuinely useful and valuable job, if it's done by a competent person that has an actual interest in understanding the problems a piece of software is supposed to solve and the needs of the customers who will be using said software.
Force the original developer to implement polymorphic return types into the JVM. This will place them in an infinite busy loop and rendered harmless to future generations.