Search Results

Search found 4835 results on 194 pages for 'practice'.

Page 33/194 | < Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >

  • Is it a Good Practice to Write HTML Using a StringBuilder in my ASP.NET Codebehind?

    - by d3020
    I'm interested to hear from other developers their opinion on an approach that I typically take. I have a web application, asp.net 2.0, c#. What I usually do to write out drop downs, tables, input controls, etc. is in the code behind use StringBuilder and write out something like sb.Append(" I don't find myself using to many .net controls as I typically write out the html in the code behind. When I want to use jQuery or call JavaScript I just put that function call in my sb.Append tag like sb.Append("td...onblur='fnCallJS()'. I've gotten pretty comfortable with this approach. For data access I use EntitySpaces. I'm just kind of curious if this sort of approach is horribly wrong, ok depending on the context, good, time to learn 3.0, etc. I'm interested in learning and was just looking for some input.

    Read the article

  • GWT: Best practice for unit testing / mocking JSNI methods?

    - by Epaga
    I have a class which uses JSNI to retrieve JSON data stored in the host page: protected native JsArray<JsonModel> getModels() /*-{ return $wnd.jsonData; }-*/; This method is called, and the data is then translated and process in a different method. How should I unit test this class, since I'm not able to instantiate (or seemingly mock?) JsArray? What is the best way to unit test JSNI methods at all?

    Read the article

  • What is the best practice for ouputting data from a collection on an ASP.net Page?

    - by bshacklett
    I've ported a page from classic ASP to ASP.net. Part of what happens in this page is that a collection of custom types is generated and then displayed via Response.Write() commands. I'd like to get the business logic separated out into a code behind file (and maybe move this all into a user control), but I can't seem to figure out how I'd actually display the collection once it's been generated. I want to specify a master page here, too, so the code can't stay inline. Here's a very stripped down version of the current code: <% Dim objs as ArrayList = New ArrayList() For i = 0 To 2 Dim obj as Obj = New Obj() obj.setProp1("ASDF") obj.setProp2("FDSA") objs.Add(obj) Next i %> <table> <thead> <tr> <th scope="col">Property 1</th> <th scope="col">Property 2</th> </tr> </thead> <tbody> <% For Each obj As Obj In objs Dim objProp1 As String = obj.getProp1 Dim objProp2 As String = obj.getProp2 %> <tr> <td><% Response.Write(objProp1)%></td> <td><% Response.Write(objProp2)%></td> </tr> <% Next %> </tbody> </table> What is the ".net" way of doing this?

    Read the article

  • Best practice for submits redirecting to another page in MVC2?

    - by blesh
    I have a situation with my MVC2 app where I have multiple pages that need to submit different information, but all need to end up at the same page. In my old Web Forms app, I'd have just accomplished this in my btnSave_Click delegate with a Redirect. There are three different types of products, each of which need to be saved to the cart in a completely different manner from their completely different product pages. I'm not going to get into why or how they're different, just suffice to say, they're totally different. After they're saved to the cart, I need to "redirect" to the Checkout view. But it should be noted, that you can also just browse straight to the Checkout view without having to submit any products to add to the cart. Here's a diagram of what I'm trying to accomplish, and how I think I need to handle it: Is this correct? It seems like a common scenario, but I haven't seen any examples of how I should handle this. Thank you all in advance.

    Read the article

  • Is it a bad practice to pass "this" as an argument?

    - by Anna Lear
    I'm currently tempted to write the following: public class Class1() { public Class1() { MyProperty = new Class2(this); } public Class2 MyProperty { get; private set; } } public class Class2() { public Class2(Class1 class1) { ParentClass1 = class1; } public Class1 ParentClass1 { get; set; } } Is passing "this" as an argument a sign of a design problem? What would be a better approach?

    Read the article

  • Is instanceof considered bad practice? If so, under what circumstances is instanceof still preferabl

    - by aioobe
    Over the years, I've tried to avoid instanceof whenever possible. Using polymorphism or the visitor pattern where applicable. I suppose it simply eases maintenance in some situations... Are there any other drawbacks that one should be aware of? I do however see it here and there in the Java libraries so I suppose it has its place? Under what circumstances is it preferable? Is it ever unavoidable?

    Read the article

  • Is it good or bad practice to use var everywhere? [closed]

    - by Earlz
    Possible Duplicate: Use of var keyword in C# Hello, I've recently been discovering the awesomeness that is the var keyword in C#. Well, I didn't think about it before but I just wrote lines of code that are along the lines of var con=CreateNewConnection(); Where this would usually be IdbConnection con=CreateNewConnection(); Is this a good use of var? Is it possible to use var too often? Are there any downsides to using it? Also, one more point of consideration: We are not worried about backwards compatability. We just care that it runs on .NET 3.5

    Read the article

  • Best Practice: QT4 QList<Mything*>... on Heap, or QList<Mything> using reference?

    - by Mike Crowe
    Hi Folks, Learning C++, so be gentle :)... I have been designing my application primarily using heap variables (coming from C), so I've designed structures like this: QList<Criteria*> _Criteria; // ... Criteria *c = new Criteria(....); _Criteria.append(c); All through my program, I'm passing pointers to specific Criteria, or often the list. So, I have a function declared like this: QList<Criteria*> Decision::addCriteria(int row,QString cname,QString ctype); Criteria * Decision::getCriteria(int row,int col) which inserts a Criteria into a list, and returns the list so my GUI can display it. I'm wondering if I should have used references, somehow. Since I'm always wanting that exact Criteria back, should I have done: QList<Criteria> _Criteria; // .... Criteria c(....); _Criteria.append(c); ... QList<Criteria>& Decision::addCriteria(int row,QString cname,QString ctype); Criteria& Decision::getCriteria(int row,int col) (not sure if the latter line is syntactically correct yet, but you get the drift). All these items are specific, quasi-global items that are the core of my program. So, the question is this: I can certainly allocate/free all my memory w/o an issue in the method I'm using now, but is there are more C++ way? Would references have been a better choice (it's not too late to change on my side). TIA Mike

    Read the article

  • Best practice to pass a value from pop over control on iPad.

    - by Tattat
    It is an iPad app based on SDK 3.2. I have a MainUIView, that is subclass from UIView, it have a UIButton and a UILabel. When user press the UIButton, the pop over control will be appeared with a table view. When the user select a cell from the table view, the UILabel changes content base on the user click, and the pop up table view will disappear. The question is, how can I pass the "selected cell" to the UILabel. I am thinking making a "middle man" object. When the user click the UIButton, and the "middle man" will pass to the table. When the cell is selected, the "middle man" will store the idx, and call the UILabel change content from the value of "middle man". But I think it is pretty complex to implement, is there any easier way to implement it? thz u.

    Read the article

  • Is it bad practice to apply class-based design to JavaScript programs?

    - by helixed
    JavaScript is a prototyped-based language, and yet it has the ability to mimic some of the features of class-based object-oriented languages. For example, JavaScript does not have a concept of public and private members, but through the magic of closures, it's still possible to provide the same functionality. Similarly, method overloading, interfaces, namespaces and abstract classes can all be added in one way or another. Lately, as I've been programming in JavaScript, I've felt like I'm trying to turn it into a class-based language instead of using it in the way it's meant to be used. It seems like I'm trying to force the language to conform to what I'm used to. The following is some JavaScript code I've written recently. It's purpose is to abstract away some of the effort involved in drawing to the HTML5 canvas element. /* Defines the Drawing namespace. */ var Drawing = {}; /* Abstract base which represents an element to be drawn on the screen. @param The graphical context in which this Node is drawn. @param position The position of the center of this Node. */ Drawing.Node = function(context, position) { return { /* The method which performs the actual drawing code for this Node. This method must be overridden in any subclasses of Node. */ draw: function() { throw Exception.MethodNotOverridden; }, /* Returns the graphical context for this Node. @return The graphical context for this Node. */ getContext: function() { return context; }, /* Returns the position of this Node. @return The position of this Node. */ getPosition: function() { return position; }, /* Sets the position of this Node. @param thePosition The position of this Node. */ setPosition: function(thePosition) { position = thePosition; } }; } /* Define the shape namespace. */ var Shape = {}; /* A circle shape implementation of Drawing.Node. @param context The graphical context in which this Circle is drawn. @param position The center of this Circle. @param radius The radius of this circle. @praram color The color of this circle. */ Shape.Circle = function(context, position, radius, color) { //check the parameters if (radius < 0) throw Exception.InvalidArgument; var node = Drawing.Node(context, position); //overload the node drawing method node.draw = function() { var context = this.getContext(); var position = this.getPosition(); context.fillStyle = color; context.beginPath(); context.arc(position.x, position.y, radius, 0, Math.PI*2, true); context.closePath(); context.fill(); } /* Returns the radius of this Circle. @return The radius of this Circle. */ node.getRadius = function() { return radius; }; /* Sets the radius of this Circle. @param theRadius The new radius of this circle. */ node.setRadius = function(theRadius) { radius = theRadius; }; /* Returns the color of this Circle. @return The color of this Circle. */ node.getColor = function() { return color; }; /* Sets the color of this Circle. @param theColor The new color of this Circle. */ node.setColor = function(theColor) { color = theColor; }; //return the node return node; }; The code works exactly like it should for a user of Shape.Circle, but it feels like it's held together with Duct Tape. Can somebody provide some insight on this?

    Read the article

  • How to deal with colleagues refuse to follow practices?

    - by Adrian Shum
    I was discussing with another colleague about what we should be used when an DB entity is referring to another. I don't think there is any good reason to break the practice of putting the Primary Key in the referring entity. However, one of my colleague says: "You should use a surrogate key in the entity, but it is better to put the human-readable natural key in the referring entity. As long it is unique, it is fine and it is easier when you are doing support or maintenance job" I know it will works, but obviously it is not a good practice you are putting a non-PK unique column as "foreign key", just for gaining a bit of ease in writing SQL during support as we can have less table join. Though I mentioned the his approach is conceptual incorrect, and causing problem too practically etc, he seems rather trade off correctness in data model in exchange of ease of maintenance. And he said: "I know it is not good practice, but good practice is not golden rule" Honestly I feel frustrated when dealing with something like this. I know there are always case that we should break some rule or practice, but doubtless it is not such case now. What will you when you are facing situation like this? Please assume yourself being a senior developer which is expected to contribute in misc development direction and convention.

    Read the article

  • How well do zippers perform in practice, and when should they be used?

    - by Rob
    I think that the zipper is a beautiful idea; it elegantly provides a way to walk a list or tree and make what appear to be local updates in a functional way. Asymptotically, the costs appear to be reasonable. But traversing the data structure requires memory allocation at each iteration, where a normal list or tree traversal is just pointer chasing. This seems expensive (please correct me if I am wrong). Are the costs prohibitive? And what under what circumstances would it be reasonable to use a zipper?

    Read the article

  • Is there a best-practice approach for internationalization of an application?

    - by Lee Warner
    We need to have our apps be translated into other languages. This entails renaming the .text properties of our visible controls as well as other literals found within our apps to whatever language we need to translate into. Is this something that can easily be accomplished with .resx files? I was thinking of creating a master resx key/value list where the key would be the fully qualified name of the control/variable/constant etc. and then refactor our apps to look into this file to get their values based on the cultureinfo found at runtime? Is there a standard or simpler approach to this problem?

    Read the article

  • Is using the Class instance as a Map key a best practice?

    - by Pangea
    I have read somewhere that using the class instances as below is not a good idea as they might cause memory leaks. Can someone tell me if if that is a valid statement? Or are they any problems using it this way? Map<Class<?>,String> classToInstance=new HashMap(); classToInstanceMap.put(String.class,"Test obj");

    Read the article

  • Do you Kung Foo? [closed]

    - by Darknight
    As a programmer who also trains in martial arts (Wing Tsun + Escrima + Judo). I am really interested to know if there are other fellow programmers who also practice martial arts. Do you practice martial arts? or do you know of programmers who practice martial arts. Further question: Do you see any analogy between your art and programming. [Apologies for the terrible pun in the title :) but I do like it cheesy...]

    Read the article

  • Practicing Java Swing

    - by user1265125
    I've been learning Java by myself through many different online and offline resources. I just finished some basic practice and theoretical knowledge of Swing. Now, to become good at it I need some practice problems which would test my Swing skills, including GUI Building, listeners etc. But I can't figure out where to find such questions/problems for my practice. Do you guys know of an online resource? Some book would also do...

    Read the article

  • Is there a standard practice for synchronizing SQL Server tables?

    - by EngineeringAutomation
    I've written an application that retrieves pricing and part options from a SQL database to generate a 3D Model of the product and create a sales proposal. My client likes it so much they want to be able to use it on laptops in the field now. The catch is, they won't have an internet connection. I'm considering setting up a SQLite database as part of the standard installation. The SQLite database on each laptop will synchronize with the main database when the internet connection is re-established. Are there best practices regarding synchronizing SQL tables like this? Are there any pitfalls I should consider? I'm open to all options. Thank you.

    Read the article

  • Is it considered a good/bad practice to configure tomcat for deploying certain apps?

    - by Roman
    Disclaimer: I've never used technique which is described below. That's why there may occur some mistakes or misunderstandings in its description. I heard that some teams (developers) use 'pre-configured' tomcat. As I understand they add different jars to tomcat \lib folder and do something else. Once I've read something about recompilation (or reassembly?) of tomcat for certain needs. Just yesterday I heard a dialog where one developer sayd that his team-mates were not able to deploy the project until he would give them configured tomcat version. So, I wonder, what is it all about and why do they do it? What benefits can they gain from that?

    Read the article

  • Is it bad practice to make a setter return "this"?

    - by Ken Liu
    Is it a good or bad idea to make setters in java return "this"? public Employee setName(String name){ this.name = name; return this; } This pattern can be useful because then you can chain setters like this: list.add(new Employee().setName("Jack Sparrow").setId(1).setFoo("bacon!")); instead of this: Employee e = new Employee(); e.setName("Jack Sparrow"); ...and so on... list.add(e); ...but it sort of goes against standard convention. I suppose it might be worthwhile just because it can make that setter do something else useful. I've seen this pattern used some places (e.g. JMock, JPA), but it seems uncommon, and only generally used for very well defined APIs where this pattern is used everywhere. Update: What I've described is obviously valid, but what I am really looking for is some thoughts on whether this is generally acceptable, and if there are any pitfalls or related best practices. I know about the Builder pattern but it is a little more involved then what I am describing - as Josh Bloch describes it there is an associated static Builder class for object creation.

    Read the article

  • Best practice. Do I save html tags in DB or store the html entity value?

    - by Matt
    Hi Guys, I was wondering about which way i should do the following. I am using the tiny MCE wysiwyg editor which formats the users data with the right html tags. Now, i need to save this data entered into the editor into a database table. Should I encode the html tags to their corresponding entities when inserting into the DB, then when i get the data back from the table, not have the encode it for XSS purposes but I'd still have to use eval for the html tags to format the text. OR Do i save the html tags into the database, then when i get the data back from the database encode the html tags to their entities, but then as the tags will appear to the user, I'd have to use the eval function to actually format the data as it was entered. My thoughts are with the first option, I just wondered on what you guys thought.

    Read the article

< Previous Page | 29 30 31 32 33 34 35 36 37 38 39 40  | Next Page >