instruction
stringlengths
34
19.9k
In my current code project, there is an awful lot of constant strings I use to print out error messages. Hardcoding such strings is generally considered to be bad practice. Now I'm searching for a "clean way" to include these strings in my program. Therefore I've written a "constants.h" and "constants.cpp" which looks ...
I am trying to create a voting system like Stack Exchange. Should I create a table and insert values like following and then sum up the "vote" or there are some better ways to do this? Table name: vote id userid article_id vote 1 1001 12 1 2 1002 12 -1 3 1003 12 1 4 ...
This question is based on some testing I've done recently in order to better understand SQL indexing system. Table with 500k entries, InnoDB engine This is a simple select query on a varchar field. The name column is not indexed. After indexing these are the results: All good until this point. When I'm trying to plac...
I often catch myself doing code unnecessarily complicated (sad but true). Is there any set of rules, discipline, etc to help avoid that? (excluding the KISS principle, because I know it but often forget when it comes to the real code :)
I'm not sure which SE site this belonged on, so I figured I'd try this one. Whenever I browser the Mac Developer Library at developer.apple.com, on the top right of the window, there's a link for a PDF version. Has anyone ever downloaded them all and combined them into one file? I want to download the Mac Developer Li...
I am building a lot of client-side heavy SPA-like apps with VS2010 and MVC3/4. VS2010 Javascript/HTML/CSS editing (mostly javascript) is interminably slow and sluggish. I'd love to use something like JetBrains' WebStorm to edit my .CSHTML files (with embedded javascript, etc. because I am using RAzor to pop in URL na...
I'm building a messaging solution with the followingsetup: all the messages are saved on a DB, two or more reader processes will read from this DB and send data to other process(es) which will send it over the network. My approach is depicted below, The following have 4 sender process with 4 fifos, and 2 readers with 2...
Say you have a function f that is or contains a critical section. How would you unit test that only one thread can run it at once, that it doesn't have race conditions, and that it doesn't cause a deadlock, etc...?
Is there a "modern" bison and flex equivalent which does not require the JVM or .NET or similar "heavy" runtimes? By modern, I mean for example Antlr and another one in Java I saw but forgot the name of. (I know that for instance Antlr has a C target, but I am toying with the idea of embedding the compiler generator in...
When selling software online what's the most suitable/secure way to provide activation in order to get rid of pirates copies of the software? Is there any well-known software for this purpose?
I'm developing a simple CMS which I'd like to make it open source. For the file structure, do you think it's safe to use names like: AppData FileUploads instead of app-data file-uploads ? Because I heard some servers have problems with the camelCase.
I'm designing a system which listens to JSON RPC calls from clients, piles them up inside a list, and if the list gets full it will store them in a DB and keep receiving calls. My original plan is to listen to the RPC calls from Perl with the JSON-RPC and put them in an array. The clients do some long polling in anothe...
I recently saw a recruiting page for a software company where one of the requirements was "Excellent knowledge of C++." Now, I know this somehow implies as expert knowledge of C++, but where exactly does expert knowledge fit into. Is it the knowledge and experience of (let's say) eight years of programming in the langu...
First, I realize this question may by somewhat long and vague and I apologize for this. This is probably a basic problem with a short name to anybody who's "got it", but as I find myself lacking in this regard, please bear with me in describing the problem. I've been doing programming in this way or the other since I w...
The Clean language uses uniqueness types to handle I/O in a purely functional setting. Why did the Haskell committee go with monads instead? Were there other proposals for handling state that the committee investigated but decided against? Note: I'm not looking for a holy war between monads and other forms of computing...
I am new to this and also a new 19 year old PHP developer that just got hired so I am unsure as to how this works. Many companies when developing their websites keep their sites hidden from being indexed. What are some ways html5/css and then php/mysql work is hidden from search engines? If I am not wrong, these are...
I am reading about a case study about a team that estimates tasks or "story points" as they call them based on the effort needed to complete them. What the units are these "story points" estimated in? I believe this notion of "story points" stems from a process called "agile development."
The feature to implement is to allow a user to select items and apply data update in bulk. It is very similar to JIRA's ability to bulk update a list of selected issues. In my case: I iterate over the items, and for each item, I simply call the existing method used for individually updating an item. Take note, I c...
Many of us, including me, started their programming life with programs written on home computers, something like 10 PRINT "ENTER RADIUS" 20 INPUT R 30 PRINT "CIRCUMFERENCE="; 2 * R * PI 40 PRINT "AGAIN?" 50 INPUT A$ 60 IF A$="Y" THEN GOTO 10 70 END Of course, the line-number based BASIC was prone for creating spagetti...
I have read in numerous places that when developing a product you need to take a different approach to when you are developing a project (think "contract" work). Some differences are: 1) There is no definitive user, but a "user-base". 2) You need to develop the minimal marketable feature set. 3) Scheduling needs to be...
while (1) { if (1+1==2) { print "Yes, you paid attention in Preschool!"; } else { print "Wait... I thought 1+1=2"; } } As a developer, we all have to use loops very frequently. We know that. What I was wondering was, who thought of the idea to have loops? What language intr...
Ok not really sure if I'm right. I only recently learned that I needed to have contravariant interface to be able to pass that interface as a parameter in C# and this feature was only added in .NET 4.0. So obviously there is some reason you can't do this Covariant or Invariant interfaces and it probably has something t...
I'm wondering if there is a tool that can generate a dependency graph between C language object files and then analyze how to turn that graph into a DAG by modifying code that creates cycles, moving it to other source files. I've drawn a dependency graph by hand and I could probably make one by using makedepend or some...
I was wanting to create a graph similar to this in C++: The one I will implement will have more edges and vertices, but will use this triangle style. I was wanting to create something that I could perform various search algorithms on in order to find shortest paths to selected vertices (or longest without loops etc.)....
I'd like to try programming with punch cards once in my life. How can I do this? I'm in my 30s, and grew up entirely in the PC era, programming on computers with screens and keyboards. I want to experience the way my father and grandfather used to work. I imagine the hardware (and probably the cards themselves) are no ...
...and unmarshalling/deserializing? Wikipedia's explanation leaves me none-the-wiser! I'm a Java programmer, in case the terminology is used differently in different languages.
Background: I'm an experienced Java developer, know basic Javascript, HTML, and CSS (and find it easy to figure out how to do something), and have a little experience in Python. I've seen Ruby before and edited a few lines of existing scripts. I'm curious not so much about any given technology, but mainly about what ...
I'm trying to work out a good way to manage user submitted content and create a method to determine when spammed/poor content should be hidden. The aim is to create comment voting similar to youtubes like/dislike comments and if the score is good show the comments, else they're invisible. Approach My thought is to do t...
When estimating (story points) a story that consists on extending a current functionality with a known tech-debt, should we consider the effort that will be spent to refactor the current code or should we estimate independently of this tech-debt?
I'm sorry if the title isn't clear, I have no idea about licences... The thing is that I have created a little app for android targeted at developers. I want to get paid for the app, but I also want to share the code so others can modify it to improve it or to suit their needs. I think this is somewhat close to minec...
I've often seen the terms immutable and const used interchangeably. However, from my (little) experience, the two differ a lot in the 'contract' they make in code: Immutable makes the contract that this object will not change, whatsoever (e.g. Python tuples, Java strings). Const makes the contract that in the scope of ...
I was told by a colleague that in Java object creation is the most expensive operation you could perform. So I can only conclude to create as few objects as possible. This seems somewhat to defeat the purpose of object oriented programming. If we aren't creating objects then we are just writing one long class C style, ...
I'm looking for general approaches and ideally libraries/tools for scheduling many thousands of recurring jobs. A simple example is a feed aggregator, where I'd want to repeatedly poll thousands of feeds. I would never want to poll a website more than once an hour (overuses everyone's resources), but I could deal with ...
On a current project, the powers that be want to have unit testing incorporated into our development cycle to avoid the constant amount of bugs that seem to seep into our code. The problem is that the spaghetti code is 95% percent procedural, which I've never done unit testing with (all my experience with unit testing ...
In my Programming Language Concepts class it was mentioned in passing that Fortran's original control structures were insufficient. It was alluded that they were too similar to machine instructions for the IBM 704. Was this the case? What exactly made them insufficient?
Suppose I am including a feature in my image-viewing software, which opens an image in Photoshop ('Send to Photoshop'), using Photoshop's OLE automation framework. Am I allowed to use the icon of Photoshop.exe as the image of this 'Send to' button?
After reading an article humbly named "The Code Commandments: Best Practices for Objective-C Coding" by Robert McNally a little less than two years ago, I adopted the practice of using properties for pretty much every data member of my Objective-C classes (the 3rd commandment as of may 2012). McNally lists these reason...
Back in university, we were able to print "unlimited" printouts on wide fanfold paper, (perhaps 128 characters wide or maybe more). I could then unfurl the printed code out across the desks or the room and get a great overview of my code, draw circles and arrows and a paragraph on each one in the wide margin, see if t...
I am trying to learn Socket programming in Java to make a game I created playable via network. I have never done much network programming so the subject is a bit confusing. In php I use apache to test my aplications on a local server. What do I need to install to be able to run network applications with Java?
When modelling an object with children it's common to include the children via composition, as a member of the parent class. Sometimes however the children need to tell the parent something, they need to call a function of the parent. How can this be accomplished using C++? Some options are: Make the parent class glob...
With unit tests the domain is quite small, so it's easy. I used Osherove's methodName_conditions_result() scheme and found it very clear. But with integration tests I feel like it would make a very long name, and what do I put in place of methodName? How do I name integration test classes? Real world examples of integr...
I'm interested in seeing how other people do this. Especially in situations where multiple different clients are using the same software base with slightly different business rules. What kind of practices do you use to document how everything is supposed to work or business rules. Basically so when a new developer come...
I want to create a websocket server and I've found a great article here. However C# will output an exe file. I'd like to have it run on a linux box. What I want to do is to connect to the server, and when something happens on the filesystem to retrieve a message from the server (using the FileSystemWatcher on Windows o...
While learning Spring framework, I found that Spring framework provides init-method and destroy-methods which can be used to initialize some properties or to do housekeeping stuff. We can do all those things in the bean's constructor so why do Spring provides these things and in the real world what is the actual use of...
I'm teaming up with a guy who has no programming experience. We're using a tool to make our game (RPG Maker) that has an event-based system that allows you to do pretty much everything you want. They have a GUI and a simple text editor for events. My friend has no programming experience. None. I need him to understand ...
I posted this question on DBA, but it got closed and was never reopened even after I rewrote the whole thing to be more specific. I think its more appropriate for programmers anyway :) Background Information I have a CouchDB server (Server B) that is accessed by another server running PHP (Server A). My web app (Client...
Originally I asked this question on Stackoverflow but I was suggested to move the question here. I've asked this question a while ago in MSDN forums but I'd like a second opinion from StackOverflow since I tried this route and found some CONS, but I'd like to hear more opinions as well. Scenario: I have a windows s...
So I have a webservice that has something like a getAccount where it would return an identifier to the account if it got it, else throw an exception. The client will always want to create an account if an exception is thrown with the same info the get is done with. I am creating a convenience library for clients that ...
Context Web application based on the .NET Framework written in C# and following the MVC design pattern. Question What is the most efficient way to structure an entity layer consisting on various data inputs? Background I am developing an application for a client that requires my reading and writing data from various so...
I have a web service (axis2) and the server performs 4 primary operations: createX, removeX, getX and updateX Where X is represented by a combination of 4 values: id1, id2, id3 and id4 So, to simplify developer life, we created 3 extra helper functions: removeXForId, getXForId and updateXForId where we represent the se...
I'm trying to understand how tcp retransmission queue works so I can implement it in my application that uses TCAP over SCTP. What I understood from the TCP queue is that every message is saved in retransmission queue with with a time, when the timer reaches 0 the message will be sent again. My question is how to che...
Attempting to research how to allow a group of people to effectively rank a set of objects (each group member will have contributed one object to the group), and then assign each member an object that's not their own based on: Their ratings of the objects, Their objects rating, and The object remaining to be assigned...
I'm not a professional programmer, but having a PhD in an engineering field, I've taught myself many programming languages over the years. The past few years I've been using primarily Ruby, and now I'm trying to learn JavaScript so I can do a bit of web programming. I guess like a lot of people, I had a mostly negative...
In OOP, it seems that if an object cross-references another object in its property, ultimately, if such objects are used a lot, the software at the end will be slow because of this. Is this true? If yes, can we intentionally not do this by getting things done?
I have a class which contains two methods. These methods add & remove an object to a datastore. The class which contains these methods has a no arg constructor but each of the two methods takes a variable amount of parameters for the addition / removal. Should these methods be static and if not should the method param...
http://babelstone.blogspot.com/2005/11/how-many-unicode-characters-are-there.html says there are 1 million unicode characters and around 240k of which are already assigned. 1 million > 240k > 65k However, http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.chrw says that chrw accept 65k characters. No...
I have hardly a year's experience in coding. After I started working, most of the time I would be working on someone else's code, either adding new features over the existing ones or modifying the existing features. The guy who has written the actual code doesn't work in my company any more. I am having a hard time und...
Possible Duplicate: Best practices for retrofitting legacy code with automated tests When working in large legacy systems (large systems with no unit testing ever) I often come across people saying use unit testing as a tool against possible bugs. I wonder if somebody have tried it on large systems with no unit test...
Let it be known that I am a big fan of dependency injection (DI) and automated testing. I could talk all day about it. Background Recently, our team just got this big project that is to built from scratch. It is a strategic application with complex business requirements. Of course, I wanted it to be nice and clean, whi...
Many times I have been in a situation where an application is apparently broken, only to find that an external configuration file has been at fault. Typically this is because the wrong file is there, or that it contains incorrect data. Is there a better way to allow an external user/process to modify the runtime charac...
I’m an EA in an organisation with 10000+ employees. Strategically we are heading towards SOA. Currently I’m researching about SOA’s and creating a road map and I have come over many blogs that talk about “SOA is dead”. We can all agree that SOA is not just web-services. The problem is that I have hard to find any infor...
I've got this idea for some time and I was wondering if anyone has seen such a feature/app in any operating system and if you haven't, what do you think about it. Where do you think I should begin? The idea is simple. I think we all have those files that are made and probably used for a few days and then are left on ou...
Is there some consensus among historians on who was the first programmer ever? If so, who was it and what were they programming on? I find it more interesting to know more about the pioneers of programming, regardless if they programmed on a programmable machine or if they've designed the machine themselves to do some ...
After having read through some of the Spring docs my inclination is towards using a XML config file rather than annotations on the classes themselves. My reasoning is that by doing so you avoid tying your POJOs to a particular framework. Based on your experience with Spring, are there any advantages that XML configurat...
So what happened to XHTML5? http://www.w3.org/TR/html5/ That page is a draft for both xhtml5 and html5? So there's no difference between these doctypes?
From MSDN... The access level for class members and struct members, including nested classes and structs, is private by default. If class members are private by default then why use the private access modifier for them? I see it all the time in code examples and open source projects including the ASP.NET MVC source. ...
I was wondering how software optimization and hardware optimization compare when it comes to the impact they have on speed and performance gains of computers. I have heard that improving software efficiency and algorithms over the years has made huge performance gains. Obviously both are extremely important, but what h...
I am looking for recommendations on a digital Scrum Board which can be shared over the internet. I imagine something like a big tablet on which you can draw and which remote users can access, too. I dislike Scrum software because I think one major benefit of a Scrum Board is its physical presence. It should be hard to ...
Everybody nowadays does SOA, even if some don't actually understand what is all about. So they do it wrong. Using that as an analogy I know what REST is (or at least I think I do) and want to do some of it. But I want to do it right. So my question is what's the proper way to do REST?
I've been reading a lot about scrum lately, and I've found what seem to me to be conflicting information about whether or not it's ok to change the sprint backlog during a sprint. The Wikipedia article on scrum says it's not ok, and various other articles say this as well. Also my Software Development professor taught...
I would like to build an Advertising project with PHP, MySQL, and Javascript. I am talking about something like... Google Adsense BuySellAds.com Any other advertising platform My question is mainly, what do I need to look out for to prevent people cheating the system and any other issues I may encounter? My design c...
It's fairly well known who the first programmer was but who was or were the first software engineer(s)? By software engineer I mean someone who uses formalized specifications and methods to deliver software not just a batch programming job. When was the term first used?
As the title states, I'd like to know if coding style can cause or influence memory fragmentation in a native application, specifically one written using C++. If it does, I'd like to know how. An example of what I mean by coding style is using std::string to represent strings (even static strings) and perform operation...
The disintegration of the Ariane 5 rocket 37 seconds after launch on her maiden voyage (Flight 501) is commonly referred to as one of the most expensive software bugs in history1: It took the European Space Agency 10 years and $7 billion to produce Ariane 5, a giant rocket capable of hurling a pair of three-ton satell...
With an encoding such as EBCDIC being in existence already (and being 8 bit to boot), what was the need to invent yet another encoding and a 7 bit one at that? Why was ASCII invented and what problems with EBCDIC did supposed to solve?
Is it recommended to use a WCF Service Library in developing an N-Tier Windows Application? Also is it better to use the VS wizards to create the DataTables and DataSets? And if so should I add all of my tables to 1 dataset or have a dataset for each table? This is all new to me and I want to learn it the right way.
Is it a good idea to use CouchDB for a web application that is going to be platform agnostic (from tablet to PC): The app is a big form which I need to be able to modify at will. I also need to scan the results to retrieve the data to send some file to help the client. I need to be able to upload the results to a ma...
On many e-mail subscription lists, the is a link at the bottom that says something to the effect of: You are subscribed to our e-mail list as you@example.com. To unsubscribe, click here What is the best way (and is there a way?) to emulate this when sending out mass text messages through SMS gateway?
So my copy of the classic book, Mastering Regular Expressions, just arrived, and I'm scanning through it. The cover (third edition) says, "for Perl, PHP, Java, .NET, Ruby, and More!" Well, it does have a full chapter for each of Perl, PHP, Java, and .NET - but no chapter on Ruby, or, more importantly to me, on Python. ...
I am currently nearing the end of my first year of my CS degree and have been disappointed with the lack of coding I have been asked to do (one unit). I am basically looking for an effective way to gain practical knowledge but am unsure where to look for experience from a near beginner's perspective.
I feel that I am good at writing code in bits and pieces, but my designs really suck. The question is, how do I improve my designs - and in turn become a better designer? I think schools and colleges do a good job of teaching people how to become good at mathematical problem solving, but let's admit the fact that most ...
So I've been asking the wrong questions for the last three days and after searching a lot I think I have an idea of what I need, my question is how to use timers with two threads writing and reading on one queue. In other words, I have one queue(or any other data structure) and two threads, producer and consumer, so ...
I am quite new to programming and I am now creating my own program as part of my Master Thesis. My program is done in Java and uses several third-party libraries. These libraries come with different licenses, mainly: LGPL 2.1 GPL 2 + GPL Linking exception Apache version 2 BSD I have actually not touched the source co...
Hi I am currently developing a web application in Spring and Hibernate where i have several different tables. The Delivery table for example is mapped many-to-one with the Customer table and the Product table. I am wondering what the best practice is for creating a view function where I display all the columns related...
What was the first program that was created as a dedicated IDE? That is, purpose built for coding, rather than simply allowing integration as part of its expansion options. This is opposed to a text editor that has generic plugin/add-in/shell features that are were not dedicated to development work. The features I am t...
I was wondering how people deal with working in a project with badly written and formatted code, I'm talking mixed tabs and spaces, unnecessary parentheses and newlines and a whole bunch of warnings appearing on the code from the IDE. For context I have this problem on java projects, where no formatting was agreed upon...
I'm working on an open source project that has full time professional developers from several universities, plus a couple of other organisations. The product has something like a dozen deployments, various variations, plugins, related components etc. Generally development so far has been driven by institutions "scratch...
I know how to do simple loops but I don't know what's going on when many loops are working together. For example: for (var i=0; i <= 9; i++){ document.write(i); for (var m=0; m <= 9; m++){ document.write(i); } } Is there a way I can learn loops inside out?
I am designing a WinForms application in C# and wanted to get a design check by you guys. I am fairly new to programming and have been reading some material, so please excuse my mis-usage of words or 'computer science' terminology if need be. The Design I have a MDI application with MAIN as my parent form and various o...
At the company I work at, every service class has a corresponding interface. Is this necessary? Notes: Most of these interfaces are only used by a single class We are not creating any sort of public API With modern mocking libraries able to mock concrete classes and IDEs able to extract an interface from a class ...
I have an online document which essentially gets stored to the database as XML string. I'm thinking about a way to implement versioning of the document for the user. So that user can go back to previous versions of the document. update In my case it's a web application with hundreds of thousands of users. A user c...
I have a collection of normal functions and self-calling functions within a javascript file. In my comments i want to say something along the lines of "This script can contain both self-calling and XXX functions", where XXX is the non-self-calling functions. "Static" springs to my mind, but feel that would be incorrec...
Let's say I have a list of precipitation values by hour, each showing how much rain happened in the prior 24 hours, ordered by date. For example: { '2012-05-24 12:00': 0.5, // .5" of rain from 5/23 12:00 - 5/24 11:59 '2012-05-24 11:00': 0.6, // .6" of rain from 5/23 11:00 - 5/24 10:59 '2012-05-24 10:00': 0...
This question relates to a question I asked earlier, which can be used for reference here: Is this the best way to approach this design? Is this an example of MVC? While coding, I came across a realization that I am not creating 'loose coupling'. The way I am trying to solve the problem right now is creating an instan...
In principle, a single Django application can be reused in two or more projects, providing functionality relevent to both. That implies that the same database structure (tables and relations) will be re-created identically in different databases, and most times this is not a problem (assuming the projects/databases are...
The purpose of this assignment was the find the smallest and largest of the integer(User inputs 5 entries) I am a beginner Java programmer with no prior experience. Is there an easier way to do this without a ton of if/else statements? Forgive for the dirty code. //Scanner Object Scanner input = new Scanner(Sy...
I have been given a file with several records. I have also been given business rules that determine how to process those records and produce an output file. The business rules are relatively simple: If record is of type A, use methodology A. If record is of type B, use methodology B. However my client emailed me with...
You try a new tool and it does not work. You google the problem and if you are lucky a random answer says you need to edit some weird configuration file and place it in a specific directory you don't know. You try but during the process things go wrong. Either because you don't understand the steps listed in the answer...
I am building an app using Code Igniter, it is being based on CI-Bonfire. I am pulling in the dev branch of CI-Bonfire using git, I want the entire project to be git controlled as well, but I want to be able to just pull the latest changes from the dev branch of CI-Bonfire, but push my entire app to a different reposit...
I stumbled upon this question and a couple of other along the same lines. While we know creation of enum is thread safe and enums are by birth singletons . It kind of confuses me that why would any one want to have a synchronized method with in an enum. Yes I am fully aware that methods in an enum are not thread safe...