How to preserve order of incoming requests on a multithreaded server

I want to write a multithreaded server application which is able to process requests in a multithreaded fashion while keeping up execution order of incoming requests of the same client. For example if client A sends a message M1 and then a message M2 the muiltithreaded server must process these requests in exactly the same order, first M1 and then M2. However, there is no guarantee that threads that process these incoming requests do process these messages in the same order. For example, thread T1 consumes message M1, thread T2 consumes message M2 and completes processing the message and is able to accept further messages before T1 has finished it's job. After a message has been processed the result will be passed to some other process for further processing (of which only one exists in the whole computation), this process will schedule sending a response to the client. These mutliple threads do only exist for the purpose of preprocessing data for some other process. This particular problem sounds like a problem with pipeline characteristics, first M1, then M2, then M3, etc. However, I wanted to parallalize as much as possible to achieve a higher number of communication cycles between the server and the clients. What architecture / pattern / technique is well suited for such a task?


Diving into C++ GUI Programming for the first time

I am about to start learning C++. I currently am a PHP programmer, I also know how to write Java code and create Java GUI applications. I have browsed http://www.cplusplus.com/doc/tutorial/ and to me it looks fairly similar to what I already know, just a few language syntax differences here and there. I want to create a C++ GUI application, and from what I researched, it sounds like using `Qt` and `Qt Creator` is a good place to start. So, is using `Qt` and `Qt Creator` a good/decent way to start to learn C++ GUI programming or should I do it some other way?


Should technical debt be scheduled as a feature or a chore (or a bug)?

I've added a couple of user stories that address some technical debt to my Pivotal Tracker board. Should I consider them as features (keeping my velocity level) or as chores/bugs (lowering my velocity)? I understand it won't make any difference in the long run if I did one or the other consistently, but every time I add a technical debt story I have to make the decision. Some thoughts:   * They aren't actually bugs, they don't break anything   * The users haven't requested anything as it is low-level implementation that doesn't affect them, but it will make long term development easier   * If you define features as stories that add value to the users, well a) they don't as the users won't see any direct benefit, but then b) they do because they make future development/maintenance possible which _does_ add value, just not right now I'm not deciding whether or not to actually do the work, or when to schedule it, I just what to know what I should call technical debt in my project management tool, and why.


Where can I find design exercises to work on?

I feel it's important to continue practicing my problem-solving skills. Writing my own mini-projects is one way, but another is to try and solve problems posted online. It's easy to find interesting programming quizzes online that require applying clever algorithms to solve - Project Euler is one well-known example. However, in a lot of real-life projects the _design_ of the software - especially in the initial phases - has a large impact and at later stages it cannot be tweaked as easily as plain algorithms. In order to improve these skills, I'm looking for any collection of design problems. When I say "design", I mean the abstract design of a software solution - for example what modules will there be and what are the dependencies between them, how data will flow in the program, what sort of data needs to be saved in the database, etc. Design problems are those problems that are critical to solve in the early stages of any project, but their solution is a whiteboard diagram without a single line of code. Of course these sort of problems do not have a single correct solution, but I'll be especially happy with any place that also displays pros and cons of the typical solutions that might be used to approach the problem.


Alternatives to Traditional Password Authentication

The third party login is excellent function that has come in recent years that relieves the load on a programmers mind so that I have to remember less useless passwords. I don't use the same password for many sites, I use an algorithm: for instance if I make a password for StackOverflow its name starts with S so I'll put in an S and then with my secret sentence so the password for SO will be something like `i81b4uS`, e.g. my secret phrase plus some token that makes the password not the same for every since since I don't want the disaster if some site saves my password in plaintext and gets hacked (then somebody would have access to all my online material if I used the same password). Biological metrics are good but this technology is not here. In the future we will probably only have to unlock at one point all our online material, instead of providing the system so many locks. Google's 2-step verification is flexible and goo but it's not perfect. Are there other, perhaps newer, or less known, authentication methods for instance that simplifies the common use-cases of renewing a password (where it is often tedious to check your mail where you often get interrupted, and providing the old password to change it to a new etc) and reset password, which is a lot like renew a password? I'm not asking for the detail of which algorithm, but rather if there are newer and more effective flows, like third party login which made me start an account at SO where I landed with me Google account, that puts less of a burden on the user's mind and manual memory and that are also safe? At my site I offer authentication much like SO and SE, where you can login at my site just like SO with Google, FB, Linkedin, Yahoo or custom accounts. I've used webapp2's user model to facilitate my logins and the simpleauth library for GAE (python). What would especially be good would be getting rid of email altogether and not bugging users about their email address at all. Some users are hesitant to leave their email, and email is often too much of a direct contact. So many users have smart-phones and androids so that there could be one app for many sites that does the authentication via smart-phone or a desktop app or a large third-party like Google, FB or Yahoo where I can offer Google, FB, Yahoo, LinkedIn so that a user can have a choice not to make up a new password, since that can be painful if you already have memorized 40 passwords for different sites and services.


How to add document directory path in javascript file in iOS -MetaIO SDK

I am working on a project using **MetaIO SDK (AREL)**. It works fine with all the files in the package (ipa), but I'm trying to download an animation automatically using a web service. It will be stored in the document directory. > Since AREL uses a javascript file, I need to give the javascript file the > address for the document directory, but I don't have any access to the iOS > (because Metaio does not give me direct access to the webview as there isn't > any other http request so cant use delegate). All i need is > window.MyImagePath = "/Users/mac/Library/Application Support/iPhone > Simulator/6.0/Applications/E02C5AE0-DFF0-4803-8C7F-134023077BD0/Documents/placeholder.png" In my JS file which is not in the document directory. I tried sending this information through the clipboard (safari allows clip board access only when paste event occurs) and through a web service which is not helpful either. Can any suggest a better solution please?


Subranges in Pascal

I'm reading some Pascal code and everything is pretty straightforward except subranges. In the program I'm reading there's a variable `d` with the following type declaration:`array[0..22] of 0..15`; there's then the following procedure:               var a:integer;     begin       a:=0;       while k>0 do         begin           k:=k-1;           a:=(a+dig[k]*two) div 10;         end;       round_decimals:=(a+1) div 2;     end;      Where `k` is a variable of type `0..63`. So since `k` can be above the range of the index of `dig` how does this code work? — It's a routine for doing fixed point arithmetic and so I would assume the array indicie overflows in some controlled manner, but if anybody could explain the exact behavior I'd be really happy. Also, do Pascal arrays assign in some known manner? There were a lot of versions of Pascal and I think this program is written in a pretty “Pascal-version agnostic” manner, but I can't find much explanation on the subtle semantics of subrange expressions.


What is a constructor? And what are set/get methods in Java?

I am having difficulty understanding constructors and set/get methods. What are they being used for? If someone can explain a little more hopefully I can get the AHA moment.


How to measure the right time to bring a new client?

My growing company has a team of developers working on a number of separate projects. Our developers depend on us to keep them working, and we depend on them to make our clients happy. Our projects have differing start and end dates, as you can imagine. The company's responsibility to the developers is to make sure we have clients waiting in the wings so that when one project ends, another can start. For now, finding clients is not a problem and not the topic of this question. What I'm trying to think through right now is, how can I best measure/view/evaluate the end dates of projects so that I know when I need to start courting the next client. Is there a tool that does this? If it's just a spreadsheet, what might it look like?


Default vs Impl when implementing interfaces in Java

After reading Should package names be singular or plural? it occurred to me that I've never seen a proper debate covering one of my pet peeves: naming implementations of interfaces. Let's assume that you have a interface `Order` that is intended to be implemented in a variety of ways but there is only the initial implementation when the project is first created. Do you go for `DefaultOrder` or `OrderImpl` or some other variant to avoid the false dichotomy? And what do you do when more implementations come along? **And most important... why?**


Is a scrum sprint backlog ordered?

Currently, Wikipedia Scrum Article defines "Sprint Backlog" as: > A prioritized list of tasks to be completed during the sprint. It is my understanding that the "Product Backlog" is a prioritized list but that the "Sprint Backlog" does not have an order. I am looking for a definitive reference for the answer.


Where should "display functions" live in an MVC web app?

I'm using the Yii Framework which is an MVC php framework that is pretty similar to your standard web-based MVC framework. I want to display the related data from a many-to-many table as a list of strings in my view. Assuming a table schema like:               tag { id, name }     post { id, title, content, date }     post_tag { post_id, tag_id }      A post will display like:               Date: 9/27/2012      Title: Some Title     Content: blah blah blah...     Tags: Smart Funny Cool Informative      I can achieve this by doing something like this in my Post view:               <?php       echo join(' ',                array_map(function($tag) { return $tag->name; }, $model->tags));     ?>      (where `$model->tags` is an array of `Tag` objects associated with my model) My questions are:   1. Is this amount of code/logic okay in the view? (Personally I think I'd rather just reference a property or call a single function.)   2. If not, where should this code live? In the model? the controller? a helper? Potentially I may want to use in in other views as well. Ultimately I think its purely a display issue which would make me think it should be in the view, but then I have to repeat the code in any view I want to use it in.


Most efficient Implementation a Tree in C++

I need to write a tree where each element may have any number of child elements, and because of this each branch of the tree may have any length. The tree is only going to receive elements at first and then it is going to use exclusively for iterating though it's branches in no specific order. The tree will have several million elements and must be fast but also memory efficient. My plan makes a node class to store the elements and the pointers to its children. When the tree is fully constructed, it would be transformed it to an array or something faster and if possible, loaded to the processor's cache. Construction and the search on the tree are two different problems. Can I focus on how to solve each problem on the best way individually? The construction of has to be as fast as possible but it can use memory as it pleases. Then the transformation into a format that give us speed when iterating the tree's branches. This should preferably be an array to avoid going back and forth from RAM to cache in each element of the tree. So the real question is which is the structure to implement a tree to maximize insert speed, how can I transform it to a structure that gives me the best speed and memory?


Architecting a modular service application

I'm looking at architecting a new solution that is very modular by nature and would like to create a structure that supports that design to allow for easy future expansion, clear separation of concerns, licensing by module, etc. Most of what I've found on the web about modular or composite applications are UI- centric, focused on Silverlight, WPF, etc. In my case, I am developing a WCF service application that will be consumed by other developers working on various UI projects. **Background** The goal of my project is to create a centralized source of business/domain logic to support several of our business applications that currently duplicate process, rules, etc. And while not every benefit of modularity will be achieved, I'd like to seize the opportunity to establish a framework that will leverage those parts we can take advantage of. I've started the design by looking at the API exposed by the service application. It is clear that the services can be segregated along the modular lines that I was considering. For instance, I will have FinanceService, InventoryService, PersonnelService, etc. services that group my service operations to provide high-cohesion in the API while keeping the coupling low so clients only have to consume the services that are pertinent to their application. It makes sense to me that I can then have separate modules for each of these services, such as MyApp.Finance, MyApp.Inventory, My.Personnel and so on. Cross-cutting concerns and shared types would be in the MyApp shared assembly. From here I get a little tied up. (Oh, I should mention that I'll be using an IoC container for Dependency Injection to keep the application loosely-coupled. I won't mention which one because I don't want to open Pandora's box!) In MyApp.ServiceHost, I will create a service host file (.svc) corresponding to each module, FinanceService.svc for example. The service host needs the name of the service which corresponds to the information in the configuration file that contains the interface defining the service contract. The IoC configuration is then used to map the concrete implementation of the interface to use. **1\. Should the service layer implement the API and delegate to the modules or should the modules be self-contained (in that they contain everything related to that module, including the service implementation)?** One way of approaching the problem is to have a MyApp.Services "module" which contains the implementation of the service contracts. Each service class simply delegate to another class int eh appropriate module which contains the domain logic for the operation. For example, the FinanceService WCF class in MyApp.Services delegates to another interface which is implemented in the Finance module to carry out the operation. This would allow me to maintain a thin service facade and 'plug-in' the implementation to the service implementation and eliminate the need for the modules to worry about WCF, for instance. On the other hand, maybe it's preferred to have each module self-contained in that it has the interface and the implementation. The service host refers to the service contract interface found in the module and the IoC is configured to use the appropriate implementation from the module as well. This means that adding a new module can be done with no changes to the service layer other than adding a new .svc file and IoC configuration information. I'm thinking about the impact if I switch from standard WCF to a RESTful service interface or maybe go to RIA services or something. If each module contains the implementation of the service contract, then I have to make changes in every module if I change the service technology or approach. But, if the facade is its own module, then I only have to swap out that part to make a change. The modules would then have to implement a different set of contracts (interfaces), possibly defined in the shared assembly??? **2\. What is the best way to handle sharing resources between modules and/or dependencies between modules?** Take, for instance, a Receiving operation. At first blush it makes sense that this goes into the Inventory module as receiving goods is an inventory function. However, there is also a financial aspect in that we need to generate a Receipt and authorize payment. On the one hand, I would expect to use some type of domain events / messaging to communicate the operation. The Inventory module raises a GoodsReceivedEvent which is handled by the Financial module to generate the Receipt and initiate the payment process. However, this means that the Financial module needs to know about the inventory items that were received. I can simply refer to them by ID but what if I need additional information for the Receipt, such as the name and/or description, unit cost, etc.? Does it make sense for each module to have their own version of an inventory item that is designed to suit the needs of that module? In that case, the Financial module would have to perform its own lookup of the inventory items when handling the GoodsReceivedEvent. Or do I now have to put my domain objects into a shared location (at which point I lose some cohesion)? ... I used this example on purpose because I've worked a lot with various ERP systems and know they are designed with this type of modularity - I just don't know how. I also don't explicitly mention it above, but I prefer to follow Domain Driven Design principals in architecting the solution and believe that this type of modularity fits right into that area. Any help getting my head wrapped around this is greatly appreciated.


How much effort should you put into a junior developer?

At what point should one give up? I've tried helping them out by having them shadow me. We agree to break a minute, and then they go missing in action for a while...then just go back to their desk. Even when I know they've done this, part of me feels like I shouldn't have to go get them but that they should be showing interest in learning. Frankly, it's a bunch of time I don't have explaining things as I go when I could just do it. Am I expecting too much to expect that if they want to learn they'll make sure I know they're ready and willing? They go to meetings that they were not told they had to attend...good, but then sit in the corner and sleep...bad. I don't even know what to do with that. Sometimes I give them something small to do and they do it great, so I give them something just a touch harder and they totally fail, hard. They check in things without testing them. Part of me thinks that maybe I should be spending more time with them but at the same time I don't see a lot of interest and I really, honestly don't have time teaching the same things over and over. Sometimes I get asked questions that are really, really easy to answer if you just do a little bit of your own work trying to find out. Other times I'm not asked anything. I'm sure I could be doing better but honestly...I don't really want to anymore.


Extremely trivial C++ phone interview question

My company is currently interviewing for a developer position, and a disturbingly high number of candidates with good resumes end up being total frauds. We do have a written technical test which works fine for that purpose (it was initially designed for interns, but we found out that even candidates interviewing for senior positions failed it abysmally), but I'd like a few questions that allows us to filter out those people with a < 10 min. time investment. I'm trying to come up with a very trivial C++ (or even just programming) question that can be easily answered on the phone. The goal is not to get tricky, or even midly complex, just to weed out the people who'd fail an "intro to programming" midterm. So far, the best I've come up with is "Let's assume I'm an intern you're mentoring: can you explain to me, in simple terms, the difference between a vector and a list, and when I should use or the other". Any other ideas?


Does it make sense to write build scripts in C++?

I'm using CMake to generate my projects IDE/makefiles, but I still need to call custom "scripts" to manipulate my compiled files or even generate code. In previous projects I've been using Python and it was OK, but now I'm having serious trouble managing a lot of dependencies in two very big projects I'm working on so I want to minimize the dependencies everywhere. Someone suggested to me to use C++ to write my build scripts instead of adding a language dependency just for that. The projects themeselves already use C++ so there are several advantages that I can see:   * to build the whole project, only a C++ compiler and CMake would be necessary, nothing else (all the other dependencies are C or C++);   * C++ type safety (when using modern C++) makes everything easier to get "correct";   * it's also the language I know the better so I'm more at ease with it even if I'm able to write some good Python code;   * potential gain in execution speed (but i don't think it will really be perceptible); However, I think there might be some drawbacks and I'm not sure of the real impact as I didn't try yet:   * might be longer to write the code (that said I'm not sure because I'm efficient enough in C++ to write something that work quickly, so maybe for this system it wouldn't be so long to write) (compilation time shouldn't be a problem for this case);   * I must assume that all the text files I'll read as input are in UTF-8, I'm not sure it can be easilly checked at runtime in C++ and the language will not check it for you;   * libraries in C++ are harder to manage than in scripting languages; I lack experience and forsight so maybe I'm missing advantages and drawbacks. So the question is: does it make sense to use C++ for this? do you have experiences to report and do you see advantages and disadvantages that might be important?


Is there a sequence to read through the Android developer site for a user new to Android?

To summarize: I can buy a book, people say "Just read the developer site", I like to be spoon-fed the early learning piece for a technology, what path through the developer site will give me that spoonfeeding I need (that is, examples tied directly to the section being discussed, a clear path, etc.). I keep seeing that I don't need to buy an Android development book, that I should just read the Android developer site, because it has everything I need to know. I see it more as drinking from a fire hose. But I'm one of those people who likes to be walked through the basics. I like to build up my knowledge, rather than being dropped into reference documentation. I also like to make sure I have see all/most of the topics covered. I'd hate to develop the wrong thing, because I don't know about Fragments, Content Providers, or whatever. So, since it's a great resource, better than any book (we don't need no stinking books), how do I traverse the site to get the information provided in the same way as a book would lay it out?


Turning your code inside out (functional style) compared to a OO paradigm

I have find this article Turning Your Code Inside Out and I want to know how this approach described in article is for OO programmers/languages. Is this style of design used in OO programmers/languages? What's downsides and goodsides of this approach in a OO language? **Update:** OO objects have state and behavior, the design explained in article is stateless. Is not only Single Responsability Principle. (If I'm talking shit, please explain to me instead of only downside/close votes)


Service Design approach - one generic operation, and its implications

The hot topic in our organization is Service Design Approach. First Approach - The team wants to design services which essentially have one operation, can take any XML and return response XML message. The operation and the parameters are in the request XML message. Once the message is received the service determines the action/method that is requested. Reasons cited are ease of deployment and flexibility of introducing future operations. Second Approach - The second group is adamant about well defined service contracts and specific messages. Reasons cited are better performance, message validation and versioning. This is my preferred approach as well. What are the Pros and Cons? Can there be challenges introducing an ESB later in the architecture if we have chosen the first approach?


Why the bound of a linear function is same as that of a quadratic equation

I am learning algorithms, and I came across something very interesting. The asymptotic bound of the linear equation `(a * n)+b` is `O(n^2)`, for all `a` > 0. This is same bound as `a * n^2 + b * n + c`, which is surprising.


What approaches exist to setting up continent/country/city drop down menus?

How easy (or difficult) is it to have a Continent/Country/City drop down menu? Where one select from Drop Down Menus (for example): 1 - Europe 2 - UK 3 - London and then writes the Province/Area (for example: Essex). Realistically, how long should it take an experienced web developer to write the code of the above, as well as to link this selection to a Browse function and database storing? I do not have a geographical database yet and I am wondering what the fastest and cheapest way to add it to the drop down menu is. Is there any way to get that geographical database for free? I can see this type of geographical drop down menu in thousands of websites, but I am struggling as to how to implement it ASAP. * * * Follow Up: Tks All x your answers and comments so far. I hear what you are saying. I understand that there are rare occasions of Countries with multiple (same) name Cities and that it might be disputable whether a Country belongs to a certain Continent/Region or not (see Russia x example, Europe or Asia?). Anyway, please take a look, for instance, at this website Sign UP screen http://www.couchsurfing.org/register.html My question then is: Where do I get that list (Country/Cities) and how do I create that _array? Manually copying it somewhere else (which would take me ages) or are there ready made lists that can be downloaded from somewhere for free? * * * Follow Up n2: No way I plan to re-write the whole planisphere! I do agree, to a certain extent, that the number of Countries on this Planet is not fixed and this very issue is arguable (I've Googled: "How many Countries are there in the world?" and realized that there are different answers, however, I haven't got time to keep up to date with the ever shifting political landscape and engage into such debate). Irrespective of the argument between the Commentators below, all I just need is a straight and practical solution: a ready made list (database) of Countries/Cities (to use as _Array) in my DropDownMenus, exactly like the one on http://www.couchsurfing.org/register.html Has anyone got a clue where to get that list please?


What is the biggest support a boss can give to his/her developers?

Buying the best hardware, paying the most precious bonus or reward, treating them politely, provide the opportunity for improvement, etc.? We want to improve the productivity of our development team. We want to see what can be regarded the biggest support (or generally a good support), so we can start from there.


Should I use try catch in my test methods?

I am doing unit testing. I am trying to test one function. I call it from my test component. But If remote function cannot handle the exception then my tester component will also get exception, I guess. So should I worry about getting exception in my tester component? Thanks. **EDIT:** PS: Throwing an error is good, but only for other functions, not to end users until its a last option! OMG I wrote a programming quote!!


Where can I find windows via c/c++ video training?

There are plenty of windows programming online-video courses but most of them is about .net programming. But many task cannot be accomplished by .net such as API Hook. I think to be a windows programmer one must learn windows api via c/c++ sooner or later.I have the _windows via c++_ book, Is there any video course about advanced windows native programming online?


Right tool for small size Content Management System Project

I'm starting a new project in my head. It will be an events calendar. It will get info from openData sources the local goverment provides and will allow registered users to add aditional events to the calendar. The project is a personal one, and will be used also as a learning tool for me. In the Web side I just know HTML+CSS+PHP, but have never used PHP frameworks like Zend or Symfony, or any CMS systems like Alfresco or LifeRay. Which will a reasonable technology for this one? I know I just can code plain php, but like to learn some new technology, even if the project size seems not to justify the use of a complex tools more apropiate for bigger projects. It's hard to figure where to start just reading and not diggin into the subject, but I will be pleased to hear your opinions.


Are my negative internship experiences representative of the real world?

I'm curious if my current experiences as an intern are representative of actual industry. As background, I'm through the better part of two computing majors and a math major at a major university; I've aced every class and adored all of them, so I'd like to think that I'm not terrible at programming. I got an internship with one of the major software companies, and half way through now I've been shocked at the extraordinarily low quality of code. Comments don't exist, it's all spaghetti code, and everything that could be wrong is even worse. I've done a ton of tutoring/TAing, so I'm very used to reading bad code, but the major industry products I've been seeing trump all of that. I work 10-12 hours a day and never feel like I'm getting anywhere, because it's endless hours of trying to figure out an undocumented API or determine the behavior of some other part of the (completely undocumented) product. I've left work hating the job every day so far, and I desperately want to know if this is what is in store for the rest of my life. Did I draw a short straw on internships (the absurdly large paychecks imply that it's not a low quality position), or is this what the real world is like?


Best practices for merging a new version of third party source into an old version you've made changes to

A project I work on uses source code that's been purchased from a third party. The source code is delivered to us in a zip file. We store this source code in version control (TFS 2010) and routinely make modifications to it. When the third party releases a new version of the product we've purchased, I need to merge their new code into ours. Because the code I get is not under any kind over version control, it's very difficult to do this merge correctly. The last time I did this, we had not made many changes. As a result, I was able to check all the files out, copy the new files into their place, and fix up everything by hand without the help of any merging tools. Now that we've got a much larger set of changes, fixing things up by hand is too fragile to be a viable option. Are there any better ideas, or is this doomed to be painful and fragile each time?


Are robotics engineers also programmers?

I am going to be a senior next year, and I have done lots in computer programming and electronics. I am thinking of studying robotics when I go to university, but I am not sure how much programming there is going to be. Are robotics engineers programmers? How much programming can I expect to do if I choose to go down this career path?


Is JSF and JPA worth learning?

I'm attending a company sponsored training event for JSF and JPA that crams 10 days of training into 5 days. I plan on getting all that I can out of the class, but there is no "final exam".


When deploying updates, do you deploy all or selected/changed assemblies?

I'm a developer and I have had several experiences in web application deployment which are the following:   1. Deploy all files then apply configuration values as appropriate to the environment. We've used this style of deployment for larger softwares with long development cycles and quick releases aren't needed or allowed unless for emergencies.   2. Deploy only what has changed; manually update configuration files with what new or updated configuration as appropriate to environment. We've used this style for web applications that tend to be more agile, i.e. fix and feature releases are almost done daily. I've had issues with this before where not all assemblies dependent on an assembly that has changed were identified (A constant value was change in assembly A and the same constant was used in assembly B and only assembly A identified as changed). Which of the 2 is a better (or best) practice? I'm starting a new medium sized project where deployments would be on a monthly basis and would like to establish this process early on.


How ensure secure two cloud services can only talk to each other?

**Question** Given two cloud services, Sender A & Receiver B, communicating over HTTPS, what options do I have to ensure that Receiver B only response to Sender A? For the purposes of **Background** The receiver is generating activation keys for some hardware from a serial number. Our support team is using Salesforce and we're making callouts from Salesforce to an Azure service to generate the key. Since neither are behind a firewall we want to make sure that only request from our Salesforce instance can generate an activation key. My thought was just to create a nice long key stored on both sides that could be used to validate the request, but I'm not a security expert and don't know if there is anything else I should be considering.


Better word for Optional Requirements?

What's a better word for an optional requirement in software engineering? The phrase is contradictory. I've used "Non-Core Requirements" in previous projects.


Designing a scalable and robust retry mechanism

**Backstory** I have an Messaging Server Application that is responsible for brokering/proxying calls made from an Application Tier to numerous external services. The purpose of this application is to abstract the technicalities of invoking these services away from the main Application Tier. This works well as the Application Server does not have to worry about http/ldap etc protocols, wcf, ftp, soap, ebxml etc etc. They simply send a "payload", with a few identifiers, and the Messaging Server handles the rest. It also means that if a service definition changes the Application Server does not need to be changed. Additionally the Messaging Server is back ended by an SQL 2008 database that stores an audit of all messages sent and associated responses etc. The general data flow architecture of this is as follows: Application Server(s) => Load Balancer => Messaging Server(s) => [X] => External Services **The Question** I need to implement a retry mechanism into the Messaging Application tier. The intention is to gracefully recover from situations where the Messaging Server isn't able to forward onto the target service (i.e. service down, network issues, timeouts etc), i.e issues with point [X] in the architecture above. **The high level design requirement is:** Application Server sends a request to the Messaging Server. This then attempts to forward to the external services. If the first attempt at this fails the Messaging Server responds synchronously to the Application Server stating that the message is "in retry" The Messaging Server then proceeds to retry the fowarding per the contract (i.e. X retries with Y seconds between each). One of two things will happen next, all contracted retries will have been performed unsuccessfully or one of the retries will succeed. In either case a message is sent back into the Application Tier to notify the state of the messaging request. **A few gothcas** The message to retry can't be held in "memory" as if that Messaging Server goes down the message is lost. Additionally a retry contract could be 5 times once every 12 hours, holding data in memory for that length of time isn't feasible. That said some retry contracts could be 5 times once every 5 seconds. If the forward network goes down and then recovers the load of the retries should be spread across the entire messaging tier rather than a single server. **The question** The commucation between Application and Messaging tier isn't a concern as that framework is already in place. However the architecture of the retry framework in the Messaging Tier is still up in the air. How would you implement this? **Options we have/are considering** On failure store the retry data in a database, then have a polling service that checks the database every second. If a message is found that is scheduled for retry this is push back onto the Messaging Tier via the Load Balancer On failure store the retry data in a database, use a CLR job to poll the database and push messages, scheduled for retry, back onto the Load Balancer **Other Information** May or may not be relevant:   * All code is C#   * Databases are SQL 2008   * Comms from Application to Messaging tier is performed via WCF with BasicHttpBinding.   * We have complete control over all aspects of the Messaging Server tier and no control over the Application Tier.   * The Messaging Tier currently handles around 500k transactions per hour, so you can imagine how quickly things will backup if there is a failure on one of the external services


How to add personal android projects to my CV to get into Android job market

I am an experienced Java Programmer. 1 year back I started android programming and published 3 Apps into the market. But these all are my personal projects. Now I want get into the android job market. As my android experience is not corporate experience does the companies consider this? How to add these android projects to my CV to get into Android job market? Thanks


How can I use icons under a CC-ND license?

I am developing an open-source Java desktop application and I would like to use some icons in the GUI to indicate various settings, external links, etc. I found a set of free icons that are published under the Creative Commons Attribution-NoDerivs 3.0 Unported license that I would like to use. My questions are:   * Would including such an icon in my application constitute an adaptation or derivative work, and as such be a violation of the license?   * The icons are a little too big for my use case. Am I allowed to include scaled-down versions in my application? And would there be a difference between scaling them in photoshop and including these modified images versus including the original images and scaling them down programmatically?   * I would like to release my program under the Apache License 2.0. Does this have an effect on whether I can include the icons or not? Would I need to take any extra steps, other than including the original copyright and license information for the icons in my NOTICE file? Edit: An ArsTechnica article titled "Creative Commons images and you: a quick guide for image users" states that > More subtle alterations, like cropping an image to make it fit your page > width, might seem to be a gray area, but as long as you don't make enough > changes so that your version, when taken as a whole, qualifies as an > original, copyrightable work in its own right, then you should be safe. So the second question essentially becomes:   * Does a scaled down version of an icon qualify for copyright in its own right? And if the answer is "no", then it is not considered an Adaptation and therefore not prohibited under the terms of the license.


High performance mysql book suggests that for sharding a blog application, one may want to put comments data across 2 shards: first, on the shard of a person posting comment, and on the shard where the post is stored. So this raises the question how to reliably duplicate this data. Which of the following data duplication options across shards is recommended?      _Option 1:_ Make 2 separate inserts from the PHP script.   _Pros:_ a) Logic is in application layer.   _Cons:_ a) User is held for 2 inserts. b) This logic will need to be duplicated in every client trying to insert similar data.   Conclusion: Seems reasonable. _Option 2:_ Form federated tables and use some trigger to handle the insert of duplicate.   _Pros:_ a) App layer doesn't need to worry about multiple inserts   _Cons:_ a) Every shard need to have federated connection to every other shard; b) Federation will work on machines in LAN, but what about at 2 different sites. c) what if connection to federated server fails.   Conclusion: Doesn't seem like a sound idea. _Option 3:_ Messaging such as RabbitMQ   _Pros:_ a) Different clients can insert data at one place, and all subscribers can consume the insert.   _Cons:_ a) Complex; b) may impose overhead in order to host messaging server, and clients; c) not sure how will it work with a look-up service to locate appropriate shards   _Conclusion:_ Not sure   _Option 4:_ your suggestion? I will greatly appreciate your help.


Design thoughts on a schema based request object for CXF endpoint

Trying to seek design suggestion on a schema based request object for a CXF endpoint. I've created a CXF SOAP endpoint which takes the following object as an input. The request object will have required fields, non-mandatory fields as well as user-defined fields.Required fields are enforced through the schema. Tag object is defined as a placeholder for user defined properties. The eventual goal of the endpoint is transform the values into Tag object and send them for processing.               public class TestServiceRequest{            @XmlElement(required = true)         protected String url;         @XmlElement(required = true)         protected String title;         protected String source;         protected List tags;              public void setUrl(String value) {             this.url = value;         }         public void setTitle(String title) {             this.title = title;         }         public void setSource(String value) {             this.text = value;         }         public List getTags() {             if (tags == null) {                 tags = new ArrayList();             }             return this.tags;         }      Tag object :               public class Tag{        public String name;        public String value;        public String weight;     }      Schema snippet:               <xsd:complexType name="tag">             <xsd:sequence>                 <xsd:element name="name" type="xsd:string" minOccurs="1" maxOccurs="1" />                 <xsd:element name="value" type="xsd:string" minOccurs="1" maxOccurs="1" />                 <xsd:element name="weight" type="xsd:string" minOccurs="0" maxOccurs="1" />                 <xsd:element name="attribute" type="tns:attribute" minOccurs="0" maxOccurs="unbounded"/>             </xsd:sequence>         </xsd:complexType>              <xsd:element name="testServiceRequest">             <xsd:complexType>                 <xsd:complexContent>                     <xsd:extension base="br:BaseRequest">                         <xsd:sequence>                             <xsd:element name="url" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="title" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="text" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="source" type="xsd:string" minOccurs="1" maxOccurs="1"/>                             <xsd:element name="tags" type="tns:tag" minOccurs="0" maxOccurs="unbounded"/>                         </xsd:sequence>                     </xsd:extension>                 </xsd:complexContent>             </xsd:complexType>         </xsd:element>      As you can see, Tag object has an additional field called weight, which is the crux of the issue. Weight is an optional field for each property defined as required (url, title) and optional fields (source) as well. The weights are static value defined for these properties. The reason why I inclined towards this model is firstly, property field names (url, title, etc.) conform to a standard and cannot deviate. Having defined them in a schema and generating the request based on it, allows me to impose that. The end-user is free from using the exact field name and just use the setter instead, thus reducing the scope of error. Moreover, schema validation can be integrated with cxf endpoint easily, hence maintenance is easy. Any change is restricted to the schema. Issue with this model is the service end-point explicitly needs to add the weight for the fields while converting them to Tag objects. If the client ever decides to send their own weight values specific to properties, then this model will break. The other option is to use a simplified request object instead of a schema generated one.               public class Tag{        public String name;        public String value;        public String weight;     }      The pros are that this model is simple and flexible and allows user to define weights and other metadata if required. Issue with this, I need an explicit validation code to make sure the required fields are provided and the field names are correct. That means, every time a new field is added, I need to touch the code to add it as part of the validation. I'm in a dilemma to decide which is the best possible way to design this. Maybe,there's a better way to do this instead. Any pointer will be highly appreciated. Thanks


How complex is the documentation you write?

In a book I'm reading there is a chapter on documentation for your code. The book is about PHP and described some easy methods but also going for some complicated and time consuming methods (xml, xsl) like DocBook. At my current small company (5 people) we even rarely write comments, but I'm wondering if in a big company how detailed documentation do they write? Do they use such tools like DocBook? Is it complex or simple?


Should database-models (conceptual or physical) be reviewed by DBAs?

Where I work, new applications that are being developed that will use their own relational database, must have their database-models (conceptual, then physical ) reviewed and aproved by DBAs. Things looked after are normalization, antipatterns, table and column naming standards, etc. Is this really a DBA's responsability to do this ? or should it be, in a greater extend, the responsability of app designers and architects ?


Including Module Source files into War file using Maven

My goal is to include modules sources files into War file. I read this explanation on the maven official site: http://maven.apache.org/plugins/maven-assembly- plugin/examples/multimodule/module-source-inclusion-simple.html I wonder if it's the only way to include all sources files contained within all modules. Can't the simple maven-plugin-war do the same ?


How to do scalar multiplication and matrix inverse when variables are of size 1000 bits?

I am doing arithmetic operations on really huge numbers. For example, I am given six variables, a_{11}, a_{12}, a_{21}, a_{22}, x_1, and x_2. Although the above are math terms, these six variables are each 1000-bit integers. What I want to do is to calculate (1) two numbers z_1 and z_2, and (2) the matrix inverse. (1) z_1 = a_{11}*x_1 + a_{12}*x2 and z_2 = a_{21}*x_1 + a_{22}*x2 (2) if A is a matrix defined as A=[a_{11} a_{12}; a_{21} a_{22}], want to compute A^{-1} I know how to do the above when these six variables are ordinary floating points. But my question is how to compute them in C or Python when the six variables are all of size 1000-bit?


Aspect Oriented Programming: When to start using a framework?

I just watched this talk by Greg Young warning people to KISS: Keep It Simple Stupid. One of the things he suggested is that to do aspect-oriented programming, one _does **not** need a framework_. He starts by making a strong constraint: that all methods take one, and only one, parameter (though he relaxes this a little later by using partial application). The example he gives is to define an interface:               public interface IConsumes<T>     {         void Consume(T message);     }      If we want to issue a command:               public class Command     {         public string SomeInformation;         public int ID;              public override string ToString()         {            return ID + " : " + SomeInformation + Environment.NewLine;         }     }      The command is implemented as:               public class CommandService : IConsumes<Command>     {         private IConsumes<Command> _next;              public CommandService(IConsumes<Command> cmd = null)         {             _next = cmd;         }         public void Consume(Command message)         {            Console.WriteLine("Command complete!");             if (_next != null)                 _next.Consume(message);         }     }      To do logging to console, one then just implements:               public class Logger<T> : IConsumes<T>     {         private readonly IConsumes<T> _next;              public Logger(IConsumes<T> next)         {             _next = next;         }         public void Consume(T message)         {             Log(message);             if (_next != null)                 _next.Consume(message);         }              private void Log(T message)         {             Console.WriteLine(message);         }     }      Then, the pre-command logging, command service, and post-command logging are then just:               var log1 = new Logger<Command>(null);     var svr  = new CommandService(log);     var startOfChain = new Logger<Command>(svr);      and the command is executed by:               var cmd = new Command();     startOfChain.Consume(cmd);      To do this in, for example, PostSharp, one would annotate the `CommandService` this way:               public class CommandService : IConsumes<Command>     {         [Trace]         public void Consume(Command message)         {            Console.WriteLine("Command complete!");         }     }      And then have to implement the logging in an attribute class something like:               [Serializable]     public class TraceAttribute : OnMethodBoundaryAspect     {         public override void OnEntry( MethodExecutionArgs args )         {             Console.WriteLine(args.Method.Name + " : Entered!" );            }              public override void OnSuccess( MethodExecutionArgs args )         {             Console.WriteLine(args.Method.Name + " : Exited!" );         }              public override void OnException( MethodExecutionArgs args )         {             Console.WriteLine(args.Method.Name + " : EX : " + args.Exception.Message );         }     }      The argument Greg uses is that the connection from the attribute to the implementation of the attribute is "too much magic" to be able to explain what's happening to a junior developer. The initial example is all "just code" and easily explained. So, after that rather longwinded build-up, the question is: when do you make the switch from Greg's non-framework approach to using something like PostSharp for AOP?


Should I have a separate method for Update(), Insert(), etc., or have a generic Query() that would be able to handle all of these?

I'm currently trying to write a class library for a connection to a database. Looking over it, there are several different types of queries: Select From, Update, Insert, etc. My question is, what is the best practice for writing these queries in a C# application? Should I have a separate method for each of them(i.e. Update(), Insert()), or have a generic Query() that would be able to handle all of these? Thanks for any and all help!


Downgrading from GPL v3 to GPL v2

I have this issue with licensing. I downloaded a third-party class from GitHub and it's under the GPL v3 license. However, I used this class on another open-source project which is under the GPL v2 license, and submitting my script there, requires that everything is under GPL v2 from my side too. Am I allowed to change the license for that class, even though I am not the author?


Is there a specific name for the "Square inherits from Rectangle" paradox?

A certain failure of OOP is shown with a class Square inheriting from Rectangle, where logically Square is a specialization of Rectangle and should therefore inherit from it, but everything falls apart when you attempt to change a Square's length or width. Is there a specific term for describing what is going wrong with that case?


How can I make team Javascript development less painful?

We have a team working on an ExtJS web app. Right now, the interface and its functionality is all stuffed in one 1500-line JS file, which is of course _terrible_. It's bad form in general, of course, but it really makes merging changes a bear. Since Javascript doesn't have a #include or @require, or any other dependency- specifying mechanism, I'm at a loss how to gracefully split out functionality into smaller logical units, without requiring a great big laundry list of includes in the consuming HTML. I figure this is a common enough problem that somebody has worked out an elegant solution. Help?


Should utility base classes be avoided

Knowing that C# doesn't support multiple inheritance, is it considered bad form to write a utility base class? Some initial thoughts:   * I could create an interface and a concretion, but then the implementation isn't portable   * Should the developer need to extend the class in say, a decorator pattern, they could implement this new class and inherit the base class in their new class **EDIT** : N.B. I'm not talking about vanilla inheritance here e.g. poodle<\--dog<\--mammal<\--animal More this sort of thing (lifted from here):                   using log4net;         using log4net.Config;              public class LogTest2         {             private static readonly ILog logger =                    LogManager.GetLogger(typeof(LogTest2));              static LogTest2()         {             DOMConfigurator.Configure();         }              static void Main(string[] args)         {             logger.Debug("Here is a debug log.");             logger.Info("... and an Info log.");             logger.Warn("... and a warning.");             logger.Error("... and an error.");             logger.Fatal("... and a fatal error.");         }     }      If I were to drop this into say, a WCF service, it would be expedient for the private member variable, constructor and perhaps some wrapper methods to sit in a base class to save cluttering up the service code (and make it reusable). So far, so dull. However: What if I wanted to add some other sort of logging not supported by log4net? E.g. Acme Corp provide some class to iMessage the support team if an issue occurs. **Base class** Had I implemented the log4net stuff in a base class, I'd then have to create some new master base class that supports both classes and inherit this. **Interface** I could implement an interface but the concretion would still be in the service code which we're trying to avoid. Acme Corp's class can of course now drop straight in but we're implementing two sets of code which do very similar things in different ways.


Resources to learn video/motion capturing

I'm hoping to do some programming for the Kinect for my final year University project, starting in a few months. Although I am a fairly competent C# programmer, I've no experience with motion capture, vision depth, basically all those things measured and captured by the Kinect. Could somebody recommend some reading on this subject, preferably at the novice level for now? Online resources would also be good.


Full Text Search Strategy For My Website

I have a website that allows users to search for items in various categories. Each category is a separate area (page) of my website. For example, some categories might be cars, bikes, books etc. At the moment a user has to search for an item by going to the page (for example, cars) and searching for the car they want. I would like to allow the user to search for anything on my site, from my main home page. At the moment, each page (category) has its own set of tables, and I don't really want to turn Full Text Search on for each table (20+ of them) and search each table individually when a search is done. This is going to be slow and tedious. What I'm thinking of doing is creating a single table that will hold all searchable information for each category of item (when an item is saved in its respective table, I would copy all searchable information over to my 'Search' table). I would then turn Full Text Search on for that table, and search that table. Does this sound reasonable? Is there a better way? I've never used Full Text Search before, so this is new to me.


Customizing configuration for PHP will Laravel 4 IoC be useful?

This topic has been discussed in this post: Customizing configuration with Dependency Injection However - I couldn't find one for PHP syntax and since one of the answers was to use a specific ASP.net container - I couldn't correlate. I currently have a static class App\Config - that injects itself with a long array of configuration. the array is nothing more than array('max_select' => '10'); and other breakdowns for different objects to be initialize. Would Laravel's IoC be useful to chop this up? If so - how would I do so? Laravel code would be: `$app->make('MyClassA');` However I don't know how to correlate.


How to improve in code after you know many languages?

Over the past years I learned about 14 programming languages (assembler phyton delphi qbasic c++ c# ruby perl - etc etc etc). However this was all out of my own interest, I didn't went to school for it. Now without real education I am into a team with other programmers. We are into robotics with our work. In contrast to me they know about 2 languages and many frameworks I never had heard of before. I don't really feel behind them, but they can surprise me and other times I can surprise them with solutions. The largest difference is that they have worked for years in the IT, while to me the programming part, is new and I enjoy it. But after the many languages I find it a bit hard to improve. Sometimes I see code (or tools) that are new to me. I never used tools as anksvn, or did versioning or never had seen USB driver made in code, I got used to them, learned from them on projects and my colleagues. I started making money with code (without a real degree) the last 2 years. Given that I haven't found any good YouTube channel or a book, that might improve my skills, how can I improve further? My interests these days are C++ and C#. The point I loose interests if books start with the basics of "if then while for types objects" after 14 languages you get that.


Is writing software easier than reading and understanding it from scratch?

Me and a friend of mine were discussing yesterday about differences between writing a large C++ software and understanding it as a new recruit. Is it possible that since a software gets done one line at a time and this process resembles how we (humans) learn things and build a thing on top of another one, writing a large software is actually easier than reading it and understanding what it does (stepping through the code helps but you need to remember multiple classes/source files together you don't even know what they've been written for, multithreaded code adds malus points)? This sounds weird at first but after we thought a bit it seemed reasonable


Source for "Programmers combine like resistors in parallel"

What is the origin (reference, time, author) of the following quote? For instance, is it from a book? > Programmers combine like resistors in parallel. It may be by Gerry Jay Sussman, and I can not rule out the quote comes in several variations. Optionally, **_secondary_** question: what does this quote mean?


How much time should be spent with use cases?

I'm starting to work with agile iterative approach to software development and this question seems quite natural. After gathering the requirements I should write a few use cases to describe how the user interacts with the system while the requirements are being met. Now, how much time should we spent with this? Should I spent something like a week figuring out the use cases, finish then and only then move to working with each of them to find the main objects? Or should I just write a few of them and get a small number to work with? If I understood agile well, I think I should get just some of them and assure that the functionality being purposed there is indeed constructed and is already usable. Only then I should move to other use cases and review what was done in the use case finished. Am I right with this idea? Thanks very much in advance!


Should model / table names be as generic as possible?

When naming a model, should the name be as generic as possible-- even if that won't be the name displayed to users? For example let's imagine a Django model for liking another user's posts. Does it make sense to name the model 'Like' even if I plan on displaying it as Kudos, Endorsements, Ups, etc? Does it make sense to make the name as generic as possible, even if the name won't be the one displayed to the user?


Why doesn't DDD consider Documents?

... that is, the inputs and outputs of service functions ? Are entities, or aggregates, allowed to leave service boundaries?


is it valid that a state machine can have more than one possible state for some transition?

I have a requirement for a workflow which I am trying to model as a state machine, I see that there is more than one outcome of a given transition(or activity). Is it valid for a state machine to have more than one possible states, but only one state will be true at a given time? **Note:** This is my first attempt to model a state machine. Eg. might be: **s1->t1->s2** **s1->t1->s3** **s1->t1->s4** where s1, s2, s3, s4 are states and t1 is transition/activity. A fictitious real world example might be: For a human, there can be two states: hungry, not hungry A basket can have only one item from: apple, orange. So, to model it we will have: **hungry->pick from basket->apple found** **hungry->pick from basket->orange found** **apple found->eat->not hungry** **orange found->take juice out of it and then drink-> not hungry**


C language portability

How exactly is portability of a language like C is determined? I've learned that compilers are ISA specific. If this is true, how is C portable? Or is it that just the source code written in C is portable but not the executables? Aren't the executables ISA specific for examples applications for x86 are separate from the applications for Apple (assuming Apple uses Motorola/PowerPC microprocessor)?


Artificial Intelligence Code?

I took a Class in college (A.I.) and I found it pretty interesting, but didn't go much further than that (I graduated that semester so I wasn't able to take any more classes). So it's something that's been kind of coming back up as a "side" interest that I kinda wanted to study on my own, I have a ton of e-books and documents but the problem is they are VERY advanced and extremely math/algorithm heavy (which I can understand).....however none of them really explain how you would go about it 'code wise'......so I guess what Im asking is, is their a beginner resource to this kinda stuff (Bayesian Networks/Machine learning/Neural Networks) and such that isn't SO math heavy. I understand why the math is there, but when it doesn't really explain how you would go about 'programming' such a system.....well it gets kind of confusing to move forward with.


Source control and compilation tool chain

I am a single developer working on a large system. I was recently informed that there may be an opportunity to recruit another developer or maybe two. I have incorporated source control into my approach using Subverison and Tortoise SVN. I was talking to another developer who I used to work with recently and he reminded me about the concept of a compilation tool chain and specifically nightly builds for unit testing. I have two questions:   1. Is it good practice for all software development teams to use unit testing and nightly builds? Is there any criteria that identifies teams that are more suitable than others for nightly builds.   2. How do developers identify areas suitable for unit testing? I assume that you look at the use cases. I assume that these use cases could include different processing methods e.g. users interacting with a web application or a batch processing job that runs via a scheduled task each night.


Does agile development need a framework in place first?

We are planning a new project and we want to go with a services oriented architecture. Everyone agrees that this is the way to go but how does this fit in with starting the development using agile methodologies? I do not have any experience with SOA, although I have some experience with TDD (test driven development). The team I work with thinks that we need a framework in place before we can even start looking at developers doing work with TDD. In others we spend weeks getting a framework in place (a SOA framework) and then the developers can build on this framework to do their work. From a TDD point of view, I would have expected each developer to just flesh out the functionality using MOCKs etc whilst the framework is being developed (although I have no idea what a framework in SOA would involve). Then we could plug in the actual framework calls when we need to. Not sure if this right but it feels the correct way.


How should contributions to an open source project be managed by the owner(s)?

When managing an open source project (using a service like GitHub) how would one respond to the following: Somebody has kindly submitted a patch to add a new feature or address a problem. Any one of the following situations occur:   * The source code doesn't meet one or more naming conventions, etc.   * I feel that the source code could be improved in a certain way. Perhaps the same effect can be achieved with far simpler source, or perhaps another useful feature would be needed. Q1. Is it acceptable for me to alter the submitted source? (is this possible on GitHub?) Q2. Should all such submissions be rejected in accordance with submission guidelines? Q3. If yes to Q2, what about a really neat idea that was poorly implemented? Is it acceptable for me to just go ahead and create my own? I want to encourage contribution but at the same time it is important to maintain a certain standard.


Clean readable code vs fast hard to read code. When to cross the line?

When I write code I always try to make my code as clean and readable as possible. Every now and then there comes a time when you need to cross the line and go from nice clean code to slightly uglier code to make it faster. When is it OK to cross that line?


Things to be aware of Client Relationships as a Beginner?

I'm an entry level programmer and am involved in daily client meeting about project progress, issues, deadlines etc. I have no experience of client management, could you people please suggest any common things to consider when interacting with clients both in a project and people management perspective.


How to simplify unit testing with higher order functions?

* this is _not_ a question on how to write unit tests   * this is _not_ a question on what to test   * this is a question on reducing the typing needed overall for a personal testing framework I know you can send function pointers as arguments to functions in C. Is there a c++98 version? Or, since c++ can work backwards, should I just use the C function pointer method? I am trying to write a function that tests functions for me. I don't want to write a long list of:               try {       func1()       out << fail     } except e {       out << pass     }          if (func2(arg2) == expected_val) {       out << pass     else       out << fail          try/catch...     try/catch...     if/else...     try/catch...     ...etc      but maybe instead:               test_this(func1, passes_on_exception)     test_this(func2, ! passes_on_exception, expected_val2, arg2)     test_this(func3, passes_on_exception)     test_this(func4...     test_this(func5...     ...etc          void test_this(func_name, pass_on_exception, expected_value, arg1, ..., argn) {       if pass_on_exception {           try {               func_name(arg1)               out << fail           } catch e {               out << pass           }       } else {           if func_name == expected_value {               out << pass           } else {               out << fail           }       }     }      Virtual functions seems out of the question since, if I recall correctly, the function names have to be overridden/hardcoded; as in, I would need to create a new class to inherit and override the functions, in which case, I would redeclare the function, and also retype all of those try/catch... the chain of try/catch/if/else seems better. If there was a way to pass function names to other functions, I think I can figure it out from there. Unless the above is actually impossible in C++, then please stop me before I start, and I'll just bear with that long list of try/catch/if/else unit testing method. So, main question: is there a way to do the above? If not, alternatives?


Differentiating between Factory Method and Abstract Factory

I've been confused for a while about the differences between the patterns Factory Method and Abstract Factory. Been doing a lot of research, still confused. I have one question: Is the **only difference** between the two patterns, is that Factory Method **produces one object** , and Abstract Factory produces a **family of objects**? Or are there more differences? I read a lot on this site and the web about this, only confused me more. I know how to use the patterns, but am having trouble differentiating between the two.


expressing the speed of a sorting algorithm

How would I express the speed of the following sort algorithm? I know bubblesort is n^n (er, I mean n^2...as someone pointed out below). In the following the array decreases each time you call it recursively. thanks. * * *               $myarray = array("21","4","8","8","1","2","19","21");     mysort($myarray);          function mysort($myarray,$sorted = null){         if(!isset($sorted)){             $sorted = array();         }         $lowest = $myarray[0];         $lowindex = 0;         for($x = 1;$x < count($myarray);$x++){             if($myarray[$x] < $lowest){                 $lowest = $myarray[$x];                 $lowindex = $x;             }         }         $sorted[] = $lowest;         array_splice($myarray,$lowindex,1);         if(count($myarray) > 1){             echo "calling recursively \n";             mysort($myarray,$sorted);         }         else if(count($myarray) == 1){                   $sorted[] = $myarray[0];             $arraystr = print_r($sorted,true);             echo "sorting finished. Array is $arraystr \n";             return;         }     }


How to reduce close points

input: C matrix 2xN (2D points) output: C matrix 2xM (2D points) with equal or less points.      Lets say we have C matrix 2xN that contains several 2D points, and it looks something like that:   ![enter image description here](http://i.stack.imgur.com/1lFgN.jpg)   What we want is to group "close" points to one point, measured by the average of the other points. For example, in the second image, every group of blue circle will be one point, the point coordinate will be the average point off all points in the blue circle. also by saying "close", I mean that: their distance one to each other will be smaller then DELTA (known scalar). So wanted output is:   ![enter image description here](http://i.stack.imgur.com/Ihekp.jpg)   About running time of the algorithm, I don't have upper-limit request but I call that method several times...   I am using Matlab, and what i have tried is this:                 function C = ReduceClosePoints(C ,l_boundry)         x_size = abs(l_boundry(1,1)-l_boundry(1,2)); %220         DELTA = x_size/10;         T = [];         for i=1:size(C,2)             sum = C(:,i);             n=1;             for j=1:size(C,2)                 if i~=j     %not same point                     D = DistancePointToPoint(C(:,i),C(:,j));                     if D < DELTA                         sum = sum + C(:,j);                         n=n+1;                     end                 end             end             sum = sum./n; %new point -> save in T matrix             T = [T sum];         end         C = T;     end      And its not working :( Also I am new to Matlab.   Thank you for your help!!


SQL Update statement generator using C# Winforms?

I am trying to make an UPDATE STATEMENT generator using C# Winforms. I would like to build a statement generator which will print statements like this:               UPDATE Customers     SET ContactName='Alfred Schmidt', City='Hamburg'     WHERE CustomerName='Alfreds Futterkiste';      But my problem is, how can I let the user paste in multiple values for each `SET`? My end user is likely to build a list using a spreadsheet and will want to paste in the values into a multi-line text box. I could create 2 multi-line text boxes, but what if i have more `SET` columns i need to add?


Killer semi-unique programming language features

When learning a new programming language you sometimes come across a language feature which makes you wish you had it in your other programming languages that you know. What are some language feature which were at the time of learning very new to you and that you wish your other programming languages had. An example of this is generators in Python or C#. Other examples may include list comprehensions in Python, template in C++ or LINQ in .NET or lazy evaluation in Haskell. What other semi-unique language features have you come across which were completely new and enlightening to you? Are there other features of older programming languages which were unique and have fallen out of fashion?


How do you manage your knowledge base?

As programmers we have a lot of inputs:   1. Ebooks    2. Code snippets    3. Interesting emails    4. Documents   5. Web articles    6. Blog posts   7. StackOverflow questions   8. Podcasts ... Which tools do you use to store, organize, search and consult all of this stuff?   Is there a silver bullet solution to handle this huge amount of data?


With continuous integration in .NET, is it acceptable to reference DLLs of rarely-changing assemblies?

My company is looking to implement a CI solution pretty soon, and I am worried about one thing in particular... we are scaling up, which means our solutions are growing with more projects. One thing I wanted to look into is to split off rarely changed projects into a separate project, and then having other projects simply reference the compiled DLL, rather than including the projects in their solutions. For example...   * /BLL/DataFramework   * /BLL/OrmFramework   * /BLL/OrmDataAdapter   * /BLL/...   * /WebUI/MyWebSite The Data and ORM projects would rarely be changed, but if not referenced as DLLs would add bloat to all solutions. Instead I'd like to exclude them from the project and have them build to a Libraries folder (or something similar), so that:   * /BLL/...   * /Libraries   * /WebUI/MyWebsite Where the ORM and Data assemblies .DLLs are in the Libraries folder. So the question is... **Is there any reason this would not work with Continuous Integration?** Could I have one solution with these rarely updated classes that will build to the library folder during CI, first, and followed by the other solutions? _Edit: **To be clear...** we want to keep these projects in the CI cycle, but to not directly reference their projects in every solution._


several similar tables vs several one-to-one relationships?

I have a sort of blog application that I'm working on for constrained writing. The posts have several types, and share some columns in common (title, body for instance), but they also have columns that they don't share in common. Please correct me if I'm wrong, but I feel like my two database design options are:   1. Create a separate table for each type of post (and then use UNION if I ever need to select all of the various types).   2. Create one table to store all of the similar columns (and then have several one-to-one relationships to define what's different about them--like an inheritance-type situation). Which is better? Why? Are there other designs that would be better? **UPDATE** : these posts will be different types of constrained writing (I.e., poems), that are validated in specific ways based on the particular constraint technique, and may have a variety of other tables associated with them, so extensibility will be really important. That said it sounds like either the nosql or inheritance options would be best. I would just be worried about doing analytical stuff with nosql (never used it, so I just don't know anything about how to aggregate, etc, with it).


How does I/O work for large graph databases?

I should preface this by saying that I'm mostly a front end web developer, trained as a musician, but over the past few years I've been getting more and more into computer science. So one idea I have as a fun toy project to learn about data structures and C programming was to design and implement my own very simple database that would manage an adjacency list of posts. I don't want SQL (maybe I'll do my own query language? I'm just having fun). It should support ACID. It should be capable of storing 1TB let's say. So with that, I was trying to think of how a database even stores data, without regard to data structures necessarily. I'm working on linux, and I've read that in that world "everything is a file," including hardware (like `/dev/*`), so I think that that obviously has to apply to a database, too, and it clearly does--whether it's MySQL or PostgreSQL or Neo4j, the database itself is a collection of files you can see in the filesystem. That said, there would come a point in scale where loading the entire database into primary memory just wouldn't work, so it doesn't make sense to design it with that mindset (I assume). However, reading from secondary memory would be much slower and regardless some portion of the database has to be in primary memory in order for you to be able to do anything with it. I read this post: Why use a database instead of just saving your data to disk? And I found it difficult to understand how other databases, like SQLite or Neo4j, read and write from secondary memory and are still very fast (faster, it would seem, than simply writing files to the filesystem as the above question suggests). It seems the key is indexing. But even indexes need to be stored in secondary memory. They are inherently smaller than the database itself, but indexes in a very large database might be prohibitively large, too. So my question is how is I/O generally done with large databases like the one I described above that would be at least 1TB storing a big adjacency list? If indexing is more or less the answer, how exactly does indexing work--what data structures should be involved?


Why was REST web srevice named REST?

What does the word Representational State Transfer (REST) mean actually ? Now I don seem to find any relation between its naming and its working, I have understood that it is a architectural style for programming web service and I've read all the hush hush stuff but can't find a reason behind its naming. What is `Representational` ? Who's `State`? and What do we `Transfer`?


How deep is enough to represent an algorithm in UML sequence diagram?

I have three simple classes. `LoginController`, `UsersCatalog` and `User`. `UsersCatalog` has an array of `User`. I have to represent a simple process of login. `LoginController` has a method `login(username, password)` that simply calls a method `authenticate(username, password)` with the same parameters. Now, it's obvious that the method `authenticate` seeks for a matching `User` object and returns it. The question is: **Is it necesary to represent the seek algorithm?** Isn't representing the seek algorithm too much low level? In the other side, the access to `User` class is inside the seek algorithm, so if i don't represent it, then i don't represent the access to the `User` class. This is part of a wider question. There are any criteria for how deep is enough to represent an algorithm in UML squence diagram?


Local Updates in Persistent/Immutable Data Structures

I'm getting into ReactJS and am intrigued but also confused about persistent data structures. I love the idea, but I'm not sure how to take my MV*, Mutable, Observable Bindings experience in designing view components and apply it in a sane way. For example, suppose I have a deeply nested structure:               Foo       Bar          Baz           someValue       Qux       Quxx      In my UI, I have a component that is an editor for `someValue`. In a mutate- observe paradigm I would do something like:               Baz.setSomeValue(newValue)  // trigger observers, etc...      As near as I can tell, though, the equivalent with persistent data structures is something like:               Foo = extend(Foo, { Bar:{ Baz:{ someValue: newValue } } });     // recompute with new value of Foo      What is the normal pattern for encapsulating a component that deals with `Baz` so that it doesn't have to know the entire structure?


Where should I store and verify files manipulated by an app

I'm working on a little Ruby script to move screenshots while renaming them based on a specific convention. I'll be writing tests to confirm the behavior. Ruby has lots of conventions for where to store files (e.g. the "spec" and "features" directories for RSpec and Cucumber, respectively), but I'm not finding best practices for storing files that will be acted upon by the tests. The same goes for a destination for the final copies of the files. So, the question in two parts is:   1. Where should I store files that the test cases will use for a source input.    2. Where should tests that need to write output files send them to.


Decide for which class of points neurone will give output 1

We have to class of points `red` and `green`. We create neurone with discrete binary activation function. **How to choose weights so the neurone will return 1 for`red` points?** **How to choose weights so the neurone will return 1 for`green` points?** I am asking for general practice how to decide for which "side" the NET will be greater or equal to 0 -> if I am right about it. ![enter image description here](http://i.stack.imgur.com/UT1i3.png) NET >= 0 towards red points ![enter image description here](http://i.stack.imgur.com/12Kxe.png) NET >= 0 towards green points


How do I get people to stop bikeshedding?

I have been tasked with teaching other teams a new codebase, but I keep running into an issue. Whenever I go to actually walk through the code with people, we don't get very far before the entire exercise devolves into a bikeshedding exercise. Since they don't know the codebase, but think they need to help improve it, they focus on the things they _can_ understand: `Why is that named that?` (2 minutes to explain why it's named that, 10+ minutes debating a new name) `Why is that an abstract base class rather than an interface?` (2 minutes to explain, 10+ minutes debating the relative merits of this decision) ...and so on. Now, don't get me wrong - good names and good, consistent design are important, but we never get to discussing what the code actually _does_ or how the system is designed in any meaningful way. I've done some meeting refereeing to get people out of these tangents, but they're gone - distracted by what the code will/should be when their pet triviality is fixed, and they miss the bigger picture. So we try again later (or with a different part of the codebase) and since people didn't get enough knowledge to overcome the bikeshedding effect, it repeats. I've tried smaller groups, bigger groups, code, whiteboarding, visio diagrams, giant walls of text, letting them just argue it to death, cutting arguments short immediately... some help more than others, but nothing **works**. Hell, I even tried having other people from my team explain it because I thought it might be that I'm just bad at explaining things. So how do you educate other programmers enough that they stop fixating on trivialities and can meaningfully contribute to the design?


Are there any famous one-man-army programmers?

Lately I have been learning of more and more programmers who think that if they were working alone, they would be faster and would deliver more quality. Usually that feeling is attached to a feeling that they do the best programming in their team and at the end of the day the idea is quite plausible. If they ARE doing the best programming, and worked alone (and more maybe) the final result would be a better piece of software. I know this idea would only work if you were passionate enough to work 24/7, on a deadline, with great discipline. So after considering the idea and trying to learn a little more, I wonder if there are famous one-man-army programmers that have delivered any (useful) software in the past?


Teaching programming to a non-CS graduate

I have a couple of friends interested in computer programming, but they're non-CS graduates; some of them have very little experience in software testing field (some of them took some basic software testing courses). I am going to be working with them on teaching basic computer programming, and computer science fundamentals (data structures etc). My questions are;   * What language should I start with?   * What are essential computer science topics that I should cover before jumping them into computer programming?   * What readings can I incorporate to make the topic interesting and non-overwhelming?   * If we want to spend a year on it, what topics should take priority and must be covered in 12 months? Again, these are non computer science folks, and I want to keep the learning as much fun as possible. Thanks everyone.


How should one handle accessing a 'local' API?

I'm currently writing a project that is using a few separate virtual machines for the database, API and front-end website (currently 1 of each). I'm writing my code in PHP, and all of these virtual machines are running within the same virtual network. What are the best practices (if any) for accessing a 'local' API like this in the front-end? Would you still use something like curl? Are there alternatives to doing so?


How to make creating viewmodels at runtime less painful

**I apologize for the long question, it reads a bit as a rant, but I promise it's not! I've summarized my question(s) below** In the MVC world, things are straightforward. The Model has state, the View _shows_ the Model, and the Controller _does_ stuff to/with the Model (basically), a controller has no state. To _do_ stuff the Controller has some dependencies on web services, repository, the lot. When you instantiate a controller you care about supplying those dependencies, nothing else. When you execute an action (method on Controller), you use those dependencies to retrieve or update the Model or calling some other domain service. If there's any context, say like some user wants to see the details of a particular item, you pass the Id of that item as parameter to the Action. Nowhere in the Controller is there any reference to any state. So far so good. Enter MVVM. I love WPF, I love data binding. I love frameworks that make data binding to ViewModels even easier (using Caliburn Micro a.t.m.). I feel things are less straightforward in this world though. Let's do the exercise again: the Model has state, the View _shows_ the ViewModel, and the ViewModel _does_ stuff to/with the Model (basically), a ViewModel _does_ have state! (to clarify; maybe it delegates all the properties to one or more Models, but that means it must have a reference to the model one way or another, which is state in itself) To _do_ stuff the ViewModel has some dependencies on web services, repository, the lot. When you instantiate a ViewModel you care about supplying those dependencies, but also the state. And this, ladies and gentlemen, annoys me to no end. Whenever you need to instantiate a `ProductDetailsViewModel` from the `ProductSearchViewModel` (from which you called the `ProductSearchWebService` which in turn returned `IEnumerable<ProductDTO>`, everybody still with me?), you can do one of these things:   * call `new ProductDetailsViewModel(productDTO, _shoppingCartWebService /* dependcy */);`, this is bad, imagine 3 more dependencies, this means the `ProductSearchViewModel` needs to take on those dependencies as well. Also changing the constructor is painful.   * call `_myInjectedProductDetailsViewModelFactory.Create().Initialize(productDTO);`, the factory is just a Func, they are easily generated by most IoC frameworks. I think this is bad because Init methods are a leaky abstraction. You also can't use the readonly keyword for fields that are set in the Init method. I'm sure there are a few more reasons.   * call `_myInjectedProductDetailsViewModelAbstractFactory.Create(productDTO);` So... this is the pattern (abstract factory) that is usually recommended for this type of problem. I though it was genius since it satisfies my craving for static typing, until I actually started using it. The amount of boilerplate code is I think too much (you know, apart from the ridiculous variable names I get use). For each ViewModel that needs runtime parameters you'll get two extra files (factory interface and implementation), and you need to type the non-runtime dependencies like 4 extra times. And each time the dependencies change, you get to change it in the factory as well. It feels like I don't even use a DI container anymore. (I _think_ Castle Windsor has some kind of solution for this [with it's own drawbacks, correct me if I'm wrong]).   * do something with anonymous types or dictionary. I like my static typing. So, yeah. Mixing state and behavior in this way creates a problem which don't exist at all in MVC. And I feel like there currently isn't a really adequate solution for this problem. Now I'd like to observe some things:   * People actually use MVVM. So they either don't care about all of the above, or they have some brilliant other solution.   * I haven't found an in-depth example of MVVM with WPF. For example, the NDDD-sample project immensely helped me understand some DDD concepts. I'd really like it if someone could point me in the direction of something similar for MVVM/WPF.   * Maybe I'm doing MVVM all wrong and I should turn my design upside down. Maybe I shouldn't have this problem at all. Well I know other people have asked the same question so I think I'm not the only one. **To summarize**   * Am I correct to conclude that having the ViewModel being an integration point for both state and behavior is the reason for some difficulties with the MVVM pattern as a whole?   * Is using the abstract factory pattern the only/best way to instantiate a ViewModel in a statically typed way?   * Is there something like an in depth reference implementation available?   * Is having a lot of ViewModels with both state/behavior a design smell?


How feasible would it be to not work for anyone, my entire programming career?

Assume I have enough money to live off of for 3 months. Would it be impossible to _just_ freelance my entire programming career, after sufficiently learning the language and helping open source projects? Or would clients want to see work experience. I am mostly talking about Objective-C development, so I would be publishing apps to make income. Is this possible?


What are the security implications of running untrusted code on my server?

I would like to set up an app that allows users to send their code and execute it on my server. The thought of running untrusted code makes me cringe, so I am trying to set up an exhaustive list of security threats that should be addressed. I am assuming I should strip down certain features of the language executed, like file access or (maybe) networking. I also come across terms like `sandboxing` or `chroot`. I know what they mean, but how should I actually use them? In short: What security threats should I address before allowing users to run their code on my machine, and how do I do it?


What factors can make mid-project join successful?

It's not entirely uncommon in IT that programmers are added to an existing project somewhere in the middle, or closer to finish. Unfortunately, I've seen that people quickly get disillusioned and leave the job. So, is there an actual problem? If there is a problem, is there some research in or are there best practices for avoiding this mid-project-join syndrome? Is this common in industry?


At what point does programming become a useful skill?

This is probably a very difficult question to answer, because of its subjectivity, but even a vague guess would help me out: Now that Khan Academy is beginning to offer Computer Science lectures I'm getting an itch to learn programming again. I maybe am a bit more technical than your average computer user, using Ubuntu as my OS, LaTeX for writing and I know some small tricks like regular expressions or boolean search for google. However from my previous attempts to learn programming, I realized I do not have a natural aptitude for it and I also don't seem to enjoy the process. But I am fairly certain that a basic proficiency in programming could prove to be very beneficial for me career wise; I also often get ideas for little scripts that I cannot implement. My question is: Let's say you study programming 1 hour / day on average. At what point will you become good enough so that programming can be used for automating tasks and actually saving time? Do you think programming is worth picking up if you never have the ambition to make it your career or even your hobby, but use it strictly for utility purposes?


Is it possible to take a binary compiled for ARMv7 architecture and convert it to ARMv6?

Is it possible to take a binary compiled for ARMv7 architecture and convert it to ARMv6 ? Are there any tools that can do this?


Advice for Setting up an On-Call Team

I'm leading a largish development team (~35 developers). We are doing primarily Web Development work on a number of sites. Historically the knowledge on the teams has been pretty siloed. If you worked on Site A you will know how to troubleshoot it, but you would not be a lot of help on Site B. We also have a few cross-cutting concerns, i.e. common components used between sites which require specialized knowledge to troubleshoot. With all this in mind, I'm trying to understand the best way to setup an on- call team. This would be a team of programmers who would be available to deal with out- of-hours emergency issues occasionally (say one call every 2 weeks). They may be required to deploy emergency fixes. Part of me is saying we can't have a big on-call team with shallow knowledge, instead we need a smaller team with deep knowledge who can expect to be on- call more often and remunerated as such. Does anyone have any suggestions based on experience on how to setup this team? Thanks in advance.


Which Common Lisp implementation to use?

There seems to be an immediate problem with starting to develop in Common Lisp: choosing an implementation. What should one take into account, and how much weight should it bear when considering a CL implementation? Should it conform to the ANSI standard? Should it be supported by SLIME? Do certain implementations lack good libraries, documentation, etc?


Why does this static field always get initialized over-eagerly?

I am looking at this excellent article from Jon Skeet. While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article: > The runtime could decide to run the type initializer on loading the assembly > to start with... Or perhaps it will run it when the static method is first > run... Or even wait until the field is first accessed... When I try this out (on framework 4), I always get the first result. That is, the static method is initialized before the assembly is loaded. I have tried running this multiple times and get the same result. (I tried both the debug and release versions) Why is this so? Am I missing something?


In what ways can I test an image slideshow javascript code?

I have a slideshow of images (and links) on a page. These images are part of a JSON response to a request sent after the page loads. The slideshow is set to play at an interval of 2 seconds. The slideshow can be paused, played over, and all other controls a normal slideshow would have. As a Rails dev, I proposed cucumber but the javascript guys in the team are not comfortable with ruby. I saw some cucumber for javascript libraries coming up, still in experimental stage. I checked out jasmine and related tutorials but all I could get from them is how I can carry out any internal functional testing such as credit-cart validation, etc. - which I think could actually be handled in unit testing? (Screw the research I did and) How should I go about testing this and similar components?