Search Results

Search found 31207 results on 1249 pages for 'atg best practice in industries'.

Page 85/1249 | < Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >

  • Is it a bad practice to include all the enums in one file and use it in multiple classes?

    - by Bugster
    I'm an aspiring game developer, I work on occasional indie games, and for a while I've been doing something which seemed like a bad practice at first, but I really want to get an answer from some experienced programmers here. Let's say I have a file called enumList.h where I declare all the enums I want to use in my game: // enumList.h enum materials_t { WOOD, STONE, ETC }; enum entity_t { PLAYER, MONSTER }; enum map_t { 2D, 3D }; // and so on. // Tile.h #include "enumList.h" #include <vector> class tile { // stuff }; The main idea is that I declare all enums in the game in 1 file, and then import that file when I need to use a certain enum from it, rather than declaring it in the file where I need to use it. I do this because it makes things clean, I can access every enum in 1 place rather than having pages openned solely for accessing one enum. Is this a bad practice and can it affect performance in any way?

    Read the article

  • SQL Why is prefixing column names considered bad practice?

    - by P.Brian.Mackey
    According to a popular SO post is it considered a bad practice to prefix table names. At my company every column is prefixed by a table name. This is difficult for me to read. I'm not sure the reason, but this naming is actually the company standard. I can't stand the naming convention, but I have no documentation to back up my reasoning. All I know is that reading AdventureWorks is much simpler. In this our company DB you will see a table, Person and it might have column name: Person_First_Name or maybe even Person_Person_First_Name (don't ask me why you see person 2x) Why is it considered a bad practice to pre-fix column names? Are underscores considered evil in SQL as well? Note: I own Pro SQL Server 2008 - Relation Database design and implementation. References to that book are welcome.

    Read the article

  • Lisp Style question label local functions or not?

    - by Andrew Myers
    I was wondering if there is a standard practice regarding the use of labels in Lisp. I've been messing around with a Lisp implementation of the algorithm described in the first answer here http://stackoverflow.com/questions/352203/generating-permutations-lazily My current version uses labels to break out portions of functionality. (defun next-permutation (pmute) (declare (vector pmute)) (let ((len (length pmute))) (if (> len 2) (labels ((get-pivot () (do ((pivot (1- len) (1- pivot))) ((or (= pivot 0) (< (aref pmute (1- pivot)) (aref pmute pivot))) pivot))) (get-swap (pivot) (let ((swp (1- len))) (loop for i from (1- len) downto pivot do (if (or (and (> (aref pmute i) (aref pmute (1- pivot))) (< (aref pmute i) (aref pmute swp))) (< (aref pmute swp) (aref pmute (1- pivot)))) (setf swp i))) swp)) (next (swp pivot) (rotatef (aref pmute (1- pivot)) (aref pmute swp)) (reverse-vector pmute pivot (1- len)))) (let ((piv (get-pivot))) (if (> piv 0) (next (get-swap piv) piv) nil)))))) Since each label is only called once I was wondering if this is considered bad practice since the only reason to do it in this case is for aesthetic reasons. I would argue that the current version with labels is clearer but that may go against common wisdom that I'm not aware of, being new to Lisp.

    Read the article

  • Blueprint CSS and Separation of Presentation and Content When Designing Forms

    - by Merritt
    Is it possible to use Blueprint CSS and maintain a a respectable level of separation between presentation and content? I like how easy the framework is to use when designing forms, but am worried that the manner in which I use the css classes for columnizing elements is a bad practice. For instance, say I have a 3 field form designed using blueprint: <div class="container"> <form action="" method="post" class="inline"> <fieldset> <legend>Example</legend> <div class="span-3"> <label for="a">Label A:</label> <input type="text" class="text" id="a" name="a" > </div> <div class="span-2"> <label for="b">Label B:</label> <input type="text" class="text" id="b" name="b" > </div> <div class="span-3"> <label for="o">Label O:</label> <input type="checkbox" id="o" name="o" value="true" checked="checked" class="checkbox">checkbox one </div> <div class="span-2 last"> <input type="submit" value="submit" class="button"> </div> </fieldset> </form> </div> Is using a class attribute with names like "span-2", "inline", and "last" a bad practice? Or am I missing the point?

    Read the article

  • Reference for proper handling of PID file on Unix

    - by bignose
    Where can I find a well-respected reference that details the proper handling of PID files on Unix? On Unix operating systems, it is common practice to “lock” a program (often a daemon) by use of a special lock file: the PID file. This is a file in a predictable location, often ‘/var/run/foo.pid’. The program is supposed to check when it starts up whether the PID file exists and, if the file does exist, exit with an error. So it's a kind of advisory, collaborative locking mechanism. The file contains a single line of text, being the numeric process ID (hence the name “PID file”) of the process that currently holds the lock; this allows an easy way to automate sending a signal to the process that holds the lock. What I can't find is a good reference on expected or “best practice” behaviour for handling PID files. There are various nuances: how to actually lock the file (don't bother? use the kernel? what about platform incompatibilities?), handling stale locks (silently delete them? when to check?), when exactly to acquire and release the lock, and so forth. Where can I find a respected, most-authoritative reference (ideally on the level of W. Richard Stevens) for this small topic?

    Read the article

  • Django : proper way to use model, duplicates!

    - by llazzaro
    Hello, I have a question about the proper, best way to manage the model. I am relative newbie to django, so I think I need to read more docs, tutorials,etc (suggestions for this would be cool!). Anyway, this is my question : I have a python web crawler, that is "connected" with django model. Crawling is done once a day, so its really common to find "duplicates". To avoid duplicates I do this : cars = Car.Objects.filter(name=crawledItem['name']) if len(cars) 0: #object already exists, update it car = cars[0] else: car = Car() #some non-relevant code here car.save() I want to know, if this is the proper/correct way to do it or its any "automatic" way to do it. Its possible to put the logic inside the Car() constructor also, should I do that? Thanks a lot!

    Read the article

  • Programming Concepts: What should be done when an exception is thrown?

    - by Dooms101
    This does not really apply to any language specifically, but if it matters I am using VB.NET in Visual Studio 2008. I can't seem to find anything really that useful using Google about this topic, but I was wondering what is common practice when an exception is thrown and caught but since it has been thrown the application cannot continue operating. For example I have exceptions that are thrown by my FileLoader class when a file cannot be found or when a file is deemed corrupt. The exception is only thrown within the class and is not handled really. If the error is detected, then the exception is thrown and whatever function is was thrown is basically quits. So in the code trying to create that object or call one of its members I use a Try...Catch statement. However, I was wondering, what should even do when this exception is caught? My application needs these files to be intact, and if they are not, the application is almost useless. So far I just pop up a message box telling the user their is an error and to reinstall. What else can I do, or better, what's common practice in these situations?

    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

  • Does it ever make sense to make a fundamental (non-pointer) parameter const?

    - by Scott Smith
    I recently had an exchange with another C++ developer about the following use of const: void Foo(const int bar); He felt that using const in this way was good practice. I argued that it does nothing for the caller of the function (since a copy of the argument was going to be passed, there is no additional guarantee of safety with regard to overwrite). In addition, doing this prevents the implementer of Foo from modifying their private copy of the argument. So, it both mandates and advertises an implementation detail. Not the end of the world, but certainly not something to be recommended as good practice. I'm curious as to what others think on this issue. Edit: OK, I didn't realize that const-ness of the arguments didn't factor into the signature of the function. So, it is possible to mark the arguments as const in the implementation (.cpp), and not in the header (.h) - and the compiler is fine with that. That being the case, I guess the policy should be the same for making local variables const. One could make the argument that having different looking signatures in the header and source file would confuse others (as it would have confused me). While I try to follow the Principle of Least Astonishment with whatever I write, I guess it's reasonable to expect developers to recognize this as legal and useful.

    Read the article

  • Number of characters recommended for a statement

    - by liaK
    Hi, I have been using Qt 4.5 and so do C++. I have been told that it's a standard practice to maintain the length of each statement in the application to 80 characters. Even in Qt creator we can make a right border visible so that we can know whether we are crossing the 80 characters limit. But my question is, Is it really a standard being followed? Because in my application, I use indenting and all, so it's quite common that I cross the boundary. Other cases include, there might be a error statement which will be a bit explanatory one and which is in an inner block of code, so it too will cross the boundary. Usually my variable names look bit lengthier so as to make the names meaningful. When I call the functions of the variable names, again I will cross. Function names will not be in fewer characters either. I agree a horizontal scroll bar shows up and it's quite annoying to move back and forth. So, for function calls including multiple arguments, when the boundary is reached I will make the forth coming arguments in the new line. But besides that, for a single statement (for e.g a very long error message which is in double quotes " " or like longfun1()->longfun2()->...) if I use an \ and split into multiple lines, the readability becomes very poor. So is it a good practice to have those statement length restrictions? If this restriction in statement has to be followed? I don't think it depends on a specific language anyway. I added C++ and Qt tags since if it might. Any pointers regarding this are welcome.

    Read the article

  • Best practice to query data from MS SQL Server in C Sharp?

    - by Bruno
    What is the best way to query data from a MS SQL Server in C Sharp? I know that it is not good practice to have an SQL query in the code. Is the best way to create a stored procedure and call it from C Sharp with parameters? using (var conn = new SqlConnection(connStr)) using (var command = new SqlCommand("StoredProc", conn) { CommandType = CommandType.StoredProcedure }) { conn.Open(); command.ExecuteNonQuery(); conn.Close(); }

    Read the article

  • Best tool for developing CSS positioning code

    - by alchemical
    What's the best way to develop CSS, in particular if it will play a role in formatting the page, etc. Is this best done by hand or with a particular editor? If by hand, how would you know the values needed to specify the positioning? If a tool is best, can VS2008/2010 do the job, or are there better alternatives. By the way, this is for an ASP.Net based web site.

    Read the article

  • Enumerations and String values in ASP.NET

    - by Jason
    I'm looking for some best practice advice on enumerations and retrieving an associated string value. Given this: public enum SerialKillers { TedBundy, EdGein, AlbertFish, GeorgeBush } What is the best way to get a related string value of the name? Eg. "Ted Bundy", given that the string value may not match the representation in the enumeration. eg "George W Bush" My current thinking is function accepting an enum and returning a string, but would that not mean hard coding the string values (which I prefer not to do)? Is using a resources file where the string can be retrieved via the enumeration too heavy handed? Should I accept the fact I am going to Hell for victimising Ted Bundy by associating him with George Bush?

    Read the article

  • JavaScript: Keeping track of eventListeners on DOM elements

    - by bobthabuilda
    What is the best way to keep track of eventListener functions on DOM elements? Should I add a property to the element which references the function like this: var elem = document.getElementsByTagName( 'p' )[0]; function clickFn(){}; elem.listeners = { click: [clickFn, function(){}] }; elem.addEventListener( 'click', function(e){ clickFn(e); }, false ); Or should I store it in my own variable in my code like below: var elem = document.getElementsByTagName( 'p' )[0]; function clickFn(){}; // Using window for the sake of brevity, otherwise I wouldn't =D // DOM elements and their listeners are referenced here in a paired array window.listeners = [elem, { click: [clickFn, function(){}] }]; elem.addEventListener( 'click', function(e){ clickFn(e); }, false ); Obviously the second method would be less obtrusive, but it seems it could get intensive iterating through all those possibilities. Which is the best way and why? Is there a better way?

    Read the article

  • Is simply upvoting the best answers to old questions the best way to get them off the unaswered list

    - by Cade Roux
    While the answers might not be the best or the question really doesn't have an answer, if none are upvoted or the person doesn't accept an answer, they sit and sit in the unanswered page. In cases which do have realistic answers, I've been voting up the best. Even if I combine the best answers into a better one, the questioners aren't upvoting, accepting or closing the questions anyway.

    Read the article

  • Onshore work methods V Offshore Supplier work methods - how to strike a balance?

    - by LadyCoconut
    Any advice on the best way to strike a balance between the work methods of an offshore supplier and the work methods of a new onshore team? We have an offshore supplier with about 2 years who have their own working practices and methods. I was bought in as the first onshore developer for my company with the view to vetting the code that comes in and putting together some best practices. Now from what I've seen there are lots of holes in their process (e.g. estimation, planning, code reviews, coding standards from about 10 years ago, no concept of mocking, refactoring etc). I need to be seen as a problem solver and not a problem creator but also I need to try and be somewhat forceful of what they are doing needs improving and at the end of the day they are a supplier. I would appreciate any advice. Thanks.

    Read the article

  • C# - Which is more efficient and thread safe? static or instant classes?

    - by Soni Ali
    Consider the following two scenarios: //Data Contract public class MyValue { } Scenario 1: Using a static helper class. public class Broker { private string[] _userRoles; public Broker(string[] userRoles) { this._userRoles = userRoles; } public MyValue[] GetValues() { return BrokerHelper.GetValues(this._userRoles); } } static class BrokerHelper { static Dictionary<string, MyValue> _values = new Dictionary<string, MyValue>(); public static MyValue[] GetValues(string[] rolesAllowed) { return FilterForRoles(_values, rolesAllowed); } } Scenario 2: Using an instance class. public class Broker { private BrokerService _service; public Broker(params string[] userRoles) { this._service = new BrokerService(userRoles); } public MyValue[] GetValues() { return _service.GetValues(); } } class BrokerService { private Dictionary<string, MyValue> _values; private string[] _userRoles; public BrokerService(string[] userRoles) { this._userRoles = userRoles; this._values = new Dictionary<string, MyValue>(); } public MyValue[] GetValues() { return FilterForRoles(_values, _userRoles); } } Which of the [Broker] scenarios will scale best if used in a web environment with about 100 different roles and over a thousand users. NOTE: Feel free to sugest any alternative approach.

    Read the article

  • Throwing exception vs returning null value with switch statement

    - by Greg
    So I have function that formats a date to coerce to given enum DateType{CURRENT, START, END} what would be the best way to handling return value with cases that use switch statement public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDate(date, "yyyy-MM-dd hh:mm:ss"); } ... default:throw new ("Something strange happend"); } } OR throw excpetion at the end public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDate(date, "yyyy-MM-dd hh:mm:ss"); } ... } //It will never reach here, just to make compiler happy throw new IllegalArgumentException("Something strange happend"); } OR return null public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDate(date, "yyyy-MM-dd hh:mm:ss"); } ... } return null; } What would be the best practice here ? Also all the enum values will be handled in the case statement

    Read the article

  • How to learn as a lone developer?

    - by fearofawhackplanet
    I've been lucky to work in a small team with a couple of experienced and knowledgeable developers for the first year of my career. I've learned a huge amount. But I'm now getting transferred within my company, and will be working on solo projects. I'll cope, but I know I'll make mistakes and won't always produce the best solutions without someone to guide me and review my output. I'm wondering if anyone has any tips in this situation. How can I keep learning? What's the best way to monitor and asses the quality of my work? How can I ensure that my career and skills don't stagnate?

    Read the article

  • I need an algorithm to find the best path

    - by user242635
    I need an algorithm to find the best solution of a path finding problem. The problem can be stated as: At the starting point I can proceed along multiple different paths. At each step there are another multiple possible choices where to proceed. There are two operations possible at each step: A boundary condition that determine if a path is acceptable or not. A condition that determine if the path has reached the final destination and can be selected as the best one. At each step a number of paths can be eliminated, letting only the "good" paths to grow. I hope this sufficiently describes my problem, and also a possible brute force solution. My question is: is the brute force is the best/only solution to the problem, and I need some hint also about the best coding structure of the algorithm.

    Read the article

  • Best Way to Include Debug Code?

    - by stormin986
    I am programming Android applications, and the best way here may or may not be the same as Java in general. I simply want to be able to set a debug flag that will only execute certain portions of code when it's set to true––equiv to C++ setting a preprocessor #define DEBUG and using #ifdef DEBUG. Is there an accepted or best way to accomplish this in Java? Right now I'm just going to set a variable in my Application object, but I don't imagine this is the best way.

    Read the article

< Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >