Configuration file for an API - should it be web.config?

I have a remote procedure call API where the connection parameters need to be stored somewhere that the API code can access. This API is expected to be used mainly to create web services. I originally planed to store these parameters in a separate xml file, and require users of the API to define the path to that file in code. A coworker has suggested that I should find a way to store these parameters in the web.config file instead. Without a lot of WCF experience, I am under the impression that the web.config file should not be used here, because it contains many settings necessary for a web service or web app to function. I don't want my API to mess with that file. I feel it is too risky. What is your opinion on this? Is web.config an appropriate place for storing settings for my API, or should it be left alone?


How i may develop in php and html?

I am learning php from the internet on codeacademy.com. I have also learned html and css but the problem that i dont know how can i build a complete website then ! I study everything on its side. But how to put all my knowledge together its very hard! like when should i use this php code? When should i use the html code? So that i can make a full website.


static languages or dynamic languages?

What is the exact border between the static and dynamic languages? I mean I am told the following parameters are the deciding factors:   1. Compilation or interpretation   2. Typing   3. Runtime generation   4. Dynamic evaluation But when I see these parameters, I can find most of them (upto a major extent) in static languages too like late binding of C++, reflection in Java and C#, void or Object types etc. My question is,   * with so much of dynamicness in these static languages, is it necessary to actually learn the dynamic languages?    * I know C++, Java and C#. On the other hand, I know PHP and Javascript. My teacher recommends me to learn more dynamic languages like Python and Ruby. Is it really necessary to do so?    * What is the commercial preference between these languages? Thank you.


How does a programmer used to static languages cope with lack of Javascript tooling

I have programmed pretty much exclusively in compiled languages, particularly Java, for most of my career. One of my favourite things about Java is how productive you can be, and how little code you actually have to write, when using tools like Eclipse. You can:   * Easily and automatically refactor your methods and classes   * View instantly all the places where a method is invoked, or a constant is used (Open Call Hierarchy/Show References)   * Static typing means you can use code completion to show all the parameters/functions available on an object   * Control-click on a function/member/class name to go straight to its definition All these facilities make me feel like the IDE is my best friend. Writing Java code and particularly understanding other peoples' programs becomes far easier. However, I am being called on more and more to use Javascript, and my experience so far has been quite negative. In particular:   * No immediate way of finding a function's entry point (other than a plain text search, which may then result in a subsequent searches for methods further up the call hierarchy, after two or three of which you've forgotten where you started)   * Parameters are passed in to functions, with no way of knowing what properties and functions are available on that parameter (other than actually running the program, navigating to the point at which the function is called, and using console.logs to output all the properties available)   * Common usage of anonymous functions as callbacks, which frequently leads to a spaghetti of confusing code paths, that you can't navigate around quickly.   * And sure, JSLint catches some errors before runtime, but even that's not as handy as having red wavy lines under your code directly in the browser. The upshot is that you pretty much need to have the entire program in your head at all times. This massively increases the cognitive load for writing complex programs. And all this extra stuff to worry about leaves less room in my brain for actual creativity and problem solving. Sure, it's faster to just throw an object together rather than write an entire formal class definition. But while programs may be slightly easier and quicker to write, in my experience they are far harder to read and debug. My question is, how do other programmers cope with these issues? Javascript is clearly growing in popularity, and the blogs I read are about how productive people are being with it, rather than desperately trying to find solutions to these issues. GWT allows you to write code for a Javascript environment in Java instead, but doesn't seem to be as widely used as I would expect; people actually seem to prefer Javascript for complex programs. What am I missing?


Why does a monad use "return" or "unit" rather than "lift"?

This is partly genuine curiosity, and partly a check on my understanding. I'm probably missing the point. In Haskell, why does a monad use operations called `return` or `unit` to describe putting a type into the container -- lifting it into the monadic space? It seems more intuitive to call the operation `lift`. Right now, in my (probably incorrect) port of monads into my own project, I'm using (pseudocode): > MyThing. **lift** (x).bind(f)... rather than > MyThing. **unit** (x).bind(f)... because it's more intuitive for me to think of lifting x into the monadic space. Is that wrong-headed? I keep getting burned by not thinking abstractly enough, and I suspect that's the case again.


Let users get requirements together on their own or guide them along?

I'm sure everyone has experienced something like this. You go into a meeting with a client who has a project. They have no/few requirements in mind and the vaguest understanding of what they want/need. At this point, there seem to be two options: 1) Tell the users, "Ok, so I can't build something for you if you cannot even describe it yet. Why don't we get back together in a few weeks when you know what you want". 2) Meet with the users a few times and help them figure out what they want by guiding them through with the good ole Socratic method. "Do you need to track X?", "How about Y?", "Do you need functionality Z?" With the first option, you don't get stuck doing someone else's job, or having gain psychic powers, however, the users might never present you with a coherent specification, or they might take forever as the deadline continues to approach. With the second option, you waste a bunch of time becoming a business analyst, and have to cram a bunch of business knowledge into your head that you will probably never use again, but you will be much more likely to come out with a spec that makes any sense. To me, this is one of the most challenging aspects of development, and I have a feeling I'm not alone in this sentiment. In your experience, which of these options tends to work better?


Absolute statements in IT that are wrong

I was recently in a discussion about the absolute statement "It costs more in programming time to optimise software than it costs to throw hardware at a problem". The general thought (of which I agree with) is that as an absolute statement this is wrong. There are too many variables to ever generalise in such a way. **What other statements do you hear about software/programming that simply do not work as an absolute and why?**


How does the contribution part of "contributing to an open source project" take place?

Note: this question is about the general case... How things usually are. OK so I can download the code and mess around with it, but how do my changes make it into the project officially? Who decides what changes make it into the project, and how? Is there often a list of required changes/additions? What if I have a cool idea that is not mentioned there? How do I get it approved? And what if two people implement the same feature. Who chooses which implementation makes it into the project? Basically, how is the whole thing managed (in the general case)?


Employee vs Contractor mentality and career

I'm trying to work something out which isn't quite covered in any of the other "contractor vs employee" threads. In a nutshell: Is there a natural (possibly even hard-wired and inborn) tendency for people to be meant for one or the other? A bit of background: I suffered a serious burnout over the past couple of years and am taking a sabbatical this year to think things over. With all the reflection I'm coming to the conclusion more and more that I'm just not cut out for the permanent, salaried kind of life. Essentially, I think I just don't have the "employee mentality". No matter how good a job is, I just seem to have some visceral, deep-seated need to move around and not be tied down to the same scenery. I'm great in the first year or two when things are fresh, but after that, it just starts to feel really boring and obnoxious to be stuck in the same routine, looking at the same code base, etc, no matter how good the job seems on paper. Most people seem to get into a groove where the stability compensates for any "contempt of familiarity" or boredom, but for me it's almost the opposite. This answer to one of my other questions (broadly related to this subject) really got my attention: it feels like I could basically be what they call a "hunter" type, a kind of "slow motion ADHD" case. I'm great at focusing on things I'm really interested in, and I'm not afraid of working hard. But it has to come packaged with a beginning, progression and end - on a short to midterm time frame. The typical salaried environment, which in software development generally means open-ended "maintenance mode", very quickly does my head in, after the first year or two in a new job. I start losing motivation and focus, and eventually slide into burnout. So basically what I'm asking is - do you think this farmer versus hunter theory is real? Not necessarily in a formal clinical psychiatric sense, but just from your subjective experiences? I'd especially like to hear from contractors, or people who have done both. Are you doing it simply because the opportunity is good, and you could do the same job permanently everything else being the same. Or do you have this feeling/mentality like me - that being tied down in the same scenery would drain your soul? **Related question** : Do people generally stick with one or the other? Or do they do both? It seems to me that most people are either employees or contractors/consultants for most of their careers, and that an overlap who do both at will is quite small. I can't find any data to back this up, it's just an impression I've got - and I find it very curious - because it seems to lend support for this idea that people just naturally/viscerally seem to have tendencies to shine in one or the other "model" of working. **EDIT** : Thanks for the responses. I think it's quite true that what burns me out is an underlying feeling of dissatisfaction with working for someone else in a typical "command and control" business environment. All the jobs I've ever had were permanent gigs which basically fit that pattern - developers treated like factory workers (some places worse than others, but always essentially true) - eg. doing what you're told without much autonomy or self-actualizing purpose. That said, I think I'll still look into doing contracting to see how it works for me compared with permanent gigs. It's probably not perfect, but I think the independence would at least keep things interesting - it took a long time in the _same_ rut before it got to this point where I burned out and became too dysfunctional to work at all. Constant lateral movement may at least keep it under control.


best practices for solving Object Oriented design questions during technical interviews

after getting a Object Oriented design question during technical interview - for example, design a car rental program - what would be the general steps (a.k.a best practices) that the interviewee should follow to solve the problem? what would be the possible pitfalls?


Working with windows Functions for Recovering Shift+Delete files

I am making software for recovering Shift+Delete files from Windows. I know when files are deleted only links to them are cut off by Windows but the actual file remains there at the same place, so recovering them would require myself to search hard-drive or specifically a particular drive. I installed the code on an old computer with Windows Millennium Edition and works. How can I make it workable for Windows 7?? Are there any API's or references for this that will be helpful?


Using PDO for Data Management

This question is more a design oriented question than a code specific question. I am new to PHP and I am planning to use PDO as a data access layer. Say for instance I have a class called CITY. Now if I need to create an instance of this class, what is the best technique.   * Should have a singleton DB access class which is used to write and read data from the db layer.    * OR should I delegate it to the individual class object. For example if I invoke city.save() (city is a class), then the city class will handle the saving of that city object's data into the database.  Excuse my ignorance but i have a java background and therefore trying to understand what is the best design principle for data management when using php.


Max number of items mapped to same location in hashmap

I have a question about hashmaps. If you have this hashmap with m slots, and need to map n items to it, and n > m. There will be collisions for sure. But assuming there is simple uniform hashing assumption, this means that the maximum amount of collisions in any spot is the load factor right? The load factor is n/m. But the load factor is probably going to be a decimal, does this mean its a ceiling of the n/m? So if n=6 and m=5, then load factor is 1.2, and the ceiling is 2, so that means the maximum collisions in one spot is 2. Is this right?


Script to check minimum requirements for an application

Is there a well-known, trusted open source script that we could use as a starting point to build a web-based analyser tool for our application that would be similar in functionality to the Firefox check add-ons tool? For example, check against a specified version of Java, screen resolution, browser versions, etc. Thanks, Kerrin


Which framework should I learn if I want to do web development in Java? Any advice?

Well, I don't have a strong background in programming. I know C, C++, some C#, some vb, and some basic java and SQL, that's it. I don't have any work experience in web development, so just consider me as a completely new starter. I would like to do web development, and I hope I can easily find a job in web development after I finish my current academic program. So I have started with asp.net MVC framework. But, at least it seems to me that many positions require java programming in web development, so I decide to learn java at the same time while learning .net. Well, there are a lot of frameworks out there. A friend of mine suggests Hibernate, some people say that play framework is good for small applications, whereas some guys recommend spring, which seems to be a very difficult one. I want to start with a framework which is relatively easy to pick up and popular in job market. So what should I start with? And aside from a framework, what else should I learn? Besides, which one is more popular in terms of web programming, .net or Java? It seems that java is required by most employers, and I haven't found many positions indicating .net experience. Which of the two is actually more popular, and what about the trend in the future?


Am I wasting my time building eCommerce website?

I see a lot of companies such has ekmpowershop, volusion, eshops, prostores and so on that give customers power to build and customise their website (in detail). On the other hand I see companies such as RedTechnology (http://www.redtechnology.com/) that build eCommerce applications for customers. I had a look at How to decide between using an existing eCommerce solution and building your own? as well. Also you have big companies such as Amazon, NextPlc, that will never use the above service. I would like to be self-employed in perhaps developing eCommerce applications, but I am a little reluctant as I see some comments "As with most Stack Exchange sites shopping recommendations are considered to be off topic as they become out of date so quickly". Also I am unsure of the amount of competition out there. So would I be wasting my time building eCommerce application for customers? As I believe this will cost more from the customer's point of view and time constraint. In turn customers will be more favourable to the companies such as ekmpowershop, volusion, eshops and prostores? Finally going back to ekmpowershop, volusion, eshops and prostores. How would one build those kind of applications? I am from .NET side.


What makes C so popular in the age of OOP?

I code a lot in both C and C++, but did not expect C to be the second most popular language, slightly behind Java. TIOBE Programming Community Index I'm curious as to why, in this age of OOP, C is still so popular? Note that 4 out of the top 5 popular programming languages are "modern", object-oriented capable languages. Now, I agree that you can use OOP in C to some extent, but it's sort of painful and inelegant (well at least compared to C++ I guess). So, what makes C so popular? Is it efficiency; being low-level; the vast majority of libraries that already exist or something else?


When designing a protocol, is it better for a method to accept a single object of a specific type, or an array?

I'm currently designing a protocol for internal use, so it doesn't make a huge difference in this particular case, but it got me wondering: Is it better for a method to accept a single object of a specific type, or an array of objects, with the documentation specifying the type it will contain? Obviously the array allows for greater flexibility in calling the method, but specifying a type gives the programmer greater clarity as to what the method will be doing. For example, my protocol has a single method (so far), called recieveDroppedItems:. It needs to accept either one or multiple NSURLs, which point at the files dropped on the sender. Thanks in advance for any advice you have! :D


What is sequential code execution?

I have been looking around on the internet and have not found a good answer yet. If anyone could be so kind and supply a code sample I would greatly appreciate it. I apologize for the simplicity of the question.


Examples of continuous integration workflow using git

Can anyone provide a rough outline of their git workflow that complies with continuous integration.   E.g. How do you branch? Do you fast forward commits to the master branch? I am primarily working with Rails as well as client and server side Javascript. If anyone can recommend a solid CI technology that's compatible with those, that'd be great. I've looked into Jenkins but would like to check out other good alternatives. To put some context into this, I am planning on transitioning from working as a single developer into working as part of the team. I'd like to start standardizing my own personal workflow so that I can onboard new devs quickly.


Are there studies about foo/bar/baz and how they inhibit or facilitate comprehension?

**Preface** `foo`,`bar`,`baz` are instantly recognizable signifiers of example or pseudo code. Their popularity seems to be a strong indication that the programming community accepts them as a good way to indicate the author is showcasing a non-specific implementation of code. As this q+a reveals they are classified as metasyntactic variables. While the history of these words seems to be rooted in over 50+ years of usage I can't find any resources studying their effectiveness. **Question** Rather than take it a face value that their ubiquity is evidence for the effectiveness I'm wondering if there is **evidence** about the impact on linguistic comprehension. To clarify, I know that `foo` is understood as signifying pseudo-code, but I'm referring to comprehension _of_ what the pseudo-code means. **Why** I have re-read the FAQ many times and before I get accused of being chatty I'm not trying to elicit a discussion, I'm not looking for personal anecdotes, I'm asking a question that is relevant to the programming community at large though it's on the edge of our concerns. I realize that there may be not anything published in this area but in case there is it'd be helpful to know in either case.


As a software developer, have you ever published an academic paper?

My university only recognizes academic papers as valid intellectual achievements. I would like to get a sense of how many Software Architect's, Software Engineer, Software Developers and/or programmers bother to publish their findings. Or as programmer do you feel your production should have academic merit as well? (oops!) I guess this is two questions.


What are some good Software Engineering books for people who didn't formally study Computer Science or Software Engineering?

I'm a graduate in the electronic & telecommunication field, but working in a software company. I want to continue in this field and going for Masters in it. Can you recommend me some of the best books on software engineering, which cover almost all the topics in software engineering. I am not looking for books about coding practices such as Code Complete, Pragmatic Programmer, but rather general software engineering references.


What's wrong performing unit test against concrete implementation if your frameworks are not going to change?

First a bit of background: We are re-architecting our product suite that was written 10 years ago and served its purpose. One thing that we cannot change is the database schema as we have 500+ client base using this system. Our db schema has over 150+ tables. We have decided on using Entity Framework 4.1 as DAL and still evaluating various frameworks for storing our business logic. I am investigation to bring unit testing into the mix but I also confused as to how far I need to go with setting up a full blown TDD environment. One aspect of setting up unit testing is by getting into implementing Repository, unit of work and mocking frameworks etc. This mean there will be cost and investment on the code-bloat associated with all these frameworks. I understand some of this could be auto-generated but when it comes to things like behaviors, that will be mostly hand written. Just to be clear, I am not questioning the important of unit testing your code. I am just not sure we need all its components (like repository, mocking etc.) when we are fairly certain of storage mechanism/framework (SQL Server/Entity Framework). All that code bloat with generic repositories make sense when you need a generic layers with ability to change this whenever you like however its very likely a YAGNI in our case. What we need is more of integration testing where we can unit- test our code with concrete repository objects and test data in database. In this scenario, just running integration test seem to be more beneficial in our case. Any thoughts if I am missing any thing here?


Alternative way of developing for ASP.NET to WebForms - Any problems with this?

So I have been developing in ASP.NET WebForms for some time now but often get annoyed with all the overhead (like ViewState and all the JavaScript it generates), and the way WebForms takes over a lot of the HTML generation. Sometimes I just want full control over the markup and produce efficient HTML of my own so I have been experimenting with what I like to call **HtmlForms**. Essentially this is using ASP.NET WebForms but without the form `runat="server"` tag. Without this tag, ASP.NET does not seem to add anything to the page at all. From some basic tests it seems that it runs well and you still have the ability to use code-behind pages, and many ASP.NET controls such as repeaters. Of course without the form `runat="server"` many controls won't work. A post at Enterprise Software Development lists the controls that do require the tag. From that list you will see that all of the form elements like TextBoxes, DropDownLists, RadioButtons, etc cannot be used. Instead you use normal HTML form controls. But how do you access these HTML controls from the code behind? Retrieving values on post back is easy, you just use `Request.QueryString` or `Request.Form`. But passing data to the control could be a little messy. Do you use a ASP.NET Literal control in the value field or do you use `<%= value %>` in the markup page? I found it best to add `runat="server"` to my HTML controls and then you can access the control in your code-behind like this: `((HtmlInputText)txtName).Value = "blah"`; Here's a example that shows what you can do with a textbox and drop down list: **Default.aspx**               <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="NoForm.Default" %>     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">                       <title></title>                   <form action="" method="post">             Name:             <input id="txtName" name="txtName" runat="server" />
             State:             <select id="ddlState" name="ddlState" runat="server">                 <option value=""></option>             </select>
             <input type="submit" value="Submit" />         </form>                **Default.aspx.cs**               using System;     using System.Web.UI.HtmlControls;     using System.Web.UI.WebControls;     namespace NoForm     {         public partial class Default : System.Web.UI.Page         {             protected void Page_Load(object sender, EventArgs e)             {                 //Default values                 string name = string.Empty;                 string state = string.Empty;                 if (Request.RequestType == "POST")                 {                     //If form submitted (post back)                     name = Request.Form["txtName"];                     state = Request.Form["ddlState"];                     //Server side form validation would go here                     //and actions to process form and redirect                 }                 ((HtmlInputText)txtName).Value = name;                 ((HtmlSelect)ddlState).Items.Add(new ListItem("ACT"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("NSW"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("NT"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("QLD"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("SA"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("TAS"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("VIC"));                 ((HtmlSelect)ddlState).Items.Add(new ListItem("WA"));                 if (((HtmlSelect)ddlState).Items.FindByValue(state) != null)                     ((HtmlSelect)ddlState).Value = state;             }         }     }      As you can see, you have similar functionality to ASP.NET server controls but more control over the final markup, and less overhead like ViewState and all the JavaScript ASP.NET adds. Interestingly you can also use HttpPostedFile to handle file uploads using your own input type="file" control (and necessary form enctype="multipart/form-data"). So my question is can you see any problems with this method, and any thoughts on it's usefulness? I have further details and tests on my blog.


Confusion related to sigwait in multiprocess system

I am having difficulty in understanding IPC in multiprocess system. I have this system where there are three child processes that send two types of signals to their process group. There are four types of signal handling processes responsible for a particular type of signal. There is this monitoring process which waits for both the signals and then processes accordingly. When I run this program for a while, the monitoring process doesn't seem to pick up the signal as well as the signal handling process. I could see in the log that the signal is only being generated but not handled at all. My code is given below               #include <cstdlib>     #include <iostream>     #include <iomanip>     #include <unistd.h>     #include <sys/types.h>     #include <sys/wait.h>     #include <sys/time.h>     #include <signal.h>     #include <unistd.h>     #include <fcntl.h>     #include <cstdio>     #include <stdlib.h>     #include <stdio.h>     #include <pthread.h>          using namespace std;          double timestamp() {       struct timeval tp;       gettimeofday(&tp, NULL);       return (double)tp.tv_sec + tp.tv_usec / 1000000.;     }          double getinterval() {        srand(time(NULL));       int r = rand()%10 + 1;       double s = (double)r/100;     }          int count;     int count_1;     int count_2;     double time_1[10];     double time_2[10];               pid_t senders[1];     pid_t handlers[4];     pid_t reporter;          void catcher(int sig) {       printf("Signal catcher called for %d",sig);     }          int main(int argc, char *argv[]) {            void signal_catcher_int(int);            pid_t pid,w;       int status;            if(signal(SIGUSR1, SIG_IGN) == SIG_ERR) {         perror("1");         return 1;       }            if(signal(SIGUSR2 ,SIG_IGN) == SIG_ERR) {         perror("2");         return 2;       }            if(signal(SIGINT,signal_catcher_int) == SIG_ERR) {         perror("3");         return 2;       }            //Registering the signal handler       for(int i=0; i<4; i++) {         if((pid = fork()) == 0) {           cout << i << endl;           //struct sigaction sigact;           sigset_t sigset;           int sig;           int result = 0;                sigemptyset(&sigset);                if(i%2 == 0) {                  if(signal(SIGUSR2, SIG_IGN) == SIG_ERR) {               perror("2");               return 2;             }                  sigaddset(&sigset, SIGUSR1);             sigprocmask(SIG_BLOCK, &sigset, NULL);           } else {                 if(signal(SIGUSR1, SIG_IGN) == SIG_ERR) {               perror("2");               return 2;             }                  sigaddset(&sigset, SIGUSR2);             sigprocmask(SIG_BLOCK, &sigset, NULL);           }                while(true) {             int result = sigwait(&sigset, &sig);             if(result == 0) {               cout << "The caught signal is " << sig << endl;             }           }           exit(0);              } else {           cout << "Registerd the handler " << pid << endl;           handlers[i] = pid;         }       }            //Registering the monitoring process       if((pid = fork()) == 0) {         sigset_t sigset;         int sig;         int result = 0;              sigemptyset(&sigset);         sigaddset(&sigset, SIGUSR1);         sigaddset(&sigset, SIGUSR2);              sigprocmask(SIG_BLOCK, &sigset, NULL);              while(true) {           int result = sigwait(&sigset, &sig);           if(result == 0) {             cout << "The monitored signal is " << sig << endl;           } else {             cout << "error" << endl;           }          }            } else {         reporter = pid;       }                 sleep(3);       //Registering the signal generator       for(int i=0; i<1; i++) {         if((pid = fork()) == 0) {                if(signal(SIGUSR1, SIG_IGN) == SIG_ERR) {             perror("1");             return 1;           }                if(signal(SIGUSR2, SIG_IGN) == SIG_ERR) {             perror("2");             return 2;           }           srand(time(0));           while(true) {             volatile int signal_id = rand()%2 + 1;             cout << "Generating the signal " << signal_id << endl;             if(signal_id == 1) {               killpg(getpgid(getpid()), SIGUSR1);             } else {                   killpg(getpgid(getpid()), SIGUSR2);             }                  int r = rand()%10 + 1;             double s = (double)r/100;               sleep(s);           }                exit(0);          } else {           cout << "Registered the sender " << pid << endl;           senders[i] = pid;              }             }                 while(w = wait(&status)) {         cout << "Wait on PID " << w << endl;       }          }                    void signal_catcher_int(int the_sig) {       //cout << "Handling the Ctrl C signal " << endl;       for(int i=0; i<1; i++) {         kill(senders[i],SIGKILL);       }            for(int i=0; i<4; i++) {         kill(handlers[i],SIGKILL);       }            kill(reporter,SIGKILL);            exit(3);     }      Any suggestions? Here is a sample of the output as well In the beginning               Registerd the handler 9544     Registerd the handler 9545     1     Registerd the handler 9546     Registerd the handler 9547     2     3     0     Registered the sender 9550     Generating the signal 1     The caught signal is 10     The monitored signal is 10     The caught signal is 10     Generating the signal 1     The caught signal is 10     The monitored signal is 10     The caught signal is 10     Generating the signal 1     The caught signal is 10     The monitored signal is 10     The caught signal is 10     Generating the signal 1     The caught signal is 10     The monitored signal is 10     The caught signal is 10     Generating the signal 2     The caught signal is 12     The caught signal is 12     The monitored signal is 12     Generating the signal 2     Generating the signal 2     The caught signal is 12     The caught signal is 12     Generating the signal 1     The caught signal is 12     The monitored signal is 10     The monitored signal is 12     Generating the signal 1     Generating the signal 2     The caught signal is 12     Generating the signal 1     Generating the signal 2     10     The monitored signal is 10     The caught signal is 12     Generating the signal 1     The caught signal is 12     The monitored signal is GenThe caught signal is TheThe caught signal is 10     Generating the signal 2      Later on               The monitored signal is GenThe monitored signal is 10     Generating the signal 1     Generating the signal 2     The caught signal is 10     The caught signal is 10     The caught signal is 10     The caught signal is 12     Generating the signal 1     Generating the signal 2     Generating the signal 1     Generating the signal 1     Generating the signal 2     Generating the signal 2     Generating the signal 2     Generating the signal 2     Generating the signal 2     Generating the signal 1     The caught signal is 12     The caught signal is 10     The caught signal is 10     Generating the signal 2     Generating the signal 1     Generating the signal 1     Generating the signal 2     Generating the signal 1     Generating the signal 2     Generating the signal 2     Generating the signal 2     Generating the signal 1     Generating the signal 2     Generating the signal 1     Generating the signal 2     Generating the signal 2     The caught signal is 10     Generating the signal 2     Generating the signal 1     Generating the signal 1      As you can see initially, the signal was generated and handled both by my signal handlers and monitoring processes. But later on the signal was generated a lot, but it was not quite processes in the same magnitude as before. Further I could see very less signal processing by the monitoring process Can anyone please provide some insights. What's going on?


Inner workings of the IF() function - why aren't expressions evaluated?

# Short version How does the **`IF()`** function cause the passed expressions to NOT be evaluated prior to being passed in as parameters? # Detailed version I am part of a standards committee, and a discussion was initiated which, in general, is trying to **ban** the use of the **`IIF()`** function. The general consensus is that if you want to do a short line-length assignment **`IF()`** is okay. And if you for some reason want to evaluate two expressions, don't try to accomplish that all on one line, explicitly and purposefully evaluate the expressions on seperate lines, then do an **`IF()`** call with the results in the **`If True`** and **`If Else`** parameters. I'm asserting that before a **`Function(param1, expression)`** is stepped into, any expressions are evaluated. Then, their evaluated value is passed as a parameter. That being asserted, this makes sense:               Sub Main()         Dim intTest As Integer = 0         Dim blnResult As Boolean = IIf(2 = 2, Integer.TryParse("3", intTest), Integer.TryParse("4", intTest))         'intTest = 4     End Sub        * As expected, **`blnResult`** is **`True`**.   * Because the conditional of the **`IIF()`** function is **`True`** , the value of the expression in the **`"If True"`** parameter is the resulting assignment.   * But **BOTH** the **`If True` AND `If Else`** expressions were evaluated (in written order) prior to even stepping into the **`IIF()`** function, so **`intTest`** became **`4`**.   * As far as I'm concerned, that is programatically expected, but not the results desired. On the reverse side of the coin, we have this:               Sub Main()         Dim intTest As Integer = 0         Dim blnResult As Boolean = If(2 = 2, Integer.TryParse("3", intTest), Integer.TryParse("4", intTest))         'intTest = 3     End Sub      As the inverse of the previous issue, we now have:   * As expected, **`blnResult`** is True.   * Because the conditional of the **`IF()`** function is **`True`** , the value of the expression in the **`"If True"`** parameter is the resulting assignment.   * But **ONLY** the **`If True`** (in this case) is evaluated, so **`intTest`** became **`3`**.   * As far as I'm concerned, that is the results desired, but not programatically expected. I'd like to see a custom function that does the same thing as **`IF()`**.


Strategy for normalising and interpreting location data

I'm a bit stuck with a problem involving the normalisation of location input data from the user (which comes from a third party). ## Aim To logically breakdown and interpret the user location input field and understand if it is listing single or multiple locations, from one or more countries. * * * ## The Problem The type of data that I am receiving from the user input is messy and has no logical structure or consistency as show below. Daily geocodes are limited from google, so I have to use them sparingly. I want to efficiently process the location input from the user and send the correct geocoding query to google to get the right result. * * * ## Data Sources Data is irrational and irregular and could be supplied in some of the following formats:               London, UK                              Alternative format     England, London                         Reversed order     London                                  Generic location                 London Sheffield, Newcastle             Three separate locations in the same country without consistent commas     London, Sales, Sales Assistant          Non location content inserted     London [NOT SPECIFIED]                  Other non location content inserted with non alphabet chars not separate with commas     London, Washington, Brazil, England     Mix of unrelated locations, including cities and countries     Washington, London, Kent                Mix of places within a single country         * * * ## Proposed Solution **Step 1: Breakdown data**   * Put each separated word in an array **Step 2: Sanitize data**   * Strip out invalid chars, commas, additional spaces etc   * Strip out any words against a stoplist.txt (like job, sales, in, at, etc) **Step 3: Deterimine if valid location**   * See if each individual array item has been geocoded before, if not, geocode and store   * Log any words which have been geocoded with no result – add these into the stoplist file to avoid pointless geocodes **Step 4: Interlink values**   * Compare if a places coordinate value falls within the range of another array item. If it does, we know they are parents and we treat them as a single item   * London + England -> London coordinates falls within the co-ordinate range of England so we know it is a single location, not two separate ones. * * * ## Issues **Issue 1: Kent, London, Sussex** Technically, there is a Kent in the USA, and it is the first one that comes up when you type it into google maps. However since all the results are in England it is extremely unlikely that the result we want is the USA one **Issue 2: England, Washington, New York** There is a Washington in England, but this doesnt seem likely to be the one in England * * * ## Question Is my proposed solution of breaking the words down into separate entities and relinking them the most logical solution? Any help or advice would be much appreciated, I know it's not any easy problem.


Is this a good use case?

I've been studying object oriented analysis and, so to get started with this in practice I've decided to first of all build my own management system to have my customers data and so on. Trying to gather requirements for the first time and write use cases for the first time led me to some doubts. I want to ask here about some doubts regarding the use cases. One of the requirements I've thought of was "manage customers". From this requirement I've obtained some use cases:   1. Register new legal person as customer;   2. Register new natural person as customer;   3. Update and correct customer data;   4. Remove a customer from the system;   5. Read customer's summary; Now, I'm greatly in doubt about all of this. First, is this right: take one single requirement and from it derive many different use cases? Or should be just _one_ use case "Manage Customers" containing everything? Second, I'll give an example about what I did. I choose to start by the first one. So I wrote the following use case: **Title:** Register new legal person as customer; **Actor:** User; **Scenario:** The user chooses to register a new company as customer. The user informs the company data and the system validates the data informed. The user is then prompted to inform the data of the responsible for the company and the system validates the data informed. The user is then taken to the list of all legal person customers. Now, I'm pretty sure I'm not doing this right. First, this seems to simple, it's just like if we said "well, the user goes and register the data". Second, all of the others use cases would be exactly like that, so I can't see how this is going to help me out. Third, from this use case I could obtain just three possible objects "legal person customer" and "responsible for the company", so I really think this is not enough. Also, usually there are many requirements like that "manage customers", "manage employees" or "manage suppliers" and it seems at first tha they will always be like that. Is this correct? Those kind of requirements always end up with this kind of uses cases that are simple like this? Am I doing this right? Is there something wrong with the uses cases I've figured out and the way I wrote that particular use case? How do we work with this kind of use cases that are so simple that the scenario is almost like just stating again the objective of the use case? I know there are many questions there, but any kind of help is appreciated. I'm starting now to work with this kind of thing and I'm unsure if I'm doing things right. Thanks very much in advance!


Should I be wary of signing a non-disclosure agreement with someone I just met?

**1/22/12 update** in case you were puzzled as to why I haven't accepted an answer: Pretty much all of the answers make the obvious point that working for him would have been silly, but none of them seemed to answer the question. **tl;dr** : Some guy I just met says he wants me to join his company. Before he shows me what they do, he wants me to sign a non-disclosure agreement. Is this weird? I'm traveling right now. Someone who saw me coding seemed to think I was smart or something and started talking with me. He explained that he owns a software company, told me a bit about what it does and told me that he was looking for a programmer who would work for a stake in the company. He explained that the company's product is being developed rather secretly, so he couldn't tell me much. But he did tell enough about the product to convince me that he's not completely making this up, which is a decent baseline. He suggested that he show me more of what he's been working on and, after seeing that, I decide whether I want to join. Because of the secrecy behind the product, he wants me to sign a non-disclosure agreement before we talk. I'm obviously somewhat skeptical because of the random nature by which we met. In the short term, I'm wondering if I should be wary of signing such an agreement. He said it would be easier to show me the product in person rather than over the internet, and I'm leaving town tomorrow, so I'd have to figure this out by tomorrow. If I decide to talk with him, I could decide later whether I trust that it's worth spending any time on this company. The concept of being able to avoid telling a secret seems strange to me for the same reason that things like certain aspects of copyright seem strange. Should I be wary of signing a non-disclosure agreement? Is this common practice? I don't know the details of the agreement of which he was thinking, (If I end up meeting with him, I'll of course read over the agreement before I decide whether to sign it.) so I could consider alternatives according to the aspects of the agreement. Or I could just consider the case of an especially harsh agreement. This question seems vaguely related. Do we need a non-disclosure agreement (NDA)? Thanks


How safe it is to do minor JVM upgrades?

I have been working on the JVM for years and I have very rarely experienced a JVM crash ... that is until approx 6 months ago. Since that I have experienced approximately 5 JVM crashes resulting from 2 JVM defects. The solution from Oracle was always the same ... upgrade. Each upgrade is always to and from a point release ... i.e. and Oracle's latest suggestion (after confirming that they did fix the bug) was to upgrade from 1.6u20 to 1.6u26. How concerned should I be upgrading minor versions of the JVM? Is this a big event that necessitates enormous amount of regression testing or are they safe upgrades that should be embraced?


How to keep Free/Paid version of the app separate in subversion

I have a paid application on the android marketplace, however, I want to release a free ad-supported version. The easiest way I thought to do this was to set up a branch on my subversion repository that has the additional code to add the ads. However, when I went to submit this to the android marketplace, they require unique package names. This solution no longer works for me because I'd have to change the package of every class file, which would make merging the trunk and branch very painful. What is the best way I can keep these two projects together, sharing patches, but with a different package?


How to introduce Scrum in a company accustomed to Scrumbutt or Scrumfall?

A colleague of mine works as a consultant. He is recently asked to help a software development company to improve their processes. The company is aware of some of the issues, like the number of bugs or the fact that they can't release their lead product more often than once per year, but nobody there knows what to do. My colleague identified that they have a primitive in-house process which they call Scrum, but which isn't. My colleague wants to suggest moving to “the real Scrum”. If he does that, he will encounter two issues:   * Managers will reply that they already use Agile, and that it wasn't helpful.   * It would be particularly tricky¹ to explain both to the managers and to the CEO of the company that it was not the real Scrum which was used until now, but rather a mix between Scrumfall and Scrumbutt. What to do? * * * ¹ In this company, two of the three managers claim they know perfectly well Agile and Scrum and apply it flawlessly to their respective teams. Claiming that they know nothing about any of those two subjects would create a hard to handle situation. My colleague's role is also not only to give his opinion, but to apply the “good” methodology for the next three months within this company. Starting by claiming that managers are incompetent in this context is not a solution.


How to perform code review of visual code?

Lately, I've been writing code in SAS Enterprise Guide, which produces "code" that looks like this (screenshot from the linked page): ![SAS Enterprise Guide screenshot](http://i.stack.imgur.com/Vozla.jpg) My question is twofold:   1. Do you think it's necessary to perform code review on this type of code? My gut feeling is **yes** , given that (1) it's still code, just visually laid out, and (2) errors = big problems.   2. If "yes" to above, how to perform the review? Are there standards for visual code? I'm really open to any ideas, comments, and suggestions here. Thanks!


What is an effective way to convert a shared memory-mapped system to another data access model?

I have a code base that is designed around shared memory. Each process that needs to access the memory maps it into its own address space. The data structures in the shared memory are directly accessed, that is, there is no API. For example: Assume the following:               typedef struct {       int x;       int y;       struct {         int a;         int b;       } z;     } myStruct;          myStruct s;      Then a process might access this structure as:               myStruct *s = mapGlobalMem();      And use it as:               int tmpX = s->x;      The majority of the information in the global structure is configuration information that is set once and read many times. I would like to store this information in a database and develop an API to access the database. The problem is, these references are sprinkled throughout the code. I need a way to parse the code and identify global structure references that will need to be refactored. I've looked into using ANTLR to create a parser that will identify references to a small set of structures and enter them into a custom symbol table. I could then use this symbol table to identify which source files need to be refactored. It looks like a promising approach. What other approaches are there? Of course, I'm looking for a programmatic approach. There are far too many source files to examine each one visually. This is all ordinary ANSI C. Nothing else.


Parallel programming library? (+ some features)

**Note** : this is a reposting as the question has been considered non- suitable for the Stack Overflow forum and should have been posted here. The original topic is there. I'd like to talk of multithreading, parallelism and the libraries available today to achieve that work. I'm especially wondering whether an easy-to-use library to achieve this concept (given below) already exists, or whether it would have to be written, and how hard it would be. **The purposes of the library** I'm looking for:   * accessible to most developers, not only to engineers or highly graduated persons (this should mean developers WANT to use it, not being afraid of it)   * available to C++ developers    * portable (start with Windows, Mac OS X and Linux, then extend to mobile devices)    * lightweight    * easy-to-use (related to accessibility)  **The most important features** I'm looking for:   * task parallelism    * task cancellation (in a soft and abrupt manner)    * task dependencies  **The existing related libraries** :   * **Thread Building Blocks** : really complicated to use, and rather restrictive licence (GPL / commercial), it's the only library that I've found and that includes all of the features I'm looking for    * **Grand Central Dispatch** : currently not portable, not too complicated, no task cancellation (once started), no task dependencies, no automatic dependency support (only manual)    * **PFunc** : Unix only, still a bit complicated, no task dependency, no task cancellation    * **Microsoft Task Parallel Library** : MS platform and .NET only, no hard cancellation, restricted and manual task dependencies (one task cannot wake up more than one other task)    * **OpenCL** : not currently available on all platforms, not much more that an GPU parallel task library (not as high level as I would wish)    * **OpenMP** : widely supported except free versions of Visual Studio, no task cancellation nor automatic task dependencies  So what are your thoughts about all of these? Why do you think there are so few libraries corresponding to these needs? Or did I miss some great library? And do you think it would mean too much work to achieve one? Or not interesting enough? Note that the lacks I wrote are those I found out with some searches, I'm not a expert in any of these libraries. The final purpose of this library, even if it's rather a dream, would be programming in a parallelized way as easily as you usually do with sequential programming. Ceylo


Is there really such a thing as "push"?

Once you escape the realm of electrical signals and are dealing with software, is there really such a thing as a "push" architecture where there isn't periodic polling? I can't think of any design where it's not polling at _some_ level. It seems like it's always just a level or two beneath the actual abstraction/API you are dealing with. Sockets at the receiving end of most "push" connections just poll for incoming requests, etc.


Are buffer overflows no longer a threat these days?

After following buffer overflow examples and reading on them in various books/websites it seems there are lots of preventative measures in place to protect against them these days. ASLR, /GS flag security cookie, stack- protector in linux, etc, etc... Some of the examples I have looked at give instructions on how to disable certain security features so that the examples will run...This seems like a really stupid idea to me - when running code against a real system you are not going to have the luxury of disabling its security features. So what is the deal with buffer overflows these days, have them been rendered redundant by advances in security or are they still of use?


What is understood under "unit" in unit testing

As I understand in theory under "unit" people mean method (in OOP). But in practice tests which verify some method in isolation are very fragile behaviour tests (verifying not the result but the fact that some dependency method was called). So I see a lot of people who by unit understand a small set of closely related classes. In this case only outer dependencies are mocked/stubbed and for dependencies which are inside unit real implementations are used. In this case there are more state, meaningful (according to specification) and not so fragile tests. So the question is how do you feel about these approaches and is it valid to call the second approach unit testing or may be it is some kind of low-level integration testing? If you see some specific considerations about applying TDD by one of these ways of testing, I would be thankful for your thoughts.


Why job postings always looking for "rockstars?"

I have noticed a recent trend in requesting programmers who are _rockstars_. I get it, they're looking for someone who is really good at what they do. But why (pray) make the reference to a rockstar? Do these companies really want these traits as a real rockstar?   * Party all night and wake up to take care of quick business in the morning?   * Substance abuse,   * Narcissism with celebrity,   * Compensation well exceeding their management,   * Excellent at putting on a short-lived show,   * Entertainment instead of value,   * 1 hit (project) wonders or single-genre performers,   * Et cetera What is wrong with _Senior_ or _Principal_ Software Engineer who has an established and proven passion for the business? Rather do we mean quite the opposite, someone who:   * rolls up the sleeves and gets to work,   * takes appropriate direction and helps influence teams,   * programs in lessons' learned and proper practices,   * provides timely communication to the whole team,   * can code and understand multiple languages,   * understands the science and theory behind computation, Is there a trend to diversify the software engineering ranks? **How many software rockstars can you hire before your band starts breaking up?** Sure, there are lots of folks doing this stuff on their own, maybe even a rare few who do coding for show, but I wager the majority is for business. I don't see ads for rockstar accountants, or rockstar machinists, or rockstart CFOs. What makes the software programmer and their hiring departments lean towards this kind of job title?


Am I allowed to create closed-source software with open-source code?

I was using a popular music package (Ableton Live) when I opened the legal section of the helpfile and saw that the program contained code licenses that appeared to be both free as in freedom and free as in beer. I cannot find an online copy, alas, but if necessary I can list the licensed packages. As far as I can see there are 3 possibilities here:   1. A fairly large company is violating code licensing - highly unlikely, if that were so why would they include the license text?   2. It's actually legit for some reason to charge money for and close source of a package that contains opensource code - this is news to me, definitely.   3. I am misunderstanding something - highly probable.


How to run an applet like a desktop application without installing entire JDK?

I want to make a desktop application- an analog-clock with the option of setting alarms using java. For rendering all the graphics and the button features, a Swing applet is the answer. But the problem is that I want to run the applet onto the desktop and so need an applet viewer like thing. Applet viewer comes with the JDK and I think installing entire JDK on a system for running just a simple alarm clock is really not a good idea at all because it will take a lot of space. Is there a way out? Can I get just the applet viewer (or anything similar to that) instead of entire JDK so that I can run my applet? Or is there any other way I can do my project using Java?


when to introduce an application services tier in an n-tier application

I am developing a web based application whose primary objective is to fetch data from the database, display it on the UI, take in user inputs and write them back to the database. The application is not going to be doing any industrial strength algorithm crunching, but will be receiving a very high number of hits at peak times (described below) which will be changing thru the day. The layers are your typical Presentation, Business, Data. The data layer is taken care of by the database server. The business layer will contain the DAL component to access the database server over tcp. The choices I have to separate these layers into tiers are:   1. The presentation and business layers can be either kept on the same tier.   2. The presentation layer on a separate tier by itself and the business layer on a separate tier by itself. In the case of choice 2, the business layer will be accessed by the presentation layer using a WCF service either over http or tcp. I don't see any heavy processing being done on the Business layer, so I am leaning towards option 1 above. I also feel for the same reason, adding a new tier will only introduce the network latency. However, in terms of scalability in case I need to scale up or scale out, which is a better way to go? This application will need to be able to support up to 6 million users an hour. There will be a reasonable amount of data in each user session, storing user's preferences and other details. I will be using page level caching as well.


How can I refactor a code base while others rapidly commit to it?

I'm on a private project that eventually will become open source. We have a few team members, talented enough with the technologies to build apps, but not dedicated developers who can write clean/beautiful and most importantly long- term maintainable code. I've set out to refactor the code base, but it's a bit unwieldy as someone in the team out in another country I'm not in regular contact with could be updating this totally separate thing. I know one solution is to communicate rapidly or adopt better PM practices, but we're just not that big yet. I just want to clean up the code and merge nicely into what he has updated. Would using a branch be a suitable plan? A best-effort-merge? Something else?


GIT workflow for web development

Long ago the small team of web developer I work with started using git for web development. Back then we just committed to staging or master directly and then merged frequently between the two. It was better than nothing, but it was also a mess. Not too long ago we adopted the gitflow work flow. While it's certainly better than the chaos that came before it seems somewhat cumbersome and excessively release/milestone oriented. My fellow devs are frequently ask me to clarify how it's supposed to work and what should merge and shouldn't. In general it seems ill suited for web development work where we're deploying code frequently and without tracking specific milestones for release. On a friends recent suggestion I've begun looking at GitHub Flow. Reading Scott Chacon's post here hits the pain point perfectly with this: > So, why don’t we use git-flow at GitHub? Well, the main issue is that we > deploy all the time. The git-flow process is designed largely around the > “release”. We don’t really have “releases” because we deploy to production > every day – often several times a day. FWIW, I've also looked at this nice round up of workflows on Atlassian's site: https://www.atlassian.com/git/workflows#!workflow-feature-branch However they ALL look like poor choices for web development in a small team and again geared towards major application releases not frequent/daily releases. The is a question over on SE asking to compare git-flow to github-flow http://stackoverflow.com/questions/18188492/what-are-the-pros-and-cons-of-git- flow-vs-github-flow That's a good answer in general, but as I mentioned in my comment below meta.programmers.SE seems to indicate that questions about general best workflow practices belong here and I was hoping for a broader list of possible answers than just git-flow and github-flow, while being specific to web development. Hence I think it warrants a new question here. With that, what do you find is the best/prefered git based workflow for a small web development team working on projects with fairly continuous deployment? Is it github-flow or something else?


What is an effective way to organize tasks for a new project?

Is there a practical solution to organizing the initial tasks for a new project? To elaborate, imagine the features/stories/goals are laid out for a project. How might one go about organizing those into sane tasks for the first few versions? The scenario I typically have in mind has the features listed as a high-level reference for what the end user-experience should involve. The tasks for constructing such features are then broken down into chunks (such as "create interface for X component"). Such a task is not necessarily "tied" to only that feature and may be useful when building subsequent features. Is breaking features down into small, code-able solutions valid? Or should they be slightly removed from any specific implementation? I do not expect that there is one "right" answer to this question, but I am looking for a fairly pragmatic and unobtrusive approach. As a note, I'm looking for solutions that are independent of any tools or "systems" used for managing the tasks themselves.


Using "prevent execution of method" flags

First of all I want to point out my concern with some pseudocode (I think you'll understand better) Assume you have a global debug flag, or class variable named "debug",               class a :        var debug = FALSE      and you use it to enable debug methods. There are two types of usage it as I know: first in a method :                method a :           if debug then call method b;           method b :      second in the method itself:                method a :             call method b;           method b :           if not debug exit      And I want to know, is there any File IO or stack pointer wise difference between these two approaches. Which usage is better, safer and why?


Can this code be made more concise?

I came across some code recently where in many, many places, expression evaluations were being assigned to different arrays one index at a time. A psuedo-code example:               array[0] = item1[0] + item2[0];     array[1] = item1[1] + item2[1];     array[2] = item1[2] + item2[2];      or               array[0] /= variable;     array[1] /= variable;     array[2] /= variable;      My instinct would be to first create a function for iterating through an array and assigning an evaluation using a single for loop. Then secondly, just call that function with arguments for the array, a number defining how many indices to loop through and the items to be evaluated.   * Obviously, one obstacle to that method is the fact that the expressions being evaluated are arbitrary - they can be additions, subtractions, divisions, multiplications.   * And for another, the expression operands can be either variables or arrays, and of course in statically typed languages, the types could be varied.   * Also, the number of operands may be varied. Is it possible to make this code more concise taking into account all possible cases, and what would the solution be called in technical terms?


Consistency of an object

I tend to keep my objects consistent during their lifetime. In some cases, setting up an object requires multiple calls to different routines. For example, a connection object may operate in this way:               Connection c = new Connection();     c.setHost("http://whatever")     c.setPort(8080)     c.connect()      please note this is just a stupid example to let you understand the point. In between calls to setHost and setPort the object is inconsistent, because the Port has not been specified yet, so this code would crash               Connection c = new Connection();     c.setHost("http://whatever")     c.connect()      Meaning that it's a requisite for connect() to have previous calls to both setHost and setPort, otherwise it won't be able to operate as its state is inconsistent. You may fix the issue with a default value, but there may be cases where no sensible default may be devised. We assume in the later example that there's no default for the port, and therefore a call to c.connect() without first calling both setHost and setPort will be an inconsistent state of the object. This, to me, points at an incorrect interface design, but I may be wrong, so I want to hear your opinion. Do you organize your interface so that the object is always in a consistent (i.e. workable) state both before and after the call ? **Edit** : Please don't try to solve the problem I gave above. I know how to solve that. My question is much broader in sense. I am looking for a design principle, officially or informally stated, regarding consistency of object state between calls.


How can I avoid the Carpal Tunnel Syndrome?

Using the keyboard, and the mouse for long time is probably one of the causes of Carpal Tunnel Syndrome. How can I avoid it?


Language agnostic programming books

Are there any great programming or software development books that are language agnostic? Why should I read it?


Standardized Data Structure Interface

I want to work with a variety of data structures (arrays, singly/doubly linked lists, sorted structures, etc.) on a plug-and-play basis. For example, I want to be able to easily swap in and out the sorted list and the array (which is re-sorted after every insertion/deletion), to test which one has better performance. In every language I know of, the public interface to such data structures is very inconsistent. So changing the implementation requires a lot of work. Is there a language, or a language-agnostic design pattern, that makes it easy to define a generic public interface that works with any data structure? Of course, I understand how different performance would be (e.g., binary search in a sorted array vs linear search in a regular array). All I ask is that the performance of the data structure doesn't degrade asymptotically or by a large constant factor due to the use of the standard interface. Example problem: iterate through the container of numbers, find the two numbers that are nearest each other, and remove the pair of them. (If several pairs are equal distance, pick an arbitrary pair). I'd like the code to solve the problem to be unchanged as I switch in and out different containers.


is requiring a video player download acceptable

Our site currently is going to require our users to download a player to view videos they will want to view on our site. The videos get uploaded by users from various sources (smartphones in 3gp format for example). However most people have Flash on their machines. I am trying to 'make a gentle stand' and tell the team that requiring a download of a video player is not acceptable. My thinking is this:   * instead of allowing people to upload 3gp and other formats then re-serving the exact format on REQUESTs from our site's users   * we will instead use a video converter such as FFMpeg to convert every uploaded video to FLV for viewing on flash.   * so when a user requests to view one of the videos on our site -- boom they probably already have Flash installed so we just play the video in their Flash player. I feel serving up FLV flash video is best. Does it ring true that requiring, say, a 3gp player download just to view a video is the wrong approach?


My most cherished dream project seems to resemble a product that already exists. What shall I do?

I guess this is more of a "comfort seeking" question than legality one. You see, for the past couple of months I have been brainstorming and developing a product, all by myself. I was planning to release it under some kind of free license. While I know no idea is ever a unique one, I was quite happy to note that the way I had visualized my software, in its form and purpose, was one of its kind, albeit bits and pieces resembling others. That private project was quite cherished one. Now I find there is a product, at least a decade old, that is so close to mine that mine looks plagiarized. While with the rest of them I had a 8:2 in my favor, feature wise, with this product it seems transposed, including the philosophy. I admit I can vaguely recall hearing the name of it but never thought of reading about it - the name didn't seem to invoke interest etc - until now. I read about it and now I am distraught and agonized. There is no risk of any legal action as that software is in "free" domain and mine is still a private project, and I don't know if it will be ever make any money from any buyer which will then lead to trouble, but that is not the point of the question. The point is how to stay focused and enthusiastic as before? I have about a month of work pending, mainly programming and complete testing, and this has completely left me drained. I am in a fetal position. I am telling myself about Newton-Leibniz, Faraday-Henry kind of independent activities with similar to same results but that isn't helping. I don't want this to spill over to my regular life and work life. I can sense two issues that are pricking me. (1) I wanted praise for my creativity. (2) I was harboring a small desire of a possible chance of making good money by attracting a buyer. This might be a casual and almost an inconsequential problem for the citizens of the business world, but I am from a different world. Help.


foreach($items as &$item) considered harmful?

Is it considered bad practice to pass items in a PHP array by reference instead of by value? Relevant documentation: http://php.net/manual/en/control- structures.foreach.php


Is there an infinite amount of knowledge in a programming language?

I can program in Java, C#, C, Scala, and Javascript fluently. I'm comfortable with Objective-C, but I don't remember the conventions used for memory management. I can read Python and Ruby and I've written scripts in Ruby. I was given the task of writing a job posting. Our application (Hansen) was built in C# (not by us) and it uses some event triggers written in Visual Basic. My group has used C# to build programs that interacts with Hansen through Hansen's web services. I wasn't specific on the technologies we need. I felt listing specific skillsets (knowledge of C# and IIS and Oracle) were a barrier to entry that wasn't necessary. My junior co-worker (by two weeks) felt that we should be focused on .NET only. Our managers are hiring for an entry level position. It started an argument where he takes the belief that we need C# and that a Java trained guy couldn't possibly adapt. I counter that there's not an infinite amount of knowledge in a programming language and that there's new languages out there and that it's fairly easy to pick up a programming language if one has knowledge of the functional programming world (C# added anonymous functions and generics and Java added anonymous classes and generics because of pressure from that world). Our code is better off by having it. I've had this discussion before when I was working in a Java group within my department. I just don't think there's an infinite amount of knowledge in a programming language or a programming platform. I think someone comfortable the JPA can adapt to LINQ and to ADO.NET. Am I missing something in assuming that programming languages don't have any infinite amount of knowledge and that four years of experience dedicated solely to C# doesn't automatically make one a better programmer?


What is the advantage of determining scopes statically and using them dynamically in case of Python?

Firstly let me clarify that I know C and am learning Python. So my OOPS is kind of bad. I was reading the official tutorial and found this > Although scopes are determined statically, they are used dynamically. At any > time during execution, there are at least three nested scopes whose > namespaces are directly accessible: > >   * the innermost scope, which is searched first, contains the local names >   * the scopes of any enclosing functions, which are searched starting with > the nearest enclosing scope, contains non-local, but also non-global names >   * the next-to-last scope contains the current module’s global names the > outermost scope (searched last) is the namespace containing built-in names > I understand namespaces. I think scopes are the same thing. But I couldn't figure out what does the sentence about scopes mean? What is the advantage of such an arrangement? I understand the sentence but couldn't visualize that. So please don't say that this is problem with my English.


Should I plan ahead, or figure out programs as I'm writing them?

I was thinking today about Paul Graham's book "Hackers and Painters." More specifically, these two paragraphs: > "I was taught in college that one ought to figure out a program completely > on paper before even going near a computer. I found that I did not program > this way. I found that I liked to program sitting in front of a computer, > not a piece of paper. Worse still, instead of patiently writing out a > complete program and assuring myself it was correct, I tended to just spew > out code that was hopelessly broken, and gradually beat it into shape. > Debugging was a kind of final pass where you caught typos and oversights... > [It] seemed like programming consisted of debugging. > > ... As far as I can tell, the way they taught me to program in college was > all wrong. You should figure out programs as you're writing them, just as > writers and painters and architects do." That's how it's taught in my college and I'm pretty sure most other colleges as well. You figure out what your program will do, and then you figure out how to do it, then you type and debug. Sometimes you make a basic version and add functionality, but the idea is that you think through and then type. This sort of reminds of that chapter in Feynman's book called "He Solves Radios By Thinking!" where he paced around thinking of how the radio could be broken, and then fixes it. To me, that's what programming is about - thinking and then finding a solution. Is this the prevalent approach to coding? If so, why don't more people just hack away and put a program together without having a preconceived idea of what it's going to look like? What are the advantages and disadvantages of think & type vs. spew & beat?


Browser parsers vs Stand-alone parsers

Firefox/Chromium have well implemented(?) parsers. Then why are parsers like lxml and other such parsers being developed with so much effort put into it? Aren't they re-inventing the wheel? Or are they solving a different problem? Can't parsers in browsers be made into standalone libraries?


Learning Asynchronous programming

Asynchronous non-blocking event driven programming seems to be all the rage. I have a basic conceptual understanding of what this all means. However what I'm not sure is when and where my code can benefit from being asynchronous, or how to make blocking IO, non-blocking. I'm sure that I can simply use a library to do this, but I'm more interested in more in depth concepts, and the various ways to implement it myself. Are there any comprehensive/definitive books, or other resources on this subject (like GoF for Design Patterns, or K&R for C, tldp for things like bash)? (Note: I'm not sure if this is actually functionally an identical question to my question on Learning event driven programming)


Storing translation data as JSON column

We're deciding on how to store translations of some descriptions of database items. We could go the traditional way and keep a translations table (and a language table and an object_translation linking table) OR we thought it might be better to just have a Description column that contains JSON like the following:               {          "EN": "This is the translation in English",          "EE" : "See on kirjeldus eesti keeles"     }      Are there any serious downsides as to why we shouldn't use this? (I haven't seen it being used anywhere else)


How do people get rid of conditional branches in Functional Programming?

Long running switch cases or if-else-if constructs are avoided in OOP using polymorphism wherever it is applicable. instead of branching by matching a value, branching is done at class-level itself. How can similar approach be applied in Functional Programming paradigm, Clojure specifically ?


Author has inserted copyright into code with gnu public license notice - implications?

I've found a project on Github that I'm interested in contributing to which claims to be open source and has a GPL license included with it. But the original author has added a copyright notification to each source file. I'm not sure why but I don't feel right contributing to a project that's always going to have someone else's name on it. It really breaks the community-created feel, and makes me uneasy about what the author might choose to do with the project next. What are the implications of copyrighting open source GPL code as so? What power does this give the original author over a contributor?               # Copyright (C) 2012, 2013 __AUTHORNAME__     # This file is part of __PROJECTNAME__.     #     # __PROJECTNAME__ is free software: you can redistribute it and/or modify     # it under the terms of the GNU General Public License as published by     # the Free Software Foundation, either version 3 of the License, or     # (at your option) any later version.     #     # __PROJECTNAME__ is distributed in the hope that it will be useful,     # but WITHOUT ANY WARRANTY; without even the implied warranty of     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     # GNU General Public License for more details.     #     # You should have received a copy of the GNU General Public License


Resources for developers to help them create better bug reports

Are there any good articles or videos available that developers could use to learn to create more informative bug reports? Often times I have to verify cases that were opened by developers where the title is the only information available, so I would like to help the devs become better bug reporters for both our benefit.


How do you conquer the challenge of designing for large screen real-estate?

This question is a bit more subjective, but I'm hoping to get some new perspective. I'm so used to designing for a certain screen size (typically 1024x768) that I find that size to not be a problem. Expanding the size to 1280x1024 doesn't buy you enough screen real estate to make an appreciable difference, but will give me a little more breathing room. Basically, I just expand my "grid size" and the same basic design for the slightly smaller screen still works. However, in the last couple of projects my clients were all using 1080p (1920x1080) screens and they wanted solutions to use as much of that real estate as possible. 1920 pixels across provides just under twice the width I am used to, and the wide screen makes some of my old go to design approaches not to work as well. The problem I'm running into is that when presented with so much space, I'm confronted with some major problems.   * How many columns should I use? The wide format lends itself to a 3 column split with a 2:1:1 split (i.e. the content column bigger than the other two). However, if I go with three columns what do I do with that extra column?   * How do I make _efficient_ use of the screen real estate? There's a temptation to put everything on the screen at once, but too much information actually makes the application harder to use. White space is important to help make sense of complex information, but too much makes related concepts look too separate.   * I'm usually working with web applications that have complex data, and visualization and presentation is key to making sense of the raw data. When your user also has a large screen (at least 24"), some information is out of eye sight and you need to move the pointer a long distance. How do you make sure everything that's needed stays within the visual hot points?   * Simple sites like blogs actually do better when the width is constrained, which results in a lot of wasted real estate. I kind of wonder if having the text box and the text preview side by side would be a big benefit for the admin side of that type of screen? (1:1 two column split). For your answers, I know almost everything in design is "it depends". What I'm looking for is:   * _General principles you use_   * _How your approach to design has changed_ I'm finding that i have to retrain myself how to work with this different format. Every bump in resolution I've worked through to date has been about 25%: 640 to 800 (25% increase), 800 to 1024 (28% increase), and 1024 to 1280 (25% increase). However, the jump from 1280 to 1920 is a good 50% increase in space--the equivalent from jumping from 640 straight to 1024. There was no commonly used middle size to help learn lessons more gradually.


Structuring Access Control In Hierarchical Object Graph

I have a Folder entity that can be Moderated by users. Folders can contain other folders. So I may have a structure like this:               Folder 1         Folder 2             Folder 3         Folder 4      I have to decide how to implement Moderation for this entity. I've come up with two options: **Option 1** When the user is given moderation privileges to Folder 1, define a moderator relationship between Folder 1 and User 1. No other relationships are added to the db. To determine if the user can moderate Folder 3, I check and see if User 1 is the moderator of any parent folders. This seems to alleviate some of the complexity of handling updates / moved entities / additions under Folder 1 after the relationship has been defined, and reverting the relationship means I only have to deal with one entity. **Option 2** When the user is given moderation privileges to Folder 1, define a new relationship between User 1 and Folder 1, _and_ all child entities down to the grandest of grandchildren when the relationship is created, and if it's ever removed, iterate back down the graph to remove the relationship. If I add something under Folder 2 after this relationship has been made, I just copy all Moderators into the new Entity. But when I need to show only the top-level Folders that a user is Moderating, I need to query all folders that have a parent folder that the user does not moderate, as opposed to option 1, where I just query any items that the user is moderating. **Thoughts** I _think_ it comes down to determining if users will be querying for all parent items more than they'll be querying child items... if so, then option 1 _seems_ better. But I'm not sure. Is either approach better than the other? Why? Or is there another approach that's better than both? I'm using Entity Framework in case it matters.


Ready to Open source the software, but want to make some money out of it

I'm an UG Student and an Entrepreneur. I have started a small company with which I'm trying to provide solutions, to various companies in my city, through my software. I put in 30-40 hours of coding and development. I've been a huge fan of Open Source projects and I've also built by software on python. But now when it comes to selling my software to my customers, I expect money. (Am I being a Hypocrite?)   1. Is there any OSS license under which I can make money and also make my source open? Please suggest.   2. Or any other way to make money with my softwares? (I guess I deserve some credit. If not the code, atleast the ideas? :D )


Displaying the number of registered users to a website

I am building an online game much like Mafia Wars. I was thinking of displaying the number of registered users on the home page, but then I thought: > "What if a new user sees that the total number of registered users is > **5**?!" :D That would be too embarrassing to my _still growing_ game. Then another thought came by: > "Why don't I display **500** instead?!" ;) Nobody would know if there is actually 500 users registered to my website unless of course they start actually playing and interacting with other players. However, I just have a feeling that this isn't ethical. What if this generates a negative publicity to my website?!! What's your opinion should I fake the number? or should I honestly display it? or should I wait till I have 1000 real account then start displaying the number? And most importantly is this legal?! :D


Merits of a "Message Passing" system vs. an "Event Based" system

My question is coming from an somewhat uneducated perspective. What are the relative merits of a "message passing" system vs an "event based" system. Why would one choose one over the other? What are their strengths and weaknesses? I would like to know not just "in theory", but also "in practice". EDIT: _Specific problem_ : I want to build system of plug-able components which behave as small scale services (each performing some small task and or providing some piece of information). The services can:   * be layered so that the output of one service can act as one of the inputs to another   * have containment hierarchies so that one service can be contained by another without a specific input-output relationship as mentioned in the previous sentence The goal of the system is to translate a single flow of low level events in another system into higher level information and functionality, and in addition provide a channel back to the other system providing a single series of events. I can provide more detail if this isn't enough. After looking around some more. This and this probably describes my situation better. This looks like it may be a good fit for my situation: http://akka.io/


Effective way of keeping past projects with their working development environment?

I find that whenever I want to go run a past project, it will take a long time before I can find it and before I have everything set-up again for it to be able to run. For example, I have python projects I created in Linux, and it depends on software packages that are easily installed in Linux, yet I no longer have the Linux VM I was using. And some of my other projects depend on other variables like web server configuration, PATH variables, sdk, IDE, OS version, device, etc. Does someone have an effective way of handling this issue? As of now I have only concerned myself with keeping the source code backed up yet **it is difficult re-establish the working development environment and it is also difficult to keep the working development environment around as well**.


Using HBase or Cassandra for a token server

I've been trying to figure out how to use HBase/Cassandra for a token system we're re-implementing. I can probably squeeze quite a lot more from MySQL, but it just seems it has come to clinging on to the wrong tool for the task just because we know it well. Eventually will hit a wall (like happened to us in other areas). Naturally I started looking into possible NoSQL solutions. The prominent ones (at least in terms of buzz) are HBase and Cassandra. The story is more or less like this:   1. A user can send a gift other users.   2. Each gift has a list of recipients or is public in which case limited by number or expiration date   3. For each gift sent we generate some token that uniquely identifies that gift.   4. For each gift we track the list of potential recipients and their current status relating to that gift (accepted, declinded etc).   5. A user can request to see all his currently pending gifts   6. A can request a list of users he has sent a gift to today (used to limit number of gifts sent)   7. Required the ability to "dump" or "ignore" expired gifts (x day old gifts are considered expired) There are some other requirements but I believe the above covers the essentials. How would I go and model that using HBase or Cassandra? * * * Well, the wall was performance. A few 10s of millions of records per day over 2 tables kept for 2 weeks (wish I could have kept it for more but there was no way). The response times kept getting slower and slower until eventually we had to start cutting down number of days we kept data. Caching helps here but it's not an ideal solution since a big part of the ops are updates. Also, as I hinted in my original post. We use MySQL extensively. We know exactly what it can and can't do both in naive implementations followed by native partitioning and finally by horizontally sharding our dataset on the application level to reside on multiple DB nodes. It _can_ be done, but that's not really what I'm trying to get from this. I asked a very specific question about designing a solution using a NoSQL solution since it's very hard to find examples for designs out there. Brainlag, not trying to come off as rude. I actually appreciate it a lot that you are the only one who even bothered to respond. but I see it over and over again. People ask questions and others assume they have no idea what they're talking about and give an irrelevant answer. Ignore RDBMS please. The question is about nosql.


What are the most relevant books on software project estimation?

Is there a book out there that's the de-facto standard for describing best practices and other helpful information about software project estimation? What about that book makes it special?


http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth- authentication/ I've been reading the article and I haven't really grasped it yet. When is the private key given to the client? **Say I have a JavaScript client - where would I store this private key (once assigned) - a cookie?** I think that this maybe is done when authenticating a user, if a JavaScript client makes a post request and authenticates a user, the server validates the input and gives back user id ( a public key ) and then some generated string (stored in a table) = the private key? And then just follow the approach (quoted) from article:               [CLIENT] Before making the REST API call, combine a bunch of unique data together (this is typically all the parameters and values you intend on sending, it is the “data” argument in the code snippets on AWS’s site)     [CLIENT] Hash (HMAC-SHA1 or SHA256 preferably) the blob of data data (from Step #1) with your private key assigned to you by the system.     [CLIENT] Send the server the following data:         Some user-identifiable information like an “API Key”, client ID, user ID or something else it can use to identify who you are. This is the public API key, never the private API key. This is a public value that anyone (even evil masterminds can know and you don’t mind). It is just a way for the system to know WHO is sending the request, not if it should trust the sender or not (it will figure that out based on the HMAC).         Send the HMAC (hash) you generated.         Send all the data (parameters and values) you were planning on sending anyway. Probably unencrypted if they are harmless values, like “mode=start&number=4&order=desc” or other operating nonsense. If the values are private, you’ll need to encrypt them.     (OPTIONAL) The only way to protect against “replay attacks” on your API is to include a timestamp of time kind along with the request so the server can decide if this is an “old” request, and deny it. The timestamp must be included into the HMAC generation (effectively stamping a created-on time on the hash) in addition to being checked “within acceptable bounds” on the server.     [SERVER] Receive all the data from the client.     [SERVER] (see OPTIONAL) Compare the current server’s timestamp to the timestamp the client sent. Make sure the difference between the two timestamps it within an acceptable time limit (5-15mins maybe) to hinder replay attacks.         NOTE: Be sure to compare the same timezones and watch out for issues that popup with daylight savings time change-overs.         UPDATE: As correctly pointed out by a few folks, just use UTC time and forget about the DST issues.     [SERVER] Using the user-identifying data sent along with the request (e.g. API Key) look the user up in the DB and load their private key.     [SERVER] Re-combine the same data together that the client did in the same way the client did it. Then hash (generate HMAC) that data blob using the private key you looked up from the DB.         (see OPTIONAL) If you are protecting against replay attacks, include the timestamp from the client in the HMAC re-calculation on the server. Since you already determined this timestamp was within acceptable bounds to be accepted, you have to re-apply it to the hash calculation to make sure it was the same timestamp sent from the client originally, and not a made-up timestamp from a man-in-the-middle attack.     [SERVER] Run that mess of data through the HMAC hash, exactly like you did on the client.     [SERVER] Compare the hash you just got on the server, with the hash the client sent you; if they match, then the client is considered legit, so process the command. Otherwise reject the command!      On second note, I believe it would be more readable from the article itself... Am I getting this right?


How can you decompose a constructor?

Lets say I have a Enemy class, and the constructor would look something like:               public Enemy(String name, float width, float height, Vector2 position,                   float speed, int maxHp, int attackDamage, int defense... etc.){}      This looks bad because the constructor has so many parameters, but when I create an Enemy instance I need to specify all of these things. I also want these attributes in the Enemy class, so that I can iterate through a list of them and get/set these parameters. I was thinking maybe subclassing Enemy into EnemyB, EnemyA, while hardcoding their maxHp, and other specific attributes, but then I'd lose access to their hardcoded attributes if I wanted to iterate through a list of Enemy (consisting of EnemyA's, EnemyB's, and EnemyC's). I'm just trying to learn how to code cleanly. If it makes a difference, I work in Java/C++/C#. Any point in the right direction is appreciated.


How to avoid duplicating the domain model in a multi-language distributed application?

My team is currently working on a web platform and we are planning to divide the application in a set of independent services written in different languages, the problem is that these services rely on a domain model layer that will need to be duplicated across the different languages(C# and Java). The Domain layer is heavily cohesive and cannot be easily splitted out. Given that working with multiple languages is a requirement **what is a good architectural style that will allow a positive approach for this problem?**


How can I interact with a client-side sound device through a web application?

I'm trying to find something that will allow a web application to analyze the line or microphone input from a client and transmit that data to the server. I've looked briefly at WebRTC and, although I find it to be the most compelling answer 'future-wise', it is (at the time of writing) far from being complete and/or standardized as a protocol. This would be my first web application that would require such functionality. Ideally, part of the sound signal processing could be handled by client-side code to reduce the impact of device latency (say, the time it takes for a sound to travel from instrument to computer, go through digital-to-analog conversion, and then be sent to the app) and internet 'lag'. The signal would, at some point, need to make it back to the server for analysis. It might be a bit high-concept, but perhaps there is a way using an existing plugin - I just thought I would turn to some folks who have spent more time in this realm than I have. Thanks in advance for your time.


Are XAML UI designers common today?

I am thinking about creating a silverlight application, and I lack the skills to create a good looking UI.   Today's graphic designers usually know HTML and CSS and thus save me the trouble of doing something I am not very good with.   Is this the same case with XAML?   Do I have to hire two employees for this job?