Search Results

Search found 91526 results on 3662 pages for 'clean code'.

Page 131/3662 | < Previous Page | 127 128 129 130 131 132 133 134 135 136 137 138  | Next Page >

  • Popup extender "frozen" on code-behind exception.

    - by davandries
    Hi, In a C#/ASP.NET project, we're using an ajax modalpopupextender to display a "Processing..." message to the users. We're displaying it using a Javascript call in the code of the ASP.NET page. Then, in the code behind, we're doing some database operation, and hide again the popup using "popup.hide();" The problem is that when an exception occurs in the code behind, the popup is still displayed and the application does not handle errors as per the "customErrors" tag of the web.config. Any idea on how to deal with this kind of issues? Thanks, David

    Read the article

  • Initialize window code Mac OS X

    - by Jarle
    I'm currently reading "the red book" for learning OpenGL properly, and in one of the first examples, the author writes a line that says "InitializeAWindowPlease();" as a place holder for the code that will make a window to draw the OpenGL content in. Since I'm using Xcode for my programing, I know that I "get" a window to work with automatically (and that I have to make my own OpenGL view in interfacebuilder). How can I make this with pure code? I'm trying to learn programming, and I'm not to happy about taking "shortcuts" all the time. How can I make a window to draw my openGL stuff in? With Objective-C and C code I would love to see it. My goal is that I can make it without opening interface builder at all:)

    Read the article

  • Debugging of native code

    - by graham.reeds
    I have a C# Service that is calling a C DLL that was originally written in VC6. There is a bug in the DLL which I am trying to inspect. After having a nightmare trying to get debug to work I eventually added the dll to the VS2005 solution containing the C# Service and added the necessary _CRT_SECURE_NO_WARNINGS. The debug version of the service is registered using 'installutil.exe' tool. I can get the debugger to break just before the line where the dll is entered via a call to System.Diagnostics.Debugger.Break();. I found some instruction on the net regarding stepping into debugging unmanaged code, and enabled the 'Enable unmanaged code debugging' check box, I've also tried turning on the Options-Debugging-Native 'Load DLL exports' and 'Enable RPC Debugging' (even though it's not COM). I've also copied the debug dll and .pdb to the same bin directory as the However the unmanaged code is not being stepped into which is what I really need. UPDATE: I found the Debugging Type in the DLL properties and set it to 'Mixed' as per suggestion on several sites but to no avail.

    Read the article

  • Efficiency of Java code with primitive types

    - by super89
    Hello! I want to ask which piece of code is more efficient in Java? Code 1: void f() { for(int i = 0 ; i < 99999;i++) { for(int j = 0 ; j < 99999;j++) { //Some operations } } } Code 2: void f() { int i,j; for(i = 0 ; i < 99999;i++) { for(j = 0 ; j < 99999;j++) { //Some operations } } } My teacher said that second is better, but I can't agree that opinion.

    Read the article

  • What are the characteristics of spaghetti code?

    - by justjoe
    Somebody said that when your PHP Code and application use global variable then it must be a spaghetti code (i assume this). I use wordpress a lot. As far as i know, it's the best thing near a great php software. And it use many global variables to interact between its components. but forget about that, cause frankly, that's the only thing i know. so it's completely biased ;D so just curious, What is the characteristic of spaghetti code ? ps : the only thing i know is wordpress. so, Hopefully, maybe this will help somebody give great answer for somebody who have a little experience on developing full web application on PHP (for example, stack-overflow website)

    Read the article

  • Javascript functions return lines of function code or "{[native code]}," what am I doing wrong?

    - by DavidR
    I am writing some code to find the user selection in a contenteditable div, I'm taking my code from this quirksmode article. function findSelection(){ var userSelection; if (window.getSelection) {userSelection = window.getSelection;} else if (document.selection){userSelection = document.selection.createRange();} // For microsoft if (userSelection.text){return userSelection.text} //for Microsoft else {return userSelection} } I'm testing it in Chrome and Firefox, if I do an alert(userSelection) within the function or an alert(findSelection();) outside the function, it returns function getSelection() {[native code]}. If I do console.log(findSelection();) it gives me getSelection(). Is there something I've done wrong?

    Read the article

  • Need help with homework(very short code)

    - by b3y4z1d
    I have a code, and I need to have it done until friday or so.I'd say 95% of it is finished,but the functions and the function-calling could use some grooming. It is really simple for anyone who knows C++ pretty well, but I'm a newbie and I just can't seem to get through this with the functions so if anyone could take a look and correct the few mistakes or add a line or two if needed I'd be very grateful. Here is the link to the full code, you'll understand the purpose of the code once you see it. I use Borland C++ by the way if it helps. Thanks in advance!

    Read the article

  • Python code that needs some overview

    - by fabio
    Hi guys, im currently learning python (in the very begining), so I still have some doubts about good code manners and how should I proceed with it. Today I created this code that should random trought 01 to 60 (but is running from 01 to 69) import random dez = ['0', '1', '2', '3', '4', '5', '6'] uni = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] sort = [] while len(sort) <= 5: random.shuffle(dez) random.shuffle(uni) w = random.choice(dez) z = random.choice(uni) chosen = str(w) + str(z) if chosen != "00" and chosen not in sort: sort.append(chosen) print chosen I'm also in doubt how to make the code stop at "60".

    Read the article

  • Solutions for redundant server and client code?

    - by Fragsworth
    In our system, the code which exists on the client side (in Flash and Javascript) mirrors the code that exists on the server side (e.g. in Python or PHP), normally with respect to the models, the methods available for those models, and the unit tests written for them. This becomes a problem in systems where you want to minimize data transfer (e.g. multiplayer games). I do not want to write the same code and unit tests redundantly for both the client and server, but I don't know of any standard solutions to deal with this. Basically, I want a language/compiler which can produce models and methods for three main languages: Actionscript, Javascript, and any server language. Does something like this exist?

    Read the article

  • Synclock a section of code while waiting for ShowDialog to return

    - by clawson
    I'm having trouble working out how to lock my application out of a section of code while it waits for a response from an external program. I've used Synclock on a section of code with the Me object in the expression. In this Synclock I call an overridden ShowDialog method of a dialog box, which has a timeout parameter, but does return the value from the underlying ShowDialog function call ,once the timer is setup. Works like this. SyncLock Me Dim frmDlgWithTimeout As New frmDlgWithTimeout ' dialog box with overridden ShowDialog ' Dim res As DialogResult = frmDlgWithTimeout.ShowDialog(10 * 1000) ' 10 sec timeout ' End SyncLock Now, external programs may raise events that bring my application to this Synclock but it doesn't prevent it from entering it, even though the ShowDialog function hasn't returned a value (and hence what I thought would keep the section of code locked). There is only one instance of the object that is used for lock in the program. Your help is greatly appreciated.

    Read the article

  • Problems with noobs putting my GA code into their sites

    - by dclowd9901
    I don't mean for the title to be derogatory, but this is a rather frustrating problem, and I'm looking for a good workaround, given a language barrier involved. I have a site set up for a plugin I wrote, and, rather than use the site's resources to write their own code, I've had people simply rip the code from the samples on the site. Normally, this wouldn't be any issue at all, but they are also taking my Google Analytics instantiation, so my Analytics data is getting very skewed by incorporating visitation data from their websites. I've been able to contact the English-speaking site owners with little issue. The problem lies in the Japanese language sites that are yanking the code. I have no idea how to ask them to take down the analytics portion. Long-term, I'm providing a package that streamlines the learning-to-use process, but in the meantime, what can I do about this language barrier? Is there a way around this problem that I haven't thought of?

    Read the article

  • Mapping US zip code to time zone

    - by Doug Kavendek
    When users register with our app, we are able to infer their zip code when we validate them against a national database. What would be the best way to determine a good potential guess of their time zone from this zip code? We are trying to minimize the amount of data we explicitly have to ask them for. They will be able to manually set the time zone later if our best guess is wrong. I realize zip codes won't help with figuring out the time zone outside the US, but in that case we'd have to manually ask anyway, and we deal predominantly with the US regardless. I've found a lot of zip code databases, and so far only a few contain time zone information, but those that do are not free, such as this one. If it's absolutely necessary to pay a subscription to a service in order to do this, then it will not be worth it and we will just have to ask users explicitly. Although language isn't particularly relevant as I can probably convert things however needed, we're using PHP and MySQL.

    Read the article

  • Is Pex (Test generation) really usefull tool?

    - by Yauheni Sivukha
    Yes, it is possible to generate tests on boundary values for functions like "Sum" or "Divide". Pex is a good tool here. But more often we create tests on business behaviour. Let's consider example from classic Beck's tdd book: [Test] public void ShouldRoundOnCreation() { Money money = new Money(20.678); Assert.AreEqual(20.68,money.Amount); Assert.AreEqual(2068,money.Cents); } Can this test be generated? No :) 95 % of tests in my projects check business logic, and can not be generated. Pex (Especially in pair with Moles) can give 100% code coverage, but a high code coverage rate of a test suite does never indicate, that code is well tested - It only gives false confidence that everything is tested. And this is very dangerous. So, the question is - Is Pex really usefull tool?

    Read the article

  • ASP.NET MVC: run code after view has rendered (close db transaction)

    - by thermal7
    Hi, I am using ASP.NET MVC2 with NHibernate, but am facing an issue. All calls to the database via NHibernate should be inside a transaction, however code inside the view kicks off database calls in some instances. Thus there is a need to be able to commit the transaction after the view has rendered. For example displaying a list of users and their user roles you might show the user role using this code: <%: Model.UserRole.Name % This will cause a hit on the database as the UserRole is loaded using a NHibernate proxy. You can fetch the UserRole eagerly which circumvents the issue in this case, but there are cases where it is much faster to use lazy loading. Anyway, is there a way to run code after a view has rendered?

    Read the article

  • Java + GWT + GSON on server side

    - by Jan
    Hi everybody. I already read that there is no possibility to run GSON in GWT client code, but that it is possible to run it in server code. The latter one is which I'm trying to achive, but not getting to work. I thought any class within the com.whatever.server package has access to the whole JRE namespace including reflection. It seems that that is not the point. So how managed all those developers to use GSON in GWT server code? (I'm new to GWT, so the answer may be really easy.) Thanks.

    Read the article

  • Linenumber for Exception thrown in runtime-compiled DotNET code

    - by David Rutten
    Not quite the same as this thread, but pretty close. My program allows people to enter some VB or C# code which gets compiled, loaded and executed at runtime. My CompilerParams are: CompilerParameters params = new CompilerParameters(); params.GenerateExecutable = false; params.GenerateInMemory = true; params.IncludeDebugInformation = false; params.TreatWarningsAsErrors = false; params.WarningLevel = 4; When this code throws an exception I'd like to be able to display a message box that helps users debug their code. The exception message is easy, but the line-number is where I got stuck. I suspect that in order to get at the line number, I may need to drastically change the CompilerParameters and perhaps even the way these dlls get stored/loaded. Does anyone know the least steps needed to get this to work?

    Read the article

  • Connecting Android XML and Code

    - by Nick
    I'm new to android and have gotten used to doing all my previous UI in code. I can understand the simple examples, but I'm trying something more complex and have no idea how to do it in code and XML. I'm trying to use the google map api and draw text on the map at a specified spot. I have succeeded in doing so by extending overlay and overriding the draw method using drawtext. This has pretty much accomplished what I'm looking to do, but I want have read that is poor practice. I now want to add a second line below the first and just using \n does not work. I can work it out using another drawtext method, but I figured it would be better to create a custom textview, I just have no idea how to position it using code and encapsulate it inside the overlay. Maybe the way I'm doing it is the best way...

    Read the article

  • Why does this code block say "not all code paths return a value"?

    - by Kishan
    I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)': not all code paths return a value Please help me... Thanks in advance... My code is as given below... public int Login(string connectionString,string username,string password) { SqlConnection con=new SqlConnection(connectionString); con.Open(); SqlCommand validUser = new SqlCommand("SELECT count(*) from USER where username=@username", con); validUser.Parameters.AddWithValue("@username", username); int value=Convert.ToInt32(validUser.ExecuteScalar().ToString()); if (value == 1) { //check for password SqlCommand validPassword = new SqlCommand("SELECT password from USER where username=@username", con); validPassword.Parameters.AddWithValue("@username", username); string pass = validPassword.ExecuteScalar().ToString(); if (pass == password) { //valid login return 1; } else { return 0; } } else if (value == 0) { return 2; } }

    Read the article

  • Would you use Code Bubbles?

    - by Paulo Santos
    I've read this question mentioning Code Bubbles and I've watched their video presentation. The video is impressive, and does seem a little bit futuristic, but apparently it's somewhat real. But that kept me thinking... Would a developer really use such tool? We, as developers, are used to deal with code files, organizing them in directories, in one way or another, some common IDE (for those language that has them). It would be a great leap to use something like Code Bubbles, as they propose. I, personally, am not sure if I could work in such environment... although I think I would just need some adjusting... but I really don't see my mind working out the kinks of it. What are your thoughts on this?

    Read the article

  • Succinct code over verbose?

    - by WeNeedAnswers
    With C# becoming more and more declarative and becoming the new Swiss army knife of Programming. Is it better to be succinct thus reducing the actual code base, or long winded but verbose. Is there a performance issue with succinct or does being succinct improve performance because your putting more of your code in the hands of the compiler. (LINQ being an example when used correctly). I know that verbosity should override succinct where code would become less readable, but is this a good idea when your style could affect the performance.

    Read the article

  • php script redirecting code problem

    - by tibin mathew
    hi, i'm using a php script for redirection after detecting the search word to my websiter from the search engines . and my redirection code is working fine but for some keywods i wat to stay in the same page. for that lines of code i'm getting a warning message in that pages. Warning: headers already sent (output started at /home/friendsj/public_html/index.php:2) in /home/friendsj/public_html/index.php on line 20 below is the code i used in that pages $ref=$_SERVER['HTTP_REFERER']; if(strstr($ref,"test")) { $url="http://www.howtomark.com/robgoyette.html"; } elseif(strstr($ref,"mu+word+gmail")) { $url="http://www.howtomark.com/marketbetter.html"; } else { if(strstr($ref,"how+to+market+better")) { } } if($url !="") { header("Location:$url"); }

    Read the article

  • iPhone 4.0 Screen Resolution and writing robust code...

    - by Magic Bullet Dave
    Does anyone know what will happen with existing apps when they run on the iPhone 4.0 in terms of the new screen resolution? I am assuming, just like developing for the iPad that there should be no hard coded screen resolutions in your code. I'd also like advice on the best way of writing robust code to work well on any device. For instance, detecting the screen resolution is not enough - on the iPad the screen is physically bigger so you can display more items on it. On the new iPhone the screen is the same physical size but higher resolution, so the likely thing is that you wont want to display more items, just higher resolution versions of them. Any help would be useful, Regards Dave EDIT: I have read the other similar posts, I guess what I really would like to know is what is the recommended way to write code for all App Store devices in a robust way so they a) all work b) make best use of the device.

    Read the article

  • Comment out a python code block

    - by gbarry
    Is there any mechanism to comment out large blocks of Python code? Right now the only ways I can see of commenting out code are to either start every line with a #, or to enclose the code in """ (triple quotes), except that actually makes it show up in various doc tools. Edit--After reading the answers (and referring to the "duplicate"), I have concluded the correct answer is "No". One person said so, and the rest lectured us about editors. Not a bad thing, but I feel it's important to put the answer at the top.

    Read the article

  • VBA Excel: Issue with Zorder /Help with Debugging Code

    - by AME
    Hi, I have multiple shapes and checkboxes in a spreadsheet. I want to create a function that places a particular shape to front (a higher Z-order than its peers) when its corresponding checkbox is clicked. This is the code that I currently have: Sub CheckBox3_Click() If CheckBox3.Value = True Then Sheet1.Shapes("blueoval").ZOrder msoBringToFront End If End Sub I get Run-time Error '424' whenever I run this code. I am new to VBA for excel, so any help would be greatly appreciated. What's wrong with this code? What's missing? etc.. Thanks!

    Read the article

  • How to convert code to properly release memory

    - by BankStrong
    I've taken over a code base that has subtle flaws - audio player goes mute, unlogged crashes, odd behavior, etc. I found a way to provoke one instance of the problem and tracked it to this code snippet: NSURL *soundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[soundsToPlay objectAtIndex:count] description] ofType:@"mp3"]]; self.audioPlayer = nil; self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundURL error:nil]; self.audioPlayer.delegate = self; AudioSessionSetActive(YES); [audioPlayer play]; When I comment out the 2nd line (nil) and add a release to the end, this problem stops. [self.audioPlayer release]; Where do I go from here? Nils are used in a similar fashion throughout the code (and may cause similar problems) - is there a safe way to remove them? I'm new to memory management - how can I discern proper nil usage from bad nil usage?

    Read the article

< Previous Page | 127 128 129 130 131 132 133 134 135 136 137 138  | Next Page >