|
Unless the requirements of your problem explicitly state several conditions on which different things occur, there's almost always a more elegant way than using big if else trees or big switch statements.
|
# ? May 29, 2008 15:52 |
|
|
# ? May 15, 2024 03:48 |
|
Aren't case statements faster than long else-if chains?
|
# ? May 29, 2008 16:01 |
|
I doubt you'd find any noticeable performance difference either way.
|
# ? May 29, 2008 16:22 |
|
chocojosh posted:1) The standard of using only up to 80 columns seems to be quite outdated. I had a prof who actually took off marks for this. My monitor supports up to 140 columns (visual studio 2003) at the default font and 1280*1024 resolution. Now, I know different people use different text editors, different font sizes, and so on, but could we please update the standard to 120/130? And then actually ENFORCE it so that I don't have to read stored procedures with lines of 200+ characters. No, mail software still breaks at ~80 characters and terminals and consoles and whatever are still 80 characters in width.
|
# ? May 29, 2008 17:17 |
|
chocojosh posted:Josh's random thoughts of the days while working on "Yet another boring web page in this enterprise application". No, absolutely not. If the file took the entire width of the screen you couldn't put two files side-by-side for comparison. quote:2) Is it normal that I don't use switch statements? I just find if/else if/else if/else much easier to read and less verbose than a switch statement. The only time I have used a switch statement is for a WinMain loop.. and that's because it's the convention I see everywhere. As long as you're not repeating an expression in every test, that's fine. HB posted:Aren't case statements faster than long else-if chains? No, because the compiler's perfectly capable of optimizing. JoeNotCharles fucked around with this message at 17:26 on May 29, 2008 |
# ? May 29, 2008 17:24 |
|
6174 posted:There is probably a better way to do it, but you could do something like That checks the actual time the file was written, though - I think he wanted to sort by the date in the filename. (Makes a difference if the whole thing was backed up or copied, for instance, which might give them all the same last modified date.)
|
# ? May 29, 2008 17:35 |
|
JoeNotCharles posted:That checks the actual time the file was written, though - I think he wanted to sort by the date in the filename. (Makes a difference if the whole thing was backed up or copied, for instance, which might give them all the same last modified date.) Very true. To do it based on filename would potentially be much more complicated based on how the files are actually named.
|
# ? May 29, 2008 18:32 |
|
JoeNotCharles posted:Unless you're already really familiar with databases, I wouldn't bother with that. If it's low-volume enough that you can do it by hand right now you should be able to just store the .csv files somewhere and read them each time you want to process them. Python has an excellent CSV parsing module - I'd just save the .csv file into a directory tree organized by date, and write a Python script to read them and calculate stats. The two languages I feel safe working in are php and python. My python experience is mostly with personal scripts to organize files and other assorted random things. I've never done anything too advanced with it related to sets of data and thing like that. I'm not even sure you can have a list as a value in another list? More importantly, I have never done anything beyond simple console output with python. While I will probably be the person using this program the most, I would like it to be usable by others at work. A dos prompt will surely scare them off. So that leaves me with php and some sort of web interface. Certainly not the best tool for the job, but doable, eh? I am not so sure about storing things in a db.
|
# ? May 29, 2008 19:35 |
|
JoeNotCharles posted:That checks the actual time the file was written, though - I think he wanted to sort by the date in the filename. (Makes a difference if the whole thing was backed up or copied, for instance, which might give them all the same last modified date.) It actually doesn't matter which one is used. As soon as the file is created and given the file name, it is placed in that directory and is not backed up or archived until this potential script is run. Doing it based on the time the file was written is fine. I have yet to test that script out, but does that look like the best way to do it? Does anyone else have any other suggestions?
|
# ? May 29, 2008 20:16 |
|
I need advice on what to use to implement a program for managing participants, teams, various shooting classes, generating score tables etc for an shooting sport I'm involved in, what out there today is old and outdated, or is ill suited for what we're doing. I'm currently set on learning a language, and had for some time been looking for a project to involve me in to really get into it, I have currently been dabbeling in Python which I really like but isn't entirely sure is the the right choice for this. I have also looked a bit into using Visual Studio 2008 (Express), which gives me some really nice tools for setting up the GUI, but precludes me from say using SQLite and necessitates that I either learn C# or VB from scratch. Is necessarily using some form of database for data storage a smart choice ?, I envisions that I need to store about 2-3 fields of data for each participants(name,club,shorthandname),30-40 fields for scores for each participants for each shootingprogram(name, club, class, team, shootingprogram, targetgroup1(shots,subtarget,sum,weightedtarget)-10 etc) and some change. Any advice would be of great help here.
|
# ? May 30, 2008 00:51 |
|
Vanadium posted:No, mail software still breaks at ~80 characters and terminals and consoles and whatever are still 80 characters in width.
|
# ? May 30, 2008 01:04 |
|
Is anyone aware of any algorithms that will generate nice looking gradients given a base color for buttons and whatnot ( Web 2.0! )? I've played with converting to HSV and then adjusting the saturation and value for the different stops of the gradient but it's a little tweaky - either the adjustment values work well for light desaturated colors or they work well for fully saturated ones, not both. Right now I'm doing something like code:
|
# ? May 30, 2008 16:49 |
|
I don't know if this thread is the best place to ask this but: What is the most common programming environment in the industry? By that I mean is it most common that you will be working in a Unix/Linux environment with some editor like Emacs are is it more common to have a Windows environment with something like Visual Studio?
|
# ? May 30, 2008 16:51 |
|
Tomed2000 posted:I don't know if this thread is the best place to ask this but: Because every part of this industry uses the exact same tool for everything edit: Seriously what kind of question is that? In my last job, one tiny part of "the industry," we used three commercial IDEs and one proprietary, and then some people used other stuff if they wanted to / were allowed to. csammis fucked around with this message at 19:20 on May 30, 2008 |
# ? May 30, 2008 19:18 |
|
If you are trying to pick the toolset to learn so as to aid your course in industry, pick the buggiest, most frustrating toolkit you can find. The patience you develop will be a useful skill.
|
# ? May 30, 2008 19:24 |
|
tef posted:If you are trying to pick the toolset to learn so as to aid your course in industry, pick the buggiest, most frustrating toolkit you can find. The patience you develop will be a useful skill. I'm not, just a student right now. I was having a conversation with a professor and he claims that 90% of the industry programs in a UNIX environment and I thought that was pretty inaccurate.
|
# ? May 30, 2008 20:01 |
|
Tomed2000 posted:I'm not, just a student right now. I was having a conversation with a professor and he claims that 90% of the industry programs in a UNIX environment and I thought that was pretty inaccurate. 90% is inaccurate. But if you're doing web development, for instance, you can often work in whatever environment you want to, so many shops leave it open. If you're writing Java for a big iron machine, it doesn't matter if the development platform is Windows, OS X, Linux, whatever, if it runs Java it's probably a legitimate dev environment. For scripting languages (PHP, Python, Perl, Ruby) it doesn't really matter either, especially since it's probably only going to be run on the servers, not on your dev machine. In this case, your dev machine is essentially a text editor.
|
# ? May 30, 2008 20:16 |
|
Tomed2000 posted:I'm not, just a student right now. I was having a conversation with a professor and he claims that 90% of the industry programs in a UNIX environment and I thought that was pretty inaccurate. If he knows so much about the industry why doesn't he work there?
|
# ? May 30, 2008 21:16 |
|
Tomed2000 posted:I'm not, just a student right now. I was having a conversation with a professor and he claims that 90% of the industry programs in a UNIX environment and I thought that was pretty inaccurate.
|
# ? May 30, 2008 23:27 |
|
My vague impression (not counting web development, since I know nothing about it): - on Windows, absolutely everybody uses Visual Studio, except the Java people who use Eclipse - on Mac, 80% of people use Xcode and the other 20% are Unix refugees who use command-line tools - on Unix, it's very fragmented: some people use Eclipse (even for non-Java stuff), some people use KDevelop, some people use specialized IDE's for their own particular task or language, but probably a majority use the commandline and VIM or Emacs. I would say Windows is still the most common, followed by Unix and then Mac trailing way behind. If you're wondering which to start with, I'd recommend learning on the command line on Mac or Linux, because then Visual Studio/Xcode/whatever is just one more front-end instead of being the only way you know where to work. It's a lot harder moving the other way if you're used to Visual Studio doing a whole bunch of the work for you.
|
# ? May 31, 2008 00:22 |
|
JoeNotCharles posted:If you're wondering which to start with, I'd recommend learning on the command line on Mac or Linux, because then Visual Studio/Xcode/whatever is just one more front-end instead of being the only way you know where to work. It's a lot harder moving the other way if you're used to Visual Studio doing a whole bunch of the work for you. On the other hand, I for one would rather sit down and start coding instead of memorizing command line tools and other crap that stand between the program in my mind and the program-to-be on the computer. Plus, I love Visual Studio, so I'm biased here. I guess if you really love command line stuff, go for it, it certainly won't make you dumber. E: VVV Really, such as? File->New Project too much? I think it's pretty intuitive. Factor Mystic fucked around with this message at 01:41 on May 31, 2008 |
# ? May 31, 2008 00:33 |
|
Factor Mystic posted:On the other hand, I for one would rather sit down and start coding instead of memorizing command line tools and other crap that stand between the program in my mind and the program-to-be on the computer. I for one would rather sit down and start coding instead of memorizing Visual Studio stuff that stands between the program in my mind and the program-to-be on the computer.
|
# ? May 31, 2008 00:52 |
|
Vanadium posted:I for one would rather sit down and start coding instead of memorizing Visual Studio stuff that stands between the program in my mind and the program-to-be on the computer.
|
# ? May 31, 2008 05:00 |
|
Factor Mystic posted:On the other hand, I for one would rather sit down and start coding instead of memorizing command line tools and other crap that stand between the program in my mind and the program-to-be on the computer. Plus, I love Visual Studio, so I'm biased here. I guess if you really love command line stuff, go for it, it certainly won't make you dumber. With C++ at least, I never actually understood the build process, linking model, and even aspects of the language until I stopped using IDEs. It was only then that I understood what a "translation unit" was, really. In my opinion, going from command line to IDE is easier than the other way around, and I'm glad I can work in both environments.
|
# ? May 31, 2008 19:11 |
|
more falafel please posted:With C++ at least, I never actually understood the build process, linking model, and even aspects of the language until I stopped using IDEs. It was only then that I understood what a "translation unit" was, really. In my opinion, going from command line to IDE is easier than the other way around, and I'm glad I can work in both environments. As a java programmer I whole heartedly agree, at university we had to make sure our applications ran from the command line which put us in good stead. I always make sure my ant scripts run from the command line when writing stuff, and if I'm building small stuff or open source apps, I generally just use ant/maven from the command line, instead of faffing around with setting up a new project in eclipse/netbeans.
|
# ? May 31, 2008 22:08 |
|
How can you make a program that runs in eclipse but doesn't run on the command line? Or do you just mean that you, personally, had to know how to build and run it?
|
# ? Jun 1, 2008 02:43 |
|
poopiehead posted:How can you make a program that runs in eclipse but doesn't run on the command line? Or do you just mean that you, personally, had to know how to build and run it? What I mean is that running from the command line you have to set the classpath up properly, you don't just go into a gui and locate your libraries. You also learn about some of the command options you can pass to java / javac. I'd certainly recommend learning java from the command line and moving up to an IDE. On my last project our client took the code in source form and built it on their own enviroments by calling the ant script from the command line, so it was important to ensure that the script ran outside of an IDE.
|
# ? Jun 1, 2008 11:53 |
|
I have a question about automake. My program's source code includes a header file which is automatically derived from another file by a Perl script. I want make to run the Perl script whenever the derived header file is out-of-date (i.e. when its modification timestamp is earlier the one on the file it is derived from). How do I do this?
|
# ? Jun 1, 2008 20:18 |
|
Mr.Radar posted:I have a question about automake. My program's source code includes a header file which is automatically derived from another file by a Perl script. I want make to run the Perl script whenever the derived header file is out-of-date (i.e. when its modification timestamp is earlier the one on the file it is derived from). How do I do this? Have a rule that creates the header file from the other_file, and has the header file depend on both the script and other_file: code:
|
# ? Jun 1, 2008 21:39 |
|
My end goal is to have a Character or 128x64 Graphical LCD to display information from a headless Linux box through a USB Port. The LCD will display information about attached USB Devices, and update when devices are plugged/unplugged (or soon thereafter). To start, something along the lines of 'lsusb | grep "XXXX"' listed on the LCD, or even the number of attached usb devices would work. Maybe thats not the right way to do it, i dont know! It just needs to be similar to a terminate-stay-resident or "service" in windows. Something that is always running in the background and kicks out new jams whenever the usb tree changes. The LCD Display needs to be accessible via USB (or USB->Serial). I think something similar to this would work if I could find Linux drivers for it. Here are the problems: 1. Ive never written anything for linux before. I dont even know where to start! I apt-got the poo poo out of build-essential on my ubuntu desktop but I don't know if something I build there will be able to run on the plain-old-debian-slimmed-down-headless target box. 2. Ive never written anything USB or hardware related. Is this as easy as doing something or other with cron and lsusb and grep and routing it to serial somehow? Pretty much I have no idea where to begin, and I'm looking for guidance on what to read up on. Thanks in advance!
|
# ? Jun 2, 2008 22:48 |
|
What's the easiest way of getting the terminal type from a remote client in a telnet session?
|
# ? Jun 3, 2008 01:09 |
|
Atltais posted:What's the easiest way of getting the terminal type from a remote client in a telnet session? the TERM variable, try echo $TERM, however many terminals lie.
|
# ? Jun 3, 2008 03:55 |
|
tef posted:the TERM variable, try echo $TERM, however many terminals lie. I meant more along the lines of the server poking the client for terminal information. Sorry if I wasn't clear enough.
|
# ? Jun 3, 2008 04:38 |
|
I'm resigning to make myself more OO disciplined, and trying to follow perfect encapsulation. I'm making a video game that has a mysql backend. In the video game, hackers move about systems, and these systems are in regions. I have the following class hierarchy: The Region class has a SystemCollection object, a database id, and a name The SystemCollection class has only a collection of Systems objects The System object has details about systems I'm making a method in the System class that procedurally creates itself. The Region object is told to make a region of random systems, it tells the system collection object to generate a random collection of systems, and the system object generates itself. The problem is that the system table in the DB has to have a region id. When the system creates itself, it needs to not only record its region id, but also it needs to use a different generation algorithm depending on what region the system belongs in. I'm having a hard time figuring out a best practice for this. Here's some ideas that just don't sound right: 1. Have the region id passed along the hierarchy, and then the system object evaluates the id and selects an algorithm. I hate this idea. 2. Have the region object reference passed along the hierarchy, have the actual algorithm in the region class, and have the system object call the method from the region it receives, and record the database id from the region class itself. Different region classes inherit from a base region class, so the algorithm can be completely unique to the region. This sounds like it's not proper encapsulation. I don't know why this sounds wrong to me, but it does. Keep in mind that I'm trying to keep good OO discipline in this project. I don't want to ask any getters for information - I only want to tell objects to do something, and have the object figure it out itself. ColdSnickersBar fucked around with this message at 18:09 on Jun 3, 2008 |
# ? Jun 3, 2008 17:53 |
|
Create a base class for system generation algorithms. The region instances a derived class for a randomly selected generation algorithm and passes it to the system. The system then uses that algorithm to perform the generation.
|
# ? Jun 3, 2008 18:53 |
|
Okay, so, kind of like this:code:
ColdSnickersBar fucked around with this message at 19:27 on Jun 3, 2008 |
# ? Jun 3, 2008 19:18 |
|
ColdSnickersBar posted:Okay, so, kind of like this: Here are a few style suggestions: 1) Generator used to parameterise a common construction template: code:
2) Generator used to build Systems wholesale: code:
3) Inheritance-is-king 90's style Systems: code:
Take your pick, or make your own, YMMV.
|
# ? Jun 3, 2008 20:10 |
|
bash: let's say I've got a command that returns a list of files, something like this: foobar -xvfzw And I want to iterate over this list of files in a for loop: for I in `foobar -xvfzw`; do ...; done But this doesn't work when some files have spaces in their names. Like if I have a file called "this is a test" then the for loop iterates over the values this, is, a, test in order. So in general, how do I write a loop like this in such a way that I get correct values for $I when dealing with the possibility of files with spaces in them?
|
# ? Jun 3, 2008 20:44 |
|
Lexical Unit posted:So in general, how do I write a loop like this in such a way that I get correct values for $I when dealing with the possibility of files with spaces in them? See points 1 and 2 at http://wooledge.org:8000/BashPitfalls
|
# ? Jun 3, 2008 20:51 |
|
|
# ? May 15, 2024 03:48 |
|
I'm aware of both of those pitfalls. I am using "$I" but the problem is that the values of $I are given "this", "is", "a", and "test". Not "this is a test". I'm also aware of the tricky hack that let's you do things like for I in *.ext; ... instead of using ls. My problem is that I'm not trying to use ls. Like I said, I want a general solution that I can apply to any possible command, here symbolized by the hypothetical foobar command. In other words, the solution that replaces `ls *.ext` with *.ext is not a solution to my problem. Edit: To clarify further... You have this situation: code:
Lexical Unit fucked around with this message at 21:08 on Jun 3, 2008 |
# ? Jun 3, 2008 21:03 |