Search Results

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

Page 75/237 | < Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >

  • Only perform jquery effects/operations on certain pages

    - by Galen
    Up until now i've been dropping all my jquery code right inside the document.ready function. I'm thinking that for certain situations this isnt the best way to go. for example: If i want an animation to perform when a certain page loads what is the best way to go about that. $(document).ready(function() { $("#element_1").fadeIn(); $("#element_2").delay('100').fadeIn(); $("#element_3").delay('200').fadeIn(); }); If this is right inside of document.ready then every time ANY page loads it's going to check each line and look for that element. What is the best way to tell jquery to only perform a chunk of code on a certain page to avoid this issue.

    Read the article

  • Java 'Prototype' pattern - new vs clone vs class.newInstance

    - by Guillaume
    In my project there are some 'Prototype' factories that create instances by cloning a final private instance. The author of those factories says that this pattern provides better performance than calling 'new' operator. Using google to get some clues about that, I've found nothing really relevant about that. Here is a small excerpt found in a javdoc from an unknown project javdoc from an unknown project Sadly, clone() is rather slower than calling new. However it is a lot faster than calling java.lang.Class.newInstance(), and somewhat faster than rolling our own "cloner" method. For me it's looking like an old best practice of the java 1.1 time. Does someone know more about this ? Is this a good practice to use that with 'modern' jvm ?

    Read the article

  • What should a developer know before building a public web site?

    - by Joel Coehoorn
    What things should a programmer implementing the technical details of a web site address before making the site public? If Jeff Atwood can forget about HttpOnly cookies, sitemaps, and cross-site request forgeries all in the same site, what important thing could I be forgetting as well? I'm thinking about this from a web developer's perspective, such that someone else is creating the actual design and content for the site. So while usability and content may be more important than the platform, you the programmer have little say in that. What you do need to worry about is that your implementation of the platform is stable, performs well, is secure, and meets any other business goals (like not cost too much, take too long to build, and rank as well with Google as the content supports). Think of this from the perspective of a developer who's done some work for intranet-type applications in a fairly trusted environment, and is about to have his first shot and putting out a potentially popular site for the entire big bad world wide web. Also: I'm looking for something more specific than just a vague "web standards" response. I mean, HTML, JavaScript, and CSS over HTTP are pretty much a given, especially when I've already specified that you're a professional web developer. So going beyond that, Which standards? In what circumstances, and why? Provide a link to the standard's specification. This question is community wiki, so please feel free to edit that answer to add links to good articles that will help explain or teach each particular point.

    Read the article

  • How to handle input and parameter validation between layers?

    - by developr
    If I have a 3 layer web forms application that takes user input, I know I can validate that input using validation controls in the presentation layer. Should I also validate in the business and data layers as well to protect against SQL injection and also issues? What validations should go in each layer? Another example would be passing a ID to return a record. Should the data layer ensure that the id is valid or should that happen in BLL / UI?

    Read the article

  • Showing response time in a rails app.

    - by anshul
    I want to display a This page took x seconds widget at the bottom of every page in my rails application. I would like x to reflect the approximate amount of time the request spent on my server. What is the usual way this is done in Rails?

    Read the article

  • Can per-user randomized salts be replaced with iterative hashing?

    - by Chas Emerick
    In the process of building what I'd like to hope is a properly-architected authentication mechanism, I've come across a lot of materials that specify that: user passwords must be salted the salt used should be sufficiently random and generated per-user ...therefore, the salt must be stored with the user record in order to support verification of the user password I wholeheartedly agree with the first and second points, but it seems like there's an easy workaround for the latter. Instead of doing the equivalent of (pseudocode here): salt = random(); hashedPassword = hash(salt . password); storeUserRecord(username, hashedPassword, salt); Why not use the hash of the username as the salt? This yields a domain of salts that is well-distributed, (roughly) random, and each individual salt is as complex as your salt function provides for. Even better, you don't have to store the salt in the database -- just regenerate it at authentication-time. More pseudocode: salt = hash(username); hashedPassword = hash(salt . password); storeUserRecord(username, hashedPassword); (Of course, hash in the examples above should be something reasonable, like SHA-512, or some other strong hash.) This seems reasonable to me given what (little) I know of crypto, but the fact that it's a simplification over widely-recommended practice makes me wonder whether there's some obvious reason I've gone astray that I'm not aware of.

    Read the article

  • When should I implement IDisposable?

    - by Bobby
    What is the best practice for when to implement IDisposable? Is the best rule of thumb to implement it if you have one managed object in the class, or does it depend if the object was created in the class or just passed in? Should I also do it for classes with no managed objects at all?

    Read the article

  • Legacy code - when to move on

    - by Mmarquee
    My team and support a large number of legacy applications all of which are currently functional but problematic to support and maintain. They all depend on code that the compiler manufacture has officially no support for. So the question is should we leave the code as is, and risk a new compiler breaking our code, or should we bite the bullet and update all the code?

    Read the article

  • How convince other developers not to ignore Exceptions?

    - by Mnementh
    Recently I encountered a bug in an application I took over from another developer. I debugged for the reason and over an hour later I realized, that the problem wasn't the code producing the exception, but some code executed before this returning wrong data. If I dived into this, I encountered the following: try { ... } catch (XYException e){} If the Exception would have been propagated (a change I did), I would have found the reason for the bugs in a few minutes, as the stacktrace had pointed me to the problem. So how can I convince other developers to never catch and ignore exceptions in this way?

    Read the article

  • Coding styles for html

    - by Hulk
    Hi, Please the coding standard followed for HTML .Please suggest links that the has the coding styles for html.(like Camel case or .....) <table> <tr> <td> Data </td> </tr> </table> Thanks..

    Read the article

  • How to insert an Array/Objet into SQL (bestpractice)

    - by Jason
    I need to store three items as an array in a single column and be able to quickly/easily modify that data in later functions. [---YOU CAN SKIP THIS PART IF YOU TRUST ME--] To be clear, I love and use x_ref tables all the time but an x_ref doesn't work here because this is not a one-to-many relationship. I am making a project management tool that among other things, assigns a user to a project and assigns hours to that project on a weekly basis, per user, sometimes for weeks many weeks into the future. Of course there are many projects, a project can have many team members, a team member can be involved with many projects at one time BUT its not one-to-many because a team member can be working many weeks on the same project but have different hours for different weeks. In other words, each object really is unique. Also/finally, this data can be changed at any time by any team-member - hence it needs to be easily to manipulate. Basically, I need to handle three values (the team member, the week we're talking about, and how many hours) dropped into a project row in the projects table (under the column for project team members) and treated as one item - a team member - that will actually be part of a larger array of all the team members involved on the project. [--END SKIP, START READING HERE :) --] So assuming that the application's general schema and relation tables aren't total crap and that we are in fact up against a wall in this one case to use an array/object as a value for this column, is there a best practice for that? Like a particular SQL data-type? A particular object/array format? CSV? JSON? XML? Most of the app is in C# but (for very odd reasons that I won't explain) we could really use any environment if there is a particular one that handles this well. For the moment, I am thinking either (webservice + JS/JSON) or PHP unserialize/serialize (but I am bit sketched out by the PHP solution because it seems a bit cumbersome when using ajax?) Thoughts anyone?

    Read the article

  • do I need to use partial?

    - by wiso
    I've a general function, for example (only a simplified example): def do_operation(operation, a, b, name): print name do_something_more(a,b,name, operation(a,b)) def operation_x(a,b): return a**2 + b def operation_y(a,b): return a**10 - b/2. and some data: data = {"first": {"name": "first summation", "a": 10, "b": 20, "operation": operation_x}, "second": {"name": "second summation", "a": 20, "b": 50, "operation": operation_y}, "third": {"name": "third summation", "a": 20, "b": 50, "operation": operation_x}, # <-- operation_x again } now I can do: what_to_do = ("first", "third") # this comes from command line for sum_id in what_to_do: do_operation(data["operation"], data["a"], data["b"], data["name"]) or maybe it's better if I use functools.partial? from functools import partial do_operation_one = do_operation(name=data["first"]["name"], operation=data["first"]["operation"], a=data["first"]["a"], b=data["first"]["b"]) do_operation_two = do_operation(name=data["second"]["name"], operation=data["second"]["operation"] a=data["second"]["a"], b=data["second"]["b"]) do_operation_three = do_operation(name=data["third"]["name"], operation=data["third"]["operation"] a=data["third"]["a"], b=data["third"]["b"]) do_dictionary = { "first": do_operation_one, "second": do_operation_two, "third": do_operation_three } for what in what_to_do: do_dictionary[what]()

    Read the article

  • To be effective on your home projects is it better using the same technologies used at work?

    - by systempuntoout
    To be more productive and effective, is it better to start developing an home project using the same technologies used at work? I'm not talking about a simple hello world web page but an home project with all bells and whistles that one day, maybe, you could sell on internet. This dilemma is often subject of flames between me and a friend. He thinks that if you want to make a great home-made project you need to use the same technologies used daily at work staying in the same scope too; for example, a c++ computer game programmer should develope an home-made c++ game. I'm pretty sure that developing using the same technologies used at work can be more productive at beginning, but surely less exciting and stimulating of working with other languages\ides\libraries out of your daily job. What's your opinion about that?

    Read the article

  • How does this code break the Law of Demeter?

    - by Dave Jarvis
    The following code breaks the Law of Demeter: public class Student extends Person { private Grades grades; public Student() { } /** Must never return null; throw an appropriately named exception, instead. */ private synchronized Grades getGrades() throws GradesException { if( this.grades == null ) { this.grades = createGrades(); } return this.grades; } /** Create a new instance of grades for this student. */ protected Grades createGrades() throws GradesException { // Reads the grades from the database, if needed. // return new Grades(); } /** Answers if this student was graded by a teacher with the given name. */ public boolean isTeacher( int year, String name ) throws GradesException, TeacherException { // The method only knows about Teacher instances. // return getTeacher( year ).nameEquals( name ); } private Grades getGradesForYear( int year ) throws GradesException { // The method only knows about Grades instances. // return getGrades().getForYear( year ); } private Teacher getTeacher( int year ) throws GradesException, TeacherException { // This method knows about Grades and Teacher instances. A mistake? // return getGradesForYear( year ).getTeacher(); } } public class Teacher extends Person { public Teacher() { } /** * This method will take into consideration first name, * last name, middle initial, case sensitivity, and * eventually it could answer true to wild cards and * regular expressions. */ public boolean nameEquals( String name ) { return getName().equalsIgnoreCase( name ); } /** Never returns null. */ private synchronized String getName() { if( this.name == null ) { this.name == ""; } return this.name; } } Questions How is the LoD broken? Where is the code breaking the LoD? How should the code be written to uphold the LoD?

    Read the article

  • .Net4 ConcurrentDictionary: Tips & Tricks

    - by SDReyes
    Hi guys, I started to use the new ConcurrentDictionary from .Net4 yesterday to implement a simple caching for a threading project. But I'm wondering what I have to take care of/be careful about when using it? What have been your experiences using it?

    Read the article

  • C# Inheritence: Choosing what repository based on type of inherited class

    - by Oskar Kjellin
    I have been making a program that downloads information about movies from the internet. I have a base class Title, which represents all titles. Movie, Serie and Episode are inherited from that class. To save them to the database I have 2 services, MovieService and SerieService. They in turn call repositories, but that is not important here. I have a method Save(Title title) which I am not very happy with. I check for what type the title is and then call the correct service. I would like to perhaps write like this: ITitleService service = title.GetService(); title.GetSavedBy(service); So I have an abstract method on Title that returns an ITitleSaver, which will return the correct service for the instance. My question is how should I implement ITitleSaver? If I make it accept Title I will have to cast it to the correct type before calling the correct overload. Which will lead to having to deal with casting once again. What is the best approach to dealing with this? I would like to have the saving logic in the corresponding class.

    Read the article

  • Why is it preferable to call a static method statically from within an instance of the method's clas

    - by javanix
    If I create an instance of a class in Java, why is it preferable to call a static method of that same class statically, rather than using this.method()? I get a warning from Eclipse when I try to call static method staticMethod() from within the custom class's constructor via this.staticMethod(). public MyClass() { this.staticMethod(); } vs public MyClass() { MyClass.staticMethod(); } Can anyone explain why this is a bad thing to do? It seems to me like the compiler should already have allocated an instance of the object, so statically allocating memory would be unneeded overhead.

    Read the article

  • Saving a reference to a int.

    - by Scott Chamberlain
    Here is a much simplified version of what I am trying to do static void Main(string[] args) { int test = 0; int test2 = 0; Test A = new Test(ref test); Test B = new Test(ref test); Test C = new Test(ref test2); A.write(); //Writes 1 should write 1 B.write(); //Writes 1 should write 2 C.write(); //Writes 1 should write 1 Console.ReadLine(); } class Test { int _a; public Test(ref int a) { _a = a; //I loose the reference here } public void write() { var b = System.Threading.Interlocked.Increment(ref _a); Console.WriteLine(b); } } In my real code I have a int that will be incremented by many threads however where the threads a called it will not be easy to pass it the parameter that points it at the int(In the real code this is happening inside a IEnumerator). So a requirement is the reference must be made in the constructor. Also not all threads will be pointing at the same single base int so I can not use a global static int either. I know I can just box the int inside a class and pass the class around but I wanted to know if that is the correct way of doing something like this? What I think could be the correct way: static void Main(string[] args) { Holder holder = new Holder(0); Holder holder2 = new Holder(0); Test A = new Test(holder); Test B = new Test(holder); Test C = new Test(holder2); A.write(); //Writes 1 should write 1 B.write(); //Writes 2 should write 2 C.write(); //Writes 1 should write 1 Console.ReadLine(); } class Holder { public Holder(int i) { num = i; } public int num; } class Test { Holder _holder; public Test(Holder holder) { _holder = holder; } public void write() { var b = System.Threading.Interlocked.Increment(ref _holder.num); Console.WriteLine(b); } } Is there a better way than this?

    Read the article

  • Newbie T-SQL dynamic stored procedure -- how can I improve it?

    - by Andy Jones
    I'm new to T-SQL; all my experience is in a completely different database environment (Openedge). I've learned enough to write the procedure below -- but also enough to know that I don't know enough! This routine will have to go into a live environment soon, and it works, but I'm quite certain there are a number of c**k-ups and gotchas in it that I know nothing about. The routine copies data from table A to table B, replacing the data in table B. The tables could be in any database. I plan to call this routine multiple times from another stored procedure. Permissions aren't a problem: the routine will be run by the dba as a timed job. Could I have your suggestions as to how to make it fit best-practice? To bullet-proof it? ALTER PROCEDURE [dbo].[copyTable2Table] @sdb varchar(30), @stable varchar(30), @tdb varchar(30), @ttable varchar(30), @raiseerror bit = 1, @debug bit = 0 as begin set nocount on declare @source varchar(65) declare @target varchar(65) declare @dropstmt varchar(100) declare @insstmt varchar(100) declare @ErrMsg nvarchar(4000) declare @ErrSeverity int set @source = '[' + @sdb + '].[dbo].[' + @stable + ']' set @target = '[' + @tdb + '].[dbo].[' + @ttable + ']' set @dropStmt = 'drop table ' + @target set @insStmt = 'select * into ' + @target + ' from ' + @source set @errMsg = '' set @errSeverity = 0 if @debug = 1 print('Drop:' + @dropStmt + ' Insert:' + @insStmt) -- drop the target table, copy the source table to the target begin try begin transaction exec(@dropStmt) exec(@insStmt) commit end try begin catch if @@trancount > 0 rollback select @errMsg = error_message(), @errSeverity = error_severity() end catch -- update the log table insert into HHG_system.dbo.copyaudit (copytime, copyuser, source, target, errmsg, errseverity) values( getdate(), user_name(user_id()), @source, @target, @errMsg, @errSeverity) if @debug = 1 print ( 'Message:' + @errMsg + ' Severity:' + convert(Char, @errSeverity) ) -- handle errors, return value if @errMsg <> '' begin if @raiseError = 1 raiserror(@errMsg, @errSeverity, 1) return 1 end return 0 END Thanks!

    Read the article

  • Best practice for installing python modules from an arbitrary VCS repository

    - by fmark
    I'm newish to the python ecosystem, and have a question about module editing. I use a bunch of third-party modules, distributed on PyPi. Coming from a C and Java background, I love the ease of easy_install <whatever>. This is a new, wonderful world, but the model breaks down when I want to edit the newly installed module for two reasons: The egg files may be stored in a folder or archive somewhere crazy on the file system. Using an egg seems to preclude using the version control system of the originating project, just as using a debian package precludes development from an originating VCS repository. What is the best practice for installing modules from an arbitrary VCS repository? I want to be able to continue to import foomodule in other scripts.

    Read the article

  • Is there a way to avoid spaghetti code over the years?

    - by Yoni Roit
    I've had several programming jobs. Each one with 20-50 developers, project going on for 3-5 years. Every time it's the same. Some programmers are bright, some are average. Everyone has their CS degree, everyone read design patterns. Intentions are good, people are trying hard to write good code but still after a couple of years the code turns into spaghetti. Changes in module A suddenly break module B. There are always these parts of code that no one can understand except for the person who wrote it. Changing infrastructure is impossible and backwards compatibility issues prevent good features to get in. Half of the time you just want to rewrite everything from scratch. And people more experienced than me treat this as normal. Is it? Does it have to be? What can I do to avoid this or should I accept it as a fact of life? Edit: Guys, I am impressed with the amount and quality of responses here. This site and its community rock!

    Read the article

  • What is the best approach towards styling GWT applications?

    - by Ashwin
    General approach in GWT is to use Panels and then apply custom CSS themes to get a customized look. While I can achieve a certain extent of personalization of my GWT app through CSS tinkering, I was wondering how others generally approach styling. Some of the suggestions I came across the web were to manage layout with plain HTML, through use of HTMLPanel's. This way one can straightaway use the HTML mock-up within the application without having to code all the layout. So what in your opinion is the best and least painful way to approach layout and custom styling of GWT application?

    Read the article

< Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >