Mobile (Client) to Amazon S3 (Server) - Architecture

let's start off with the problem statement: My iOS application has a login form. When the user logs in, a call is made to my API and access granted or denied. If access was granted, I want the user to be able to upload pictures to his account and/or manage them. As storage I've picked Amazon S3, and I figured it'd be a good idea to have one bucket called "myappphotos" for instance, which contains lots of folders. The folder names are hashes of a user's email and a secret key. So, every user has his own, unique folder in my Amazon S3 bucket. Since I've just recently started working with AWS, here's my question: What are the best practices for setting up a system like this? I want the user to be able to upload pictures directly to Amazon S3, but of course I cannot hard-code the access key. So I need my API to somehow talk to Amazon and request an access token of sorts - only for the particular folder that belongs to the user I'm making the request for. Can anyone help me out and/or guide me to some sources where a similar problem was addressed? Don't think I'm the first one and the amazon documentation is so extensive that I don't really know where to start looking.


Role of "Refactoring" in good programming pratices?

I have learned in Agile Development that: > Refactoring is the process of clarifying and simplifying the design of > existing code, without changing its behavior. I have heard about some GUI refactoring tools like ReSharper and DevExpress Refactor Pro! Here are my questions:   1. How does it takes place in the Software development process and how far it effects the system?   2. Does Refactoring using these tools really speed up the process of development/maintenance?


How to choose a good namespace name? (Linguistically)

English in not my native language, therefore it is a little more difficult to pick a good name for a namespace. One example to make you see my problem a bit better: We have a set of classes that have to do with the way a company is organized (we can create organizational charts with it). Currently the namespace is `CFW.CoreSystem.Organizational`. Is this a good name? What is **linguistically** the best way to name a namespace? (`CFW.CoreSystem.Configuration` is better than `CFW.CoreSystem.Configurables`). [Moved it from StackOverflow]


Should an abstract class always abstract its methods to an interface?

I had learned sometime ago that abstract classes should always abstract their functions to an interface. So instead of having something like this -               abstract class a{         public int i;         public int foo();     }          class b : a{         public int foo(){return 42;}     }      we have something like this -               interface Ia{         public int foo();     }          abstract class a : Ia{         public int i;     }          class b : a{         public int foo(){return 42;}     }      From my perspective, this is better because of single responsibility, modularity, and maintainability. My colleague disagrees though, and states that there is no perceivable advantage to this and that it only adds to complexity. I tried to find some writing on this topic, but I cant remember the pattern name and my googling hasn't turned anything up. Is this pattern an actual thing? Was I right to abstract everything as much as I can, or is my colleague correct?


Trying to understand how MySQL license applies to code I wrote

I have an ERP, coded with Java and the database in MYSQL Community edition. When I was going to sell it to a client he asked me for the sources to my application (with the belief that it is GPLed). I already got an upfront payment from him. But now he asks me to deliver the source code for my ERP with the executable. When I told him no, he responds that as I am using MySQL community edition the project must be open source, and I must give him the sources. He is not willing pay extra for the source for what I wrote. It doesn't seem like the MySQL license should affect the license of the code I have written. But is that true?


GPL'ing code of a third party?

I am facing the following dilemma at the moment. I am using code from a scientific paper in a commercial project. So basically I copied and pasted the code from the paper's pdf into my code editor and use it in my own code. The code in the paper **does not** have any copy restrictions or license(like the GPL) so I thought I would be ok using it in a commercial project. However, I have seen several gpl licensed open source projects that use the **exact** same code from the paper to the point of having the same variable names like in the paper. So what happened here is that a gpl license was put on a third parties non gpl'ed code. Are these open source projects in violation of the gpl or would I be in violation of the gpl because I use code which has been gpl'ed? My common sense tells me it is not allowed to gpl somebody elses non-gpl'ed (like in this case from the paper) code but I though I would ask anyway.


Python - Service, how to get a code review

I am usually a PHP and Delphi developer and have been getting into Python lately. I am developing an app and would love to get some feedback on the code, there are few things which I would love to tidy up myself but I am sure there are other things. Where / how is a good way to get in touch with an experienced Python dev? Paying is no problem.


Multiple many to many relations or one option table?

Let's say I have a database of persons who have some properties. For the sake of this problem let's say all of these properties relate as N-N. I can either create two tables for each property (one for different values and one for cross-referencing them to the main object). Or, I can make the following structure: ![enter image description here](http://i.stack.imgur.com/S93FG.png) Basically having just one huge table of values. Are there any advantages to this approach? Also, does this approach or pattern have a name that I can look up? UPDATE: For example, we make classifier `pets` with properties `cat`, `dog` and `fish`. So one person may have a `cat` and a `dog` (or one pet, or none). And we make a classifier `hobby` with values `skiing`, `skating`, `football` and `TV`. So Joe has properties `cat`, `dog`, and `TV`. Then `cat` and `dog` are `pets` and `TV` is `hobby`. The question is, is it worthwhile to put this data using this diagram, or is it a better idea to just create `pets`, `pets_xref`, `hobby`, `hobby_xref` tables?


Reviews of Company Codebases

Does anybody know of a solid source of information regarding the quality/details of a company's codebase? I'm asking as a potential employee of some companies, having been highly dissatisfied by the technology stack of some companies I've worked with in the past. I considered creating a website like this a while back, but ultimately decided that it was really just a subset of what features a site like Glassdoor could offer. Glassdoor has a great site for company reviews, but seems mostly geared towards salary information and is much more general-purpose than this.


Is prefixing symbols also considered as namespacing?

For example, the Objective-C convention is to prefix the symbols with two or three capital letters which are abbreviations of the project: NSString, CABasicAnimation, MGTwitterEngine… In C, many projects also do this (OpenGL and nginx for example). Is this also considered namespacing or am I missing something?


Is a Scrum Master needed on a high performing team?

My understanding of the duties of the scrum master are as follows:   * Enforce the process   * Remove impediments (that the developers cannot remove themselves)   * Prevent interruption from outside   * Facilitate scrum meetings (stand up, retrospective, etc.) If the developers on the team are disciplined, they will follow the process without someone coaching them. They will also have no problem holding retrospective and other scrum meetings. If the rest of the organization understands the sprint boundaries, outside interruptions and impediments that would require a scrum master are already minimized. As a team becomes high performing and an organization understands the sprint boundaries, it seems as though the needs for a scrum master reduce. Is it possible for a team to eventually get to the point where a scrum master is no longer needed?


Why C# is not statically typed but F# and Haskell are?

There was a talk given by Brian Hurt about advantages and disadvantages of static typing. Brian said that by static typing he don't mean **C#** , but **F#** and **Haskell**. Is it because of `dynamic` keyword added to C#-4.0? But this feature is relatively rarely useful. By the way, there are `⊥` and `unsafeCoerse` in Haskell which obviously are not the same, but something that could blown your head off in runtime similarly like exception thrown as a result of `dynamic`. Finally, why F# and Haskell could be named a statically typed languages and C# couldn't?


Attaching Events to Document Better Than Attaching Them to Elements?

While bouncing around StackOverflow, I've noticed a number of people attaching events (notably `click` events) to the `document` as opposed to the `elements` themselves. **Example:** Given this:               <button id="myButton">CLICK ME</button>      Instead of writing this (using jQuery just for brevity):               $('#myButton').on('click', function() { ... });      They do this:               $(document).on('click', function() { ... });      And then presumably use `event.target` to drill down to the element that was actually clicked. Are there any gains/advantages in capturing events at the `document` level instead of at the `element` level?


Is "funny commenting" a bad practice or not?

I want to ask you whether adding some "easter eggs" in the source documentation is unprofessional or not. Probably you have read the StackOverflow poll for funny comments in a source documentation, and I have personally stumbled at many such things during my work, including funny (or not) stuff in public API documentation (for example this weak BZZZTT!!1! thing in Android public documentation, I can give at least a dozen more examples). I can't come to a final opinion for myself, because I have contradicting arguments by myself. Pro argument:   * It can cheer up somebody, and make his/her day funnier/more productive. Major portion of the source code doesn't need to be commented anyway (if the project is done properly), because the specific method (for example) is self explanatory, or if it is a pile of strange crappy code, it can't be explained in a meaningful way, so a funny joke doesn't harm the possible info that you can obtain from the doc.  Cons argument:   * If you are very concentrated/frustrated, the last thing you need is somebody's stupid joke, instead of giving you information you need about the documented code portion, it can just make you even more frustrated. And the idea of what the documentation would look like if everybody starts doing so is horrible. Plus the guy who writes the joke may be the only one who thinks that it is funny/interesting/worth wasting time to read it. What do you think?


What is the correlation between the quality of the software development process and the quality of the product?

I used to believe the practicing "good" software development methods tends to yield a better product in the long run. However, I've seen quite a few cases where "quick-and-dirty" \ "brute-force" \ "copy-paste" programming appeared to give decent results quicker, and cheaper. This appears especially in cases where time to market is more critical then maintenance overhead. Is there a correlation between the quality of the development process and techniques and the quality of the product?


How can I get started as a freelance programmer?

Assume that I know zero about freelancing, but I am a good .NET programmer. I want to start freelancing. How would I get started?


What are studies comparing programmer productivity in determined languages/environments?

I'm not sure if I'm using the right terms, but with productivity I mean the concept of transforming an idea/design in actual software.


OOD: class hierarchy with method arguments forming another hierarchy

I'd like to find out how do you guys handle the following situation: you have a class hierarchy, call it H1, with some polymorphic method that is supposed to accept an argument which type forms hierarchy H2 in the following way: the higher the class is in H1, the higher H2 argument it accepts.               +-----------+           +-----------+     |     A     |           |     A'    |     |-----------+           +-----------+     |method(A') |                 ^     +-----------+                 |           ^                 +-----------+            |                 |     B'    |     +-----------+           +-----------+     |     B     |                 ^     |-----------+                 |     |method(B') |           +-----------+      +-----------+           |     C'    |           ^                 +-----------+           |     +-----------+     |     C     |     |-----------+     |method(C') |     +-----------+      Before writing any code I mention that I have two protocol classes with methods `check` that have much in common, but request parameters are specific for concrete arguments -- transactions. The language is scala, but the problem is language-agnostic. At the first glance it should look like that:               trait BaseMerchantProtocol     {       def check(transaction: BaseTransaction) = {         // some common code...         println(requestParams(transaction))         // ...and here as well       }            protected def requestParams(transaction: BaseTransaction)     }          class SmsCommerceMerchantProtocol extends BaseMerchantProtocol     {       override protected def requestParams(transaction: SmsCommerceTransaction) = {         List("result specific for SmsCommerceTransaction class")       }     }          class TelepayMerchantProtocol extends BaseMerchantProtocol     {       override protected def requestParams(transaction: TelepayTransaction) = {         List("result specific for TelepayTransaction class")       }     }      But of course it does not compile as Liskov substitution principle is violated. Let's try this one:               trait IMerchantProtocol {       def check(transaction: SmsCommerceTransaction)       def check(transaction: TelepayTransaction)     }          class MerchantProtocol extends IMerchantProtocol     {       def check(transaction: SmsCommerceTransaction) = {         doCheck(transaction)       }            def check(transaction: TelepayTransaction) = {         doCheck(transaction)       }            private def requestParams(transaction: SmsCommerceTransaction) = {         List("result specific for SmsCommerceTransaction class")       }            private def requestParams(transaction: TelepayTransaction) = {         List("result specific for TelepayTransaction class")       }            private def doCheck(transaction: BaseTransaction) = {         // some common code...         println(requestParams(transaction))         // ...and here as well       }     }      But that won't compile as well -- and with the same reason: `doCheck` accepts `BaseTransaction`, but `requestParams`s have more strict preconditions. The only thing that I came up with and that works is the following:               class MerchantProtocol extends IMerchantProtocol     {       def check(transaction: SmsCommerceTransaction) = {         doCheck(transaction, requestParams(transaction))       }            def check(transaction: TelepayTransaction) = {         doCheck(transaction, requestParams(transaction))       }            private def requestParams(transaction: SmsCommerceTransaction) = {         List("result specific for SmsCommerceTransaction class")       }            private def requestParams(transaction: TelepayTransaction) = {         List("result specific for TelepayTransaction class")       }            private def doCheck(transaction: BaseTransaction, requestParams: List[String]) = {         // some common code...         println(requestParams)         // ...and here as well       }     }      But I don't like that all `check` methods belong to the same class. How can I split them by classes?


How should a REST API handle PUT when missing parameters?

I have a list of users that are being assigned to a certain office. I use checkboxes to select each user and when the client is done, a PUT is performed:               PUT offices/:id          users[0] : 14     users[1] : 12     users[2] : 25      The problem occurs when the server has users saved, but the client decides to clear the board. So he deselects the users and hits save. The problem in this case is that the Ajax request is not sending an empty `users[0] :` parameter, because each checkbox is unchecked. In the case when a parameter is not included at all, should PUT overwrite that it and set it to null or should the request include the empty parameter somehow?


C# inherit from a class in a different DLL

I need to make an application that needs to be highly modular and that can easily be expanded with new functionality. I've thought up a design where I have a main window and a list of actions that are implemented using a strategy pattern. I'd like to implement the base classes/interfaces in a DLL and have the option of loading actions from DLL's which are loaded dynamically when the application starts. This way the main window can initiate actions without having to recompile or redistribute a new version. I just have to (re)distribute new DLL's which I can update dynamically at runtime. This should enable very easy modular updating from a central online source. The 'action' DLL's all inherit their structure from the code defined in the the DLL which defines the main strategy pattern structure and it's abstract factory. I'd like to know if C# /.Net will allow such a construction. I'd also like to know whether this construction has any major problems in terms of design.


What next steps to gain contributors to my programming language Wake?

I have spent several months creating the language Wake. It is now in alpha status, meaning its highly usable but still has many planned features -- features which will be slow to create with only one developer. Being in an alpha release, I don't want to go for too much publicity too soon. I don't want to push anyone to use it in production, or have Wake remembered as "that language that is in the works." The number one thing at this point is gaining contributors. I did a presentation (there's a video on youtube) to friends and family that might have gained me one or two, probably more help on styling and docs than feature development. Do you think the language is ready for   * sharing on reddit   * presenting at conferences   * pitching to companies for supplementary help   * adding to package databases like ubuntu, brew, chocolatey, etc   * sharing on lambda the ultimate And what other publicity actions could I take? Do you think I need to write "how to contribute" articles? I have been planning on making a blog post _From the ashes of Google's Noop comes a new language: Wake_ to take a piggy-back approach to marketing it. Is that sort of introduction good to broadly publicize right now?


S-Shaped Perl Program?

In his Why I Hate Django presentation, Cal Henderson brings up this awesome program in Perl which is a giant "S," which solves a Sudoku problem. Does anyone know where I could get access to this code? I've been searching for it and I'm just dying to be able to read it.


How to implement lazy evaluation of if()

I am currently implementing an expression evaluator (single line expressions, like formulas) based on the following:   * the entered expression is tokenized to separate literal booleans, integers, decimals, strings, functions, identifiers (variables)   * I implemented the Shunting-yard algorithm (lightly modified to handle functions with variable number of arguments) to get rid of parenthesis and order the operators with a decent precedence in a postfixed order   * my shunting-yard simply produces a (simulated) queue of tokens (by means of an array, my Powerbuilder Classic language can define objects, but only have dynamic arrays as native storage - not true list, no dictionary) that I evaluate sequentially with a simple stack machine My evaluator is working nicely, but I am still missing an `if()` and I am wondering how to proceed. With my shunting-yard postfixed and stack based evaluation, if I add `if()` as another function with a true and false parts, a single `if(true, msgbox("ok"), msgbox("not ok"))` will show both messages while I would like to show only one. This is because when I need to evaluate a function, all of its arguments has already been evaluated and placed on the stack. Could you give me some way to implement `if()` in a lazy way? I though about processing these as a kind of macro, but at early time I have not yet the condition evaluation. Perhaps that I need to use an other kind of structure than a queue to keep separately the condition and the true / false expressions? For now the expression is parsed before evaluation, but I also plan to store the intermediate representation as kind of precompiled expression for future evaluation. **Edit** : after some though on the problem, I think I could build a tree representation of my expression (an AST instead of a linear token stream), from which I could easily ignore one or another branch of my `if()`.


Audio Sync : Detecting current time of a program

I am trying to do some audio sync things (see Wikipedia on acoustic fingerprints). I know it is possible to place watermarks in an audio signal to analyse it later, but how would I do to get the current time of a video? Would it be something like placing a watermark each second? Wouldn't placing so much watermarks create the risk of having false positive? Also, I have tried to read audio frequencies on my Android phone (with zero crossing) but it is not very precise. So on a less conceptual topic: Could anyone advice me on a good way to detect audio watermark for smartphones/tablets?


What's your suggestion if the company didn't recognize my contribution towards a big project?

I am an entry level developer with 1 year of experience. I have worked on a large scale project which I have played around 80% of the project work, those 5 months were terrible to me - late nights spent working, even Sundays. i have worked on whole Process Model , doing some of my colleagues work ,DB Design ,client feedback all this but the point is some of my work been owned by my Team Lead & hope now realize why i mention 80% of work is done by me! Now the project is completed, and the client seems completely satisfied with the work. But, I haven't found the company to give any sort of encouragement / appreciation. My seniors who where not involved in the project were given praise, leave, bonuses, etc. Also I was rejected permission to attend an important family function - that makes me ask "what's the credit I have now"? I have been wondering, is being honest/dedicated to the job what resulted in this situation? I have currently gotten 3 offers with good package - I've been thinking to move on to any of the companies now. What's your suggestion at this point of time?


UTF-16 Pitfalls, Chinese

I'm going to be writing an application that is pure HTML5 and JS and MVC.net back-end. We have .resx files that are getting compiled to .js files for resources in the html5 application. The application has to work in English and in Chinese which I understand to mean that we need to use UTF-16 everywhere. Does anyone have any experience using UTF-16 for such a task, or any best practices thereof?


Zend PHP 5.3 certification

I'm planning to give the Zend PHP 5.3 certification. Any suggestions on how to prepare for it? Also, what kind of questions can I expect? Can anyone remember what they were asked?


Should you apply a language filter to a randomly generated string?

A while back I created a licensing system for my companies new product, as well as all products after this one. As with a lot of licensing systems mine generates codes: 25 character product and registration codes, as well as 16 character module unlocking codes. My question is, since some parts of these generated codes are random should I apply a language filter to it to avoid any embarrassing language being given to the end users? I chose to as it was not difficult at all. But has anyone else ever came across something like this? Any viewpoints as to if it is worth the effort?


What is a good C++ API Design for HW registers?

I am designing an API for a driver that manipulates HW. I have done the following:               namespace HWRegister     {         //private:         namespace Data         {             //accessible only within this namespace                  //Represents one of the four HW blocks.             enum EHWUnit             {                 Block0,                 Block1,                 Block2,                 Block3             };                  enum EHWSet             {                 Rx0,                 Rx1,                 Rx2,                 Rx3,                 Tx0,                 Tx1,                 Tx2,                 Tx3             };         }              using namespace Data;              //Returns Error Code         int32_t enableHWUnit( const EHWUnit aHWNumber, const EHWSet aHWSet );         //Returns Error Code.         int32_t disableHWUnit( const EHWUnit aHWNumber );      I would like to get peoples opinion on this. I am wondering if those enums are a good idea, I declare them here and therefore people who use my API are forced to use them, will this cause more problems for the callers of my API? Can I improve this API somehow? I will add more documentation into the API when I am sure it is looking good.


How would I programmatically verify gift cards on a website?

I'm trying to include a feature on my website that verifies retail gift card balances on cards previously registered at the retailer's website by the card holder. Can this simply be done by writing an algorithm that pulls and aggregates this data on my site?


Less code or less operation

Sometimes I hesitate between "More code to avoid unnecessary operations" and "less code but with redundant operations". Let me just take an example (Win32 API): I try to paint some controls manually when the cursor is over it. If the cursor is over this control and it is painted, then it doesn't need to be painted again before the cursor goes out from it. Of course, I can just paint this control whenever a `WM_MOUSEMOVE` appears. Or, I can use more variables to record the state of this control and paint it only when the state is changed. Although it is not a question (in practice) in my example, I still want to have a feeling for which is the better choice, in general. And if this depends on cases, any way to develop a good sense to do the choice? (I am not focus on "efficient". It is more or less like a question as: If you are an idealist of programming, which one is better in your opinion.)


Project based prefix for class names

My project leader uses project based prefixes for class names, lets say projects name ABC, he create User class name as ABCUser. and he says he do this becasuse if he wants to make User.aspx Users get mixed. so I told him why not use namespace (Entity.User ie.) to make it specific but he against it. I would like to hear from you guys' opinion on this subject. We code c#.net and using visual studio for projects.


Learning C# in a unified manner

Microsoft technologies keep getting better but they do so on the expense of adding one more abstraction layer every time. In the early stages we used to play with C# code and SQL procedures to perform CRUD operations. Then generics came along with ADO.NET, DataSets, Entities. Next, LINQ came offering LINQ to SQL, to XML, to Entities, to Objects. To get more easier and more confusing, EF 4.1 came. C# just kept evolving and adding new abstractions layers again and again. The end result is that I am so confused that I don't know which one is which and when to use which one. When I try to follow books, some teach EF while some are stuck with ADO.NET. Seriously I have no clue whatsoever why we have evolved so much for data manipulation To be honest, all I know is the C# syntax and some basic stuff. Data manipulation is out of the window and so are the advanced features.   * Is there a unified manner to learn C# ? I don't want to use Entity Framework and LINQ when I don't understand them or what they offer. I just want to have a thorough understanding from Level 0 to Level 10.    * Also, I am thinking of learning PHP simultaneously because I feel learning some other language will might help me understand C# better. Is this the right thing?


How relevant are Brainbench scores when evaluating candidates?

I've seen many companies using certification services such as Brainbench when evaluating candidates. Most times they use it as a secondary screen prior to interview or as a validation to choose between candidates. What is your experience with Brainbench scores? Did you try the tests yourself, and if so do you feel the score is meaningful enough to be used _as part_ of a hiring process? * * * Difficult choice. Consensus seems to be that BB cert are not very good as a certification. The biggest argument was around the fact that some of the questions are too precise to form a good evaluation. This view can probably be tempered somewhat but still, to hold someone's future solely on the results of this evaluation would be irresponsible. That said, I still think it is possible to use them properly to gain additional objective knowledge on a candidate's level of expertise provided the test is done in a controlled environment ensuring that all taking it stand on equal footing. Thus I went with the answer that best reflected this view keeping in mind that it is still just an hour long 50ish multiple choice question to evaluate skills and knowledge that take years to acquire. To be taken with a grain of salt ! In short, the tests have value but whether or not they are worth the money is another debate. Thanks all for your time.


UI Testing with Visual Studio 2010 Feature Pack 2

One of the most intriguing items in the recently released Visual Studio 2010 Feature Pack 2 is the ability to create and edit UI tests in Silverlight. Here is an example of a coded UI test. I haven't had much time to use it yet, but for people who have, I am curious as to what your thoughts are. Is this something you have found to be particularly useful? I would like to be able to automate a significant amount of regression testing that we are currently performing manually. In your experience, has it made a major impact on the resources that you would normally have to dedicate to testing? Thanks


Approach to Authenticate Clients to TCP Server

I'm writing a Server/Client application where clients will connect to the server. What I want to do, is make sure that the client connecting to the server is actually using my protocol and I can "trust" the data being sent from the client to the server. What I thought about doing is creating a sort of hash on the client's machine that follows a particular algorithm. What I did in a previous version was took their IP address, the client version, and a few other attributes of the client and sent it as a calculated hash to the server, who then took their IP, and the version of the protocol the client claimed to be using, and calculated that number to see if they matched. This works ok until you get clients that connect from within a router environment where their internal IP is different from their external IP. My fix for this was to pass the client's internal IP used to calculate this hash with the authentication protocol. My fear is this approach is not secure enough. Since I'm passing the data used to create the "auth hash". Here's an example of what I'm talking about:               Client IP: 192.168.1.10, Version: 2.4.5.2     hash = 2*4*5*1 * (1+9+2) * (1+6+8) * (1) * (1+0)     Client Connects to Server     client sends: auth hash ip version     Server calculates that info, and accepts or denies the hash.      Before I go and come up with another algorithm to prove a client can provide data a server (or use this existing algorithm), I was wondering if there are any existing, proven, and secure systems out there for generating a hash that both sides can generate with general knowledge. The server won't know about the client until the very first connection is established. The protocol's intent is to manage a network of clients who will be contributing data to the server periodically. New clients will be added simply by connecting the client to the server and "registering" with the server. So a client connects to the server for the first time, and registers their info (mac address or some other kind of unique computer identifier), then when they connect again, the server will recognize that client as a previous person and associate them with their data in the database. Edit: The approach I ended up going was this: I ended up using an approach similar to what OpenSSH does, but reverse. Since when a client connects, I'm not sure I can trust the client. If it is the first time a client is connecting, it will provide me with a public key and a unique identifier (In this case, I will be using a computer's service tag since the computers I'm going to be dealing with are all Dells). The server stores the id and public key in the database then sends the client a secret question encrypted using the public key. The client will then need to respond with the decrypted answer. Before a client can be accepted by the server, I may end up doing a unique id registration on the server manually before connecting the client for the first time, this way not any sly person can just generate public keys and emulate what a client does with a "new unique id". Thanks for the help! I hope this helps someone down the line. Feel free to tear apart the security flaws of this approach :)


Will you work with much less experienced not passionate coworkers? Or they slow you so much that you should always try to work with at least as experienced and passionate as you coworkers. Will less experienced not passionate coworker reduce your productivity?


Scuttlebutt Reconciliation from "Efficient Reconciliation and Flow Control for Anti-Entropy Protocols"

_This question might be more suited to math.stackexchange.com, but here goes:_ ## Their Version Reconciliation takes two parts-- first the exchange of digests, and then an exchange of updates. I'll first paraphrase the paper's description of each step. To exchange digests, two peers send one another a set of pairs-- (`peer`, `max_version`) for each peer in the network, and then each one responds with a set of deltas. The deltas look like: `(peer, key, value, version)`, for all tuples for which `peer`'s state maps the `key` to the given `value` and `version`, and the version number is greater than the maximum version number `peer` has seen. This seems to require that each node remember the state of each other node, and the highest version number and ID each node has seen. ## Question Why must we iterate through all peers to exchange information between p and q?


Why big internet companies (Google, Facebook, Twitter, etc) going open source way?

These very large internet companies using, developing, and promoting open source technologies like crazies. What is the rationale behind promoting and developing open source tools and technologies rather than closed source software like traditional tech companies (Microsoft, Apple, Adobe)?


Dependency Injection/IoC container practices when writing frameworks

I've used various IoC containers (Castle.Windsor, Autofac, MEF, etc) for .Net in a number of projects. I have found they tend to be frequently abused and encourage a number of bad practices. Are there any established practices for IoC container use, particularly when providing a platform/framework? My aim as a framework writer is to make code as simple and as easy to use as possible. I'd rather write one line of code to construct an object than ten or even just two. For example, a couple of code smells that I've noticed and don't have good suggestions to:   1. Large number of parameters (>5) for constructors. Creating services tends to be complex; all of the dependencies are injected via the constructor - despite the fact that the components are rarely optional (except for maybe in testing).   2. Lack of private and internal classes; this one may be a specific limitation of using C# and Silverlight, but I'm interested in how it is solved. It's difficult to tell what a frameworks interface is if all the classes are public; it allows me access to private parts that I probably shouldnt touch.   3. Coupling the object lifecycle to the IoC container. It is often difficult to manually construct the dependencies required to create objects. Object lifecycle is too often managed by the IoC framework. I've seen projects where most classes are registered as Singletons. You get a lack of explicit control and are also forced to manage the internals (it relates to the above point, all classes are public and you have to inject them). For example, .Net framework has many static methods. such as, DateTime.UtcNow. Many times I have seen this wrapped and injected as a construction parameter. Depending on concrete implementation makes my code hard to test. Injecting a dependency makes my code hard to use - particularly if the class has many parameters. How do I provide both a testable interface, as well as one that is easy to use? What are the best practices?


How Do You Effectively Use Trace And Debug

I'm a self taught C# programmer and up to now I haven't really been making use of Debug and Trace and feel as though I should use them. I've been leaning more on TDD to understand and get feedback from my code. The .Net Framework Developers Guide declines to specify general guidelines for strategic placement of trace statements _"because applications that use tracinig vary widely..."_ ; What are your experiences of using Debug/Trace? Does using them too much create code maintenance issues? How much output is too much? How much is too little? What sorts of things do you tend to record?


Program Loaders in Linux and Windows

I was wondering what the loaders in Linux and Windows are called, i.e., their command names? Loaders' definitions are > In computing, a loader is the part of an operating system that is > responsible for loading programs.


Teaching programmer looking for a simple statically and weakly typed language

I'm trying to illustrate the differences between the four different type systems -- static vs. dynamic typing and weak vs. strong typing.   * Dynamic + weak = JavaScript   * Dynaimc + strong = Python   * Static + strong = Java (is there a good _purely_ interpreted language for this? The Java "compiler" can be annoying without a framework like Ant of Maven)   * Static + weak = ??? For static + weak the one that is most immediately apparent is C++, with operator overloading, pointer arithmetic, and, frankly, the ability to treat almost any data type as some form of number, it seems like it would be a very clear example of static typing and weak typing. But, it is also _incredibly_ complicated, especially if I want to teach a **beginner**. What alternative teaching languages are there for beginners which are both statically and weakly typed? Ideally something which is easy to install and get running with minimal effort? (Even more ideally, something which supports OOP in some form?)


Offline demo of website - tools to handle "saved" external links

I am designing a test (demo to users) of a web site from my local machine without Internet access. The site will be hosted locally, but I would also like users to be able to follow links to certain external sites. Are there tools that can make the user think they are browsing a site online when they are actually browsing a local copy of the relevant external pages? The kind of tool I'm imagining would allow you to specify a proxy in the browser that would intercept certain URLs and hand them to the offline copy of a page. There would also be an easy way to save and manage these offline pages. The offline access requirement is a developing world thing - smart people don't rely on Internet access in places where there is little by way of infrastructure and they only have one chance to get something right.


When and why would we use immutable pointers?

In Java, the `String` object is both immutable and also a pointer (aka reference type). I'm sure there are other types/objects which are both immutable and a pointer as well and that this extends further than just Java. I can not think where this would be desirable possibly due to my own experience I've only used either a reference types OR immutable primitive types. Can some one please give me a situation where it would be useful so I can get an appreciation for their meaning/value/concept.


Why is the Apache HTTP Server so complex?

The Apache HTTP server is a fairly large project—much larger than, say, `lighthttp` or `nginx` or certainly the "simple HTTP servers" you see floating around in C/C++ tutorials. What is the extra code for? Does it add security/stability (and if so, how?) or is it just for doing things like parsing Apache `conf` files/`.htaccess` type things (and, I guess, `VirtualHosts` etc). I ask not to critique Apache, but because I'm interested in writing a web server of sorts and I'd like to know things that, while perhaps not obvious, are important to remember for a secure, stable and fast web server.


Is the escaping provided by the Google-Gson library enough to ensure a safe JSON payload?

I am currently using the Google-Gson library to convert Java objects into JSON inside a web service. Once the object has been converted to JSON, it is returned to the client to be converted into a JSON object using the JavaScript eval() function. Is the character escaping provided by the Gson library enough to ensure that nothing nasty will happen when I run the eval() function on the JSON payload? Do I need to HTML Encode the Strings in the Java Objects before passing them to the Gson library? Are there any other security concerns that I should be aware of?


How to reduce tight coupling between two data sources

I'm having some trouble finding a proper solution to the following architecture problem. In **our setting (sketched below)** we have 2 data sources, where data source A is the primary source for items of type Foo. A secondary data source exists which can be used to retrieve additional information on a Foo; however this information does not always exist. Furthermore, data source A can be used to retrieve items of type Bar. However, each Bar refers to a Foo. The difficulty here is that each Bar should refer to a Foo which, if available, also contains the information as augmented by data source B. My question is: how to remove the tight coupling between SubsystemA.1 and DataSourceB? ![http://i.stack.imgur.com/Xi4aA.png](http://i.stack.imgur.com/Xi4aA.png)


Why can people expect hardware/software requirements on software applications, but it's not for web applications?

Questions revolving around ways of getting customers to embrace new web technology / browsers so one can deliver better web software to the end user. It's hard to manage expectations of customers. Expectations such as:   1. Websites should work on older browsers. (ambiguous).   2. Websites should not require specific hardware.   3. Giving system / computer specs for running a website is unacceptable. Web development isn't as easy as many think. There's a lot that goes into creating a properly run web application (not just a website). Take a look at Google Docs or Microsoft Office online. These are more than just regular websites, and they force users to use newer browsers. MS Office Online will not work with IE6, and they are trying very hard to push people to use IE8 (soon IE9). Google pushes as well, same with many other strong web entities. You can do a lot on the internet, from playing games, watching movies, doing work, even coding and have the server you're connected to compile your code. With everything the web can do, I find it amazing that people still want to put unrealistic expectations on web applications just because it will require someone to use a browser that is only... 2-3 years old. I understand people don't like change. And we all know that many corporations will provide days/weeks of training to help their employees understand new internet browsers. There are also cases where people are forced to use old browsers because the archaic system they use for internal work only runs on that browser (ActiveX+IE6). **My Questions** How can you tell your end users that they will need to upgrade their browser to use the latest version of your website without a huge outcry? Why does the expectation exist that it's ok for software to require people to upgrade Windows/Mac versions, but a website cannot require a new browser version?


What is a real-world use case of using a Chomsky Type-I (context-sensitive) grammar

I have been having some fun lately exploring the development of language parsers in the context of how they fit into the Chomsky Hierarchy. What is a good real-world (ie not theoretical) example of a context-sensitive grammar?


Algorithm/Strategy or Data structure to capture priorities sub priorities in an app

I am working on a CMS that is starting to evolve a bit. We started off with content that had the following priorities ( columnn in the db on the content table): HIGH MED LOW. Data was fetched by priority HIGH being on top etc. Now after a few months a need has risen to have sub priorities: HIGH [ high, med , low ], MED [high, med, low ] etc. I have a test branch with a sub-priority column in the db. So fetch by priority now brings back HIGH(high) HIGH(med) HIGH(low) first. Wondering is there a better way to do this that I not seeing. There is a rails app.


shipping a recompiled plugin under lgpl

I have recompiled a plugin (making changes before they are accepted upstream) for the gstreamer media framework. I did not recompile the whole library -- just a plugin. If I want proprietary python code to use this plugin -- am I running afoul of the LGPL license? My code never _directly_ links to the modified plugin. MyPythonCode [proprietary] --> pygst/binary [LGPL] --> gStreamer/binary [LGPL] --> modifiedPlugin/binary(w/source)[LGPL] The source code for the modified plugin would be available per LGPL.


What should a C++ developer expect on an interview at a Rails company?

I have been working on C++ backend large scale apps for over 5 years. I'm doing TDD, using STL and Boost etc. I decided I need a change and about year ago started learning Ruby, and few months ago I started playing with Rails, HTML5 and CSS. I don't know JavaScript yet, I'm focusing on Rails now. What can I expect on an interview for a Ruby on Rails backend developer job? How can I present myself to take advantage of my C++ experience? I'm on a senior level now and I can't start from intern position. I consider myself really good in C++, I know also some Scheme, some Python and quite a bit of Ruby. I'll have one small Rails app ready and 1 simple Gem published before I'll start applying. Plus quite a few personal C++ projects. I have a bachelor degree in Electrical Engineering and I'm completing master degree in CS in June 2011.


PHP, structural or OOP based language?

I would like to discuss why is PHP called a structural language? what are the OO concepts that cannot be implemented using PHP?


Facebook and Twitter authentication from Mobile Applications

I might be missing something with the Facebook and Twitter logins APIs. Something that is blocking me from understanding how they would be used in mobile applications. Both APIs seem like they need to redirect you to and then back to a website. How would that work from a mobile app? Or is there another way to use these APIs? I have to write a website that has native login, Facebook login and Twitter login. Then I am expected to turn around and open up a set of web services to an Android and iPhone mobile apps. Thought this was to "loose" of a question to ask on StackOverflow. What is the best approach? Any links on calling the API without UI interaction?


What are some easter eggs that went wrong?

What are some easter eggs that went wrong and resulted in unintended consequences, e.g programmer(s) being fired, monetary losses, even human life loss, etc? Please share.


Convention on model names in ruby on rails

I was doing my ER diagram for a rails application I'm about to begin with and there I have an entity called `Class News` so I'd have a model `ClassNew` but I don't know if I will have problems in the future with the `New` part or what would be the right way to do this o how should I call the model? since the right thing would be `ClassNews` and the table should be `class_news`... What's the best thing to do when working with `News` at the time of creating models for ActiveRecord in Ruby on Rails. Thanks.


Adapting parts of an open-source project for my own use

I'm in the process of coding a game and almost done with the game mechanics to the point where it's pretty playable. I later discovered an open source version of the kind of game I'm making with the same mechanics, whereas I coded mine from scratch. However, in the interest of optimizing later on, I may want to adapt a small part of the open source project's code. The project is under the GNU GPL 2, and it's coded in a different language for a different framework (Android/Java versus mine on C#/XNA). What are my options as to copying functions / routines from a GPL open source project, if I would have to port the code anyways, for the language I'm using? These are not patented algorithms I'm talking about, just code I found that could possibly make my program more efficient or stamp out a bug.


How to indicate the word is method name in Objective-C?

You can indicate that `XXX` is method name by writing `XXX()`. But in Objective-C, you can not write `XXX()` for `XXX` method. If you write `XXX`, you can't tell if `XXX` is method name or other type of identifier. How can you indicate that `XXX` is method name of Objective-C class? _**EDIT_** Method call of Objective-C is different from other language. in Objective-C, method call is:               [self XXX];      in other language, method call is:               self->XXX();      In other language, for example, we can write in stackoverflow:               XXX() doesn't work      And we can know `XXX` is method thanks to `()`. But in Objective-C, we can't say:               XXX doesn't work      Instead, to make it clear that XXX is method, we have to say:               XXX method doesn't work


What are memory addresses?

I have more or less 0 knowledge in low-level topics, so forgive my possible ignorance. I know that in languages such as C, pointers hold 'memory addresses', i.e. strings (or binary data?) written in hex such as `0x52A132F3`. Judging by the term 'memory address', I assume this number actually leads to some place in memory. But I'm having a hard time understanding what a 'place in memory' actually is and how a hexadecimal number can 'lead' to it. (A Java programmer here..) So two questions:   1. Do the memory addresses point to places on the CPU itself, or anywhere in the computer?   2. Is memory 'ordered' in hardware in some way that it makes sense to refer to it using an 'ordinal' number, such as `0x52A132F3`? How is memory ordered in hardware, and how and why does it make sense to access it using a numerical value?


Properties under ARC: Always or public-only?

After reading an article humbly named "The Code Commandments: Best Practices for Objective-C Coding" by Robert McNally a little less than two years ago, I adopted the practice of using properties for pretty much every data member of my Objective-C classes (the 3rd commandment as of may 2012). McNally lists these reasons for doing so (my emphasis):   1. Properties enforce access restrictions (such as readonly)   2. _Properties enforce memory management policy (strong, weak)_   3. Properties provide the opportunity to transparently implement custom setters and getters.   4. Properties with custom setters or getters can be used to enforce a thread-safety strategy.   5. Having a single way to access instance variables increases code readability. I put most of my properties in private categories, so number 1 and 4 are usually not issues I run in to. Arguments 3 and 5 are more 'soft', and with the right tools and other consistencies they could become non-issues. So finally, to me the most influential of these arguments was number 2, memory management. I've been doing this ever since.               @property (nonatomic, strong) id object; // Properties became my friends.      For my last few projects I've switched to using ARC, which made me doubt whether creating properties for pretty much anything is still a good idea or maybe a little superfluous. ARC takes care of memory managing Objective-C objects for me, which for most `strong` members works fine if you just declare the ivars. The C-types you had to manually manage anyway, before and after ARC, and the `weak` properties are mostly public ones. Of course I still use properties for anything that needs access from outside of the class, but those are mostly only a handful of properties, while most data members are listed as ivars under the implementation header               @implementation GTWeekViewController     {         UILongPressGestureRecognizer *_pressRecognizer;         GTPagingGestureRecognizer *_pagingRecognizer;         UITapGestureRecognizer *_tapRecognizer;     }      As an experiment I've been doing this a bit more rigorously, and the move away from properties for everything has some nice positive side effects.   1. Data member code requirements (`@property`/`@synthesize`) shrunk down to just the ivar declaration.   2. Most of my `self.something` references cleaned up to just `_something`.   3. It's easily distinguishable which data members are private (ivars) and which are public (properties).   4. Lastly, it 'feels' more like this was the purpose Apple intended properties for, but that's subjective speculation. **On to the question** : I'm slowly sliding towards ~~the dark side,~~ using less and less properties in favor of implementation-ivars. Can you provide me with a bit of reasoning for why I should stick to using properties for everything, or confirm my current train of thoughts as to why I should use more ivars and less properties only where needed? The most persuasive answer for either side will receive my mark. _EDIT:McNally weighs in on Twitter, saying: "I think my main reason for sticking with properties is: one way to do everything, that does everything (including KVC/KVO.)"_


Software architecture for authentication/access-control of REST web service

I am setting up a new RESTful web service and I need to provide a role-based access control model. I need to create an architecture that will allow users to provide their username and password to get access to the services and then restrict how they can use the services (which services they can use, read vs read/write, etc) based upon the roles assigned to that users. I have looked around at other questions and found pieces of what I want. For example there are several great discussions about how to handle passing credentials to REST services restful-authentication, best practices. There are also some great pointers on what programmers should know when creating websites (what every developer should know before building a public web site). But I haven't been able to find a good post, article, book on best practices and patterns for the software architecture that implements these solutions. Specifically:   * How should user details and access rights be stored? (data model, location, format)   * What are good design patterns for representing and tracking these in the server? (sessions in memory, db lookups each time, etc)   * What are good patterns for mapping these rights to the services in a secure way in the code base?   * What architectural choices can help keep the system more secure and reliable?   * What lessons learned do people have from the trenches? I am looking for are design patterns and recommendations for the software architecture outside of any specific technologies. (If the technologies matter, I am planning to implement this using python, twisted, and a postgresql database)


Why do some teachers often consider bad practice things that are not?

In college, teachers often say that some things are bad practices while they are not. I'm referring to the recent Why is naming a table's Primary Key column “Id” considered bad practice? question, or to the fact that my teacher told us that early returns are bad practice and must never be used. There are plenty of other examples everyone who have been in college remembers. Once learned, those things are hard to unlearn. When you deal with an intern who learned something wrong from her teacher, it's not always obvious to explain that the thing the teacher told is either not totally true or sometimes completely wrong. What makes those teachers mistakenly believe that things are bad practices, while in programming industry, most people would disagree with them? Don't they read programming books we, developers, read? Don't they talk frequently to developers?


Fast algorithm for finding common elements of two sorted lists

Suppose I have two lists of N 3 by 3 vectors of integers. I need to find a quick way (say of running time at most N^(1+epsilon)) to find the vectors of the first list that have the same 1st coordinate with a vector of the second list. Of course, I could do the following naive copmarison:               for u in list_1 do     for v in list_2     if u[1] equals v[1] then     print u;print v;     end if;end for; end for;      This, however, would require N^2 loops. I feel that sorting the two lists according to their first coordinate and then look up for collisions is perhaps a fast way. Bubbleshort, etc., would probably take logN time, but I can't really see how to code the search for collision between the sorted lists. Any help would be appreciated.


Effective versus efficient code

**TL;DR: Quick and dirty code, or "correct" (insert your definition of this term) code?** There is often a tension between "efficient" and "effective" in software development. "Efficient" often means code that is "correct" from the point of view of adhering to standards, using widely-accepted patterns/approaches for structures, regardless of project size, budget, etc. "Effective" is not about being "right", but about getting things done. This often results in code that falls outside the bounds of commonly accepted "correct" standards, usage, etc. Usually the people paying for the development effort have dictated ahead of time what it is that they value more. An organization that lives in a technical space will tend towards the efficient end, others will tend towards the effective. Developers often refuse to compromise their favored approach for the other. In my own experience I have found that people with formal education in software development tend towards the Efficient camp. Those that picked up software development more or less as a tool to get things done tend towards the Effective camp. These camps don't get along very well. When managing a team of developers who are not all in one camp it is challenging. In your own experience, which camp do you land in, and do you find yourself having to justify your approach to others? To management? To other developers?


Naming for a class that consumes an iterator pattern

The iterator pattern is very clearly defined. What would you call the consumer of an iterator?


Guidelines for creating referentially transparent callables

In some cases, I want to use referentially transparent callables while coding in Python. My goals are to help with handling concurrency, memoization, unit testing, and verification of code correctness. I want to write down clear rules for myself and other developers to follow that would ensure referential transparency. I don't mind that Python won't enforce any rules - we trust ourselves to follow them. Note that we never modify functions or methods in place (i.e., by hacking into the bytecode). Would the following make sense? > A callable object `c` of class `C` will be referentially transparent if: > >   1. Whenever the returned value of `c(...)` depends on any instance > attributes, global variables, or disk files, such attributes, variables, and > files must not change for the duration of the program execution; the only > exception is that instance attributes may be changed during instance > initialization. > >   2. When `c(...)` is executed, no modifications to the program state occur > that may affect the behavior of any object accessed through its "public > interface" (as defined by us). > > If we don't put any restrictions on what "public interface" includes, then rule #2 becomes: > When `c(...)` is executed, no objects are modified that are visible outside > the scope of `c.__call__`. Note: I unsuccessfully tried to ask this question on SO, but I'm hoping it's more appropriate to this site.


Identifying Domain Services & Application Services when doing DDD

-I'm trying to figure out how to identify Application Services in my application. I think I can identify a Domain service by 2 things:   1. It acts as a facade to the repository.   2. It holds business logic that can't be encapsulated in a single entity. So I thought about this simple use case that I'm currently working on: An admin should be able to ban a certain user. The operation must be logged and an email must be sent to the banned user. I have a `UserRepository` which has a function `getUserById()`. I have a `User` entity which has a `ban()` function.   I'll create a `UserService` like this:               class UserService{         static void banUser(int userId){               User user= UserRepository.getUserById(userId);               user.ban();               UserRepository.update(user);         }     }      The `userId` is a `POST` variable that I'll be receiving in my `Controller` from a web form. Now where does the logging go? I need to log the ban process twice before and after the operation ex:               Logger.log("Attempting to ban user with id:"+userId);     //user gets banned      Logger.log("user banned successfully.");      Second, I need to send a mail to the user. where should the call go? I thought about putting the logging and email is the `UserService` class itself, but I think there are better solutions. Third, where do Application Services fit in all of this?


Understanding stack frame of function call in C/C++?

I am trying to understand how stack frames are built and which variables (params) are pushed to stack in what order? Some search results showed that the C/C++ compiler decides based on operations performed within a function. For example, if the function was supposed to just increment a passed-in int value by 1 (similar to ++ operator) and return it, it would put all the parameters of the function and local variables into registers. I'm wondering which registers are used for returned or pass by value parameters. How are references returned? How does the compiler choose between eax, ebx,ecx and edx? What do I need to know to understand how registers, stack and heap references are used, built and destroyed during function calls?


Methods for testing a very large application

I have a PHP app which is very large. There are usually 2-3 developers working on it full time and we are getting to the point where we are making changes and creating bugs (cough features!). The software isn't complex per say, just there is a lot going on (35~ controllers, about the same models, etc). Even being careful it's easy for a change in this view (tweaking an id on an element) to wreck an ajax query happening under some special condition (logged out while standing on one foot). Unit tests are the first things which spring to mind, but we tried these on another app, and it's so easy to forget them / or spend more time writing tests then doing tests. We do have a staging environment where code gets checked over before pushing live. Maybe we need a part time Q/A person? Anyone have any suggestions/thoughts.


New Starter Introduction and Induction Process

First day at work for a new programmer. Assuming that the company has covered all the usual corporate stuff (benefits, paperwork, health and safety and so on), **What are the things you should be talking a new developer through to get them up to speed and productive as soon as possible?** In additional what are the key things in making this process a success? What have you seen work particularly well? (Edit: Added a bounty. The current top answer is fine but I'm still thinking there is more that can be done to make a programmers first week as useful to them as possible. Really hoping for insights from good and bad starts to jobs people have had).


Pricing of a collaborative work

I suppose there's no straight answer to this, but what ideas come to mind for determining how much each programmer would get for participation in a collaborative project if it were to be sold?


Dealing with bilingual(spoken language) code?

So I've got to work with this set of code here for a re-write, and it's written by people who speak both English and French. Here's a snapshot of what I'm talking about (only, about 4000 lines of this)               function refreshDest(FormEnCours,dest,hotel,duration) {         var GateEnCours;         GateEnCours = FormEnCours.gateway_dep.options[FormEnCours.gateway_dep.selectedIndex].value;         if (GateEnCours == "") {               FormEnCours.dest_dep.length = 0           } else if (FormEnCours.dest_dep != null && FormEnCours.dest_dep.type && FormEnCours.dest_dep.value != "ALL") {           if (Destinations[GateEnCours] == null || Destinations[GateEnCours].length == 0) {                RetreiveDestinations(FormEnCours,GateEnCours,dest,hotel,duration);           } else { refreshDestSuite(FormEnCours,GateEnCours,dest,hotel,duration); }         }     }          function refreshDuration(FormEnCours,GateEnCours,DestEnCours,hotel,duration) {         // Refresh durations         var FlagMoinsDe5Jours = "";         var Flag5a10jours = "";         var Flag11a16jours = "";         var FlagPlusDe16Jours = "";     .......       Is there any approach that I, as a speaker of only one of these languages, can use to make this entire process a lot less painful for both figuring out what everything does, and then refactoring it?


Conceptually what does it mean when it is said that each thread gets its own stack?

I have been reading Java Concurrency in Practice by Brian Goetz and inside the section **Stack Confinement** it is mentioned that each thread gets its own stack and so local variables are intrinsically confined to the executing thread; they exist on the executing threads stack, which is not accessible to other threads. What does he mean that each thread has its own execution stack ?


At what point is asynchronous reading of disk I/O more efficient than synchronous?

Assuming there is some bit of code that reads files for multiple consumers, and the files are of any arbitrary size: **At what size does it become more efficient to read the file asynchronously? Or to put it another way, how small must a file be for it to be faster just to read it synchronously?** I've noticed (and perhaps I'm incorrect) that when reading very small files, it takes longer to read them asynchronously than synchronously (in particular with .NET). I'm assuming this has to do with set up time for things like I/O Completion Ports, threads, etc. Is there any rule of thumb to help out here? Or is it dependent on the system and the environment?


Reasonable commision for position

My situation is that I have been offered a job working on a product for a small company. I'm currently working for a large corporation for a respectable salary considering my experience. Long term I am interested in creating my own products and starting up my own company. I've been offered a job to develop a product that I would be primarily developing. I looked at the idea and I think it is a pretty good idea and has a reasonable chance of being successful. I told him that I would be interested in earning a commission from the sales of the product. Considering that I would be developing the product what percentage would be reasonable to ask?


What shoud I know or should be doing after six years of experience in software development?

Even after six years of experienece I am still doing the things which I was doing six years ago. Working on the same mundane CRUD stuff. Nothing has been real challenging. Since I am working in a small company, we dont even have a proper development process. We don't even do unit testing, for example. I am feeling like I am just not going to the next level in my career.


Function that requires many parameters

I have a problem related to this: Are there guidelines on how many parameters a function should accept? In my case, I have a function that describes a rounded rectangle. The caller specifies   * An integer which determines how the rectangle should be merged into previously created shapes   * An Anchor, which is a point that is used for alignment (right, left, top, bottom etc). (0,-1) means that position (next parameter) describes the top, middle point of the rectangle.   * The position of the rectangle   * Width and height   * Corner radius Should I use Parameter Object pattern in this case? It is hard to see how these parameters are related


IDE for visually impaired

A visually impaired colleague has asked me to recommend an IDE with easy-to- find and easy-to-use controls for:   1. font size   2. background and foreground colors   3. changing syntax color scheme   4. support for at least C/C++ and Java He would prefer an IDE that is either portable or that has similar versions for Linux, Windows and Mac. He prefers a dark background and light colored fonts and needs to sit very close to the display.


What is the justification of use .inc files to declare and implement code is some Delphi RTL units?

Starting with #Delphi #XE2 many of the new RTL units related to Vcl styles, OSX and so on, uses inc files to declare types, classes and implement code (just like the FPC does), what is the justification to do that? you can see what i mean if you inspect one of these folders (source\rtl\posix, source\rtl\posix\osx, source\rtl\sys )


What is the big-O cpu time of Euclid's Algorithm of "Greatest common divisor of two numbers"

Looking at Euclid's algorithm for the "Greatest common divisor of two numbers", I'm trying to divine the big-O cpu time for numbers K, and N. Can anybody help? This is the algorithm as I understand it.. Where:   * max(A,B) = the greater of A or B such that: min(10,3) = 10   * min(A,B) = the smaller of A or B such that: min(10,3) = 3   * modulus(A,B) = the remainder of A divided by B such that: modulus(10, 3) = 1 The algorithm is:   1. r = modulus(max(K,N), min(K,N))   2. if r = 0      * then GCD is max(K,N)     * else:        * max(K,N) = r       * go to step 1 It appears to me that due to the division occurring, it can't be a linear algorithm which is why it's useful as something more efficient than a naive implementation that just tries all the possibilities from 0 to min(K,N). But I can't quite figure out just what the runtime is. Any pointers would be very helpful!


Code Base with awful code conventions, follow them?

With no time to refactor, when you are working on legacy code, with the most awful conventions, what is the best practice? Will trying to follow _better_ coding style would improve readability or actually hurt it? For example, in java method names are usually camel cased: > myGoodNamedMethod But in the repository there are code with methods like this (not all, but the majority) > my_c_style_method_that_looks_off_in_java


Alternatives to type casting in your domain

In my Domain I have an entity `Activity` which has a list of `ITask`s. Each implementation of this task has it's own properties beside the implementation of `ITask` itself. Now each operation of the `Activity` entity (e.g. `Execute()`) only needs to loop over this list and call an ITask method (e.g. `ExecuteTask()`). Where I'm having trouble is when a specific tasks' properties needs to be updated, as in configuring the task (not as part of the execute method). How do I get an instance of that task? The options I see are:   * Get the Activity by Id and cast the task I need. This'll either sprinkle my code with:      * `Tasks.OfType<SpecificTask>().Single(t => t.Id == taskId)`     * or `Tasks.Single(t => t.Id == taskId) as SpecificTask`   * Make each task unique in the whole system (make each task an entity), and create a new repository for each ITask implementation I don't like either option, the first because I don't like casting: I'm using NHibernate and I'm sure this'll come back and bite me when I start using Lazy Loading (NHibernate currently uses proxies to implement this). I don't like the second option because there are/will be dozens of different kind of tasks. Which would mean I'd have to create as many repositories. Am I missing a third option here? Or are any of my objections to the two options not justified? How have you solved this problem in the past?


What drives the adoption, or not, of new programming languages?

I'd really like to focus on why some new programming languages are adopted in the mainstream, and others remain relatively niche. I'd like to know about things like specific use cases, backwards compatibility, or some new features, simple or complex implementation difficulty. Specific examples would be appreciated, but let's not get caught up on the exact definition of "mainstream" or "niche" here.


Business case for decentralized version control systems

I searched and couldn't find any _business_ reasons why git/mercurial/bazzr systems are better than centralized systems (subversion, perforce). If you were trying to sell a DVCS to a non-technical person what arguments would you provide for the DVCS **increasing profit**. I will shortly be pitching git to my manager, it will take some time converting out subversion repositories and some expense in buying smartgit licences. **Edit** I tried to make this question into a generic discussion on centralized vs decentralized, but inevitably it has turned into git vs subversion. Surely there are better centralized systems than subversion.


Why aren't Multi-Platform Programming Languages popular?

So I was talking to a friend and he mentioned > Using WAC I can write Javascript code that will compile and run in iOS, > Android, BB etc and there is this programming language that lets you write code that is _multi-platform_ : http://haxe.org/doc/intro I was wondering why these hasn't got that much attention yet because the idea is so good. So in a sense, what is probably wrong with these ideas in a real-world perspective(real deployable projects)? **EDIT:** So I have probably misused some terms so here are some clarifications. It goes something like, for example, I write code in one language, then I can run it in iOS and Android devices, both of which have their native programming languages. That means I have an app that I can run on both device without having to code any Java or Objective C That's the best I can do for clarifications because I myself am a little confused T_T


How do you handle regular latecomers at the stand-up meetings?

We have our daily stand-up meeting at **8:45** while the workday starts at **8:30**. Even with the 15 minutes slack people keep coming too late, on a regular basis. This results in our meetings being small, incomplete, inefficient and sometimes even completely useless. We have tried to have people bring fruit for the team on the next day, but this didn't work as we'd be having multiple breakfasts every day (and after a while they didn't even bother to bring any anymore). We have been thinking of imposing a fine, but we find solutions like that quite childish. How do you handle regular latecomers at stand up meetings? What worked - and what didn't?


How to represent compound elements within a database?

I need to design a database table that holds the data of programmers work hours. The problem is that I have a compound type - two pieces of data belong to a category. Specifically, the work hours are classified into categories: design, program, test, troubleshoot, etc... and each category is divided into two types: hours spent at work and hours spent at home. How can I design a compound type in the database side? ![enter image description here](http://i.stack.imgur.com/gXob9.jpg) I thought about storing the two types in one field like "6,2" but that creates more problems to resolve. I would now have to convert and split data along with worrying about localization issues, missing data, or if another location was added to the categories. * * * Clarification:   Asking my question a different way, it's relatively easy to design a table without compound types like this: ![enter image description here](http://i.stack.imgur.com/izuiu.jpg) But how to deal with it when each category is split into two types?


What to name a parent thread that just delegates to workers?

I have a program where one thread creates a work queue and a bunch of workers that pull from it, and occasionally does some cleanup work for the workers. If the workers are all instances of `FooWorker`, what would I name the other class? One idea I've had so far is a `FooManager`, but maybe there's a better one?


Calculations in Vector Register

How do vector registers work in terms of calculations and alloting data to them ? Is there a detailed reference available somewhere explaining how vector registers work and how data is fetched from them ?


Why don't I see many unit test projects that bring up and tear down a DB? (ASP.NET MVC)

I see all the examples that demonstrate unit testing code and mocking the calls to the DB since you are not suppose to touch the DB. But it seems to me having a set up tasks that uses the actually schema, loads the lookup tables and then populates it with data using the methods to be tested... This way it is more real world testing and all the stored procedures are tested as well.. But I never have seen any examples like this... Is there some reason I do not understand why using this technique is not as useful as it seems ? EDIT1: Sorry.. I shouldn't have called it unit test.. yes. I will have unit tests as well that are for testing code.. But beyond that it seems like a good idea to bring up and tear down and DB and have code that modifies that DB and does assertions.. But I don't want this to be UI testing.. I just want to perform a lot of CRUD functions and a lot of assertions .. :My question is #1 does this make sense.. #2 how do I automate this all within visual studio ? How do I tell VS 2012 to run a SQL script before running the tests? is there some special API for this ?


Why Python and not Lua?

Why has Python been backed by google and become so rapidly popular and Lua has not? Do you know why Lua has stayed in background?


Should all new web projects build their backend based on xml/json result sets?

If you were building a new Saas project, would it make sense to start with all of the backend services returning xml/json? Because these days you need to build for both the web and mobile devices, and having a backend that is build from the start to return xml and json, you are ready to go mobile (all services have the business logic, so you won't be repeating anything). Now the web would be MVC, so the controller would just be routing the request to your service backend, and converting the json or xml to html. The obviousl downside is that you have to build a backend, and then another web project that calls your backend. But this also goes to you favor as it forces you to seperate your concerns, and not leak business logic in your controller/view layer. Thoughts?


ACM student chapter event ideas?

I was recently elected president of the student chapter of ACM at my university, and am trying to come up with some ideas for events for the following year. The big one we do every year is practice matches and try outs for the ICPC. I am hoping to host one or two more events this year, and was wondering if anyone has some cool ideas or has some past experiences that worked well. One idea that we have had so far is to do a hackathon but it generally seems difficult to convince the underclassmen that they have the skill to participate in events like this.


The bad habits formed in the process of learning the C programming language

In the Cambridge University Computer Science curriculum booklet of 2012-13 under the module entitled 'Foundations of Computer Science' it states: > The main aim of this course is to present the basic principles of > programming. As the introductory course of the Computer Science Tripos, it > caters for students from all backgrounds. To those who have had no > programming experience, it will be comprehensible; to those experienced in > languages such as C, it will attempt to correct any bad habits that they > have learnt. They seem pretty sure that one who has learned a little C, has formed 'bad habits' in the process. I wish to learn C for I am interested in reading and writing Kernel source code. How do I learn C without forming 'bad habits'?


Representing a rule in a ruleset

How to represent rules for a rule engine as objects? A rule would be > if ( _booleanExpression(input)_ ) then _a chain of generic actions_ " else > _next rule_ ...where the generic actions might be e.g. passing the input to a different chain of rules, returning a conclusion (terminating analysis with result), or gathering additional data - though probably other actions might prove necessary too. Now the problem of parsing arbitrary boolean conditions aside (let's assume we have a fully working `booleanExpression` class available), how would such a Rule object look like, and specifically, how would the Ruleset object containing orderly, interconnected grid of these look like, in particular in a structure that will be possible to process by the actual engine. (if the data structures don't make it obvious how such engine should process them, maybe a hint about it too?) This will be written in C++ but a language-agnostic answer is most welcome too. * * * This is derivative of my question about Event Correlator, which seems to be unanswerable simply because it's too broad to tackle in one answer, so I'm trying to split the problem into smaller, bite-sized chunks.


Maintaining indices for location in a sorted list in database rows

I have a fairly simple data structure like this:               create table project (id int auto increment primary key, name text);          create table item (id int auto increment primary key, name text,         project_id int not null,          project_sort_index int not null,         sort_index int not null,         foreign key fk_project(project_id) references project(id));      A `project` can have many `item`s. Items have two different fields for maintaining sort order, `project_sort_index` and `sort_index`. These sort order fields apply in the following way. When I view all items belonging to a project, I need a sort order specific to each project for the items. When I view _all_ items globally, I need a sort order for them globally. I have a couple of questions as to how best to maintain and modify sort order for these items. Lets say that I have moved an item at index 4 to index 2. How do I propagate that change to my database efficiently? For example, how do I now update all index numbers >= 2 to move everything down, yet close the gap left in place 4? Is there a better way of sorting lists in SQL?


Is reverse debugging possible?

I know there are some products for reverse debugging. I am wondering that does reverse debugging mean going to one step back or starting over again up to one step back? I've found an explanation here.


Software license options

Is there a software license that allows free access to source code, but does not allow redistributing any binaries, either direct from the source code or modified source code for a limited time? The idea being much like a open source software patent; the original developer has the exclusive right to sell and distribute the product, and prevent others from copying the product for a limited time, and the source code would be disclosed to the public. Obviously the downside is enforcing this license, but larger companies (e.g. Microsoft) could possibly gain the benefits of open source projects but still keep their proprietary position.


Patterns and practices for Web Scraping in .Net (C#)

I will be putting together an application to automate an external web site/application. In some instances I will need to navigate the site as a user would (some links I need to follow cannot be predicted and must be parsed from a response) I am already using Html Agility Pack, and am aware of Tidy if that is needed. **Are there any other technologies I should be aware of?** **Are there any recommended patterns for being able to quickly adjust in the event that the external web app changes?** I’m envisioning encapsulating the validation of responses as some type of strategy or similar pattern that can be easily separated/plugged in as necessary, but any specific suggestions would be great.


Are Quines useful as anything more than a programming puzzle?

Quines, which are programs that generate their own code as part or all of their output are a neat idea for a programming puzzle. However, do they have any use beyond that?


Architecting multi-model multi-DB ASP.NET MVC solution

I have an ASP.NET MVC 4 solution that I'm putting together, leveraging IoC and the repository pattern using Entity Framework 5. I have a new requirement to be able to pull data from a second database (from another internal application) which I don't have control over. There is no API available unfortunately for the second application and the general pattern at my place of work is to go direct to the database. I want to maintain a consistent approach to modeling the domain and use entity framework to pull the data out, so thus far I have used Entity Framework's database first approach to generate a domain model and database context over the top of this. However, I've become a little stuck on how to include the second domain model in the application. I have a generic repository which I've now moved out to a common DataAccess project, but short of creating two distinct wrappers for the generic repository (so each can identify with a specific database context), I'm struggling to see how I can elegantly include multiple models?


Why does Java require a servlet container for simple RPC service?

I have a big database controller which is written in Java. The controller reads information from the database, and interprets it into data structures which are then displayed in a CLI. Java was chosen because writing code in it is fast and easy. Now I want to create an RPC server on top of the controller (XML-RPC or JSON-RPC for future AJAX calls), but it looks like I need a servlet container for my RPC service. I am confused because last year when I needed this kind of capability for another project in python, it took me less than 5 minutes to create the same functionality using the SimpleXMLRPCServer The same ease of creation applies also to C# as far as I recall. But in Java the story is different; now I need a servlet and therefore a servlet container (i.e Tomcat, Jetty) which means I need to install and maintain web servers. From what I can tell, JSON-RPC requires `Spring` framework in order to work. I have already spent around two hours in learning the design and sort-of how Tomcat works without writing even one line of code. I searched the web and found out that I have standalone options: I can use this library, but it doesn't seem maintained and it is also somewhat complex (I'm looking for something with decorators / annotations).   The other option I found is to use the so called "embedded" jetty and then trying to set it and configure it by code which also seems a tedious task. Why isn't there a **standalone** mechanism for such a popular interface? Am I missing out something here?


Attending my first software conference - any tips before I go?

My nice employer allowed me to visit a software conference in June (International PHP Conference, for those who care). Wanting to make the most of it, I would ask the more experienced conference goers in here to give me some tips on what I could do to maximize my learning experience on the conference, and to reduce beginner mistakes. Sorry that this question is a little ambiguous, but I think it's best to keep it a little bit more open, so I can get a wide range of Ideas, and it will be of more use to further people seeking for an answer.


Functional programming: Writing a small interpreter

I'm working on a small Unix shell, and am contemplating the idea of writing a script interpreter. While reading about the subject I inevitably hear of functional programming, lambda calculus, and find out about the whole fascination around Lisp. Before I jump into this I have some questions.   * Which language should I use? I am curious about functional programming, so that would be a great opportunity to start. I want my shell to have as little 3rd party dependencies as possible. I am wondering whether I should look for a compiled language. I would like being able to distribute it more easily. Is this a correct approach? if so, which language would you recommend?   * How do you embed an interpreter in your program? The way I see it is having the interpreter run in a second separate process. As far as I know, two processes communicating, are either listening to a pipe or sending signals to one another. Is this a realistic approach? Is there a particular language that handles this part? Are there other ways of embedding the interpreter?


What design patterns does every developer need to know

I was wondering what design patterns **every** developer, no mather what dev language, should know and why?


How would you go about looking for collaborators?

I seem to have a never ending stream of more-or-less original, more-or-less cool ideas for software/apps/stuff yet to be written on my mind. Sometimes, I decide to just start implementing my idea. Several hours later, I end up with a decent, more-or-less working prototype of what I'm trying to build. Then, my alarm clock goes ringing and I have to get back to the real world, tired as hell. In most cases, the stuff I started remains unfinished forever. Sometimes, that's okay. Other times, I honestly feel like that's a bummer. But I realize that there are sites like GitHub and there are many other coders out there. Is there a place where one can post ideas, proposals, concepts, or rough-around-the-edges-code in order to find people who are interested in collaborating on projects? **Edit:** I am aware of "the usual way" – keep developing on your own for some period of time, open-source the code, mention your project on dev blogs, IRC or wherever else you go; eventually attracts others. What I'm looking for is a place to connect with other devs (e.g. of different specializations) on the early stages of a project.


Can cross-platform development be speeded by really specific, complete pre-coding design?

I'm green at programming but not entirely noobish. I taught myself some Java about five years ago, and I learnt me some Objective-C recently. I was talking with a Unix guy a while back, and he said that if you do your object architecture and design very completely and correctly, cross-platform development becomes really easy. All you have to do is take the description of each element and implement it. Since your design is so complete, each individual element is composed of relatively simple tasks. I'd like to get some feedback on that concept. In theory it makes sense, but programming is about execution. And if you agree with the concept, can you point me to some material that would help me understand how to build those kind of complete, specific designs?


Why are software schedules so hard to define?

It seems that, in my experience, getting us engineers to accurately estimate and determine tasks to be completed is like pulling teeth. Rather than just giving a swag estimate of 2-3 weeks or 3-6 months... what is the simplest way to define software schedules so they are not so painful to define? For instance, customer A wants a feature by 02/01/2011. How do you schedule time to implement this feature knowing that other bug fixes may be needed along the way and take up additional engineering time?


WCF and object-oriented programming

I am building a program which would have WCF support. I am using the MVC pattern. For each controller there is a WCF service class. e.g. I have `CTRL.CTRLBooking`, `WCF.IWCFBooking` and `WCF.WCFBooking`. For each controller (total of 10) there is a WCF class and an endpoint. Is this a good approach or should I keep all the methods I provide in one single class e.g. `WCF.WCFService` (considering their count would be no more than 25-30)?


Examples of different architecture methodologies

Is there a resource or site which illustrates building the same application (desktop or web) using several different contrasting architectures? Such as MVP versus MVVM versus MVC, etc. It would be very helpful to see how they look side-by-side using real-world code instead of comparing written theory to written theory. I've often found that something can be _described_ well in a book, but when you go to _implement_ it, the subtleties and weaknesses of the theory become readily apparent.


CQRS and validations

I'm starting to introduce myself in CQRS concepts, but I get stucked with the following situation: Supouse you have an entity that must have an unique name. In order to verify that, prior to create the entity you must make a query, thus you are verifing against the query subsystem. But what happens if the syncronization has not been happened between the command system and the query system yet? Other client just had sent the same name before you. What happens in that case?


Best way to test a reimplemented web service

In my team, we are about to start the reimplement of a service. One of the important steps to do to accomplish this is how do we ensure that we are doing it in the right way and we are not introducing new bugs. So, what we have in mind is create a bunch of test to verify the following:   * The behavior. Both services should behave the same way (store data in the same places, send same, notificacions, etc...)   * Results. Object returned by the service's calls should be exactly the same. So, the things that we have thought is to do the following:   * Create a set of test that verifies the behavior and results of old service.   * Create the new service adding unit test, and whitebox integration test for the new service   * Create some kind of "Mirror test" that checks if the new service is working as the old one. Is there a way to do this? Thanks for any help. Note: None of the code of the previous version is reusable. There is no test for the older version of the service [Edited]replaced original word "migrate" with "reimplement"


How flexible can hardware get?

This subject is long time in the making for me and it particularly took off when I was researching bootloaders for computers and consumer electronics, which, I will note, differ drastically. I've learned how ancient and inflexible x86 hardware is and just how much the structure of software is constrained by it. Examples of what I am talking about:   * Bootloaders cannot have an arbitrary size.   * Specialized functions like memory-mapped hardware.   * An Intel processor's ties to a particular type of firmware. So I've wondered about systems that might be designed like this:   * Writing text to the screen handled pixel-by-pixel by an operating system instead of an intermediary microcontroller.   * Sectorless hard drives wherein a computer simply begins executing at the first address and the bootloader can be any size.   * Functionality of microcontrollers moved into the software. I understand that this would take away a lot of simplicity, but do systems like this exist? I am guessing this would be more prevalent in embedded systems. To better understand this question, imagine a device where there are no controllers or independent systems and everything is controlled by the CPU.


opensaml assertion signature validation

I have a SAML 2 response with one assertion which is signed and the response itself has signed again. I use below code to validate the signature profile of the response.               SAMLSignatureProfileValidator signatureProfileValidator = new SAMLSignatureProfileValidator();     signatureProfileValidator.validate(**response**.getSignature());      And below code block to validate signature.               SignatureValidator signatureValidator = new SignatureValidator(validatingCredential);     signatureValidator.validate(**response**.getSignature());      But I believe that these things validate the response signature and the response signature profile only. **Do I need to validate the assertion signature as well?** I have tried validating assertion signature using below code block. But it gives me the ValidationException which means it is not valid. But it should be.               SignatureValidator signatureValidator = new SignatureValidator(validatingCredential);     signatureValidator.validate(**assertion**.getSignature());


Developing with confidence without a real development environment

I've recently been hired for a project that involves working with and around several third-party "enterprise" systems. Due to what I imagine would be the astronomical cost and effort required to build a sufficiently faithful replica of the production environment, the prospect of having a real development environment seems vanishingly slim. This is of course not ideal. On the bright side, I imagine there must be people out there safely testing and deploying software into unreplicable environments like this, and I can probably follow in their footsteps. How those who effectively deal with these kinds of situations do it?