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
TSDK
Nov 24, 2003

I got a wooden uploading this one

graffin posted:

I am starting my first software development job in about a month and a half, and I want to get a good understanding of the software development life cycle. Are there any good books on this subject?
Steve McConnell's Code Complete.

Adbot
ADBOT LOVES YOU

graffin
Sep 28, 2002

TSDK posted:

Steve McConnell's Code Complete.

Thanks. I have heard from many sources that this book is one of the best books to read as a developer.

baquerd
Jul 2, 2007

by FactsAreUseless

graffin posted:

Thanks. I have heard from many sources that this book is one of the best books to read as a developer.

As it sounds like you've not held a development position before...

If you're working for a medium to large sized company, you will likely have zero input on their development practices as an extra junior developer. There will be exceptions, and you can use best practices for many things - but the overarching cycle is probably not in your hands.

graffin
Sep 28, 2002

quadreb posted:

As it sounds like you've not held a development position before...

If you're working for a medium to large sized company, you will likely have zero input on their development practices as an extra junior developer. There will be exceptions, and you can use best practices for many things - but the overarching cycle is probably not in your hands.

Thanks. I'm just looking to learn. Since I'm not even a CS major, I am not looking to revamp their practices. I just want a general idea of software development, so I can walk in there with all the CS people and not sound like an idiot.

Nam Taf
Jun 25, 2005

I am Fat Man, hear me roar!

Turkmenbashi posted:

No, I should be able to implement that. Thanks!

Think in vectors, my friend, for that is the path to true Matlab enlightenment.

a = zeros(8,3)
a(:,3) = (mod((0:1:7),2)>0) % does 1's column
a(:,2) = (mod((0:1:7),4)>1) % does 2's column
a(:,1) = (mod((0:1:7),8)>3) % does 4's column

I'm sure this could be refined if you didn't want modular arithmetic, but I believe this will be faster than looping it.

Oh, and it leaves your table upside-down, but if that's a problem change it to be 7:-1:0, as such:

a = zeros(8,3)
a(:,3) = (mod((7:-1:0),2)>0) % does 1's column
a(:,2) = (mod((7:-1:0),4)>1) % does 2's column
a(:,1) = (mod((7:-1:0),8)>3) % does 4's column

Which'll give you your requested table.

edit: here is the first option for n columns:

a = zeros(2^n,n);
for i = 1:n
a(:,(n+1-i)) = (mod((0:1:2^n-1),2^i)>2^(i-1)-1);
end

PROTIP: Don't set n>31 unless you've saved your work and hate matlab.
Don't expect n=31 to work because matlab will tell you to get more memory.
Don't expect n>16 to be quick to generate even the zero matrix - n=24 took like 30 seconds to produce the zero matrix alone.
I don't know where the limits for this is.

Nam Taf fucked around with this message at 08:37 on Nov 24, 2008

hey mom its 420
May 12, 2007

Here's a little question for all you y'all. I'm doing a data structures assignment for school and I have to implement a system of two main roads that have roads crossing them. I also have to implement the shortest path search from town 1 to town 2. Here's an example:

I've implemented this in Python. Here's how the path search algorithm works:
I keep two shortest paths, left_path and right_path. They both start out as empty lists. I also keep left_price and right_price, which both start out as 0. And then, I see what the shortest path from the start to the next left node is. In the start, that could either be to take the left road directly (incur a cost of 10) or to take to right road and then cross over, which would incure a cost of 80. Obviously it's better to take the direct road. So new_left_price is now left_price + 10 and new_left_path is ['a']. Then I see what the shortest path to the next right node would be. Obviously, it's better to take the 10 road and then cross over for 30 instead of going over the road that costs 50. So new_right_price now becomes left_price + 10 + 30 and new_right_path becomes left_path + 'a' + 'r'. And this goes on for all the sections until I reach the end and then I just see which of the two possible paths is cheaper.

It works, but I think this is O(n2). If I was just reporting the shortest path cost, it would be O(n), but the thing is that I have to make copies of the left_path and right_path lists because at any moment the right path can become the left path plus something.

This problem could be easily avoided if I were using a purely functional language because with laziness and referential transparency you basically get persistence for free, but my assistant prof told be I can't do it in Haskell because he doesn't know wtf about Haskell.

So, does anyone have any hints or suggestions for making this something better than O(n2)?

hey mom its 420 fucked around with this message at 12:31 on Nov 24, 2008

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
I like your pictures. :3: That is all.

PT6A
Jan 5, 2006

Public school teachers are callous dictators who won't lift a finger to stop children from peeing in my plane

Bonus posted:

Here's a little question for all you y'all. I'm doing a data structures assignment for school and I have to implement a system of two main roads that have roads crossing them. I also have to implement the shortest path search from town 1 to town 2. Here's an example:

I've implemented this in Python. Here's how the path search algorithm works:
I keep two shortest paths, left_path and right_path. They both start out as empty lists. I also keep left_price and right_price, which both start out as 0. And then, I see what the shortest path from the start to the next left node is. In the start, that could either be to take the left road directly (incur a cost of 10) or to take to right road and then cross over, which would incure a cost of 80. Obviously it's better to take the direct road. So new_left_price is now left_price + 10 and new_left_path is ['a']. Then I see what the shortest path to the next right node would be. Obviously, it's better to take the 10 road and then cross over for 30 instead of going over the road that costs 50. So new_right_price now becomes left_price + 10 + 30 and new_right_path becomes left_path + 'a' + 'r'. And this goes on for all the sections until I reach the end and then I just see which of the two possible paths is cheaper.

It works, but I think this is O(n2). If I was just reporting the shortest path cost, it would be O(n), but the thing is that I have to make copies of the left_path and right_path lists because at any moment the right path can become the left path plus something.

This problem could be easily avoided if I were using a purely functional language because with laziness and referential transparency you basically get persistence for free, but my assistant prof told be I can't do it in Haskell because he doesn't know wtf about Haskell.

So, does anyone have any hints or suggestions for making this something better than O(n2)?

Have you covered graphs yet? Implement the map as a graph, with one vertex per intersection, and an edge between any two connected intersections. You can then do a shortest path search by doing a breadth-first-search on the graph, sorting edges by their cost (I think you could do this by using a priority queue to keep track of which vertex to visit next, instead of a normal queue). The first path that arrives at the destination is the shortest.

I'm just learning this stuff myself, so don't take my word for it, but I think it should work.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Bonus posted:

So, does anyone have any hints or suggestions for making this something better than O(n2)?

You can create immutable data structures in non-functional languages. The language might not guarantee that it's immutable, but it's easy enough to just. not. mutate it.

Also, it doesn't change the asymptotic complexity, but in your restricted setting there's a pretty obvious encoding for paths requiring only N-1 bits (where N is the length in segments of the main roads).

PT6A: the problem setup is more restricted than the general problem over graphs, so it's worth considering whether we can improve over the general case. In this case, of course, the answer is "not really", although we should get better constant factors.

hexadecimal
Nov 23, 2008

by Fragmaster

Bonus posted:

Here's a little question for all you y'all. I'm doing a data structures assignment for school and I have to implement a system of two main roads that have roads crossing them. I also have to implement the shortest path search from town 1 to town 2. Here's an example:

I've implemented this in Python. Here's how the path search algorithm works:
I keep two shortest paths, left_path and right_path. They both start out as empty lists. I also keep left_price and right_price, which both start out as 0. And then, I see what the shortest path from the start to the next left node is. In the start, that could either be to take the left road directly (incur a cost of 10) or to take to right road and then cross over, which would incure a cost of 80. Obviously it's better to take the direct road. So new_left_price is now left_price + 10 and new_left_path is ['a']. Then I see what the shortest path to the next right node would be. Obviously, it's better to take the 10 road and then cross over for 30 instead of going over the road that costs 50. So new_right_price now becomes left_price + 10 + 30 and new_right_path becomes left_path + 'a' + 'r'. And this goes on for all the sections until I reach the end and then I just see which of the two possible paths is cheaper.

It works, but I think this is O(n2). If I was just reporting the shortest path cost, it would be O(n), but the thing is that I have to make copies of the left_path and right_path lists because at any moment the right path can become the left path plus something.

This problem could be easily avoided if I were using a purely functional language because with laziness and referential transparency you basically get persistence for free, but my assistant prof told be I can't do it in Haskell because he doesn't know wtf about Haskell.

So, does anyone have any hints or suggestions for making this something better than O(n2)?

http://en.wikipedia.org/wiki/Dijkstra's_algorithm
This one works well if you dont have negative edge cycles.

Use heap or some similar data structure for extracting minimum path from list of already covered vertices, and you can achieve logarithmic time. (wiki says its (|E|+|V|) log |V| )

Lexical Unit
Sep 16, 2003

So I'm on RHEL4 and using gcc to compile. I want to link against a shared library using the command line option -lname but there's no libname.so file in my library path. That's because I'm building -m32 on a 64 bit platform. So there is a /usr/lib64/libname.so, but no /usr/lib/libname.so.

However there is a /usr/lib/libname.so.1, I just need to make a symbolic link to it by the name libname.so and that solves my problem.

The question is, why do none of the 32 bit .so files on my machine have these symbolic links setup, but the 64 bit .so files do? I'm guessing that's just the default since the machine is 64 bit.

In the future is there a way to install things with (with rpm I suppose) such that the symlinks are setup for both 32 bit and 64 bit libaries, and is there a way now to quickly setup all the symlinks in places like /usr/lib, /usr/X11R6/lib, ... or do I just have to do it manually (ie: write some script to do it in batch, and manually execute that script on every machine I want to compile on)?

covener
Jan 10, 2004

You know, for kids!

Lexical Unit posted:



The question is, why do none of the 32 bit .so files on my machine have these symbolic links setup, but the 64 bit .so files do? I'm guessing that's just the default since the machine is 64 bit.

Doesn't appear to be the case on 64-bit RHEL5/em64t or 64-bit SLES9/ppc64(I don't have a 64-bit RHEL4 running unfortunately).

Net, I believe the symlinks should be there for a _typical_ library. Do you have symlinks for zlib or expat?

Lexical Unit
Sep 16, 2003

Ah that may be it. The library in question was Boost.Regex, not too far out there, but not _typical_ either. Could be a misconfigured boost installation is the problem.

I was just wondering if maybe not having .so symlinks for off-architecture libs was standard operating procedure and I was ignorant of that, I guess not.

hey mom its 420
May 12, 2007

rjmccall posted:

You can create immutable data structures in non-functional languages. The language might not guarantee that it's immutable, but it's easy enough to just. not. mutate it.
Well that's what I'm doing here, instead of mutating the list with the path, I'm copying it. It's just that when you have a lazy language, you usually get persistence for free, so you don't incur time penalties for making a copy.

I implemented the search with Dijkstra by using the algorithm description from Wikipedia. It works, only the constant factor is much bigger than the one in my own algorithm and it's still O(n^2) because I didn't use a priority queue to store the unoptimized vertices but a normal list. Because I'm a bit confused when it comes to using a priority queue to store the unoptimized vertices. Here's the pseudocode from Wikipedia:
code:
  function Dijkstra(Graph, source):
      for each vertex v in Graph:           // Initializations
          dist[v] := infinity               // Unknown distance function from source to v
          previous[v] := undefined          // Previous node in optimal path from source
      dist[source] := 0                     // Distance from source to source
      Q := the set of all nodes in Graph    // All nodes in the graph are unoptimized - thus are in Q
      while Q is not empty:                 // The main loop
          u := node in Q with smallest dist[]
          remove u from Q
          for each neighbor v of u:         // where v has not yet been removed from Q.
              alt := dist[u] + dist_between(u, v)       // be careful in 1st step - dist[u] is infinity yet
              if alt < dist[v]              // Relax (u,v)
                  dist[v] := alt
                  previous[v] := u
      return previous[]
If I use a binary heap for Q, I put them in by their distance from the source. That's all cool, but when relaxing (u,v), the distance for a vertice is changed and then suddenly the binary heap doesn't satisfy the heap property. If I rebuild the heap after relaxing (u,v), well that increases the complexity so much that it doesn't make sense to use a heap at all.

I did that with my own binary heap implementation, which takes a projection function, so I do something like heap.push(Q, vertex, key=lambda x:dist[x]) and u = heap.pop(Q, key=lambda x:dist[x])

hey mom its 420 fucked around with this message at 16:03 on Nov 25, 2008

floWenoL
Oct 23, 2002

Bonus posted:

If I use a binary heap for Q, I put them in by their distance from the source. That's all cool, but when relaxing (u,v), the distance for a vertice is changed and then suddenly the binary heap doesn't satisfy the heap property. If I rebuild the heap after relaxing (u,v), well that increases the complexity so much that it doesn't make sense to use a heap at all.

No need to rebuild the heap; just remove (u, old_dist) and insert (u, new_dist), both of which are lg n operations.

hey mom its 420
May 12, 2007

Uh, wait, but I'm supposed to modify the distence of v, not u. u is the priority element and modifying it is log n, but I'm supposed to modify v, which is the neighbour of the priority element and I don't know where that element is in the priority queue.

floWenoL
Oct 23, 2002

Bonus posted:

Uh, wait, but I'm supposed to modify the distence of v, not u. u is the priority element and modifying it is log n, but I'm supposed to modify v, which is the neighbour of the priority element and I don't know where that element is in the priority queue.

Oh, right. Actually, it suffices to exchange the changed element with its parent while necessary. That's log(n) and preserves the heap property. I guess you'd also have to store per-node info as to where it is in the heap (and update it). Hmm.

hey mom its 420
May 12, 2007

Haha, nevermind, I actually managed to make a solution in O(n) time. Can someone confirm that this is O(n)?
code:
    def path(self):
        left_price, right_price = 0, 0
        previous = {}
        current = current_left, current_right = self.start
        while (current_left, current_right) != self.end: # O(n)
            _, a_len, next_left = current_left.next
            _, b_len, next_right = current_right.next
            _, c_len, _ = next_right.sideways
            if a_len + left_price <= b_len + c_len + right_price:
                new_left_price = left_price + a_len
                previous[next_left] = current_left, current_left.next
            else:
                new_left_price = right_price + b_len + c_len
                previous[next_left] = next_right, next_right.sideways
                previous[next_right] = current_right, current_right.next
            if b_len + right_price <= a_len + c_len + left_price:
                new_right_price = right_price + b_len
                previous[next_right] = current_right, current_right.next
            else:
                new_right_price = left_price + a_len + c_len
                previous[next_right] = next_left, next_left.sideways
                previous[next_left] = current_left, current_left.next
            right_price, left_price = new_right_price, new_left_price
            current_left, current_right = next_left, next_right
        end_left, end_right = self.end
        if left_price <= right_price:
            return extract_path(end_left, previous)
        else:
            return extract_path(end_right, previous)
Basically instead of storing the paths in a list and copying them, I store them in a dict where the key is a vertex and the value of that key corresponds to a tuple of (vertex, edge) which points to the key, so with that dict I can run extract_path on it to follow the best path. So it's sort of like a Dijkstra, only modified for this and I'm pretty sure it's O(n)

EDIT: I timed this, and it's a massive speed improvement over the previous version and the time looks like it's linear. w00t!

hey mom its 420 fucked around with this message at 18:56 on Nov 25, 2008

narbsy
Jun 2, 2007

floWenoL posted:

Oh, right. Actually, it suffices to exchange the changed element with its parent while necessary. That's log(n) and preserves the heap property. I guess you'd also have to store per-node info as to where it is in the heap (and update it). Hmm.

The remove/add thing does work; Java code below. However .. O(n) solution is more awesome.

code:
		while( ! pq.isEmpty() ) {
			Pair<V> curr = pq.poll();
			int temp;
			
			Collection<E> edges = g.outgoingEdges(curr.vertex);
			for ( E e : edges ){
				temp = cost.get(e.src()) + e.weight();
				if ( temp < cost.get(e.dest())) {// e requires attention, relax e
						cost.put(e.dest(), temp);
						previous.put(e.dest(), e.src());
						Pair<V> p = new Pair<V>(temp, e.dest());
						pq.remove(p);
						pq.offer(p);			//pq fix
				}
			}
		}

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Bonus posted:

Well that's what I'm doing here, instead of mutating the list with the path, I'm copying it. It's just that when you have a lazy language, you usually get persistence for free, so you don't incur time penalties for making a copy.

But that's what I mean. In a functional language, you would use a data structure that doesn't require a copy, and you can use that exact same data structure in Python. My Python might be rusty, but:

code:
class Cons:
  def __init__(self,hd,tl):
    self.head = hd
    self.tail = tl
    if tl:
      self.cost = hd.cost + tl.cost
    else:
      self.cost = hd.cost

def shortest_path():
  left = Cons(left_segments[0],None)
  right = Cons(right_segments[0],None)
  
  i = 0
  while i < n - 1:
    cross = crosses[i]
    if (left.cost + cross.cost < right.cost):
      right = Cons(cross, left)
    elif (right.cost + cross.cost < left.cost):
      left = Cons(cross, right)

    i = i + 1
    left = Cons(left_segments[i], left)
    right = Cons(right_segments[i], right)
  
  # whatever post-processing you need to do here

rjmccall fucked around with this message at 23:38 on Nov 25, 2008

ndb
Aug 25, 2005

I need some help figuring out an algorithm for multiplying IEEE-compliant single floating points with only using an integer multiplication and in either binary or hexadecimal.

The only part I'm able to figure out so far is what to do with the exponent and the sign.

It's not a straight up multiplication, but I'm not sure what it is:

Look at these mantissas:

code:
001 0001 1001 1001 1001 1001

011 1011 0110 0000 0000 0000

Gives:

101 0101 0010 0011 1001 1010
Since I can only use integer multiplication, I can't even convert the entire number to decimal. Is there just something I'm missing?

I don't want to ruin my entire Thanksgiving because of this. :(

TSDK
Nov 24, 2003

I got a wooden uploading this one
It should just be a straight multiplication, but don't forget that the single precision format is normalised so that there's an implicit '1' at the front, and you'll need to shift the result appropriately back into normal form once you're done.

EDIT: You can do the multiplication in calc.exe:

code:
1 001 0001 1001 1001 1001 1001
*
1 011 1011 0110 0000 0000 0000
=
110 1010 1001 0001 1100 1100 0101 1100 0110 0000 0000 0000

=> (shifting, lopping off the '1' and truncating:

1 101 0101 0010 0011 1001 1000
Which is pretty drat close, ignoring rounding errors...

TSDK fucked around with this message at 19:43 on Nov 27, 2008

ndb
Aug 25, 2005

Is that it? I feel kinda dumb now. Thanks. :P

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe
Been working on a batch file to automatically svn a file and ftp it. I have in the batch file so far:

code:
svndir=c:\svndir\
cd %svndir%
TortoiseProc.exe /command:update /path:"%svndir%" /closeonend:1
copy %1
TortoiseProc.exe /command:commit /path:"%svndir%"/closeonend:1
ftp -s:update.txt %1
update.txt is as follows
code:
open ftp.server.com
username
password
cd public
put %1
quit
obviously when I get into the ftp part it's just trying to do put %1 rather than taking the command line argument. How could I specify a file to take into the ftp part and upload it. Or is there a way to do in on one line in Windows? Or a way to variably select a file to upload rather than just hard coding all the of files that could possibly be modified (really don't wanna do that)?

I was gonna use Filezilla for the uploading rather than the regular windows ftp, but it seems that only supports connecting and not uploading from command line.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Why not just make an SVN hook to FTP it wherever it needs to go?

clockwork automaton
May 2, 2007

You've probably never heard of them.

Fun Shoe

Avenging Dentist posted:

Why not just make an SVN hook to FTP it wherever it needs to go?

Because that's far too logical and I don't know how to do that. :) But yeah, I'll look it up.

ndb
Aug 25, 2005

I'm having a bit of trouble with debugging C++ and 0x86 assembly code together.

For some reason, in Visual Studio C++ 2008 Express Version Latte with Sprinkles edition, if I press start debugging, it skips the the C++ part of the program and skips to debugging the ASM file.

Here's the C++ code:

code:
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
 extern "C" int FpMult(string *, string *); //prototype for ASM file.

int main(int argc, _TCHAR* argv[])
{
	string operand1; //our operands for the multiplication.
	string operand2;
	string product; //product of the operand.
	string stopper; //used in stopping the loop.

	while(true)
	{
	cout << "Please put in two 8 digit IEEE standard floating point number in hexadecimal.";
	cin >> operand1;
	cin >> operand2;

	product = FpMult(&operand1, &operand2);
	cin >> product;
	cout << "Would you like to calculate another value? (y/n)";
	cin >> stopper;

	if(stopper == "y")
		break;
	} 

	return 0;
}
It skips the input streams, so when FpMult is called it goes to the ASM function with garbage values. I'll post the ASM file if it's requested but it's quite long.

Any help is appreciated.

EDIT: Input and output streams are being skipped. Sorry for not mentioning that.

ndb fucked around with this message at 05:09 on Dec 1, 2008

floWenoL
Oct 23, 2002

Why are you assigning the return value of FpMult (an int) to the string product? Why are you then immediately overwriting product with whatever cin reads in?

Why does a function named FpMult() return an int? How exactly do you write a floating point number in hex?

ndb
Aug 25, 2005

Both of those were the result of being sleep-deprived while programming. Thanks for catching them.

code:
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
 extern "C" string FpMult(string *, string *); //call ASM file.

int main(int argc, _TCHAR* argv[])
{
	string operand1; //our operands for the multiplication.
	string operand2;
	string product; //product of the operand.
	string stopper; //used in stopping the loop.
	while(true)
	{
	cout << "Please put in two 8 digit IEEE standard floating point number in hexadecimal.";
	cin >> operand1;
	cin >> operand2;

	product = FpMult(&operand1, &operand2);
	cout << product;
	cout << "Would you like to calculate another value? (y/n)";
	cin >> stopper;

	if(stopper == "y")
		break;
	} 

	return 0;
}
Still same problem though. :(

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Clock Explosion posted:

Both of those were the result of being sleep-deprived while programming. Thanks for catching them.

Still same problem though. :(

You might want to put in some newlines after your output. Also you have the logic for "y/n" screwed up.

I made a test function for FpMult and everything works fine. So I'm going to go out on a limb and guess that you're treating the strings as char*s in your assembly code. That's not going to work.

ndb
Aug 25, 2005

Avenging Dentist posted:

You might want to put in some newlines after your output. Also you have the logic for "y/n" screwed up.

I made a test function for FpMult and everything works fine. So I'm going to go out on a limb and guess that you're treating the strings as char*s in your assembly code. That's not going to work.

But would that really cause the debugger to totally bypass the input streams in the C++ file?

I have a feeling you're probably right about the char*, but I at least want to input some value in to see whether or not it works first.

EDIT: Input and Output.

ndb fucked around with this message at 05:08 on Dec 1, 2008

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Clock Explosion posted:

But would that really cause the debugger to totally bypass the input streams in the C++ file?

You are probably looking at the internal std::string data and not the raw char* and thus it looks like crap.

ndb
Aug 25, 2005

Changing the code to this (probably not correct...I've never worked with C-style strings that much)...

code:
#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;
 extern "C" char* FpMult(char*, char*); //call ASM file.

int main(int argc, _TCHAR* argv[])
{
	char operand1[8]; //our operands for the multiplication.
	char operand2[8];
	char* product; //product of the operand.
	string stopper; //used in stopping the loop.
	
	while(true)
	{
	cout << "Please put in two 8 digit IEEE standard floating point number in hexadecimal.";
	cin >> operand1;
	cin >> operand2;

	product = FpMult(operand1, operand2);
	cout << &product;
	cout << "Would you like to calculate another value? (y/n)";
	cin >> stopper;

	if(stopper == "n")
		break;
	} 

	return 0;
}
I'm still having the debugger bypass the output AND input streams.

PSUEDO-EDIT: That was probably a useful bit of information that was missing, the fact it's skipping the output stream as well.

Triple Tech
Jul 28, 2006

So what, are you quitting to join Homo Explosion?
Let's say I have a process that needs to be initialized (new Org::Process;) and it handles the import of various files. But the nature of the import is that it takes a non-trivial amount of time and has side effects (10-20 minutes, bcp'ing). How should the interface for this be written? Or, what do you think?

A) Org::Process->importFile( $file ) takes a file and immediately imports it.

B) Org::Process->addFile( $file ) takes a file and defers its import to some later time when Org::Process->importFiles is called.

Jethro
Jun 1, 2000

I was raised on the dairy, Bitch!
It would seem that B) consists of enqueuing $files as they are given to you by the "user" and then doing Org::Process->importFile( $file ) as you de-queue them. But the "user" has already constructed their own (possibly informal) queue when they collected the $files they gave to you. If you can add more value than that, then it might make sense to create B), but even in that case it doesn't seem like it would make a lot of sense to hide A) from the "user"

Zombywuf
Mar 29, 2008

You should probably do both, that is have a class that does A) and another class that does B) using A) to do it. Always one task per class.

floWenoL
Oct 23, 2002

Zombywuf posted:

You should probably do both, that is have a class that does A) and another class that does B) using A) to do it. Always one task per class.

Edit:
Nevermind, I misunderstood the question.

floWenoL fucked around with this message at 22:59 on Dec 1, 2008

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

floWenoL posted:

In particular, the most parsimonious way to do this would be to use a producer-consumer queue with a threadpool. If you need strict FIFO behavior, then you simply have 1 thread in your threadpool.

Ok, before involving threads and poo poo, step back and think about what you NEED. Yes, this function will take a while to run could fail in the middle for a variety of outside reasons. Does this matter? Is this to be run from a command-line utility? If so, just copy each file as it's given to you, abort with an error code (or throw an exception) if it fails, and die with an error message if any of them happen. Is this to be run from a GUI that needs to not freeze while the copy is happening? If so, you're going to need to use a thread (or fork off a subprocess) to do the copying. Now decide how much error handling you need (if you can pop open a progress bar, you just need "still going" or "it failed", otherwise you have to worry about the user triggering other actions while your file copy is going on in the background.)

But there's no point in trying to design a complex threaded architecture to handle every possible case if you're not going to need it.

floWenoL
Oct 23, 2002

JoeNotCharles posted:

But there's no point in trying to design a complex threaded architecture to handle every possible case if you're not going to need it.

Yeah, you're right; I misinterpreted B to be an asynchronous version of A.

Adbot
ADBOT LOVES YOU

Gilgamesh
Nov 26, 2001

This is really pissing me off and I'm sure it's something stupid. For some reason, $_POST isn't populating.

code:
(in self.php:)

<? print_r($_POST); ?>
<form method="POST" action="self.php">
<input type="hidden" value="test" id="test">
<input type="submit" value="click me">
</form>
Returns:

code:
Array ( )
It does this for every input type I try, not just the hidden and submit ones.

Edit: php 5.2 and apache 2.0.61

Gilgamesh fucked around with this message at 18:14 on Dec 3, 2008

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