title: Algorithm to measure how "diffused" 5,000 pennies are in an economy?

text: Please allow me to use this example/metaphor to describe an algorithm I need. **Objects**   * There are 5 thousand pennies.    * There are 50 cups.   * There is a tracking history (Passport "stamp" etc) that is associated with each penny as it moves between cups. **Definition** I'll define a "highly diffused" penny as one that passes through many cups. A "poorly diffused" penny is one that either passes back and forth between 2 cups **Question** How can I objectively measure the diffusion of a penny as:   1. The number of moves the penny has gone through   2. The number of cups the penny has been in   3. A unit of time (day, week, month) Why am I doing this? I want to detect if a cup is hoarding pennies. **Resistance from bad actors** Since hoarding is bad, the "bad cup" may simply solicit a partner and simply move pennies between each other. This will reduce the amount of time a coin isn't in transit, and would skew hoarding detection. A solution might be to detect if a cup (or set of cups) are common "partners" with each other, though I'm not sure how to think though this problem. **Broad applicability** Any assistance would be helpful, since I would think that this algorithm is common to   * Economics   * The study of migration patterns of animals, citizens of a country   * Other natural occurring phenomena  ... and probably exists as a term or concept I'm unfamiliar with.


title: Does freelancing require supreme ability on programming?

text: I can write independent java, python, c, c++ code but I do not know every aspect of them. For example, I don't how to code with database in python/c/c++. I have few experience with GUI programming. I was aware that most of the jobs isn't just need us to write an simple code. They may need some GUI and you need to upload the programming result to a FTP server via some ftp code with some I-don't-know-the-name plugin/library. I have seen a job of web scrapping by python, and the client wants the program to insert the data into a database immediately after the web scrapping, and delete old data older than 6 month. A client won't accept a contractor to say "I will need to figure this xyz- technology for sometime before I can tell you whether I can do it". What is worse, is that you find you are incapable of doing his job for whatever the reason, you are screwed. I am wondering, do you apply for a freelance job if you don't feel like an expert to all the fields/technology listed in the job requirement?


title: How can I rank teams based off of head to head wins/losses

text: I'm trying to write an algorithm (specifically in Ruby) that will rank teams based on their record against each other. If a team A and team B have won the same amount of games against each other, then it goes down to point differentials. Here's an example:               A beat B two times     B beats C one time     A beats D three times     C bests D two times     D beats C one time     B beats A one time      Which sort of reduces to               A[B] = 2     B[C] = 1     A[D] = 3     C[D] = 2     D[C] = 1     B[A] = 1      Which sort of reduces to               A[B] = 1     B[C] = 1     A[D] = 3     C[D] = 1     D[C] = -1     B[A] = -1      Which is about how far I've got I think the results of this specific algorithm would be:               A, B, C, D      But I'm stuck on how to transition from my nested hash-like structure to the results. My psuedo-code is as follows (I can post my ruby code too if someone wants):               For each game(g):       hash[g.winner][g.loser] += 1      That leaves `hash` as the first reduction above               hash2 = clone of hash     For each key(winner), value(losers hash) in hash:       For each key(loser), value(losses against winner):         hash2[loser][winner] -= losses      Which leaves `hash2` as the second reduction Feel free to as me question or edit this to be more clear, I'm not sure of how to put it in a very eloquent way. Thanks!


title: New User Registration Logic

text: I am writing up a user registration application in PHP as part of my learning process. I have written up the general rules my code should follow. Please let me know what you guys think of it.   1. Have a form with the email address and password.   2. Generate 2 random tokens to be appended to the URL to validate the email and complete the registration. Send user en email with the URLs. Use the first token to continue the registration and the second token to cancel (In the case where the registration request was unsolicited).   3. At this point, in the database table, I maintain a table with 6 columns - email, password, register_token, cancel_register_token, counter, timer.    4. When user clicks on the link to continue with the registration process, prompt the user for the password. If the user had inadvertently entered an incorrect email address, then that someone else obviously doesn't know the password and cant continue with the registration.    5. If the user who already has an active email in the db, waiting to register, wants an activation email sent again (maybe someone else registered the email on his behalf, unsolicited and he doesn't have the password to continue), then create another 2 random tokens, erasing the first set from the table and keeping a counter, increasing the counter each time a new set of tokens are generated against an email. When the counter reaches a maximum, do not accept any more requests. Maybe a max of 5 such requests and no more.   6. Keep the register link alive for 1 day if there is no activity. Use the timer column for the same.


title: Suggestion to Design API Centric Application using Appengine

text: I have been planning to create an new application. So I was designing the application structure.i know this application will be accessed form multiple devices and the app feature will be increased. So following is what I collection   1. Application is big, so need to splitup   2. Need Central Database with API (so all other clients including webapp will use this application)   3. Need Central Authentication System I am using Appengine as PAAS and Datastore as Database Following are various ways I thought I can implement it:   1. **Keep Authentication and API in one application with has common datastore     * problem here is webapp need datastore so frequently , so accessing it from another application will be performance impact, right?**   2. Keep Authentication, API, WebApp as different applications In above two cases following is my problem,   1. datastore cannot be shared, I know about cloud datastore which is currently too complex   2. maintaining data consistent across multiple application is hard (I don't have clear idea in it) Using New Appengine Modules would solve some of the issues (i.e keeping datastore, authentication, webapp in one application with different versions), but the problem here is application will be under heavy load, since is common. Any better solutions or drawbacks in current application design is very much appreciated.


title: What languages are more suited for long term projects?

text: What languages are more suited for long term projects ( _will have to be recompiled in 20 years, with the minimum amount of changes in the source code_ ), in terms of minimal amount of rewriting what's already written due to changing of the versions of the language & changing of compilers & OSs (i.e. backward compatibility), as far as we can judge from past references? (we can't tell what the future will bring, so no _predictions_ here - just base your answer on so far known ones) IMHO, yes, *nix oriented ones will have some advantage in here. For example,   Perl (good, AFAIK), vs.   Python (bad with it's v2.5 -> v3.x rather large backward compatibility breakup - it has also been said that back compatibility will not be kept in future versions). If you could explain your arguments as to why did you choose a particular language, along with what were the larger changes in it.


title: Programmers doing testing

text: I am wondering how typical it is for programmers to switch hats and do testing on each other's work. Assume that the team wants to take a "shared responsibility" approach to moving tasks from being formalized to their release - **(1)** is it a good idea to have programmers work as software testing as long as they didn't write a feature? **(2)** Does this happen often? Also, I am wondering **(3)** to what degree a programmer can "test" their own work. Even with TDD and unit tests, isn't there still a need for a software testing apparatus in the development process?


title: Where are some good places to announce a personal programming project?

text: Where can I advertise my personal projects for free? Other than hosting services. It seems to get followers on github you need them to already know about what you're doing from another source.


title: Why the scorn for COBOL?

text: When people mention COBOL, it's usually either met with a snort or groan. I don't know much about COBOL, but I've seen some programs written in it. I can see that it's wordy, and to uninitiated eyes such as mine, unintelligible. But, really, aren't all programming languages complete gibberish to a lay person? I understand that it works, works well, and is still in widespread use in the industries it was designed for. Aren't those the hallmarks of a good language? What's so bad about COBOL?


title: Cross Platform Compilation of C++ .exe

text: I have been asked to re-write an old C/C++ project in C++11. The old project is multi-platform, however, in order to deploy the system on other architectures the current process is to log into a remote service which has all the available target platforms (Red Hat Linux, Umbuntu, Sco Unix et al.) and build the .exe on each platform for distribution. Is there a way that I can send the user a package that will self-compile on their architecture and build the correct .exe _without giving the source code_? I am also open to cross-compilation to get around having to log into separate servers and compile for each platform. How easy or not is it to compile a code for different architectures using a cross compiler?


title: can non-programing fizzbuzz work?

text: We all know what a fizzbuzz is and I've seen many varients of programs to be implemented. However, it takes time to watch someone write the code out, it seems time inefficent to sit there watching code be written after someone has already 'figured it out'. It's also harder to give a programing fizzbuzz over the phone. I was wondering if other simple questions can be used as a fizzbuzz? Questions like "when is it best to use the following structures: hashmap, a linked list, or a sorted tree" or "in Java what other method should you always override if you override the equals method"? Would questions like these work as well as a standard programing fizzbuzz? If you were in person, where a person could write on paper, would you ever consider a non-programing fizzbuzz over a programing one? Would a non-programing fizzbuzz be less likely to seem insulting then a programing one?


title: Can XCode work with TFS?

text: We have been using Team Foundation Server (TFS) for source code management of our solution which contains components for a number of platforms - asp.net, windows & android so far. We now wish to develop iOS apps for the solution but is there any integration possible between XCode and TFS? What's the best way to use TFS version control with Xcode now that I find out we need to write some iOS apps? We will also eventually want to have automated builds for a Continuous Integration process


Why does the modifier access for the properties need to be public with Unity? I'm very interested in a detailed explanation for my question. I read about tips to do it in other ways, but not a detailed explanation about why this can't be declared explicitly in my code.


title: Maintainability of Boolean logic - Is nesting if statements needed?

text: Which of these is better for maintainability?               if (byteArrayVariable != null)         if (byteArrayVariable .Length != 0)              //Do something with byteArrayVariable       OR               if ((byteArrayVariable != null) && (byteArrayVariable.Length != 0))       //Do something with byteArrayVariable       I prefer reading and writing the second, but I recall reading in code complete that doing things like that is bad for maintainability. This is because you are relying on the language to not evaluate the second part of the `if` if the first part is false and not all languages do that. (The second part will throw an exception if evaluated with a null `byteArrayVariable`.) I don't know if that is really something to worry about or not, and I would like general feedback on the question. Thanks.


title: 2D grid with multiple types of objects

text: This is my first post here in programmers.stackexchange (I'm a regular on SO). I hope this isn't too general. I'm trying a simple project to learn Java from something I've seen done in the past. Basically, it's an AI simulation where there are herbivorous and carnivorous creatures and both must try to survive. The part I am trying to come up with is that of the board itself. Let's assume very simple rules. The board must be of size X by Y and only one element can be in one place at one time. For example, a `critter` cannot be in the same tile as a `food` block. There can be obstacles (rocks, trees..), there can be food, there can be critters of any type. Assuming these rules, what would be one good way to represent this situation ? This is what I came up with and want suggestions if possible: Use multiple levels of inheritance to represent all the different possible objects (AbstractObject -> (NonMovingObject -> (Food, Obstacle) , MovingObject -> Critter -> (Carnivorous, Herbivorous))) and use polymorphism in a 2D array to store the instances and still have access to lower level methods. Many thanks. Edit: Here is the graphic representation of the structure I have in mind. ![enter image description here](http://i.stack.imgur.com/4QK7N.png)


title: Alternatives to pulling updates off the website

text: So, I think it look pretty bad when you release an update and pull it off the web. I'm pretty sure this has happened for at least two of the the last three Delphi XE2 updates. I'm not complaining because I'd do (and have done) the same thing. The only problem is, how do you do this gracefully? And, how do you alert the 10-20 facilities ( 500-2000 end users ) who downloaded your awful software that what they downloaded is no good, but what they're going to download is super awesome? The reason I ask it is because I work for a small business, Embarcadero is a big(ger) business and we do the exact same dumb thing when our release is found to be deficient. The problems might be as simple as a file missing or even a legal problem, the code might be perfect and there still might be problems with the app.


title: Is measuring software project metrics popular in todays industry?

text: I encountered a developer who wanted some outside advice on their teams project. I found out they're developing a huge software suite for the companies executives, project manager and developers that can calculate metrics automatically and graph them per iteration. As a student from a computer science background I know very little on metrics and their importance, but my questions are:   1. Do most companies have some way, doesn't have to be an elegant program, to measure meaningful metrics?   2. Which metrics, single or combined, help you narrow down your projects scope and estimates?   3. As a person who analyzes metrics, how often do you base decisions off of them? IE. Tests failed per week is increasing drastically?   4. Do you feel that the introduction of studying metrics has helped you understand the project better? Not sure why but the developers project intrigued me and I must know more. If y


title: Published Windows Phone 7 apps: good for the Resume/CV?

text: I'm a long time Microsoft developer who has recently started publishing Windows Phone 7 apps to beef up my current C#/.NET skills, and get more direct exposure to WPF/Silverlight, and of course because it is new and cool. So far I've published over 10 apps successfully.   1. Is this a good thing to put on my resume?   2. Does it appear to show a grasp of the latest Microsoft technologies?   3. Any downside seen by potential employers?    4. Would you put this on your resume, if looking for a full time professional Software Engineering position?


title: svn vs git for the sole developer?

text: If I am sole developer (I do not work in a team) working from my laptop (Windows OS and Linux VM) and backing up data to the cloud (Dropbox etc), then is git still better than svn for my version control needs? I was thinking not since I wont need any of git's distributed features. But is git such a better approach to version control that I should consider moving anyway? With so many articles saying how people are moving from svn to git? I was wondering, if they are talking about large or open projects with teams of developers vs the sole developer. What do you think?


title: How to represent (enum) types in a public API

text: I am working on a simple API that I want to use for my own client, and to open to the public in the future. I have "Item" objects which can have different "types". The type is a C "typedef enum", for the moment I have :               typedef enum {         ItemTypeBool,         ItemTypeNumber,         ItemTypeDate,     } ItemType;      (I may add some in the future) I am wondering if I should rather transfer it as integers or as defined "strings". The JSON would be : For integers :               {       "name": "The name",       "type": 0,        ...     }      For strings :               {       "name": "The name"       "type": "boolean"        ...     }      I'm wondering if there's a best practice for this. Keeping the integer would slightly simplify the code, and reduce the bandwidth, but strings would be easier for developers to remember. I remember I worked on a project, and I had to remember 1=image, 2=audio, 3=html,... which doesn't make any real sense. So I'm asking you, if you know any other aspect I should consider.


title: Why are UUID / GUID's in the format they are?

text: Globally Unique Identifiers (GUID) are a grouped string with a specific format which I assume has a security reason. > A GUID is most commonly written in text as a sequence of hexadecimal digits > separated into five groups, such as: > > 3F2504E0-4F89-11D3-9A0C-0305E82C3301 Why aren't GUID/UUID strings just random bytes encoded using hexadecimal of X length? > This text notation contains the following fields, separated by hyphens: >   >   >     | Hex digits | Description >     |------------------------- >     | 8            | Data1 >     | 4            | Data2 >     | 4            | Data3 >     | 4            | Initial two bytes from Data4 >     | 12           | Remaining six bytes from Data4 >   There are also several versions of the UUID standards. > Version 4 UUIDs are generally internally stored as a raw array of 128 bits, > and typically displayed in a format something like: > > uuid:xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx


title: What am I allowed to do programmatically with pictures that have a Creative Commons "don't modify" license

text: I'm working on a project that uses some icons that are under a Creative Commons license (ND) that forbids modification of the picture. What can I do with this icons as a programmer? Can I modify the looks of the image in the program as long as I don't change anything in the file that contains the icon? Have I modified the image if I put a colored transparent layer over it so the color of the icon changes?


title: At what point should you start putting functions in a new file?

text: I'm currently writing a python script. It's currently about 400 lines long, and it seems like it's getting a bit long, as when I'm trying to scroll through it with eclipse it takes a bit to get from function A to function B. The structure is that it reads in a file, and then performs actions on what it reads in depending on the flags passed in by the user on the command line. Everything is more or less related (and in fact many functions call on other functions), so it makes sense in that regard to just leave everything in the same file. I'm currently adding more features, or more things that can be put in for command line flags, and I'm wondering if there are any standards about how long a file should be before you start putting things into a new file. PEP 8 mentions the length of a line but nothing on the length of a file. In summary: Are there any standards for how long a file should be before you just start throwing stuff into a new file?


title: Why did Aiken decided to separate data and instructions in the Harvard Mark I?

text: When Aiken devised the Mark I, why did he decided to separate data and instructions? It was not mentioned in Wikipedia (or in any other searches I've looked) on how or why Aiken separated data and instructions.


title: Null checking whilst navigating object hierarchies

text: I had to implement some code which traversed a small object hierarchy to fetch a value and display it in a TextView object (this is Android / Java). I had to do this _6 times_ to populate _6 TextViews_ for various values in the object hierarchy. My implementation was **Implementation B**. But upon review, my colleague disagreed and certain that **Implementation A** was the way to go. I believe that my version is not just cleaner, but also less error prone as I could easily miss something as a developer. Could you provide me with your opinion, with pros and cons for both of these implementations? ### Implementation A:               if (house != null && house.getLounge() != null && house.getLounge().getLetter() != null)     {         String myValue = house.getLounge().getLetter();         textView.setText(myValue);     }     else     {         // Do nothing, or maybe make textView hidden.     }      ### Implementation B:               try     {         String myValue = house.getLounge().getLetter();         textView.setText(myValue);     }     catch (NullPointerException e)     {         // Do nothing, or maybe make textView hidden.     }


title: How to protect software on an Amazon Machine Image?

text: There are other similar questions for ways to protect software from piracy or license violations: 1, 2, 3, 4 with great answers. A lot of those suggestions don't completely apply to my situation, since I am hoping to sell a service, not software. However, some customers may refuse service, so want to optionally sell the software too. I have prepared an Amazon Machine Image (AMI) for a turnkey distribution solution which is important since I must provide a free trial period, which may make some security options available beyond a normal binary distribution/installer. I acknowledge that it's difficult/impossible to prevent reverse engineering, but I would like to know what are some easy to implement measures I can take. Here are the ideas I have so far:   1. Specify in the license agreement how they're permitted to use the software, and then ask them to delete it when the business relationship expires. This is probably the best option, but my question is to explore programming solutions, not business/legal solutions.   2. After compiling code on the AMI, I can just delete the source code. This means customers who want updates will need to maintain a business relationship with me.   3. I can look at the system time and compare it to an expiration date compiled into the binary, a sort of self-destruct option. Sounds trivial to implement, and although I know it can be defeated, how difficult is it really for someone who's never done it before? What if I disable root access on my AMI?   4. I can use Amazon's Shared AMIs option, and simply delete the AMI when the business relationship expires. I understand that this can be defeated if a user clones my AMI, but is there anything else I can do to protect an AMI or to lock the software to a particular AMI?   5. I can use Amazon's Paid AMIs option, which uses their DevPay system to make sure users are paying to continue to use my software. How secure is this system?   6. I can have the AMI "phone home". I don't think my customers would approve. Thanks!


title: Database design for tagging system

text: I'm creating a system where items will have one or more tags. Now there will be an **item** table that will store each item, and a **tags** table, that will store all tags used in the system. My question is: What is the best design I can have that will allow me to link items to their respective tags, and record how many times an item received a particular tag from a user? For example, I'm wondering if I should create a third table that would associate a particular item with a particular tag and how many times that tag was selected. The fields would be like this: item_id, tag_id, tag_hits - where tag_hits is the number of times the tag was used. This solutions would associate all items with their tags in a single table. **Or** the other solution I'm thinking of is to create a table for each item and record each tag and the amount of the time the tag was used. So, for itemX I would create a table **itemX** and the fields would be: tag_id, tag_hits. For another itemY, I would create a table called itemY with the same fields. So for every item, there would be a table associating it with its tags. Now there could be hundreds of thousands of items in this system. I suppose the developers of this website had to make similar consideration because each question is tagged. And you can browse questions by tag. My system will have similar functionality. Can someone recommend a design solution, taking into consideration all that I have said, and performance consideration. Please indicate where you think indexing might help also. I use SQL databases in my development, but if you think a no-SQL solution would do it, please suggest a design along these lines. please be very specific. Thanks, Ron


title: Should laying out a GUI graphically be considered "cheating?"

text: I have a friend who has a slightly greater amount of programming experience as me. We were talking about all the different programming technologies we use and Interface Builder came up in conversation. Being of no programming background except for what I've taught myself, I personally believe that IB and all it's features (`IBOutlets`, `IBActions`) help coders of my skill level (and all skill levels, for that matter) complete projects of theirs in less time. His view of IB is a little enthusiastic. He believes that coders that utilize Interface Builder are "cheating" in the fact that they don't have to lay out interfaces by hand. * * * Question: **Should using a GUI builder to lay out interface elements be considered "cheating" (since most programming originally required laying interfaces out by hand in code)?** Why?


title: VPS versus Shared Hosting

text: Is there any compelling reason a programmer would host on a shared platform versus just having a VPS account somewhere?


title: Alternatives to the singleton pattern

text: I have read different opinions about the singleton pattern. Some maintain that it should be avoided at all costs and others that it can be be useful in certain situations. One situation in which I use singletons is when I need a factory (let's say an object f of type F) to create objects of a certain class A. The factory is created once using some configuration parameters and then is used each time an object of type A is instantiated. So every part of the code that wants to instantiate A fetches the singleton f and create the new instance, e.g.               F& f                   = F::instance();     boost::shared_ptr<A> a = f.createA();      So the general my scenario is that   1. I need only one instance of a class either for optimization reasons (I do not need multiple factory objects) or for sharing common state (e.g. the factory knows how many instances of A it can still create)   2. I need a way to have access to this instance f of F in different places of the code. I am **not interested** in the discussion whether this pattern is good or bad, but assuming I want to avoid using a singleton, what other pattern can I use? The ideas I had were (1) to get the factory object from a registry or (2) to create the factory at some point during program start up and then pass the factory around as a parameter. In solution (1), the registry itself is a singleton, so I have just shifted the problem of not using a singleton from the factory to the registry. In case (2) I need some initial source (object) from which the factory object comes so I am afraid that I would again fall back to another singleton (the object that provides my factory instance). By following back this chain of singletons I can maybe reduce the problem to one singleton (the whole application) by which _all other singletons_ are directly or indirectly managed. Would this last option (using one initial singleton that creates all other unique objects and injects all other singletons at the right places) be an acceptable solution? Is this the solution that is implicitly suggested when one advises not to use singletons, or what are other solutions, e.g. in the example illustrated above? **EDIT** Since I think the point of my question has been misunderstood by some, here is some more information. As explained e.g. here, the word **singleton** can indicate (a) a class with a single instance object and (b) a design pattern used to create and access such an object. To make things clearer let us use the term **unique object** for (a) and **singleton pattern** for (b). So, I know what the singleton pattern and dependency injection are (BTW, lately I've been using DI heavily to remove instances of the singleton pattern from some code I am working on). My point is that unless the whole object graph is instantiated from a single object living on the stack of the main method, there will always be the need to access some unique objects through the singleton pattern. My question is whether having the complete object graph creation and wiring depend on the main method (e.g. through some powerful DI framework that does not use the pattern itself) is the only **singleton-pattern** free solution.


title: How should I implement a secure priority queue in C?

text: I have an assignment to implement a priority queue in C as well as make an app that uses it. I, however, only know basic-level C (I do know Java). My intuition says that I need to learn pointers. What other stumbling blocks should I expect or prepare for? How do I go about making this secure?


title: What's the proper way to check commit data in Git?

text: My goal is to check commit data that don't meet certain requirements and then reject either the commit being created or pushed to the remote repository. The problem of doing a pre-commit hook is that it's hard to deploy to many people who have to manually update their pre-commit hook file. As well, Git does not allow you to have submodules in the .git folder which would've been very easy for deployment yet alas. The other option I see is doing the checking in I believe the update hook on the remote side, which will check each commit being pushed by a dev and reject the push if any of the commits fail the tests. Does anyone have any insight on this problem? And if so, could you provide or point me towards an example update hook script? I'm a little confused as to how it works.


title: Any reason behind hyphens in a GUID?

text: Just when I generated a GUID, I found some hyphens in between the character and also at specified intervals               8b55fec7-c987-4e7b-abad-16e5aaea9b53      Is there any story behind this? **Note:** My intention is to remove those hyphens as I am adding this GUID to a filename and our filename should only be aplhanumeric.


title: Is this an assembly language?

text: In my childhood I used to program on an MK-61 Soviet calculator. It had four operating registers (X, Y, Z, T) and 15 storage registers. A program could have 105 steps. As I recall it, it had commands like:   * Swap X and Y registers   * Shift registers (Z to T, Y to Z, X to Y)   * Copy from storage register (1..15) to X   * Copy from X to storage register (1..15)   * If X < 0 then go to program step ##   * Perform operation (+, -, *, /) using X and Y values and put result to X Is this command set an assembly language? Did I have a basic idea of assembly languages by using this device? ![Device](http://i.stack.imgur.com/yRDXh.jpg) It turns out it is something called "keystroke programming". Funny fact: a similar calculator (like this one, but with energy independent memory) was used as a back-up hardware for space mission trajectory calculations in 1988. :-)


title: Why does it matter that HTML and CSS are not programming languages?

text: Example here: What languages should I know if I'm interested in building web applications ? Yes, I understand that HTML and CSS are not Turing-complete. Yes, I understand that they are declarative, not imperative languages. But why are people always clubbed over the head with this pedantic (and arguably obvious) fact when they ask a question about these languages?


title: How can a non-technical person learn to write a spec for small projects?

text: How can a non-technical person learn to write specs for small projects? A friend of mine is trying to outsource some development on a statistics project. In particular, he does a lot of work in excel, and wants to outsource the creation of scripts to do what he now does by hand. However, my friend is extremely non-technical. He is poor at writing technical specs. When he does write a spec, it is written the way you would describe doing something in excel (go to this cell and then copy the value to that cell). It is also overly verbose, and does examples several times. I'm not sure if he properly describes corner cases. The first project he outsourced was a failure. I think he overdescribed some details, but underdescribed corner cases. That and/or the coder he hired didn't think through the corner cases and ask appropriate questions. I'm not sure. I got on IM with him and it took me half an hour to dig out a description that should have taken five minutes or less to describe. I wrote the scripts for him at the end, but didn't examine why his process with the coder failed. He has asked me for help. However, I refuse to get involved, because taking his spec and translating it into clear requirements is 10x more work than executing on a clearly written spec. What is the right way for him to learn? Are there resources he could use? Are there ways he can learn from small, low-pressure practice projects with coders? Most of his scripts are statistical and data processing oriented. e.g. take this column and run an average over it. Remove these rows under these conditions. So the challenge is different than spec'ing a web app.


title: Delivery terminology and order of magnitude

text: What is the standard way of describing how software products are released and the proportionate order of magnitude to which the changes relative to the software product are conveyed? Is   1. Release    2. Update   3. Patch    4. Bug Fix redundant? or Is   1. Update   2. Patch  too terse? As an end user I'd think that all bug fixes are patches (insofar as they are not 100% new code) and all patches should be updates (insofar as they don't degrade the product) and all updates should be releases (insofar as they are actually released), but this really doesn't help anyone understand why they need to get them. Then, if the person who makes the software change appends "critical" or "zero- day" in the notes, I would be unwise to leave the changes unapplied.


title: Implementation defined behaviour changing const type in c

text: The C standard states that if an attempt is made to change a const type,the result is implementation defined.This gives error on my system,but what does it depend on(compiler,os)? What are the possible results(implementation defined) on various machines?


title: Organisation of Application Development Team Wiki?

text: Are there any resources available around that suggest best-practice structure for setting up a wiki for developers? I'll be managing a team that has not had the best track record for documentation, communication and knowledge-sharing. I'd like to have a framework set up to make it easier for the team to get started in this area. Thanks!


title: What are some best practices for deleting from source control?

text: When is it okay to delete? ...destroy? When should you never delete/destroy no matter how old (ie. health-management software?)


title: API Auth vs User Auth

text: I have read many posts and articles on this topic but still cant connect the dots. I want to make a Rails app that is strictly a JSON API maybe using Sinatra or the rails-api gem. I also want to make both a web client app and an iPhone app which consumes the API. No plans on letting third party dev's use it. So I could create a separate username/password combination for both the web and mobile client and use HTTP Basic over SSL. Each app would have these values as configs in the source and use it to authenticate to the API so only these can make a call. Anyone else trying would get a 401 error returned. This would be considered handling the API authentication. The web and mobile client apps allow end users to sign up and read/write data to the API. When each user is created, I create and save a token in their profile. If a user successfully signs in, I send back the token. On each future read/write then also send along this token in the header. I get the token and lookup the user in the database and make the read/write. Does this sound like an appropriate way to handle it. For the web client, when I initially send back the token, where do I store it. In a cookie? Do I also drop a cookie to handle session state?


title: Programmaticaly finding the Landau notation (Big O or Theta notation) of an algorithm?

text: I'm used to search for the Landau (Big O, Theta...) notation of my algorithms by hand to make sure they are as optimized as they can be, but when the functions are getting really big and complex, it's taking way too much time to do it by hand. it's also prone to human errors. I spent some time on Codility (coding/algo exercises), and noticed they will give you the Landau notation for your submitted solution (both in Time and Memory usage). I was wondering how they do that... How would you do it? Is there another way besides Lexical Analysis or parsing of the code? This question concerns mainly PHP and or JavaScript, but I'm opened to any language and theory.


title: How can I convince my boss that ANSI C is inadequate for our new project?

text: A few months ago, we started developing an app to control an in-house developed test equipment and record a set of measurements. It should have a simple UI, and would likely require threads due to the continuous recording that must take place. This application will be used for a few years, and shall be maintained by a number of computer science students during this period. Our boss graduated some 30 years ago (not to be taken as an offense; I have more than half that time on my back too) and has mandated that we develop this application in ANSI C. The rationale is that he is the only one that will be around the entire time, and therefore he must be able to understand what we are doing. He also ruled that we should use no abstract data types; he even gave us a list with the name of the global variables (sigh) he wants us to use. I actually tried that approach for a while, but it was really slowing me down to make sure that all pointer operations were safe and all strings had the correct size. Additionally, the number of lines of code that actually related to the problem in hand was a only small fraction of our code base. After a few days, I scrapped the entire thing and started anew using C#. Our boss has already seen the program running and he likes the way it works, but he doesn't know that it's written in another language. Next week the two of us will meet to go over the source code, so that he "will know how to maintain it". I am sort of scared, and I would like to hear from you guys what arguments I could use to support my decision. Cowardly yours,


title: What do you think of "Planning Poker"?

text: Planning Poker Summary, in case you don't want to read the wiki article:   1. Get a list of tasks you want to do for the upcoming iteration   2. For each task:   2.1 Discuss with the group what it entails   2.2 Everyone writes down / selects an estimation of how much effort is required for the task   2.3 Everyone reveals their estimation   2.4 The highest and lowest outliers explain their reasoning   2.5 Repeat until a consensus is reached Usually something similar to numbers from the Fibonacci sequence like 0, ½, 1, 2, 3, 5, 8, 13, 20, 40, 100 are the allowed values, so you don't get long arguments over close values like 23 vs 27. Further, the numbers represent a unit-less value of effort, whose value is determined by a baseline task that everyone agrees equals about a 1, and all else is relative to that. Ultimately, the goal is to get a good feel for a given team's "velocity", which is the number of these points that can be completed in a given iteration. With that, it's possible to make reasonably accurate estimates of how long any given feature will take. * * * We did this at iteration planning meetings at one company I worked at, and I thought it was one of the few good things about that particular company. So, what I'm wondering is, has anyone used this? Do you think it's a useful tool for estimation? Does it work in all situations, or does it lend itself to certain teams, projects, etc?


title: Matrix Pattern Recognition Algorithm

text: I am designing a logic analyzer and I would like to implement some Matrix Algorithm. I have several channels each one represented by a row in the matrix and every element in the column would be the state, for example:               Channel 1   1 0 0 1 0 1 1 0 1     Channel 2   1 1 0 1 1 0 0 1 1     Channel 3   0 1 0 1 1 0 1 0 0      I would like to detect a pattern inside my matrix for example, detect ALL the matches of the bitmap inside the matrix:               1 0     1 1      I think it can be accomplished testing element by element but I think there should be a better way of doing it. Is there any Java API or any way to do it ? If there is a API ARM optimized for NEON instructions would be great also but not mandatory. They will be about 8 matrix of 3 or 2 rows by 20000 columns approximately, the matrix is not fixed, it change every time I scan it because I am constantly receiving data. I need to process them in 500mS or less. I am working on an ARM platform, dual core, 1.2GHz, 1Gb RAM, Android 4.1.2 Thank you very much in advance.


title: Decrementing/Incrementing loop variable inside for loop. Is this code smell?

text: I have to read lines from a text file in sequential order. The file is a custom text format that contains sections. If some sections are out of order, I would like to look for the starting of the next valid section and continue processing. Currently, I have some code that looks like this:               for (int currentLineIndex=0; currentLineIndex < lines.Count; currentLineIndex++ )     {         //Process section here         if( out_of_order_condition )         {             currentLineIndex--;//Stay on the same line in the next iteration because this line may be the start of a valid section.            continue;         }     }      Is this code smell? UPDATE: I didn't mention this earlier, but the root cause of this kind of code was a complicated switch-case (typical when you're parsing). I got rid of the incrementing/decrementing variable by using the "goto case" statement. The structure now looks like this:               switch(state)     {        case State.BOF:            {                //Process BOF case            }        case State.SeenHeader:            {                if( out_of_order_condition )                {                    state = State.BOF;    //Reset the state to some respectable one                         //currentLineIndex--; Removed                    //continue;           Removed                         goto case State.BOF;//Handle this in this iteration itself.                 }            }     }


title: Unit test cases(JUnit), not by developer but other team members

text: I have a very interesting situation. Management has strictly asked to do unit testing for the code being developed and divided the task in such a way that few are developing the code and others are writing the test cases for the code. Now developer keeps on refactoring the code and others keep on changing the test cases. I told them that this is not the best practice(since person who is developing the code need to write test case), but they are not willing to listen me and citing all kind of examples from their past experiences where work is divided like this way. How should I convince them or deal with this situation. Edit: I am looking for some argument/proof which could make them think. * * * Note I asked management about reasons for this and they told me that we are just dividing the workload. I opposed for this and told them that it is not best practice, then they started citing some of their past experiences. Actually, one of team members has accepted the task in past. At that time I tried to convince him to oppose this and now they are saying if he can do why can't you. I have accepted to do as of now but I want to stop this as practice. To my best I want to demonstrate something that can convince them.


title: How to convey your approach is faster than the built-in, alternative approaches?

text: Imagine you have a tool that's much faster than another one (built-in, alternative). You want to mention this in the description of the tool so people can see the point of your tool existing. By comparison, I mean say 40x faster, and when the data set gets large, the performance gain increases even more, say 70x. I didn't want to use "orders of magnitude faster", because that to me implies it's a few times faster. How can I convey this message in a good, understandable manner? Also I thought of using numbers but then like I said, as the data set becomes larger, so the performance gain. Should I just say mine runs in linear time? Not sure if I can verify that.


title: Why do programmers still use mailing lists?

text: Why do many open source projects collaborate primarily through mailing lists rather than through, say, forums? I may be ignorant in my assessment, but I, along with my communication teacher, think mailing lists are rather inefficient:   * It's hard to reference old messages. You have to wait until an archiving site picks up the message you want to link to, then look it up.   * It's hard to reply to messages you haven't received from subscription, since you have to manually copy the sender and message contents.   * It's impossible to moderate threads of discussion. Posts cannot be deleted or modified without supernatural powers.   * It's tricky to keep threads together (namely, to ensure all participants in the conversation are copied/replied to).   * It's tricky for users to participate in multiple high-volume mailing lists, as they have to subscribe and set up filters (or just be really involved). What _real_ edge do mailing lists have that didn't occur to me?


title: What to translate in a billingual software

text: I'm designing/building a web application that will be available in two languages: French/English. I placed i18n mechanisms to extract every text from the application. But what about the user's input? I have some "system settings" that currently ask for both lang for their labels...   But I can't obviously ask a translation for every input (pure data, receipts, etc)... Where can you trace the line between what should be available in translations? N.B : An instance of the application (a same database) will be used by more than one person (~10 users).


title: Should you abandon an ORM framework when you need to implement a bulk operation?

text: Here's a common situation:   * You need to implement a bulk operation in an application that uses an ORM framework.   * After the first pass, you've noticed significant performance problems. Here's my question:   * In this situation, should you _favor_ a solution that includes raw SQL?   * Or are there well-known design patterns that can help you mitigate problems that are commonly associated with bulk operations with ORM frameworks? **EDIT:**   * I'm not asking if you should remove the ORM framework from the entire application.   * I'm asking: Should you forgo the ORM framework for this small slice of the application?


title: C# Linq question

text: I am desperately trying to understand linq and now I have a concrete example of what I want to do (and fail):               Console.WriteLine("{0}", (from myaddresses[x].PostalNr where x => myaddresses[x].SortType == "110" ))      `myaddress` is a dictionary of `OneAddress` objects (my own object) and that object contains the properties `SortType` and `PostalNr`. I thought I didn't need a loop to do the above, but when the above is rewritten to work it might only take the first hit it gets or? The questions I want to perform is:   For each entry in the dictionary that has `SortType` set to 110, print out it's postal number.


title: How do I deal with a problem that will pop up in a later iteration

text: This is an Agile development project and I do not have the ability to change that. The design that will be the fastest and most obvious for the first phase of our project will not be compatible with the needs of our second phase. The change would not be difficult to implement now but it would take a little more time to implement. Our PM is pushing for the quick phase 1 approach saying we will deal with the problem in phase 3 when we get there. Making the change at phase 3 will require refactoring and data transformation will be very intensive. Is there anything I can or should do now that fits in the agile methodology?


title: why no hasLock/testLock on mutexes

text: looking through the docs of posix' `pthread_mutex_t` and window's `mutex` and `CRITICAL_SECTION` I noticed there is no easy way of checking whether the current thread holds a specific mutex posix' `pthread_mutex_t` can be tested when it's not reentrant but that is only a artifact of a non-reentrant mutex ofcourse checking whether another thread holds a mutex is trivial with trylock java does allow checking whether the current (and only current) thread holds an object monitor with `Thread.holdsLock(Object)` which is advised to only be used for debugging likewise the interface of `java.util.concurrent.locks.Lock` in also doesn't provide any checking method (the implementation `ReentrantLock` however does with `ReentrantLock.isHeldByCurrentThread()`) * * * I can imagine that this can be quite easily implemented alongside any other lock (and is even required when implementing a reentrant mutex) all it would require is a unique handle for each thread (already available in threading libraries or could even be the TLS pointer whichever is smaller) and at most 2 extra fields (one for the handle and one for the holdcount)   1. when locking: after the lock is acquired increment the holdcount and set the handle to the current thread handle   2. when unlocking: before unlocking decrement the holdcount and set the handle to nil only when the holdcount is now 0   3. when testing: get the handle and compare it to the current thread's handle   this may be possible without any membarriers as long as a simultaneous write doesn't mangle the bits of the read in a such way that a handle is read that wasn't being written (i.e. the reading thread's handle) the only race conditions possible are in #3 (the rest happens when the lock is held) and may be irrelevant depending on the memory model given the size of the read value (one word) ( **edit** : if a atomic read/write scheme is used this is even solved entirely) the holdcount is not even be necessary when the mutex is not reentrant and you're not making it reentrant * * * **EDIT2** : I want to clarify that the `hasLock` would only be used for debugging purposes (asserts) for example to ensure that a method that needs a lock held by the caller actually has it as for the race condition being irrelevant:   1. first requirement is that you need a way to write and read concurrently in a way that you would only get values that were actually written   2. second the test `handle == currentHandle` would treat both `nil` and the handle of another thread the same way   3. the only way that currentHandle would be equal to handle is when the current thread has written it during locking


title: In Windows 8 will it be possible to use WCF in conjunction with HTML5/JS?

text: Correct me if I'm wrong but I've heard that communicating with a database in Windows 8 will more than likely be done with WCF when working with C#/XAML. If this is true then will this also be the case when working with HTML5/JS?


title: Implementing a programming language without the specification

text: What if, instead of looking at the C++ specification, you analyze the behavior (by inspecting the source code and testing with sample inputs) of existing C++ compilers and use your knowledge of C++ to create a new compiler? Is it a good way to implement programming languages? What are the possible disadvantages of this approach?


title: Is there a reason for the crossover from the Ruby community to the Clojure Community?

text: When we look at the the overlap between the Ruby Community - we see the following overlaps:   * Think Relevance (now Cognitect) has switched from Ruby to Clojure   * Jay Fields has switched from Ruby to Clojure   * David Chelimsky \- author of RSpec \- has left the Ruby RSpec project to join Cognitect Is there some linguistic similarity that has lead to this crossover?


title: What does it mean for "Bootstrap" to be precompiled?

text: I was reading the Bootstrap Getting Started docs, and I came across "Pre- Compiled Source" as a feature. Upon downloading the package, I just found `.js`, `.css`, and some image files. What is there to be "pre-compiled"? Doesn't it all compile in the browser upon page load? I'm guessing this means that it was compiled and tested before shipping, but I don't understand why this would need to be advertised.


title: What actions should I not rely on the packaged functionality of my language for?

text: While talking with one of my coworkers, he was talking about the issues the language we used had with encryption/decryption and said that a developer should always salt their own hashes. Another example I can think of is the mysql_real_escape_string in PHP that programmers use to sanitize input data. I've heard many times that a developer should sanitize the data themselves. My question is **what things should a developer always do on their own, for whatever reason, and not rely on the standard libraries packaged with a language for it?**


title: Naming a class that decides to retrieve things from cache or a service + architecture evaluation

text: I'm a junior developer and I'm working on a pet project that I want to learn as much as possible from. I have the following scenario: There's a WCF service that I use to retrieve and update data, lets say Cars. So it's called **CarWCFService** and has a GetCars(), SaveCar(), ... . It implements interface **ICarService**. This isn't the Actual WCF service but more like a wrapper around it. Upon retrieving data from the service, I want to store them in local memory, as cache. I have made a class for this called **CarCacheService** which also implements interface **ICarService**. (I will explain later why it implements ICarService) I don't want client code to be calling these implementations. Instead, I want to create a third implementation for **ICarService** that tries to read from the **CarCacheService** before calling the **WCFCarService** , stores retrieved data in the **CarCacheService** , etc. 3 questions:   1. How do I name this third class? I was thinking about something as simple as **CarService**. This does not really says what the service does exactly, tho. Is the naming for the other classes good?   2. Would this naming and architecture be obvious for future programmers? This is my biggest concern.    3. Does this architecture make sense? The reason that I implement **ICarService** on the **CarCacheService** is mainly because it allows me to fake the **WCFService** while debugging. I can store dummy data in a **CarCacheService** instance and pass it to the **CarService** , together with an(other) empty **CarCacheService**. If I made **CacheCarService** and **WCFService** public I could let client code decide if they want to drop the caching and just work directly on the **WCFService**.


title: Why was I asked general, non-technical questions during an interview?

text: I got through the first phone interview at Amazon last week and they asked some basic technical questions during that interview. Today, I had my second phone-interview and I prepared myself well expecting for another technical interview, but it was not technical at all. After we introduced ourselves, he asked questions like:   1. Why do you like to do programming?   2. What do you Not like about programming?    3. What do you expect from a new job?   4. In the last project you worked on, how did you make sure the project was implemented to the client's requirements?   5. Was there was any project, that during the development, you felt like the design was bad, and if so, what did you do to fix the issue?   6. As an engineer how would you keep up with the new technologies? Additionally, when I explained to him about a recent project I worked on, he asked me about why we decided to make a specific design decision and whether it was my decision. I was wondering why he asked me these kind of questions; since English is not my native language, I assume that one of the reasons was to test my knowledge of the language. And most of the answers I gave him were very short and since I felt like he's expecting more, I tried to come up with things to say and ended up just blabbering. Overall I think the interview went really bad because I couldn't clearly convey my points to him. Why was I asked these types of questions, and what kind of answers do interviewers expect?


title: Methods on packaging an assembler with compiler

text: I am planning on creating a compiler that will generate assembly, that is as far as I really want to go with this project (don't want to create the object files myself or any of the machine code). Since I'm doing this on linux, I would like to use the gas assembler. I'm not sure the best way to package the application. Should I require that the people have gas on their system already (which it is on most linux distros by default if I'm not mistaken, which I could be)? Or is it better to package the source with my application, or even package the actual application with my compiler? * * * By packaging I mean any form of distribution so that would include putting the code up on github as well.


title: How to become good at object-oriented analysis and design (OOAD)?

text: Becoming a good analyzer and designer can greatly benefit a developer. But there are definitely obstacles for this. Not everybody is interested in OOAD, and not every person who is interested, knows the path. Should a good OOAD know multiple OO languages? Or should he/she have failed projects? How can one become a good OOAD?


title: What is the Enterprise Architecture Pattern called for a web service wrapping a web service?

text: As part of a service orientated architecture (SOA) I've been asked to create a web service which itself acquires data from a third party web service. I'm to hide any implementation specific details of the third party web service and map the data returned so as to avoid leaking any implementation details of the third party service. I'm new to SOA. I would colloquially call this project something like " _a web service bridge_ ".   **What is the correct SOA enterprise architecture pattern term for this?** I'm very confused as many of the enterprise architecture patterns seem to be describing the same thing (service facade?, message broker? message channel? proxy?). I don't think I'm quite in tune with the level of abstraction required.


title: What, why or when it is better to choose a queuing tool vs database task table?

text: I would like to know what, why or when it is better to choose a queuing tool and what, why or when it is better to choose database task table? I don't understand the difference of sending my tasks in a queuing tool or in a database table that will be read and act as a queue. Is there some properties that queuing tools has that database cannot do? Read my question as "what are the benefit or what are the arguments to choose a queuing tool solution". My question is not about what language, technology, or project one should take up next. Thank you,


title: Which are C# 4.0 programming paradigms?

text: * Which are C# 4.0 programming paradigms?   * In what category does extension methods fall into? > A programming language can support multiple paradigms. For example, programs > written in C++ or Object Pascal can be purely procedural, or purely object- > oriented, or contain elements of both paradigms. > > In object-oriented programming, programmers can think of a program as a > collection of interacting objects, while in functional programming a program > can be thought of as a sequence of stateless function evaluations. When > programming computers or systems with many processors, process-oriented > programming allows programmers to think about applications as sets of > concurrent processes acting upon logically shared data structures. > > Just as different groups in software engineering advocate different > methodologies, different programming languages advocate different > programming paradigms. Source: Wikipedia


title: Why do most issue tracking systems have only single status field?

text: Most issue tracking systems have only single status field. Typical Status: New -> Fixed When code is pushed to repository with commit message "Fixed issue #1234", the issue #1234 is automatically mark as "Fixed". I have the below idea but no system can fulfill. **The question is: Am I right or just not finding the suitable tool?**   1. Programming status I think this is problematic because only the programmer says he has fixed an issue.   2. QA / release status It is not possible to know if QA team has verified or not. There is no place for QA team to mark the status. Also, even for open source projects, the end-user may not want to compile from source. The end-user is only interested in whether he can get a release version. If the new release is not ready to ship, from the point of view of the user, it is nothing "Fixed".   3. Feedback status It is also useful if the user can set the "feedback status" to "Fixed" after testing the released version or source code, rather than leaving a comment "Thanks, it works!". Status fields are searchable.


title: Ring of numbers where adjacent entries sum up to a prime

text: Given a number n, find a permutation of the numbers 1...n such that all adjacent entries sum up to primes. If such a permutation does not exist, throw an error. Is there a purely-functional way to do this problem? The solution, which apparently uses backtracking, given uses C++, a language which I am not very familiar with, and loops in loops in loops with very badly-named variable names and a whole lot of mutation. Even if the solution requires mutation, nested loops are really difficult to translate into Racket, the language I currently use. A more general question would be, how to do backtracking algorithms purely functionally when the concept of backtracking seems to always involve maintaining a state of where you are currently and a big history breadcrumb global state variable that keeps getting mutated? Of course the dumb way would be to generate all permutations and test them one by one, but are there more efficient ways, preferably implementing a backtracking method, to do so functionally? Since I use Racket, the solution might not be _purely_ functional but preferably mostly functional, i.e. no repeatedly mutating counter vars in loops or such.


title: Earliest use of Comments as Semantically Meaningful Things in a Program?

text: In certain corners of the PHP meta-programming world, it's become fashionable to use PHPDoc comments as a mechanism for providing semantically meaningful information to a program. That is, other code will parse the doc blocks and do something significant with the information encoded in those comments. Doctrine's annotations and code generation are an example of this. What's the earliest (or some early) use of this technique? I have vague memories of some early java _Design by Contract_ implementations doing similar things, but I'm not sure of those folks were inventing the technique, or if they got it from somewhere. Mainly asking so I can provide some historical context for PHP developers who haven't come across the technique before, and are distrustful of it because it seems a little crazy pants.


title: How to elevate engineering culture at large corporations?

text: One thing I have realized working at a large corporation is that it doesn't matter how smart you are because if everyone else doesn't see the value in what you are doing then you are not going to get very far. It's much harder to convince 1000 people that a certain part of the software stack should be in groovy than it is to convince 10 people of the same thing. I'm curious how people go about elevating the engineering culture at large corporations because I've been running into walls left and right and I would like to be more proactive about how I go about it. I have been advocating tech talks and tech demos along with code reviews as potential solutions. Do people have other suggestions? Note that 1000 people and groovy are just representative examples. I am not married to groovy or any other language and 1000 people is meant to indicate large scale and how to go about teaching a large group of people about best practices and engineering principles in general.


title: Application Development: Python or Java (or PHP)

text: I'm looking to get into application development, such as Facebook or Android apps and games. I am doing this for fun and to learn. Once my skills are to par I would like to have some side income from the apps, but I'm not banking on living off that (just so you know where I'm coming from and know what my end goals are). Currently I know and am familiar with PHP and frameworks such as cakephp and yii. However, I have been wanting to learn another language to broaden my horizons and to become a better developer. So I have narrowed it down to 2 languages. Python, and Java (I can already hear people cringing at the difference in the languages I have chosen, but I have some reasons). Python: closer to PHP than Java. Cross-platform. Also great as a general scripting language and has many file system level benefits that PHP does not. Cleaner syntax, readability, blah blah and the list goes on. Python will work great for cross platform apps and can be run on many OS's and is supported by Facebook for app development. But there is no support on Android (for full fledged apps). Java: a much stronger typed language, very robust community and corporate backing. Knowing Java is also good for personal marketability for enterprises, if you're into that. The main benefit here is that Java can write apps natively for Android and the apps can be ported for web versions to play on Facebook. So while I have seen many developers prefer Java over the two, Java has this significant advantage, where I can market my apps in both markets and in the future build more potential income. But like I said it is for fun. While money isn't the goal, it would still be nice. PHP: I'm putting this here because I know it already, and I'm sure a case could be made for it. It obviously works great for Facebook but like Python does not do so well on android. While it's mostly the realm of 'application development' that appeals to me, I do find Android apps fairly interesting and something that has a ton of potential to. But then again Facebook has a ton more users and the apps can also potentially be more immersive (desktop vs. mobile). So this is why I'm kinda stuck on what route to choose. Python for Facebook and web apps, with likely faster development to production times, or Java which can be developed for any of the platforms to make apps. Side note: I'm not really trying to get into 3D development, mostly 2D. And I also want to make an app with real-time play (websockets, etc). Someone mentioned nodejs to me for that but Python seems to be more globally versatile for my goals. So, to anyone that does Facebook or Android development in either language: what do you suggest? Any input is valuable and I do appreciate it. And sorry for being long winded. **EDIT:** as mentioned in one of the answers, my primary goal is gaming. Although I do have some plans for non-gaming apps such as general web based and desktop based ones. But gaming is my main goal with the possibility of income. **EDIT:** Another consideration could be Jython. Writing Python code which is converted into Java bytecode. This would allow the ability to do Android apps using Python. I could be wrong though, I'm still looking into it. **Update 1-26-11:** I recently acquired a new job which required I learn .NET using C#. Im sure some of you are cringing already but I really like the whole system and how it all works together between desktop and web development. But, as I am still interested in Python very much, and after some research I have decided I will learn Python as well as the IronPython implementation for .NET. But (again: I know...) since .NET is mostly a Windows thing and not as cross- compatible as I like, I will be learning Mono which is a cross platform implementation of .NET where I can use what I learn at work using C# and what I want to learn, Python/IronPython. So while learning and writing C#/.NET @ work I will be learning Python -> Mono -> Iron Python for what I want to do personally. And the benefit of them all being very closely related will help me out a lot, I think. What do you guys think? I almost feel like that should be another question, but there's not much of a question. Either way, you guys gave very helpful input.


title: Printing a table from mysql and php as PDF

text: I would like some help with printing out put of mysql tables as PDF. I have scenarios where a user views their details from the database printed to an HTML table, I would the same HTML table to also print in PDF.


title: Unit Testing of JavaScript - Are we testing the logic of the code or the behavior against a browser

text: [Warning]: I am new to the whole unit testing and have been trying to learn as much as possible. I am working on a MS CRM 2011 project and I have been trying to introduce unit testing in my company. For unit testing JavaScript web resources, I found this link at MSDN blog. The Solutions Architect in my company suggest that this is a bad approach as we are not even testing against the IE's JS engine but testing using CScript (Windows Host) and while I agree to that point, isn't the whole idea of Unit Testing all about testing the individual function's functionality and not about the dependency. For testing whether it will work within IE, would a testing tool such as Selenium not be better? Or am I missing something?


title: Implementing your own Membership Provider in ASP.NET MVC

text: Are there are any specific rules and regulation to follow while developing a custom membership provider. Like, implementing a particular Interface or Abstract class. Or a definite model architecture to follow. If yes, then what are the rules or I am free to design, model and code anything ?


title: Detecting Internet code leaks

text: I'm curious after reading today about a minor code leakage from a large project to some blogs & forums (to say it short: the guys forgot to _anonymize_ the code before asking for help), all detected and (angrily) complained by the **customer** who reasonably wanted to protect the IP they paid for. First of all, I know it's a good practice (correct me if I'm wrong), when required to disclose code to public sites in order to ask for help, to take appropriate _anonymization_ measures, like renaming in all snippets something like `com.thecompanyiworkfor` with `com.somecompany` or `com.bank.MortgageRiskCalculatorClass` to `com.somecompany.SomeGenericRiskIndicatorClass` and so on... Now, suppose I would like to find out **if** and **where** (and maybe _who_ , but it's not important now and it's not part of the question) the originally restricted code was leaked in order to properly react (read "send all the guys an email telling either they delete/clean posts or something bad will happen to the culprit", haha). I suppose that a good way could be googling something _unique_ that you could find in the code. For example, if I worked for Inintech I would try to google for `com.inintech` to see if somebody was stupid enough to paste code full with `import`/`using` directives. It's not a comprehensive method, it's based on the assumption that someone is better trying to protect the _binding_ between company and code (ie. for security by obscurity reasons, public image...) rather than preventing intellectual property from being freely available to the public. My straight questions are: ### Do you know/think there are other good practices to perform such investigations? How would you do that if your boss asks to find if someone leaked the company's code? I don't think someone would ever try to google for an entire source code file in one query string :) ### Do you know if there are companies performing such investigations? If so, what could you tell me about them more than their names, like the way they work?


Which according to you are the top languages to watch out for in 2011 and beyond? This article  talks about 9 languages to watch out for in 2011. What are your views and inputs on this?


title: How do you address or avoid problems with new features being quickly added to the scope of a project?

text: I am working on a project with a single developer (so far) and myself in a testing role. There are a bunch of new features being added. The project is .NET4.0 based, but some users need 3.5 compatibility, support for Silverlight and Windows Phone 7. These are all features wanted by users, but with the number of people participating in this project, it might get out of hand. What experiences do you have in controlling feature requests and scope creep?


title: Rules and advice for logging?

text: In my organization we've put together some rules / guildelines about logging that I would like to know if you can add to or comment. We use Java but you may comment in general about loggin - rules and advice   1. Use the correct logging level     * ERROR: Something has gone very wrong and need fixing immediately     * WARNING: The process can continue without fixing. The application should tolerate this level but the warning should always get investigated.      * INFO: Information that an important process is finished     * DEBUG. Is only used during development   2. Make sure that you know what you're logging.    3. Avoid that the logging influences the behavior of the application  The function of the logging should be to write messages in the log.   1. Log messages should be descriptive, clear, short and concise. There is not much use of a nonsense message when troubleshooting.   1. Put the right properties in log4j Put in that the right method and class is written automatically. Example: Datedfile -web               log4j.rootLogger=ERROR, DATEDFILE     log4j.logger.org.springframework=INFO     log4j.logger.waffle=ERROR     log4j.logger.se.prv=INFO     log4j.logger.se.prv.common.mvc=INFO     log4j.logger.se.prv.omklassning=DEBUG          log4j.appender.DATEDFILE=biz.minaret.log4j.DatedFileAppender     log4j.appender.DATEDFILE.layout=org.apache.log4j.PatternLayout     log4j.appender.DATEDFILE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}.%M] - %m%n          log4j.appender.DATEDFILE.Prefix=omklassning.     log4j.appender.DATEDFILE.Suffix=.log     log4j.appender.DATEDFILE.Directory=//localhost/WebSphereLog/omklassning/        1. Log value. Please log values from the application.   1. Log prefix. State which part of the application it is that the logging is written from, preferably with something for the project agreed prefix e.g. `PANDORA_DB`   1. The amount of text. Be careful so that there is not too much logging text. It can influence the performance of the app.   1. Loggning format: -There are several variants and methods to use with log4j but we would like a uniform use of the following format, when we log at exceptions: `logger.error("PANDORA_DB2: Fel vid hämtning av frist i TP210_RAPPORTFRIST", e);` In the example above it is assumed that we have set log4j properties so that it automatically write the class and the method. Always use logger and not the following: `System.out.println(), System.err.println(), e.printStackTrace()` If the web app uses our framework you can get very detailed error information from EJB, if using try-catch in the handler and logging according to the model above: In our project we use this conversion pattern with which method and class names are written out automatically . Here we use two different pattents for console and for datedfileappender:               log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n          log4j.appender.DATEDFILE.layout.ConversionPattern=%d [%t] %-5p %c - %m%n      In both the examples above method and class wioll be written out. In the console row number will also be written our.   1. `toString()` Please have a `toString()` for every object. EX:               @Override     public String toString() {       StringBuilder sb = new StringBuilder();       sb.append(" DwfInformation [ ");       sb.append("cc: ").append(cc);       sb.append("pn: ").append(pn);       sb.append("kc: ").append(kc);       sb.append("numberOfPages: ").append(numberOfPages);       sb.append("publicationDate: ").append(publicationDate);       sb.append("version: ").append(version);       sb.append(" ]");       return sb.toString();     }      instead of special method which make these outputs               public void printAll()     {         logger.info("inbet: " + getInbetInput());         logger.info("betdat: " + betdat);         logger.info("betid: " + betid);         logger.info("send: " + send);         logger.info("appr: " + appr);         logger.info("rereg: " + rereg);            logger.info("NY: " + ny);            logger.info("CNT: " + cnt);        }      So is there anything you can add, comment or find questionable with these ways of using the logging? Feel free to answer or comment even if it is not related to Java, Java and log4j is just an implementation of how this is reasoned.


title: Creating alternate keys with Visio ERD diagrams

text: I'm trying out Visio for the first time today, creating ERD's. Is it possible to specify alternate keys in _addition_ to PK's in Visio ERD diagrams. I can't see any way to define more than one key on a table. Any ideas? Cheers.


title: Refactoring code to separate concerns

text: While programming an object that represent a GUI, the class is a mix of code of following sections:   1. Overrides of super GUI, for behavior customization   2. Implementations of interface contracts, to talk/listen to other GUI objects   3. Local event handling methods   4. Local data crunching methods   5. Code to query/update a remote database and a global object provider Assuming all this is crammed into one class file, how would you split it into separate files or parent-child classes so that you can delegate these to different developers with minimum dependency on each other?


title: Should a method comment include both a summary and return description when they're often so similar?

text: I'm a proponent of properly documented code, and I'm well aware of the possible downsides of it. That is outside of the scope of this question. I like to follow the rule of adding XML comments for every public member, considering how much I like IntelliSense in Visual Studio. There is one form of redundancy however, which even an excessive commenter like me is bothered by. As an example take List.Exists().               /// <summary>     ///     Determines whether the List<T> contains elements     ///     that match the conditions defined by the specified predicate.     /// </summary>     /// <returns>     ///     true if the List<T> contains one or more elements that match the     ///     conditions defined by the specified predicate; otherwise, false.     /// </returns>     public bool Exists( Predicate<T> match )     {         ...     }      `Summary` and `returns` are basically saying the same thing. I often end up writing the summary more from a `returns` perspective, dropping the `returns` documentation altogether. > Returns true when the List contains elements that match the conditions > defined by the specified predicate, false otherwise. Additionally, the returns documentation doesn't show up in IntelliSense, so I rather write any immediately relevant information in `summary`.   1. Why would you ever need to document `returns` separately from `summary`?   2. Any information on why Microsoft adopted this standard?


title: How to quickly search through a very large list of strings / records on a database

text: I have the following problem: I have a database containing more than 2 million records. Each record has a string field X and I want to display a list of records for which field X contains a certain string. Each record is about 500 bytes in size. To make it more concrete: in the GUI of my application I have a text field where I can enter a string. Above the text field I have a table displaying the (first N, e.g. 100) records that match the string in the text field. When I type or delete one character in the text field, the table content must be updated on the fly. I wonder if there is an efficient way of doing this using appropriate index structures and / or caching. As explained above, I only want to display the first N items that match the query. Therefore, for N small enough, it should not be a big issue loading the matching items from the database. Besides, caching items in main memory can make retrieval faster. I think the main problem is how to find the matching items quickly, given the pattern string. Can I rely on some DBMS facilities, or do I have to build some in-memory index myself? Any ideas? **EDIT** I have run a first experiment. I have split the records into different text files (at most 200 records per file) and put the files in different directories (I used the content of one data field to determine the directory tree). I end up with about 50000 files in about 40000 directories. I have then run Lucene to index the files. Searching for a string with the Lucene demo program is pretty fast. Splitting and indexing took a few minutes: this is totally acceptable for me because it is a static data set that I want to query. The next step is to integrate Lucene in the main program and use the hits returned by Lucene to load the relevant records into main memory.


title: Is it efficient to attach a comment on every function?

text: I moved to this company recently, and my first reaction of the development process leaves me with doubts. Here is where I really doubt the efficiency: _Every single_ function _must_ have Javadoc style comment, and the code is tested by White-box Test automatically. Even when I write simple & short function, the function must have a Javadoc style comment. For example:               void request_ait(void)     {           hoa_request_ait();     }      If I write code without a Javadoc style comment, even for this simple function, the QA tool register it as a defect. So I write a simple comment template. For example:               /**       * @author peter       * @version 1.0       * @since   2011-08-28       */         void request_ait(void)         {               hoa_request_ait();         }      I know that comments on API functions or important functions are really useful. But forcing every function to have a Javadoc style comment is inefficient... I want to listen your opinion. Am I wrong?


title: File with Apache 2.0 and my modifications

text: I read the original text of Apache License, Version 2.0 and the explanation in plain English. OK, I copy a class distributed by _The Best Company in the World_ , their license, and modify the code a bit. **The original file with my changes.**               /*      * Copyright (C) 2011 The Best Company in the World      *       * Licensed under the Apache License, Version 2.0 (the "License");      * you may not use this file except in compliance with the License.      * You may obtain a copy of the License at      *       * http://www.apache.org/licenses/LICENSE-2.0      *       * Unless required by applicable law or agreed to in writing, software      * distributed under the License is distributed on an "AS IS" BASIS,      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.      * See the License for the specific language governing permissions and      * limitations under the License.      */          package com.mypackage;          public class MyClass {              private void someMethod() {             // Their code             // My little change         }     }      Then I use MyClass in my application.   1. Do I need to replace _The Best Company in the World_ with the name of my company or with my own name? If not, will my project contain two licenses: theirs and mine? Where to save them in this case?   2. And as far as I understand, I must distribute my application using Apache Licence, Version 2.0. Wikipedia says: > The Apache License is widely, but not universally, considered permissive in > that it does not require a derivative work of the software, or modifications > to the original, to be distributed using the same license (unlike copyleft > licenses – see comparison).


title: can you have too many dto/bo - mapping method

text: I have a windows service, 2 web services and a web interface that need to follow the same path (data wise). So I came up with two ways of creating my solution. ![first one](http://i.stack.imgur.com/zcPcD.png) My concern is the fact that the UI/WS/etc will have their own kind of DTO (let's say the model in ASP.Net MVC) that should be mapped to a DTO so the SL can then map it to a BO then mapping it to the proper EF6 DTO so that I can save it in a database. So I'm thinking of doing it this way ![second one](http://i.stack.imgur.com/viDm4.png) to remove one level of mapping. Which one should I take? Or is there a 3rd solution?


title: How can I access my Handler/runnable class from all my other classes in Android?

text: I am trying to create a class which allows me to do something every 5 seconds and I want to be able to start and stop this from running from any of the other classes. Here is my Timer class:               public class Timer extends Activity {          @Override     protected void onCreate(Bundle savedInstanceState) {         // TODO Auto-generated method stub         super.onCreate(savedInstanceState);               }              Handler handler = new Handler();         Runnable runnable = new Runnable() {                  public void run() {                      Toast.makeText(getApplicationContext(), "DISPLAY MESSAGE", Toast.LENGTH_SHORT).show();                 handler.postDelayed(runnable, 5000);             }         };     }      Now my knowledge on Object Orientated programming is not as good as I thought it was, I am used to creating instances of classes and using the classes properties, but how can I use a classes properties once across the whole program, do I still create instances of the Timer class in other classes? Should I use the Singleton pattern, or should I make the class static? So basically In Class1 I would like to start the timer by doing this:               Timer.runnable.run();      And perhaps in Class2 stop the runnable started in Class1 by doing this:               Timer.handler.removeCallbacks(runnable);      I am looking for advice and an explanation on the correct way to program this idea and why. Thank you!


title: How can Agile methodologies be adapted to High Volume processing system development?

text: I am developing high volume processing systems. Like mathematical models that calculate various parameters based on millions of records, calculated derived fields over milions of records, process huge files having transactions etc... I am well aware of unit testing methodologies and if my code is in C# I have no problem in unit testing it. Problem is I often have code in T-SQL, C# code that is a SQL stored assembly, and SSIS workflow with a good amount of logic (and outcomes etc) or some SAS process. What is the approach YOu use when developing such systems. I usually develop several tests as Stored procedures in a designed schema(TEST) and then automatically run them overnight and check out the results. But this is only for T-SQL. And Continous integration IS hard. But the problem is with testing SSIS packages. How do You test it? What is Your preferred approach for stubbing data into tables (especially if You need a lot data initialization). I have some approach derived over the years but maybe I am just not reading enough articles. So Banking, Telecom, Risk developers out there. How do You test your mission critical apps that process milions of records at end day, month end etc? What frameworks do You use? How do You validate that Your ssis package is Correct (as You develop it)/ How do You achieve continous integration in such an environment (Personally I never got there)? I hope this is not to open-ended question. How do You test Your map-reduce jobs for example (i do not use hadoop but this is quite similar). luke Hope that this is not too open ended


title: Support Vector Machines as Neural Nets?

text: This is more of a conceptual question. I have learned about Neural Nets, and I have some clue as to how Support Vector Machines work. I read somewhere however that given the appropriate kernel (is that right?), the SVM is identical to the Neural Net. Could someone who understands this please enlighten me as to how that's possible?


title: What's wrong with being a code monkey? (Or, what is a code monkey?)

text: Programmers tend to talk about being a "code monkey" in a derogatory way. "Don't work _there_ , you will just be a code monkey!". I have two offers for jobs, one at a small company, one at a very large company (same salary). My friend just told me I will be a code monkey at the large company, and knows from first hand experience that the small company will be more rewarding than reducing me to a "code monkey". I don't really understand the distinction between a "code monkey" and a "real" programmer. Please elaborate. I love programming, so to me the idea of sitting at a computer programming (i.e., code monkey) doesn't seem bad. What does a programmer mean by "code monkey" if he/she enjoys programming?


title: Is my description of the actor model right?

text: If I understood, the actor model is just like the object model, but with a few differences:   1. EVERY object spawns it's own separate thread and its not a problem even when you have thousands of objects.   2. Actors don't interact by calling functions and getting return values but instead by sending and receiving messages.   3. If you don't violate that model your app will be using concurrency to its full power without any risks of race conditions.   4. Everything you can do in OO you can do using actors but better, the problem being that everything we coded in the last years was OO based - but a transition is imminent. So for instance, suppose I have to define 3d vector class/actor, create two instance and call a sum operation on them. OBJECT ORIENTED:               class V3d {        constructor V3d(x,y,z) //bla        float x,y,z;        function sum(V3d b)         {            return V3d(x+b.x,y+b.y,z+b.z);         }     }          //using:     mySum = V3d(1,2,3).sum(V3d(3,2,1)) //creates 2 instances, sum, returns instantly     drawPoint(mySum) //uses the result      ACTOR MODEL:               actor V3d      {         constructor V3d(x,y,z) //bla         float x,y,z;         loop          {            receive 'sum',b:V3d :                send(caller,'sumResult',V3d(x+b.x,y+b.y,z+b.z))         }      }          //using:     send(V3d(1,2,3),'sum',V3d(3,2,1)) //creates 2 instances, send to the first one a request to sum with the second one          loop      {        receive 'sumResult',result:           drawPoint(result) //receives result and draws it     }      Is that it? Or am I completely wrong?


title: Questions about using open source software commercially?

text: Here's my situation: I'm starting a small computer repair business on the side. I'll be making house calls in my neighborhood but in the future I'd like to provide remote support. I was thinking of a VNC-based solution but I don't know if it would be practical to use an existing one or not. I was tossing around the idea of writing a custom VNC-based remote support solution. It would have all my own wording and logos so it would seem much more professional I think. First, how difficult would something like that be? I have a little coding experience and I usually just learn new things out of necessity, like in this case. Also, since I'd be basing my software off of open source and using it for profit, would that be allowed? Would I have to release the source? Thanks.


title: Daily builds with SVN for a small team

text: I have a general question regarding best practices. I have a small team working on a medium-scale software project, which involves integrating code from different environments, etc. The project is a standalone piece of desktop software. Based on lessons learned from a similar prior project that went badly, I am trying to implement some better software engineering practices. I'd like to start by automating daily builds. We use SVN for source control, and all the developers are working in the trunk, including me. My question is rather simple: Where locally do we do the daily builds? Should I make another folder on my local machine that is the "daily build" folder? Should I set up a virtual machine? Should I suck it up and do it in my development folder? I understand the revision control paradigms pretty well. I'm mostly looking for how folks implement it _in practice_.


title: Quantitfying a cost for a software project

text: _Disclaimer: I didn't know exactly where to put this question. If you feel that this question is not suitable for Programmers @ StackExchange, feel free to migrate it._ _Background:_ Broadening my last question, there is a request for tender for a software system that's open and I have decided to take it on. I am a software developer & engineer by profession and, in this tender process, I have to put on the pricing for my bid. I have been provided a documentation consisting of functional and non-functional requirements only. I have to put a project manager's cap on and think of all aspects, e.g. cost for implementation for the project, resources needed, etc. My question is: Is there a project framework that I can follow that breaks the project cycle into steps and corresponding cost aspect or how would I go about best calculating/approximating the cost for the project?


title: Is Ruby on Rails supposed to have a steep learning curve or is it just me?

text: I'm a self-taught programmer. I've been learning RoR since October with varying intensity (sometimes all day, sometimes nothing for several weeks). Before that I knew only Java, but knew it pretty well. I've heard so much hype about RoR and how it's supposed to make you happy, productive, etc. So far it's only made me frustrated. I learned it out of the Agile book, and I suspect part of the difficulty might have to do with my not knowing JavaScript and CSS, and having only a shaky grasp of databases and HTML. But apparently it took me much longer to complete the project in the Agile book than other people, and I still don't remember much of it. There are some things about Rails that I just can't seem to get, e.g. when to use symbols and when NOT to, or how dynamic methods are called. Recently I was given a small Rails assignment where I'm asked to make a small change to the interface. It's taken me around 25 hours and although I've made some progress in understanding the code, I still have no idea how to proceed. I can't even ask Stack Overflow because there is so much code I'll have to provide to give context. So my question is in the title: is RoR supposed to take a long time to learn or am I just slow? Can it be that I've been learning from the wrong book? My learning style is such that I either understand nothing or understand everything, if that makes sense.


Value types are types which do not have an identity. When one variable is modified, other instances are not. Using Javascript syntax as an example, here is how a value type works.               var foo = { a: 42 };     var bar = foo;     bar.a = 0;     // foo.a is still 42      Reference types are types which do have an identity. When one variable is modified, other instances are as well. Here is how a reference type works.               var foo = { a: 42 };     var bar = foo;     bar.a = 0;     // foo.a is now 0      Note how the example uses mutatable objects to show the difference. If the objects were immutable, you couldn't do that, so that kind of testing for value/reference types doesn't work. **Is there any functional difference between immutable value types and immutable reference types? Is there any algorithm that can tell the difference between a reference type and a value type if they are immutable?** Reflection is cheating. I'm wondering this mostly out of curiosity.