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
Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

Aleksei Vasiliev posted:

Wikipedia helpfully explains how to calculate the date of Easter Sunday in MS Excel using what appears to be the most convoluted method possible:
Easter for any given year is pretty terrible to calculate. I'm not even sure this About.com page says it all: http://catholicism.about.com/od/holydaysandholidays/f/Calculate_Date.htm

quote:

The Council of Nicaea (A.D. 325) set the date of Easter as the Sunday following the paschal full moon, which is the full moon that falls on or after the vernal (spring) equinox.

It then goes on to give round dates, which I'm not entirely sure are actually that consistent. And then if you're trying to calculate Easter before the Council of Nicaea, then the best of luck to you.

Adbot
ADBOT LOVES YOU

zokie
Feb 13, 2006

Out of many, Sweden
Easter can go suck a dick, but Gauss's formula works and to be safe just get a list of the next 50 Easters and unit test that poo poo.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
We had a bug in our Easter function recently. It didn't work too well if you gave it 0 as input. (Not really a horror or anything. The bug was just that 0 was being passed in the first place.) But our stupid Hungarian notation, which is ugly on the best of days, is particularly foul here.
C# code:
public static DateTime Easter(int iYear)
{
	int iG = iYear % 19 + 1;
	int iC = iYear / 100 + 1;
	int iX = (3 * iC) / 4 -12;
	int iZ = (8 * iC + 5) / 25 - 5;
	int iD = (5 * iYear) / 4 - iX - 10;
	int iE = (11 * iG + 20 + iZ - iX) % 30;

	if ((iE == 30) && ((iG > 11) || (iE == 24)))
	{
		iE += 1;
	}
	int iDay = 44 - iE;
	if (iDay < 21)
	{
		iDay += 30;
	}
	iDay += (7 - (iD + iDay) % 7);
	return new DateTime(iYear, iDay > 31 ? 4 : 3, iDay > 31 ? iDay - 31 : iDay);
}

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Rocko Bonaparte posted:

And then if you're trying to calculate Easter before the Council of Nicaea, then the best of luck to you.

Clearly that's Undefined Behavior and makes your Easter program invalid :)

LP0 ON FIRE
Jan 25, 2006

beep boop
For a couple of years I've been working on a game, and the biggest nightmare I'm going through now is recoding it so it can be more readable when I add more characters and enemies, which allows me to make no features and have it run virtually the same. It's wasted about a month when I should have just thought this through and did it right the first time. I'm also realizing just now the redundant enemies and single characters should come from the same super class, because their behaviors can be the same. (A character you can talk to can switch modes and become an enemy that you can fight, and an item can behave like an enemy.)

I read through this thread that brought up a good point of not making everything as perfect as it could possibly be in a program, because you'll end up working on it forever. After I'm done with this update, I'm certain this time I won't have to do much more with how the engine works.

It's hard to wait for the benefits, but I'm certain it will be worth it.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Yeah that's the one thing you can't learn except by doing. You have to make some really awkward code at first and only then will you realize how and why object reuse, inheritance, & composition are great ideas. At some point you'll have enough "tools" sitting in your spine that you'll start to see the similarities between different problems and how they can be solved using those tools. But I haven't met anyone who really got it without writing some really awful horrors first, including myself.

Zamujasa
Oct 27, 2010



Bread Liar

LP0 ON FIRE posted:

It's wasted about a month when I should have just thought this through and did it right the first time.

You're improving and realizing how past you from n months ago was an awful programmer. Welcome to the club. As you improve, everything before looks like a horror. :cheeky:

Eleeleth
Jun 21, 2009

Damn, that is one suave eel.

Zamujasa posted:

You're improving and realizing how past you from n months ago was an awful programmer. Welcome to the club. As you improve, everything before looks like a horror. :cheeky:

I constantly run into situations where I've looked at code I had wrote earlier that day and winced.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Back around 1999 ish I started a website originally for putting up Aphex Twin lyrics, and later for general IDM lyrics. I still have the code around, and it is hilariously bad. The first couple of versions actually took down the server a couple of times cause they spammed the apache logs with so many perl errors that the hard drive would fill up in less than a week (and the traffic was seriously very very low).

This is how it looked in 2001: http://web.archive.org/web/20011204041630/http://idmlyrics.vectorx.org/

In the first couple of versions, it was like, all HTML output was through print statements, GET params being used as file paths, etc, etc. Loops were retarded:

Perl code:
    if ($lyricsdata[$i] eq "lyrics={")
    {
      until ($lyricsdata[$i] eq "}")
      {
        $i++;
        $lyrics .= "\n\t\t\t\t\t$lyricsdata[$i]<br>" unless ($lyricsdata[$i] eq "}");
      }
    }

Bobbin Threadbear
May 6, 2007

LP0 ON FIRE posted:

It's wasted about a month when I should have just thought this through and did it right the first time.
If you had done this, and had no previous experience creating games/engines, "doing it right the first time" would probably mean you now have an engine thats super useless.

Bobbin Threadbear fucked around with this message at 00:47 on Feb 16, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
http://scientificninja.com/blog/write-games-not-engines

Opinion Haver
Apr 9, 2007

Carthag posted:

Back around 1999 ish I started a website originally for putting up Aphex Twin lyrics, and later for general IDM lyrics. I still have the code around, and it is hilariously bad. The first couple of versions actually took down the server a couple of times cause they spammed the apache logs with so many perl errors that the hard drive would fill up in less than a week (and the traffic was seriously very very low).

This is how it looked in 2001: http://web.archive.org/web/20011204041630/http://idmlyrics.vectorx.org/

In the first couple of versions, it was like, all HTML output was through print statements, GET params being used as file paths, etc, etc. Loops were retarded:

Perl code:
    if ($lyricsdata[$i] eq "lyrics={")
    {
      until ($lyricsdata[$i] eq "}")
      {
        $i++;
        $lyrics .= "\n\t\t\t\t\t$lyricsdata[$i]<br>" unless ($lyricsdata[$i] eq "}");
      }
    }

Hey, writing a webpage in the year 190 is seriosuly impressive.

e: "whores of MS"

Strong Sauce
Jul 2, 2003

You know I am not really your father.





LP0 ON FIRE posted:

For a couple of years I've been working on a game, and the biggest nightmare I'm going through now is recoding it so it can be more readable when I add more characters and enemies, which allows me to make no features and have it run virtually the same. It's wasted about a month when I should have just thought this through and did it right the first time. I'm also realizing just now the redundant enemies and single characters should come from the same super class, because their behaviors can be the same. (A character you can talk to can switch modes and become an enemy that you can fight, and an item can behave like an enemy.)

I read through this thread that brought up a good point of not making everything as perfect as it could possibly be in a program, because you'll end up working on it forever. After I'm done with this update, I'm certain this time I won't have to do much more with how the engine works.

It's hard to wait for the benefits, but I'm certain it will be worth it.

Technical debt is okay. You just got to remember that you'll have to repay it.

Zhentar
Sep 28, 2003

Brilliant Master Genius

LP0 ON FIRE posted:

I should have just thought this through and did it right the first time.

You're not doing it right this time, either. In my experience, you aren't really getting close until the third or fourth time around.

tef
May 30, 2004

-> some l-system crap ->

Strong Sauce posted:

Technical debt is okay. You just got to remember that you'll have to repay it.

For learning to code, you don't always have to repay it, you can just write something new instead.

For commercial code, you can just move jobs :v:

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Zhentar posted:

You're not doing it right this time, either. In my experience, you aren't really getting close until the third or fourth time around.

Yeah, you've got to remember that the knowledge you have now is not the knowledge you had then. Odds are, even if you really put effort into more planning up front, you still would've had plenty of blind spots you didn't even know existed. Better to get the runs on the board and understand you may have to rework stuff later on once you understand the problem better, than to spend ages in planning hell for diminishing returns.

Innocent Bystander
May 8, 2007
Born in the LOLbarn.

Maluco Marinero posted:

Yeah, you've got to remember that the knowledge you have now is not the knowledge you had then. Odds are, even if you really put effort into more planning up front, you still would've had plenty of blind spots you didn't even know existed. Better to get the runs on the board and understand you may have to rework stuff later on once you understand the problem better, than to spend ages in planning hell for diminishing returns.

So when do you plan? Not trying to stir up poo poo, just curious.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Innocent Bystander posted:

So when do you plan? Not trying to stir up poo poo, just curious.

It's a cycle. The point of an agile cycle is that you're constantly moving through a Plan - Do - Review process, to keep it simple.

You plan with the knowledge you have available, and then get to work. At the end of your iteration / sprint, whatever you want to call it, you're reviewing how your plan matched up with how things actually went, and that effects how you plan the next iteration.

The important thing is that you learn the knowledge you need to plan accurately in the Do and Review process, not in the planning process. You don't actually KNOW that this architecture, or this toolkit works in this situation until you actually try to do it and review the pros and cons you directly experience.

How you plan to gain that knowledge is up to you, but you need to DO something to get it, whether it's prototyping, running tests, whatever.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Innocent Bystander posted:

So when do you plan? Not trying to stir up poo poo, just curious.
When there are multiple people involved. That's about it, in my experience.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



yaoi prophet posted:

Hey, writing a webpage in the year 190 is seriosuly impressive.

e: "whores of MS"

ya the year 190 was p chill

Zombywuf
Mar 29, 2008

Plorkyeran posted:

When there are multiple people involved. That's about it, in my experience.

Yeah, planning on your own never works well. Planning should be an argument.

pigdog
Apr 23, 2004

by Smythe

Innocent Bystander posted:

So when do you plan? Not trying to stir up poo poo, just curious.

You can't really plan how something must work technically and how much time do you need for all that, but you can and should plan what do you need to accomplish (and how, exactly, in a clear line of thought is that going to result in $$$), and how the application should behave to match these guals. You've got to have a clear vision of how your work is even going to be useful and successful in the first place, otherwise everything else is a wasted effort.

Then, given a clear attempt to specify exactly how should the application work and look like, before committing too much into building the thing. If you're building a website, then it's much easier and cheaper to draw a lot of mockups and pictures of all the flows on pieces of paper, rather than 6 months into coding have the customer decide she doesn't like any of it. Planning "why" and "what" is useful, planning "how" and "when" far less so.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

Innocent Bystander posted:

So when do you plan? Not trying to stir up poo poo, just curious.

A couple times a day. Your understanding of the problem improves, requirements change, plans get outdated.

Scaevolus
Apr 16, 2007

DSLs are awesome!

C++ code:
/* LinkInsertAfter: Insert a link after a given link.
*/

InternalFunction( LinkInsertAfter, Void, JPC, Return, ( CPLink cplinkGiven,
  CPLink cplinkInsert ) )
{
  /* Check for null pointers.
  */

  NullCheck( cplinkInsert, "LinkInsertAfter [insert]" );
  NullCheck( cplinkGiven, "LinkInsertAfter [given]" );


  /* Check to make sure the link to be inserted is not in another chain.
  */

  #ifdef INTEGRITY_CHECKING
  {
    if( Arrow( cplinkInsert, Link, plinkNext ) || Arrow( cplinkInsert, Link,
      plinkPrev ) )
    {
      ErrorStart( 1 );
      ErrorPrintf( "Attempt to insert link that is part of another" );
      ErrorNewline( 1 );
      ErrorPrintf( "chain in LinkInsertAfter." );
      ErrorExit();

      Return
    }
  }
  #endif


  /* Check to make sure the given link IS a part of a chain.
  */

  #ifdef INTEGRITY_CHECKING
  {
    if( !Arrow( cplinkGiven, Link, plinkNext ) )
    {
      ErrorStart( 1 );
      ErrorPrintf( "Attempt to insert link after a link that is not" );
      ErrorNewline( 1 );
      ErrorPrintf( "a part of a chain in LinkInsertAfter." );
      ErrorExit();

      Return
    }
  }
  #endif


  /* Update the next link's prev-link pointer.
  */

  Arrow( Arrow( cplinkGiven, Link, plinkNext ), Link, plinkPrev ) =
    cplinkInsert;


  /* Create the prev- and next-link values for the inserted link.
  */

  Arrow( cplinkInsert, Link, plinkPrev ) = cplinkGiven;
  Arrow( cplinkInsert, Link, plinkNext ) = Arrow( cplinkGiven, Link,
    plinkNext );


  /* Update the given link's next-link pointer. NOTE: Cannot do this before
  ** the previous step.
  */

  Arrow( cplinkGiven, Link, plinkNext ) = cplinkInsert;
}
EndFunction
C++ code:

  #define Arrow( po, type, member ) \
    ( JPCDeref( po, type, True ).member )

  #define JPCDeref( po, type, arrow ) \
      ( *(type pTr) MemAllocCheckPointer( (PObject) (po), sizeof( type ), \
        acFnName, #po, arrow ) )

/* Typedefs. Use #define to appease a bug in Unix cc.
*/

#define Void void
#define Object Void
#define SByte signed char
#define Byte unsigned char
#define Char char
#define Short short
#define Int int
#define Sign Int
#define Long long
...
#define Internal static
#define External extern
#define Permanent static
(OO in C...)

Scaevolus fucked around with this message at 06:59 on Feb 17, 2013

Pilsner
Nov 23, 2002

I'm not one of those that laugh at memes all day, but we have an interface that describes whether an object can have documents attached to it. The interface is called IHasDocuments. I can has documentz?

Carthag posted:

Yeah that's the one thing you can't learn except by doing. You have to make some really awkward code at first and only then will you realize how and why object reuse, inheritance, & composition are great ideas. At some point you'll have enough "tools" sitting in your spine that you'll start to see the similarities between different problems and how they can be solved using those tools. But I haven't met anyone who really got it without writing some really awful horrors first, including myself.

Zamujasa posted:

You're improving and realizing how past you from n months ago was an awful programmer. Welcome to the club. As you improve, everything before looks like a horror. :cheeky:
I don't think it's that we were necessarily bad devs n months ago, it's just that requirements change and you have to code for what you know right now. No one will ever, even with 50 years of experience, write the right code the first time. All code goes through a cycle where it's due for an overhaul sooner or later, the more you work on it. You can't do a complete rewrite every time you need to introduce a little new feature, and after 10 of these it probably stinks.

Wasse
Jan 16, 2010

Aleksei Vasiliev posted:

Wikipedia helpfully explains how to calculate the date of Easter Sunday in MS Excel using what appears to be the most convoluted method possible:

=DATE(A1,INT((MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30)+MOD((32+(2*MOD(INT(A1/100),4))+(2*INT(MOD(A1,100)/4))-(MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30))-(MOD(MOD(A1,100),4))),7)-(7*INT(((MOD(+A1,19))+(11*MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30))+(22*MOD((32+(2*MOD(INT(A1/100),4))+(2*INT(MOD(A1,100)/4))-(MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30))-(MOD(MOD(A1,100),4))),7)))/451))+114)/31),MOD((MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30)+MOD((32+(2*MOD(INT(A1/100),4))+(2*INT(MOD(A1,100)/4))-(MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30))-(MOD(MOD(A1,100),4))),7)-(7*INT(((MOD(+A1,19))+(11*MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30))+(22*MOD((32+(2*MOD(INT(A1/100),4))+(2*INT(MOD(A1,100)/4))-(MOD((19*(MOD(+A1,19))+(INT(A1/100))-(INT(INT(A1/100)/4))-(INT((INT(A1/100)-(INT((INT(A1/100)+8)/25))+1)/3))+15),30))-(MOD(MOD(A1,100),4))),7)))/451))+114),31)+1)

It also provides this method:
=ROUND(DATE(A1,4,1)/7+MOD(19*MOD(A1,19)-7,30)*14%,0)*7-6
I wonder which one I should use

Just to be fully baller you need to use the first one.

I pity the person who figured that out, though.

Tei
Feb 19, 2011

Pilsner posted:

I don't think it's that we were necessarily bad devs n months ago, it's just that requirements change and you have to code for what you know right now. No one will ever, even with 50 years of experience, write the right code the first time. All code goes through a cycle where it's due for an overhaul sooner or later, the more you work on it. You can't do a complete rewrite every time you need to introduce a little new feature, and after 10 of these it probably stinks.

If you have never feel the "I was drunk when I wrote this?", you have not programed enough, or long enough.

Its not that old code is bad, is that take the wrong route in maintanibility, scalability or any other -ity or -ism.
You know what route to go now precisely because you have already explored the dead ends.

Tei fucked around with this message at 15:29 on Feb 20, 2013

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
Got lazy and used google to do some arithmetic on addresses from a FRAM dump, using this query:

quote:

(0x1e20 - 17e0) in decimal




:doh:



At least I found my fuckup before I started digging through the code that generated the dump to determine why the "wrong" amount of data was written.

Clavius
Oct 21, 2007

Howdy!
On a temp contract with a company right now doing some pretty cool work. Finished it up early and they asked me to spend a week just tweaking their online shop built in netsuite to make it more brand consistent and seo friendly or whatever. So okay, never used netsuite, how bad can it be?



:stare: It's like house of leaves in here, the deeper you dig the more the tables expand into more tables, I haven't seen anything close to this bad in ten years of development, even by ten years ago standards. It's fascinating.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
I like that the order of attributes on tags is completely random. Gotta stay away from consistency.

Clavius
Oct 21, 2007

Howdy!
code:
<CENTER><FONT class=Apple-style-span size=2><BR></FONT></CENTER>
lol

..btt
Mar 26, 2008

I like how you complain about a 10-year-old style of html while using a 12 year old OS and listening to 20 year old music :v:

Seriously though, I find tables can often be useful for non-tabular layout, especially if you have to support stupid old browsers like IE6 without introducing some serious div-soup. I wouldn't say it's that big a horror for auto-generated html. Kinda odd using the font tag with a css class though...

vvv: You can use the ugly Windows 95 corporate grey taskbar in Windows 7? I had no idea. I guess some people really loving hate change.

..btt fucked around with this message at 10:18 on Feb 21, 2013

Pilsner
Nov 23, 2002

..btt posted:

using a 12 year old OS
He looks like an intelligent person who uses the classic style taskbar in Windows 7. :colbert:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Clavius posted:

On a temp contract with a company right now doing some pretty cool work. Finished it up early and they asked me to spend a week just tweaking their online shop built in netsuite to make it more brand consistent and seo friendly or whatever. So okay, never used netsuite, how bad can it be?



:stare: It's like house of leaves in here, the deeper you dig the more the tables expand into more tables, I haven't seen anything close to this bad in ten years of development, even by ten years ago standards. It's fascinating.

That looks a bit like the code I maintained a couple of years ago. Every value was rendered as a table. So a status indicator that was a just a green box with the text OK inside it was actually <table><tbody><tr><td style="background:green">OK</td></tr></tbody></table>, or something similar.

edit: Oh hey, I thought I might have posted about this before:

Wheany posted:



What is "Slot1"?

You might think that it's just the first cell of a 3x8 table.

No, it is in fact the only cell of a 1x1 table that is inside a 1x2 table, that is inside a 3x2 table.

The three cells under Slot1 are in a 1x3 table. The text in some, but not all, cells is in a div just for kicks.

And every table contains a shitload of inline styles. Like '<td class="fart_butt" style="font-size:8pt; border-bottom:0">'

Wheany fucked around with this message at 10:35 on Feb 21, 2013

Goat Bastard
Oct 20, 2004

Pilsner posted:

He looks like an intelligent person who uses the classic style taskbar in Windows 7. :colbert:

gotta make my 3 year old operating system look like a 17 year old operating system

God of Mischief
Oct 22, 2010

Clavius posted:

On a temp contract with a company right now doing some pretty cool work. Finished it up early and they asked me to spend a week just tweaking their online shop built in netsuite to make it more brand consistent and seo friendly or whatever. So okay, never used netsuite, how bad can it be?



:stare: It's like house of leaves in here, the deeper you dig the more the tables expand into more tables, I haven't seen anything close to this bad in ten years of development, even by ten years ago standards. It's fascinating.

I think I am most fond of the fact that the tr is actually styled using display: table-row.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Pilsner posted:

He looks like an intelligent person who uses the classic style taskbar in Windows 7. :colbert:

Looks like the Windows XP icon on the start button to me. The Vista and Windows 7 icons have the icon lighter in the center, while XP has the faux flag 3D shading.

That Turkey Story
Mar 30, 2003

Suspicious Dish posted:

Looks like the Windows XP icon on the start button to me. The Vista and Windows 7 icons have the icon lighter in the center, while XP has the faux flag 3D shading.

Yeah, man. Any true nerd knows this.

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal

Clavius posted:

On a temp contract with a company right now doing some pretty cool work. Finished it up early and they asked me to spend a week just tweaking their online shop built in netsuite to make it more brand consistent and seo friendly or whatever. So okay, never used netsuite, how bad can it be?



:stare: It's like house of leaves in here, the deeper you dig the more the tables expand into more tables, I haven't seen anything close to this bad in ten years of development, even by ten years ago standards. It's fascinating.

You need to look at that with the new 3d viewer thingy in firefox. A goddamn mountain of failure, jutting out of the page.

Adbot
ADBOT LOVES YOU

pigdog
Apr 23, 2004

by Smythe
Whoah that 3D thingy is pretty cool.

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