Ok so here is the question: What are the advantages and Disadvantages of Using an Aspect Orientated Programming Paradigm. My advantages and disadvantages thus far: ## Advantages:   * Complements object orientation.    * Modularizes cross-cutting concerns improving code maintainability and understandability.  ## Disadvantage:   * Not the easiest of concepts to grasp - not as well documented as O-O   * O-O goes far enough in the separation of concerns...  Would anyone like to challenge any of these/ add their own? Many Thanks, J


When to Use workflow engines?

I've worked in past on some of the workflow engines as programmer but never had a clarity on why we chose the work-flow engines in first place. And as programmer I know that there are at least 100 ways to do anything when you are writing code but only few of the ways are the best! I still don't understand which use cases are best solved by workflow engines (or rather their concept) than designing a good DI enabled application. I'm looking for any general characteristics of domain-neutral use cases, where work-flow engines are one of the the best options. So my question is: What are general characteristics of a requirement which can be taken as a signal for opting for a good workflow engine and coding around it?


Programmers' concerns about export restrictions from the United States

Which aspects do I need to consider when designing and publishing software that must meet the US export restrictions for cryptographic software? Wikipedia says that there are various categories which you can assign to cryptographic software. And the export destination (e.g. China, Russia) does play a major role as well. But I didn't really understand those restrictions and their effect on my work. Can anybody explain that to me? I'm asking because if you try to publish your application (e.g. on Apple's App Store or Android's Market) you have to assure that your application meets the US export restrictions. And there are lots of applications who offer secure information storage, e.g. for passwords. Have they all notified the government and asked for a review? Of course, you cannot know if they did. But do they need to do this?


How can I program effectively during an Internet outage?

So much of development is now done online to take advantage of interconnectivity and shared resources. In a prolonged Internet outage, how can one cope with the lack of that connection? Are there ways to replicate or work around the innumerable benefits the Internet adds to development?


non-programming jobs that making use of programmig skills?

> **Possible Duplicate:**   >  Jobs that use programming which aren't in the technology sector I have programming skills, but i don't want to sit in front of a computer 8 hours a day. Is there other career choices that I can consider, that also utilize my existing skills? And what I should do to get those jobs? I am open to anything that doesn't require extensive use of computer, also something that perform routine rather than going through projects (i don't like keep thinking about a project in my free time, because no one's paying me for that, i believe that's where stress comes from). Also it would be nice if the job doesn't require a CS degree, because I don't have one.


Javascript Event in Innerhtml Resulting from PHP Server Script

I'm (very slowly) making a website, and I'm creating a search engine for the database, which is essential to organize the dependencies during data entry. Anyway, what I would like is to type a few keywords into a box, have a menu pop up with various search results, and have the box fill with the ID number of the selected entry when it's clicked. Currently, I have a document called search.php which fills a div called search-output using xmlhttp.open() and the innerhtml property. Everything is working perfectly except for filling the original search box with the ID number when clicking. My first attempt was to add an onclick event to each entry in the output from search.php. Unfortunately, I found that javascript inserted into innerhtml is not run for security reasons. I've been Googling for hours but haven't been able to find a solution. How can I get the original search text box to fill with the correct ID when I click it? Is what I'm doing a good setup for the results I desire, or is there a better way to integrate search features into data entry?


Should I use mMember and sStatic naming convention in Android?

Android source code and many Android open-source apps and libs use m prefix for member fields and s prefix for static member fields:               private static boolean sStarted;     private long mTimestamp;      I personally dislike this, because it looks ugly and it's redundant – my IDE already uses different color and formatting for local, member and static member variables. What's closest to truth?   1. It's a good practice.   2. It's a bad practice but you should use it anyway in order to be consistent with the majority of Android code out there.   3. It's a bad practice and you shouldn't use it.


Why does Internet Explorer have so many incompatibilities with other browsers?

Internet Explorer has a number of proprietary features that aren't found in other browsers as well as a number of incompatibilities with the standards. Does anyone have an idea what is _the cause_ of those incompatibilities? For example: I develop a browser extension using Crossrider framework. The extension works well with all combinations of [Windows | Mac OS | Linux] and [Chrome | Firefox] but it does not work with IE because IE handles `$(window).height()` and `$(window).scrollTop()` a bit differently. Is there a known thorough analysis of that situation, or an interview with an insider that would clarify the cause? Is it the corporate culture, the design process, a QA flaw, or some horrid unknown legacy?


How to organise the different bits and pieces in an agile environment?

Trying to make our shop an agile environment, we struggle with some bits and pieces of that world. While not making it waterfally, we do have to have some sort of agreement on what a new feature needs to do. We follow the KISS and "minimally viable product" principle. Still, after discussing a story, we end up with:   * UI/UX design   * Acceptance criteria   * Constraints   * Use cases   * Some extra specifications (like what fields to show in tables etc) As tools we use JIRA, Greenhopper, Balsamiq, Glyphy and Confluence and they are working very well but we're not quite sure where to store which bits and how to make this work together well. How do you guys approach that. Please include details on how far you go detailing the feature before development starts.


Why do you need float/double?

I was watching http://www.joelonsoftware.com/items/2011/06/27.html and laughed at Jon Skeet joke about 0.3 not being 0.3. I personally never had problems with floats/decimals/doubles but then I remember I learned 6502 very early and never needed floats in most of my programs. The only time I used it was for graphics and math where inaccurate numbers were ok and the output was for the screen and not to be stored (in a db, file) or dependent on. My question is, where are places were you typically use floats/decimals/double? So I know to watch out for these gotchas. With money I use longs and store values by the cent, for speed of an object in a game I add ints and divide (or bitshift) the value to know if I need to move a pixel or not. (I made object move in the 6502 days, we had no divide nor floats but had shifts). So I was mostly curious.


Redistributing BSD-licensed software?

Is it acceptable to distribute unmodified BSD-licensed software (pyglet) with GPL-licensed software I created? The BSD allows for sale of modified software, I know, but does it allow re-licensing of unmodified? Seems to defeat the purpose of having a license at all.


Running pieces of code distributed through out the system, automatically

I have pieces of code, written in java, which I can convert in jar and run from the terminal. I also have some node.js script, which I would like to run before running these jar files. So the process of running my project is as follows: > Start mongodb from terminal->Run Node.js script-> Run the java code(jar > file) So I want to know, is there a way I could automate my project by just calling some one single file instead of running so many files separately? if so, how?


Do higher resolution laptop displays matter for programmers?

I'm buying a new laptop that I'll be using mainly for programming. A couple of options that really intrigue me are the Asus Zenbook UX31A and the new Retina Macbook Pro. It's obvious that the high-resolution displays on these laptops is useful for entertainment, photo-editing, and other things. My question is this: Do these displays provide any benefit for programmers? Do these displays make code any easier to read? Are they any easier on the eyes after a whole day of staring at the screen?


Are there any languages to replace or compete with Javascript?

Time and time again I am surprised at how difficult Javascript is to maintain or write proper programs in, mostly because it is so weakly typed. I truly find it akin to writing programs in assembly. Sure, there is some intellisense for it and you can get some tools to make it easier. You can even use things like jQuery to make it more platform independent. But does there exist some sort of language (strongly-typed) that I could write in, syntax similar to Java or C#, that could "compile" into Javascript? Or perhaps there are tools that would make Javascript strongly-typed, and could detect bugs, that a C# compiler would detect? I'm not trying to just hate on JS here, but I'm wondering if there is some sort of roadblock that prevents this. Or perhaps doing this would make JS difficult to use in the web. Edit: While I may have been pointing directly at javascript, I guess my broader question, is there a reason why Javascript is the only game in town? And is there something inherent about client-side code that makes javascript that way it is?


What is a closure and how is it implemented in Ruby?

In the context of the Ruby programming language, what is a closure and when do you use one? What are the uses for it in Rails?


Schema table for multi-integration tokens

I'm designing a schema table that will manage the auth tokens for integrations // app with social networks. At the moment only for Twitter and Facebook. I'm thinking in this mode               id  social   tw_token   tw_token_auth   tw_secret   tw_secret_key   fb_token  fb_secret     1    twitter   aaa         bbbb           cccc        dddd            NULL       NULL     2    facebook   NULL        NULL          NULL         NULL            AAA1      bbb3      I don't like that many NULL, but for a so-simple-schema I would not realize a different table for social networks. How to perform this better than I'm doing now?


How to translate Lisp to Javascript

I have some legacy code, which uses _Lisp_ as it's scripting language. To broaden, ease and accelerate scripting I'd like to replace _Lisp_ by _Javascript_. In order to be able to built on all present scripting files, I first need to translate all `lsp` to `js`. Now I found _parenscript_ but am not yet sure what it is good for (seems to modify Javascript to be able to run lisp, which is not what I want). Also there are some converters on the web, which seem to work quite well. Has anyone already done this and can share some experiences, best pracises and tools?


Practical Meta Programming System (MPS)

This is in regards to Meta Programming System or MPS by JetBrains. Thus far, from my efforts to learn how to use MPS, I have only learned its basic purpose and that it is very complex. Is MPS worth learning? Is there anyone who already effectively uses MPS to create their own languages and editors for those languages and uses these created editors as their primary way of programming? If so, what types of programs have they made with this? What are the advantages and disadvantages of working with MPS?


Should REST APIs be context independent or dependent?

Let's say I have several users and each one has a `user_id` and also `friends` To access their friends, they should be logged in, so a session will be established with the server. Should the REST API for their friends be `user/:user_id/friends` or just `friends`


Is Visual C++ Redistributables backward compatible?

I am including two programs in my software. One of which requires VC10 and the other requires VC11. My question is that if program developed for VC10 will work on VC11 or I have to include both VC10 and VC11


Using Vim when coding a large-scale application

I'm starting to learn Vim, and following some of the advices given here in stackexchange. I'm beginning to use it in some toy projects and I'm cool with that.   But I started to wonder how you can be productive without opening other files all the time just to know how's that class' Name, what's that macro included in other file, etc. etc. What are the common advices you can give?


How are the conceptual pairs Abstract/Concrete, Generic/Specific, and Complex/Simple related to one another in software architecture?

(= 2 (+ 1 1))      take the above. The requirement of the '=' predicate is that its arguments be comparable. Any two structures are comparable in this case, and so the contract/requirement is pretty generic. The '+' predicate requires that its arguments be numbers. That's more specific.               (socket domain type protocol)      the arguments here are much more specific (even though the arguments are still just numbers and the function itself returns a file descriptor, which is itself an int), but the arguments are more abstract, and the implementation is built up from other functions whose abstractions are less abstract, which are themselves built from less and less abstract abstractions. To the point where the requirements are something like move from one location to another, observe whether the switch at that location is on or off, turn the switch on or off, or leave it the same, etc. But are functions also less and less complex the less abstract they are? And is there a relationship between the number and range of arguments of a function and the complexity of its implementation, as you go from more abstract to less abstract, and vice versa?               (= 2 (+ 1 1) 2r10)      the '=' predicate is more generic than the '+' predicate, and thus could be more complex in its implementation. The '+' predicate's contract is less generic, and so could be less complex in its implementation. Is this even a little correct? What about the 'socket' function? Each of those arguments is a number of some kind. What they represent, though, is something more elaborate. It also returns a number (just like the others do), which is also a representation of something conceptually much more elaborate than a number. To boil it down, I'm asking if there is a relationship between the following dimensions, and why:   1. Abstract/Concrete   2. Complex/Simple   3. Generic/Specific And more specifically, do different configurations of these dimensions have a specific, measurable impact on the number and range of the arguments (i.e., the contract) of a function?


Good way to handle the notification counter like Facebook does

I want to build a similar notification mechanism that Facebook handles. ![enter image description here](http://www.techlicious.com/images/computers/facebook-notification- icon-100px.jpg) I actually store the user's notification in an SQL table (actually it's a graph database but everybody master RDBMS terms). I'm interested in the case where the user clicks on the icon: The counter should get a value of 0 internally and visually disappears. How the clearing of this counter should be made?   * On clicking, call a Rest API that flags each notification as being `read` (table's column `READ`)?   Drawback would be that it would take some time if there was huge amount of notifications to flag in order to get the counter to 0 and making it disappear.   * Having a kind of column for each user called `HAS_NEW_NOTIFICATION` that is valued as `false` each time the icon is clicked (through a REST API call), if the counter was present.   Thus, the counter would be present only if the flag value is `true`. What would be a good practice?


Help with database design with a strict and structured subset of clinical data

I'm developing an application to keep some of the data in chronic patients, the data came from a very strict subset of data, vital signs, exams, ecc. On a first glance I thought to create a Patient model with has_many encounters, and put every info in a different field like (age, height, weight, ecc), but it will result in a big model. So I wondered about embedding to make it easier to maintain and scale if in a couple of months I need to register a new exam, right now I have been thinking in something like this: ### Patient               name: string,     address: string,     phone: integer,     diagnose: string,     etc...      ### Encounters               patient_id: ObjectID,     age: Integer,     vital_signs: [ { height, weight, bmi, systolic_pressure, diastolic_pressure } ],     exams: [ { creatinine, total cholesterol... } ],     next_encounter: Date      I'm going to still need to access to `bmi` for example if I want to get how many people in the community is obese (hint: an awful lot), so embedding maybe it's not a very good idea. In any case, all the "analysis" will only be done only monthly (or less). I picked mongodb, because I'm afraid the requisites for this database will be changing from time to time, so flexibility it's important. Maybe in this case since data is structured, every document will have the same types of fields, a relational database could be better? I don't think it makes sense using a nosql database in a sql way, right? PS.- I read this article from mongodb blog, and I'm more confused about if this really it's the best approach.


I created a program based on an LGPL project, and I'm not allowed to publish the source code

I thought LGPL was a permissive license, just like MIT, BSD or Apache. But today I read, that only _linking_ to LGPL (libraries etc) is allowed from closed-source code - other than that, it's copyleft - so I have to publish code that is based on an LGPL program. I created a program for my employer that is based on an LGPL program, but has considerable modifications to it. Of course, I am not allowed to put that modified source code out there. At the same time, I have to, if I distribute it (right?). So I wonder whether there is a workaround to this, so I can keep this closed- source (I wish I could publish the source) - any suggestions? My idea: can I put most functions of the original LGPL app into an external library, write the core executable from scratch, but refer back to the library for all functions that I haven't modified? Currently, everything is in a .jar file (it's Java/Swing). if you think my idea is legally/technically feasible - how much effort would it be to seperate what I wrote and what the original is? I'm not the most java savvy.


Can you be a manager and a programmer at the same time?

Managing other programmers while you are yourself a part of the programming work force. It's a very common scheme, at least in the companies I worked for. Can you be a good programmer or a good manager if you do both at the same time? I'm questioning the effectiveness of an individual that has to be in two very different roles, requiring very different skills, environment, concentration, organization, etc. **UPDATE** : my question includes management of the company (which is my case), not specifically team management. But I'm interested in both of course.


Auto functions in c++

I'm not so familiar with C++. Can someone please inform me what this lines does (in detail):               auto add_element = [&rows,&cols,&values](size_t row, size_t col, double value)     {         rows.push_back(int(row));         cols.push_back(int(col));         values.push_back(value);     };      Rows, cols, values are obvious vectors. Is this the same as void add_element(vector & rows, size_t row, .....)


Source of (programmer) inefficiency

I am interested to gain a better insight about the possible reasons of personal inefficiency as programmers (and only in programming) due to – simply - our own errors (because we are humans – well, almost all of us). I am not interested in how much we are productive or in how many adjustements the customer asks for when the work is done, but where and how each of us spend that part of its time in tasks that are unproductive and there is no one to blame except ourselves. Excluding ego - feeding and / or self – gratification, what I am trying to get (for all of us) is: what are the common issues eating our time; insight on reasons for that issues; identify simple way for us, personally (not delegating actions to other or our organizations), to correct our own problems. Please, do not think in academic terms but aim at the opportunity to compare our daily experiences and understand what are and how we try to fix our personal deficiencies. If you are interested to respond to this post, please:   * integrate the list if you see something important (or obvious) missing;   * highlight or name honestly your first issue tellng the way _you_ try to address and solve _your_ issue acting on yourself and yourself only in a sort of "continuous quality improving" My criteria for accepting the answer is: choose the best solution (feasibility and utility) to fix one (or more) of the problems of the list. Of course, selecting an error is not a vote on our skills: maybe we are hyper professional programmers and we lose ten minutes only every year or we are terribly inefficient, losing a couple of days a week: reasons for inefficiency could be really the same - but in a different scale. A possible list:   * Plain error in the names (variables, functions).    * Inability to see the obvious in your code. Misreading. Lack of concentration.   * Trying to use a technology you have not mastered.   * Errors with data types.   * Time required to understand your previous code or your documentation.   * Trying to do something more than requested because you enjoy it    * Using solutions more complicated than required because you enjoy it.   * Plain logical errors.   * Errors due to your fault in communications.   * Distraction My first personal issue: "Trying to use a technology you do not master." I have to use daily several technologies and I often need to spend significant time correcting code because my assumptions were plainly wrong. Reasons for this: production needs put high pressure and make difficult to find the time to learn. I try to address this reading technical books - as many as I can - even if this actually consumes a lot of time.


Does increasing the number of classes increase code complexity?

To illustrate the question, let's say we have two programmers of comparable skill that both solve the same problem. The code they turn out has roughly the same lines of code, but one programmer uses 5 classes while another programmer uses 20. Both sets of code get comparable wtfs per minute in code review, implying that the code is not hard to follow and doesn't do anything silly. Is the code with 20 classes more complex than the code that utilizes 5?


Sharing eBooks within large development teams

We have a few hundred developers, and want to legally share eBooks in the same vein we used to share hard copy books (someone buys it and it ends up on the bookshelf). Has anyone solved this in a novel way? I understand there are subscription options available that license them to you but I want something that is as easy and cheap as our previous method.


can gpl code contain more restrictively licensed code? (CC BY-NC-ND 3.0)

There is a wordpress theme I am modifying to create my own derived work. This original wordpress theme has the GPLv2 licence in it's root directory, so I assume that the entire theme is GPL code. There is a particular php file which has the following written in its first few lines:               // This code is protected under Creative Commons License: http://creativecommons.org/licenses/by-nc-nd/3.0/      Is that legal for them to make a part of the code under a more restrictive license? The CC license referenced is more restrictive because it prohibits derivative work, but that is exactly what I am doing is making a derivative work. So here are my two questions:   * By having the full GPL (version 2) licence in the root of the theme's directory, is that a legally binding way of saying that the code is licensed under the GPL2?   * Is that legal for them to make that file licensed under that particular CC license? Ultimately, what I care about is this: I want to make sure that what I am doing is technically legal :) EDIT: None of the source files actually _say_ that it is under GPL; except the theme does include jQuery and jQuery plugins (under MIT and GPL2) as well as thumb.php which explicitly says it is under GPL2.


Is there a common mathematical symbology for collections?

I am being asked to define several of my algorithms in mathematical terms to describe my work to a customer. I am trying to determine if anybody knows whether common operators for collections like sequences, lists, tuples, etc have been defined. If so, is there a good reference that I could be pointed to. Thanks. I am interested in the actual symbols used. I am wondering if the following would make sense or be appropiate to anybody. Given two sequences (or strings): S = (A, B, C) and T = (A, D, H) In my mind, the intersection of these sequences would look like S ∩ T = (A) and the union of these sequences would be S ∪ T = (A, B, C, A, D, H)


Is there a term for "Use procedures that execute a single task"?

I'm having a discussion with a fellow developer, and I'm trying to argument this in something like a short "term". SoC (Separation of Concerns) is pretty straight forward design practice, but it dwells deeper. If we want to pick on it's deep corners, we can Google it and there are plenty of articles that pop up, and after taking a glimpse, we know a lot more, and might find some examples. But, what about "Use procedures that execute a single task"? That's also a great design principle to use when writing applications and it becomes more and more rewarding, the larger the application gets. Is there a term for _Use procedures that execute a single task_?


Securing credentials passed to web service

I'm attempting to design a single sign on system for use in a distributed architecture. Specifically, I must provide a way for a client website (that is, a website on a different domain/server/network) to allow users to register accounts on my central system. So, when the user takes an action on a client website, and that action is deemed to require an account, the client will produce a page (on their site/domain) where the user can register for a new account by providing an email and password. The client must then send this information to a web service, which will register the account and return some session token type value. The client will need to hash the password before sending it across the wire, and the webservice will require https, but this doesn't feel like it's safe enough and I need some advice on how I can implement this in the most secure way possible. A few other bits of relevant information:   * Ideally we'd prefer not to share any code with the client   * We've considered just redirecting the user to a secure page on the same server as the webservice, but this is likely to be rejected for non-technical reasons.   * We almost certainaly need to salt the password before hashing and passing it over, but that requires the client to either a) generate the salt and communicate it to us, or b) come and ask us for the salt - both feel dirty. Any help or advice is most appreciated.


Would experience in multiple programming languages/frameworks assist one in becoming a software architect?

Would it be useful to have experience in multiple programming languages/frameworks/stacks when applying for a software architect role? For example, combining experience in C#/.NET with Java/J2EE. How valuable would the above be, in this context?


When is method overloading appropriate?

Suppose I am working on an existing, reasonably large system. I have an object, `myObject` of class `MyClass` (for the example's sake, suppose I'm working in Java). `myObject` is a composition containing a `Collection`, say, a `List` and other objects which (I think) are irrelevant. It contains delegate methods which just serve to call upon the methods of the `List` it is composed of, in order to ensure the `List` it has is not exposed (sorry if I've got my terminology wrong). Let's say that this `List` is a `List<String>` but, for some reason, the main access method is a mask method for class `SomeOtherClass`. If I wanted to insert a new value pair into my `List`, then I'd have an object of `SomeOtherClass` called `someObject`. I'd call `myObject.insert(someObject)` and inside the `insert` method there would be some magic that would retrieve a `String` to put into the `List<String>`. Supposing now that I've only got a `String` value, and no `SomeOtherClass` object to insert. Assuming I can't modify the `insert` method because it would break everything in this system. Then should I overload the `insert` method? Or should I create a new object of `SomeOtherClass` every time I want to call `insert`? I guess if I did overload it, it would look something like this...               public void insert(String s) {         ...     }          public void insert(SomeOtherObject obj) {         this.insert(obj.magicStringMethod());     }      (This example is a contrived puzzle based upon a similar (slightly more complex) situation regarding overloading that I encountered yesterday. I'll expand it if there's anything that was unclear) Would this be an appropriate place to overload a method? If not, when should I overload a method?


What's the difference between overloading a method and overriding it in Java? Is there a difference in method signature, access specifier, return type, etc.?


Differences between Dynamic Dispatch and Dynamic Binding

I've been looking on Google for a clear diffrentiation with examples but couldn't find any. I'm trying to understand the differences between Dynamic Dispatch and Dynamic Binding in Object Oriented languages. As far as I understand, Dynamic Dispatch is what happens when the concrete method invoked is decided at runtime, based on the concrete type. For example:               public void doStuff(SuperType object){         object.act();     }      `SuperType` has several subclasses. The concrete class of the object will only be known at runtime, and so the concrete `act()` implementation invoked will be decided at runtime. However, I'm not sure what Dynamic Binding means, and how it differs from Dynamic Dispatch. Please explain Dynamic Binding and how it's different from Dynamic Dispatch. Java examples would be welcome.


Equivalence class for this requirement

The automated bell system of Stateless University should ring every hour during Mondays, Wednesdays, and Fridays. It should ring every 90 minutes during Tuesdays and Thursdays, and does not ring at all during weekends So the equivalence classes for these are: Mondays, Wednesdays, Fridays Tuesdays and Thursdays Saturdays and Sundays 90 minutes 60 minutes Am i right?? or am i missing something?


Understanding the bridge design pattern

I do not understand the "bridge" design pattern at all. I have gone through various web sites, but they haven't helped. Can anybody help me in understanding this?


How to include licenses for third-party Maven dependencies?

I'm producing a binary distributable for my Java project. I'm releasing it in two ways:   1. Maven Central   2. Zipped distributable on Google code My project is licensed under the Apache 2.0 license. I use a small number of third-party parties, one of which is MIT licensed. I believe it's my obligation to make users of my project aware of the license contents, based on the following text from the license: > The above copyright notice and this permission notice shall be included in > all copies or substantial portions of the Software. How am I best to reference this within my source and my distributables? I'm currently thinking:   1. My source files needn't reference anything. They just include my Apache 2.0 boilerplate notice.   2. I add a LICENSE.txt file at the root of my project including the Apache 2.0 license text.   3. For my zipped distributable, I need to also add _something_ that indicates a component is MIT licensed. Perhaps a NOTICE file?   4. For my Maven Central distribution, I needn't do anything as my artifact just declares its dependencies, but doesn't actually include them. Does this seem like a valid plan? If so, can anyone advise how to accomplish point 3.


How should you TDD a Yahtzee game?

Let's say you're writing a Yahtzee game TDD style. You want to test the part of the code that determines whether or not a set of five die rolls is a full house. As far as I know, when doing TDD, you follow these principles:   * Write tests first   * Write the simplest thing possible that works   * Refine and refactor So an initial test might look something like this:               public void Returns_true_when_roll_is_full_house()     {         FullHouseTester sut = new FullHouseTester();         var actual = sut.IsFullHouse(1, 1, 1, 2, 2);              Assert.IsTrue(actual);     }      When following the "Write the simplest thing possible that works", you should now write the `IsFullHouse` method like this:               public bool IsFullHouse(int roll1, int roll2, int roll3, int roll4, int roll5)     {         if (roll1 == 1 && roll2 == 1 && roll3 == 1 && roll4 == 2 && roll5 == 2)         {             return true;         }              return false;     }      This results in a green test but the implementation is incomplete. Should you unit test every possible valid combination (both of values and positions) for a full house? That looks like the only way to be absolutely sure that your `IsFullHouse` code is completely tested and correct, but it also sounds quite insane to do that. How would you unit test something like this? ## Update Erik and Kilian point out that using literals in the initial implementation to get a green test might not be the best idea. I'd like to explain why I did that and that explanation does not fit in a comment. My practical experience with unit testing (especially using a TDD approach) is very limited. I remember watching a recording of Roy Osherove's TDD Masterclass on Tekpub. In one of the episodes he builds a String Calculator TDD style. The full specification of the String Calculator can be found here: http://osherove.com/tdd-kata-1/ He starts with a test like this:               public void Add_with_empty_string_should_return_zero()     {         StringCalculator sut = new StringCalculator();         int result = sut.Add("");              Assert.AreEqual(0, result);     }      This results in this first implementation of the `Add` method:               public int Add(string input)     {         return 0;     }      Then this test is added:               public void Add_with_one_number_string_should_return_number()     {         StringCalculator sut = new StringCalculator();         int result = sut.Add("1");              Assert.AreEqual(1, result);     }      And the `Add` method is refactored:               public int Add(string input)     {         if (input.Length == 0)         {             return 0;         }              return 1;     }      After each step Roy says "Write the simplest thing that will work". So I thought I would give this approach a try when trying to do a TDD-style Yahtzee game.


Securely changing system configuration from a web application

I need to write a web application that acts as a configuration interface for some system services. Meaning it will probably change some kind of configuration file and has to restart (linux) system services. I was wondering how to design such a thing in a secure way. It is very similar to router web interfaces and such, so I had a quick look at some of these as well as webmin. Basically, I could run the web service/CGI-Script/etc. with root privileges, filter the input as good as possible and just write to the system and execute whatever program I'd like. This does not seem very secure. I would like to achieve some kind of privilege separation. Maybe having my web app run as unprivileged user and pass the Information to some privileged daemon/service, i.e., having a Python web app writing the infos to a file and notifying the daemon or use unix sockets to communicate with this backend program. Any ideas or experience you could share regarding this issue? Thank you very much in advance.


Using A Debugger (An Interview Question)

During a phone interview I had, the interviewer was asking me questions about my previous job as a web developer. After discussing how I had used Eclipse to write Java Servlets, he asked me the question whether I was familiar with the debugger, "you know, stepping through code, setting breakpoints, et cetera." I responded by saying something along the lines that I use the debugger almost every day at work in order to track down any bugs that may arise. Looking back now, it sounds like saying "I use the debugger almost every day" makes it seem like I write poor code that I constantly have to debug. So, my question is: **Is using the debugger frequently a sign of bad programming, or just a natural part of the development process?**


Are Domain Objects in Domain Driven Design only supposed to be write-only?

I've been reading about Domain Driven Design for almost two years and have been cautiously been introducing some concepts in to my daily work or at least making plans for how things I do regularly could be done within a Domain Driven Design. One conclusion that I've beginning to come to especially in response to reading more about Event Sourcing and Command Query Responsibility Segregation (CQRS) that perhaps domain objects are intended to be used only for write purposes. To be more clear, it seems that what people are subtly suggesting in much of the documentation I've read that the domain objects are responsible for doing domain centric operations/calculations, validation, and then are there mainly to provide a road to persistence through the infrastructure provided within a Repository implementation. Although I do like the fact that this may simplifies the domain model greatly as it cuts out the responsibility of exposing state. If it is indeed correct that domain objects are mainly to be used as write- only objects then that raises some questions for me that I'm hoping somebody could answer.   1. How does one perform unit tests on an object that has setters, or methods that modify the state of an object but that provide no outwardly public interface to read the state from such as property getters in C#? Is it okay to expose state solely for the purpose of making that object testable?   2. How does one show to a user the results of calculations or operations done in the domain without having to persist them and then pull the results from persist store outside of the context of the domain? Is it okay to expose state solely for the purpose of showing results. Is the rule of thumb that the only property getters (get accessors) should be ones that are also writable in the domain? Or said differently should readonly properties be the only thing to avoid since they are only there for read purposes and thus do not play a a necessary role in the actual domain model? Related material:   1. TDD, DDD and Encapsulation


Small C Projects

I am a professional developer who generally uses high level, memory managed languages. However, I am growing more and more ashamed at my incompetence at low level languages like `C`, which I haven't used since my Systems courses in college. I want to relearn some of the more distinct parts of the `C` language, but I don't have a large amount of time to devote to hobby work. What are some small projects that would highlight the low level aspects of the language to help me rekindle my knowledge?


What methods exist for assessing an organisation's development capability?

I have a bit of a challenge at work at the moment. Presently (and in fact, for some time now), we have been experiencing the following problems with some in- house maintained applications:   * Defects (sometimes quite serious) being released into production;   * The Customer (that is, the relevant business unit) perpetually changing their minds (or appearing to do so) about what issue to work on next;   * A situation where everyone seems to be in a "fire-fighting" mode a lot of the time;   * Development staff responding to operational requests from business users; ("operational" here means something that needs to be done in order to continue with business, or perhaps just to make a business user's life a little less painful, as opposed to fixing a bug in the application, or enhancing the application); Now I'm sure this doesn't sound particularly new or surprising to most of the participants on this Q&A site and no prizes for identifying the "usual suspects" when it comes to root causes. My challenge is that I have to persuade the higher-ups to do _uncomfortable_ things in order to address all of this. The folk I need to persuade come from a mixture of the following two cultures:   * Accounting;   * IT Infrastructure. I have therefore opted for a strategy that draws from things with-which folk from such a culture would be most comfortable (at least, in my estimation), namely: numbers and tangibles. Of course modern development practitioners know all too well that this sort of thing isn't easily solved using an analytical mindset (some would argue that _that_ mindset is, in fact, entirely inappropriate). Never-the-less, this is the dichotomy with-which I am faced, so that's the stake that I've put in the ground. I would like to be able to do research and use the outputs to present findings in the form of metrics and measures. I am finding it quite difficult, though, to find an agreed-upon methodology and set of templates for assessing an organisations development capability--the only thing that seems applicable is the Software Engineering Institute's Capability Maturity Model. The latter, however, seems dated and even then rather vague. So, the question is: How do I go about assessing our organisation's software engineering capability such that I can present the findings in a way that is concrete and references a generally accepted industry standard? **UPDATE:** Doing a little more research, I came across this little oasis \- a CMMI FAQ worded in laymans terms--just the sort of useful resource that one needs in this area ... and _free_.


Embedded Model Designing -- top down or bottom up?

I am trying to learn RoR and develop a webapp. I have a few models I have thought of for this app, and they are fairly embedded. For example (please excuse my lack of RoR syntax):               Model: textbook         title:string         type:string         has_many: chapters          Model: chapter         content:text         has_one: review_section          Model: review_section         title:string         has_many: questions         has_many: answers , through :questions          Model: questions        ...          Model: answers             ...      **My question is, with the example I gave, should I start at the top model (textbook) or the bottom most (answers)?**


TRS-80 Color BASIC as an inspiration for a new programming language

For a time now I have been wanting to make my own programming language. I'm 17 and the only language I know is Color BASIC. I know that compared to today's complicated languages, it's pretty weak. But I was wondering if it would be hard to create a language that is kinda like color BASIC/BASIC and how would I start it? What to do or what do I need to do to learn how to make my own programming language?


Should I have unit tests for known defects?

If my code contains a known defect which should be fixed, but isn't yet, and won't be fixed for the current release, and might not be fixed in the forseeable future, should there be a failing unit test for that bug in the test suite? If I add the unit test, it will (obviously) fail, and getting used to having failing tests seems like a bad idea. On the other hand, if it is a known defect, and there is a known failing case, it seems odd to keep it out of the test suite, as it should at some point be fixed, and the test is already available.


Is the version problem a nightmare in programming?

Let say you are building an app and you are using the latest library verion from a third party (say `ver2.jar`). Then you saw an example written 2 years ago, but that example uses the `ver1.jar` Now in `ver1.jar`, there is `web.method1()`, but in `ver2.jar` there is no such method. Instead, in `ver2.jar` you have `web.getOtherMethod.method1();` You ran your app with `ver2.jar` and found a lot of missing classes, and lots of errors. So what are you going to do to solve the incompatibility? I think the version problem is really a nightmare because it is unstructured and you do not actually understand what is going on. Also, why changed the location of the method in `ver2.jar` so differently like that?


.NET DataSource binding for legacy SQL Server DB with undefined relationships

I'm designing a utility that will load data into a legacy SQL Server Database. I've been trying to mock up a simple WinForms utility with C# using the DataSource connectors (Tried a straight ORM Entity Framework approach first, but was having problems as the db follows few conventions). I am having particular difficulty in establishing parent/child relationships and displaying them with data grids (ie, click on this row and the child grid gets filtered). Some examples of database challenges:   * No foreign keys with referential constraints. What would normally be a foreign key shows up as part of the Primary composite key in "child" table. Sometimes with different data types (ie, double instead of long)   * Sometimes a composite key is used on a parent table to define the entity, but only one of those composite fields shows up in a "child" table. `{dbo.Parent Key = [ParentID, ParentGroupID, OtherField], dbo.Child Key = [ChildID, ParentID]}`   * Naming conventions are non existent. Things like this make it difficult to bind data sets to parent/child data grids, and use some of the other out of the box functionality that .NET offers. How to address above challenges? I tried looking at some older ADO.Net tutorials but sometimes methods have changed or are no longer available...


Circular dependency and object creation when attempting DDD

I have a domain where an `Organization` has `People`. **Organization Entity**               public class Organization {         private readonly List<Person> _people = new List<Person>();              public Person CreatePerson(string name) {             var person = new Person(organization, name);             _people.Add(person);             return person;         }              public IEnumerable<Person> People {             get { return _people; }         }     }      **Person Entity**               public class Person     {         public Person(Organization organization, string name) {             if (organization == null) {                 throw new ArgumentNullException("organization");             }                  Organization = organization;             Name = name;         }              public Organization { get; private set; }            public Name { get; private set; }     }      The rule for this relationship is that a `Person` must belong to exactly one `Organization`. The invariants I want to guarantee are:   1. A person must have an organization     * this is enforced via the Person's constuctor   2. An organization must know of its people     * this is why the Organization has a `CreatePerson` method   3. A person must belong to only one organization     * this is why the organization's people list is not publicly mutable (ignoring the casting to List, maybe `ToEnumerable` can enforce that, not too concerned about it though) What I want out of this is that if a person is created, that the organization knows about its creation. However, the problem with the model currently is that you are able to create a person without ever adding it to the organizations collection. Here's a failing unit-test to describe my problem               [Test]     public void AnOrganizationMustKnowOfItsPeople()     {         var organization = new Organization();         var person = new Person(organization, "Steve McQueen");              CollectionAssert.Contains(organization.People, person);     }      What is the most idiomatic way to enforce the invariants and the circular relationship?


VB6 general search form

I'm working on an old vb6/access2003 app which is used to handle orders, bills of materials and that sort of things. I'm thinking about creating a form that I call every time the users needs to search for something. This should work like these:   * Click on the field to complete, let's say name of a buyer   * Open new form, search for the client and click on it   * Return the name of the buyer to the previous form (probably the header of the order) So, I would need to pass to the new form something that identify the type of search I have to do (so what access table to open) and return some values. Is my idea correct or there something better? I would like to use only one form for all the searches, now the app works with a lot of msflexgrid for every form.


Developing a Configurable Pricing Program

The organization I work at has some interesting requirements when it comes to pricing for online commerce. Currently the developers write different 'pricing rules' and those rules can be applied to our items based on attributes of the items. > For Example:   >  INPUTS: [cost, sug_retail, discontinued, warehouse_qty, orderable_qty, > brand, type, days_available, shipping_rate, weight, map_protected, > map_discount]   >  MATCH: brand=x, warehouse_qty > 1, discontinued=True, map_protected=False   >  SET: retail_price = (sug_retail * 0.95), offer_price1 = (cost * 1.25 + > shipping_rate) I am looking to allow the merchandising team to have more control over the pricing and formulas - they are afterall technical enough to write excel formulas. I've been looking at writing a desktop application that uses something like numexpr http://code.google.com/p/numexpr/ or http://sympy.org/en/index.html to allow non-programmers to integrate their own logic into our pricing backend. We have multiple price-tiers we have to set, for multiple markets, so an elegant solution is needed. It's getting frustrating for the dev team to continually tweak/manage all of the pricing rules (we sell over 200 brands in 3 markets). `My question is`; does this seem like a decent approach? Can you think of a better way to parse string-mathematical-grammer? Can you think of a different way for users to provide formula's to integrate into a automated pricing system? Does anyone know of any examples of existing applications that do this? Excel, and Access are out of the question - the volume of data we manipulate has already proven the need to automate it - now we just need some visibility into that automation.


Is MongoDB appropriate for systems that will be likely to change?

I've been using MongoDb (mainly with Meteor) and for me, it has been a great way to mock up prototypes and proof of concepts quickly. I'm just wondering, after building the initial product, if your product is likely to grow and change, is it a good idea to stick with mongoDb? Cause it seems like with MongoDb, you need to know a lot about how you're going to use the data upfront. From my experience only, I seemed to constantly be trying to decide whether a datatype should be a document in its own right or a sub-document. Making it a document gives it flexibility, but if you have all your datatypes as documents, well then you pretty much just have an SQL database with foreign keys that have no foreign key constaints. Making it a subdocument makes things perform better whilst being convenient - you don't need to join tables (which you seem to have to do manually) - but the problem seems to be if you need to query that datatype outside the context of the parent, it's very hard. So for example, if I'm building a website with chatrooms, I might have two datatypes - chatrooms and textEntries. Chatroom will be its own document. But textEntries can either be a document in its own right or a subdocument within Chatroom. If I make TextEntries a document, then I would need to manually keep track of the relationship between chatroom and textEntries which defeats the purpose of using mongoDB at all. If I make TextEntries a subdocument, this will make things easier but what if later on, I have a new requirement where I want to search across all TextEntries in all chatrooms for a particular word? With a prototype, I know exactly what I'm building so these decisions tend to be based on just getting the product working. But longer term, I wouldn't know how or in what way I'm going to want to query the data so in light of that, would I be better off just moving to an SQL database?


Which style to use for unused return parameters in a Python function call

Is there any recommended/generally accepted coding style for handling situations where a function returns a tuple of values but only one of those values is used afterwards (note that this is mostly meant for library functions I can't change -- writing a wrapper around the call is probably a bit of overkill…)? Instead of doing               a, b, c = foo()      and then just not using `a` and `b`, which of the following variants should be preferred (or is there another one?): ## Variant 1 (underscore)               a, _, _ = foo()      (which is very clear and simple but might clash with `_ = gettext.gettext` used in many applications that use translation) ## Variant 2 (dummy name)               a, unused, unused = foo()      (not very appealing, I think, same goes for other names like `dummy`) ## Variant 3 (index)               a = foo()[0]      (to me the `()[0]` looks un-pythonic…)


controlling an object through another object?

Today I've seen the following pattern: you have an object A and an object B. Object B accepts a pointer to A at its constructor. Once B is created, there's a method B.doCalc() that performs a calculation (internally using A's information). The result is obtained with method B.getResult(). In order to perform another calculation, A is modified, and B.doCalc() is called again. What is your opinion on this choice ? I would have designed it differently, but I want to hear your voice. **Edit** : note that my main objection is to modify A to have a different result from B, without touching B. Although similar, I think that just this discipline expresses a much better feeling of what's going on. Instead of               a = new A     a.whatever = 5     b = new B(a)     b.doCalc()     res = b.getResult()     a.whatever = 6     b.doCalc()     res = b.getResult()      You get the a pointer object from b itself.               a = new A     a.whatever = 5     b = new B(a)     b.doCalc()     res = b.getResult()          a = b.getAPointer()     a.whatever = 6     b.doCalc()     res = b.getResult()      because it makes more explicit the fact that a is taken from b and then modified. I still don't like it, though... **Edit 2** : one of the reasons why B accepts A at constructor is because it has to setup internal data for the calculation. These data   * depend on the nature of A   * they must be read from the disk, which may be slow   * B may be run many times on the same A, albeit slightly modified A. The nature of these changes would not invalidate B's internal data. We don't want to re-load the info every time doCalc() is invoked, nor run the risk to run a doCalc(a) with B's internal data being inconsistent with the submitted A.


Is there any evidence that graphic interfaces tend to mess with SVN- and Git-repositories?

In my company I am faced with assertion that graphic interfaces for VCSs like SVN or (especially) Git tend to mess repositories - especially regarding branching. Being a passionate Windows and GUI user, I have a hard time believing this is true. For Git especially, I accept that some moves are too complex for conduction via a GUI. But what is the real background of this accusation?


What are the benefits of using both Scalate and Jade?

I recently did a little "tool roundup": If I were to program a website in Scala and Coffeescript, what frameworks would I go for? I came across this great presentation: http://www.slideshare.net/mraible/html5-with-play-scala-coffeescript-and-jade- devoxx-2011 The only problem is that I couldn't find a complete version with commentary. Thus I'm left wondering: Why would anyone combine Scalate and Jade ? The presentation is very inspiring and refers to a lot of interesting resources. Nevertheless there's little information how they get along. I always thought both Jade and Scalate were essentially a way to dynamically generate HTML5 and in fact shared the same "territory". my question: What are the benefits of using both Scalate and Jade ?


Is lack of whitespace a sign of a cargo cult programmer?

Eric Lippert has written about cargo cult programming, and Steve McConnell has tackled the subject from a Software Engineering point of view. Eric provides a fairly succinct description: > They understood the **form** but not the **content**. There are lots of > cargo cult programmers -- **programmers who understand what the code does, > but not how it does it**. Therefore, they cannot make meaningful changes to > the program. They tend to proceed by making random changes, testing, and > changing again until they manage to come up with something that works. This isn't to say that cargo cult programmers are _bad_ , per se, just that they approach coding differently than others. Their goal is to get things done; not understand why the code is doing something. This Programmers question discusses formatting and "sloppy programmers", but it's different in that it doesn't focus on whitespace and it's clear the programmers are considered bad. Much has been written on Programmers about using comments as well as the use of whitespace. The general acceptance is to use comments to explain " _why_ not _what_ " and to use whitespace to separate out logical constructs within the code. To borrow from traditional writing, whitespace provides paragraphs of text to read instead of facing a wall of text. It separates out key concepts. * * * I'm in the middle of re-factoring some code originally written by a cargo cult programmer, and one of the challenges I have encountered is consistent lack of whitespace to indicate context or concepts within the program. Looking over the code, it's clear to me the developer didn't understand the why or the context behind the task they were assigned. Ignoring the incorrect copy & paste issues, the code just doesn't read well because of disjointed flow amongst statements. I realize that use of whitespace is biased by the original language that someone first learns, but I can't help but wonder if "illogical" use of or lack of use of whitespace is an indicator of a cargo cult programmer. **My question:** \-- Is there a correlation between not using whitespace correctly and the odds of the person being a cargo cult programmer? * * * _Addendum_ : I realize my question is subjective, but I think it falls into the good subjective category because this question is best answered with a "why" type answer rooted in experience and / or potentially some amount of research. Likewise, I believe there is an answer to the question, and I have focused the question on identifying if there is a correlation while avoiding any potential ranting. In my question, I am using the broader definition of cargo cult programming as defined by Eric. Cargo Cult Programmers mix and match forms because the snippet they took appears to solve the problem at hand. Yet they do not understand why the sections they copied resolve the issue. In this context, I don't see Cargo Cult Programming as attempting to imitate another person's style, but rather just trying to "fix" whatever the problem at hand is with whatever code they can find.


Visual Studio Notepad++ Sync Color Schemes

Is there an easy way to sync the color scheme/theme between visual studio 2008/2010 and notepad++? I would like to have it so that I could point visual studio and notepad++ to the same document and maintain the styles just through that.


How do lines of code get executed by the CPU?

I'm trying to really understand how exactly a high-level language is converted into machine code and then executed by the cpu. I understand that the code is compiled into machine code, which is the low level code that a CPU can use. If I have an assignment statement say:               x = x + 5;     y = x - 3;      Does the CPU execute each line one at a time? So it will first execute the x = x + 5; instruction and then the next instruction the CPU will execute is the y = x- 3; I'm really trying to understand the execution process and how the code I write is actually execute by the CPU.


Studies on code documentation productivity gains/losses

After much searching, I have failed to answer a basic question pertaining to an assumed known in the software development world: WHAT IS KNOWN: Enforcing a strict policy on adequate code documentation (be it Doxygen tags, Javadoc, or simply an abundance of comments) adds over-head to the time required to develop code. BUT: Having thorough documentation (or even an API) brings with it productivity gains (one assumes) in new and seasoned developers when they are adding features, or fixing bugs down the road. THE QUESTION: **Is the added development time required to guarantee such documentation offset by the gains in productivity down-the-road (in a strictly economical sense)?** I am looking for case studies, or answers that can bring with them objective evidence supporting the conclusions that are drawn. Thanks in advance!


What source control do i want for large project in average company?

I know git is great for open source projects. But i was wondering. For a company with 20 programmers on a 1 year project which source control is desirable? From what i heard GIT uses pulling, wouldnt it be less then desirable to need to go through someone else to get your changes in the main trunk? especially when everyone is working at the same time? Thats just of an example i wonder. I know how to use svn but even at my last job we didnt use it on our projects since everything was done in php and typically standalone 1 week projects. I just had svn for my local code and didnt need to use it with others. So what are good source controls and specifically why is it good for this?


Why do many PHP Devs hate using isset() and/or any of PHP's similarly defensive functions like empty()?

Over on stackoverflow, I see this issue crop up all the time:   * E_NOTICE ?== E_DEBUG, avoiding isset() and @ with more sophisticated error_handler   * How to set PHP not to check undefind index for $_GET when E_NOTICE is on?   * How to stop PHP from logging PHP Notice errors   * How do I turn off such PHP 5.3 Notices ? Even Pekka (who offers a lot of solid PHP advice) has bumped against the dreaded `E_NOTICE` monster and hoped for a better solution than using `isset()`: isset() and empty() make code ugly Personally, I use `isset()` and `empty()` in many places to manage the flow of my applications. For example:               public function do_something($optional_parameter = NULL) {         if (!empty($optional_parameter)) {             // do optional stuff with the contents of $optional_parameter         }         // do mandatory stuff     }        Even a simple snippet like this:               if (!isset($_REQUEST['form_var'])) {         // something's missing, do something about it.     }      seems very logical to me. It doesn't look like bloat, it looks like stable code. But a lot of developers fire up their applications with `E_NOTICE`'s enabled, discover a lot of frustrating "uninitialized array index" notices, and then grimace at the prospect of checking for defined variables and "littering" their code with `isset()`. I assume other languages handle things differently. Speaking from experience, JavaScript isn't as polite as PHP. An undefined variable will typically halt the execution of the script. Also, (speaking from _inexperience_ ) I'm sure languages like C/C++ would simply refuse to compile. So, are PHP devs just lazy? (not talking about you, Pekka, I know you were refactoring an old application.) Or do other languages handle undefined variables more gracefully than requiring the programmer to first check if they are defined? (I know there are other `E_NOTICE` messages besides undefined variables, but those seem to be the ones that cause the most chagrin) **Addendum**   From the answers so far, I'm not the only one who thinks `isset()` is not code bloat. So, I'm wondering now, are there issues with programmers in other languages that echo this one? Or is this solely a PHP culture issue?


Want to learn one of those NoSQL databases, looking for advice on which one to check out

As someone who first encountered relational databases and SQL at uni in the early 90's, and who has spend a goodly slice of a fifteen year career working with MS SQL Server, I'm probably a textbook example of the people who, according to NoSQL enthusiasts, "have SQL as my hammer and see everything as a nail." So, to broaden my horizons, I'd like to do some sort of mess-around project using one of these NoSQL databases, as a learning experience. Question is, though, which one should I mess around with?   * MongoDB seems to be one of the best known and most respected   * Raven DB? It's getting some buzz and Hibernating Rhinos have made stuff I respect.   * CouchDB, since it's part of the Apache project?   * something else? I don't have a problem to solve, a project to complete, or a client to satisfy, so I'm not asking which might be best suited to any particular purpose. Just recommendations based on quality, potential, and perhaps most importantly, availability of good docs, guides, tutorials, screencasts, etc. Oh, C# / .NET is my field of expertise, so looking for something which fits that well, e.g. has C# examples in its documentation. Any tips?


PHP ORM style of querying

Ok so I have made an ORM library for PHP. It uses syntax like so: *(assume that $business_locations is an array)*               Business::type(Business:TYPE_AUTOMOTIVE)->               size(Business::SIZE_SMALL)->               left_join(BusinessOwner::table(), BusinessOwner::business_id(), SQL::OP_EQUALS, Business::id())->               left_join(Owner::table(), SQL::OP_EQUALS, Owner::id(), BusinessOwner::owner_id())->               where(Business::location_id(), SQL::in($business_locations))->               group_by(Business::id())->               select(SQL::count(BusinessOwner::id());      Which can also be represented as:               $query = new Business();     $query->set_type(Business:TYPE_AUTOMOTIVE);     $query->set_size(Business::SIZE_SMALL);     $query->left_join(BusinessOwner::table(), BusinessOwner::business_id(), SQL::OP_EQUALS, $query->id());     $query->left_join(Owner::table(), SQL::OP_EQUALS, Owner::id(), BusinessOwner::owner_id());     $query->where(Business::location_id(), SQL::in($business_locations));     $query->group_by(Business::id());     $query->select(SQL::count(BusinessOwner::id());      This would produce a query like:               SELECT COUNT(`business_owners`.`id`)     FROM   `businesses`            LEFT JOIN `business_owners`              ON `business_owners`.`business_id` = `businesses`.`id`            LEFT JOIN `owners`              ON `owners`.`id` = `business_owners`.`owner_id`     WHERE  `businesses`.`type` = 'automotive'            AND `businesses`.`size` = 'small'            AND `businesses`.`location_id` IN ( 1, 2, 3, 4 )     GROUP  BY `businesses`.`id`        _Please keep in mind that the syntax might not be prefectly correct (I only wrote this off the top of my head)_   * Any way, what do you think of this style of querying?    * Is the first method or second better/clearer/cleaner/etc?   * What would you do to improve it?


How to approach people you've found through internet with similar programming interests?

I've recently really dived into Ruby/Rails and I'm falling in love. I have a gut feeling this might be something that could last for a while. What I've been missing is interaction with people who are as passionate about Ruby, Rails and things closely related to these. I live in a relatively small city, but was able to find five local people through a RoR website. Weekly meetups with Macs, beer and bro-love rushed through my mental theater. Seriously though, I have no clue how I could approach these people. I have their e-mail addresses. Any advice?


game unpublished due to copyright issue

I have made a simple batman puzzle game using some batman posters from the internet. Now there are apps on google play store and windows phone store that also feature these kind of batman pictures and they have'nt been pulled off , But my app from play store has been pulled off because of this copyright thing . How do I publish my app to play store and windows phone store without any copyright issues ?


Regular Expressions and Language Generators

I have few CS textbooks with me which discuss languages, well actually 2 plus old course notes supplied a few years ago. I have been searching the web too any only seem to come up with vague responses just like the text books I have. My question is about language recognisers verses generators. I get the overriding principle of a recogniser. That it analyses a language and is able to determine nay or yay if a String belongs to a language. This is at least what I have picked up from the books and notes. However, it's much more complex than that is it not? A tokeniser and syntax analyser (which I assume to be recognisers) do not just say yes or no, they also say where don't they...? However, language generators. No one seems to be very clear about what they are. The typical description I get is For example Sebasta's Concepts of programming languages says 'A language generator is a device that can be used to generate the sentences of a language. We can think of a generator as a push button that produces a sentence of a language every time it is pressed.' Seriously? That's it?? Your kidding right.... I read that Regex is an example of a Generator, then why when people talk of generators to they not talk of the inputs. For example Regex has a target String, and the Regex with defines both the accepted alphabet and it's grammar rules. Can someone provide for me a clearer distinction of what a recogniser is?


Isn't open source bad for developers themselves?

Why do programmers even like the idea of open source? I am not talking about the creators of those projects, of course they get fame, but I am talking about the industry in general, why are we so fond of the open source concept when it brings so many bad impact to the industry? First, projects like wordpress and other CMS, they take away a lot of freelance jobs where clients want a blog or a simple website. Secondly, projects like Rails and other libraries and API's, they put a lot of programmers out of work, and make the demand for programmers smaller, because now with these open source API's, one programmer can do things that 10 programmers used to do. And finally, with open source software such as Notepad++, now people just feel funny when you ask them to buy software. So, the question is, why do we still like open source if it kind of making us poor? Probably, my life as a programmer would be harder, but at least I can make a living out of it. But now, it's more like machine replacing human, funny thing is, we are creating those "machines" that replace ourselves. Let's say, if you invented a tool, you don't have to share it, it will still help you and your company. Even without these open source tools, other programmers will live because they still have a job that makes money.


Basic OOP Question for a Report

I'm in development of a sample project in Android for a friend's phone that keeps track of his sales. At first, one of the requirements was to create yearly reports of this sales data. This would be stuff like most profitable week, total per quarter, total per month, and even yearly total, as well as compares for previous years (about 10 things total). I created a class called YearlyReport that has all of these properties and they get populated from a database class that makes the appropriate SQL calls. This data is displayed on a statistics page, but after seeing this my friend asked me to give the viewer the ability to select different weeks and display weekly data too (3 bits of information: the total for the week, the best day in the week, the worst day in the week). So as they change weeks in the year, he wants to see weekly data appear above the yearly data. So now I need to do specific queries of weekly data, but display yearly data too. I feel really disorganized for some reason! At first I made a WeeklyReport object, and the database will say "ok for a given week W, I'll fill your WeeklyReport object and return it". Then I started wondering if I should do something smarter. Maybe combine something? Should there be inheritance? I'm missing something. Is it OK to have a WeeklyReport and YearlyReport object? Should I combine them? If I do, it's still strange because the yearly report doesn't change much unless you move to a new year (not often), but the weekly does (depending upon the date).


What happens if computer crashes after giving commit command

If we are updating a field in SQL and ALTER the row also. After giving the COMMIT command, the system is crashed. What will happen to the commands given, whether it will UPDATE and ALTER the table or not?


Dictionary vs List

So I ran into a `Dictionary<int, int>` today at work. This just seemed weird to me because I would have probably just used a `List<int>` instead. Is there a difference and would there be a use case where one structure would be preferred over the other?


Places where I can do some voluntary software development/programming work?

I asked this question due to my lack of experience which is a major problem for me when applying for a job because all the companies require 2 to 3 years of programming experience. So I am taking this voluntary work path to gain experience and have some number or technologies on my resume to satisfy the HRs requirements. Any suggestions please?


Converting lib from other language to python and Rights issue

If I take a program, and basically translate its source from some language to python, with some small changes, can I do a entirely my new lib or I have to make a "version" of the old one? would this be a copy of the first or a new lib based in the ideas of the first? **OBS: Consider the original lib is using Apache License v2** Not sure if well explained, but I can't see for now how to make it more clear.


Why is CSS3 doing animations?

Like what the title says, why are there animations in CSS3? With basis from the "rule" of separation of concerns, HTML is the content, CSS is the **_style_** , and JavaScript is the interactive component. And by interactivity, one can conclude that anything moving due to any interaction, user or non-user triggered should be covered by JavaScript, not CSS. So why did they make CSS3 capable of doing animations? Doesn't it breach the rule, which is separation of concerns? Is there anything I missed that makes animations qualified to be classified as styles rather than interaction?


Is Embedded Engineer and Firmware Engineer the same Job?

I'm looking to steer my career of Computer Scientist a little more into robotics. I've been analyzing and junior embedded positions might be a good opportunity to start. However, searching through I've seen other similar titles. My questions are:   1. Is Embedded Engineer and Firmware Engineer pretty much the same role? Please give quick examples of each if not.    2. Which other titles/positions would allow me to get started on Robotics as a developer? I could be more specific if I had the knowledge, but for now I want to get closer to the field so anything as a developer would help greatly.


What should I use as a random seed in a Brainfuck?

As I understand it, most pseudo-random algorithms work by taking one or more truly random `long`s, such as the date, time, MAC-Address, serial-number, etc., passing them through a complex series of calculations, and returning the result. However, this isn't possible in Brainf*ck. The language only has 8 valid syntax characters, but I won't bother you with a full description, which can be found here. The gist is that there aren't any functions to access system time or any other number that I can think of as a seed. I can't think of where to get good seeds to put into functions. Does anyone have any suggestions? Thanks in advance. _Note: feel free to edit this questions so that it applies to more languages; I just can't put my finger on the right word to use._


What is a "template" in Perl?

I can find all sorts of weird information about templates in Perl, but nothing about what they actually are. Are they generic types like in C++? Is it a class-like structure? Or maybe something else?


Are there any programming fonts with oldstyle figures?

I find that oldstyle (or text) figures are much easier to read in any context outside of simple assignment. Are there any low-ambiguity fonts, monospaced or proportional, that have text figures and other programming-friendly features, such as marked zeroes; aligned braces, operations, and other symbols; and bold and italic forms with identical width to regular? Note. Old-style figures are numerals which are drawn with variable ascent and descent. Typically, for example, a "0" will be slightly larger than a lowercase "o"; the "6" and "9" will have have circles that are sized and placed similar to a "0", with flags extending up and down from that.   In general, if one is trying to examine numbers as numbers (e.g. parse "8675309" as "eight six seven five three oh ni-y-ine"), the "lining" forms with unified ascent and descent are easier to read. On the other hand, multi- digit numbers written with old-style numerals have different shapes. If one is comparing columns of figures, a number like "1265" will look very different from "1285", since the former will have a flag on the "6" that sticks up far above any feature of the latter. Tabular figures are figures spaced with equal width; they may be lining or oldstyle. So all monospaced fonts have tabular figures, but most proportional fonts do not.


How to use the unit of work and repository patterns in a service oriented enviroment

I've created an application framework using the unit of work and repository patterns for it's data layer. Data consumer layers such as presentation depend on the data layer design. For example a CRUD abstract form has a dependency to a repository (IRepository). This architecture works like a charm in client/server environments (Ex. a WPF application and a SQL Server). But I'm looking for a good pattern to change or reuse this architecture for a service oriented environment. Of course I have some ideas: * * * **Idea 1: The "Adapter" design pattern** Keep the current architecture and create a new unit of work and repository implementation which can work with a service instead of the ORM. Data layer consumers are loosely coupled to the data layer so it's possible but the problem is about the unit of work; I have to create a context which tracks the objects state at the client side and sends the changes to the server side on calling the "Commit" (Something that I think the RIA has done for Silverlight). Here the diagram:               ----------- CLIENT----------- | ------------------ SERVER ----------------------          [ UI ] -> [ UoW/Repository ] ---> [ Web Services ] -> [ UoW/Repository ] -> [DB]      * * * **Idea 2: Add another layer** Add another layer (let say "local services" or "data provider"), then put it between the data layer (unit of work and repository) and the data consumer layers (like UI). Then I have to rewrite the consumer classes (CRUD and other classes which are dependent to IRepository) to depend on another interface. And the diagram:               ----------------- CLIENT ------------------ | ------------------- SERVER ---------------------          [ UI ] -> [ Local Services/Data Provider ] ---> [ Web Services ] -> [ UoW/Repository ] -> [DB]      * * * Please note that I have the local services layer on the current architecture but it doesn't expose the data layer functionality. In another word the UI layer can communicate with both of the data and local services layers whereas the local services layer also uses the data layer.               |    |      |                 |      |      |     |    | ---> |  Local Services | ---> |      |     | UI |      |                 |      | Data |     |    |                               |      |     |    | ----------------------------> |      |


Is obtrusive JavaScript ever ok?

I was thinking that if all the users of a website are required to have JavaScript enabled, Is it ok to use obtrusive JavaScript? I'm all for progressive enhancement, but what's the point when an advanced web application bounces users at the door if they have an old browser or JavaScript disabled? We have a very slim target audience, and we can tell our target audience what browser and plugins/functionality they are required to have. So my question is, is mixing JS and HTML alright in that case? Like using onclick attributes.


Different ways to see a monad

While learning Haskell I have faced a lot of tutorials trying to explain what are monads and why monads are important in Haskell. Each of them used analogies so it would be easier to catch the meaning. At the end of the day, I have end up with 3 differents view of what a monad is: **View 1: Monad as a label** Sometimes I think that a monad as a label to a specific type. For example, a function of type:               myfunction :: IO Int      myfunction is a function that whenever is performed it will yield an Int value. The type of the result is not Int but IO Int. So, IO is a label of the Int value warning the user to know that the Int value is the result of a process where a IO action has been made. Consequently, this Int value has been marked as value that came from a process with IO therefore this value is "dirty". Your process is not pure anymore. **View 2: Monad as a private space where nasty things can happen.** In a system where all the process are pure and strict sometimes you need to have side-effects. So, a monad is just a little space that is allow to you for doing nasty side-effects. In this space your are allow to escape the pure world, go the impure, make your process and then come back with a value. **View 3: Monad as in category theory** This is the view that I don't fully understand. A monad is just a functor to the same category or a sub-category. For example, you have the Int values and as a subcategory IO Int, that are the Int values generated after a IO process. **Are these views correct? Which is more accurate?**


Learn Linux System Programming by doing projects

I have only a very basic idea about linux system programming. I have not done any real projects using linux system programming. In my current company i do system admin type work. but i am more interested in Linux System Programming. I want to do some projects on my own, so that i could put those projects in my resume when i apply for joining another companies. Kindly tell me the whether there is any projects where i could learn more linux system programming by doing some real programming stuff. Please Note that i only have experience in C programming and not in Linux System Programming. But i know very basic things in linux system programming. Thanks


Is duck typing a subset of polymorphism

From Polymorphism on WIkipedia > In computer science, polymorphism is a programming language feature that > allows values of different data types to be handled using a uniform > interface. From duck typing on Wikipedia > In computer programming with object-oriented programming languages, duck > typing is a style of dynamic typing in which an object's current set of > methods and properties determines the valid semantics, rather than its > inheritance from a particular class or implementation of a specific > interface. My interpretation is that based on duck typing, the objects methods/properties determine the valid semantics. Meaning that the objects current shape determines the interface it upholds. From polymorphism you can say a function is polymorphic if it accepts multiple different data types as long as they uphold an interface. So if a function can duck type, it can accept multiple different data types and operate on them as long as those data types have the correct methods/properties and thus uphold the interface. (Usage of the term interface is meant not as a code construct but more as a descriptive, documenting construct)   * What is the correct relationship between ducktyping and polymorphism ?   * If a language can duck type, does it mean it can do polymorphism ?


Is SQL Server Sevice Broker appropriate for transfering large volumns of records from one database to another

I have a database that collects and process large volumes of records However due to the legacy nature of the system im working with (and the powers that be) i need to transfer (processed) records to a different database instance (with some small field modifications along the way) The options i have identified are as follows   * I could set up a schedule task with a stored proc to transfer the records with any logic needed   * The company i work for is insisting i dump records to a file and ftp them and the use some existing logic to poll and insert   * SQL Service broker which seems to have built in fault tolerance, and has facilities to do this actual task Im just wondering what some potential pitfalls of sql service broker might be and is it the right technology for the job Anyone have any suggestions


Object pointer with privileged access?

Let's say you have   * class Car with Car->tune() and Car->drive()   * class CarDriver   * class CarMechanic Each CarDriver and CarMechanic object has a reference/pointer to a Car object. The CarDriver object will call $this->car->drive(), the CarMechanic object will call $this->car->tune(). The question is, how can I prevent a CarDriver from calling $car->tune() ? There are probably two approaches:   1. Language level: Using access modifiers like public/private/protected, and then either abuse inheritance or use more exotic language features like a C++ "friend class".   2. Composition: Split the car into a CarFrontend and CarBackend, or create a DriverCarWrapper, which exposes only the drive() method.   This seems like a good idea, but it will likely introduce clutter and code duplication, which might outweigh the benefits of access control. Especially if there are many methods that should be accessible to the car driver. Are there any other solutions that I missed? Background: My real-world use case is in PHP, but I am asking this as a cross- language question.


Encapsulate standard C functions?

While studying the C programming language and learning safe practices, I'm inclined to write a layer of functionality over several parts of the standard library. This would serve two purposes: I could use standard parts of the language in ways that feel more familiar or rational to me, and I could easily replace that functionality with my own, if I needed to. I could benefit from this, but should I do it? As an example, we can consider memory management. If I've written malloc() into the constructors of each of my objects, then decide that I need to handle memory allocation on my own, I have to edit the constructor associated with every object. By referencing my own function, I can change the contents of that function without writing a new constructors. It seems obvious that I should do this, but I'm used to Python. I'm extremely comfortable in that environment and have no problem linking to any part of the standard library from any part of my program because I know I will almost certainly leave that relationship untouched for the life of the project. The situation I'm running into with C feels like I'm trying to hide the language from myself. Will writing a layer of functionality over the C standard library help me in learning the language and developing a codebase, or will it stifle my understanding going forward?


Is there more to being a programmer than what I'm being exposed to?

I've been working as a programmer for almost 3 years now. Goes without saying that this is the first job that I got as a programmer after graduating from college. Anyways, I went for an interview at another company feeling that I need to move on (2-3 yrs is about the norm for a programmer right?) and in the interview I started wondering... They asked me whether I had any experience in web services, I didn't. And they asked me a whole bunch of other server-side related experience and frankly I didn't know what they were talking about nor do I remember what they went on about. What I do at my current company is this: We have a few databases, I then write the code for the front end program (Vaadin) and the code to then connect to the databases and do all the necessary CRUD (Create Read Update Delete) functionality. And that's pretty much it... So what I'm wondering is, is this what the average developer does? Or is there more to it than what I'm doing? There's no way for me to know since this is my first developer job after all.


Java Graphics 2D rotation problem?

I have been trying to program a game lately, wherein I drew a rectangle onto the screen using ImageIcon. Later I realised, anything drawn on the screen there after rotates along with the image drawn previously along with it in the same axis. Can anyone tell me why? And what am i missing? Thank you.


Testing strategy for games

I've inherited a web-based educational game. Over the past year I've worked towards stabilizing the code and adding new features. Most of the logic is in the front-end, so back-end unit tests, while helpful, cover a small percent of the code. The game has gotten to the point where it's starting to get complex. There are two different modes for each game and the game behaves differently depending on the mode. There are also various flags that affect game play. I've been an application developer for 10+ years now and this perplexes me. In the enterprise world, an algorithm always functions the same way. I'll write a unit test for an algorithm, I'll expect the value 42 and it'll error if I don't get that value. When it comes to games, I'm lost. How do I test them? I have testers available to me. I can spend time writing unit tests. Testers are ... unreliable. They aren't the best at rooting out issues and I haven't given them the best direction. Short of spending a ton of time every release cycle testing every permutation and combination of the game, how should I use them as a resource? Unit tests seem limited. Since most of the logic is javascript (and I inherited spaghetti code), I can use a front-end suite like Cucumber or selenium to ensure certain features are working. Is that the best strategy? How do game companies test games? I have read the question "Test Driven Development for Complex Games" (among others on the site), but it doesn't address what I'm looking for. I'm asking for strategies, not specific examples of how to test.


How to avoid churn when you are defining a schema while others are trying to program against it

I'm in charge of defining an XML schema for some data; the plan is to have various systems (all under our control) upload XML files that match this schema to a central server for processing. I don't have much knowledge of the design of these other systems, so I'm working collaboratively with those system experts to make this XML schema reasonable to both consume (on our side) and produce (on their side). The schema is not entirely clear-cut, and I'm defining the data we want to collect at the same time as defining the schema. There are a million ways to do it so there's a definite "do something, think about it, talk to so-and-so, refactor, repeat" process in place. All of that said, we have an unfortunate situation where myself and a few others are defining things and a few other developers are implementing it. I'd like to write some code but haven't found the time. This leads to the frustrating cycle whereby the design changes in the ivory tower and then the guys writing the code have to go and change it again and again. Avoiding details for various reasons, the developers writing the implementation aren't in a position to effectively define the requirements of the schema and the data we must collect. Should I be the one writing and playing with this stuff as I figure out how it should be done? This would be ideal to me, but we're under pressure to get things done and it's quicker to have a few people working on it rather than just me. Do we have too many cooks in the kitchen with the XML file providers influencing the schema? Ease of XML file creation should be a consideration of the schema, right? Is there a better way to solve this problem, or is churn a necessary evil when you're trying to fly the plane as you build it? **What is the correct development process to apply here which will minimize wasted time?**


Ambiguous If-else nested block in C without braces

Consider the following code in C:                   if(34)               if(0)                   printf("Stat1");         else             printf("Stat2");      Here,the first **if** condition is true,while the second **if** condition is false.So I assumed,that control should **NOT** pass over to the _else_ block,as there are no parentheses enclosing both the 2nd **if** and _else_ statements together. But when I compiled it in GCC compiler,the output was : **_Stat2_**   This means that the code compiled in a similar fashion as the following code:                     if(34)           {             if(0)                   printf("Stat1");             else                 printf("Stat2");         }        I am unable to understand why the compiler treats both the above pieces of code in the same way.Please explain.Thanks. PS-Please ignore the indentation,I wrote it that way to show my line of thought about how the code should run.


Website that suggests latest browser upgrade from same vendor

I want the user to upgrade to the latest browser, however, I feel like it's wrong to act as an evangelist (also I love Firefox). I know about browsehappy.com but what I'm looking at is a website that suggests upgrade to the same vendor's latest browser. Poor opera is second-last in that list. Is there a website that suggests only the latest opera version to opera users? PS: I also am not a fan of web-kit monopoly. I think subliminally a browser that appears earlier in the list is likely to be perceived better. But please no flame wars here!


Best design for a memory resident tool

I apologize if this tends more toward design that programming, but here goes. What design would you recommend for a database that is   1. Memory resident   2. Must run on windows, linux and (at a stretch) the mac   3. Accept multiple queries simultaneously   4. Have minimum overhead, since a search is expected to take <0.25s This program implements a domain-specific search. Think of it as a database, but one that takes advantage of domain specific information to outperform a convential database search (for example, with custom oracle indexing). We have a custom data structure for our data. Our protoype is a simple exe that constructs the database in memory each time it is run. We were thinking that perhaps this program would suffice, but augmented with sockets so it can listen for queries. This database will be static. Its contents will change infrequently. We expect queries, and the solution, to be delivered via a web service.


What is the market share of programs written in .NET nowadays?

We are currently migrating our Visual Basic 6.0 program to .NET. The target audience are just normal desktop users at home. Discussing this, we realized that we cannot come up with mainstream programs that seem to be written in .NET. Are we mistaken? Is there a good reason for this?


How to improve my algorithm for analyzing twitters messages from users?

Hello I think I have a nice idea to implement for human kind goodness. I call it FixTheUnFixed. The idea goes like this, imagine you are driving or traveling all over the world and when you see some obstacle or damage - broken light, trash covering the street or any other problem you would like the responsible authority to fix it. All you have to do is twit it, maybe add a photo, and of course provide the location using the inherit location service of twitter or Facebook.                    @FixTheUnFixed there is broken fire hydrant here          @FixTheUnFixed my cellular company charged me 18,572$            for using my iPhone aboard.      I thought a lot about how to process the messages. The most frequent issues that will come up are municipality concerns and I would like them to receive that location either by a retwit or an email. My two ideas for getting this address are by googling it (with google API) or just make a regular query mentioned in this pseudo Algorithm:                      1. get the location from the Twitter or Facebook status that was sent from.            2. look for key words such as trash, cats, animals etc.            3. find the relevant authority e-mail, twitter or Facebook account.            4. send the message to the authority account and retwit it to the public               world so they can follow if there is any cahnge.      In the third step, is there any smart way to implement it? I didn't find any good way to do this! I don't want to spam the authorities or publish spam of sneaky people.   * How can I improve the algorithm?   * How can I search for the communication resources of the relevant authorities? Thanks originally asked here: http://stackoverflow.com/questions/8393424/how-to- improve-my-algorithm-for-analyzing-twitters-messages-from-users