Search Results

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

Page 89/237 | < Previous Page | 85 86 87 88 89 90 91 92 93 94 95 96  | Next Page >

  • Avoid loading unnecessary data from db into objects (web pages)

    - by GmGr
    Really newbie question coming up. Is there a standard (or good) way to deal with not needing all of the information that a database table contains loaded into every associated object. I'm thinking in the context of web pages where you're only going to use the objects to build a single page rather than an application with longer lived objects. For example, lets say you have an Article table containing id, title, author, date, summary and fullContents fields. You don't need the fullContents to be loaded into the associated objects if you're just showing a page containing a list of articles with their summaries. On the other hand if you're displaying a specific article you might want every field loaded for that one article and maybe just the titles for the other articles (e.g. for display in a recent articles sidebar). Some techniques I can think of: Don't worry about it, just load everything from the database every time. Have several different, possibly inherited, classes for each table and create the appropriate one for the situation (e.g. SummaryArticle, FullArticle). Use one class but set unused properties to null at creation if that field is not needed and be careful. Give the objects access to the database so they can load some fields on demand. Something else? All of the above seem to have fairly major disadvantages. I'm fairly new to programming, very new to OOP and totally new to databases so I might be completely missing the obvious answer here. :)

    Read the article

  • Why is "copy and paste" of code dangerous?

    - by Yigang Wu
    Sometimes, my boss will complain us why we need so long time to implement a feature. Actually, the feature has been implemented in other AP before, you just need to copy and paste codes from there. The cost should be low. It's really a hard question, because copy and paste codes is not a easy thing from my point. Do you have any good reason to explain your boss who doesn't know technology?

    Read the article

  • User upload file above web root with php

    - by Chris
    I have a website where local bands can have a profile page, I'm implementing an upload system so that they can add songs to their profile. I want to make sure that clever visitors to my website cannot download their songs. I was thinking about uploading them to above the folder for my domain so that they cannot be accessed directly. Is this a good idea and/or possible? If not, what do you suggest I do to try and avoid users downloading songs. I'm already using a flash player to try and prevent downloads.

    Read the article

  • Using table-of-contents in code?

    - by AareP
    Do you use table-of-contents for listing all the functions (and maybe variables) of a class in the beginning of big source code file? I know that alternative to that kind of listing would be to split up big files into smaller classes/files, so that their class declaration would be self-explanatory enough.. but some complex tasks require a lot of code. I'm not sure is it really worth it spending your time subdividing implementation into multiple of files? Or is it ok to create an index-listing additionally to the class/interface declaration?

    Read the article

  • Checking for nil in view in Ruby on Rails

    - by seaneshbaugh
    I've been working with Rails for a while now and one thing I find myself constantly doing is checking to see if some attribute or object is nil in my view code before I display it. I'm starting to wonder if this is always the best idea. My rationale so far has been that since my application(s) rely on user input unexpected things can occur. If I've learned one thing from programming in general it's that users inputting things the programmer didn't think of is one of the biggest sources of run-time errors. By checking for nil values I'm hoping to sidestep that and have my views gracefully handle the problem. The thing is though I typically for various reasons have similar nil or invalid value checks in either my model or controller code. I wouldn't call it code duplication in the strictest sense, but it just doesn't seem very DRY. If I've already checked for nil objects in my controller is it okay if my view just assumes the object truly isn't nil? For attributes that can be nil that are displayed it makes sense to me to check every time, but for the objects themselves I'm not sure what is the best practice. Here's a simplified, but typical example of what I'm talking about: controller code def show @item = Item.find_by_id(params[:id]) @folders = Folder.find(:all, :order => 'display_order') if @item == nil or @item.folder == nil redirect_to(root_url) and return end end view code <% if @item != nil %> display the item's attributes here <% if @item.folder != nil %> <%= link_to @item.folder.name, folder_path(@item.folder) %> <% end %> <% else %> Oops! Looks like something went horribly wrong! <% end %> Is this a good idea or is it just silly?

    Read the article

  • Do the UI first with SketchFlow - Do I concern about the UI look?

    - by stacker
    There is no questions: UI-First Software Development. But what does it takes to do the UI first? I started to build a website, a complicated one, and know I start to concern about the UI. Instead to start coding html+css, I decided to start with SkecthFlow. now, I'm very confused. Do I want to build a exact sketch? meaning to think about colors, fonts make sure that the button will look like a web link... etc, or just build the application sketch flow? meaning put a textboxes and buttons. Do I need to implement every thing in SketchFlow first? I'm looking for best practice.

    Read the article

  • c++ dynamic_cast error handling

    - by Nazgob
    Is there any good practice related to dynamic_cast error handling (except not using it when you don't have to)? I'm wondering how should I go about NULL and bad_cast it can throw. Should I check for both? And if I catch bad_cast or detect NULL I probably can't recover anyway... For now, I'm using assert to check if dynamic_cast returned not NULL value. Would you accept this solution on a code review?

    Read the article

  • Should java try blocks be scoped as tightly as possible?

    - by isme
    I've been told that there is some overhead in using the Java try-catch mechanism. So, while it is necessary to put methods that throw checked exception within a try block to handle the possible exception, it is good practice performance-wise to limit the size of the try block to contain only those operations that could throw exceptions. I'm not so sure that this is a sensible conclusion. Consider the two implementations below of a function that processes a specified text file. Even if it is true that the first one incurs some unnecessary overhead, I find it much easier to follow. It is less clear where exactly the exceptions come from just from looking at statements, but the comments clearly show which statements are responsible. The second one is much longer and complicated than the first. In particular, the nice line-reading idiom of the first has to be mangled to fit the readLine call into a try block. What is the best practice for handling exceptions in a funcion where multiple exceptions could be thrown in its definition? This one contains all the processing code within the try block: void processFile(File f) { try { // construction of FileReader can throw FileNotFoundException BufferedReader in = new BufferedReader(new FileReader(f)); // call of readLine can throw IOException String line; while ((line = in.readLine()) != null) { process(line); } } catch (FileNotFoundException ex) { handle(ex); } catch (IOException ex) { handle(ex); } } This one contains only the methods that throw exceptions within try blocks: void processFile(File f) { FileReader reader; try { reader = new FileReader(f); } catch (FileNotFoundException ex) { handle(ex); return; } BufferedReader in = new BufferedReader(reader); String line; while (true) { try { line = in.readLine(); } catch (IOException ex) { handle(ex); break; } if (line == null) { break; } process(line); } }

    Read the article

  • SOAP - Why do I need to query for the values for an update?

    - by Phill Pafford
    I'm taking over a project and wanted to understand if this is common practice using SOAP. The process that is currently in place I have to query all the values before I do an update cause I need to pass back all the values that are not being updated. Does this sound right? Example Values: fname=phill lname=pafford address=123 main phone:222-555-1212 So if I just wanted to update the phone number I need to query for the record, get all the values and submit these values for an update. Example Update Values: fname=phill lname=pafford address=123 main phone:111-555-1212 I just want to know if this is common practice or should I change the functionality of this?

    Read the article

  • How to properly document programming languages?

    - by roydukkey
    Where can I find information on how to properly document a programming language? What I mean is that there seems to be a standard way to document code. php.net and api.jquery.com seem to document there code the a similar way. For example, the trim() description on php.net. string trim ( string $str [, string $charlist ] ) And likewise on jquery.com .animate( properties, [ duration ], [ easing ], [ callback ] ) Does anyone even know what this syntax is called?

    Read the article

  • What should the Java main method be for a standalone application (for Spring JMS) ?

    - by Brandon
    I am interested in creating a Spring standalone application that will run and wait to receive messages from an ActiveMQ queue using Spring JMS. I have searched a lot of places and cannot find a consistent way of implementing the main method for such a standalone application. There appears to be few examples of Spring standalone applications. I have looked at Tomcat, JBoss, ActiveMQ and other examples from the around the web but I have not come to a conclusion so ... What is the best practice for implementing a main method for a Java application (specifically Spring with JMS) ?

    Read the article

  • Exposing APIs - third party or homegrown?

    - by amelvin
    Parts of the project I'm currently working on (I can't give details) will be exposed as an API at some point over the next few months and I was wondering whether anyone could recommend a third party API 'provider' (possibly Mashery or SO advertiser Webservius). And I mean recommend in the 'I've used these people and they are good' sense because although I can google for an answer to this question it is more difficult to get truly unbiased opinions. As an addendum is there much mileage in creating a bespoke API solution and has anyone had any joy going down that road? Thanks in anticipation.

    Read the article

  • Reverse search in Hibernate Search

    - by Javi
    Hello, I'm using Hibernate Search (which uses Lucene) for searching some Data I have indexed in a directory. It works fine but I need to do a reverse search. By reverse search I mean that I have a list of queries stored in my database I need to check which one of these queries match with a Data object each time Data Object is created. I need it to alert the user when a Data Object matches with a Query he has created. So I need to index this single Data Object which has just been created and see which queries of my list has this object as a result. I've seen Lucene MemoryIndex Class to create an index in memory so I can do something like this example for every query in a list (though iterating in a Java list of queries would not be very efficient): //Iterating over my list<Query> MemoryIndex index = new MemoryIndex(); //Add all fields index.addField("myField", "myFieldData", analyzer); ... QueryParser parser = new QueryParser("myField", analyzer); float score = index.search(query); if (score > 0.0f) { System.out.println("it's a match"); } else { System.out.println("no match found"); } The problem here is that this Data Class has several Hibernate Search Annotations @Field,@IndexedEmbedded,... which indicated how fields should be indexed, so when I invoke index() method on the FullTextEntityManager instance it uses this information to index the object in the directory. Is there a similar way to index it in memory using this information? Is there a more efficient way of doing this reverse search? Thanks

    Read the article

  • Is there a difference here?

    - by HotHead
    Please consider following code: 1. uint16 a = 0x0001; if(a < 0x0002) { // do something } 2. uint16 a = 0x0001; if(a < uint16(0x0002)) { // do something } 3. uint16 a = 0x0001; if(a < static_cast<uint16>(0x0002)) { // do something } 4. uint16 a = 0x0001; uint16 b = 0x0002; if(a < b) { // do something } What compiler does in backgorund and what is the best (and correct) way to do above testing? p.s. sorry, but I couldn't find the better title :) Thank you in advance!

    Read the article

  • php : echo"", print(), printf()

    - by marc-andre menard
    Is there a better way to output data to html page with PHP ? if i like to make a div with some var in php i will write something like that print ('<div>'.$var.'</div>); or echo "'<div>'.$var.'</div>'"; what is the PROPER way to do that ? or a better way, fill a $tempvar and print it once? like that: $tempvar = '<div>'.$var.'</div>' print ($tempvar); in fact, in real life, the var will be fill with much more !

    Read the article

  • What is the best way to handle my softwares licenses?

    - by Sergio Tapia
    By best I mean more time tested, easier to implement and easier for the users to work with. I do not want my licensing crap to interfere with their work. I was thinking of launching a WCF service that check with my license DB if it's a valid license and if it is, send a True. If the returned response is False, then shut down the program after telling them to fix their license. Do you think this is a good way to handle it?

    Read the article

  • linux tooling for starting as a net programmer

    - by alfredo dobrekk
    What are the linux developper tools to do the things i do with .NET in my windows environnement : I would like to port my client server application that runs under winform/nhibernate/sql server. Language c# Database SQL server ORM Nhibernate Source control SVN / Tortoise Unit testing Nunit Continuous integration Cruise Control Should i go java and eclipse ? Python and ??? Ruby and ??? Is there some IDE that allow me to manage all these processes under linux ?

    Read the article

  • Passing arguments and values form HTML to jQuery (events)

    - by Jaroslav Moravec
    What is the practice to pass arguments from HTML to jQuery events function. For example getting id of row from db: <tr class="jq_killMe" id="thisItemId-id"> ... </tr> and jQuery: $(".jq_killMe").click(function () { var tmp = $(this).attr('id).split("-"); var id = tmp[0] // ... } What's the best practise, if I want to pass more than one argument? Is it better not to use jQuery? For example: <tr onclick="killMe('id')"> ... </tr> I didn't find the answer on my question, I will be glad even for links. Thanks.

    Read the article

  • Why should I use a container div in HTML?

    - by lara.robertson
    I am currently learning html/css, and have noticed a common technique is to place a generic container div in the root of the body tag: <html> <head> ... </head> <body> <div id="container"> ... </div> </body> </html> Is there a valid reason for doing this? Why can't the css just reference the body tag?

    Read the article

  • ASP.Net MVC: Showing the same data using different layouts...

    - by vdh_ant
    Hi guys I'm wanting to create a page that allows the users to select how they would like to view their data - i.e. summary (which supports grouping), grid (which supports grouping), table (which supports grouping), map, time line, xml, json etc. Now each layout would probably have different use a different view model, which inherit from a common base class/view model. The reason being that each layout needs the object structure that it deals with to be different (some need hierarchical others a flatter structure). Each layout would call the same repository method and each layout would support the same functionality, i.e. searching and filtering (hence these controls would be shared between layouts). The main exception to this would be sorting which only grid and table views would need to support. Now my question is given this what do people think is the best approach. Using DisplayFor to handle the rendering of the different types? Also how do I work this with the actions... I would imagine that I would use the one action, and pass in the layout types, but then how does this support the grouping required for the summary, grid and table views. Do i treat each grouping as just a layout type Also how would this work from a URL point of view - what do people think is the template to support this layout functionality Cheers Anthony

    Read the article

  • Simplest PHP Routing framework .. ?

    - by David
    I'm looking for the simplest implementation of a routing framework in PHP, in a typical PHP environment (Running on Apache, or maybe nginx) .. It's the implementation itself I'm mostly interested in, and how you'd accomplish it. I'm thinking it should handle URL's, with the minimal rewriting possible, (is it really a good idea, to have the same entrypoint for all dynamic requests?!), and it should not mess with the querystring, so I should still be able to fetch GET params with $_GET['var'] as you'd usually do.. So far I have only come across .htaccess solutions that puts everything through an index.php, which is sort of okay. Not sure if there are other ways of doing it. How would you "attach" what URL's fit to what controllers, and the relation between them? I've seen different styles. One huge array, with regular expressions and other stuff to contain the mapping. The one I think I like the best is where each controller declares what map it has, and thereby, you won't have one huge "global" map, but a lot of small ones, each neatly separated. So you'd have something like: class Root { public $map = array( 'startpage' => 'ControllerStartPage' ); } class ControllerStartPage { public $map = array( 'welcome' => 'WelcomeControllerPage' ); } // Etc ... Where: 'http://myapp/' // maps to the Root class 'http://myapp/startpage' // maps to the ControllerStartPage class 'http://myapp/startpage/welcome' // maps to the WelcomeControllerPage class 'http://myapp/startpage/?hello=world' // Should of course have $_GET['hello'] == 'world' What do you think? Do you use anything yourself, or have any ideas? I'm not interested in huge frameworks already solving this problem, but the smallest possible implementation you could think of. I'm having a hard time coming up with a solution satisfying enough, for my own taste. There must be something pleasing out there that handles a sane bootstrapping process of a PHP application without trying to pull a big magic hat over your head, and force you to use "their way", or the highway! ;)

    Read the article

  • Why is giving a fixed width to a label an accepted behavior?

    - by kemp
    There are a lot of questions about formatting forms so that labels align, and almost all the answers which suggest a pure CSS solution (as opposed to using a table) provide a fixed width to the label element. But isn't this mixing content and presentation? In order to choose the right width you basically have to see how big your longest label is and try a pixel width value until "it fits". This means that if you change your labels you also have to change your CSS.

    Read the article

< Previous Page | 85 86 87 88 89 90 91 92 93 94 95 96  | Next Page >