Jump to content

sharpnyourteeth

Active Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by sharpnyourteeth

  1. I do not believe you are a professional developer, or that you have a ton experience (feel free to correct me if I'm wrong) to back up a statement like that (not that I do, either). You may believe that is so, as well as many other people, but I don't think it is fair to call it "bad programming". There are also many poeple who would disagree with you.(I mentioned this guy in my previous post, he does not think it is "bad programming". ). This is another opinion. You may think it looks nice by having all the variables up there, but someone else may think it's just clutter. Since the functions are small, will you really have a hard time remeber what a variable was you declared 5 lines ago? Or is it all that hard to take 5 seconds to scan through the previous 15 lines compared to 2 seconds to go straight to the top of the funciton? If I'm using a variable once inside of some nested loops or if statements, why should I delcare it at the top of the function? This is just needlessly extending it's scope. Or if I need a temporary variable at the end of the function why declare it way at the top when I'm only using it 2 statements before I return? I agree that if you're developing software with a group of people it's obviously a bad idea to use a different coding style than the rest of them. But I don't agree that it is "bad programming" and should not be used. I think this topic is more of an opinion than some sort of coding rule.
  2. This isn't C! Quote from Effective Java: "If a variable is declared before it is used, it is just clutter - one more thing to distract the reader who is trying to figure out what the program does. By the time the variable is used, the reader might not remember the variable's type or initial value. If the program evolves and the variable is no longer used, it is easy to forget to remove the declaration if it's far removed from the point of first use." It is definitely annoying while reading someone elses code to be at the bottom of a method, see a variable you don't remember, then have to jump back up to the top to see what it is. It's also annoying when writingn code, if you decide you need a new variable near the end of the method, why go back up to the top to declare it then go back down to use it? I guess that's just my opinion though.
  3. Learning some Unix programming and writing a basic unix shell
  4. I think it's better the other way around. Thats what I did anyway. Sure if you can jump right into C and have no problems then everything will indeed be easier down the road, but I think it's better to start with something easy, where it is easy to get results. (python, java, php i think all qualify). This will keep the person interested. If someone jumps right into C, it can get intimidating and the best a beginner can do is output to the console, which isn't very interesting. It is very easy to wrtie a simple GUI in java or python, or some cool scripts in PHP. Learning is much more fun and rewarding if you can produce results (like simple apps with GUI or apps you can use) right away. Once they are able to program with the layer of abstraction those languages offer, and are familiar with programming concepts, it will be easier to go down to C, then ASM. As they move down they will better understand how everything works and how much they've been taking for granted using those other languages hehe. Thats my opinion anyway, everyone learns differently. I started with Java and PHP, then C++/C then ASM (well, MIPS assembly).
  5. http://docs.python.org/lib/string-methods.html take a look at the documentation for replace. it takes two parameters anda third optional parameter. The first parameter is the string you want replaced. the second is the string to replace it with, and the optional is the number of times to do it so say you want to replace e with 3. you would do name = ent.get() name = name.replace("e", "3") that will replace all occurences of "e" in name with "3"
  6. i think a better description of what you're trying to do is needed. the source code would also help quite a bit.
  7. use the ereg_replace function. here's an example: <?php $money = "$3,301.98"; $formatted = ereg_replace('$|,', "", $money); echo $formatted; //prints out: 3301.98 ?> ereg_replace replaces the regex (first parameter) with the second paramter from the string in the third parameter. so this is saying replace any $'s or commas with nothing. Make sure you escape the $.
  8. Like Dr Zaius said, there is no way to redirect a certain IP with .htaccess, but what he suggested would work. And heres a solution in PHP to send certain IP addresses to a page. You can put this at the very top of any of your pages, say your index.php (if your host supports php of course) and if someone has the IP you specified they'll be redirected to the other page, but everyone else will see the normal page. <?php $address = $HTTP_SERVER_VARS["REMOTE_ADDR"]; if ($address == "xxx.xxx.xxx.xxx") { header("Location: goatse.html"); } ?>
×
×
  • Create New...