Search Results

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

Page 160/3662 | < Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >

  • Help in debugging the string concatenation code

    - by mithun1538
    I have a code to concatenate strings. However, for some reason, the final string is not a combination of the required strings. Consider the following code : //cusEmail is of type String[] String toList = ""; for(i=0; i < cusEmail.length - 1; i++) { toList.concat(cusEmail[i]); toList.concat("; "); System.out.println(cusEmail[i]); } toList.concat(cusEmail[i]); System.out.println(toList); The first sout statement displays the strings in cusEmail[i] correctly. However, once concatenated, the second sout displays a blank / empty. Any reason for this? Am i concatenating it correctly?

    Read the article

  • Placement of a call to the parent method

    - by Alejandro
    I have a class that has a method. That class has a child class that overrides that method. The child's method has to call the parent's method. In all OO that I've seen or written calls to the parent's version of the same method were on the first line of the method. On a project that I am working on circumstances call for placing that method call at the end of a method. Should I be worried? Is that a code smell? Is this code inherently bad? class Parent { function work() { // stuff } } class Child { function work() { // do thing 1 // do thing 2 parent::work(); // is this a bad practice? // should I call the parent's work() method before // I do anything in this method? } }

    Read the article

  • Factor Clojure code setting many different fields in a Java object

    - by chris
    How do I factor code setting many different fields in a Java object? I would like to factor (set! (. employee name) "Chris") (set! (. employee age) 100) (set! (. employee salary) 5000) to (doseq [field '((name "Chris") (age 100) (salary 5000))] (set! (. employee (first field)) (second field))) However this won't work because the period is a macro, and tries to evaluate (first field) literally. By the way, I understand that setting fields is not good practice. I need to inter-operate with legacy code.

    Read the article

  • Use of LOC to determine project size

    - by acidzombie24
    How many lines of code (LOC) does it take to be considered a large project? How about for just one person writing it? I know this metric is questionable, but there is a significant difference, for a single developer, between 1k and 10k LOC. I typically use space for readability, especially for SQL statements, and I try to reduce the amount of LOC for maintenance purpose to follow as many best practice as i can. For example, I created a unified diff of the code I modified today, and it was over 1k LOC (including comments and blank lines). Is "modified LOC" a better metric? I have ~2k LOC, so it's surprising I modified 1k. I guess rewriting counts as both a deletion and addition which doubles the stats.

    Read the article

  • Feasability of reverse engineering some embedded code

    - by user258526
    All, My company is in the situation where we are using an embedded control system from another company in another country. We do not have the source code or the schematics to this system, and the manufacturer doesn't want to release them, seemingly at any price or under any terms. We are thus stuck with a 6 month turn around to get even a small modification done, and they can basically charge any amount they want. Legal aspects aside, would it be at all feasible to reverse engineer the embedded code back into C? Do any companies exist that could do this for us? Thank you, Fred

    Read the article

  • MicroChip Sample Code setting Current to a CMPDAC, DAC threshold which expect an voltage

    - by jason hong
    Sorry, the MicroChip Forum is very slow,I prefer to use overflow site to ask questions. dsPIC33FJ06GS101/X02 and dsPIC33FJ16GSX02/X04 device Sample Code // configure comparator2 CMPCON2bits.CMPON = 1; // enable comparator CMPCON2bits.INSEL = 1; // select CMP2B input pin (RB0) CMPCON2bits.RANGE = 1; // select high range, max DAC value = Avdd/2 //CMPDACx: COMPARATOR DAC CONTROL REGISTER //CMREF<9:0>: Comparator Reference Voltage Select bits CMPDAC2 = CURR_HWLIM; // DAC threshold #define CURR_HWLIM 1023 // 1023 // 10.15 * 101A MicroChip Sample code setting CURR_HWLIM which 1023A to COMPDAC2 which expects voltage I think that's mistake.

    Read the article

  • Visual Studio confused by server code inside javascript

    - by Felix
    I ran into an annoying problem: the following code gives a warning in Visual Studio. <script type="text/javascript"> var x = <%: ViewData["param"] %>; </script> The warning is "Expected expression". Visual Studion gets confused, and all the javascript code after that is giving tons of warnings. Granted, it's all warnings, and it works perfectly fine in runtime - but it is very easy to miss real warnings among dozen of false positives. It was working the same way in VS2008, and it wasn't fixed in VS2010. Does anybody know if there is a workaround, or a patch?

    Read the article

  • Resuming execution of code after exception is thrown and caught

    - by dotnetdev
    Hi, How is it possible to resume code execution after an exception is thrown? For exampel, take the following code: namespace ConsoleApplication1 { class Test { public void s() { throw new NotSupportedException(); string @class = "" ; Console.WriteLine(@class); Console.ReadLine(); } } class Program { static void Main(string[] args) { try { new Test().s(); } catch (ArgumentException x) { } catch (Exception ex) { } } } } After catching the exception when stepping through, the program will stop running. How can I still carry on execution? Thanks

    Read the article

  • Explain a block of crazy JS code inside Sizzle(the CSS selector engine)

    - by Andy Li
    So, here is the function for pre-filtering "CHILD": function(match){ if ( match[1] === "nth" ) { // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); // calculate the numbers (first)n+(last) including if they are negative match[2] = (test[1] + (test[2] || 1)) - 0; match[3] = test[3] - 0; } // TODO: Move to normal caching system match[0] = done++; return match; } The code is extracted from line 442-458 of sizzle.js. So, why is the line var test = ..., have the exec inputing a boolean? Or is that really a string? Can someone explain it by splitting it into a few more lines of code?

    Read the article

  • NSImage different size in code different shown by Finder/Preview

    - by krasnyk
    I have a couple of images that i use in my application(one of them is attached). The strange thing is that the real image size(shown by finder and preview) is 1200x701 px. When I access image from the code and as for its size, I get 360x210px. What is going on? Code I'm using to get the size of the image: NSImage *newImg = [[NSImage alloc] initWithContentsOfURL: [NSURL URLFromPasteboard:[sender draggingPasteboard]]]; float h = [newImg size].height; //height is 210px - should be 701px float w = [newImg size].width; //width is 320px - should be 1200px The content of the newImg is the same image that has been pointed and loaded - I display it in the NSImageView anyway so I see. Just the size taken with -size is wrong. This is the image:

    Read the article

  • Python 2.6 and 3.1.1, earlier version compatibility

    - by Todd
    I ordered three books to start teaching myself Python - a beginning programming book, a computer science book that uses Python for all of its code references, and a book on Python network programming. Unfortunately, I was a little too quick on ordering them, because I hadn't noticed the version differences. The beginner book is for python 3.1, the CS book is Python 2.3, and the last is Python 2.6. The CS book is also oriented towards beginners. My question is, will the different versions be too different at this level for me to effectively use all three, or will I likely be able to get by learning from the 3.1 beginners book and then sort of teach myself from the 2.3 CS book, and be able to comprehend 2.6 code? That probably didn't make sense. I hope it did.

    Read the article

  • How to write a Compiler in C for C

    - by Kerb_z
    I want to write a Compiler for C. This is a Project for my College i am doing as per my University. I am an intermediate programmer in C, with understanding of Data Structures. Now i know a Compiler has the following parts: 1. Lexer 2. Parser 3. Intermediate Code Generator 4. Optimizer 5. Code Generator I want to begin with the Lexer part and move on to Parser. I am consulting the following book: Compilers: Principles, Techniques, and Tools by Alfred V. Aho, Ravi Sethi, Jeffrey D. Ullman. The thing is that this book is highly theoretical and perplexing to me. I really appreciate the authors. But the point is i am not able to begin my project, as if i am blinded where to go. Need guidance please help.

    Read the article

  • require_owner code to limit controller actions not recognizing current user as owner

    - by bgadoci
    I am trying to restrict access to certain actions using a before_filter which seems easy enough. Somehow the ApplicationController is not recognizing that the current_user is the owner of the user edit action. When I take the filter off the controller correctly routes the current_user to their edit view information. Here is the code. Link to call edit action from user controller (views/questions/index.html.erb): <%= link_to "Edit Profile", edit_user_path(:current) %> ApplicationController (I am only posting the code that I think is affecting this but can post the whole thing if needed). class ApplicationController < ActionController::Base def require_owner obj = instance_variable_get("@#{controller_name.singularize.camelize.underscore}") # LineItem becomes @line_item return true if current_user_is_owner?(obj) render_error_message("You must be the #{controller_name.singularize.camelize} owner to access this page", root_url) return false end end and the before_filter class UsersController < ApplicationController before_filter :require_owner, :only => [:edit, :update, :destroy] #... end I simply get the rendering of the error message from the ApplicationController#require_owner action.

    Read the article

  • Godaddy's Code sign certificate and MIDlet

    - by abc
    i have developed an application in java (J2ME), and i want trusted domain for that application using goDaddy's certificate. can i obtain it ? let me re describe the full scenario. i have developed an application.in which i want FILE IO operations to be done without the permission of user (for every read write, it means user will be asked only once.) so to obtain that i want trusted domain for my application. for that i need to sign my application using code sign certificate. now go Daddy's certificate is not listed under Nokia 3110Classic, so i have externally added it in CA list. but still its showing app signing option disabled. so my question is can i obtain trusted domain using the goDaddy's code sign certificate ?

    Read the article

  • Text code decoding

    - by Diana Villafane
    Hello. I am an English/Spanish Spanish/English translator. I have been given a job where I have to translate Spanish text messages sent from cell phones. Some of them are in code. I assume each set of figures represents a letter. Is there any website where I can find information on how to decipher the code? For instance, the first message says: ‘0x69 ox61 0x6e 0x70 0x72 0x2e 0x6e 0x65 0x74 0x2f 0x3f 0x64 0x34 0x39 0x31 0x66 0x30 0x37 0x38 0x35 0x35 0x32 0x39 0x62 0x36 0x31 0x31 0x00 Thank you for any help you provide. Diana

    Read the article

  • Calling unmanaged c++ code in C# Mixed with STL

    - by Turtle
    Hey, I want to call unmanaged c++ code in C# The function interface is like following(I simplified it to make it easy to understand) Face genMesh(int param1, int param2); Face is a struct defined as: struct Face{ vector<float> nodes; vector<int> indexs; } I googled and read the MSDN docs found ways to call simple c/c++ unmanged code in C#, also know how to hand the struct as return value. And My question is how to handle "vector". I did not find rules about mapping between vector and some types in C# Thanks!

    Read the article

  • Code in Global.asax prevents webpage from loading

    - by pete the pagan-gerbil
    I've made a static class to hold a number of configuration values (and also swap these values out in unit tests). If I initialise it in the Global.asax, the code runs correctly but the page doesn't load at all, and trying to navigate to a specific page fails. I can't initialise the values in a constructor or inline on the field declarations, because I need to be able to swap the values out in unit tests before the web.config is interrogated. Basically, putting the one line "ConfigClass.SetValues()" in the Global.asax prevents the app from loading correctly (although, as I say, it runs the code fine) and removing it again makes the app load properly - but without the class values initialised. As an aside, I'm sure I had this working correctly and being initialised in the Global.asax yesterday. I'm positive I didn't take any action to change or break it... Does anyone have advice on how I might track down what's going on here? Was I mistaken that it worked before (always possible) and that I need to go back and redesign something?

    Read the article

  • how to speed up the code??

    - by kaushik
    in my program i have a method which requires about 4 files to be open each time it is called,as i require to take some data.all this data from the file i have been storing in list for manupalation. I approximatily need to call this method about 10,000 times.which is making my program very slow? any method for handling this files in a better ways and is storing the whole data in list time consuming what is better alternatives for list? I can give some code,but my previous question was closed as that only confused everyone as it is a part of big program and need to be explained completely to understand,so i am not giving any code,please suggest ways thinking this as a general question... thanks in advance

    Read the article

  • Passing an array for setting variable

    - by mathk
    Hi, I often see this idiom when reading php code: public function __construct($config) { if (array_key_exists('options', $config)) { ... } if (array_key_exists('driver_options', $config)) { ... } } Here I am concern with the way the parameter is used. If I were in lisp I would do: (defun ct (&key options driver_options) (do-something-with-option-and-driver_option)) But since I am in PHP I would rather have a constructor that take a list of parameter and let them be null if there a not require. So what do you guys think about having an array as parameter in other to do some initialization-or-whatever? In other to answer you have to take in account the point of view of the user of the function and the designer of the API. Also have you ever heard this has a code-smell? thanks

    Read the article

  • proper Django ORM syntax to make this code work in MySQL

    - by gtujan
    I have the following django code working on an sqlite database but for some unknown reason I get a syntax error if I change the backend to MySQL...does django's ORM treat filtering differently in MySQL? def wsjson(request,imei): wstations = WS.objects.annotate(latest_wslog_date=Max('wslog__date'),latest_wslog_time=Max('wslog__time')) logs = WSLog.objects.filter(date__in=[b.latest_wslog_date for b in wstations],time__in=[b.latest_wslog_time for b in wstations],imei__exact=imei) data = serializers.serialize('json',logs) return HttpResponse(data,'application/javascript') The code basically gets the latest logs from WSlog corresponding to each record in WS and serializes it to json. Models are defined as: class WS(models.Model): name = models.CharField(max_length=20) imei = models.CharField(max_length=15) description = models.TextField() def __unicode__(self): return self.name class WSLog(models.Model): imei = models.CharField(max_length=15) date = models.DateField() time = models.TimeField() data1 = models.DecimalField(max_digits=8,decimal_places=3) data2 = models.DecimalField(max_digits=8,decimal_places=3) WS = models.ForeignKey(WS) def __unicode__(self): return self.imei

    Read the article

  • How to Run NUnit Tests from C# Code

    - by Dror Helper
    I'm trying to write a simple method that receives a file and runs it using NUnit. The code I managed to build using NUnit's source does not work: if(openFileDialog1.ShowDialog() != DialogResult.OK) { return; } var builder = new TestSuiteBuilder(); var testPackage = new TestPackage(openFileDialog1.FileName); var directoryName = Path.GetDirectoryName(openFileDialog1.FileName); testPackage.BasePath = directoryName; var suite = builder.Build(testPackage); TestResult result = suite.Run(new NullListener(), TestFilter.Empty); The problem is that I keep getting an exception thrown by builder.Build stating that the assembly was not found. What am I missing? Is there some other way to run the test from the code (without using Process.Start)?

    Read the article

< Previous Page | 156 157 158 159 160 161 162 163 164 165 166 167  | Next Page >