Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
we just switched to slack and giphy has a disappointingly high anime to actual good gif ratio

Adbot
ADBOT LOVES YOU

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
we use flowdock and i like it

Pizzatime
Apr 1, 2011

I don't like XML

rarbatrol
Apr 17, 2011

Hurt//maim//kill.

Suspicious Dish posted:

we just switched to slack and giphy has a disappointingly high anime to actual good gif ratio

We switched a few months ago. Only a few NSFW giphy incidents so far. Apparently, "bouncy" is a bad keyword.

kitten emergency
Jan 13, 2008

get meow this wack-ass crystal prison
Giphy is awful. Unsurprisingly, it got turned off after a week and then the sales dudes whined until it got turned back on.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Pizzatime posted:

I don't like XML



looks like the problem's with the library you're using, xml doesn't need to be any more painful than any other structured serialization format

Pizzatime
Apr 1, 2011

Soricidus posted:

looks like the problem's with the library you're using, xml doesn't need to be any more painful than any other structured serialization format

I'm not sure if I'm allowed to use anything outside of the .NET framework so I was scared to use LINQ to XML or something similar.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Pizzatime posted:

I'm not sure if I'm allowed to use anything outside of the .NET framework

horror spotted

raminasi
Jan 25, 2005

a last drink with no ice

Pizzatime posted:

I'm not sure if I'm allowed to use anything outside of the .NET framework so I was scared to use LINQ to XML or something similar.

Well, XML deserialization comes out of the box, so unless you're doing something fancy you don't need to.

Visual Studio will even (try to) write the classes for you

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings
It's also pedantic as hell, but mixing int and Int32 in C# is just so goofy. Choose one and use it :v

SupSuper
Apr 8, 2009

At the Heart of the city is an Alien horror, so vile and so powerful that not even death can claim it.

Pizzatime posted:

I'm not sure if I'm allowed to use anything outside of the .NET framework so I was scared to use LINQ to XML or something similar.
That is .NET Framework. Either way you should just write classes and let .NET map them to XML for you, instead of walking the XML tree yourself.

ninjeff
Jan 19, 2004

Pizzatime posted:

I don't like XML



your code is bad and it's not because of the libraries you used

brap
Aug 23, 2004

Grimey Drawer
yeah dude you just need to learn to deserialize XML using the built-in stuff.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

For me, the bad thing about XML is manual editing or reading. Like programs that use an XML file for configuration and expect the user to edit those. gently caress those programs.

If I can use a library, I don't give a crap what format it uses.

HFX
Nov 29, 2004

Thermopyle posted:

For me, the bad thing about XML is manual editing or reading. Like programs that use an XML file for configuration and expect the user to edit those. gently caress those programs.

If I can use a library, I don't give a crap what format it uses.

They aren't so bad if you have an editor that is XML aware and hopefully can even understand XML schemas. Just hope you don't get called in the middle of the night to fix something and find out the system it is running on has vanilla vi.

Bognar posted:

C# code:
/// <summary>
/// Summary description for PCAUtilities
/// </summary>
public class PCAUtilities
{
    #region Properties

    public double CrashReportsTimeSpan { get; set; }

    #endregion Properties

    public PCAUtilities()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    protected string mdy(string s)
    {
        if (String.IsNullOrEmpty(s))
            return "99/99/9999";
        string y = (string)s.Substring(0, 4);
        string m = (string)s.Substring(4, 2);
        string d = (string)s.Substring(6, 2);
        return m + "/" + d + "/" + y;
    }

}
In its defense, mdy is protected and PCAUtilities is never inherited.

I've seen people do stuff like this in Java too when dealing with dates.
While this one is probably fine, the cases where I run into it is because they don't know how to deal with parsing a date into a Date and properly handling timezones before storing it somewhere that expects a different format.

That said, I wouldn't say this is a horror, just someone who is under experienced. It reminds me of the code my college new hires write especially if they didn't come from an IS background.

HFX fucked around with this message at 04:26 on Feb 1, 2016

gonadic io
Feb 16, 2011

>>=

HFX posted:

handling timezones before storing it somewhere that expects a different format.

Please don't trigger me.

I'm slowly removing all instances of millisAtMidnight from our codebase as now the company has offices and operations in the UK but our servers (and half the dev's) laptops are still in Italy.

For now we're just switching to millisAtNoon but by god I can't wait to have actual Dates, as opposed to nothing but DateTimes.

qntm
Jun 17, 2009

gonadic io posted:

Please don't trigger me.

I'm slowly removing all instances of millisAtMidnight from our codebase as now the company has offices and operations in the UK but our servers (and half the dev's) laptops are still in Italy.

For now we're just switching to millisAtNoon but by god I can't wait to have actual Dates, as opposed to nothing but DateTimes.

What is "millisAtNoon"?

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

qntm posted:

What is "millisAtNoon"?

More importantly, why is that an improvement over "millisAtMidnight"?

gonadic io
Feb 16, 2011

>>=

qntm posted:

What is "millisAtNoon"?

The number of milliseconds since epoch start until noon on a given day. MillisAtMidnight plus 12 hours. Which timezone? Hopefully UTC...

Dessert Rose posted:

More importantly, why is that an improvement over "millisAtMidnight"?

Because they all get converted back into a date anyway, so when we gently caress the timezones up and get moved an hour back 11am is the same date as noon. 11pm is not the same date as midnight.

gonadic io fucked around with this message at 12:36 on Feb 1, 2016

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

gonadic io posted:

The number of milliseconds since epoch start until noon on a given day. MillisAtMidnight plus 12 hours. Which timezone? Hopefully UTC...


Because they all get converted back into a date anyway, so when we gently caress the timezones up and get moved an hour back 11am is the same date as noon. 11pm is not the same date as midnight.

Until you open an office in Kiribati, that is: https://en.wikipedia.org/wiki/UTC%2B14:00

Thanks to that stupid timezone (and the UTC+13:00 timezone) there's no time of the day where the whole planet is on the same date.

Edit: I posted this at 12:00:00 UTC because I'm cool like that.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

HFX posted:

That said, I wouldn't say this is a horror, just someone who is under experienced. It reminds me of the code my college new hires write especially if they didn't come from an IS background.

While no part of it is particularly egregious, I liked the whole class just because there's an example of what not to do on almost every line. In order:

1. Useless XML-doc comments
2. Region directives around a single property
3. A property called "...TimeSpan" that is of type double (and is used elsewhere in the code to convert to and from a TimeSpan object)
4. An empty constructor that could be removed containing a useless TODO
5. A protected helper method in a class that is never inherited, that
6. Returns an invalid date if the input is null/empty
7. Doesn't do any length checks before calling Substring
8. Casts string to string

The entire class could be replaced with a variable of type TimeSpan.

Beef
Jul 26, 2004
I am working on an industrial branch of an academic branch of academic code that has evolved over a decade of engineering students plugging away at it between paper deadlines. Wading through the code and trying to document the software architecture is akin to mapping a jungle that has grown over mayan ruins. All code evolved over time, but no one ever thought or dared to change the architecture.
This is an archetypical big ball of mud project and a goldmine for coding horrors.

Q: Why does this object serialize itself to a byte array, only to be deserialized right after? A: Oh, there used to be separate processes, but it got mashed together. It works.
Q: Why does this mother of a God class subclass some other class and is the only class to do so? A: Well, there used to be different subclasses... It works.
Q: Wait, this object has an enum value field that is constantly checked in a switch statement to see what code to run on it? A: This was probably from a student that had a poor grasp of polymorphism. But hey, it works.


Guess who has to wade through the entire code and document it!


Today's drop in the bucket: It is neither helpful nor OK to split up your gigantic monstrosity of a function into multiple functions overloaded with the same name.

code:
void doCommit(T1 foo, T2 bar) {
  ...
  doCommit(T3 baz, T4 quux, ...)
  ...
}
Oh and it calls methods of other objects that have again the same name with again different signatures and functionality.

Beef fucked around with this message at 17:56 on Feb 2, 2016

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Beef posted:

I am working on an industrial branch of an academic branch of academic code that has evolved over a decade of engineering students plugging away at it between paper deadlines. Wading through the code and trying to document the software architecture is akin to mapping a jungle that has grown over mayan ruins. All code evolved over time, but no one ever thought or dared to change the architecture.
This is an archetypical big ball of mud project and a goldmine for coding horrors.

Ahh, reminds me of a previous job. I was brought on to fix issues this lab was having with their custom-built-over-ten-years hardware control program. It crashed every once in awhile, they didn't know why, and the previous dev and the original dev had both left for greener pastures.

The program was written largely in Python, which is fine; I like Python. Normally. But I hadn't counted on academic Python, especially not a 25-kline Python monstrosity. Among the things I found in this system, and leaving aside such pedestrian matters as inscrutable variable names and a nigh-total lack of informative comments, were:

  • Most modules were named after the original developer (name changed to protect the guilty). So e.g. there was DanB.py, DanC.py, DanJ.py, DanM.py, and of course Dan.py. All of these modules were reduced to single-letter names when imported -- "import DanB as B". Except for the Dan module, which was always imported as X.
  • There were almost no classes; each module was just a collection of functions and state, like a singleton. Except that all program state was stored as fields in the Dan module. Figuring out who accessed or modified a given variable therefore meant searching the entire program, because literally every module imported the Dan module.
  • I tried to generate a dependency graph of the program using a static analyzer. The analyzer crashed.
  • The developers had heard of source control, and didn't believe in it. Instead, whenever they made a change to the system, they would comment out the old code, and mark it with a date and the name of the developer that had made the change, but no comment indicating why the change was made. Most of the dates were from at least five years ago. The first thing I did when I started work was to make a repository. The second thing was to delete at least 5k lines of useless comments. Ultimately I was able to shrink the program to literally half its original size by deleting cruft and refactoring.
  • There was a separate "library" of utility functions that the developer had made to use in this and other programs he had worked on. It too contained its own set of Dan* modules, as well as "helpful", "helpfulX", and "helpfulX2" all of which did different things. I had a method call in one of the modules I was trying to track down. It called a function in helpfulX2 named "func2". I opened up helpfulX2; all I could find was
    code:
    func2 = func
    with func nowhere to be found in helpfulX2. But helpfulX2 does "from helpfulX import *". So I open up helpfulX; again, func is nowhere to be found. But helpfulX does "from helpful import *"! And indeed in helpful.py I finally found func. It was a wrapper function around a Numpy library function.

Xarn
Jun 26, 2015

TooMuchAbstraction posted:

I tried to generate a dependency graph of the program using a static analyzer. The analyzer crashed.
:v:

TooMuchAbstraction posted:

The developers had heard of source control, and didn't believe in it. Instead, whenever they made a change to the system, they would comment out the old code, and mark it with a date and the name of the developer that had made the change, but no comment indicating why the change was made.

What is it with people and using these kinds of bullshit instead of version control? I can see why someone would just comment out poo poo in 20 line script instead of versioning, but how do you get to the 25KLOC monstrosity without thinking "There is got to be a better way"? (Hell, how do you get to 1KLOC without thinking that)

Beef
Jul 26, 2004
:stare: At least I am dealing with a buildup of small --innocuous by themselves-- changes.

To add some content to the post:

The mother of all singletons is referred to by nearly every class in the system and contains an amalgamation of configuration objects, reporting/logging and the kitchen sink. It is the product of years of thinking along the lines of:
"I could pass the relevant configuration options to the constructor of this class, but that is too much effort. Let's put all this information that only this class uses in this God singleton object and 3-arrow access my way to the relevant data in the constructor."
Accessing anything useful from it requires 3, 4 and the mythical 5-star programming style with really long multi-part variable names. I have lines wrapping on my 1920p-wide display.

I made a collage of the collaboration diagram of a single important class once, it fit on 8x A4 pages pasted together with the smallest readable font. Doxygen gives up on most classes and the pub/priv. box (generated UML) is typically "...196 more"

One of the method chains starts with about a dozen arguments,
takes one off and passes it along,
eleven more on the arguments chain.

There was documentation on the top-level function of the above chain, it lists four methods and somehow survived a decade of people adding arguments without bothering to change the documentation comments.

xzzy
Mar 5, 2009

Laziness?

"We got this far doing it this way, and changing the process means I have to spend X amount of time refactoring all this stuff, or I could spend a fraction of that time continuing like we have been."

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Xarn posted:

What is it with people and using these kinds of bullshit instead of version control? I can see why someone would just comment out poo poo in 20 line script instead of versioning, but how do you get to the 25KLOC monstrosity without thinking "There is got to be a better way"? (Hell, how do you get to 1KLOC without thinking that)

For this I'll blame the boss of the lab, who did not understand version control and was paranoid about losing anything. He kept literally everything from every piece of hardware he bought (we had a room full of old boxes and packing material, just in case we ever needed to ship something back to the manufacturer). We also had many, many binders full of the manuals for each device in the system; he did not cope well with the "modern" trend of including only software versions of manuals. As for source control, he asked to see some of my code at one point and nearly had a fit when he realized there were no dates or logs in the code and therefore it wasn't immediately obvious when things had changed. I spent a good hour telling him about how source control worked, demonstrating that I could pull up any version of the program at a moment's notice, and talking about our backup strategy, and I'm fairly certain he still didn't believe me.

Amberskin
Dec 22, 2013

We come in peace! Legit!

Xarn posted:

:v:


What is it with people and using these kinds of bullshit instead of version control? I can see why someone would just comment out poo poo in 20 line script instead of versioning, but how do you get to the 25KLOC monstrosity without thinking "There is got to be a better way"? (Hell, how do you get to 1KLOC without thinking that)

Mainframe background.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe
Oh, that reminds me! At one point my boss asked for a dump of the contents of the repository, so I handed him a printout of the (slightly formatted) contents of `find`. He asked me where the information about what each directory contained was; I pointed at the README.txt files I'd made. He declared this inadequate, and asserted that back in his day, every directory had included, as part of its information, some manner of comment string declaring what it was for -- like, when you made a new directory, you had to write in a bit of text saying "for storing photos of cats" or whatever. And then you'd see that string whenever you did a directory listing, "so you always knew what everything was for."

I don't remember ever seeing an OS that worked that way, but I could believe that it happened on systems that lost prevalence before I entered the workforce. Maybe a VAX?

Cuntpunch
Oct 3, 2003

A monkey in a long line of kings

xzzy posted:

Laziness?

"We got this far doing it this way, and changing the process means I have to spend X amount of time refactoring all this stuff, or I could spend a fraction of that time continuing like we have been."

This also seems to be a symptom of poor unit testing - often combined in a moderate risk corporate environment. When you don't trust your tests to tell you if you broke downstream code with a change, you end up trying to make every change as small and minimal as possible, rather than tearing apart entire widely-used classes to make them better.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Beef posted:

:stare: At least I am dealing with a buildup of small --innocuous by themselves-- changes.

To add some content to the post:

The mother of all singletons is referred to by nearly every class in the system and contains an amalgamation of configuration objects, reporting/logging and the kitchen sink. It is the product of years of thinking along the lines of:
"I could pass the relevant configuration options to the constructor of this class, but that is too much effort. Let's put all this information that only this class uses in this God singleton object and 3-arrow access my way to the relevant data in the constructor."

dependency infection

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

Nude
Nov 16, 2014

I have no idea what I'm doing.

This is a pretty good metaphor for a procrastinator.

brap
Aug 23, 2004

Grimey Drawer

Cuntpunch posted:

This also seems to be a symptom of poor unit testing - often combined in a moderate risk corporate environment. When you don't trust your tests to tell you if you broke downstream code with a change, you end up trying to make every change as small and minimal as possible, rather than tearing apart entire widely-used classes to make them better.

It can be poor unit testing, lack of testability as in you can't write unit tests for some of these mudballs, and even lack of testability as in you can't even run the app and be that confident of what the original behavior was supposed to be.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sometimes writing a unit test involves having to hook the OS, or simulate complex hardware. Not everyone is set up to write a dummy USB driver.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

This actually seems fine? Breaks out of the loop if try() returns true, and assigns it to succeed.

I mean, "succeed" is kind of a useless variable there, and I don't think you can call a method try() in a language where that's a keyword, but...

As stupid sayings translated into code go, at least it actually does what it's supposed to do.

CPColin
Sep 9, 2003

Big ol' smile.
Except you're always trying at least once, but the saying says to try only if you don't succeed first.

qntm
Jun 17, 2009
So,

code:
do {
    succeed = try();
} while(!succeed);
?

Nude
Nov 16, 2014

I have no idea what I'm doing.

Dessert Rose posted:

This actually seems fine? Breaks out of the loop if try() returns true, and assigns it to succeed.

I mean, "succeed" is kind of a useless variable there, and I don't think you can call a method try() in a language where that's a keyword, but...

As stupid sayings translated into code go, at least it actually does what it's supposed to do.
Just because I made try() a user created function to create a true horror.

https://jsfiddle.net/ojvkp35b/

For the lazy:

code:
 
var Succeed;

function Try ()
{
	if (Succeed)
	{
  		console.log ("Coding");
  		Succeed = true;
 	}
  
  	if (!Succeed)
 	{
  		console.log("Horror");
   	 	Succeed = true;
 	}
  
  	return Succeed;
}

Succeed = true;
while(!(Succeed = Try())); //Outputs "Coding"
Succeed = false;
while(!(Succeed = Try())); //Outputs "Horror"
It's not that bad I guess. And of course the do (while) mentioned by the above poster would make it way more readable.

Nude fucked around with this message at 19:12 on Feb 3, 2016

Adbot
ADBOT LOVES YOU

M31
Jun 12, 2012
Success is signalled by a 0 return code

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply