Messages - rkarman [ switch to compact view ]

Pages: prev1 2 [3] 4 5 6next
11
General Software Discussion / Re: Data recovery software suggestions?
« on: September 15, 2006, 03:25 PM »
RECOVER MY FILESSSSSSSSS


it saved me just 2 weeks ago when Norton messed up my partition tables and i had to make new partitions on my disk, format and reinstall windows. this program actually got 95% of all my stuff back after all that!!!


so i say: recover my files +10 (or was i only allowed to do a +1?)

12
yeah, i meant a compiler like Joel Spolsky wrote is not a big deal at all. like compiling some language to another (non machine) language.

i guess writing a genuine compiler could be done in a few months too. but you have to have a lot more knowhow to pull that off. if you have to first go figure out the PE format or the machine operations of the target platform then you are more looking toward a small year worth of work, lol.

13
Writing a compiler is not such a big deal, especially if you get back that you only have to maintain 1 codebase instead of 2 or more.

Then i have to agree that typeless/dynamic typed languages (like ruby) are really bad news for professional enterprise systems (not looking at speed at all here) but dynamically typed languages delay the moment you find bugs, and this delay can be deadly in enterprise software. i have to admit i frowned when i read he was actually saying PHP was a good choice.... or did they strong type it by now?

To me all this guy says makes perfect sense and i suspect everyone going nuts at him are all hobby programmers. which hobby programmer cares if their code fails (on some type error) after if has been tested and is running for a month? not many i guess. personally i always try to proof my code is correct instead of proofing that my code is not correct (that last one is called debugging) and dynamic typing can only proof your code is not correct in some obscure situation when it happens!

14
i'm sure many of you think this is an obvious story, but i'm going to tell it anyway for all who didn't know yet :-p


there are 2 types of variables in programming, one is called a value type the other is called a reference type. very nice that you have them both, but what does it actually mean? well, a value tpye variable is actually quite easy to explain, it's just a variable that can hold a value. then the question comes, what is a reference type variable then? well a reference type variable is a variable that has a value (of course) and also a reference to itself.

now the reason why we need 2 types of variables becomes clearer when you understand what happend when a variable is passed to a method or function.

lets look at the normal situation first:
when you pass a value type variable to a method, the actual value of the variable is copied into the function. so the function gets a new copy of the value to work with. this means that if you change the value of the variable inside your method, the origional value of the variable outside your method is not changed at all.
when you pass a reference type variabel to a method, the reference to the variable is copied into the function. so the function gets a new copy of the reference, but not of the value. this means that if you change the value of the variable inside your method, the origional value of the variable outside your method is changed.

now you can also pass variables "by value" or "by reference" in some languages. usualy this mean that reference type variables are always passed by reference, even if you declare the method to pass "by value".
for a value types it means that a reference can be created on the fly when you pass the variable "by reference"

now there is one more tricky thing about all this reference and value business, if you want to know if changing your variable inside a method will change it outside the method too then you need to know about something we call "immutable variables" too (yes i swear we are done after this one). basically when a variable is immutable it means that it can not change. of course it's not the same as a constant though, because you can make a new copy of this type of variable and change the reference to point to this new copy. this way it looks like your variable changed, and it also looks like other references (that did not get updated) still have the old variable value (in fact they have the complete old unchanged variable).

phewww, i bet some of you need to read that 2 times :-P


so now some ways these are all used
value type: usually has small data (like numbers) and can not be NULL, stucts/stuctures
reference type: usually has lots of data (like strings), classes
immutable: usually normal reference type variables

not in all languages this is the same though, just in most. C for instance has the char type which is basically a string like type, it is not immutable however (this is one of the reasons why C is called a low level language by some)

15
i just realize i should give an example of why it is bad

consider the following code (in c#):

string getnode(string xpath)
{
        try
        {
                return myconfigfile.SelectSingleNode(xpath).Value.ToString();
        }
        catch
        {
                return "";
        }
}


at first it looks like this is a good routine (a lil lazy written maybe) because whatever happens you always get an empty string instead of an null pointer exception. even if the node did not exist.

but what happens if you feed an invalid xpath string? the routine also returns an empty string! this can cause a lot of things to go wrong in your code, but not at the point where it fails, but later on where the results are used of your code that failed. debugging those errors is a crime.

now look at this code:

string getnode(string xpath)
{
        Node mynode = myconfigfile.SelectSingleNode(xpath);
        if (mynode == null)
                return "";
        else
                return mynode.Value.ToString();
}

this also returns an empty string if the node doesn't exist, but if you feed it a wrong xpath string this code will crash. so the first time a developer runs his code that calls this function, he will get an warning about invalid xpath syntax.

the try catch unnecesarrily catches all or a subset of errors. by instead checking for the speciffic anticipated situation we were not caught off guard when writing some flawed xpath string.

of course there are situations where this example would not apply at all, but i think it is a good thing to not to write code this way by default


hope this clarifies my view a lil more

Pages: prev1 2 [3] 4 5 6next
Go to full version