title: What security is used by default in WSHttpBinding (service side) or the WCF Test client (client side)?

text: I recently moved a service from BasicHttpBinding to WSHttpBinding (i.e. soap 1.1 -> soap 1.2). In WCF, using WSHttpBinding() makes it start using some default security settings. I presume the same default security settings are also used by the WCF Test Client since the client and server can continue talking after switching to the 'secured' WSHttpBinding. In fiddler, I've confirmed this security setup since I can witness a more complex security handshakes from the previously dead-simple request-response i.e. **Before:** (BasicHttpBinding)   1. [HttpRequest ] (Soap Request In Clear) [HttpResponse] (Soap Response In Clear) **After:** (WSHttpBinding)   1. [HttpRequest ] RequestSecurityToken [HttpResponse] RequestSecurityTokenResponse   2. [HttpRequest ] RequestSecurityToken [HttpResponse] RequestSecurityTokenResponse   3. [HttpRequest ] RequestSecurityTokenResponse  [HttpResponse] RequestSecurityTokenResponseCollection   4. [HttpRequest ] EncryptedData  [HttpResponse] EncryptedData   5. [HttpRequest ] EncryptedData **(actual application level request)** [HttpResponse] EncryptedData **(actual application level response)** So I can safely assume security is being applied. Now to the questions: **Question 1: What are the security settings?** I never told WCF of any membership provider. In fact I don't have any table (SQL or XML) of any usernames <-> passwords. So what kind of authentication is happening? Although WCF Test Client can authenticate as above, SoapUI doesn't pick up these Microsoft .NET defaults and has issues. SoapUI attempts clear text communications and then the server responds with an incorrect security token error. **Question 2: What is the most commonly practiced security model for SOAP 1.2?** Is it via certificates or username passwords or digest or **_** ? How are those credentials stored (SQL/XML?) and configured on the WCF server side?


title: Strengthening code with possibly useless exception handling

text: Is it a good practice to implement useless exception handling, just in case another part of the code is not coded correctly? ## Basic example A simple one, so I don't loose everybody :). Let's say I'm writing an app that will display a person's information (name, address, etc.), the data being extracted from a database. Let's say I'm the one coding the UI part, and someone else is writing the DB query code. Now imagine that the specifications of your app say that if the person's information is incomplete (let's say, the name is missing in the database), the person coding the query should handle this by returning "NA" for the missing field. What if the query is poorly coded and doesn't handle this case? What if the guy who wrote the query handles you an incomplete result, and when you try to display the informations, everything crashes, because your code isn't prepared to display empty stuff? This example is very basic. I believe most of you will say "it's not your problem, you're not responsible for this crash". But, it's still your part of the code which is crashing. ## Another example Let's say now I'm the one writing the query. The specifications don't say the same as above, but that the guy writing the "insert" query should make sure all the fields are complete when adding a person to the database to avoid inserting incomplete information. Should I protect my "select" query to make sure I give the UI guy complete informations? ## The questions What if the specifications don't explicitly say "this guy is the one in charge of handling this situation"? What if a third person implements another query (similar to the first one, but on another DB) and uses your UI code to display it, but doesn't handle this case in his code? **Should I do what's necessary to prevent a possible crash, even if I'm not the one supposed to handle the bad case?** I'm not looking for an answer like "(s)he's the one responsible for the crash", as I'm not solving a conflict here, I'd like to know, should I protect my code against situations it's not my responsibility to handle? Here, a simple "if empty do something" would suffice. In general, this question tackles redundant exception handling. I'm asking it because when I work alone on a project, I may code 2-3 times a similar exception handling in successive functions, "just in case" I did something wrong and let a bad case come through.


title: What are the advantages to using SQL query builders?

text: Are there any advantages to using a query builder, rather than using raw SQL? E.g.               $q->select('*')       ->from('posts')       ->innerJoin('terms', 'post_id')       ->where(...)      vs:               SELECT * FROM posts WHERE ...      I see that many frameworks use these kind of abstraction layers, but I fail to understand the benefits.


title: Good Practices of writing release notes

text: At the delivery of every version of software we have to write a release note. For example, here are some of the terms I add when I write a release note:   * Release Date   * Bug Solved Is that enough, or is there anything else?


title: How could I make automatic tests for GUI?

text: How can I check automatically what is seen and what not? Or at least, how can I organize some partly automatic tests? IDE: Eclipse (could use also IntelliJ Idea if necessary) Testing tool: Junit (again, could use something else if advised, but better if it is free) Application OS: Android Developer's OS: Linux (could change for MAC or Windows(reluctantly)) Language: Java All the work goes in the external device. No emulator. The application is a user wrapper for the firmware TV player, called as external activity. So, 70% of the code is for GUI. (The other 30% speak to servers and provides info to the GUI) Before I programmed the testing function myself, not using any tools. Now I have a tool at hand. But I can't imagine how could I test the UI, with the tool or without it. (Strictly said, with the Internet connections I have problems too, but I'll leave them probably for the other question.) The answer needn't be too platform-dependent, the principles and ideas will help, too. Of course, it is good to check, is some element in another and checked or not. Some regression checks would be nice for that. But I should also be sure that the element mentioned is not cut by some other elements and winks as I ordered by animation. The advices here: Is there a tool to test Java UI? won't help - there are only tools, not principles, and none of the tools could help in my situation.


title: Is it possible to check a client side application identity from server side?

text: Assume there is a web service which is visible publicly but it must be just responsive to a specific client application. Is there any mechanism to check client side application identity to prevent disallowed application to access the service? For instance, I have a web service which is called by my iOS application. I want to prevent others from calling my web service. Regarding the fact that others can decompile my client application and create another one which is working the same as mine, I think the only way to avoid unwanted access to the service is to check application identity on server to ensure the request comes from my own application. Is there any robust and secure way to do that?


title: Naming convention for higher order functions?

text: Is there a naming convention for higher order functions? That is, functions which return other functions. An example in Javascript:               function onlyDivisibleBy(div) { // <-- higher order function       return function (n) {         return n % div === 0;       }     }          var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];          arr.filter(onlyDivisibleBy(3)); // [0, 3, 6, 9]     arr.filter(onlyDivisibleBy(5)); // [0, 5]      I've tended to write it as above: that is, optimising for legibility at the invocation point (I'd read the last lines above as "filter the array to get items only divisible by 5"), however at the definition point away from the context in which it's used, it's not so easy to understand what this function does from its name.


title: Best process for product development and maintenance by a small team?

text: I'm going to be managing projects for a very small (2-5) senior developer team. They develop a subscription based web application. It has been in use for many years so at this point the work involves:   1. Developing new features and updates to existing features   2. Developing in-house tools and reports   3. Fixing bugs   4. Investigating customer service issues Production releases are sometimes determined by customer obligations, sometimes by competitive advantage, but for the most part are not time- critical. I'd like to have regular production releases to keep the product fresh -- once every 2 months or so. Since the team is so small, the developers themselves will have to be involved in designing, testing, deployment, and maintenance. Since we do not have a dedicated maintenance team I see the major challenge being development and planning disrupted by bug fixing and customer service issues. They can distract us during new feature development and disrupt the release schedule. My initial thought is to do the following:   1. Hire a junior programmer to buffer the senior developers from maintenance tasks. In between maintenance tasks this person can assist the senior devs.   2. Adopt a scrum style approach where we have a series of sprints leading up to a production release. This will allow us to keep the stakeholders in the loop and allow us to reflect and improve our process with each sprint.   3. Shortly following the release, which is when most bugs surface, the team can focus on design for the next release with the expectation that each one will likely get pulled into bug fixing. I'd love to hear your thoughts and lessons learned.


title: Multi-threaded application design

text: I'm currently planning a Windows service. It will be a multi-threaded application which will continuously check for database records and process them. My first thoughts were to set a number of max available threads and create new thread for each process. This works OK but since I'm creating a new thread for every new process I fear that its overhead will multiply if there are lots of records to process. My question is, is this a good design or would you recommend any other solutions? Here's what the application will do basically:   1. Check for available number of threads   2. If there are available threads check the database for records to process.   3. If there are records to process select top 100 of them   4. Create a new process   5. Call a web service for each record and update the record according to web service call result (This call+update usually take around 500ms so process will be live for about 50 seconds)   6. Continue to step 1 This is currently what I am doing:               timer1.Tick += Tick();          private void Tick()     {         //do some text logging         //do some TextBox updating     }          int MaxThreads = 10          while(true)     {         if(ThreadCount < MaxThreads)         {             new Thread(() => Process()).Start();             ThreadCount++;         }         else         {             Thread.Sleep(10000);         }     }          private void Process()     {         //call ws         //update records              ThreadCount--;     }


title: How to release project under public domain?

text: I'm currently working on project, which is going to demonstrate how widgets can be done with Context Framework. I will also publish the source code. In this case I want to give users as much freedom as possible, so that they can freely copy-paste, modify and also relicense whatever code they reuse. So, how do I mention that in the project? Are the some ready-made licences etc. that are suitable for this?


title: Dealing with multiple business requirement streams without compromising team size

text: A business has five discrete streams of business requirements to be implemented in software. There is a team of ten developers. A "naiive" organisational solution is to split the team into five "teams" of two (one per requirements stream). But I feel this compromises the integrity of the team (making teamwork more difficult, causing silo effects, making communication harder etc). Has anyone any insight into how best organise a developer team like this to deliver against multiple requirement streams? Is it workable to have fewer development teams than there are requirements streams?


title: A description for a changing-wording-of-a-website framework

text: I have built a Ruby gem, which allows programmer (or whoever) to change wording on their Rails website. When the edit mode is activated, every text on the website will have an edit icon. User can click on that edit icon and change the corresponding text immediately. It works with text, attributes of any element, select element, and string in Javascript. Now I don't know how to describe it succinctly. Right now the description is "WhowishWord facilitates the process of changing wording of a website". I think the description is bad and vague. Maybe there is a regular keyword for this kind of task (changing wording) that I do not know. Could someone help me, please?


title: What a Site Needs To Be Considered a WebApp?

text: I've been looking at the Chrome Store and I started to think about developing some nice stuff to publish there, since I have a machine installed with Chromium and I see the WebApp market a lot better than the platform-specific one. But what a site really needs and how it should be designed to be considered a WebApp?


title: Is there an anti pattern for historically grown software?

text: Is there an anti pattern that describes a historically grown software system where multiple developers just added new features to the system but no one really kept an eye on the overall architecture nor were refactorings ever done? I think this happens when management/customer asks for new feature constantly and no one ever refactors anything but just adds on to what other developers haven done before. A reason could also be that the developer is just overwhelmed with the software system and does not really understand how it currently works and then just adds/glues his code at the very end (instead of refactoring the code and changing it.) So over time it's getting harder and harder to maintain the system. (I wonder if there are pictures for these kind of anti pattern to make this more clear to none programming folks - like a car that was built by just adding more and more features without thinking of the overall design. Like someone has the need to tow trailers while riding backwards and then an engineer just welds a tow bar to the front of the car. Job done. But now the cowl doesn't open anymore.)


title: Is there a software license "for personal use only" and against any derivative work

text: I want to release an npm (NodeJS) module that will be a development dependency for extensions built for my product (will be used in testing). I don't want this module to be used in any released derivative work (commercial or free, open or closed source). Is there an existing suitable license that I can use?


title: Programming languages that improve your programming skill in general?

text: What languages would you suggest a programmer to learn, not because they will have a lot of use of the language (but they may have), but because it will improve one's programming skill in general and let one think in a different (and possibly better) way?


title: Starting as a developer what are the possible career steps?

text: I would like to know what kind of **jobs/roles** one could expect on their career path if they start as a developer. I also want to know **how many years** you'll be expected to stay in the same role until you progress to the next level. The career path is of course, based on how good you do your job, the company etc. but assume a normal person who balances life and family with career. Some examples of roles that I have in may head: developer, senior developer, architect, project manager etc.


title: Using SVN along with WAMP

text: I would like to run SVN server on my local machine along with WAMP. All SVN server binaries include Apache. Whereas I don't need Apache as I'm already running WAMP. Please let me know if there are any installs available that includes only the SVN server. If there are none available, shall I go ahead with what's available? And how would I do that without breaking anything. PS: I tried CollabNet and VisualSVNServer. Both includes Apache.


title: Legal issues with an NDA that I do not want to sign

text: I've been given a non-disclosure agreement (NDA) to sign by my current employer that I do not want to sign. It is incredibly open ended and I feel that it should have been a condition of my initial employment agreement, which I signed three weeks ago. The document contains very many definitions in the form of "including but not limited to," and "directly or indirectly." As well, it states that:   * I agree that any breach of the contract would inflict irreparable harm on the company (I agree that a breach may result in harm to the company but not necessarily irreparable harm).   * Should the document be amended any time in the future and I refuse to sign the amendment that I would be in violation of its terms.   * Everything I develop while under the company's employment is its property (neglecting to say whether what I develop on my own time, distinctly from my work, is my own).   * After my employment ends at the company I would be required to continue my duties there to assist in the perfection of its software, that I would not be allowed to perform any duties directly or indirectly related to my duties there for one year after my employment at the company ends (would I not be allowed to engineer software for a year?).   * Should the company decide to prosecute me for breach of contract that I agree not to defend myself, and that all terms in the document would be transferred to any company which purchases the one I work for without my consent. In short, they would legally own me for life and could absolutely destroy me for any reason they deemed fit. Are there any legal arguments that I could use to defend myself against signing the contract? For example, the fact that the NDA was not part of my initial employment agreement or that the document is intentionally abstract and vague to allow them to fill in the blanks any way they please? The company hosts the entirety of its source code on a site which employs a publicly accessible SCM and greatly embraces open source software -- the chances that I would ever come in contact with information that could legally be considered a "trade secret" or "confidential information" is very slim, so why would I need to sign the NDA? I do not believe that many of the employees there actually took the time to understand the NDA before they signed it, and know for a fact that a few of them did not. Are the terms of this agreement commonplace among the software engineering community?


title: Writing in C for Performance?

text: I know I have quite frequently heard that C typically has a performance advantage over C++. I didn't really think anything else of it until I realized that MSVC doesn't even seem to support the newest standard of C, but the newest it supports it C99 (as far as I know). I was planning on writing a library with some code to render in OpenGL so I could reuse it. I was planning to write the library in C since any performance increase is welcome when it comes to graphics. But would it really be worth it? The code using the library would likely be written in C++ and I prefer to code in C++ generally. However, if it would produce even a small difference in performance, I would likely go with C. It may also be noted that this library would be something that I would make to work across Windows/OS X/Linux, and I would likely compile everything natively (MSVC for Windows, Clang or GCC for OS X, and GCC for Linux...or possibly Intel's compilers for everything). I've looked around and I've found some benchmarks and such, but everything I've seen has dealt with GCC rather than MSVC and Clang. Also, the benchmarks don't mention the standards of the languages used. Anyone have any thoughts on this?


title: Explicit or implicit looping?

text: Why or when is "explicit" preferred when implicit solutions often are more readable and less code? It says "explicit is better than implicit" when for example an implicit loop is better than an explicit loop isn't it?               for every in all:       every.updated = True      The above looks implicit to me and better than an explicit counter since a counter is another thing that can go wrong and why not leave to the compiler or other environment instead of requirement an explicit counter variable:                 for(int i=0, i<a.length, i++)     ...      And there are languages where all looping is "implicit" - what does it mean and when is it preferred? And not explicitly setting a value to `null`or `None` or likewise seems better to me and I want to rewrite code when I "solve" a requirement by explicitly setting `return null` or `String name = null` since I think being explicit about what should be null and None should have a more clear solution such as only use a variable if it's needed and if I write return null somewhere I'm probably doing it wrong. When I was writing Java I found myself writing `return null` and declaring values as null at some places and I didn't like it and could rewrite it even though the case where I put `return null` was reached only in case of error. I asked the guru at work whether we ever should declare a variable to null, isn't defaults much better? I'd be glad to know your thoughts about this. An example where it _is_ better to be explicit I can think of is declaring a list and explicitly declaring what type is in the list is better than just a list of objects e.g. it's preferred to declare `ArrayList<ArrayList>` instead of just an ArrayList if we know that it's a list of lists.


title: How to take things step by step

text: This is about the third time I've had to write software to control a cellular modem. For those unfamiliar with the process, you have a sequence of steps you have to take. Each step takes a certain amount of time, and there's a few responses you should receive in that amount of time. There are also some responses you can receive at any time, regardless of the step you are on. Based on the response you have to go to another stage in the process. If it times out, you have to go to a different stage. In some cases, steps are attempted multiple times before going to another stage. These have to be non-blocking functions, which I can run as a task on a single threaded machine. So the main program would be calling this `modemTask()` a few hundred times a second, it checks whether it needs to do something, then performs a function if needed, and exits. In the past I've written this as a simple `switch` based state machine, with enumerated stages, somewhat like the following:               switch(stage){        case Power:           powerOn();                 // Turn the modem on           nextstage = ResetCmd;      // Go perform a reset           attemptsLeft = 5;          // Send the reset command up to five times           break;        case ResetCmd;           modem.write("ATZ\n");      // ATZ - reset           attemptsLeft--;            // Use one of our attempts           nextstage = ResetReply;    // Next wait for a response (should be OK)           timeout = millis() + 5000; // Wait for up to 5 seconds each attempt           break;        case ResetReply;           if(receivedResponse() == OK)     // Success           {              nextStage = NetworkAttachCmd; // Attach to the cellular network           } elseif(receivedResponse() == ERROR || timeout < millis())           {        // If we get an error or timeout, reattempt if we can, power on if we can't              if(attemptsLeft > 0)              {                 nextStage = ResetCmd;              } else {                 nextStage = Power;              }           }            break;        case NetworkAttachCmd:        ...     }     stage = nextstage;               // Assign stage indirectly for debug purposes - nice to know where we came from at this point      It's difficult to keep track of the whole flow of the system, inserting an additional step requires changes to the steps before and after, and it just seems like there should be an easier way. The largest one I've had to design had fewer than 60 stages, so it's not unmanageable, but I can't help but think that there's a better strategy or pattern for this type of work. While I use a few `#define` for most timeouts and attempts, it would be a bit nicer if this weren't embedded in the state machine. Perhaps a structure of some sort could be made to hold each state, but since the responses vary it seems just as complicated. Most steps will have a simple "OK" but some contain status and data that have to be acted on, where the stage will change based on the exact response.


title: Why is testing MVC Views frowned upon?

text: I'm currently setting the groundwork for an ASP.Net MVC application and I'm looking into what sort of unit-tests I should be prepared to write. I've seen in multiple places people essentially saying 'don't bother testing your views, there's no logic and it's trivial and will be covered by an integration test'. I don't understand how this has become the accepted wisdom. Integration tests serve an entirely different purpose than unit tests. If I break something, I don't want to know a half-hour later when my integration tests break, I want to know immediately. **Sample Scenario :** Lets say we're dealing with a standard CRUD app with a Customer entity. The customer has a name and an address. At each level of testing, I want to verify that the Customer retrieval logic gets both the name and the address properly. To unit-test the repository, I write an integration test to hit the database. To unit-test the business rules, I mock out the repository, feed the business rules appropriate data, and verify my expected results are returned. **What I'd like to do :** To unit-test the UI, I mock out the business rules, setup my expected customer instance, render the view, and verify that the view contains the appropriate values for the instance I specified. **What I'm stuck doing :** To unit-test the repository, I write an integration test, setup an appropriate login, create the required data in the database, open a browser, navigate to the customer, and verify the resulting page contains the appropriate values for the instance I specified. I realize that there is overlap between the two scenarios discussed above, but the key difference it time and effort required to setup and execute the tests. If I (or another dev) removes the address field from the view, I don't want to wait for the integration test to discover this. I want is discovered and flagged in a unit-test that gets multiple times daily. I get the feeling that I'm just not grasping some key concept. Can someone explain why wanting immediate test feedback on the validity of an MVC view is a bad thing? (or if not bad, then not the expected way to get said feedback)


Is "pass by value" synonymous with "functional programming" ?   1. Are there any iterative programming languages that are (largely) "pass by value"?   2. Are there any functional programming languages that are (largely) "pass by reference"? Thanks.


title: How does compiler handle exceptions that are implicit? Looking for design strategies

text: Throughout the function handleException, the exception encountered is implicit. How does the compiler handle such implicit passing of exceptions? [For e.g. in C++ methods, **this** pointer is passed to account for the current object. My question is how does a compiler handle exceptions internally - handleException has no arguments.]                void handleException()      {        try {          throw;        }        catch (MyException& e) {          ...code to handle MyException...        }        catch (YourException& e) {          ...code to handle YourException...        }      }           void f()      {        try {          ...something that might throw...        }        catch (...) {          handleException();        }      }


title: Java Heap Allocation Faster than C++

text: I already posted this question on SO and it did ok. It was unfortunately closed though(only needs one vote to reopen) but someone suggested I post it on here as it is a better fit so the following is literally a copy paste of the question * * * I was reading the comments on this answer and I saw this quote. > Object instantiation and object-oriented features are blazing fast to use > (faster than C++ in many cases) because they're designed in from the > beginning. and Collections are fast. Standard Java beats standard C/C++ in > this area, even for most optimized C code. One user (with really high rep I might add) boldly defended this claim, stating that   1. heap allocation in java is better than C++'s    2. and added this statement defending the collections in java  > And Java collections are fast compared to C++ collections due largely to the > different memory subsystem. So my question is can any of this really be true, and if so why is java's heap allocation so much faster.


title: What popular program is used to develop GUI in C++?

text: I'm asking this question because my creativity can only go so far with console programs in C++. I need to know what program/software the majority of c++ software developers out there use develop GUI in C++. I'm heading into College in a couple weeks and want to major in Computer programming and I really would like that head start. Thanks.


title: Testing for Non Programmers

text: I would like to get my younger brother, who can't program, to test some code I am writing from requirements I provide him in documentation. Is there a way to get him going quickly? Ideas? Please and thank you.


title: What is Zend's relationship with PHP?

text: What exactly is Zend's relationship to PHP? I don't mean the framework but the company itself. Are they the gatekeepers or guardians of sort? I've just been reading up on PHP, and other than requiring knowledge of C to extend it you apparently need to learn the Zend APIs. But when you first start out with PHP you don't need to know anything "Zend", and the same goes for non-Zend frameworks like Cake and CodeIgniter. So I'm confused and curious about when knowing things Zend begins to matter in using PHP.


title: Oracle owns Java but Google is using Java?

text: Ok, I don't get it. What does "Oracle owns Java" mean? Google is definitely using Java in Google App Engine, does that mean that Google have to pay Oracle for doing so?


title: Peer programming and experience sharing

text: There was a mention in the Java Posse Podcast about how teams should be divided up into pairs. However, there was a mention from the lady on the podcast that: "Pairs should be mixed up [sic]" (an encouragement for diversity) I understand the benefits of pair programming, but what benefit is there to intentionally mix people up. To me it would seem that it would be better to take a genetic algorithm like approach to find optimal groups to generate pairs. An example: Let's say you have a tax developer and a front end developer how would either of these guys benefit from the intentional mixing of peer groups? Why did her assertion go unchallenged? (I got the sense that she was advising that it should go cross groups and development tiers)


title: How do I succeed as a lead developer?

text: I have become the lead developer in a particular project, but I'm having difficulty focusing on the big picture and making sure all pieces of the project are covered. What should I keep in mind when managing this project? How can I make sure everything gets handled the way it should?


title: Scrum Daily meeting: Punctuality over Full team presence?

text: My understanding is that a Daily Scrum meeting should be very quick, hosted in a friendly way and that it requires all the team members present. Because it is objective is to have everyone up to date with what everybody else is doing. I like Scrum Daily Meetings that are held like that. In my latest project our Daily Scrums are more like a Status Update meeting. Although the position is that we are holding Scrums and practicing proper Agile. We are a distributed team, in 2 different countries, and the people that is in the same Country are not in the same office. As consequence we have virtual Scrums. The problem is that our meetings always start on time, many people calls before the actual start time, so they actually start at the very first second of the meeting. Without any tolerance for small delays. For example the last time we were on the phone and the person coordinating the meeting checked if everyone was on, and we said one of our team members was not on yet but he was calling. And I was told to start sharing without waiting for my team member. Also everyone has a lot of meetings, and sometimes they are back to back with the Scrum meeting, so it is understandable if they arrive during the first or second minute of the meeting. Is that the normal for teams practicing Daily Scrums? It is the first time that happens to me. I can not find any bibliography directly about it. Although the presence of all team members is stressed, it is stressed also that the meetings should always start at the same time. But I imagine there can be a small delay tolerance. I even read on a blog someone suggesting that the Scrum Master can place penalties if someone arrives "5 seconds" late. I thought the Scrums were supposed to be friendly, and having a penalty like that seems counter productive. What is the recommended approach in a situation like this?


title: How would one start a website with robust and scaleable hosting?

text: This question is about hardware and hosting, and how to "bootstrap" them. If you built a really great website, how could you have it hosted at low cost but so that it reassures customers that their data is safe and available. As an example, what if I have a web application I developed for small companies to use for their accounting, a replacement for Quickbooks. Aside from getting a bunch of money from VCs or Angels, how would you be able to host this so that you could guarantee your customers that their data won't be lost, and the site will always be up so that they can always get to their data?


title: Is Haskell good at teaching fundamentals of mathematics?

text: I'm involved in teaching mathematics to classes with requirements such as AS and A level Mathematics specification. Class books normally provide examples of computer software applied to mathematics tasks, but they are normally based on software applications like mathlab, mathematica or derive. Even when a _real_ programming language is used, it is normally old fashoned language like Pascal. And this is really sad in my opinion. Because, Haskell is famous for his feeling with mathematics, and because I'm interested in it as well, I'd like to ask whether Haskell is a good choice as extension exercise method for students of a first year university class. Typical subjects are functions, caclulus, limits, but also linear algebra for example. I've intermediate knowledge experience in programming (c#, ruby, powershell, javascript, tex) and also have already approached functional programming with XSLT. Answers will be upvoted responsibly. Verbose answers including also some basic examples of Haskell code applied to mathematics, such as linear algebra (e.g. vectorial space), polynomials, solving linear equations are much appreciated and targeted as the wanted one.


title: Dynamically load and call delegates based on source data

text: Assume I have a stream of records that need to have some computation. Records will have a combination of these functions run `Sum`, `Aggregate`, `Sum over the last 90 seconds`, or `ignore`. A data record looks like this:               Date;Data;ID      **Question** Assuming that ID is an `int` of some kind, and that int corresponds to a matrix of some delegates to run, how should I use C# to dynamically build that launch map? I'm sure this idea exists... it is used in Windows Forms which has many delegates/events, most of which will never actually be invoked in a real application. The sample below includes a few delegates I want to run (sum, count, and print) but I don't know how to make the quantity of delegates fire based on the source data. (say print the evens, and sum the odds in this sample)               using System;     using System.Threading;     using System.Collections.Generic;     internal static class TestThreadpool     {              delegate int TestDelegate(int  parameter);              private static void Main()         {             try             {                 // this approach works is void is returned.                 //ThreadPool.QueueUserWorkItem(new WaitCallback(PrintOut), "Hello");                      int c = 0;                 int w = 0;                 ThreadPool.GetMaxThreads(out w, out c);                 bool rrr =ThreadPool.SetMinThreads(w, c);                 Console.WriteLine(rrr);                      // perhaps the above needs time to set up6                 Thread.Sleep(1000);                      DateTime ttt = DateTime.UtcNow;                 TestDelegate d = new TestDelegate(PrintOut);                      List<IAsyncResult> arDict = new List<IAsyncResult>();                      int count = 1000000;                      for (int i = 0; i < count; i++)                 {                     IAsyncResult ar = d.BeginInvoke(i, new AsyncCallback(Callback), d);                     arDict.Add(ar);                 }                      for (int i = 0; i < count; i++)                 {                     int result = d.EndInvoke(arDict[i]);                 }                           // Give the callback time to execute - otherwise the app                 // may terminate before it is called                 //Thread.Sleep(1000);                      var res = DateTime.UtcNow - ttt;                 Console.WriteLine("Main program done----- Total time --> " + res.TotalMilliseconds);             }             catch (Exception e)             {                 Console.WriteLine(e);             }                  Console.ReadKey(true);         }                   static int PrintOut(int parameter)         {             // Console.WriteLine(Thread.CurrentThread.ManagedThreadId + " Delegate PRINTOUT waited and printed this:"+parameter);             var tmp = parameter * parameter;             return tmp;         }              static int Sum(int parameter)         {             Thread.Sleep(5000); // Pretend to do some math... maybe save a summary to disk on a separate thread             return parameter;         }              static int Count(int parameter)         {             Thread.Sleep(5000); // Pretend to do some math... maybe save a summary to disk on a separate thread             return parameter;         }              static void Callback(IAsyncResult ar)         {             TestDelegate d = (TestDelegate)ar.AsyncState;            //Console.WriteLine("Callback is delayed and returned") ;//d.EndInvoke(ar));         }          }


title: Is it a responsibility of the software developer to understand what the customer meant with his request?

text: Kind of a yes / no question and why? **Is it the responsibility of the software developer to understand what the customer meant with his/her request or is it the responsibility of the customer to properly explain his/her request to the developer?** The situation at work is currently "the customer already explained us, what he wants. It's your responsibility to understand the request, not ask more questions". While English is not my strong suite, all the requests are written in obscure English with misplaced words and hard to understand sentences, some requests assume previous understanding of the system on my part. I'm the 3rd or 4th developer of the system (the last developers quit the job) and that might be the reason the customer expects some understanding on the developers side. The system itself is quite messy both in the UI and source code level. This looks like monkey coding to me - code and hope you get the request right, while not actually understanding the request. I'm actually thinking about quitting the job, but haven't yet, given I'm not sure about who's right and who's wrong.


title: When should I use parallelism?

text: After asking this question, I got to realize that parallelism may not always be good. So far I can see that parallelism (under c#) is   * A little complicated code-wise   * Will probably insert some concurrency complications   * Will not always be faster I am looking inside parallelism because I want to make existing and new applications work faster, but now I see that it is no silver bullet. When should I use it? are there any best practices? Is it just a waste of time in most cases? Is it suitable for a specific kind of applications? I am looking forward for your insights on this matter.


title: How can Swift be so much faster than Objective-C in these comparisons?

text: Apple launched its new programming language Swift at WWDC14. In the presentation, they made some performance comparisons between Objective-C and Python. The following is a picture of one of their slides, of a comparison of those three languages performing some complex object sort: ![enter image description here](http://i.stack.imgur.com/wcdXk.jpg) There was an even more incredible graph about a performance comparison using the RC4 encryption algorithm. Obviously this is a marketing talk, and they didn't go into detail on how this was implemented in each. I leaves me wondering though:   1. How can a new programming language be so much faster?    2. Are the Objective-C results caused by a bad compiler or is there something less efficient in Objective-C than Swift?    3. How would you explain a 40% performance increase? I understand that garbage collection/automated reference control might produce some additional overhead, but this much?


title: Why is using 'final' on a class really so bad?

text: I am refactoring a PHP OOP legacy website. I am so tempted to start using 'final' on classes to "`make it explicit that the class is currently not extended by anything`". This might save lots of time if I come to a class and I am wondering if I can rename/delete/modify a `protected` property or method. If I _really_ want to extend a class I can just remove the final keyword to _unlock it_ for extending. I.e If I come to a class that has no child classes I can record that knowledge by marking the class a final. The next time I come to it I would not have to re-search the codebase to see if it has children. Thus saving time during refactorings. It all seems like a sensible time saving idea.... but I have often read that classes should only be made 'final' on rare/special occasions. Have you ever treated `final` liberally and had bad experiences or is this 'fear of final' just a myth. Maybe it screws up Mock object creation or has other side effects that I am not thinking of. What am I missing?


title: Avoid ELSE when setting a variable?

text: Which of these styles do people prefer?               string mystring = "defaultvalue";     if (condition)        mystring = "othervalue";      VS               string mystring = null;     if (condtion)        mystring = "othervalue";     else        mystring = "defaultvalue";      VS               mystring = condition? "othervalue" : "defaultvalue";


title: Interview Questions in OOP

text: I faced the below interview questions in OOP under PHP language. Kindly clear my clarifications regarding this. I am very confused. As i am a beginner to OOP i got too confused. Could anyone clarify these things clearly?   1. **Difference between Abstract class and interface.** Interviewer : Let us consider abstract class contains three abstract methods such as a,b,c and interface contains three methods a,b,c. In this case these do the same functionality. Then why are going for abstract and why are we going for interface. Me : ?   2. **static keyword.** Interviewer: We call static method without creating object by using scope resolution operator in PHP. As well as we can able to call concrete methods also. Then what is need of static keyword there? Me : ....   3. **final keyword.** Interviewer: Give me any scenario of using final keyword. Me : For db connection related method Interviewer: Other than that? Me: ...   4. **Constructor.** Interviewer: What is the use of constructor? Me : There is no need for object to access this. It will call automatically when the class calls. Interviewer: Other than that? Me : .... Thanks in advance...


title: Why Aren't There New Versions of C?

text: While many other languages have rapid development, such as Python, which has come out with a whole new version in the past few years, or to use a framework, Rails, which evolves super-fast (A book that was published in early 2011 is now obsolete), it seems that there are no updates for C. Why is this?


title: Overcoming slow problem solving due to increased knowledge of what might go wrong

text: This has been troubling me for some time, and I'd really appreciate the input of other professionals. Short background: I started programming when my parents bought me my first computer in 1988 (at age 14, I'm 39 now). I followed a couple of other career paths before finally becoming a professional programmer in 1997. Late bloomer, perhaps, but that's how it was. I'm still happy with my choice, I love programming, and I consider myself good at what I do. Lately, I've been noticing that the more experience I gain, the longer it takes me to complete projects, or certain tasks in a project. I'm not going senile yet. It's just that I've seen so many different ways in which things can go wrong. And the potential pitfalls and gotchas that I know about and remember are just getting more and more. Trivial example: it used to be just "okay, write a file here". Now I'm worrying about permissions, locking, concurrency, atomic operations, indirection/frameworks, different file systems, number of files in a directory, predictable temp file names, the quality of randomness in my PRNG, power shortages in the middle of any operation, an understandable API for what I'm doing, proper documentation, etc etc etc. In short, the problems have long since moved from "how do I do this" to "what's the best/safest way of doing it". The upshot is that it takes me longer to finish a project than a novice. My version may be rock solid, and as impenetrable as I know how to make it, but it takes longer. The "create file" example above was just that, an example. Real tasks are obviously more complex, but less suited for a generic question like this one. I hope you understand where I'm going with this. I have no problem coming up with efficient algorithms, I love math, I enjoy complex subjects, I have no difficulties with concentration. I think I do have a problem with experience, and consequently with a fear of errors (intrinsic or extrinsic). I spend almost two hours a day reading up on new developments, new techniques, languages, platforms, security vulnerabilities, and so on. The conundrum is that the more knowledge I gain, the slower I am in completing projects. How do you deal with this?


title: .NET silverlight development tools

text: What tools are necessary when developing efficiently with Silverlight 4? VS 2010 is a gimme, but what version? Is Pro enough? Premium? What about Expression Blend/Web/Both? When considering VS 2010, premium comes with an MSDN subscription but it's at the high end of the budget. It makes sense if Expression comes with it though. It's for a one man development show, making an LOB app that will integrate video/audo and mic/webcam equipment.


title: How does aggregation work when databases are involved?

text: So I'm reading a book on Design Patterns (Design Patterns Explained 2nd Edition), and all throughout the book it says to "favor aggregation over inheritance". I'm trying to wrap my head around trying to design something, and I feel so stupid. So conceptually, I have `Recruiters`. I figured these recruiters can be an abstract class, because I have a couple different types of recruiters... full time and part time. The thing is, I want each recruiter to be able to have references to other recruiters because they might work together and need to share and combine information. Each Recruiter would have one or more `Regions` that they oversee, perhaps sharing it with other Recruiters. All the region is a conceptual aggregate of `SubRegions`. The SubRegions define places that fall along certain geographical boundaries. These contain some numerical statistic information about recruitments for that SubRegion as a whole. The Subregions consist of `Recruitments`, which contains detailed information about particular recruiting events for a SubRegion. They also contain other statistical information that makes sense to be under Recruitments(because they're very specific to the Recruitment), but not under SubRegions. Every time some information from the recruitment is updated, it needs to create a new record of that transaction so I can keep a history of how the numbers are adjusting. Now, I want all of these to be able to be stored in a database. I am very naive when it comes to database design and structuring, especially when it comes to dealing with abstract classes and interfaces which are new to me. Everything in the database is going to be linked in some way, among different tables. Say, the Recruiters are going to be a table, and there is going to be a Region table, a SubRegion table, and a Recruitment table. Where do I need to put the logic, and how do I put it, such that I can make sure I can save everything out to the database, keyed together nicely, but loosely coupled in the code?


title: Is it safe to use CamelCased file names?

text: I'm developing a simple CMS which I'd like to make it open source. For the file structure, do you think it's safe to use names like:               AppData     FileUploads      instead of               app-data     file-uploads      ? Because I heard some servers have problems with the camelCase.


title: If I use multiple third party components, using several different open source licenses, how should I attribute them?

text: I'm developing a Java application that utilizes several third party open source libraries. I'm adding a section to my app's "About" dialog that lists the components and their license notices. For those that use the same license, do I have to repeat the same license text for each one? For example, I use several components that are all released under the Apache 2 license. Do I have to list the Apache 2 license terms for each one, or just say "Foo, Bar, and Baz are used under the terms of the Apache 2 License" and list the actual terms once? Thanks. Just want to do the right thing.


title: In integration testing, do you use the data access objects for setup and validation or a different data access method?

text: When writing integration tests for business logic objects and data access objects, what makes the most sense to use for setup and validation? In my case, I'm using an ORM in the implementation of my data access interface that will be used in production, and I plumb that ORM implementation together with the business logic objects for integration testing. Given that the ORM implementation is tested separately using INSERT and SELECT statements for setup and validation, is it best for integration testing setup and validation to use the ORM implementation of the data access interface, to use the ORM directly, to use those INSERT and SELECT statements, or to do something else, **_edit: and why?_** The ORM in this case is NHibernate, the ORM implementation of the data access interface is a simple pass-through to NHibernate's LINQ provider that also provides simple pagination and sorting mechanisms. I'm curious to know what you think, either generally or with this specific scenario. _**edit:_** I'm not looking to know what DAO I should connect to the BL objects. That _clearly_ should be the same DAO that will be used in production. The question is about the mechanism used to put data into the database to set up the test _before_ the business logic function is tested. Presumably, the same mechanism would be used to poll the database _after_ the business logic function is tested. Here's some very high-level pseudo-code to demonstrate what I mean:               MyIntegrationTest()     {         Foo fooBefore = GenerateFooForTesting();         SomehowInsertIntoDatabase(foo); // What should be used here and why?              // Plumb things together; actually done using IoC, not hard-coded.         DaoFactory realDaoFactory = GetRealDaoFactory();         BizFactory realBizFactory = GetRealBizFactory();         realBizFactory.DaoFactory = realDaoFactory;              BusinessLogicObject biz = realBizFactory.BuildBusinessLogicObject();         biz.DoBusinessWithFooById(fooBefore.Id);              Foo fooAfter = SomehowGetFooFromDatabase(fooBefore.Id); // Same question.              Assert.AreEqual(5, fooAfter.SomethingThatShouldBeFiveAfterBusinessIsDone);     }


title: Language-agnostic libs every programmer should consider learning?

text: Assuming the language provides it, what are some things to do or libs to use that every programmer should know? My list would be   * Regular Expressions   * Named Pipes   * standard IO (std in/out/error)   * Executing outside executables (like imagemagik and your own scripts)   * How to grab an http page as a string (mostly for updates and grabbing configs from servers) I have a similar questions about tools. Also i am looking for specific answers. i dont want answers that can be done in different ways (such as learn how to synchronize threads). I know how to do the above in 3+ languages. There always seems to be things programmers dont know how to do which can make their lives easier. For the longest time i didnt know what regular expression was (although i did hear of it) and I was surprised how many people who tried to make a toolchain or complex app and did not know how to (or that you could) get the stdout from an exe they launched (they checked for errors in a very weird way or just didnt and hope it produce the expected results). What do you think useful, not well known and should be something every senior (or starting out) programmer should know?


title: Can a candidate be judged by asking to write a complex program on "paper"?

text: Sometime back in an interview, I was asked to write following program: * * * _In a keypad of a mobile phone, there is a mapping between number and characters. e.g. 0 & 1 corresponds to nothing; 2 corresponds to 'a','b','c'; 3 corresponds to 'd','e','f'; ...; 9 corresponds to 'w','x','y','z'_. _User should input any number (e.g. 23, 389423, 927348923747293) and I should store all the combinations of these character mapping into some data structure. For example, if user enters "23" then possible character combinations are_ : > ad, ae, af, bd, be, bf, cd, ce, cf _or if user enters, "4676972" then it can be_ , > gmpmwpa, gmpmwpb, ..., hnroxrc, ..., iosozrc * * * Interviewer told that people have written code for this within 20-30 mins!! Also he insisted I have to **write on paper**. If I am writing a code then my tendency is as of I am writing production code, even though it may not be expected from me. So, I always try to think all the aspects like, _optimization, readability, maintainability, extensible_ and so on. Considering all these, I felt that I should be writing on PC and it needs decent 2 hours. Finally after 25 mins, I was able to come up with just the concept and some shattered pieces of code (not to mention of my rejection). My question is not the answer for the above program. I want to know that **is this a right way to judge the caliber of a person** ? Am I wrong / too slow in the estimates ? Am I too idealistic ?


title: How should I handle a redirect to an identity provider during a web api data request

text: # Scenario I have a single-page web app consisting purely of html, css, and javascript. After initial load and during use, it updates various views with data from one or more RESTful apis via ajax calls. The api calls return data in a json format. Each web api may be hosted on independent domains. # Question During the ajax callout, if my authorization token is not deemed valid by the web api, the web api will redirect me (302) to the identity provider for that particular api. Since this is an ajax callout for data and not necessarily for display, i need to find a way to display the identity provider's authentication page. It seems that I should trap that redirect, and open up another view to display the identity provider's login page. Once the oauth series of redirects is complete, i need to grab the token and retrigger my ajax data call with the token attached. Is this a valid approach, and if so are there any examples showing the ajax handling of the redirects?


title: Why do websites restrict the number & choice of characters in a password?

text: Registering on an insurance company's website right now, and my password is 16 characters long, using a nice variety of letters, numbers, special characters, etc. However, here's their list of restrictions: > Note your password: > >   * must be between 6 and 12 characters >   * must not contain spaces, special/international characters >   * must not contain your user name, first name or last name >   * is case-sensitive >   * should contain at least 1 number and 1 letter > I can understand minimum 6 characters, not allowing parts of your name, being case-sensitive, and needing at least 1 number and letter. The part I don't get is restricting your choice of characters you can use, and having an upper bound. Why do websites do this? The only thing I can think of it they don't know the basics of hashing a password, which would secure it better than anything, and get rid of any security concerns. If I choose to type `DELETE FROM users WHERE 1=1` as my password, I should be allowed to. PHP's MD5 hash of it becomes `fe5d54132b51b7d65ab89b739b600b4b` which I don't think will harm anything.


title: How to write good code with new stuff?

text: I always try to write easily readable code that is well structured. I face a particular problem when I am messing around with something new. I keep changing the code, structure and so many other things. In the end, I look at the code and am annoyed at how complicated it became when I was trying to do something so simple. Once I've completed something, I refactor it heavily so that it's cleaner. This occurs after completion most of the time and it is annoying because the bigger the code the more annoying it is the rewrite it. I am curious to know how people deal with such agony, especially on big projects shared between many people ?


title: How do you cope with change in open source frameworks that you use for your projects?

text: It may be a personal quirk of mine, but I like keeping code in living projects up to date - including the libraries/frameworks that they use. Part of it is that I believe a web app is more secure if it is fully patched and up to date. Part of it is just a touch of obsessive compulsiveness on my part. Over the past seven months, we have done a major rewrite of our software. We dropped the Xaraya framework, which was slow and essentially dead as a product, and converted to Cake PHP. (We chose Cake because it gave us the chance to do a very rapid rewrite of our software, and enough of a performance boost over Xaraya to make it worth our while.) We implemented unit testing with SimpleTest, and followed all the file and database naming conventions, etc. Cake is now being updated to 2.0. And, there doesn't seem to be a viable migration path for an upgrade. The naming conventions for files have radically changed, and they dropped SimpleTest in favor of PHPUnit. This is pretty much going to force us to stay on the 1.3 branch because, unless there is some sort of conversion tool, it's not going to be possible to update Cake and then gradually improve our legacy code to reap the benefits of the new Cake framework. So, as usual, we are going to end up with an old framework in our Subversion repository and just patch it ourselves as needed. And this is what gets me every time. So many open source products don't make it easy enough to keep projects based on them up to date. When the devs start playing with a new shiny toy, a few critical patches will be done to older branches, but most of their focus is going to be on the new code base. How do you deal with radical changes in the open source projects that you use? And, if you are developing an open source product, do you keep upgrade paths in mind when you develop new versions?


title: Type of AI to tackle this problem?

text: I posted this on stackoverflow but want to get your recommendations as well as a user on overflow recommended I post it here. I'm going to say from the beginning that I am not a programmer, I have a cursory knowledge of different types of AI and am just a businessman building a web app. Anyways, the web app I am investing in to develop is for a hobby of mine. There are many part manufacturers, product manufacturers, upgrade and addon manufacturers etc. for hardware/products in this hobby's industry. Currently, I am in the process of building a crowd sourced platform for people who are knowledgeable to go in and mark up compatibility between those parts as its not always clear cut if they are for example: Manufacturer A makes a "A" class product, and manufacturer B makes upgrade/part that generally goes with class "A" products, but is for one reason or another not compatible with Manufacturer A's particular "A" class product. However, a good chunk (>60%-70%) of the products/parts in the database can have their compatibility inferenced by their properties, For example: Part 1 is type "A" with "X" mm receiver and part 2 is also Type "A" with "X" mm interface and thus the two parts are compatible.. or Part 1 is a 8mm gear, thus all bushings of 8mm from any manufacturer is compatible with part 1. Further more, all gears can only have compatibility relationships in the database with bushing and gear boxes, but there can be no meaningful compatibility between a gear and a rail, or receiver since those parts don't interface. Now what I want is an AI to be able to learn from the decisions of the crowdsourced platform community and be able to inference compatibility for new parts/products based on their tagged attributes, what type of part they are etc. What would be the best form of AI to tackle this? I was thinking a Expert System, but explicitly engineering all of the knowledge rules would be daunting because of the complex relations between literally tens of thousands of parts, hundreds of part types and many manufacturers. Would a ANN (neural network) be ideal to learn from the many inputs/decisions of the crowdsource platform users? Any help/input is much appreciated.


title: How to better integrate a unix development environment into Windows

text: I'm mostly a Windows user but I do most of my development (essentially web development) using unix tools and software. I've been going back and forth between using a dedicated lubuntu virtual machine on Virtualbox and using some tools directly in windows (msgit, python, django), but none of these approaches is entirely satisfactory. I'd like to hear of ways other devs use to better integrate a unix workflow into windows. For instance tighter integration between a linux and vm and windows. The vagrant demo showed how a VM could work off of a windows project folder and I found that nice. I'd like to hear of other tools and tips that would help mimic the workflow one can find on OS X (of course I understand that it cannot be as tightly integrated on Windows as it doesn't have the same unix underpinnings). PS: I have tried cygwin as well EDIT for clarifications about What I find lacking (thanks to axblount for pointing that out) : unix tools like msys et al do not work as well as their native unic counterparts. Many scripts, installers require further configuration or do not work at all. For instance getting virtualenvwrapper to work is not very straightforward. virtualbox: ideally I would like to use windows software (photoshop, sublime text 2) seamlessly with linux. I mostly use a FTP client atm to move over files edited on the windows side which is a tedious process. **SUMMARY:** It seems there are no established solutions. As a temporary solution I will probably try to use the native versions of frameworks and libraries through the windows command line when possible and switch to a tool like vagrant for incompatible programs. **MORE INFO FROM REPLIES AND COMMENTS:** The case-sensitivy issue seems to work against windows as pointed out by @GlenPeterson


title: Why does the US government disallow dynamic languages for secure projects?

text: I know some people that are currently working on a project for the US military (low security level, non-combat human resources type data). An initial state of the project code was submitted to the military for review, and they ran the program through some sort of security analyzer tool. It returned a report of known security issues in the code and required changes that needed to be implemented before delivery of the final product. One of the items that needed to be resolved was removal of part of the project that was written in Ruby as it is a dynamic language. What is the background/reason for not allowing a dynamic language to be used in a secure setting? Is this the government being slow to adopt new technologies? Or do dynamic languages pose an additional security risk compared to static languages (ala C++ or Java)?


title: How do I output an error when I'm determining how to output an error?

text: I've written an API which can be configured to signal errors in different ways (return values, debugging messages, or exceptions). I've got a check in place when the API is first initialized to see what type of error handling the client is requesting - what should I do when they request an undefined error handling type? This is kind of similar to "Where do I log the error that I can't write to the logfile?" Do I go with the idiom of the language, do I fatal? Do I throw an exception, even though if they aren't asking for exception handling they probably haven't wrapped the call in a try/catch? The language I'm writing doesn't have an ENUM type so it can't be a type error.


title: Reason for (post/pre) increment operator in Java or C#

text: Recently, I've stumbled across question about predicting the output of code which heavily uses post/pre increment operators on integers. I am experienced C programmer, so I felt like at home, but people made statements that Java just blindly copied that from C (or C++), and that this is an useless feature in Java. That being said, I am not able to find good reason for that (especially with keeping in mind the difference betwen post/pre forms) in Java (or C#), because it's not like you will manipulate arrays and use them as strings in Java. Also, it was long ago when I last looked into bytecode, so I don't know if there's a `INC` operation, but I don't see any reason why this               for(int i = 0; i < n; i += 1)      could be less effective than               for(int i = 0; i < n; i++)      Is there any particular part of the language where this is really useful, or is this just a feature to bring C programmers in town?


title: is there a way to leave notificationManager and alarmManger alive even when the app is closed?

text: how would you recommend for me to design an android app where i want it to 1) send location update every 10 minutes 2) to show push notification I want both actions be available even when the app is closed. Here i might ask for your explanation what "closed" states an app can be in? a) removed from recent tasks stack - close the whole process including its services ? b) forces closed - close the whole process including its services ? c) other? I was using 1) alarm manager that sends a pending intent to a broadcast receiver. 2) notification manager I have tried to register all manager using ApplicationContext instead of Current-Activity context. Now both actions work even after user remove the app from the "recent tasks" stack. but I'm not sure about the "closed" states so I might be missing something.


title: Software Licence Agreement: Does our spec abide by the licence

text: Can you determine if this Open Source Winforms UI Library licence allows companies to use this code in a commercial software application? > The MIT License (MIT) > > Copyright (c) 2011 Sven Walter, http://github.com/viperneo > > **Permission is hereby granted** , free of charge, to any person obtaining a > copy of this software and associated documentation files (the "Software"), > **to deal in the Software without restriction** , including without > limitation the rights to use, copy, modify, merge, publish, distribute, > sublicense, **and/or sell copies of the Software** , and to permit persons > to whom the Software is furnished to do so, **subject to the following > conditions** : > > The above copyright notice and this permission notice shall be included in > all copies or substantial portions of the Software. > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS > IN THE SOFTWARE. Licence can be found here I can see that it gives permission to use the code in commercial products but it is subject to conditions. We intend to use the UI (a Windows 8 looking interface) in a simple application that will convert Civil Engineering survey files from one format to another which maybe sold commercially in the future. Those in the know, do our intentions fall within the lines of the license rules?


title: Model-View-Controller: Does the user interact with the View or with the Controller?

text: I have recently learned about the MVC design pattern. I'm learning from the Head First Design Pattern book. According to this book (if I understand correctly): **The Model** is most of the application logic and data. **The View** is basically the GUI that represents the Model visually to the user. **The Controller** is responsible to 'mediate', and act as a 'middleman' between the View and the Model. The View reports to the Controller that the user made an action, and the Controller translates it to method calls on the Model. **However, a lot of places on the web contradict what I understand from that book. They claim that generally the user interacts with the Controller, not the View.** Which one is true or more common? Does the user interact with the Controller directly, or with the View directly? Are both approaches acceptable? Which is more common?


title: What is the best way to exchange files via authenticated web service?

text: I'm not so much looking for code (although if you want to link to tutorials it would be appreciated) as I am trying to get an idea of what people in the know are doing. Our system is written in PHP. As part of an Electronic Medical Record System, I need to be able to **securely** exchange documents (Word, PDF, etc.) with business partners. I also need to transmit identifying information with the documents (patient name, medical record number, etc.) If I Google exchanging files in a web service, I am given a bunch of information about a variety of methods. But, what's not easy to see is how old the information is, how commonly the methods are used, and if there is something out there that if I just knew what I was looking for, would blow my socks off. TLDR - If you were going to use a web service to exchange files, and your system was written in PHP, how would you go about doing it, and why?


title: I want to sell my software along with it's source code. Is there a licence restricts anything but in-house changes?

text: Is there a license that:   * Allows the client to make in-house changes to the tool/source code if need be.   * Prohibits to redistribute the source code outside the company.   * Prohibits to sell derivative work or services. Basically prohibits anything, but to make customizations for personal use- case.


title: Is it okay to user other open source libraries when building your own or should that be avoided?

text: Seems like an odd question, but I've been questioning this myself for some time now.   I've been told that, if you're working on a open source library/project, you should avoid adding dependencies for other external, open sourced, libraries because that'll make the software, that uses your libraries, become heavier with all the dependencies, inside dependencies, etc... But sometimes I'm a little on the fence about that. Do I really need to reinvent the wheel just to keep my library away from external dependencies?   For example, I'm currently building an `Objective-C` project that will be open sourced on Github and I need to use a `XML` parser to get data from — you guessed it — XML files. Apple's OS X already has a built-in API for `XML` parsing, but I'm not very fond of the way it works, it needs a lot of background processing and workarounds to get the data I really need, so I was thinking about using another `XML` parser to do a much cleaner job in terms of making my life easier, as the developer, but also by making the code a lot more legible for other developers.      What are your thoughts on this? Thank you.


title: Event system architecture for networking when performance is concerned

text: How should I design a system for an action game (think in Golden Axe) where events can happen remotely? I'm using TCP for this because the client is in flash. There's so many options, I can make a binary protocol (I don't like this idea, I found it to be too hard to mantain) but I was also thinking that passing jsons through clients and server can be slow (Is that a exaggerated concern?). What about the internal architecture for the server? And for the client? I'm really lost, If it's a question that is too big, please indicate me some material so I can formulate a better question next time.


What is the difference of delegator and dispatcher? I am not quite sure of either concept.


title: How do existential types differ from interfaces?

text: Given the existential type               T = ∃X.{op₁:X, op₂:X→boolean}      and this generic Java interface:               interface T<X> {         X op₁();         boolean op₂(X something);     }      What are the fundamental differences between the existential type and the Java interface? Obviously there are syntactical differences, and Java's object-orientation (which also includes details such as hidden `this` parameters etc.). I'm not so much interested in these as in conceptual and semantic differences — though if someone would like to shed light on some finer points (such as the notational difference between `T` vs. `T<X>`), that would be appreciated too.


title: Unique and primary keys on a database (mysql)

text: I'm having quite some doubts here... If I have a table related to **username/password login** how can I assure there won't be any more matches of the **same username and password in the same table** using sql? For example:               >username: username     >password: password      ^this user just signed up. So the following conditions apply: > **1º there can't be any more users named "username"** > > 2º most surely there can't be any more users named "username" **AND with the > same password** so how exactly should I put the keynames in the database? The id is primary, should I put **username AND password** as **_unique_** to form an unique pair and avoid another identical insertion?


title: Would this be a correct way to use the Repository pattern in ASP .NET MVC application implementing Entity Framework?

text: This ASP .NET MVC application implements Entity Framework. I've declared the repositories in the DbContext like this:               public class CompanyDbContext : DbContext     {             // constructor goes here                  public DbSet<Customer> Customers { get; set; }             public DbSet<Order> Orders { get; set; }             public DbSet<CustomerOrder> CustomerOrders { get; set; }                  private IGeneralEntityRepository<Customer> customersRepository;             private IGeneralEntityRepository<Order> ordersRepository;                  // ...................     }      This way we can declare and initialise CompanyDbContext within a controller and then access the repositories using the CompanyDbContext instance. Is this correct? Or should I create a separate "Unit Of Work" class to access the repositories?


title: Are there any languages that allow the static context of a method call to be available at runtime?

text: Is it possible for a method to know the type of the method it is called under? So for example in the following object orientated psuedo code:               Instance io = new InstanceSubclass();     io.doStuff();      Is there a language that allows `doStuff()` to know that it was called as an `Instance`? The question arose out of the fact the Java does not provide any kind of support for interface name clashes, for example if you create a class that implements interfaces A and B that both have a method signature such as `void doWork()` would it be possible for the body of `doWork()` to do something similar to the following :               public void doWork() {         Class<?> context = getMethodCallContext();         if(context == InterfaceA.class) {             doAsInterfaceA();         }         else if(context == InterfaceB.class) {             doAsInterfaceB();         }         else {             // Shenanigans and error handling         }     }      I am not planning to write any code that takes advantage of this feature as to do so reeks of an anti-pattern waiting to happen, I only want to know if it CAN be done, if so which languages permit it?


title: Why does Rails do config in code?

text: According to the Pragmatic Programmers, code should be for abstractions, while configuration and details should live in metadata. Rails seems to diverge dramatically from this pattern. Much config is done in code files such as `application.rb`, `routes.rb` and the various `environment.rb` files, while other types of config is done in yaml files (e.g. `database.yml`). What is the thinking behind this design decision?


title: If a variable containing a function gave the function's return instead of a reference to the function, what would an array of functions return?

text: I'm creating a prototype scripting language similar to something like Javascript. In my language, every single reference to a variable is actually a function call (a getter function), whether it has parentheses or not. So for example, if do this:               var foo = 3;     var bar = foo;      What really happens is foo.set() is called on the first line, which creates a new getter function. In the second line, the newly created getter function for foo is called, which looks like this:               foo.get()     {         return 3;     }      I can also assign a function to a variable, in which case that function BECOMES the getter function.               var foo =      {         return 4+5;     }     var bar = foo; // bar is now equal to the number 9, NOT the function that foo contains      So what I'm working on now is what an array of functions should return. For example:               function func1     {         return 1;     }     function func2     {         return 2;     }          var foo = new array();     foo.push(func1);     foo.push(func2);          var bar = foo; //what does bar contain? [func1, func2] or [1, 2]?      A reference to a single function runs that function and gives the return of the function. So I'm trying to decide if a reference to an array of functions should also run those functions, or if it would be more advantageous to just return the array of functions. In other words, would the getter function for foo look like this:               foo.get()     {         return [func1.reference, func2.reference]; //would return [func1, func2]     }      Or like this:               foo.get()     {         return [func1(), func2()]; //would return [1, 2]     }      Specifically, I'm asking if anyone knows if there are problems or solutions that one method or the other would create? Are there any established rules of good programming language design that apply here?


title: What constitutes "commercial purposes"?

text: I'm looking at this license. It says that I can use it for "non-commercial purposes". What does that mean? I see in Stack Exchange, under Network Profile there is that graph that tracks your points across your Stack Exchange accounts. It uses a control called HighCharts which have a paid and Creative Commons licensed version. So would Stack Overflow constitute a commercial site? We don't pay to use this site, but obviously the site makes money from ads, etc. Then again, there's a lot of sites that have ads who won't necessarily make a profit, it may only be subsiding their costs. But even then, you could argue that even if it is only subsiding their costs, a lot of IT companies run at a loss in order to build a big enough customer base. So where is the line here? Is it any website on the internet? Is it any website that has ads? Is it any website that turns over a profit?


title: Does language endorsement by different platforms (Android, iOS) hurt app development?

text: Developing iOS or OSX based applications typically requires knowledge of Objective C, since XCode is highly tailored to this language. Android, on the other hand, has chosen Java as it's preferred language for app development. Now, I know other programming languages can be used to develop applications on either platform, but lets be honest, it's a lot easier (and encouraged) to develop apps using these "native languages." As a new app developer, it seems like it would be much easier if there was a common language and development environment for developing applications on all the major platforms. This thought is probably too idealistic for a programming discussion, and I wouldn't be surprised if the SE vultures flew in to close this topic. But, here's my question. Do you think that language endorsement creates unreasonable barriers to entry for new programmers, or do you think it's beneficial in some way (if so, why) for these platforms to use completely different development environments and languages for app development?


title: How to learn elegantly handling mistakes?

text: One of the things I've noticed as a junior developer is that the people I respect and admire the most are those that can own up to their mistakes and clearly/logically come up with a great way to resolve them. Frankly, I aspire to have that skill - but I don't already have it. With this in mind - what are some of the things you do when you make a mistake? How do you communicate with your manager or user base and do you have any particular points to make the process of resolving the issue go easier for all involved?


title: How does the Scrum Master participate in Daily Stand-Ups?

text: We have a professional Scrum Master consultant [*] who recently joined our project. Unfortunately, we don't know her name (she never introduced herself to us, she just came in one day and said "we are having a daily stand-up"), and she doesn't seem to do much else except chair a daily stand up meeting - when I half-jokingly asked her to also give daily feedback in the meeting, she was quite affronted, saying it's the Scrum Master's job to "facilitate, not participate". This seems fairly anti-Agile (having worked on other agile projects, where the teams were self directed), which is supposed to be egalitarian, but I am not sure about how it works in the Scrum Methodology. I suspect she doesn't do much all day, and that's the reason for her defensiveness on this issue. Does the Scrum Master take part in the "yesterday, today, impediments" spiel during the stand-up meeting, or is their role to just chair ("facilitate") the meeting? [*] We weren't actually told what her job is, we just assume, since she calls herself the Scrum Master


title: How to minimize the data loss when laying off a programmer?

text: I was just laid off and it was the standard process that is used in the US: call the person to talk to personnel, and remove access to the network while that is going on, then have someone help pack, always have someone with the person until they are escorted from the property. That is supposed to keep an unhappy developer from deleting or damaging software or data: to mimimize data loss. However, it still results in a lot of data loss, as all of the work the programmer was working on is dropped: software not checked in is possibly lost, documents not finished are lost, releases in process are slowed down or stopped, and a huge amount of knowledge could be lost. It seems the potential data loss is more than offset by the actual data loss. How can all losses, both potential and actual, be mimimized?


title: Is there already a "Binder" data-structure?

text: I was thinking of a data structure that I cannot describe better than with the word "book", or more exactly "binder". I was wondering if this had already been implemented in libraries like Boost or others. ### Principle It's a data structure that allows constant-time random access and amortized constant time insertion/deletion (as long as the sequence of those are performed on indexes not too far away from each other). It consists of two stacks "left" and "right" representing the state of a binder that would be open on a particular page. Inserting and deleting elements near this page is pretty fast since it consists in pushing/popping the pages to/from the left stack, and flipping some pages if necessary. Of course in the worst case one would have to flip from the first page to the last page (fill one stack with the other), for example if the user inserts something at the beginning and then something at the end. Here is a very rudimentary implementation in C++:               #include <iostream>     #include <vector>          using namespace std;          template<class T>     class Book {              vector<T> left, right;          public:              inline size_t size()         {             return left.size() + right.size();         }              void push(T t)         {             insert(size(),t);         }              T& get(size_t i)         {             if (i < left.size())                  return left[i];             else return right[right.size()-i+left.size()-1];         }              void insert(size_t i, T t)         {             reposition(i-1);             left.push_back(t);         }              void remove(size_t i)         {             reposition(i);             left.pop_back();         }          protected:              void reposition(size_t i)             // puts the element at position i on the top of the left stack         {             while (i < left.size()-1)             {                 right.push_back(left.back());                 left.pop_back();             }             while (right.size() >= size()-i)             {                 left.push_back(right.back());                 right.pop_back();             }         }          };          int main()     {         Book<int> b;         for (int i = 0; i < 15; i++)             b.push(i);              b.insert(5,42);         b.remove(10);              int i = 0;         while (i < b.size())         {             if (b.get(i)%2 != 0)                  b.remove(i);             else i++;         }              for (int i = 0; i < b.size(); i++)         {             cout << b.get(i) << " ";         }         cout << endl;         return 0;     }      Note: A possible nice optimizations would be to have the two stacks in reverse order, to allow a memcpy of the whole portion to be moved from on stack to the other instead of moving elements one by one (memcpy is usually much faster). ### Use So a good use case of this DS would be an algorithm that runs through a sequence of elements and can, for each index, add new elements or remove old elements near this index. A particular case of this is filtering an array of elements. All you need to do is to iterate over all the indexes and simply call binder.remove(i) if the element at index i is to be removed. An efficient (and optimal) way to do it, given an array of elements, would usually be to allocate another array of the same size, and copy only the elements that we want to save. It is easy to see that this does the same amount of operations than our Binder implementation (if it starts on the first page), the main difference being that Binder allows a simpler algorithm hiding the dirty details of implementation. (And we don't end up with a different object.) Things get even messier to implement when we need to handle deletion of close elements or a mix of deletion and addition, while with the Binder DS it is all encapsulated and the algorithm stays very simple. So the Binder DS can be seen as an array (or "vector" in the sense of C++) which allows efficiently working on its content by including a working buffer, so one never has to allocate extra space by hand (so it helps reduce dynamic memory allocations). It makes the whole mutation processes transparent. ### Conclusion I haven't time-tested it against more conventional algorithms, but I expect it would be a little slower in element access than a plain vector because of the higher complexity of having two buffers instead of one. Do you think this is a good idea of a data structure, and it would prove efficient? Has it already been done, and in which library? Do you have a better alternative to propose?


title: OOP and Data Structures in C++?

text: Is it a must to study Object Oriented Programming before going into Data Structures in the C++ language or can I begin with lists, stacks ,queues,sorting ......etc and does Object Oriented Programming have a relation with data structures?


title: Best practice in setting return value (use else or?)

text: Whenever you want to return a value from a method, but whatever you return depends on some other value, you typically use branching:               int calculateSomething() {       if (a == b) {         return x;       } else {         return y;       }     }      Another way to write this is:               int calculateSomething() {       if (a == b) {         return x;       }       return y;     }      Is there any reason to avoid one or the other? Both allow adding "else if"-clauses without problems. Both typically generate compiler errors if you add anything at the bottom. Note: I couldn't find any duplicates, although multiple questions exist about whether the accompanying curly braces should be on their own line. So let's not get into that.


title: Is possible to create and download a video file via JavaScript, only on the client side?

text: Is possible to create and download a video file only on the client side? Suppose that we have an animated canvas like in this **JSFIDDLE**. Please see this snippet:               ...     var stop = false;     setTimeout(function () {         stop = true;     }, 1860);     ...     if (!stop) { requestAnimationFrame( draw, 10 ); }      So, my animation duration is `1860ms`. We can generate text files for download, I know that we can generate images from canvas, but is possible to render and download a video file? Would adding sound possible?


title: Finding next free IP in a network

text: I have an IP network and want to automatically find a free IP address to provision a new server. Due to frequent server additions/removals the used IPs might be quite fragmented over the whole address space. To effectively check if an IP is free I have to ping and ask the DNS system, which is considered expensive. So I want to minimise these lookups and store some information about used/free addresses in a relational database. This should give me good candidates and I only have to do a few such lookups. The question is how to do so in a most simple and efficient way that SQL can handle? One first idea was to generate all possible addresses and store them in the database. Used ones just get the use column set to true. Then just make a SQL query that returns like the first 10 addresses where the use value is false. Looks fairly simple to get a new address. But this approach could become a problem for big networks. Also I have to generate and remove unused addresses for every network change. If I only store the used addresses I don't see how to make a query that returns me free addresses. I have to retrieve the whole list and implement the logic on the client. But I was hoping I could off-load that to the database server. Are there any better alternatives? Scan for free addresses regularly and only store a few ones? Sort the list of used addresses, maybe in a tree like structure where the non-leafs hold some information about free addresses in their child segment? These solutions seem rather complicated to me. I would prefer a simple algorithm without any extra running scanners/generators, and then in the worst case I have to fall back to some other method. Is there anything SQL can provide me with? Like give me the smallest free element in a sorted list of integers? Cheers.


title: should this code be structured into an event capture and a method or put the functionality in the event capturing

text: I have adopted some jQuery code that has like 20 event-captures that look like this                 // used on menu#edit       $('.show-headers-only-toggle').on('click',function(){         arc_eh.menu_edit.show_headers_only_toggle.call(this);       });      that call a method that does the functionality. This is the only place that this method is called. I want to put the functionality after the event like this since I think there's no reason to have this other method. The argument for having it in a method is that I'm polluting this space and the event handling is like a router and this is a controller. I feel like this is bikeshedding and we're not using a framework so it's just simpler to have all in place. Who do you feel is wrong in this? I feel they are bikeshedding this.                 // used on menu#edit       $('.show-headers-only-toggle').on('click',function(){         var action=$(this).attr('arc-action');         // this would just be what is in the function above         if(action=='hide-items'){           $('.menu-item-admin').hide();           $(this).text('show items');           $(this).attr('arc-action','show-items');         }else{           $(this).text('show headers only');           $('.menu-item-admin').show();           $(this).attr('arc-action','hide-items');         }       });


title: Database design - Store state or compute state every time?

text: Let's say I have a relational database application and a "user" object and a "message" object. Now I want to show the number of unread messages to this user. What's the best way to archive this? Do I introduce a field in the user and count it up if the user receives a message and decrease the count if he reads one? Or do I execute a query every time to compute the number of messages for the user that are flagged as unread? I think the first approach is more complicated and error prone, but will perform better than the second approach. How is this normally done or what's the better approach?


title: Enumerators vs. returning

text: I've been reading over the Enumerable module in Ruby, and it contains a few methods that follow the pattern of               enum.foo(n) {|obj| block } → nil     enum.foo(n) → an_enumerator      Which is to say, they seem to return an iterator when chained and nothing otherwise. What's the reasoning behind taking this approach instead of just returning a sequence? (I'm asking about general reasoning for this approach, not necessarily just its use in Ruby)


title: Where do I begin when dealing with my first corporate client?

text: I recently developed a desktop client that automates much of the work involved during online research. I developed this tool in 2-3 hours, and it has reduced an hour's worth of work to about 5 minutes. The softwas has had some visibility, and some higher-ups in the organization are excited about the time and effort it's saving. Now, it s that the company is interested in distributing the software to every salesperson in the company, perhaps wanting to even buy it from me. I've never been in the situation of potentially selling my software to a corporate client. I've only worked on personal projects or developed in-house software for my employer. I have no idea what a fair price is, or even what a fair model for payment is (e.g., is it normal to accept a bulk payment in exchange for delivery of a static software application, or to sign a contract to further develop and maintain that application over a period of time, or what?). I just don't have the experience that would give me a basis for knowing how to approach this situation. How I can get this knowledge so as to make informed choices moving forward?


title: Code documentation: Public vs. Non-Public?

text: I'm one of those developers that has the mindset that the code written should be self-explanatory and read like a book. HOWEVER, when developing library code for other people to use I try to put as much documentation in the header files as possible; which brings up the question: Is documenting methods that are non-Public even worth the time? They won't be using them directly, in fact, they can't. At the same time if I distribute the raw code (albeit, reluctantly) those non-Public methods will be visible and may need explaining. Just looking for some standards and practices that you all see or use in your travels.