Search Results

Search found 12660 results on 507 pages for 'programming pearls'.

Page 78/507 | < Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >

  • Do most programmers copy and paste code?

    - by John MacIntyre
    I learned very early on that cutting & pasting somebody else's code takes longer in the long run that writing it yourself. In my opinion unless you really understand it, cut & paste code will probably have issues which will be a nightmare to resolve. Don't get me wrong, I mean finding other peoples code and learning from it is essential, but we don't just paste it into our app. We rewrite the concepts into our app. But I'm constantly hearing about people who cut & paste, and they talk about it like it's common practice. I also see comments by others which indicate it's common practice. So, do most programmers cut & paste code?

    Read the article

  • Best exception handling practices or recommendations?

    - by user828584
    I think the two main problems with my programs are my code structure/organization and my error handling. I'm reading Code Complete 2, but I need something to read for working with potential problems. For example, on a website, if something can only happen if the user tampers with data via javascript, do you write for that? Also, when do you not catch errors? When you write a class that expects a string and an int as input, and they aren't a string and int, do you check for that, or do you let it bubble up to the calling method that passed incorrect parameters? I know this is a broad topic that can't be answered in a single answer here, so what I'm looking for is a book or resource that's commonly accepted as teaching proper exception handling practice.

    Read the article

  • Low coupling and tight cohesion

    - by hidayat
    Of course it depends on the situation. But when a lower lever object or system communicate with an higher level system, should callbacks or events be preferred to keeping a pointer to higher level object? For example, we have a world class that has a member variable vector<monster> monsters. When the monster class is going to communicate with the world class, should I prefer using a callback function then or should I have a pointer to the world class inside the monster class?

    Read the article

  • Can somebody guide me asto how I can make a game for playing cards [closed]

    - by user2558
    In college me and my friends use to play cards all the time. I want to make a game for that. It's quite similar to hearts, a kind of modified hearts which we made up. I want to make a multiplayer game which could be played over the internet. Plus there should also be an option for computer to play if less players availiable at the time. I don't want to make a exe. I want to play in browser. How should I go about it.

    Read the article

  • Get entities ids from two similar collections using one method

    - by Patryk Roszczyniala
    I've got two lists: List<Integer, ZooEntity> zoos; List<Integer, List<ZooEntity>> groupOfZoos; These operations will return collections of values: Collection<ZooEntity> cz = zoos.values(); Collection<List<ZooEntity>> czList = groupOfZoos.values(); What I want to achieve is to get list of all zoo ids. List<Integer> zooIds = cz ids + czList ids; Of course I can create two methods to do what I want: public List<Integer> getIdsFromFlatList(Collection<ZooEntity> list) { List<Integer> ids = new ArrayList<Integer>(); for (ZooEntity z : list) { ids.add(z.getId()); } return ids; } public List<Integer> getIdsFromNestedList(Collection<List<ZooEntity>> list) { List<Integer> ids = new ArrayList<Integer>(); for (List<ZooEntity> zList : list) { for (ZooEntity z : zList) { ids.add(z.getId()); } } return ids; } As you can see those two methods are very similar and here is my question: Is it good to create one method (for example using generics) which will get ids from those two lists (zoos and groupOfZoos). If yes how it should look like? If no what is the best solution? BTW. This is only the example. I've got very similar problem at job and I want to do it in preety way (I can't change enities, I can change only getIds...() methods).

    Read the article

  • Should my colleagues review each others code from source control system?

    - by Daniel Excinsky
    Hi everybody. So that's my story: one of my colleagues uses to review all the code, hosted to revision system. I'm not speaking about adequate review of changes in parts that he belongs to. He watches the code file to file, line to line. Every new file and every modified. I feel just like being spied on! My guess is that if code was already hosted to control system, you should trust it as workable at least. My question is, maybe I'm just too paranoiac and practice of reviewing each others code is good? P.S: We're team of only three developers, and I fear that if there will be more of us, colleague just won't have time to review all the the code we'll write.

    Read the article

  • How you return to a code when you don't remember what you were doing?

    - by speeder
    Well, I have some problems with procrastination and whatnot, but those get infinitely worse, when I cannot remember what I should be doing. I mean, I know my project, I wrote 100% of the code so far, and I knew more or less what I was doing, but I don't remember exactly what, I don't remember what file I was editing and why. How I get back on track? (because right now my technique of opening the source code and staring at it is not working)

    Read the article

  • How to recover from finite-state-machine breakdown?

    - by Earl Grey
    My question may seems very scientific but I think it's a common problem and seasoned developers and programmers hopefully will have some advice to avoid the problem I mention in title. Btw., what I describe bellow is a real problem I am trying to proactively solve in my iOS project, I want to avoid it at all cost. By finite state machine I mean this I have a UI with a few buttons, several session states relevant to that UI and what this UI represents, I have some data which values are partly displayed in the UI, I receive and handle some external triggers (represented by callbacks from sensors). I made state diagrams to better map the relevant scenarios that are desirable and alowable in that UI and application. As I slowly implement the code, the app starts to behave more and more like it should. However, I am not very confident that it is robust enough. My doubts come from watching my own thinking and implementation process as it goes. I was confident that I had everything covered, but it was enough to make a few brute tests in the UI and I quickly realized that there are still gaps in the behavior ..I patched them. However, as each component depends and behaves based on input from some other component, a certain input from user or some external source trigers a chain of events, state changes..etc. I have several components and each behave like this Trigger received on input - trigger and its sender analyzed - output something (a message, a state change) based on analysis The problem is, this is not completely selfcontained, and my components (a database item, a session state, some button's state)...COULD be changed, influenced, deleted, or otherwise modified, outside the scope of the event-chain or desirable scenario. (phone crashes, battery is empty phone turn of suddenly) This will introduce a nonvalid situation into the system, from which the system potentially COULD NOT BE ABLE to recover. I see this (althought people do not realize this is the problem) in many of my competitors apps that are on apple store, customers write things like this "I added three documents, and after going there and there, i cannot open them, even if a see them." or "I recorded videos everyday, but after recording a too log video, I cannot turn of captions on them.., and the button for captions doesn't work".. These are just shortened examples, customers often describe it in more detail..from the descriptions and behavior described in them, I assume that the particular app has a FSM breakdown. So the ultimate question is how can I avoid this, and how to protect the system from blocking itself? EDIT I am talking in the context of one viewcontroller's view on the phone, I mean one part of the application. I Understand the MVC pattern, I have separate modules for distinct functionality..everything I describe is relevant to one canvas on the UI.

    Read the article

  • Best way to indicate more results available

    - by Alex Stangl
    We have a service to return messages. We want to limit the number returned, either allowing the caller to specify the max number to return, or else to use an internal hard limit. We also have thought it would be nice to include in the response whether more messages are available. The "best" way to go about this is not clear. Here are some ideas so far: Only set the "more messages" indicator if the user did not specify a max limit, and the internal max limit was hit. Same as #1 except that "more messages" indicator set regardless of whether the internal hard limit is hit, or the user-specified limit is hit. Same as #1 (or #2) except that we internally read limit + 1 records, but only return limit records, so we know "for sure" there is at least one additional message rather than "maybe" there are additional messages. Do away with the "more messages" flag, as it is confusing and unnecessary. Instead force the user to keep calling the API until it returns no messages. Change "more messages" indicator to something more akin to an EOF indicator, only set when the last message is known to have been retrieved and returned. What do you think is the best solution? (Doesn't have to be one of the above choices.) I searched and couldn't find a similar question already asked. Hopefully this is not "too subjective".

    Read the article

  • What's a good data structure solution for a scene manager in XNA?

    - by tunnuz
    Hello, I'm playing with XNA for a game project of myself, I had previous exposure to OpenGL and worked a bit with Ogre, so I'm trying to get the same concepts working on XNA. Specifically I'm trying to add to XNA a scene manager to handle hierarchical transforms, frustum (maybe even occlusion) culling and transparency object sorting. My plan was to build a tree scene manager to handle hierarchical transforms and lighting, and then use an Octree for frustum culling and object sorting. The problem is how to do geometry sorting to support transparencies correctly. I know that sorting is very expensive if done on a per-polygon basis, so expensive that it is not even managed by Ogre. But still images from Ogre look right. Any ideas on how to do it and which data structures to use and their capabilities? I know people around is using: Octrees Kd-trees (someone on GameDev forum said that these are far better than Octrees) BSP (which should handle per-polygon ordering but are very expensive) BVH (but just for frustum and occlusion culling) Thank you Tunnuz

    Read the article

  • How important do you find exception safety to be in your C++ code?

    - by Kai
    Every time I consider making my code strongly exception safe, I justify not doing it because it would be so time consuming. Consider this relatively simple snippet: Level::Entity* entity = new Level::Entity(); entity->id = GetNextId(); entity->AddComponent(new Component::Position(x, y)); entity->AddComponent(new Component::Movement()); entity->AddComponent(new Component::Render()); allEntities.push_back(entity); // std::vector entityById[entity->id] = entity; // std::map return entity; To implement a basic exception guarantee, I could use a scoped pointer on the new calls. This would prevent memory leaks if any of the calls were to throw an exception. However, let's say I want to implement a strong exception guarantee. At the least, I would need to implement a shared pointer for my containers (I'm not using Boost), a nothrow Entity::Swap for adding the components atomically, and some sort of idiom for atomically adding to both the Vector and Map. Not only would these be time consuming to implement, but they would be expensive since it involves a lot more copying than the exception unsafe solution. Ultimately, it feels to me like that time spent doing all of that wouldn't be justified just so that the a simple CreateEntity function is strongly exception safe. I probably just want the game to display an error and close at that point anyway. How far do you take this in your own game projects? Is it generally acceptable to write exception unsafe code for a program that can just crash when there is an exception?

    Read the article

  • Any language where every class instance is a class too?

    - by Dokkat
    Taking inspiration from Javascript prototypes, I had the idea of a language where every instance can be used as a class. Before I potentially reinvent the wheel, I would like to ask if there is a language already using this concept: //To declare a Class, extend the base class (in this case, Type) Type(Weapon,{price:0}); //Same syntax to inherit; simply extend the parent: Weapon(Sword,{price:3}); Weapon(Axe,{price:4}); Sword(Katana,{price:7}); Sword(Dagger,{price:3}); //And the same to create an instance: Katana(myKatana,{nickname:"Leon"}); myKatana.price; // 7 myKatana.nickname; // Leon // An operator to return children of a class; Sword_; // [Katana, Dagger] // An operator to return array of descendants; Sword__; // [Katana, Dagger, myKatana] // An operator to return array of parents; Sword^; // Weapon // Arrays can be used as elements Sword__.price += 1; //increases price of Sword's descendants by 1 mySword.price; //8 // And to access specific element (using its name instead of index) var name = "mySword" Katana_[name]; // [mySword] Katana_[name].nickname; // Leon Has this kind of approach been already studied/implemented?

    Read the article

  • Modifying Contiguous Time Periods in a History Table

    Alex Kuznetsov is credited with a clever technique for creating a history table for SQL that is designed to store contiguous time periods and check that these time periods really are contiguous, using nothing but constraints. This is now increasingly useful with the DATE data type in SQL Server. The modification of data in this type of table isn't always entirely intuitive so Alex is on hand to give a brief explanation of how to do it.

    Read the article

  • Something similar to Objective-C categories in other languages?

    - by adig
    I understand Objective-C categories and how they become useful, but I always have a hard time explaining the concept to other programmers that are not familiar with Objective C. Maybe I'm just bad at explaining things, but I was thinking at another way to explain it by comparing to similar features offered by other (more popular) languages. (ex : I can explain the similarities between Objective C protocols and Java Interfaces) Any examples similar to Categories ?

    Read the article

  • Sell Yourself! Presentation

    - by Mike C
    Thanks to everyone who attended my "Sell Yourself!" presentation at SQLSaturday #61 in Washington, D.C., and thanks to NOVA SQL for setting up the event! I'm uploading the presentation deck here in PDF, original length, with new materials (I had to cut some slides out due to time limits). This deck includes a new section on recruiters and a little more information on the resume. BTW, if you're rewriting your resume I highly recommend the book Elements of Resume Style by S. Bennett. I've used it as...(read more)

    Read the article

  • Writing use cases for XML mapping scenarios between two different systems

    - by deepak_prn
    I am having some trouble writing use cases for XML mapping after a certain trigger invoked by the system. For example, one of the scenarios goes: the store cashier sells an item, the transaction data is sent to Data management system. Now, I am writing a functional design for the scenario which deals with mapping XML fields between our system and the data management system. Question : I was wondering if some one had to deal with writing use cases or extension use cases for mapping XML fields between two systems? (There is no XSLT involved) and if you used a table to represent the fields mapping (example is below) or any other visualization tool which does not break the bank ? I searched many questions on SO and here but nothing came close to my requirement.

    Read the article

  • Getting rid of getting stuck often [closed]

    - by Pankaj Upadhyay
    I have been working with C# and .NET for around 2-3 years. But, still i get stuck too often. My project includes few simple websites(asp.net) in the early parts and then a desktop application for cotton transaction management(wpf). And right now, I am building a price compare website (asp.net MVC). Along the lines, I have read quite few books on C# and .NET, but still I get stuck very often. What pisses me is that the problems I get stuck in aren't very typical or hard. You can get a better idea by visiting my questions page on SO. After looking at my question lists, do you also feel that my basis or knowledge as a programmer are weak ? If so, How can i find a remedy to this problem ? And How can I stop getting stuck too often for simpler problems.

    Read the article

  • How is dependency inversion related to higher order functions?

    - by Gulshan
    Today I've just seen this article which described the relevance of SOLID principle in F# development- F# and Design principles – SOLID And while addressing the last one - "Dependency inversion principle", the author said: From a functional point of view, these containers and injection concepts can be solved with a simple higher order function, or hole-in-the-middle type pattern which are built right into the language. But he didn't explain it further. So, my question is, how is the dependency inversion related to higher order functions?

    Read the article

  • Why C++ is an abomination [closed]

    - by Chander Shivdasani
    Possible Duplicate: Why do so many people dislike C++? I was reading the blog by Peter Seibel (Author of Coders at Work) where brilliant programmers like Ken Thompson, Joshua Bloch and Guy Steele have despised c++ to no end. What is it in C++ that people hate so much? And despite so much hate towards it, companies like Google are still using it, and some of the programmers who snubbed C++ have worked or are already working at Google. So, what is it in the language that despite so much hate from top programmers, it's still used at most of the places? I haven't really used C++ beyond academic projects, so i don't know much about the disadvantages of the language. What do programmers here think about it? --Chander

    Read the article

  • Making game constants/tables available to game logic classes/routines in a modular manner

    - by Extrakun
    Suppose I have a game where there are several predefined constants and charts (a XP chart, cost of goods and so on). Those could be defined at runtime, or load from files at start-up. The question is how should those logic routines access the constants and charts? For example, I could try using global variables, but that cause all classes relying on the variables to be tightly coupled with them.

    Read the article

  • Should a programmer take writing lessons to enhance code expressiveness?

    - by Jose Faeti
    Given that programmers are authors and write code to express abstract thoughts and concepts, and good code should be read by other programmers without difficulties and misunderstandings, should a programmer take writing lessons to write better code? Abstracting concepts and real world problems/entities is an important part of writing good code, and a good mastery of the language used for coding should allow the programmer to express his thoughts more easily, or in a better way. Besides, when trying to write or rewrite some code to make it better, much time can be spent in deciding the names for functions, variables or data structures. I think this could also help to avoid writing code with more than one meaning, often cause of misunderstanding between different programmers. Code should always express clearly its function unambiguously.

    Read the article

  • Finding Stuff in SQL Server Database DDL

    You'd have thought that nothing would be easier than using SQL Server Management Studio (SSMS) for searching through the DDL for both the names and definitions of the structural metadata of your databases, for the occurrence of a particular string of letters. Not so easy, it turns out, though Phil Factor is able to come up with various methods for various purposes.

    Read the article

  • Starting to make 2D games in C++

    - by Ashley
    I'm fairly experienced with C and C#, but I've only ever created console/windows applications. I'm also experienced with AS3 and I've made some flash games. I want to make proper 2D games in C++, but I have no idea where to begin with graphics. There are entire books devoted to game development in C++ that only work with console applications and I'm finding the lack of resources and tutorials for proper 2D games frustrating... I'm also not particularly interested in using existing engines because I want total control of what I create. I've heard of the Allegro library; is it something important/popular that I should look into? How will I use DirectX? Any resources or links to tutorials or information is greatly appreciated.

    Read the article

  • Scaling Down Pixel Art?

    - by Michael Stum
    There's plenty of algorithms to scale up pixel art (I prefer hqx personally), but are there any notable algorithms to scale it down? In my case, the game is designed to run at 1280x720, but if someone plays at a lower resolution I want it to still look good. Most Pixel Art discussions center around 320x200 or 640x480 and upscaling for use in console emulators, but I wonder how modern 2D games like the Monkey Island Remake look good on lower resolutions? (Ignoring the options of having multiple versions of assets (essentially, mipmapping))

    Read the article

  • GLSL, is it possible to offsetting vertices based on height map colour?

    - by Rob
    I am attempting to generate some terrain based upon a heightmap. I have generated a 32 x 32 grid and a corresponding height map - In my vertex shader I am trying to offset the position of the Y axis based upon the colour of the heightmap, white vertices being higher than black ones. //Vertex Shader Code #version 330 uniform mat4 modelMatrix; uniform mat4 viewMatrix; uniform mat4 projectionMatrix; uniform sampler2D heightmap; layout (location=0) in vec4 vertexPos; layout (location=1) in vec4 vertexColour; layout (location=3) in vec2 vertexTextureCoord; layout (location=4) in float offset; out vec4 fragCol; out vec4 fragPos; out vec2 fragTex; void main() { // Retreive the current pixel's colour vec4 hmColour = texture(heightmap,vertexTextureCoord); // Offset the y position by the value of current texel's colour value ? vec4 offset = vec4(vertexPos.x , vertexPos.y + hmColour.r, vertexPos.z , 1.0); // Final Position gl_Position = projectionMatrix * viewMatrix * modelMatrix * offset; // Data sent to Fragment Shader. fragCol = vertexColour; fragPos = vertexPos; fragTex = vertexTextureCoord; } However the code I have produced only creates a grid with none of the y vertices higher than any others.

    Read the article

< Previous Page | 74 75 76 77 78 79 80 81 82 83 84 85  | Next Page >