Search Results

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

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

  • What ways are there for cleaning an R environment from objects?

    - by Tal Galili
    I know I can use ls() and rm() to see and remove objects that exist in my environment. However, when dealing with "old" .RData file, one needs to sometimes pick an environment a part to find what to keep and what to leave out. What I would like to do, is to have a GUI like interface to allow me to see the objects, sort them (for example, by there size), and remove the ones I don't need (for example, by a check-box interface). Since I imagine such a system is not currently implemented in R, what ways do exist? What do you use for cleaning old .RData files? Thanks, Tal

    Read the article

  • Extension methods for encapsulation and reusability

    - by tzaman
    In C++ programming, it's generally considered good practice to "prefer non-member non-friend functions" instead of instance methods. This has been recommended by Scott Meyers in this classic Dr. Dobbs article, and repeated by Herb Sutter and Andrei Alexandrescu in C++ Coding Standards (item 44); the general argument being that if a function can do its job solely by relying on the public interface exposed by the class, it actually increases encapsulation to have it be external. While this confuses the "packaging" of the class to some extent, the benefits are generally considered worth it. Now, ever since I've started programming in C#, I've had a feeling that here is the ultimate expression of the concept that they're trying to achieve with "non-member, non-friend functions that are part of a class interface". C# adds two crucial components to the mix - the first being interfaces, and the second extension methods: Interfaces allow a class to formally specify their public contract, the methods and properties that they're exposing to the world. Any other class can choose to implement the same interface and fulfill that same contract. Extension methods can be defined on an interface, providing any functionality that can be implemented via the interface to all implementers automatically. And best of all, because of the "instance syntax" sugar and IDE support, they can be called the same way as any other instance method, eliminating the cognitive overhead! So you get the encapsulation benefits of "non-member, non-friend" functions with the convenience of members. Seems like the best of both worlds to me; the .NET library itself providing a shining example in LINQ. However, everywhere I look I see people warning against extension method overuse; even the MSDN page itself states: In general, we recommend that you implement extension methods sparingly and only when you have to. So what's the verdict? Are extension methods the acme of encapsulation and code reuse, or am I just deluding myself?

    Read the article

  • Good input validation loop using cin - C++

    - by Alex
    Hi there, I'm in my second OOP class, and my first class was taught in C#, so I'm new to C++ and currently I am practicing input validation using cin. So here's my question: Is this loop I constructed a pretty good way of validating input? Or is there a more common/accepted way of doing it? Thanks! Code: int taxableIncome; int error; // input validation loop do { error = 0; cout << "Please enter in your taxable income: "; cin >> taxableIncome; if (cin.fail()) { cout << "Please enter a valid integer" << endl; error = 1; cin.clear(); cin.ignore(80, '\n'); } }while(error == 1);

    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

  • Any difference in compiler behavior for each of these snippets?

    - 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 :) EDIT: values 0x0001 and 0x0002 are only example. There coudl be any 2 byte value instead. Thank you in advance!

    Read the article

  • Most efficient way to save tile data of an isometric game

    - by Harmen
    Hello, I'm working on an isometric game for fast browsers that support <canvas>, which is great fun. To save information of each tile, I use a two-dimensional array which contains numbers representing a tile ID, like: var level = [[1, 1, 1, 2, 1, 0], [0, 1, 1, 2, 0, 1], [0, 1, 1, 2, 1, 1]]; var tiles = [ {name: 'grass', color: 'green'}, {name: 'water', color: 'blue'}, {name: 'forest', color: 'ForestGreen'} ]; So far it works great, but now I want to work with heights and slopes like in this picture: For each tile I need to save it's tile ID, height and information about which corners are turned upward. I came up with a simple idea about a bitwise representation of all four corners, like this: 1011 // top, bottom and left corner turned up My question is: what is the most efficient way to save these three values for each cell? Is it possible to save these three values as one integer?

    Read the article

  • QT/PyQT best practice for using QT Designer

    - by pierocampanelli
    What is your development approach with QT/PYQT and QT Designer ? Are you doing this: Put all components on the panel (without any layout) and arrange them Put components in layout (Align Vertically/Horizontally/Form/Grid) Generate UI file and start coding how do you manage when you have custom widget ? For example when you have to fine tune behaviour of a QButton or QLineEdit ? Is it possible to add this custom widget to designer?

    Read the article

  • How many address fields would you use for a UK database?

    - by Draemon
    Address records are probably used in most database, but I've seen a number of slightly different sets of fields used to store them. The number of fields seems to vary from 3-7, and sometimes all fields are simple labelled address1..addressN, other times given specific meaning (town, city, etc). This is UK specific, though I'm open to comments about the rest of the world too. Here you need the first line of the address (actually just the number) and the post code to identify the address - everything else is mostly an added bonus. I'm currently favouring: Address 1 Address 2 Address 3 Town County Post Code We could add Country if we ever needed it (unlikely). What do you think? Is this too little, too much?

    Read the article

  • Guidelines for good webcrawler 'Etiquette'

    - by Harry
    I'm building a search engine (for fun) and it has just struck me that potentially my little project might wreak havok by clicking on ads and all sorts of problems. So what are the guidelines for good webcrawler 'Etiquette'? Things that spring to mind: Observe Robot.txt instructions Limit the number of simultaneous requests to the same domain Don't follow ad links? Stopping the crawler from clicking on ads - This one is particularly on my mind at the moment... how do i stop my bot from 'clicking' on ads? if it is going straight to the url in the ad is it counted as a click?

    Read the article

  • Time/resource allocation on a Stylish vs. Functional user interface

    - by jasonk
    When developing applications how much focus/time do you place on an application’s style vs. functionality. Battleship gray apps drive me insane. On the other hand maximizing a business application’s "style" can tax time and financial resources. Applications need to be appealing to resell or meet basic customer expectations, but defining a healthy medium can be difficult. What would you say are reasonable "standards" for allocating develop time/resources should be dedicated to stylizing a business application?

    Read the article

  • Rank Source Control Options-VSS vs CVS vs none vs your own hell

    - by Roman A. Taycher
    It seems like a lot of people here and on many programmer wikis/blogs/ect. elsewhere really dislike VSS. A lot of people also have a serious dislike for cvs. In many places I have heard a lot of differing opinions on whether or not using VSS or cvs is better or worse then using no source control, please rate the worst and explain why!!!!! you rated them this way. Feel free to throw in your own horrible system in the rankings. If you feel it depends on the circumstances try to explain the some of the different scenarios which lead to different rankings. (note:I see a lot of discussion of what is better but little of what is worse.) second note: while both answers are nice I'm looking less for good replacements and more for a comparison of which is worse and more importantly why!

    Read the article

  • Password reset by email without a database table

    - by jpatokal
    The normal flow for resetting a user's password by mail is this: Generate a random string and store it in a database table Email string to user User clicks on link containing string String is validated against database; if it matches, user's pw is reset However, maintaining a table and expiring old strings etc seems like a bit of an unnecessary hassle. Are there any obvious flaws in this alternative approach? Generate a MD5 hash of the user's existing password Email hash string to user User clicks on link containing string String is validated by hashing existing pw again; if it matches, user's pw is reset Note that the user's password is already stored in a hashed and salted form, and I'm just hashing it once more to get a unique but repeatable string. And yes, there is one obvious "flaw": the reset link thus generated will not expire until the user changes their password (clicks the link). I don't really see why this would be a problem though -- if the mailbox is compromised, the user is screwed anyway.

    Read the article

  • What are the common programming mistakes in Python?

    - by Paul McGuire
    I was about to tag the recent question in which the OP accidentally shadowed the builtin operator module with his own local operator.py with the "common-mistakes" tag, and I saw that there are a number of interesting questions posted asking for common mistakes to avoid in Java, Ruby, Scala, Clojure, .Net, jQuery, Haskell, SQL, ColdFusion, and so on, but I didn't see any for Python. For the benefit of Python beginners, can we enumerate the common mistakes that we have all committed at one time or another, in the hopes of maybe steering a newbie or two clear of them? (In homage to "The Princess Bride", I call these the Classic Blunders.) If possible, a little supporting explanation on what the problem is, and the generally accepted resolution/workaround, so that the beginning Pythoner doesn't read your answer and say "ok, that's a mistake, how do I fix it?"

    Read the article

  • Best architecture for accessing secondary database

    - by fearofawhackplanet
    I'm currently developing an app which will use a Linq to SQL (or possibly EF) data access layer. We already have a database which holds all our Contacts information, but there is currently no API around this. I need to interact with this DB from the new app to retrieve contact details. I can think of two ways I could do this - 1) Develop a suite of web services against the contacts database 2) Write a Linq to SQL (or EF) DAL and API against the contacts database I will probably be developing several further apps in the future which will also need access to the Contacts data. Which would generally be the prefered method? What are the points I need to consider? Am I even asking a sensible question, or am I missing something obvious?

    Read the article

  • Increasing your efficiency during programming

    - by Tom
    Yeah, yeah, I know, it is a little bit of offtopic, but let's try. So, I want to increase my efficiency during my programming as much as possible to programme as fast and sensibly as possiblle. What do you do before starting coding? Drink a lot of coffee, energy drinks? Do you listen to music during programming or you keep quite? Share your ideas.

    Read the article

  • What should I name my files with generic class definitions?

    - by Tomas Lycken
    I'm writing a couple of classes that all have generic type arguments, but I need to overload the classes because I need a different number of arguments in different scenarios. Basically, I have public class MyGenericClass<T> { ... } public class MyGenericClass<T, K> { ... } public class MyGenericClass<T, K, L> { ... } // it could go on forever, but it won't... I want them all in the same namespace, but in one source file per class. What should I name the files? Is there a best practice?

    Read the article

  • Generic data input form in asp.net mvc application

    - by Diego
    Hello, I have an application that have EF 16 classes that share this information: They all are classes only with a key field and a description. I think it should be a waste if I make a controller with just 1 method just to present a form to fill these classes info, then I was thinking in to make a generic form(with key, description) and dynamically fill the right class through a sort of selection the selected info in any way, any good suggestion or pattern to do that? Where the generic methods should be located.

    Read the article

  • keep viewdata on RedirectToAction

    - by Thomas Stock
    [AcceptVerbs(HttpVerbs.Post)] public ActionResult CreateUser([Bind(Exclude = "Id")] User user) { ... db.SubmitChanges(); ViewData["info"] = "The account has been created."; return RedirectToAction("Index", "Admin"); } This doesnt keep the "info" text in the viewdata after the redirectToAction. How would I get around this issue in the most elegant way? My current idea is to put the stuff from the Index controlleraction in a [NonAction] and call that method from both the Index action and in the CreateUser action, but I have a feeling there must be a better way. Thanks.

    Read the article

  • If terminating a hung thread is a good idea, how do I do it safely?

    - by Steve
    My Delphi program relies heavily on Outlook automation. Outlook versions prior to 2007-SP2 tend to get stuck in memory due to badly written addins and badly written Outlook code. If Outlook is stuck, calling CreateOleObject('Outlook.Application') or GetActiveObject ... doesn't return and keeps my application hanging till Outlook.exe is closed in the task manager. I've thought of a solution, but I'm unsure whether it's good practice or not. I'd start Outlook with CreateOleObject in a separate thread, wait 10 seconds in my main thread and if Outlook hangs (CreateOleObject doesn't return), offer the user to kill the Outlook.exe process from my program. But since I don't want to force the user to kill the Outlook.exe process, as an alternative I also need a way to kill the new thread in my program which keeps hanging now. Is this good practice? How can I terminate a hanging thread in Delphi without leaking memory?

    Read the article

  • How to handle management trying to interfere with the project (including architecture decision)

    - by Zwei Steinen
    I feel this is not a very good question to post on SO, but I need some advice from experienced developers... (I'm a second year developer) I guess this is a problem to many, many projects, but in our case, it is getting intense. There were so much interference from people that don't know a bit about software development, that our development came to an almost complete stop. We had to literary escape to another location to get any useful job done. Now we were happily producing results, but then I get a request for a "meeting" and it's them again. I have a friendly relationship with them, but I feel very daunted at the thought of talking about non-sense all over again. Should I be firm and tell them to shut up and wait for our results? Or should I be diplomatic and create an illusion they are making a positive contribution or something?? My current urge is to be unfriendly and murmur some stuff so they will give up or something. What would you do if you were in this situation?

    Read the article

  • Static classes in PHP via abstract keyword?

    - by Boldewyn
    According to the PHP manual, a class like this: abstract class Example {} cannot be instantiated. If I need a class without instance, e.g. for a registry pattern: class Registry {} // and later: echo Registry::$someValue; would it be considered good style to simply declare the class as abstract? If not, what are the advantages of hiding the constructor as protected method compared to an abstract class? Rationale for asking: As far as I see it, it could a bit of feature abuse, since the manual refers to abstract classes more as like blueprints for later classes with instantiation possibility.

    Read the article

  • Is my method for avoiding dynamic_cast<> faster than dynamic_cast<> itself ?

    - by ereOn
    Hi, I was answering a question a few minutes ago and it raised to me another one: In one of my projects, I do some network message parsing. The messages are in the form of: [1 byte message type][2 bytes payload length][x bytes payload] The format and content of the payload are determined by the message type. I have a class hierarchy, based on a common class Message. To instanciate my messages, i have a static parsing method which gives back a Message* depending on the message type byte. Something like: Message* parse(const char* frame) { // This is sample code, in real life I obviously check that the buffer // is not NULL, and the size, and so on. switch(frame[0]) { case 0x01: return new FooMessage(); case 0x02: return new BarMessage(); } // Throw an exception here because the mesage type is unknown. } I sometimes need to access the methods of the subclasses. Since my network message handling must be fast, I decived to avoid dynamic_cast<> and I added a method to the base Message class that gives back the message type. Depending on this return value, I use a static_cast<> to the right child type instead. I did this mainly because I was told once that dynamic_cast<> was slow. However, I don't know exactly what it really does and how slow it is, thus, my method might be as just as slow (or slower) but far more complicated. What do you guys think of this design ? Is it common ? Is it really faster than using dynamic_cast<> ? Any detailed explanation of what happen under the hood when one use dynamic_cast<> is welcome !

    Read the article

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