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

The Gripper posted:

For a commercial package, SweetScape 010 editor is hard to beat and particularly good for game data/save game things. Has a built-in c-like templating language that lets you define the format of your file and highlight/separate regions, structs and values.

Thanks for the reference. I was actually going to try to write a tool like that. Does it allow you to attach semantics against the structs? The thing that I was going to build would allow you to say "this field is the number of file_t records, and afterwards there are that many file_t records", and then say "this field is a uint32_t that's an absolute offset", "this field is a uint32_t that's a file length" and let me see the results against the actual data.

Adbot
ADBOT LOVES YOU

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?

AlsoD posted:

In general, this isn't possible (see the Halting Problem). Some languages can detect some kinds of infinite loops (GHC's <<loop>> for example).

edit: Agda can apparently do something like this, but then it's not Turing complete.

This is also the reason for the good old "AppName (Not Responding)" in the title bar in Windows, and similar behaviour in other operating systems. There is really no way to detect an infinite loop even when the code is running, so the best you can do is use a watchdog (effectively what Windows is doing in software) and take some action if the code fails to reset the watchdog trigger before the timeout.

In the case of Windows the action is to notify the user that "uh we might have a problem here" and give them the option to terminate the application. In embedded systems the watchdog is often a separate IC which will literally just reset the entire device if the timeout is reached as the situation is considered to be unrecoverable - this is what happens when your mobile phone spontaneously reboots.

The Gripper
Sep 14, 2004
i am winner

Suspicious Dish posted:

Thanks for the reference. I was actually going to try to write a tool like that. Does it allow you to attach semantics against the structs? The thing that I was going to build would allow you to say "this field is the number of file_t records, and afterwards there are that many file_t records", and then say "this field is a uint32_t that's an absolute offset", "this field is a uint32_t that's a file length" and let me see the results against the actual data.
The example BMP/ZIP/WAV templates show fairly concisely how things can be done. Say for a bitmap file you want to load the file and info headers up into their own structs, you'd define them as:
code:
typedef struct {   // bmfh
    CHAR    bfType[2];
    DWORD   bfSize;
    WORD    bfReserved1;
    WORD    bfReserved2;
    DWORD   bfOffBits;
} BITMAPFILEHEADER;

typedef struct {    // bmih
    DWORD   biSize;
    LONG    biWidth;
    LONG    biHeight;
    WORD    biPlanes;
    WORD    biBitCount;
    DWORD   biCompression;
    DWORD   biSizeImage;
    LONG    biXPelsPerMeter;
    LONG    biYPelsPerMeter;
    DWORD   biClrUsed;
    DWORD   biClrImportant;
} BITMAPINFOHEADER;
then, in the main code block where the work is done to populate the structures (based on the currently loaded file) you'd do:
code:
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
giving the result of:


Anything from those structs can then be used in any other logic, like determining if the loaded file is actually a bitmap:
code:
// Check for header
if( bmfh.bfType != "BM" )
{
    Warning( "File is not a bitmap. Template stopped." );
    return -1;
}
or in logic for building other structs:
code:
local int bytesPerLine = (int)Ceil( bmih.biWidth * bmih.biBitCount / 8.0 );
Also, structs don't need to be pre-defined, and can be built and populated in the main code block, using values from previously populated structs (headers, etc):
code:
// Calculate bytes per line and padding required
    local int bytesPerLine = (int)Ceil( bmih.biWidth * bmih.biBitCount / 8.0 );
    local int padding      = 4 - (bytesPerLine % 4);
    if( padding == 4 )
        padding = 0;

    // Define each line of the image
    struct BITMAPLINE {

        // Define color data
        if( bmih.biBitCount < 8 )
             UBYTE     imageData[ bytesPerLine ];
        else if( bmih.biBitCount == 8 )
             UBYTE     colorIndex[ bmih.biWidth ];
        else if( bmih.biBitCount == 24 )
             RGBTRIPLE colors[ bmih.biWidth ];
        else if( bmih.biBitCount == 32 )
             RGBQUAD   colors[ bmih.biWidth ];

        // Pad if necessary        
        if( padding != 0 )
             UBYTE padBytes[ padding ];

    } lines[ bmih.biHeight ] <optimize=true>;
Creating a new struct with the same variable name doesn't overwrite it, it extends it to an array and adds the new struct to it so the output would (for this example struct) be something like:


Theres a ton of example templates for popular formats here if you want to check them out and see if you can follow. All the code I've quoted above is from the BMPTemplate file.

edit; plus there are built-in functions like FSeek for working with absolute offsets rather than reading sequentially like the example above does.

The Gripper fucked around with this message at 11:31 on Feb 2, 2012

gonadic io
Feb 16, 2011

>>=

rolleyes posted:

There is really no way to detect an infinite loop even when the code is running


This bit isn't quite true - if something tries to evaluate exactly itself in GHC's runtime, the program terminates with a <<loop>> error. Of course, this is only one specific type of loop, but surely aborting due to stack/heap overflows are an indicator of non-terminating behaviour too?

rolleyes
Nov 16, 2006

Sometimes you have to roll the hard... two?

AlsoD posted:

This bit isn't quite true - if something tries to evaluate exactly itself in GHC's runtime, the program terminates with a <<loop>> error. Of course, this is only one specific type of loop, but surely aborting due to stack/heap overflows are an indicator of non-terminating behaviour too?

Well, stack or heap violations can be caused by a variety of things so it doesn't necessarily indicate an infinite loop, but yes runaway code in an unmanaged programming language could trigger that. Although by then there's no point 'detecting' the loop because (assuming a modern OS) the OS will already have stopped it as a memory violation.

Glans Dillzig
Nov 23, 2011

:justpost::justpost::justpost::justpost::justpost::justpost::justpost::justpost:

knickerbocker expert

Scaramouche posted:

If you have it Powershell could do it. There's a dedicated thread in this forum too.

Oh sorry, didn't see that the first time. I'll take this there then. Thanks!

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Regarding solving the halting problem, there are a few interesting things you might be able to based on the fact that physical computers are actually finite-state machines. Using a pumping-lemma style argument, you could say that a computer with three bits of memory that executes more than 8 instructions must be in an infinite loop because it's forced to revisit a previous state. With good pruning heuristics it might even be possible (but expensive!) to exhaustively prove things about programs running on something on the scale of a small microcontroller.

The important caveat to this approach is that it only holds up for closed systems. Fixed input (like running a compiler on a specific file) can be treated as an extension of the program, but once you connect the computer to sensors or other sources of non-determinism all bets are off.

Internet Janitor fucked around with this message at 15:13 on Feb 2, 2012

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Walter_Sobchak posted:

1) Is there a way to specify a file by the Date Modified column? I basically want to have a script that auto-deletes the oldest file in a certain folder when I run it.

You could also look at Belvedere by one of the contributors of Lifehacker. I haven't tried it but it does what you need. Also, try the Windows Software thread. This is probably a solved problem by some software out there.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Are there any websites that talk about writing video games for the old 80's and early 90's arcade machines? I realize most of the stuff has been long since thrown away or under NDA, but I love to read some write-ups on their tools chains and methods they used to get the art and code from whatever computers they used, to the arcade boards themselves.

gwar3k1
Jan 10, 2005

Someday soon
I'm reading through O'Reilly's Programming C# 3.0 which is a bit light on examples. I think I understand what I'm reading, but I'm having a hard time thinking of practical situations I can apply them to: I'm a dull gently caress and can't think of anything to program and its killing my comprehension of OOP.

I could do an address book, but what else would be good for reenforcing OOP concepts?
e: I'm also trying to avoid .Net and GUI stuff for now, just focusing on the C# language and base functionality.

gwar3k1 fucked around with this message at 21:41 on Feb 2, 2012

JawnV6
Jul 4, 2004

So hot ...

Bob Morales posted:

Are there any websites that talk about writing video games for the old 80's and early 90's arcade machines? I realize most of the stuff has been long since thrown away or under NDA, but I love to read some write-ups on their tools chains and methods they used to get the art and code from whatever computers they used, to the arcade boards themselves.

This isn't exactly what you're talking about, but I think you'd find it interesting.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

gwar3k1 posted:

I'm reading through O'Reilly's Programming C# 3.0 which is a bit light on examples. I think I understand what I'm reading, but I'm having a hard time thinking of practical situations I can apply them to: I'm a dull gently caress and can't think of anything to program and its killing my comprehension of OOP.

I could do an address book, but what else would be good for reenforcing OOP concepts?
e: I'm also trying to avoid .Net and GUI stuff for now, just focusing on the C# language and base functionality.

This is kind of the problem with being introduced to OOP; the concepts don't abstract very well because they're... already kind of abstract. When I was first introduced to it I already had been tainted by functional/procedural programming too, and the scale of projects I worked on always had these 'easy' non OOP solutions that probably weren't the best implementation, but I knew I could bang them out faster that way. In my opinion where OOP shines is large, multi-function projects which are kind of hard for hobbyist programmers teaching themselves to come up with and get to grips with.

My only suggestion is to come up with a project that requires the OOP style methodology and do it out. For me it was some crappy games; a crib game and a roguelike that never got off the ground, but by god those character and inventory objects were well-defined!

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

gwar3k1 posted:

I could do an address book, but what else would be good for reenforcing OOP concepts?

Well, let's say you have a pen and a pencil, both are writing utensils...

No, really, this is probably the best way:

Scaramouche posted:

My only suggestion is to come up with a project that requires the OOP style methodology and do it out. For me it was some crappy games; a crib game and a roguelike that never got off the ground, but by god those character and inventory objects were well-defined!
Especially since you can make your classes represent objects a lot less abstract (like a class for "sword" and "player" etc).

SydneyRoad
Mar 24, 2011
I'm interested in making a website that is similar to Fitocracy in that it's a social network that will log user's stats and then award them achievements. What type of coding would work best and how much would a website like this cost to program?

gwar3k1
Jan 10, 2005

Someday soon
Thanks both of you, its actually reassuring to hear that. I started to write down how Bejewelled works (or how I think it works) and think I could do something along those lines, then aim for something bigger again like you said.

The Born Approx.
Oct 30, 2011
Don't know where to post this because I don't come in here much, but does anyone have experience running code on Cray hardware? I have some research level code that I have been running successfully on several "standard" Linux clusters. Now I have access to a Cray machine as well and it's quite a different beast...

My big problem is that my code, as it is, relies on the OpenMPI libraries in order to run. Well, OpenMPI does not do well on the Cray machines. I installed it myself and got the code running, only to find out that mpirun on its own will not pass my job from the batch node to the compute nodes. Instead, I have to run something called "cluster compatibility mode" which is the Cray machine's attempt to emulate a standard Linux cluster as best it can. However, apparently when I do this, OpenMPI has to use TCP/IP to communicate between nodes, which is (I guess) fairly slow. So, I would like to figure out how to compile the code in a more native (to the Cray architecture) way.

My biggest hurdles are thus: the native MPI-2 implementation on the Cray machine is MPICH2. When I load this module, I do not have access to the mpi compiler wrappers such as mpicc and mpif90 which I use to compile my code. Also, my code has dependencies on libraries such as lib_mpif90.so (something like that, going from memory) and this library is not part of the MPICH2 installation on my Cray machine. It looks like it might provide some similar libraries, but I don't know what to do to make my code be happy with them. So for anyone who has faced a similar situation, how difficult are these problems to overcome?

Sorry for making such a long winded post; I realize this is an esoteric problem and I'm not sure who to ask about it. The guy who you'd consider the head developer of this code has never configured it to run on Cray hardware, and my sysadmin doesn't know anything about my code, since only a handful of people have ever used it. I am not a computer scientist or software developer, just an engineer trying to keep his head above water with all this crazy poo poo...

baquerd
Jul 2, 2007

by FactsAreUseless

SydneyRoad posted:

I'm interested in making a website that is similar to Fitocracy in that it's a social network that will log user's stats and then award them achievements. What type of coding would work best and how much would a website like this cost to program?

I read an article recently (linked from these forums?) that said the best language to use here is LISP so you might try that out.

In reality there are dozens of perfectly workable programming languages to write this from scratch, and nearly as many social networking projects you can re-purpose to your own ends. If you are paying someone else to do this and not doing it as a labor of love, it will cost tens of thousands of dollars at a bare minimum assuming you don't mind paying college students to do it.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

SydneyRoad posted:

I'm interested in making a website that is similar to Fitocracy in that it's a social network that will log user's stats and then award them achievements. What type of coding would work best and how much would a website like this cost to program?

Eh it depends on how pro you want to go. You could bang together >something< using OSS stuff like Wordpress/Joomla/Drupal/etc. and use free modules like calendars and so on. If this is just something you want to have around you could probably cut some corners and get it done on the cheap. If it's a new business venture and meant to generate revenue and has to look all pro you're probably looking at more like what baquerd said, though I think something more like $5,000 - $10,000 could do it if you don't care about using Indian rent-a-coders in php.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


Scaramouche posted:

I think something more like $5,000 - $10,000 could do it if you don't care about using Indian rent-a-coders in php.

You'll spend a lot less up front, but making changes and bug fixes will be very expensive.

Thermopyle
Jul 1, 2003

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

I've thought about this myself. Not a Fitocracy type of web app, but a web app of similar complexity.

I've got lots of ideas for revenue-generating web apps, but I lack the time and motivation to write them and learn every thing I'd need to know. I wonder how having someone like myself, who wouldn't just go to a rent-a-coder and say "write this for me", but would be involved in the process would change things.

Would the cost be less? Would the code end up more maintainable? Would the product be better?

SydneyRoad
Mar 24, 2011

baquerd posted:

I read an article recently (linked from these forums?) that said the best language to use here is LISP so you might try that out.

In reality there are dozens of perfectly workable programming languages to write this from scratch, and nearly as many social networking projects you can re-purpose to your own ends. If you are paying someone else to do this and not doing it as a labor of love, it will cost tens of thousands of dollars at a bare minimum assuming you don't mind paying college students to do it.

Thanks everyone. Yes, I am trying to go as pro as I can get. That's the ballpark I was figuring. With of course more costs after it is active. I was mostly wondering what language they coded Fitocracy with. If it can be achieved through any means then I am satisfied.

Munkeymon
Aug 14, 2003

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



Thermopyle posted:

I've thought about this myself. Not a Fitocracy type of web app, but a web app of similar complexity.

I've got lots of ideas for revenue-generating web apps, but I lack the time and motivation to write them and learn every thing I'd need to know. I wonder how having someone like myself, who wouldn't just go to a rent-a-coder and say "write this for me", but would be involved in the process would change things.

Would the cost be less? Would the code end up more maintainable? Would the product be better?

I just always end up wondering how long it would take for some bottom feeding shitbag to come along and sue me for infringing on his patent #38432958234982348 Using Images On A Mobile Computing System On A Friday In Autumn

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

SydneyRoad posted:

Thanks everyone. Yes, I am trying to go as pro as I can get. That's the ballpark I was figuring. With of course more costs after it is active. I was mostly wondering what language they coded Fitocracy with. If it can be achieved through any means then I am satisfied.

You can glean some of it from builtwith:
http://builtwith.com/fitocracy.com

Unfortunately they're running nginx which doesn't say if it's Windows or UNIX, but I'm pretty sure it's the latter since they're using mySQL/Python.
https://forums.aws.amazon.com/message.jspa?messageID=302728#302728

SydneyRoad
Mar 24, 2011

Scaramouche posted:

You can glean some of it from builtwith:
http://builtwith.com/fitocracy.com

Unfortunately they're running nginx which doesn't say if it's Windows or UNIX, but I'm pretty sure it's the latter since they're using mySQL/Python.
https://forums.aws.amazon.com/message.jspa?messageID=302728#302728

That's a useful tool. Thank you.

Dolemite
Jun 30, 2005

ultrafilter posted:

You'll spend a lot less up front, but making changes and bug fixes will be very expensive.

SydneyRoad - I know this has been beaten to death already, but I'm quoting ultrafilter because he's absolutely right.

I work part time for a development firm and we inherited a client's absolutely lovely, custom e-commerce site. The code is a god awful mess. As you go through the code, you can almost see the lovely Indian devs growing from pathetic coding babbys to, well, only kind of lovely. It would bring a smile to my face and a tear to my eye. If the code didn't make me want to drink myself to death.

The point of this ranting? The code is so bad, that finding the source of a bug can take several hours alone. This should not happen in sensibly written code. While I can knock out some bugfixes in 'only' 3-5 hours, it's not uncommon to take 10-15 hours to fix bugs or add new features.

When gathering at the bar and bitching about this with the other devs, I found out that they too can take as long to fix something in this poo poo code. So imagine paying the typical developer rate X 10 hours to do things as trivial as adding a feature to give you free shipping.

Don't be this client. Especially don't follow this client's example of rejecting our idea to rewrite the lovely software from scratch. Even after we explained how much money he's pissing away by continuing to have us patch his existing heap.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Unfortunately, when most developers say "I'll just rewrite this, and do it properly this time", they underestimate the required resources by a dozen orders of magnitude (and greatly oversell the benefits). In this context, paying ten times the cost to add a new feature to a working system sounds like a bargain, especially strung out over many months or years.

(Which isn't to say that a rewrite is the wrong idea in your case, it's just a general impression.)

oRenj9
Aug 3, 2004

Who loves oRenj soda?!?
College Slice

Dolemite posted:

Especially don't follow this client's example of rejecting our idea to rewrite the lovely software from scratch. Even after we explained how much money he's pissing away by continuing to have us patch his existing heap.

Developers should try to overcome this mentality. To your client, his software works (mostly) how s/he wants it to so it continues to be an asset to his business. While s/he is paying more for fixes and enhancements, it is likely that it is in the best interest of the business to continue to pay a known premium for fixes and enhancements because it frees up capital to be uses for growing other parts of the business.

It would be like telling him to sell his old but paid-off Camry and buy a new Prius because it would save him money on gas and repair bills6. While that is true, the fact is that $25,000 buys you a lot of gas and repairs.

coaxmetal
Oct 21, 2010

I flamed me own dad

pokeyman posted:

Unfortunately, when most developers say "I'll just rewrite this, and do it properly this time", they underestimate the required resources by a dozen orders of magnitude (and greatly oversell the benefits). In this context, paying ten times the cost to add a new feature to a working system sounds like a bargain, especially strung out over many months or years.

(Which isn't to say that a rewrite is the wrong idea in your case, it's just a general impression.)

or (i've done this) they start a rewrite, realize it's going to be way more work than they thought, and abandon it, having wasted time and resources attempting it.

The Gripper
Sep 14, 2004
i am winner

coaxmetal posted:

or (i've done this) they start a rewrite, realize it's going to be way more work than they thought, and abandon it, having wasted time and resources attempting it.
Or (as I experienced first-hand when a developer convinced us a rewrite was better) get a finished product done, deploy it and then realize that a few of the "awful, badly implemented" parts of the software were done that way intentionally to work around limitations and broken code in other systems.

There was a section that made multiple inefficient connections to another server when it should have been making only one, something like this:
code:
<snip>
x = ServerInterop("192.168.0.2")
y = ServerInterop("192.168.0.2")
z = ServerInterop("192.168.0.2")
x.connect()
...
<snip>
data = source.get()
x.send(data)
x.disconnect()
y.disconnect()
z.disconnect()
y.connect()
y.send(data)
y.disconnect()
z.disconnect()
z.connect()
z.disconnect()
It's obviously lovely code (re-written off the top of my head, there were other bits and pieces doing similarly weird things) and the developer decided that this was due to bad coding. In the rewrite he looked at the docs for the server and rewrote it as:
code:
x = ServerInterop("127.0.0.1")
x.send(source.get())
When he deployed the new system, nothing worked. Data locally would be missing fields, things being saved would be missing fields (or missing entirely), requests were slow.

Guess how long it took to determine that the original block of code was a fix for a long-running issue with ServerInterop, and to fix the new code? hint: it was longer than it would have taken to add the new feature we originally wanted to the old code.

I think the moral of the story is that rewriting things is probably fine as long as the developers don't make assumptions about anything.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I know people are calling out against "the Indian developers" - on one hand, they produce crap code. On the other hand, they're usually restricted beyond all belief.

Backstory and context for when I built something from Verizon, before we get to the Indian developers part: Verizon's networks are all a mess of random mergings, so there's lots of special hardware and strange bugs. (This is Verizon Telecom and Verizon Business, not Verizon Wireless, which is a separate network that has separate origins). One of the things the networking engineers and support guys have are a bunch of tools that check the statuses of networks and such. Verizon underwent a project called "Delphi" a few years ago to merge all their existing tools (ITS, NXTT, DTI-Web, DTI-Desktop, etc.) into one new tool called "DTI-X".

(DTI-X as a rewrite was full of terrible things - they hand-rolled their own JavaScript instead of using something like GWT or jQuery - reasoning being "what if jQuery/Google went out of business? Then we're stuck". They built this instead, but this was a WTF of the American developers. I guess I'll post this in the Coding Horrors thread.)

Anyway, the Indian arm of the Verizon engineering team, "VDSI", was assigned various tasks in DTI-X, such as testing. Unfortunately, they were completely unable to do anything of the sort, as the workstations could not access real customer databases (they were told to fabricate their own data, and communication problems meant that there were several failures when we had invalid input in our databases). Additionally, if they wanted to access an internet resource at all, they had to check out from their workstation, bring themselves over to the "internet room" where they were checked by a guard to make sure that they were not hiding any USB keys, and the only thing they could do is print resources from the "internet room" and bring it back to their machine. Since the process took more than five minutes, they were reluctant to access API documentation and often bugged the American employees for help.

Talking to the Indian developers at VDSI, they said that this natural distrust towards the engineers was common at about all contracting firms, and VDSI were among the ones that treated their employees the best. So I have a bit of sympathy towards the "Indian developer".

gwar3k1
Jan 10, 2005

Someday soon
In C# I have a class EventTile inheriting from MapTile. Map has x and y coordinates for a draw routine.

If I use the following code, I don't need to use x and y in EventTile do I? They will be passed to base (MapTile) without intervention, right?

code:
public EventTile(int x, int y, rarity r) : base(x, y, true)

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

gwar3k1 posted:

In C# I have a class EventTile inheriting from MapTile. Map has x and y coordinates for a draw routine.

If I use the following code, I don't need to use x and y in EventTile do I? They will be passed to base (MapTile) without intervention, right?

code:
public EventTile(int x, int y, rarity r) : base(x, y, true)

Right, that's like declaring a MapTile object using whatever you're passing in for your x and y for it, but with the extra stuff provided by EventTile on top.

how!!
Nov 19, 2011

by angerbot
I'm doing a presentation at a local python meetup group on MVC. Can someone look over my slides and tell me if I'm on the right track? A lot of the stuff I wrote is based on my experience (instead of stuff I've read in fancy computer science papers), so I could be way off on some things: https://docs.google.com/present/edit?id=0AbTEcUIK5FrQZDg3NmNoYl8zMmhrcG01Z2Nm&hl=en_US

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
From my skimming, you're not way off on anything. It might be worth pointing out that there are various interpretations of what MVC means, so disagreement isn't necessarily bad.

Also you could spend more time hammering home how incredibly painful it is updating a site built the way you show on your "without MVC" slide.

gangnam reference
Dec 26, 2010

shut up idiot shut up idiot shut up idiot shut up idiot
Not really a programming question, but does anyone have a link to a guy's rant about car/animal analogies being used for Object-Oriented Programming? Class I'm taking is doing that right now and it was just so relevant that I really want to read it again.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Goodbye, lovely Car extends Vehicle object-orientation tutorial

Jewel
May 2, 2009


You can’t add code to ducks.

You can’t refactor ducks.

Ducks don’t implement protocols.

Suspicious Dish
Sep 24, 2011

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

Jewel posted:

You can’t add code to ducks.

You can’t refactor ducks.

Ducks don’t implement protocols.

My favorite duck-related quote is from Evolutionary Programming and Gradual Typing in ECMAScript 4 (which is an excellent paper on a neat novel type system. RIP ES4):

Lars T Hansen posted:

This kind of type discipline is often known as “duck typing”, on the principle that if something walks like a duck and talks like a duck, it is a duck. (This should not be confused with an older and now discredited type discipline, which says that if a woman floats like a duck then she’s a witch. ES4 has no objects that float like ducks, but it does have floats that bewitch – decimals.) The performance of duck typing is discussed later, but suffice it to say that the phrase that applies if you’re not a little careful is not "getting all your ducks in a row", but "sitting duck". (Author ducks.)

Sab669
Sep 24, 2009

In my algorithms class we're going over recursion. I understand the concept, but the specific example we did I'm having a tough time reading.

code:
	public static void main(String[] args)
	{
		double y = power(5.6,2);
		System.out.println(y);
		
	}

	private static double power(double d, int i) {
		if(i == 0)
			return 1.0;
		
		return d*power(d, i-1);
	}
That's what he showed us, and it really confuses me. Why isn't y 1.0 when we print it? Because of the if statement, I feel like it should be. I also don't understand how d is ever even being incremented. I guess simply just having a recursive method call in the return statement is what's really killing me.

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

Sab669 posted:

That's what he showed us, and it really confuses me. Why isn't y 1.0 when we print it? Because of the if statement, I feel like it should be. I also don't understand how d is ever even being incremented. I guess simply just having a recursive method call in the return statement is what's really killing me.

You're going to be calling the power() function multiple times. It seems like you're only focusing on the final instance it's called. You should write out explicitly what the code does, starting from the function call power(5.6,2).

That will return d * power(d, i-1) = 5.6 * power(5.6,2-1) = 5.6 * power(5.6,1)

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