Can XCode work with TFS?

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.


Maintainability of Boolean logic - Is nesting if statements needed?

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.


2D grid with multiple types of objects

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)


Alternatives to pulling updates off the website

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.


Is measuring software project metrics popular in todays industry?

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


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

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?


svn vs git for the sole developer?

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?


How to represent (enum) types in a public API

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.


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

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


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

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?


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

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?


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

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.


Null checking whilst navigating object hierarchies

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.     }


How to protect software on an Amazon Machine Image?

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!


Database design for tagging system

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


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

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?


VPS versus Shared Hosting

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


Alternatives to the singleton pattern

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.


How should I implement a secure priority queue in C?

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?


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

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.


Any reason behind hyphens in a GUID?

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.


Is this an assembly language?

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. :-)


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

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?


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

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.


Delivery terminology and order of magnitude

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.


Implementation defined behaviour changing const type in c

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?


Organisation of Application Development Team Wiki?

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!


What are some best practices for deleting from source control?

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


API Auth vs User Auth

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?


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

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.


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

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,


What do you think of "Planning Poker"?

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?


Matrix Pattern Recognition Algorithm

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.


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

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.                 }            }     }


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

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.


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

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.


Why do programmers still use mailing lists?

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?


What to translate in a billingual software

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).


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

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?


C# Linq question

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.


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

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?


why no hasLock/testLock on mutexes

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


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

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?


Implementing a programming language without the specification

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?


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

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?


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

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.


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

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?**


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

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**.


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

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?


Methods on packaging an assembler with compiler

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.


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

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?


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

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.


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

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,


Which are C# 4.0 programming paradigms?

* 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


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

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.


Ring of numbers where adjacent entries sum up to a prime

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.


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

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.


How to elevate engineering culture at large corporations?

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.


Application Development: Python or Java (or PHP)

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.


Printing a table from mysql and php as PDF

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.


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

[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?


Implementing your own Membership Provider in ASP.NET MVC

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 ?


Detecting Internet code leaks

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?


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

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?


Rules and advice for logging?

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.


Creating alternate keys with Visio ERD diagrams

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.


Refactoring code to separate concerns

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?


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

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?


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

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.


Is it efficient to attach a comment on every function?

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?


File with Apache 2.0 and my modifications

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).


can you have too many dto/bo - mapping method

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?


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

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!


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

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


Support Vector Machines as Neural Nets?

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?


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

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?


Is my description of the actor model right?

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?


Questions about using open source software commercially?

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.


Daily builds with SVN for a small team

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_.


Quantitfying a cost for a software project

_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?


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

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.


How to justify technology choice to customer?

When freelancing / contracting a customer will typically specify functional requirements, acceptance criteria, etc, and the implementation details are in the developer's hands. As a developer your technology choice is a balancing act between what you are most familiar with, technologically what the right tool appears to be, ease of finding coders with this skill and their expense, and a few other factors. I'm in a situation where I have evaluated my options and selected a somewhat obscure open source technology that I believe will get me there faster, easier, and be more maintanable in the long term. It's different, but I think that that is what the requirements call for. The customer has inquired about what I'm going to use to build the solution, and now they are concerned because they've never heard of it before. The reasons for my choice are mostly technical, whereas the customer isn't (but they know some buzzwords!). Explaining these technical reasons will not be easy, and I am not sure if that is the right way to approach this situation anyway. And that's my question: what is the right way to approach this situation so as to cause the least amount of headache for everyone involved?


How do you decide what kind of database to use?

I really dislike the name "NoSQL", because it isn't very descriptive. It tells me what the databases _aren't_ where I'm more interested in what the databases _are_. I really think that this category really encompasses several categories of database. I'm just trying to get a general idea of what job each particular database is the best tool for. A few assumptions I'd like to make (and would ask you to make):   1. Assume that you have the capability to hire any number of brilliant engineers who are equally experienced with every database technology that has ever existed.   2. Assume you have the technical infrastructure to support any given database (including available servers and sysadmins who can support said database).   3. Assume that each database has the best support possible for free.   4. Assume you have 100% buy-in from management.   5. Assume you have an infinite amount of money to throw at the problem. Now, I realize that the above assumptions eliminate a lot of valid considerations that are involved in choosing a database, but my focus is on figuring out what database is best for the job on a purely technical level. So, given the above assumptions, the question is: what jobs are each database (including both SQL and NoSQL) the best tool for and why?


const vs. readonly for a singleton

First off, I understand there are folk who oppose the use of singletons. I think it's an appropriate use in this case as it's constant state information, but I'm open to differing opinions / solutions. (See The singleton pattern and When should the singleton pattern not be used?) Second, for a broader audience: C++/CLI has a similar keyword to `readonly` with `initonly`, so this isn't strictly a C# type question. (Literal field versus constant variable in C++/CLI) Sidenote: A discussion of some of the nuances on using const or readonly. My Question: I have a singleton that anchors together some different data structures. Part of what I expose through that singleton are some lists and other objects, which represent the necessary keys or columns in order to connect the linked data structures. I doubt that anyone would try to change these objects through a different module, but I want to explicitly protect them from that risk. So I'm currently using a "readonly" modifier on those objects*. I'm using readonly instead of const with the lists as I read that using const will embed those items in the referencing assemblies and will therefore trigger a rebuild of those referencing assemblies if / when the list(s) is/are modified. This seems like a tighter coupling than I would want between the modules, but I wonder if I'm obsessing over a moot point. (This is question #2 below) The alternative I see to using "readonly" is to make the variables private and then wrap them with a public get. I'm struggling to see the advantage of this approach as it seems like wrapper code that doesn't provide much additional benefit. (This is question #1 below) It's highly unlikely that we'll change the contents or format of the lists - they're a compilation of things to avoid using magic strings all over the place. Unfortunately, not all the code has converted over to using this singleton's presentation of those strings. Likewise, I don't know that we'd change the containers / classes for the lists. So while I normally argue for the encapsulations advantages a get wrapper provides, I'm just not feeling it in this case. A representative sample of my singleton               public sealed class mySingl     {         private static volatile mySingl sngl;         private static object lockObject = new Object();              public readonly Dictionary<string, string> myDict = new Dictionary<string, string>()         {             {"I", "index"},             {"D", "display"},         };              public enum parms         {             ABC = 10,             DEF = 20,             FGH = 30         };              public readonly List<parms> specParms = new List<parms>()          {              parms.ABC,              parms.FGH          };              public static mySingl Instance         {             get             {                 if(sngl == null)                 {                     lock(lockObject)                     {                         if(sngl == null)                             sngl = new mySingl();                     }                 }                 return sngl;             }         }              private mySingl()          {             doSomething();         }     }      Questions:   1. Am I taking the most reasonable approach in this case?   2. Should I be worrying about const vs. readonly?   3. is there a better way of providing this information?


Release build vs nightly build

A typical solution is to have a CI (Continuous Integration) build running on a build server: It will analyze the source code, make build (in debug) and run tests, measure test coverage, etc. Now, another build type usually known is "Nightly build": do slow stuff like create code documents, make a setup package, deploy to test environment, and run automatic (smoke or acceptance) tests against the test environment, etc. Now, the question:   * Is it better to have a third separate "Release build" as release build?    * Or do "Nightly build" in release mode and use it as a release? What are you using in your company? (The release build should also add some kind of tag to source control of potential product version.)


What are the reasons that make PHP more popular for freelancing world?

In many freelancing websites, you see many job ads for PHP (backed by MySQL). However, job ads for .NET, Java, Ruby, etc. are not that much. What are the reasons which make PHP so popular for freelancing? Is it because of its importance? Or is it because PHP is free? The reason I'm asking this question is that, I'm an ASP.NET developer and while I see that ASP.NET development productivity is higher (because of fascinating tools it has), it still doesn't attract developers as much as PHP. I want to know if I'm missing something here that I should take into account or no.


Algorithm design for comparing split times in a race

I need to determine the ranking of values in an array without altering their position, so that I can print the position of each split time next to the actual value of the split time in a table like so.

       Split 1	       Split 2	       Split 3

       4.66 (1)	       5.12 (3)	       4.75 (2)

      My array = [4.66, 5.12, 4.75] and I need to iterate through it and print the rank rank as seen in parenthesis above. I can't sort, because I need to do this for several decimals in the html table. Any suggestions for implementing this algorithm?


Productivity enhancing development strategies for small teams

I think one of the best ways to learn and become a better programmer is to share knowledge gained from working on personal or work projects with others. One way to do this at the workplace is to set aside an hour or so a week and let one or several team members present their progress on the part of the code base they have been working on. This is especially helpful when each team member has a specialized skill set. What are some other useful practices that managers can institute to increase team cohesion and improve productivity?


Common Industry Term For Negative Logging?

It is one thing to log something that happened in code, a process, or procedure. It is another thing to log something that didn't happen. For example, if your ETL system is supposed to receive a file every hour for import, and a file did not arrive at the usual appointed time, then it would be good to log "what didn't happen." I've called this negative logging, but I'm curious if there is an industry common term for this - a term which means "log both what happened **and what didn't happen**." Any idea?


Definition of "state"

What is a good way to define "state", as in state variable or state machine, to a new (previously non) programmer? What are some good ways to explain why this concept is useful for writing software? Is the concept of state explicitly taught in beginning programming courses or books commonly?


Securing client->database game

OK, I am creating a game using JavaScript and HTML5. The variables such as `map`, `x`, `y`, `level`, `exp`, etc are stored in JavaScript to keep track. On my client page, the JavaScript variables are stored to play along with the game. Every 5 seconds, the client page sends a POST AJAX call to the MySQL database and it successfully updates it. However a user can easily modify the JavaScript variables and cheat their way in the game. Then once they edit the JavaScript variables, the POST grabs that and updates it even though they edited it unethically. So, how do I prevent this from happening?


How do you call the process of taking a part of a function and making an individual function of it?

I know there was a **technical term** for this. I'm just can't remember what it was. If the title needs clarification, here is what I mean; If this is the old code:               Result foobar(Param1,Param2,Param3) {       code that does abc       code that does xyz       code that does asdf       more code that does something     }      and it's changed into:               SomeResult do_xyz(SomeParams) {       code that does xyz     }     Result foobar() {       code that does abc       do_xyz(args);       code that does asdf       more code that does something     }


Implementing custom "Remember Me" with Stripe

Implementing **remember me** with Stripe, while not using their `Checkout` (not supported on PhoneGap), seems to be fine using the path: **First time:**   1. Request token on the client side using card info.   2. Create customer on server side using token.   3. Upon confirm, charge customer. **Second time:**   1. Check if current user is Stripe customer by requesting the info from our server.   2. If is Stripe customer, show "use credit card on file" instead of regular CC form.   3. Upon confirm, charge customer. However, there is one important convenience items missing--last four digits of card number. Most sites inform you of the card you're using before making the payment, pretty important in case you have to switch out cards. I have seen that you can retrieve charges which would allow me to get the last four digits. Is it bad practice to pull that and display it? Are there alternative solutions anyone has in mind?


Does a custom scripting language require it's own compiler/assembler?

Or is the script generally converted to a known language such as C++ first? And how generally to you integrate a scripting language with the say a game engine?