Search Results

Search found 5915 results on 237 pages for 'practices'.

Page 95/237 | < Previous Page | 91 92 93 94 95 96 97 98 99 100 101 102  | Next Page >

  • Is it against best practice to throw Exception on most JUnit tests?

    - by Chris Knight
    Almost all of my JUnit tests are written with the following signature: public void testSomething() throws Exception My reasoning is that I can focus on what I'm testing rather than exception handling which JUnit appears to give me for free. But am I missing anything by doing this? Is it against best practice? Would I gain anything by explicitly catching specific exceptions in my test and then fail()'ing on them?

    Read the article

  • How to make a jQuery plugin (the right way)?

    - by macek
    I know there are jQuery cookie plugins out there, but I wanted to write one for the sake of better learning the jQuery plugin pattern. I like the separation of "work" in small, manageable functions, but I feel like I'm passing name, value, and options arguments around too much. Is there a way this can be refactored? I'm looking for snippets of code to help illustrate examples provided with in answers. Any help is appreciated. Thanks :) example usage $.cookie('foo', 'bar', {expires:7}); $.cookie('foo'); //=> bar $.cookie('foo', null); $.cookie('foo'); //=> undefined Edit: I did a little bit of work on this. You can view the revision history to see where this has come from. It still feels like more refactoring can be done to optimize the flow a bit. Any ideas? the plugin (function($){ $.cookie = function(name, value, options) { if (typeof value == 'undefined') { return get(name); } else { options = $.extend({}, $.cookie.defaults, options || {}); return (value != null) ? set(name, value, options) : unset(name, options); } }; $.cookie.defaults = { expires: null, path: '/', domain: null, secure: false }; var set = function(name, value, options){ console.log(options); return document.cookie = options_string(name, value, options); }; var get = function(name){ var cookies = {}; $.map(document.cookie.split(';'), function(pair){ var c = $.trim(pair).split('='); cookies[c[0]] = c[1]; }); return decodeURIComponent(cookies[name]); }; var unset = function(name, options){ value = ''; options.expires = -1; set(name, value, options); }; var options_string = function(name, value, options){ var pairs = [param.name(name, value)]; $.each(options, function(k,v){ pairs.push(param[k](v)); }); return $.map(pairs, function(p){ return p === null ? null : p; }).join(';'); }; var param = { name: function(name, value){ return name + "=" + encodeURIComponent(value); }, expires: function(value){ // no expiry if(value === null){ return null; } // number of days else if(typeof value == "number"){ d = new Date(); d.setTime(d.getTime() + (value * 24 * 60 * 60 * 1000)); } // date object else if(typeof value == "object" && value instanceof "Date") { d = value; } return "expires=" + d.toUTCString(); }, path: function(value){ return "path="+value; }, domain: function(value){ return value === null ? null : "domain=" + value; }, secure: function(bool){ return bool ? "secure" : null; } }; })(jQuery);

    Read the article

  • What is the best way to store site configuration data?

    - by DaveDev
    I have a question about storing site configuration data. We have a platform for web applications. The idea is that different clients can have their data hosted and displayed on their own site which sits on top of this platform. Each site has a configuration which determines which panels relevant to the client appear on which pages. The system was originally designed to keep all the configuration data for each site in a database. When the site is loaded all the configuration data is loaded into a SiteConfiguration object, and the clients panels are generated based on the content of this object. This works, but I find it very difficult to work with to apply change requests or add new sites because there is so much data to sift through and it's difficult maintain a mental model of the site and its configuration. Recently I've been tasked with developing a subset of some of the sites to be generated as PDF documents for printing. I decided to take a different approach to how I would define the configuration in that instead of storing configuration data in the database, I wrote XML files to contain the data. I find it much easier to work with because instead of reading meaningless rows of data which are related to other meaningless rows of data, I have meaningful documents with semantic, readable information with the relationships defined by visually understandable element nesting. So now with these 2 approaches to storing site configuration data, I'd like to get the opinions of people more experienced in dealing with this issue on dealing with these two approaches. What is the best way of storing site configuration data? Is there a better way than the two ways I outlined here? note: StackOverflow is telling me the question appears to be subjective and is likely to be closed. I'm not trying to be subjective. I'd like to know how best to approach this issue next time and if people with industry experience on this could provide some input.

    Read the article

  • [Design Question] When to open a link on a new window?

    - by Ian
    Hi All, When designing a web application/web site, is there an accepted practice on when to open a link on a new window? Currently, if the site being linked to is outside the domain (say Google.com), I am always launching it on a new window. If the page being linked is within the same domain, I open it on the current active window. I've read somewhere the opening links on a new window explicitly is being frowned upon. Thanks!

    Read the article

  • How do I put an ASP.NET website project and class library projects in one .sln file on Subversion

    - by JustinP8
    My company has several class libraries we use in multiple website projects (not web application projects). Website projects don't have .sln files, but I'm sure I've read in my past research that you can make a blank solution and put your website and class library projects in it. After answers to my previous questions, this is the direction that I'm going (based slightly on [http://amadiere.com/blog/2009/06/multiple-subversion-projects-in-one-visual-studio-solution-using-svnexternals/][1]: /websites /website1 /trunk /website1 /libraries /library1 /trunk /library1 /library2 /trunk /library2 /etc... Then I planed on using svn:externals to copy /library1, /library2, and so on into the working_copy/websites/website1/ folder. I want my team members to be able to checkout the /trunk folder for website1 and get a .sln file, /library1 external, /library2 external, etc. I want that .sln file to contain the website1 website project, and all of the library external projects. Hopefully that would look something like: /working_copy /websites /website1 /trunk /website1 /library1 (svn:external of libraries/library1/trunk/library1) /library2 (svn:external of libraries/library2/trunk/library2) /etc. website1.sln So, at the end of all of this, the goal is that my teammates check out the trunk, open the solution, and everyone has the exact same solution. When we commit, everything is committed appropriately to subversion (the website code, and the libraries are committed to their appropriate place on the repo). How have others solved these issues? How can I make a .sln file that my team members and I can share in this manner? [1]: "This Article"

    Read the article

  • Use database field maxlength as html layout input maxlength best practice. asp.net mvc

    - by Andrew Florko
    Hello everybody, There are string length limitations in database structure (email is declared as nvarchar[30] for instance) There are lots of html forms that has input textbox fields that should be limited in length for that reason. What is the best practice to synchronize database fields and html layout input fields length limitations ? Can it be done automatically (html layout input fields declared the same max length as database data they represent)? Thank you in advance.

    Read the article

  • JavaScript-library-based Project Organization

    - by Laith J
    Hello, I'm very new to the JavaScript library world. I have used JS by itself before to create a mini social network but this is the first time I use a JS library and I really don't know how to go about this. I'm planning to use Google Closure and I'm really not sure how I should go about organizing the code. Should I put everything in one file since it's a web app and should have one screen? Should I separate the code to many chunks and put them in different files? Or should I put different dialogs (like settings) in a separate page and thus a separate file? Like all programmers I'm a perfectionist so please help me out with this one, thanks.

    Read the article

  • Send through Email, or store in database?

    - by user156814
    I have wondered when it is best to send an email, and when its best to store data in a database/log file. Everytime a user wants to contact me or inform me of soething, I suppose an email is best.. but is an email always preferred over other ways, and in what cases. Possible reasons for being contacted I can think of are questions, suggestions, feedback, reporting abuse, advertising, etc... I assume email, "why add unnecessary things to the DB?", but I figure data in DB would be a lot easier to manage. Whats the better/best way to be informed of things like this.. What is the best way for you (webmaster) to be informed of something by users? through email, or some other way

    Read the article

  • Singular method name for single object argument, plural for a list?

    - by nasufara
    I'm having a problem with naming a method for a database application. In my Database instance, I have a method that can remove an Agreement object from the database. However, I want to be able to remove multiple Agreements at once, to be able to use transactions. The problem is that I also have an overload to remove a single Agreement object. Essentially, my structure is like this: public class Database { // ... public void RemoveAgreement(Agreement a) { // ... } public void RemoveAgreement(IEnumerable<Agreement> agreements) { // ... } } But this can be confusing, as the overload with the list of Agreements has a singular name, despite being inherently plural. My question is, how should I structure this? Should I have two overloads with the name RemoveAgreement(), or RemoveAgreements()? Or should I use two separate methods, instead of overloads? Thanks.

    Read the article

  • syntax for binding multiple variables within text

    - by danke
    When binding multiple variables value1 value2 value3 in the same text field, do I do this: text="{some text value1 other text value2 and other text value3}" or text="some text {value1} other text {value2} and other text {value3}" I noticed both work, but which is the right way to do it and will work all the time.

    Read the article

  • Is it bad to explicitly compare against boolean constants e.g. if (b == false) in Java?

    - by polygenelubricants
    Is it bad to write: if (b == false) //... while (b != true) //... Is it always better to instead write: if (!b) //... while (!b) //... Presumably there is no difference in performance (or is there?), but how do you weigh the explicitness, the conciseness, the clarity, the readability, etc between the two? Note: the variable name b is just used as an example, ala foo and bar.

    Read the article

  • What are the advantages to use StringBuilder versus XmlDocument or related to create XML documetns?

    - by Rob
    This might be a bit of a code smell, but I have seen it is some production code, namely the use of StringBuilder as opposed to XmlDocument when creating XML documents. In some cases these are write once operations (e.g. create the document and save it to disk) where as others are passing the built string to an XmlDocument to preform an XslTransform to a document that is returned to the client. So obvious question: is there merit to doing things this way, is it something that should be done on a case-by-case basis, or is this the wrong way of doing things?

    Read the article

  • What lessons can you learn from software maintanence?

    - by Vasil Remeniuk
    Hello everyone, In the perfect world, all the software developers would work with the cutting edge technologies, creating systems from the scratch. In the real life, almost all of us have to maintain software from time to time (unlucky ones do it on a regular basis). Personally I first 2 years of my career was fixing bugs in the company that no longer exists (it has been taken up by Oracle). And probably the biggest lesson I've learned that time - despite of the pressure, always try to get as much information about the domain as possible (even if it's irrelevant to fixing a specific bug or adding a feature) - abstract domain knowledge doesn't lose value as fast as knowledge about trendy frameworks or methodologies. What lessons have you learned from maintenance?

    Read the article

  • "Special case" records for foreign key constraints

    - by keithjgrant
    Let's say I have a mysql table, called foo with a foreign key option_id constrained to the option table. When I create a foo record, the user may or may not have selected an option, and 'no option' is a viable selection. What is the best way to differentiate between 'null' (i.e. the user hasn't made a selection yet) and 'no option' (i.e. the user selected 'no option')? Right now, my plan is to insert a special record into the option table. Let's say that winds up with an id of 227 (this table already has a number of records at this point, so '1' isn't available). I have no need to access this record at a database level, and it would act as nothing more than a placeholder that the foreign key in the foo table can reference. So do I just hard-code '227' in my codebase when I'm creating 'foo' records where the user has selected 'no option'? The hard-coded id seems sloppy, and leaves room for error as the code is maintained down the road, but I'm not really sure of another approach.

    Read the article

  • A good approach to db planing for reporting service

    - by Itay Moav
    The scenario: Big system (~200 tables). 60,000 users. Complex reports that will require me to do multiple queries for each report and even those will be complex queries with inner queries all over the place + some processing in PHP. I have seen an approach, which I am not sure about: Having one centralized, de-normalized, table that registers any activity in the system which is reportable. This table will hold mostly foreign keys, so she should be fairly compact and fast. So, for example (My system is a virtual learning management system), A user enrolls to course, the table stores the user id, date, course id, organization id, activity type (enrollment). Of course I also store this data in a normalized DB, which the actual application uses. Pros I see: easy, maintainable queries and code to process data and fast retrieval. Cons: there is a danger of the de-normalized table to be out of sync with the real DB. Is this approach worth considering, or (preferably from experience) is total $#%#%t?

    Read the article

  • Communication between layers in an application

    - by Petar Minchev
    Hi guys! Let's assume we have the following method in the business layer. What's the best practice to tell the UI layer that something went wrong and give also the error message? Should the method return an empty String when it was OK, otherwise the error message, or should it throw another exception in the catch code wrapping the caught exception? If we choose the second variant then the UI should have another try,catch which is too much try,catch maybe. Here is a pseudocode for the first variant. public String updateSomething() { try { //Begin transaction here dataLayer.do1(); dataLayer.do2(); dataLayer.doN(); } catch(Exception exc) { //Rollback transaction code here return exc.message; } return ""; } Is this a good practice or should I throw another exception in the catch(then the method will be void)?

    Read the article

  • Why is debugging better in an IDE?

    - by Bill Karwin
    I've been a software developer for over twenty years, programming in C, Perl, SQL, Java, PHP, JavaScript, and recently Python. I've never had a problem I could not debug using some careful thought, and well-placed debugging print statements. I respect that many people say that my techniques are primitive, and using a real debugger in an IDE is much better. Yet from my observation, IDE users don't appear to debug faster or more successfully than I can, using my stone knives and bear skins. I'm sincerely open to learning the right tools, I've just never been shown a compelling advantage to using visual debuggers. Moreover, I have never read a tutorial or book that showed how to debug effectively using an IDE, beyond the basics of how to set breakpoints and display the contents of variables. What am I missing? What makes IDE debugging tools so much more effective than thoughtful use of diagnostic print statements? Can you suggest resources (tutorials, books, screencasts) that show the finer techniques of IDE debugging? Sweet answers! Thanks much to everyone for taking the time. Very illuminating. I voted up many, and voted none down. Some notable points: Debuggers can help me do ad hoc inspection or alteration of variables, code, or any other aspect of the runtime environment, whereas manual debugging requires me to stop, edit, and re-execute the application (possibly requiring recompilation). Debuggers can attach to a running process or use a crash dump, whereas with manual debugging, "steps to reproduce" a defect are necessary. Debuggers can display complex data structures, multi-threaded environments, or full runtime stacks easily and in a more readable manner. Debuggers offer many ways to reduce the time and repetitive work to do almost any debugging tasks. Visual debuggers and console debuggers are both useful, and have many features in common. A visual debugger integrated into an IDE also gives you convenient access to smart editing and all the other features of the IDE, in a single integrated development environment (hence the name).

    Read the article

  • Create swipe controlled simple flipbook style animation in ObjC

    - by eco_bach
    Hi I am a beginner in Obj C development, though quite experienced (over 10 years) with other ECMAscript based languages and OOP development. I want to build a simple flipbook style animation, controlled through swiping motion. I'm sure extremely simple for any advanced ObjC coders. Can anyone with extensive ObjC-CocoaTouch experience give me some higher level recommendations? ie, 1 -general application design, should I start with a simple view based application, or navigation based or? 2 -should I use 3rd party animation frameworks such as Cocos2D, or stick with built in classes and methods? 3 -if using built in methods, classes, what is the recommended way of achieving a animation, that will be controlled via swipe and touch gestures? 4 -I want to eventually have multiple 'flipbooks' that I can 'instantly' swap with one another, ie to give the net effect of an object changing color, etc, but not sure how to approach this from a memory management point of view, related to #1 above Except for point 3 above, I'm not expecting any actual code examples. Just general guidelines to follow and perhaps, what are some next steps I should take in my goal as an ObjC code samurai.

    Read the article

  • Custom User Management for Google App Engine Java

    - by Gopi
    I am using GAE Java for a multi-user application. There are multiple users with different roles. Each user can login, do some operations and logout. The business restricts me from using Google User Service and I need to implement my own for authentication and session management. Can anyone please share with me how should I go about implementing my own user management? I have read its very tricky to implement own user management. Any pointers in terms of best approaches/ design / existing frameworks if any ? I could see some similar posts but they are for python.

    Read the article

  • File descriptor limits and default stack sizes

    - by Charles
    Where I work we build and distribute a library and a couple complex programs built on that library. All code is written in C and is available on most 'standard' systems like Windows, Linux, Aix, Solaris, Darwin. I started in the QA department and while running tests recently I have been reminded several times that I need to remember to set the file descriptor limits and default stack sizes higher or bad things will happen. This is particularly the case with Solaris and now Darwin. Now this is very strange to me because I am a believer in 0 required environment fiddling to make a product work. So I am wondering if there are times where this sort of requirement is a necessary evil, or if we are doing something wrong. Edit: Great comments that describe the problem and a little background. However I do not believe I worded the question well enough. Currently, we require customers, and hence, us the testers, to set these limits before running our code. We do not do this programatically. And this is not a situation where they MIGHT run out, under normal load our programs WILL run out and seg fault. So rewording the question, is requiring the customer to change these ulimit values to run our software to be expected on some platforms, ie, Solaris, Aix, or are we as a company making it to difficult for these users to get going? Bounty: I added a bounty to hopefully get a little more information on what other companies are doing to manage these limits. Can you set these pragmatically? Should we? Should our programs even be hitting these limits or could this be a sign that things might be a bit messy under the covers? That is really what I want to know, as a perfectionist a seemingly dirty program really bugs me.

    Read the article

  • How to best launch C++ application from web page

    - by JB
    I guess there are two parts to this question, one technical and one best practice for security and doing things "right". I'm working on a little game using C++ / directx but I would like to be able to launch it from a web page by someone clicking on a link on that page. Ideally I would like the first time they clicked for it to launch an installer downloads and installs the game on their machine, and then the next time to launch an application which updates the game from a web site if it's old and then launches it. I have no problems with the expected security popups and questions the first time it runs. I want people to be certain what they are installing and understand what they are doing. But it would be nice if once it is installed they could run it with the minimum of fuss. My question then is what technologies I could use to do this? I'm thinking that it would need a browser plugin and an activex control so that first time you'd install that, and subsequently the control/plugin would be able to launch the game. I'm not sure that under newer browser secuity models that a plugin would have the permissions to be able to run an installer though or silently invoke applications on the client machine even if they are already installed. Is there a more sensible way to achive what I want to achieve? And I'm worried about the security aspects too. I want this to be convenient for users but I of course want to do it "right". I know this can be done as I've seen several mmorpg type games that launch in this way from the browser now but it's not entirely clear to me how they've done it.

    Read the article

  • How do you PEP 8-name a class whose name is an acronym?

    - by Arrieta
    I try to adhere to the style guide for Python code (also known as PEP 8). Accordingly, the preferred way to name a class is using CamelCase: Almost without exception, class names use the CapWords convention. Classes for internal use have a leading underscore in addition. How can I be consistent with PEP 8 if my class name is formed by two acronyms (which in proper English should be capitalized). For instance, if my class name was 'NASA JPL', what would you name it?: class NASAJPL(): # 1 class NASA_JPL(): # 2 class NasaJpl(): # 3 I am using #1, but it looks weird; #3 looks weird too, and #2 seems to violate PEP 8. Thoughts?

    Read the article

< Previous Page | 91 92 93 94 95 96 97 98 99 100 101 102  | Next Page >