Daily Archives

Articles indexed Saturday April 24 2010

Page 5/78 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Question on overview of C# OOP in business WinForms application - scope of Object

    - by TimR
    I may have all this OO completely wrong, but here goes: Ok the scenario is a classic order entry. Customer places an Order which has OrderLineItems of StockItems. Order is entered by Employee. 1) Application starts and asks for login/password 2) Employee selects 'Orders' from Mainmenu form 3) Orders forms opens.... 4) Employee selects Customer 5) Employee selects Stock adds to OrderLineItems 6) Selects second StockItem; add to OrderLineItems 7) Order is committed, [stock decremented, order posted to DB, Order printed] 8) Employee is returned to MainMenu Now with Object scope: 1) Application starts and asks for login/password Is this the best place to make objEmployee, to be kept whilst in this whole Sales application? 2) Employee selects 'Orders' from Mainmenu form 3) Orders forms opens.... *Make objOrderHeader, is objEmployee able to be passed in or is it created here, or re-created here.* 4) Employee selects Customer - adds/edits Customer details if required... Make objCustomer 5) Employee selects Stock adds to OrderLineItems... *Make objStockItem and objOrderLineItem - add to objOrderLineItems_collection* 6) Selects second StockItem; add to OrderLineItems... *Make objStockItem and objOrderLineItem - add to objOrderLineItems_collection* 7) Order is committed, [stock decremented, order posted to DB, Order printed, Order Entered By = EmployeeID] Once posted to Db, all objects now redundant/garbage [except objEmployee?] 8) Employee is returned to MainMenu is objEmployee still valid as an object?

    Read the article

  • iphone image is leaking, but where?

    - by Brodie4598
    the image that is being displayed in this code is leaking but I cant figure out how. What I have a tableview that displays images to be displayed. Each time a user selects an image, it should remove the old image, download a new one, then add it to the scroll view. But the old image is not being released and I cant figure out why... -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [imageView removeFromSuperview]; self.imageView = nil; NSUInteger row = [indexPath row]; NSString *tempC = [[NSString alloc]initWithFormat:@"http://www.website.com/%@_0001.jpg",[pdfNamesFinalArray objectAtIndex:row] ]; chartFileName = tempC; pdfName = [pdfNamesFinalArray objectAtIndex:row]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docsPath = [paths objectAtIndex:0]; NSString *tempString = [[[NSString alloc]initWithFormat:@"%@/%@.jpg",docsPath,pdfName]autorelease]; NSData *data = [NSData dataWithContentsOfFile:tempString]; if (data != NULL){ self.imageView = nil; [imageView removeFromSuperview]; self.imageView = nil; UIImageView *tempImage = [[[UIImageView alloc]initWithImage:[UIImage imageWithData:data]]autorelease]; self.imageView = tempImage; [data release]; scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height); scrollView.maximumZoomScale = 1; scrollView.minimumZoomScale = .6; scrollView.clipsToBounds = YES; scrollView.delegate = self; [scrollView addSubview:imageView]; scrollView.zoomScale = .37; } else { [data release]; self.imageView = nil; [imageView removeFromSuperview]; self.imageView = nil; activityIndicator.hidden = NO; getChartsButton.enabled = NO; chartListButton.enabled = NO; saveChartButton.enabled = NO; [NSThread detachNewThreadSelector:@selector(downloadImages) toTarget:self withObject:nil]; } chartPanel.hidden = YES; } -(void) downloadImages { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; self.imageView = nil; [imageView removeFromSuperview]; NSURL *url = [[[NSURL alloc]initWithString:chartFileName]autorelease]; NSData *data = [NSData dataWithContentsOfURL:url]; UIImageView *tempImage = [[[UIImageView alloc]initWithImage:[UIImage imageWithData:data]]autorelease]; self.imageView = tempImage; tempImage = nil; scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height); scrollView.maximumZoomScale = 1; scrollView.minimumZoomScale = .37; scrollView.clipsToBounds = YES; scrollView.delegate = self; [scrollView addSubview:imageView]; scrollView.zoomScale = .6; activityIndicator.hidden = YES; getChartsButton.enabled = YES; chartListButton.enabled = YES; saveChartButton.enabled = YES; [pool drain]; [pool release]; }

    Read the article

  • How to use router QoS?

    - by Nathaniel
    N00b question. How exactly does one use router quality of service settings? I've read up on it a bit but I'm still not exactly sure how to use it. So, my real questions are these: Generally, how does QoS work? How would one use it, say, to guarantee smooth performance in latency sensitive application (cough online gaming cough)? Performance for that sort of stuff bombs out on our connection when somebody is uploading files. I apologize if this is kind of sprawling. Suggestions to clean it up / edits welcome.

    Read the article

  • can create a new thread on goog-app-engine ..(python)

    - by zjm1126
    i use this code can crteate ,but someone say it can't create ,why ? class LogText(db.Model): content = db.StringProperty(multiline=True) class MyThread(threading.Thread): def __init__(self,threadname): threading.Thread.__init__(self, name=threadname) def run(self,request): log=LogText() log.content=request.POST.get('content',None) log.put() def Log(request): thr = MyThread('haha') thr.run(request) return HttpResponse('')

    Read the article

  • debugging scaffolding contingent upon degbugging boolean (java)

    - by David
    Recently i've found myself writing a lot of methods with what i can only think to call debugging scaffolding. Here's an example: public static void printArray (String[] array, boolean bug) { for (int i = 0; i<array.lenght; i++) { if (bug) System.out.print (i) ; //this line is what i'm calling the debugging scaffolding i guess. System.out.println(array[i]) ; } } in this method if i set bug to true, wherever its being called from maybe by some kind of user imput, then i get the special debugging text to let me know what index the string being printed as at just in case i needed to know for the sake of my debugging (pretend a state of affairs exists where its helpful). All of my questions more or less boil down to the question: is this a good idea? but with a tad bit more objectivity: Is this an effective way to test my methods and debug them? i mean effective in terms of efficiency and not messing up my code. Is it acceptable to leave the if (bug) stuff ; code in place after i've got my method up and working? (if a definition of "acceptability" is needed to make this question objective then use "is not a matter of programing controversy such as ommiting brackets in an if(boolean) with only one line after it, though if you've got something better go ahead and use your definition i won't mind) Is there a more effective way to accomplish the gole of making debugging easier than what i'm doing? Anything you know i mean to ask but that i have forgotten too (as much information as makes sense is appreciated).

    Read the article

  • Playing audio files from system directory

    - by zx
    hi, I have audio files in var/ This is the file name 2-3109999999-3246758493-1271129518-1271129505.6.wav Format 2=campaign id 3109999999=caller id 3246758493=number called 1271129518=timestamp call ended 1271129505=timestamp call started 6=call id If I were to pass just the number called which was 3246758493, how can I find all the files without defining all the other variables(such as timestamp, etc) and just the files that have that number in the filename?

    Read the article

  • Declaring an array of linked list in C#

    - by xarzu
    I got the compile error message "Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)" when I tried to declare an array of linked lists. public LinkedList[2] ExistingXMLList; Also, if I wanted to create a small array of strings, isn't this the way: string [2] inputdata;

    Read the article

  • Tag Suggestion system, approaches and ideas

    - by Galois
    Hi guys! -- I am working on a (auto) tag suggestion system (NOT tag autocomplete). Lets say I want to suggest tags for a given question like here on SO (although SO's tagging system is auto-complete). My main idea is to get the intersection between the tags_set and the given question.split()_set. (In python the set_intersection is efficient enough). Also, in order to make it a little bit more accurate I might use words-distance to count as 'the same' very close words i.e movie == movies. For now I am not thinking about using any Collaborative Filtering technique looking for the tags to similar questions and so on, because I believe since the question text is pretty short (comparing with a blog article or a paper) it is not worth the effort. So I was wondering if you have any other (more) efficient approaches to suggest. Any ideas, specially from people who they have done something like that before, are more than welcome.

    Read the article

  • Loop a formula in excel VBA

    - by CEMG
    I am trying to loop a formula in Column "D" until Column "B" doesn't have any more data. The formula I am adding to Column "D" is : IF(ISNUMBER(C5),C5,IF(C5A5/3+OFFSET(C5,-1,0)) ,IF(C5<C6,((OFFSET(C5,1,0)-OFFSET(C5,-2,0))(A5/3)+OFFSET(C5,-2,0)),""))) So the result I want in Column "D" once the macro is run is this: A B C D 3 May-10 78.0000 78.00000 1 Jun-10 52.06667 2 Jul-10 26.13333 3 Aug-10 0.2000 0.20000 1 Sep-10 0.21393 2 Oct-10 0.22786 3 Nov-10 0.2418 0.24179 1 Dec-10 0.26640 2 Jan-11 0.29102 3 Feb-11 0.3156 0.31563 1 Mar-11 0.34821 2 Apr-11 0.38080 3 May-11 0.4134 0.41338 1 Jun-11 0.44992 2 Jul-11 0.48646 3 Aug-11 0.5230 0.52300 1 Sep-11 0.56440 2 Oct-11 0.60580 3 Nov-11 0.6472 0.64720 1 Dec-11 0.43147 If someone can help me at what I am doing wrong with the VBA codes I would greatly appreciated. My CODES are the following: Sub IsNumeric() // first logic: IF(ISNUMBER(C6),C6 // If Application.IsNumber(Range("c5").Value) Then Range("d5").Value = Range("C5").Value // second logic: IF(C6 ElseIf Range("c6").Value < Range("c5").Value Then Range("d6").Value = Range("c6").Offset(2, 0).Value - Range("c6").Offset(-1, 0).Value * (Range("a6").Value / 3) + Range("c6").Offset(-1, 0).Value // third logic: IF(C6<C7,((OFFSET(C6,1,0)-OFFSET(C6,-2,0))*(A6/3)+OFFSET(C6,-2,0)),""))) // ElseIf Range("c6").Value < Range("c7").Value Then Range("d6").Value = (Range("c6").Offset(1, 0).Select) - Range("c6").Offset(-2, 0).Select * (Range("a6").Select / 3) + Range("c6").Offset(-2, 0).Select Else Range("d6").Value = "" End If End Sub

    Read the article

  • Defining jUnit Test cases Correctly

    - by Epitaph
    I am new to Unit Testing and therefore wanted to do some practical exercise to get familiar with the jUnit framework. I created a program that implements a String multiplier public String multiply(String number1, String number2) In order to test the multiplier method, I created a test suite consisting of the following test cases (with all the needed integer parsing, etc) @Test public class MultiplierTest { Multiplier multiplier = new Multiplier(); // Test for 2 positive integers assertEquals("Result", 5, multiplier.multiply("5", "1")); // Test for 1 positive integer and 0 assertEquals("Result", 0, multiplier.multiply("5", "0")); // Test for 1 positive and 1 negative integer assertEquals("Result", -1, multiplier.multiply("-1", "1")); // Test for 2 negative integers assertEquals("Result", 10, multiplier.multiply("-5", "-2")); // Test for 1 positive integer and 1 non number assertEquals("Result", , multiplier.multiply("x", "1")); // Test for 1 positive integer and 1 empty field assertEquals("Result", , multiplier.multiply("5", "")); // Test for 2 empty fields assertEquals("Result", , multiplier.multiply("", "")); In a similar fashion, I can create test cases involving boundary cases (considering numbers are int values) or even imaginary values. 1) But, what should be the expected value for the last 3 test cases above? (a special number indicating error?) 2) What additional test cases did I miss? 3) Is assertEquals() method enough for testing the multiplier method or do I need other methods like assertTrue(), assertFalse(), assertSame() etc 4) Is this the RIGHT way to go about developing test cases? How am I "exactly" benefiting from this exercise? 5)What should be the ideal way to test the multiplier method? I am pretty clueless here. If anyone can help answer these queries I'd greatly appreciate it. Thank you.

    Read the article

  • Controlling usb devices from a droid?

    - by user324721
    Anyone know where I can find information on how I can control the USB port on a Droid running Android 2.0? I want to know how to either initialize the USB port or send data across it vi a program. I want to be able to atatch a device to the USB port to act as a switch to control a microservo. So when I said "send data" across the port, I just need to be able to energize the transmit pin on the USB to turn the servo on. Thanks ahead, Tom

    Read the article

  • Having trouble with confusing behaviour of error between debug and release modes in Xcode

    - by Cocorico
    Hi guys, I am confused over something (what is new!). I have an iPhone program I am writing and using some sqlite in a certain method, and there is some error which is giving me a message that says "Program received signal: “EXC_BAD_ACCESS” Okay, so I am trying to hunt down why this is doing this, and I notice something: When I run the program in debug mode, it gives me this error every single time I access this method (I test on the device). However when I run the program in release mode, I can access this method 2 times, and then it will give me this error the third time. So I mean, can someone just give me an explanation of what might cause this, I think that maybe deep-down I am not that smart on the difference in XCode of debug and release modes. I think that release mode does optimizing, and I guess the actual assembly machine code comes out different, yes? I AM A BIG NEWBIE USER UNFORTUNATELY! I am not clear on a lot of things like this, or whether it needs for I to remove nslog commands in the release build and such. Maybe I should just post the actual code in separate Stack OVerflow post, and see if people can see the error, then maybe this all become clear to me.

    Read the article

  • Jquery Bugs?? Long decimal number after two numbers multiply...

    - by Jerry
    Hi all I am working on a shopping site and I am trying to calculate the subtotal of products. I got my price from a array and quantity from getJSON response array. Two of them multiply comes to my subtotal. I can change the quantity and it will comes out different subtotal. However,when I change the quantity to certain number, the final subtotal is like 259.99999999994 or some long decimal number. I use console.log to check the $price and $qty. Both of them are in the correct format ex..299.99 and 6 quantity.I have no idea what happen. I would appreciate it if someone can help me about it. Here is my Jquery code. $(".price").each(function(index, price){ $price=$(this); //get the product id and the price shown on the page var id=$price.closest('tr').attr('id'); var indiPrice=$($price).html(); //take off $ indiPrice=indiPrice.substring(1) //make sure it is number format var aindiPrice=Number(indiPrice); //push into the array productIdPrice[id]=(aindiPrice); var url=update.php $.getJSON( url, {productId:tableId, //tableId is from the other jquery code which refers to qty:qty}, productId function(responseProduct){ $.each(responseProduct, function(productIndex, Qty){ //loop the return data if(productIdPrice[productIndex]){ //get the price from the previous array we create X Qty newSub=productIdPrice[productIndex]*Number(Qty); //productIdPrice[productIndex] are the price like 199.99 or 99.99 // Qty are Quantity like 9 or 10 or 3 sum+=newSub; newSub.toFixed(2); //try to solve the problem with toFixed but didn't work console.log("id: "+productIdPrice[productIndex]) console.log("Qty: "+Qty); console.log(newSub); **//newSub sometime become XXXX.96999999994** }; Thanks again!

    Read the article

  • PHP Classes Extend

    - by John
    I have two classes that work seperate from another, but they extend the same class. Is it possible to have them work the same instance of the extended class. I'm wanting the constructor of the extended class to run only once. I know this isn't right but something like this: <?php $oApp = new app; class a extends $oApp {} class b extends $oApp {}

    Read the article

  • A good data model for finding a user's favorite stories

    - by wings
    Original Design Here's how I originally had my Models set up: class UserData(db.Model): user = db.UserProperty() favorites = db.ListProperty(db.Key) # list of story keys # ... class Story(db.Model): title = db.StringProperty() # ... On every page that displayed a story I would query UserData for the current user: user_data = UserData.all().filter('user =' users.get_current_user()).get() story_is_favorited = (story in user_data.favorites) New Design After watching this talk: Google I/O 2009 - Scalable, Complex Apps on App Engine, I wondered if I could set things up more efficiently. class FavoriteIndex(db.Model): favorited_by = db.StringListProperty() The Story Model is the same, but I got rid of the UserData Model. Each instance of the new FavoriteIndex Model has a Story instance as a parent. And each FavoriteIndex stores a list of user id's in it's favorited_by property. If I want to find all of the stories that have been favorited by a certain user: index_keys = FavoriteIndex.all(keys_only=True).filter('favorited_by =', users.get_current_user().user_id()) story_keys = [k.parent() for k in index_keys] stories = db.get(story_keys) This approach avoids the serialization/deserialization that's otherwise associated with the ListProperty. Efficiency vs Simplicity I'm not sure how efficient the new design is, especially after a user decides to favorite 300 stories, but here's why I like it: A favorited story is associated with a user, not with her user data On a page where I display a story, it's pretty easy to ask the story if it's been favorited (without calling up a separate entity filled with user data). fav_index = FavoriteIndex.all().ancestor(story).get() fav_of_current_user = users.get_current_user().user_id() in fav_index.favorited_by It's also easy to get a list of all the users who have favorited a story (using the method in #2) Is there an easier way? Please help. How is this kind of thing normally done?

    Read the article

  • special debugging lines (java)

    - by David
    Recently i've found myself writing a lot of methods with what i can only think to call debugging scaffolding. Here's an example: public static void printArray (String[] array, boolean bug) { for (int i = 0; i<array.lenght; i++) { if (bug) System.out.print (i) ; //this line is what i'm calling the debugging scaffolding i guess. System.out.println(array[i]) ; } } in this method if i set bug to true, wherever its being called from maybe by some kind of user imput, then i get the special debugging text to let me know what index the string being printed as at just in case i needed to know for the sake of my debugging (pretend a state of affairs exists where its helpful). All of my questions more or less boil down to the question: is this a good idea? but with a tad bit more objectivity: Is this an effective way to test my methods and debug them? i mean effective in terms of efficiency and not messing up my code. Is it acceptable to leave the if (bug) stuff ; code in place after i've got my method up and working? (if a definition of "acceptability" is needed to make this question objective then use "is not a matter of programing controversy such as ommiting brackets in an if(boolean) with only one line after it, though if you've got something better go ahead and use your definition i won't mind) Is there a more effective way to accomplish the gole of making debugging easier than what i'm doing? Anything you know i mean to ask but that i have forgotten too (as much information as makes sense is appreciated).

    Read the article

  • What design patterns are used in diagramming tools?

    - by TheMachineCharmer
    Diagram.net is good diagramming tool. I need to understand what design patterns are used by this tool so that I can understand how it works. What design patterns are used in this tool? What design patterns are generally used for diagramming tools? I would also like to know how can I use this to develop very simple diagramming tool (Only rectangular nodes and straight links). NOTE/Caution: I am doing this for FUN so please don't direct me to existing tools(I might down vote.. just kiddin ;).

    Read the article

  • What's the largest (most complex) PHP algorithm ever implemented in a single monolithic PHP script?

    - by Alex R
    I'm working on a tool which converts PHP code to Scala. As one of the finishing touches, I'm in need of a really good (er, somewhat biased) benchmark. By dumb luck my first benchmark attempt was with some code which uses bcmath extensively, which unfortunately is 1000x slower in Java, making the Scala code 22x slower overall than the original PHP. So I'm looking for some meaningful PHP benchmark with the following characteristics: The source needs to be in a single file. I need it to be simple to setup - no databases, hard-to-find input files, etc. Simple text input and output preferred. It should not use features that are slow in Java (BigInteger, trigonometric functions, etc). It should not use exoteric or dynamic PHP functions (e.g. no "eval" or "variable vars"). It should not over-rely on built-in libraries, e.g. MD5, crypt, etc. It should not be I/O bound. A CPU-bound memory-hungry algorithm is preferred. Basically, intensive OO operations, integer and string manipulation, recursion, etc would be great. Thanks

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >