Is this looping solution possible with recursion?

Eventually, I would like to generalize this solutions to work with a Tuple of any length. I think recursion is required for that, but I haven't been able to do it.               def combineRanges(maxValues) :         for x in range(0, maxValues[0]) :             for y in range(0, maxValues[1]) :                 for z in range(0, maxValues[2]) :                     print (str(x) + '-' + str(y) + '-' + str(z));          m = (6,9,20);         combineRanges(m);      http://repl.it/WiZ


Should I follow the normal path or fail early?

From the _Code Complete_ book comes the following quote: > "Put the normal case after the `if` rather than after the `else`" Which means that exceptions/deviations from the standard path should be put in the `else` case. But _The Pragmatic Programmer_ teaches us to "crash early" (p. 120). Which rule should I follow?


Overused or abused programming techniques

Are there any techniques in programming that you find to be overused (I.E. used way more excessively than what they should be) or abused, or used a bit for everything, while not being a really good solution to many of the problems which people attempt to solve with it. It could be regular expressions, some kind of design pattern or maybe an algorithm, or something completely different. Maybe you think people abuse multiple inheritance etc.


How to get a list of valid addresses?

I need to get a list of valid addresses in 4 or 5 clusters (cities) in both the UK and US. It's to generate sample data for an application that will do geolocation and searching. At the moment I'm generating the addresses more or less randomly, which means I hit postcodes that don't exist and obviously the street and number never match the postcode. Any recommendations on how to programatically obtain a list of addresses to build test data?


Public vs Private Repositories

Say I am developing an app for sale. Does it make sense to use a public repository for this project? Doesn't default copyright protect the code from someone else using it? If so, what advantages are there in paying for a private repository?


Is this a Best Practice with Enum in C#

When Enum is used as below, say if we have               enum Designation     {         Manager = 0,         TeamLead = 1,         Associate = 2     }      then write the below code               if (designation == Designation.TeamLead) //somecode      Now if we decide to change the enum element from "`TeamLead`" to "`Lead`" then we have to modify the above line of code as well i.e. `designation == Designation.TeamLead` to `designation == Designation.Lead`. So what is the best practice.


computing whether service level times are met

For a ticket reporting tool, I want to compute whether certain service level times (slt) are met. That is (a bit simplified): Was the timespan between opening and closing of the ticket within a certain slt. Now there is also something called a service window (SW), like mo-fr,9:00-17:00. Now to compute whether a slt was met, times not within the SW have to be excluded. Even though not forseen, tickets can be opened or closed outside the SW, since there are other sla wich allow for 24x7 service. An engineer could work on a ticket outside the SW, since it might be easier for him to close a ticket while he is at it. Maybe he was doing work on a related ticket. In order to determine the time a ticket took between opening and closing time, I though of two algorithms: 1) Distinguish all possible combinations of start_date and end_date beeing within or outside the SW, on different days and so on (I see 8 combinations). Then for each combination, set up a seperate formula to compute the time the ticket took. Plus: little computational overhead Minus: Rather complex, lots of code 2) Decide for a smallest possible unit (minutes seem to be apropriate), then for each unit between start_date and end_date, decide whether this unit is inside or outside the SW. If inside, add to the time the ticket took. Plus: very simple Minus: big computational overhead. I am leaning towards 2) since compuation is cheap, simple code is to be preferred, and the rest of the programm contains lots of time consuming db queries, so a little computation will not be noticable. However, both solutions seem not very elegant to me. Does anyone see a third way?


How do you put different versions of your library under version control? Do you use tags? Or branches? Or another method?

I have recently started putting my code under version control (in the lab I'm working, under SVN, and my own codes in github (obviously with git)). Before using version control, I used to do something like this. I had a folder with the name of the library, inside many folders with the version number. Every time I wanted to start working on a newer version, I would make a copy of the last version, change the name to the new version and start implementing. This however seems way redundant when the folder is put under version control. Apart from redundancy, if someone wants to get the latest version, they would be downloading all versions if he just `import`s/`clone`s. Now I see many ways to doing this with version control but since I'm new to it, I don't know which would be more maintainable. ### Method 1: Using tags If I understood tags correctly, you would have your main branch, you commit whatever change you got and tag them with a version. Then, when you want to get a working copy of it, you get the one with a certain tag. (correct me if I'm wrong) ### Method 2: Branching versions In this method, the main branch would be the development branch. Every now and then that a stable version is is made (let's say `v1.2.0`), you create a branch for that version and never commit to it. That way, if you want to download a certain version, you get the code from that branch. Although I said you never commit to it, it may be possible to do bug fixes and commit to an old version's branch to keep the old version running. For example if the current version is `v2.0`, but there are people who want to use `v1.2`, you can get another branch from `v1.2`, namely `v1.2.1` and commit the bug fixes, or just keep the version the same as `v1.2` and just commit the bug fixes. So the branches would look like this:                                 v1.2.1  v1.2.2                      /       /      v1.0.0   v1.2.0---------     v2.0.0     /        /                   /     -------------------------------------- dev      This way you have branches for every minor version update. (Note that in the graph above, v1.2.1 and v1.2.2 or created after v2.0.0 was released, so they were not part of the development between v1.2.0 and v2.0.0. Think of it as support for older versions) ### Method 3: Branching development This method is the opposite of the previous. The main branch would be the latest stable version. Whenever you are working on a new version, you create a branch (for development), work on your code and when it is stable, merge it with the main branch. In this case, the branches would look like this:                ________  ____  ________________  _____ dev     /        \/    \/                \/     ---------------------------------- latest_version      Probably this one needs to be done in conjunction with tags right? ### The question! Anyway, my question is that based on your experience, which of these methods proves more practical? Is there a known best method out there (that possibly I didn't figure out myself)? How are these things commonly done?


What is a good toy project to teach an introduction to DVCS?

## Context I will be coaching student's programming projects in my engineering faculty (group of <10 students). At this occasion I wanted to draw the student's attention to the usefulness of version control systems in particular DVCS. There are many convincing DVCS tutorials out there, however all the ones I found use unrealistic or contrived examples (e.g. hginit uses cooking recipes). ## What I am looking for I want the students to collaborate in class on a _simple but realistic_ programming project that makes them discover the benefits of the DVCS through its usage. The class would collaborate as a dev team. I am looking for a toy project simple enough to keep the focus on the DVCS workflow. The goal is for student to face DVCS challenges that arise naturally in a collaborative development: bug fixes, branch management (stable vs development), merge conflict resolution, etc. I would be greateful if you could give me specific project ideas and highlight their DVCS challenges (e.g. a basic signal processing pipe-line, where each steps is written by different student, forcing them to deal with interface conflicts, etc). Thanks !


What's the canonical way to store translations of user data?

I've developed some software that allows my users to attach a blurb to some non-language specific information: Pseudocode model:               item():       ID       creationdate       byline //Only one byline for the object       description //Only one description for the object          faq:       faqID       question       answer       itemID //ForeignKey      So this is basically a simple model in which an info item has a description and any number of faq questions related to it. If my user now wants to have translations for his description and faq questions, what is the canonical way to extend the model? Some candidates that I thought of:   * Add an alias (FK to self) field on the info as well as a language field. Then have business logic that finds the desired language.      * Upside: required fields are required for any language entry. You create partial translations. You will be reminded when the schema adds another text field.     * Downside: There's now two types of objects in the table: main language objects and alias objects.   * Add a table with all the language specific fields (description), and access the string via the foreign key      * Upside: clean, everything is it's own type     * Downside: more tables. Also the FAQ table needs to somehow make sure there's a full translation for each language. So how would you do it?


Dynamic typing function arguments - how to keep readability high?

Dynamic typing newbie here, hoping for some wizened words of wisdom. I'm curious if there is a set of best practices out there for dealing with function arguments (and let's be honest, variables in general) in dynamically typed languages such as Javascript. The issue I often run into is with regards to readability of code: I'm looking at a function I wrote a while ago and I have no clue what the structure of the argument variables actually is. It's usually ok at the moment of development of new code: everything's fresh in my head, every variable and parameter makes sense because I just wrote them. A week later? Not so much. For example, say I'm trying to crunch a bunch of data about user sessions on a website and get something useful out of it:               var crunchSomeSessionData = function(sessionsMap, options) {         [...]     }      Disregarding the fact that the function name isn't helpful - that obviously is a huge deal - I actually don't know anything at all about what the structure of sessionsMap or options is. Ok.. I have k/v pairs the sessionsMap object, since it's called Map, but are the value a primitive, an array, another hash of stuff? What is options? An array? A whitespace separated string? I have a few options:   * clarify the structure exactly in the comment header for the function. The problem is that now I have to maintain the code in two places.   * have as useful of a name as possible. e.g. userIdToArrayOfTimestampsMap or even have some kind of pseudo-Hungarian dialect for variable naming that only I speak that explains what the types are and how they're nested. This leads to really verbose code, and I'm a fan of keeping stuff under 80 col.   * break functions down until I'm only ever passing around primitives or collections of primitives. I imagine it might work, but then I'd likely end up with micro-functions that have one or two lines at most, functions that exist only for the purpose of readability. Now I have to jump all over the file and recompose the function in my head, which just made readability worse.   * some languages offer destructuring, which to some extent can almost be thought of as extra documentation for what the argument type is going to contain.   * could create a "class" for the specific type of object, even though it'd not make a huge difference in a prototypal language like JS, and would probably add more maintenance overhead than necessary. Alternatively, if available, one can try to use protocols, maybe something along the lines of Clojure's deftype/defrecord etc. In the statically typed world this is not nearly as much of an issue. In C# for example you get a:               public void DoStuff(Dictionary<string, string> foo) {[...]};      Ok, easy peasy, I know exactly what I'm getting, no need to read the function header, or go back to the caller and figure out what it's concocting etc. What's the solution here? Are all people developing in dynamically typed languages continuously boggled by what types their subroutines are getting? Are there mitigation strategies?


Report generator windows service polling database for work

I'm building a new report generator for our in-house survey system. (No I can not use any off-the-shelf software. These are highly customized reports.) I want to use Topshelf to host the generator as a service. Our current generator is a desktop-app and requires a user to be logged in on the server. I want to try to avoid this. The report-generation itself is very straight forward and procedural in nature. But the server is more than capable of generating several reports at one time. I want the service to spin up a few instances of the generator at the same time, is this something I would use the Task Parallel Library for? A bit of pseudo would look a bit like this:               poller.Poll(order => { // blocking(?) call to listen for new report-orders       var gen = new Generator(order);       gen.process(); // generates report       set gen = null; // or something else to destroy the generator for that report     });      Anyone have any suggestions on how to accomplish this?


So I'm a developing a workflow with vagrant+git...does this make sense?

**Relevant Background Details**   1. We've got two types of VMs (Utility Boxes & Web Servers) that developers need.    2. We are going to be using git for version control.   3. We have developers who have different preferences for their working environment (e.g. Some Linux, Some Windows).   4. I'm in the Linux camp and I believe Git and Windows doesn't mix as well as Linux & Git. However, this could be personal bias.   5. We using Linux in production. **Building the Vagrant VMs for distribution**   1. Build a base box with the relevant OS for vagrant.    2. Using a configuration manager (e.g. Chef) to build out the Utility & Web images, convert them to new base boxes. It will clone service configurations from a centralized git repository.   3. Distribute the base boxes (really just virtual machine images) for the users to develop locally with vagrant. The distributed box will automatically pull in source code from certain git repos (e.g. libraries).   4. If changes are planned for the production environment, all developers will need to pull down new base boxes for vagrant as they come prepackaged. I think this is the simplest way for a new developer to deal with it. Staging is updated to match the new development VMs in preparation. **Developer Workflow**   1. Get assigned an issue from the issue tracker.   2. Use the vagrant VM to clone the current dev repository into the folder it shares with the host OS (so the Developer can use their favorite IDE).   3. Developer commits changes and tests locally.   4. When satisfied, Developer merges his changes to the dev repository. If conflicts, work with the Developer commited the conflicting code to resolve the issue.    5. When Dev is in a stable state, Dev is merged with the current Staging repository for QA of the new features. Nothing is pushed from Dev to Staging until Step #6 is completed. Hooks generate new copy of documentation for Staging.   6. Staging is cloned into Production once the QA is completed. Hooks generate new copy of documentation for Production. Is there any obvious flaws/pitfalls in the above or steps that are generally considered 'best practices' that should be added?


How to consider the login function collecting requirements of an application? is it a user requirement?

I am working on an application that expected to the user logs in when the application is started (as for example it is in Skype: the user open the application and appear to him a login mask when he insert the username and password to start work with the application) Now I am preparing some use case diagram and I am collecting the application requirements (I have to write some documentation) Can I consider it as a user requirement? Or what is it?


Could someone help me understand SQL TDE Database encryption?

I don't quite follow how it works. According to the MSDN Article there is a big hierarchy of keys protecting other keys and passwords. At some point the database is encrypted. You query the database which is encrypted, and it works seamlessly. If you're able to simply connect to the database as normal and not have to worry about any of the encryption from a developer point of view, how exactly is it secure? Surely anyone can simply connect and do `select * from x` and the data is revealed. Sorry my question is a bit scattered, I am just very confused by the article.


How would most programmers feel about the bugs they wrote?

Do they feel frustrated, disappointed, or even don't admit at all?


Am I a code monkey?

I just tried integrating my website with facebook. I got a lot of copy-paste code from the facebook developers site. I just put the code and it works fine. Do you call this kind of programmers "code monkeys"? If you say I am a code monkey, in the same case what would you expect me to do?


Designing tool for C#

I have seen few developers use a tool for designing their application where they simply dragged needed elements (classes, variables, objects) and just did magic work. Then there was a button to generate a code where the design was generated into a C# code after what developer continued to work on software manually. Anyone can give me an idea about what those are called and where I may grab one?


Billing from card directly

I, for the life of me, cannot find any literature on this, simply because I have no clue how it is called. I want to learn how to implement a payment option that consists of paying with your credit/debit card directly without the use of a third party like paypal. This is what I am talking about ![enter image description here](http://i.stack.imgur.com/9gYOn.png) Can you please give me some information about how this payment method is called and possibly some articles I can read up on. Thank you!


I've always wondered why one _calls_ a function as opposed to, for example, _executing_ it. A Google search for `function call etymology` and similar terms turns up nothing useful, Wikipedia doesn't mention it, online dictionaries have either no entry at all or no etymology section. Where did the notion of 'calling' a function come from?


How would you create useful tests for Oracle BI Publisher reports?

I'm curious about how to test reports that seem rather straightforward. I'm supposed to create test cases for an Oracle report(XML Publisher/BI Publisher). So for example, a report is supposed to just return columns(say , 10 columns). Here is what I thought of so far:               Validate that the  report returns accurate output.     Validate that the all column headers and table values are correctly aligned and there are no run-ons/incorrect formatting     Validate that dates are in the MM/DD/YYYY format     Validate that all currencies are accurate, and contain 2 decimal places.      Here's a sample pic(of what the report produces) : ![enter image description here](http://i.stack.imgur.com/MfxvB.png) What would the edge/boundary cases be? If the report takes in parameters, does that make it more demanding of a report? Thanks


embedding LEFT OUTER JOIN within INNER JOIN

I am having some problems with one of the question's answered in the book "SQL FOR MERE MORTALS". Here is the problem statement ![Problem Statement](http://i.stack.imgur.com/894yN.jpg) Here is the Database Structure ![The Database Structure](http://i.stack.imgur.com/CKsHU.jpg) Here is the answer which I am unable to comprehend ![DoubtFul Answer](http://i.stack.imgur.com/SWxVI.jpg) Here is an answer which looks perfect to me ![Confirmed Answer](http://i.stack.imgur.com/PnJza.jpg) Now the problem with the first answer I am having is: We first use LEFT OUTER JOIN for recipe class and recipes. So it selects all recipe class rows but only matching recipes. Perfecty fine as the question is demanding. Lets call this result set R. Now in the next step when we use INNER JOIN to join RecipieIngridients, it should filter out the rows from R in which Recipie ID doesn't match with the Recipe Id in Recipie Ingredients and hence filtering out the related Recipe class and recipe description also(Since it filters out the entire row of R). So this contradicts with the problem which demands all recipieID and RecipieDescription to be displayed from Recipe_Classes Table in this very step only. How can it be correct. Or Am i Missing some concept.


Where should user permission checks take place in and MVC and by who?

Should user permission checks take place in the model or the controller? And who should handle the permission checks, the User object or some UserManagement helper? ## Where should it happen? ### Checking in the Controller:               class MyController {       void performSomeAction() {         if (user.hasRightPermissions()) {           model.someAction();         }       }       ...      Having the checks in the Controller helps making the Models simple actions, so we can keep all logic to the Controllers. ### Checking in the Model:               class MyModel {       void someAction() {         if (user.hasRightPermissions()) {           ...         }       }       ...      By putting the checks in the Model, we complicate the Model, but also make sure we don't accidentally allow users to do stuff they aren't supposed to in the Controller. ## And by who? Once we've settled on the place, who should do the checks? The user?               Class User {       bool hasPermissions(int permissionMask) {         ...       }       ...      But it's not really the user's responsibility to know what he or she can acccess, so perhaps some helper class?               Class UserManagement {       bool hasPermissions(User user, int permissionMask) {         ...       }       ...      I know it's common to ask just a single question in, well, a question, but I think these can be answered nicely together.


Can I demand code quality on a project I've gotten

I have been given a Drupal project from an external web agency and have been trying to becomer wiser on both Drupal and their approach of making a site. With time I've learnt a bit morer about Drupal, even though I've come to notice it really isn't my cup of tea. Recently, I tried to "simply" replace the HTML generation of a part of the site, which seemed to be generated through a custom module (their addons for the site). I changed that code and realised that the effect simply didn't alter anything, or at least I thought. Basicly now I've without exaggerating replaced the same piece of code with very small differences 26 times, and it's _still_ not changing everywhere. So what I'm dealing with is a set of code that have literally never or barely heard of global class nor function and is simply copy & paste'd all over the site. I'm curious on what I'm supposed to do with this. There's one file alone that has over 3000 lines of basicly the _exact_ same code 16 times over. If you order a web agency to develop at site, can you expect it to be common sence that the code should be at least a _little_ maintainable and simply not a big piece of code, more annoying to edit than far more necessary, or does it specifically have to be requested and I should had instead had to validate the code before paying for the handover of the site? This is the first time I have ever came across such a poorly written piece of code in my career and it feels as if we bought a good looking suit that we saw from the outside of the store, and all we got was a poster of that suit for the same price. ## The question What would be the appropriate thing to do in my case? Should I suck it up and convince my employer that the code is poorly written in hope that my given deadline for completing the project gets extended, or can I demand the web agency to do some action? **EDIT:**   Thanks for all your answers! They help me get some more perspective on this. I will discuss this internally a bit more, and try to mark out the best answer, even though most of yours covers the same but also different fields of the question.


Does IE have more strict Javascript parsing than Chrome?

This is not meant to start a religio-technical browser war - I still prefer Chrome, at least for now, but: Because of a perhaps Chrome-related problem with my web page (see https://code.google.com/p/chromium/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Pri%20M%20Iteration%20ReleaseBlock%20Cr%20Status%20Owner%20Summary%20OS%20Modified&groupby=&sort=&id=161473), I temporarily switched to IE (10) to see if it would also view the time value as invalid. However, I didn't even get to that point - IE stopped me in my tracks before I could get there; but I found that IE was right - it is more particular/precise in validating my code. For example, I got this from IE:               SCRIPT5007: The value of the property '$' is null or undefined, not a Function object       ...which was referring to this:               <script src="/CommonLogin/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>     <script type="text/javascript">         // body sometimes becomes white???? with jquery 1.6.1         $("body").css("background-color", "#405DA7");     <      This line is highlighted as the culprit: $("body").css("background-color", "#405DA7"); jQuery is referenced right above it - so why did it consider "$" to be undefined, especially when Chrome had no problem with it...ah! I looked at that location (/CommonLogin/Scripts/) and saw that, sure enough, the version of jQuery there was actually jquery-1.6.2.min.js. I added the updated jQuery file (1.9.1) and it got past this. So now the question is: why does Chrome ignore this? Does it download the referenced version from its own CDN if it can't find it in the place you specify? IE did flag other errs after that, too; so I'm thinking perhaps IE is better at catching lurking problems than, at least, Chrome is. Haven't tested Firefox diesbzg yet.


Static code analysis application: Where to start?

I am trying to create a _poc_ for a **_static code analysis_** tool supporting an Object Oriented and a procedural language (C and Java, for example). Even after quite a bit of internet search I am still not sure where to begin.   * Plan to use very few metrics to start with, possibly simple ones.    * Several tools are available but I am looking for a generic approach and not a tool. Few open questions :   * Should the tool work on basic object code or should it work on the raw source code?    * Should I create a domain specific language for defining parsing rules etc.? I am not asking for a complete solution. I am just asking if some one can point me in the right direction.


Code execution within delimiters

Is there any way I can execute a block of code in a loop, like so:               [ some code goes here ]      Where the delimiters are "[" and "]", and also allowing for nested blocks, i.e.:               [the user can create another loop[]]      I am creating a parser for a language that implements such semantics, and it reads the code one byte/character at a time since the commands are all single characters and because the syntax is supposed to be very minimal (which is fairly important), and I am currently stuck in this loop thing. I have tried matching the byte (since I am only reading 1 character at a time) with a "[" character and then setting a global variable across the instance, but this seems to break when the statements are nested, and doesn't seem to work. Any help (in Python, possibly) is appreciated! **EDIT:** Conforming to what @mattnz commented, the question & post has been further clarified.


Managing unique data correctly in SQL

Here in Brazil we have a personal identifier called **CPF**. This identifier has a sequence of 11 digits and is unique for each Brazilian citizen. Possibly in other countries there is something like that too. How is a unique identifier, I chose to set it in the database like a **UNIQUE KEY**. And now that things get complicated. A user could be registered by an administrator and be removed by some kind of problem. However, it is not actually removed, but hidden by a deleted flag. And in another moment, he could be recreated again (there is a need to recreate it, and not re-enable it). Because it is an individual identifier, the CPF would be reused on recreated user and would conflict in UNIQUE KEY. In this situation, I thought of some practical solutions to solve the problem as well as its disadvantages. But I like what is the most appropriate way to solve this kind of problem.   1. **Do not use a UNIQUE KEY.** The disadvantage is that it could increase the query time, which could perhaps be solved by a KEY-only column.   2. **Set the column to NULL on pseudo-DELETE.** The disadvantage is that I lose the information, however, could solve just creating a second column to store its value before being annulled.   3. **The UNIQUE KEY could group the column with a date removal column (NULL by default).** The disadvantage is having to use two columns for each group UNIQUE KEY.   4. **Create a second table to store data removed without UNIQUE KEY.** The disadvantages here are almost incalculable!   5. **Remove the row, rather than hide it.** The disadvantage here is that I could lose the references in a user FK. Currently I prefer the first option, and if very necessary, I would opt for the second or third option. But I wonder if there is a more correct way, following the concept more accepted by the community.


junior / professional / senior categorization

Hey guys, is it just me or is the categorization of developer levels highly subjective? I get the feeling that every company tries to hire experienced developers as juniors because they don't know $technology. For example my own career: I switched technologies a couple of times, while sticking to java as a programming language. For example I first worked for 3 years using JavaSE technologies, the next company I worked for hired me as junior because I didn't have JavaEE experience - while still selling me as professional level to customers (I work in consulting). The next company hired me again as junior because I didn't have SAP experience - they mostly work with SAP Java technologies which is definitely a niche. Still, they are selling all their technology consultants for exactly the same rate while paying them significantly different wages. Now when switching jobs again I feel like this whole thing is going to start all over again because I don't have Spring experience or Oracle knowledge. tl;dr = is my observation totally off base that companies are just using these categorizations as means to keep down wages?


Protecting proprietary code linking with LGPL v3 code

I've been warned that LGPL v3 forbids any kind of modifications that would prevent reverse-engineering, including software protection such as obfuscation. In practice, does this license make it illegal to use something like SecureSWF, or simply a JavaScript minifier, when linking a program with a LGPL-licensed library?


String patterns that can be used to filter and group files

One of our application filters files in certain directory, extract some data from it and export a document from the extracted data. The algorithm for extracting the data depends on the file, and so far we use regex to select the algorithm to be used, for example `.*\.txt` will be processed by algorithm A, `foo[0-5]\.xml` will be processed by algo B, etc. However now we need some files to be processed together. For example, in one case we need two files, `foo.*\.xml` and `bar.*\.xml`. Part of the information to be extracted exist in the _foo_ file, and the other part in the _bar_ file. Moreover, we need to make sure the wild card is compatible. For example, if there are 6 files               foo1.xml     foo23.xml     bar1.xml     bar9.xml     bar23.xml     foo4.xml      I would expect foo1 and bar1 to be identified as a group, and foo23 and bar23 as another group. bar9 and foo4 has no pair, so they will not be treated. Now, since the filter is configured by user, we need to have a pattern that can express the above requirement. I don't think you can express meaning like above in standard regex. `(foo|bar).*\.xml` will match all 6 file above and we can't identify which file is paired for a particular file. Is there any standard pattern that can express it? Or any idea how to modify regex to support this, that can be implemented easily?


What do programmers "micro-optimize" for today?

Back in the "good ol' days," when we would copy shareware onto floppies for friends, we also used a fair bit of assembly. There was a common practice of "micro-optimization," where you would stare and stare at lines of assembly until you figured out a way to express it in one fewer instruction. There was even a saying, which was mathematically impossible, that " _You can always remove one more instruction._ " Given that changing runtime performance by small constant factors isn't a major issue for (most) programming today, are programmers transferring these micro-optimization efforts elsewhere? In other words, **Can a best-practice be taken to an extreme state where it's no longer adding anything of value?** And instead is wasting time? For example: Do programmers waste time _generalizing_ private methods that are only called from one place? Is time wasted reducing test case data? Are programmers (still) overly concerned about reducing lines of code? There are two great examples of what I'm looking for below: (1) Spending time finding the right variable names, even renaming everything; and (2) Removing even minor and tenuous code duplication. * * * Note that this is different from the question "What do you optimize for?", because I'm asking what other programmers seem to maximize, with the stigma of these being "micro" optimizations, and thus not a productive use of time.


When I should I use message passing over shared memory?

I know a little about how to use message passing and shared memory, but I still don't know when to choose one or another. Can you tell me about their traits (not the implementation)?


How to build a career path to be an Architect?

I'm currently a junior Java developer with 1 year of experience. And I want to know how to become an Architect. what things should I focus on to reach that goal or to be more specific what is the road map to be a great architect?


How to port a J2ME application to Android platform?

I have heard that there are soft wares for converting an existing J2ME app to Android? But I was doing a manual conversion till now. Am I doing a silly job/is it possible to do convert any J2ME application?


when to use java and when to use c++

Lets say I am writing a server, which will run continuously and answer the queries of the client. Now what parameters (speed, memory, ease of use, quality etc.) should I consider to decide whether to use JAVA or to use C++ and how? How does system architecture decides this? Or they just choose the one in which they can found expertise?


Is "truthiness" a legitimate programming term?

SO has quite a few questions using the word "truthiness" to mean the truth value of an expression, when evaluated as a boolean, regardless of its original type. It's very useful in dynamic languages. So my question is, is this a real term, and if so were we using it before Stephen Colbert made it popular? Or did we just adopt it afterward? In that case, what is the correct term with the definition I gave above?


Using snippets of open source code in my application

I'm working on an internal company application(not built on Wordpress) that needs to have shortcode functionality similar to Wordpress (http://codex.wordpress.org/Shortcode_API). Wordpress has a bunch of functions relating to handling short codes but the ones I was looking at were just the ones that handled the regex portion of the process. Is there something wrong with just using the few functions I need from Wordpress in my application? If it is ok, how do I go about giving credit in those sections. I did a quick check and Wordpress is licensed under GPLv2. I'm using the Kohana Framework in my application which is licensed under BSD. I'm not sure if that changes anything but I thought I'd include it just in case.


Moving from academics to workforce

I have worked for the past 4 years as a programmer and research assistant. It is my second major job out of college(CS degree). It was a good position at the time, but I grew frustrated at the slow pace and decided to enter the private sector. My question: what skills are academic programmers lacking compared to those that have been in the general workforce? I want to minimize any deficiencies while I search for new work.


How does persistence fit into a purely functional language?

How does the pattern of using command handlers to deal with persistence fit into a purely functional language, where we want to make IO-related code as thin as possible? * * * When implementing Domain-Driven Design in an object-oriented language, it's common to use the Command/Handler pattern to execute state changes. In this design, _command handlers_ sit on top of your domain objects, and are responsible for the boring persistence-related logic like using repositories and publishing domain events. The handlers are the public face of your domain model; application code like the UI calls the handlers when it needs to change domain objects' state. A sketch in C#:               public class DiscardDraftDocumentCommandHandler : CommandHandler<DiscardDraftDocument>     {         IDraftDocumentRepository _repo;         IEventPublisher _publisher;              public DiscardDraftCommandHandler(IDraftDocumentRepository repo, IEventPublisher publisher)         {             _repo = repo;             _publisher = publisher;         }              public override void Handle(DiscardDraftDocument command)         {             var document = _repo.Get(command.DocumentId);             document.Discard(command.UserId);             _publisher.Publish(document.NewEvents);         }     }      The `document` domain object is responsible for implementing the business rules (like "the user should have permission to discard the document" or "you can't discard a document that's already been discarded") and for generating the domain events we need to publish (`document.NewEvents` would be an `IEnumerable<Event>` and would probably contain a `DocumentDiscarded` event). This is a nice design - it's easy to extend (you can add new use cases without changing your domain model, by adding new command handlers) and is agnostic as to how objects are persisted (you can easily swap out an NHibernate repository for a Mongo repository, or swap a RabbitMQ publisher for an EventStore publisher) which makes it easy to test using fakes and mocks. It also obeys model/view separation - the command handler has no idea whether it's being used by a batch job, a GUI, or a REST API. * * * In a purely-functional language like Haskell, you might model the command handler roughly like this:               newtype CommandHandler = CommandHandler {handleCommand :: Command -> IO Result)     data Result a = Success a | Failure Reason     type Reason = String          discardDraftDocumentCommandHandler = CommandHandler handle         where handle (DiscardDraftDocument documentID userID) = do                   document <- loadDocument documentID                   let result = discard document userID :: Result [Event]                   case result of                        Success events -> publishEvents events >> return result                        -- in an event-sourced model, there's no extra step to save the document                        Failure _ -> return result               handle _ = return $ Failure "I expected a DiscardDraftDocument command"      Here's the part I'm struggling to understand. Typically, there'll be some sort of 'presentation' code which calls into the command handler, like a GUI or a REST API. So now we have two layers in our program which need to do IO - the command handler and the view - which is a big no-no in Haskell. As far as I can make out, there are two opposing forces here: one is model/view separation and the other is the need to persist the model. There needs to be IO code to persist the model _somewhere_ , but model/view separation says that we can't put it in the presentation layer with all the other IO code. Of course, in a "normal" language, IO can (and does) happen anywhere. Good design dictates that the different types of IO be kept separate, but the compiler doesn't enforce it. So: how do we reconcile model/view separation with the desire to push IO code to the very edge of the program, when the model needs to be persisted? _How do we keep the two different types of IO separate_ , but still away from all the pure code? * * * **Update** : The bounty expires in less than 24 hours. I don't feel that either of the current answers has addressed my question at all. @Ptharien's Flame's comment about `acid-state` seems promising, but it's not an answer and it's lacking in detail. I'd hate for these points to go to waste!


Why execution time is different each time in java?

I am trying to make a program in Java which measure the complexity of a specific program with respect to its run time. Let's take a problem and code that problem in all possible ways with respect to time complexity, let's say we can write code for a specific problem in O(n), O(log(n)), O(n log(n)) and O(n^2). I will record the run time of each case and I will make a scale with these values to measure the time complexity of other's solution. Like   1. O(n) -> 2-3 ms   2. O(log(n)) -> 1-2 ms etc. Now if other code has run time 2.3 ms, then my Java program will say that given solution has time complexity of the order O(n). Now problem is that, as my code is in Java, whenever I run any program using Ubuntu commands through Java code , each time I get the different run time, and the run time has very huge range from 0.364246 to 0.902362. Why it is happening and what can I do to make a efficient scale? Here is my code:               import java.io.*;          class ps_ef     {         public static void main(String args[])     {         String s=null,file_name,extension;         int pos = args[0].lastIndexOf(".");              extension = args[0].substring(pos+1);         file_name = args[0].substring(0,pos);              int lang = 0; //  1 -> c,c++ , 2 -> java              try         {                     Process compile = null;                  switch(extension)             {                 case "c"    :    compile = Runtime.getRuntime().exec("gcc -g "+ args[0] + " -o "+file_name);                             lang = 1;                                        break;                 case "c++"  :    compile = Runtime.getRuntime().exec("g++ -g "+ args[0] + " -o "+file_name);                             lang = 1;                             break;                 case "java" :    compile = Runtime.getRuntime().exec("javac "+ args[0]);                             lang = 2;             }                  BufferedReader stdError = new BufferedReader(new InputStreamReader(compile.getErrorStream()));                  if((s = stdError.readLine()) != null)             {                 System.out.println("Compile Time Error OR Warning : ");                      System.out.println(s);                 while((s = stdError.readLine()) != null)                 {                     System.out.println(s);                 }             }                  double startTime, run_time;             Process run;                  if(lang == 1)             {                  startTime = System.nanoTime();                       run = Runtime.getRuntime().exec("./"+file_name);                       run_time = (System.nanoTime()-startTime)/(double)Math.pow(10,6);             }             else             {                      startTime = System.nanoTime();                       run = Runtime.getRuntime().exec("java "+file_name);                       run_time = (System.nanoTime()-startTime)/(double)Math.pow(10,6);             }                  System.out.println("RunTime : "+ run_time+" ms");                  BufferedReader run_stdInput = new BufferedReader(new InputStreamReader(run.getInputStream()));                  BufferedReader run_stdError = new BufferedReader(new InputStreamReader(run.getErrorStream()));                  if(( s = run_stdError.readLine()) != null)             {                 System.out.println("Runtime Error : ");                      System.out.println(s);                      while((s = run_stdError.readLine()) != null )                 {                     System.out.println(s);                 }             }             else if((s = run_stdInput.readLine()) != null)             {                 String s_string = null;                 int failed = 0;                      File fs = new File(file_name+".txt");                      BufferedReader br  = new BufferedReader(new FileReader(fs));                      if((!s.equals(s_string = br.readLine())))                 {                     failed = 1;                 }                      while(((s = run_stdInput.readLine()) != null) & ((s_string = br.readLine()) != null) & (failed == 0))                 {                     if(!s.equals(s_string) )                     {                         failed = 1;                         break;                     }                 }                      if((failed == 1) || s != null || s_string != null)                 {                     System.out.println("Submmision Failed : ");                     System.out.println("Either Output Is Wrong.\nOR\nYour Output Is Not According To The Given Format. ");                     System.exit(0);                      }                 else                 {                     System.out.println("Submission Successful.");                 }                  }         }            catch(IOException e)         {             System.out.println("Some Error Has Occured : ");             e.printStackTrace();             System.exit(-1);         }          }      } Here is my output of run time: ![enter image description here](http://i.stack.imgur.com/tWUwp.png)


What do you call an application that is not specifically tied to a DB structure

I'm wondering what you call an applications that are not hard coded around any database structure? Let me give a small example: I have one application where the views, the controllers and the model are tailored to the information and fields in the model, and thus the database. I have a second (theoretical) application where the views and controllers are completely generic; I could change the fields in my database and make some minor adjustments to model classes and the application still works for editing/adding information. I wouldn't try to create an application on either of these principles, but I'm wondering what you would label them as.


Controllers and re-factoring for maintainability / sensibility

I have read many posts similar to this on the site: however I still am questioning what is best in my situation (also the answers are contradicting from question to question). I have a website (web-application) with a controller per section of domain logic (i.e. ProductsController, NewsController, ContactsController, etc..) and one very large very ugly admin controller which contains the logic for the Add/Edit/View/Delete functions for each section... now as you can imagine this controller is getting very out of control (whereas each function is not overly large, having dozens of functions in one controller does not sit well with me...). From what I've read the general consensus is to just lump the _admin_ functions in the 'sections' controller; however some also suggest you create a new controller for each admin section as well. so I would then have ProductsController and AdminProductsController - to me this seems a little overkill, however I have no real clue about this: any tips or readings would be appreciated - or if there is a 'industry best practise' that would be nice to know as well.


What are advantages and disadvantages of browser rapid release cycles for web developers?

Chrome and Firefox have now rapid release cycles. Also Opera is starting to get speed and Internet Explorer should take the high road soon. I am a web developer. What does that mean for me? What consequences does it have for me? Will it be an advantage for my work or another burden?


How do you decide where functionality should belong in a large-scale project?

In my current development situation, we have a lot of DLLs, executables, and static libraries. How do you decide what should go into a DLL? What should go into an executable? Why have separate functionality in different executable files? I'm hoping the answer will be concise, but this is a largely opinionated topic it would seem. How do you decide where functionality resides in a large-scale project (more than one executable file)? I'm expecting answers to range from, "Good Design" to "Modularity" to "Whatever management puts in a requirements doc".


Clever PHP Application Organization Structures?

There are a million-and-one file-system structures that go into the myriad of Open Source projects available. Things like modules, language files, domains, third-party libraries, migrations, internationalization, backups, and syslinks to other parts of the system have given rise to many approaches to organize the filesystem of a project. As a PHP developer I'm wondering if any type of standardization is starting to emerge among projects. With PSR-0 we finally have a standard for naming and loading files - but it nothing to my knowledge about the rest of the components that make up the system or how they can be handled in a sane way. **We are dealing with a lot more than just MVC, so what examples are there of large projects correctly handling all of these things?**


My very first serious project and I'm concerned about security

I'm making a small social networking web site for a specific university's students (where I study) and I'm concerned about security (access to the database). What should I do? What I have to check for last time until I went online? (Yeah, Facebook Facebook. Facebook don't have that community sense. You cannot find all your department mates on Facebook. You cannot see all foreign students on Facebook. You cannot hide your identity on Facebook while commenting, etc etc. Just please don't compare it with Facebook, we had a great _local_ social network until it went _public_ . * ))


Do/Should you consider GM releases as final?

I was wondering that, as a developer, you consider a GM release the final release and if you do it for serious development or if you stick to the stable version. With the iOS SDK, you're able to submit apps to Apple for submission to the App Store using a GM version. Do you recommend using the GM version of an SDK or waiting a couple of weeks and use the stable version?


Intellectual-Property Question

Like almost everyone here, I have a handfull of scripts and software that I have developed and am enthused about. I will be looking for my first job as a software designer / coder. It seems natural that I will be eager to please my employer and use scripts or similar methods that I have developed and worked for me in the past to please my employer. It seems certain that many things that I code will look very similar to things I have coded in the past. I don't understand how to document and articulate to an employer that this code base was mine before I got here and this will continue to be mine when I leave. Surely, this is a common issue, but none of the various searches I've done on the net have produced an answer to this question. How is this situation commonly dealt with in the industry? I feel like there should be a digital version of sending myself a 'certified letter' with my code/software/scripts contained. I'm not trying to protect my code from others using it; I am trying to protect my right to continue using my code base that I have developed prior to to gaining employment with an employer.


Is it better to use an external variable or to pass around a pointer?

While writing in C, I have always wondered about when is the best time to use an external variable. I generally prefer to pass a pointer into a method. Is there a correct time to use an external variable and a correct time to use pointers?


Database Context and Singleton injection with IoC

All of the below relates to a ASP.NET c# app. I have a Singleton Settings MemoryCache that reads values from database on first access and caches these, then invalidates them using SQL Service Broker message and re-reads as required. For the purposes of standard controllers, i create my Db Context in a request scope. However, this obviously means that i can't use the same context in the Settings Cache class, since that is a singleton and we have a scope collision. At the moment, i ended up with two db contexts - the Controllers get it via IoC container, whereas a Singleton just creates it's own. However, i am not satisfied with this approach (mostly due to the way i feel about two contexts, the cache doesn't set anything on the db hence concurrency is not an issue as much). What is a better way to do it?


Mobile development project architecture model/pattern

I would like to hear some improvement suggestions for mobile development (Android/iOS) project architectures. I would like to go for a "safe" design, modular and that can be easily maintained in time. As far as I know **Android** and also **iOS** platforms are built on **MVC** , at least have the `Activities` and `UIViewControllers` that are a sort of _controller_ part from **MVC** (as many stated out there on the internet). Also I know two approaches so far for a basic project( **Android** /* _iOS_ *): ##  1\. My favorite (a sort of MVC) _**Model_** \- I have here the models, only simple getter/setter classes   shaping the project entities _**View_** \- the Activities, UIViewController and custom views, only display, get data from the user interface here, usually gets the data from the Controller, never directly from the Acess _**Controller_** \- some singletons (not necessary but usual) that manage each entity data, usually are doing business jobs, loading data from the Access layer and don't have access to the view layer. _**Access_** \- Database and Web Service managers, serves data back to Controller layer, can't have contact to any other layers. ## 2\. Commonly seen (also a sort of MVC) _**Model_** \- the models, only simple getter/setter classes shaping the project entities, I usually saw also some business jobs here too. _**View-Controller_** -(Activities and UIViewController) that manage entity data, usually are doing business jobs and also take care of displaying data to the user. Also make calls through some web service classes to get the data. So far I am using the first variant as I consider it more decoupled and I can see the difference between who is making business jobs, user interface communication and data providers. This making it more maintainable than the second one. The drawback for the first one is that has 2 more layers than the second one, this means more classes(but less code in each class) and at the start of a project, this can take a bit longer to develop than the second one. What approach do you use or which do you think it is better and why?


Scaling Scrum within a group of 100s of programmers

Most Scrum teams lean toward 7-15 people ****** , though it's not clear how to scale Scrum among 100s of people, or how the effectiveness of a given team might be compared to another team within the group; meaning beyond just breaking the group into Scrum teams of 7-15 people, it's unclear how efforts between the teams are managed, compared, etc. **Any suggestions related to either of these topics, or additional related topics that might be of more importance to account for in planning a large scale SCRUM grouping?** ****** In reviewing research related to the suggested size of software development teams, which appears to be the basis for the suggested Scrum team size, I found what appears to be an error in the research which oddly appears to show that bigger teams (15+ ppl), not smaller teams (7 ppl) are better. * * * **UPDATE, "Re: Scrum doesn't scale":** Made huge amounts of progress personally researching the topic, but thought I'd respond to the general belief of some that Scrum doesn't scale by citing a quote from Succeeding with Agile by Mike Cohn : > **Scrum Does Scale:** You have to admire the intellectual honesty of the > earliest agile authors. They were all very careful to say that agile > methodolgies like Scrum were for small projects. This conservatism wasn’t > because agile or Scrum turned out to be unsuited for large projects but > because they hadn’t used these processes on large projects and so were > reluctant to advise their readers to do so. But, in the years since the > Agile Manifesto and the books that came shortly before and after it, we have > learned that the principles and practices of agile development can be scaled > up and applied on large projects, albeit it with a considerable amount of > overhead. Fortunately, if large organizations use the techniques described > regarding the role of the product owner, working with a shared product > backlog, being mindful of dependencies, coordinating work among teams, and > cultivating communities of practice, they can successfully scale a Scrum > project. > > **SOURCE:** (ran across the book thanks to Ladislav Mrnka answer)


Web Developer interview questions

I read an article today that listed some basic questions about web development:   1. Describe how POST data was submitted to a server by a browser.   2. Explain a number of HTTP status codes (except maybe 404 and 500).   3. Explain SOLID or name a design pattern.   4. Explain ways to improve a page load speed or user experience. The author says " **if you can’t answer the questions above there are a lot of people who wouldn’t think of you as a Senior Web Developer.** " My questions are:   1. How relevant are these questions in respect to real life web programming and scalability?   2. How true is that statement? In other words, do you consider this knowledge a requirement to be considered a Senior Web Developer?   3. I was able to answer all the questions, too easily it seemed, so I'm wondering whether it is effective to use these or similar questions to screen developers rather than asking them to write sample code.


MVC, Java Design Pratices, and Flaws of java.util.Observable and java.util.Observer

I am planning learning Model-View-Controller (MVC) development using Java. While reading I came across a post which mentions **java.util.Observer** and **java.util.Observable** for MVC development. As I never heard of it before, upon more googling I came across this SO post, which discusses some design flaw with the above-mentioned classes. My question now has three parts   1. Are these classes still used in Industry for MVC development (except Eclipse as mentioned in the SO post)?   2. What are the flaws with these classes and why/why not should one use them?   3. Are there some ways MVC projects are developed in industry? (would be nice if you can answer this in general terms, NOT looking for answers like **SPRING** :P ) **[edit: both for desktop and web applications]**


Web application (Spring, JSF) forks, how to reuse existing code for subprojects?

my question is going to be somewhat philosophical and "architectural oriented" so bear with me. Right now we have existing Java web application built on top of Spring and JSF(facelets) with maven. These are basically our tools that limit our scope of possible solutions. Now to the point. We need to implement a fork of this application that will be running on different domain for different "end consumers" and implement some change requests for both versions, but **code base of these versions will probably always be ~90% same**. Same change requests can be defined for implementation in both versions simultaneously BUT separate change requests only for chosen version might come as well. We have no control over what change requests there might come in later in project (but we are expecting quite a few). The differences in functionality may occur both on bean and view part of the application. We don't want to create 2 completely separate projects as implementing changes might sometimes mean implementing them twice. THE BIG ISSUE is that we expect to have **even more forks in the future** so the effort might multiply even further. The question is what ways of control or architectural patterns can we introduce to promote better maintainability of our projects. One solution might be for example:   * using Spring profiles to inject proper components based on current fork of application and completely separating view (xhtml) implementation. **In summary we are looking for best way to implement application wide changes that can be isolated and activated only based on some context variable (how to propagate it everywhere?).** Any input, idea or new perspective is appreciated.


Java labels. To be or not to be

Before I start this question I know the java 'goto' is a big no go. So I've been writing a program and I have some indented Loops and statements and I need to `BREAK` multiple on command. Rather than having a load of `boolean` variables and `if(!<booleanName>) BREAK;` statements throughout these loops and statements what is everyone's opinions on using labels to break them using the `BREAK <label>` statement? e.g.                for(...) {                indented_example_loops:     // Label name                for(...) {                     for(...) {                          if(match) break indented_example_loops;                          // ^ Break statement to break the 2 for loops at once                     }                }           }      Perfectly okay? Okay to do occasionally? Completely avoid? or should i go to a corner and call the Devil to take my soul?


Is python lambda "really formal" λ-calculus or just share the name?

Now and then I use the Python lambda. Is it so formal that it is safe to say that you can do formal lambda calculus with it? I just used it but I didn't fully understand whether the python lambda and the lambda calculus like I read was done by Alonzo Church. I also used it in Javascript, I think. Isn't this more common in functional languages (e.g. Haskell, Scheme/Lisp, Clojure...) and I never saw lambda in use with Java or C(++)? Is says on this site " a function you can pass on to another function as argument.". What is "lambda" code? But how do I get used to it enough so that I can tell where to benefit from it? If I can do it in say SQL, JPQL or GQL instead, shouldn't I prefer to do it in the query language?


Is Tax Localization a good use for Workflow Foundation?

**Scenario:** We have both Winforms and MVC code that is being used to work on a nation wide multi-user platform that does lots of logistics for lots of users. Tax rules change per state and even per city or county. These tax rules make a huge difference for our industry. The other issue is that rules can change based on legislation. The system will have to handle cases where before a date it works one way and then different after that date. This changeover will need to be entered into the system and tested before that date comes. **Proposed Solution:** Use Workflow Foundation to create a time based system where our users can change and add rules that change the way taxes are calculated. **Question:** I have not used Workflow Foundation and searching has returned books to look at but not a lot of examples of people using this technology successfully. Is my scenario a good use of Workflow Foundation?(I think so.) If you have any experience with Workflow Foundation, any tips on making this work well?


Alternative to "Passing/Broken build" indicator?

When having a continuous integration executing the tests at each commit, a common best practice is to have all the tests passing at all times (aka "do not break the build"). I find some problems with that: For example one cannot help an open source project by creating tests corresponding to tickets. I know if I propose a Pull Request to an open source project containing failing test, the build will be marked as failed and the project will not want that merged into its repository because it would "break the build". And **I don't believe it is a bad thing to have failing tests in your repo** , it's like having open issues in your tracker. These are just things waiting to be fixed. The same goes in a company. If you work with TDD, you can't write tests, commit and then write the logic code that fulfills the test. That means if I have written 4-5 tests on my laptop, I can't commit them before going on holidays. Nobody can take back my work. I can't even "share" them with a colleague except by sending them by email for example. It also prevents working with one person writing the tests, the other one writing the model. All that to say, am I misusing/misunderstanding the build process/continuous integration? It seems to me that "passing"/"not passing" is a too narrow indicator. Is there a way to make continuous integration and TDD compatible? Maybe there is a standard solution/practice to distinguish "new tests" (that can fail) and "regression tests" (that should **not** fail because they used to work)?


ASP.NET MVC vs WCF for REST API + Webpage usage

I think the discussion for programmatic service oriented usage vs human interaction is clear. But if I were to create an application that makes use of both a programmatic API and a website that makes use of the data connected by the same API, does it lean the favour towards using only ASP.NET? How easy is it to integrate ASP.NET and WCF to work on the same application?


Freelancer Organization Solution

As a freelancer working on both paid and personal projects, I'm always splitting my time between a huge number of small and large projects/tasks/fine details. I've developed a small custom-coded solution to organizing my time and tasks. What is the best solution to organizing and managing your projects, tasks and to-do list as a freelancer? This could include both paid and unpaid services, programs, or other web-based solutions. I know it can be subjective to say 'the best', so I'll rephrase the question to 'what do you find to be the most effective solution for yourself, and why?'


What’s the opposite of abstraction?

As I understand it, abstraction is the term we use for when more meaning is created out of something simpler without altering it. It is derived from the latin verb abstrahere (to ‘draw away’). For instance, text is just one abstraction of binary data—as are bitmaps. So, in computers, text and bitmaps exist on top of (are implemented in terms of) binary data. My question is: what is the opposite term? If I want to know the possible more basic things that bitmaps could be implemented in terms of other than binary data—things like tiles for a mosaic or fabric patches for a patchwork quilt—what am I asking for? Is there a word for that? Abstraction has connotations of generalization and the opposite process of that is specialization. IDK whether that helps.


Is COBOL lucrative?

I once had this crazy idea that I might learn COBOL. COBOL developers are getting older and retiring, but there's still a lot of legacy code hanging around that needs maintaining. People have told me that this has lead to an under supply of COBOL developers, resulting in a lot of available work and could be potentially very lucrative! (not my only motivation, honest!) Is there any truth in this or is it a bit of a myth?


Implementation strategies for atomic counter

I basically have a counter variable that is decremented and frequently polled. There are three options to implement that, that I can think of: Number 1:               private volatile int count;     public void Finished() {         Interlocked.Decrement(ref count);     }          public bool Done() {         return count == 0;     }      Number 2:               private int count;     public void Finished() {         Interlocked.Decrement(ref count);     }          public bool Done() {         return Volatile.Read(ref count) == 0;     }      Number 3:               struct AtomicInteger {         private int value;              public int Get() {             return Volatile.Read(ref value);         }         // other methods     }     // In actual class:     private AtomicInteger count;     public bool Done() {          return count.Get() == 0;     }      The first one gives a compiler warning because of passing a volatile variable by reference. On the other hand it's clear from the variable definition that the variable is accessed concurrently which is clearly a warning sign to anybody looking at the code. If I ever decide that I actually need a long, this method does not work at all any more. The second one doesn't give any warnings, but just from reading `private int count` it's not clear that the variable is used concurrently, so this has to be explicitly stated with a comment (I actually had a bug where I used a normal read in an assertion instead of `Volatile.Read` \- such an easy thing to overlook.) Changing the variable to a long on the other hand does not introduce any additional work. I do like number 3 and it shouldn't result in any performance overhead compared to the other solutions after inlining. Downside: Code duplication for every primitive. On the other hand the code is simple enough and can be copy- pasted without fear of problems and is unlikely to ever change. Any comments on advantages/disadvantages of each method that I've overlooked or what would be considered idiomatic in C#?


Should all HTTP requests including credentials be made using a POST even if it is actually just a request for data?

Assume there is a request which is going to look up a list of items from a service which requires authorisation (e.g. it's behind a Basic Authentication domain). If the service didn't require authentication, I would always make this request as a GET (it's idempotent). But because the credentials would end up in the query string, I'm basically required to do this as a POST. Is there any alternative to this method?


Why there is perception that VB.NET is good for small to medium size application and not for enterprise class project?

I love VB.NET very much. Coding VB.NET with Visual Studio is just like typing messages. Smooth, fast and simple. Any error will be notified instantly. The OO capability of VB.NET is good enough. But often in any .Net languages discussion, there is perception that VB.NET is good for small to medium size application and not for large scale project? Why there is such perception? Or am I missing anything regarding to VB.NET?


Client = Html5 + CSS3 + JS + Jquery. Server =?

I want to build most of my functionality on the client. However I'm not quite sure which server-side web development framework can provide me with a nice REST endpoint to handle resources, business logic, etc. I come from a JAVA EE world, where JSF is mostly stateful and component based (both have their pros and cons, I'd just rather not keep a component tree, etc).. However... I used to build templates in Facelets, how can I do this now if I don't use JSF/Facelets as my presentation layer? Or how do I create HTML tables iterating over collections, etc? I'm open to using any language/framework. I see a lot of discussion yet not really any valuable input. Perhaps I have yet to look in the right places. There's a lot of people talking about JS + RESTful ws... Is this actually possible for a whole web site? I think that if I drop my component based web framework I'll have to implement so many things by myself, like conditionally rendered portions of the website, iterating over data to build grids, tables, handling multiple-page operations, view scoped data. Maybe someone could also tell me: are you out of your mind? Go hybrid or don't do that. Any directions will help.


Basic features for a basic language? DSL suggestions?

I've finally begun to understand the complexity behind creating an interpreter and a compiler. I've built several versions of TinyBasic, 1964 (Dartmouth) Basic, and my own expansions on those languages before getting to this point. The most recent project is one I call Open Source Basic... because I could think of no other features of the language that would interest people. To be able to open up the source of the language and understand how some complex things are done (how scanning, parsing, interpreting, and compiling are done) Open Source Basic is first interpreted into a stack based language. That stack based language is then interpreted and executed immediately or turned into a CLR executable. My questions all boil down to this:   * **What are the basic features/constructs of a Basic-based language?** I have these basic constructs already: Assignments, Expressions, Variables, some functions (Random, ToUpper, ToLower), Looping (for and do-while/until), If (block and single-line) Else decisions, console based input (Input) and output (Print), and sub-routines (with no parameters, yet).   * When I'm 'done' adding the basic constructs onto my language - how should I branch out? Into what domain(s)? In other words, **what direction(s) should my open source basic language take once I've got all the generic constructs working?** Thank you for your time, Dominick


How To Organize Factories in a .Net Project?

I'm just beginning to grasp the concept of factories, and want to use them in my next project (I'm using dependency injection, so using factories will make object instantiation easier). Some basic questions I have:   1. Does it make sense to have one factory class per application layer (GUI, BLL, DAL), per class, or just one factory class for everything?   2. What is a typical naming convention for factory classes? Addendum:   1. If I create a factory per class, in a .Net project, should I simply create one class file called Factories.cs to house all of my factory classes? If not, what would be a better approach?


Branching strategy for frequent releases

We have very frequent releases and we use Git for version control. When i am mentioning about frequency, please assume it to include bug-fixes and feature release too. All releases are eventually merged into ‘mainline’. When a release is deployed on production and if a bug is identified, people start fixing the bug on the same branch from which the latest release was deployed on production. They do not create a new bug-fix branch for the same. I feel that’s not the right way to go for. There are several components and each component has a different owner, and thus, different perspective. Though I have not initiated talks with them, I am sure there will be a lot of resistance. Main issue that they might cite would be, “There’s a lot of work involved in creating and tracking branches especially when there are so frequent deployments on production. This will consume a lot of dev effort.” Do you think that fixing bug on the same branch from which release was done, a good idea? If yes, how do you manage it? Using tags? I know that best practices may not always be applicable due to several factors but still I would like to know what might be a good approach for branching in a scenario where releases/bug-fixes happen almost on a daily basis. **Edit:** Thanks everyone for sharing your views and for the useful links. I think the main concern i have here is this: _Do you think that fixing bug on the same branch from which release was done, a good idea?_ Is this approach fine in the long run or are we messing up things just to realize it later?


the perils of using eval() for dynamic object creation -- is this a valid argument in a consenting-adults culture?

I've read on stackoverflow explicit warnings against using eval() to create objects. The reason that seems to be given is that malicious code could be injected and blindly created objects could compromise a system. Isn't this malicious-intent argument invalidated by the consenting-adult argument, though? Some sample code:               class Test(object):         def __init__(self, vala, valb, valc):             self._vala = vala             self._valb = valb             self._valc = valc              def __repr__(self):             return "<Test(vala={0}, valb={1}, valc={2})>".format(self._vala, self._valb, self._valc)               testlist = [dict(cls="Test", vala="this is vala", valb="this is valb", valc="this is valc"), dict(cls="Test", vala="this is vala II", valb="this is valb II", valc="this is valc II")]          mytestobjects = []          for test in testlist:         newobj = eval(test['cls'])(**{key: value for key, value in test.items() if key != "cls"})         mytestobjects.append(newobj)          print(mytestobjects)


How do you evolve & version an interface?

Say you have an interface `IFoo`:               public interface IFoo {         void Bar(string s);         int Quux(object o);     }      In version 2 of your API, you need to add a method `Glarg` to this interface. How do you do so without breaking your existing API users and maintaining backwards compatibility? This is mainly aimed at .NET, but can apply to other frameworks & languages as well.


Storing web app passwords so that they can be retrieved

**Short version** My boss wants me to store _user_ passwords for an ASP.NET Web Forms web app we're developing in clear text, so that a user with admin rights can click a button and get back the current passwords for the accounts she controls. _I don't want to do that_ , because I deeply care about the security and privacy of users of a web app I am involved with in whatever way. What would be a good way to store the passwords in an encrypted form, that can still however be decrypted? I can't count on users having an email address, so sending the user a link to reset the password is not an option. Read the following for more context. **Some context** This app was written by individuals who have little clue as to how software should be written. Lots of duplicated code, risks for SQL injection everywhere, no unit tests whatsoever, one new connection gets instantiated and opened for each and every query... name a bad practice, you'll find it in this codebase. The passwords are currently stored as a simple MD5 of the original string, which is weak and horrible and everything, but still a tiny bit better than clear text. I just finished implementing a feature request where the admin I was talking about can click a button and have an account automatically created for each employee she manages, with a random password. I cringe while writing this, but one of the requirements was to _export the credentials in an Excel spreadsheet_. Which I did. This is bad in and of itself, but then my boss said "What if the user loses the spreadsheet? Users are dumb, you know. There needs to be a way to get the passwords back." Bang. Getting him to listen to people who know what they're talking about is not an option, sadly. The obvious suggestion would be "GTFO", I know, but rest assured that it's something I'll do as soon as I possibly can. Meanwhile, I need to cheat and pretend I store passwords in clear text, while I do things in the best way possible to protect my users' passwords. **EDIT** For some reason people answering are assuming I'm a girl so, just for the record, I would like to clarify that I'm a guy. Not that it should make any difference, but hey ;)


What are functional languages most used for?

I wondered what functional languages are mainly used for? I've been reading about them and read about Haskell and others. Some seem to be just "academic" languages which makes little sense to me, so hoping to get a better idea of their uses in real world applications.


Is it reasonable for REST resources to be singular and plural?

I have been wondering if, rather than a more traditional layout like this:               api/Products     GET // gets product(s) by id     PUT // updates product(s) by id     DELETE // deletes (product(s) by id     POST // creates product(s)      Would it be more useful to have a singular and a plural, for example:               api/Product     GET // gets a product by id     PUT // updates a product by id     DELETE // deletes a product by id     POST // creates a product          api/Products     GET // gets a collection of products by id     PUT // updates a collection of products by id     DELETE // deletes a collection of products (not the products themselves)     POST // creates a collection of products based on filter parameters passed      So, to create a collection of products you might do:               POST api/Products {data: filters} // returns api/Products/<id>      And then, to reference it, you might do:               GET api/Products/<id> // returns array of products      In my opinion, the main advantage of doing things this way is that it allows for easy caching of collections of products. One might, for example, put a lifetime of an hour on collections of products, thus drastically reducing the calls on a server. Of course, I currently only see the good side of doing things this way, what's the downside?


Most of programmer work deals with mapping?

During all my work I've been working with ORM, WS, integration services, viewmodel and so on. The common stuff in all these kind of work is that I had to make mappings and not always the available framework are enough to help in this mapping. The question which I'm wondering is: is a consistent part of the development process dealing with mapping? It would be good to develop a tool for solving this kind of problems? i.e.               sqlClient.AddParameterWithValue("switch", SqlDbType.TinyInt, user.IDUser);     sqlClient.AddParameterWithValue("IDUtente", SqlDbType.Int, user.IDUser);      i.e.               GetSQLParameter("@switch", SqlDbType.TinyInt, 1), _     GetSQLParameter("@IDUtente", SqlDbType.Int), _      i.e.               MappingFramework.Mapper.CreateMap<DataRecordWrapper, User>()         .ForMember(dest => dest.IDUser, opt => opt.MapFrom(src => src.GetInt("switch")))         .ForMember(dest => dest.FirstName, opt => opt.MapFrom(src => src.GetString("IDUtente")))


Help identify the pattern for reacting on updates

There's an entity that gets updated from external sources. Update events are at random intervals. And the entity has to be processed once updated. Multiple updates may be multiplexed. In other words there's a need for the most current state of entity to be processed. There's a point of no-return during processing where the current state (and the state is consistent i.e. no partial update is made) of entity is saved somewhere else and processing goes on independently of any arriving updates. Every consequent set of updates has to trigger processing i.e. system should not forget about updates. And for each entity there should be no more than one running processing (before the point of no-return) i.e. the entity state should not be processed more than once. So what I'm looking for is a pattern to cancel current processing before the point of no return or abandon processing results if an update arrives. The main challenge is to minimize race conditions and maintain integrity. The entity sits mainly in database with some files on disk. And the system is in .NET with web-services and message queues. What comes to my mind is a database queue-like table. An arriving update inserts row in that table and the processing is launched. The processing gathers necessary data before the point of no-return and once it reaches this barrier it looks into the queue table and checks whether there're more recent updates for the entity. If there are new updates the processing simply shuts down and its data is discarded. Otherwise the processing data is persisted and it goes beyond the point of no-return. Though it looks like a solution to me it is not quite elegant and I believe this scenario may be supported by some sort of middleware. If I would use message queues for this then there's a need to access the queue API in the point of no-return to check for the existence of new messages. And this approach also lacks elegance. Is there a name for this pattern and an existing solution?


Adding svn support to our git repo

We have been using SVN for several years. Recently, we switched over to git, since some members of the organization pointed out that if our SVN server dies our team is toast. So far, we've got something worked out with the git workflow, however some team members really do not like this git process. They want to simply right- click on a file and then hit SVN Commit (we're using tortoiseSVN) without having to worry about all this pushing and pulling. I've been asked to provide SVN support for our repository while keeping the git repo (hosted on github) updated. The workflow I'm imagining is that we'll all just do the normal SVN things as before, and then once in awhile I'll just do a push to github to backup our files. What are some options for using git purely for backup purposes (one person would manage the git repo), while everyone uses the SVN repo? I've read about git-svn, but it seems like a completely different tool. Perhaps someone can clarify this? If I checked out a svn repo using git-svn, would I be able to operate on it using tortoiseSVN? Or can everyone else use a regular SVN checkout, while I maintain a git-svn checkout?


Great Lunch and Learn Topics

We recently revived the lunch in learns for the programming department in the company I work for. We were all asked if we had any ideas for a session, and if we would be interested in doing a presentation. I've had a few ideas ranging from various topics such as: _How to think like a user when designing UI_ or _Differences in HTML5_ A few coworkers I tossed these ideas around to seem to like them. However, I'd like some more ideas before I dig too far into creating a presentation. **What are some great lunch and learn topics?**


Need to re-build an application - how?

For our main system, we have a small monitor application that sits outside our network and periodically tries to log in to verify the system still works. We have a problem with the monitor though in that the communications component set (Asta 3 inside Delphi applications) doesn't always connect through. Overall, I'd say it's about 95% reliable, but that other 5% kills the monitor since it will try to log in and hang on the connection attempt (no timeout in the component). This really isn't an issue on the client side of the system since the clients don't disconnect and reconnect repeatedly on the same application instance, but I need a way to make sure the monitor stays up and continues working even when the component fails on a run. I have a few ideas as to which way to have the program run, the main idea being to put the communications inside a threaded data module so that if one thread crashes then another thread can test later and the program keep going. Does this sound like a valid way to go? Any other ideas how to ensure a reliable monitoring application with a less than 100% reliable component? Thanks. P.S. Not sure these tags are the most appropriate. Tried including "system- reliability" as one, but not high enough rep to create.


What is the industry norm for naming standard for gui object event handlers in C#

Lets say you have a button objects on a form with a click event (c#/.Net). How is the event handler normally named throughout the industry?   * fooButton_Click   * fooButtonClick (or if you like Hungarian)   * btnFoo_Click   * btnFooClick When visual studio creates the event handler it defaults to underscore + EventName. This seems to violate the norm of using camelCasing and UppderCamelCasing instead of separating words with underscores. Is there any reason to change it, or practically everyone following what Visual Studio does?


Examples of web applications that work entirely offline using HTML5

I would like to check out some real-world web applications that work offline using HTML5 (application cache and local storage, I believe). I am not able to find any. I can find a lot of experimentations, but not an application with actual users. Why is that?


How do I access databases from a mobile device securely?

I have been doing some research on accessing a DB from mobile devices. There are so many different ways of doing it. There are also multiple ways to make it secure. What is a good way to access a database from a mobile device securely? Also considering my specific case, where I have an existing WCF service which does everything I would need for the app, I would like to re-use it. I have been working on using jsonp calls to the service and develop apps for iOS, Android and windows phone. The calls are secured by HTTPS and I would be implementing some authentication policy for the calls. But how secure would all this be? I have some really sensitive data to worry about. I am using HTML5 and JS for app development to keep it uniform and less difficult to manage for all platforms. How do I access the database and keep my data secure?


What counts as an IDE?

Recently reading the question What languages do you use without an IDE? One question asked in a few answers was "is Notepad++ and IDE?" One answers to the original question said "None, I use vim...", implying that vim is an IDE. But then another answer suggested vim isn't an IDE. So where is the line? What about notepad, ed, or nano? Is the only non-IDE coding technique the butterfly technique?


Is it poor practice to call methods through multiple objects?

I have code that looks like this:               tr.t.findIndexSmoothed(arg0.getX(), arg0.getY());      "tr" and "t" are objects. Is it bad practice to reach all the way down the object hierarchy to call methods? The only reason I can think of is that is breaks encapsulation, and if that's the case, can anybody tell me why that poses a problem? Also, does this code structure inhibit performance in any way?


Version Changes: How considerable are the compatibility issues in project?

For example if we consider ActionScript2.0(based on Objects but programming does not implement much OOP ) vs 3.0(highly OOP) its like a whole new scripting language in the sense of approach, programming style,features you get the idea. In PHP we can see current versions going from 3-5. brief version changes   * Question :Developers who work on PHP is it easy to migrate from version to version?   * Question :Are there any extensive compatibility issues, forward or backward?   * Question :Does your project stick to a particular version till the end ?   * Question :Does the programming style ,approach change from version to version?   * Question :If you had to get started on PHP to contribute to a project built earlier versions, would learning the latest version be counterproductive towards this aim? Some related topics i had come across on SE How should I be keeping track of php script version/changes? What is happening to PHP 6? * * * It would be Really helpful in understanding if you could answer this topic directly to the questions put forth.


Etiquette: Our old developer is displaying our project in his portfolio without permission

I was wondering what the situation is regarding a sub-contracted programmer using our project in his portfolio. He has dragged an 8 week build to over a year, messed us around, disappeared for 3 months in the middle of it and has cost us money. We have had to pay someone else to correct all his mistakes. He is assuming he can, and is kicking up a fuss when we implied we may not let him. I feel we are well within our rights to refuse, based on this guys quality of work and timescales, he has caused the project to stall. In our work agreement we stated that we didn't want him to have an actual text credit on the product itself, but that we would happily write him a reference if he wanted to pitch for work on the back of it. That he signed and agreed to. As the ones who designed the product, and all of the front end, we feel we should have the right to not allow him to display our product on his website. Maybe we don't want the world to know that our expensive high-end product was built by one guy in India. Perhaps we are trying to place ourselves as a company who delivers the whole package, including the programming side. Is it considered good etiquette to ask permission first before displaying software in a portfolio?


Do any package managers provide select-one dependencies

With jquery very slowly being phased out you get into more and more situations where library X will run with either jquery or zepto.js (but at least one is required). No package managers that I can think of however allow you to express dependencies like this. If I was to propose this feature to - say - bower, is there precedent for how it might look?


Best Way to Express Meta-Info on Missing Data?

I work in healthcare IT, reviewing data management processes of various observational studies. One problem I have repeatedly faced is the poorly encoded data, especially when some values are missing. * * * **Background Intermezzo, skip if you suffer from TL;DR:** I am currently reviewing a study which collects data on patients suffering from a specific disease. Patients usually join the study once the disease is confirmed (a few months after the outbreak). One of the important parameters is the result of a certain blood test in the acute phase of the disease, i.e. hopefully as close to the outbreak as possible. Sometimes however, that test was not performed because there was no indication for it or the patient forgot to bring a copy of the result, etc. An important aspect here is that all the data in the DB is generated from (tons of unsorted) paper files and often people do not have the time to skim through all of it, so they do not enter the blood test's result just because they _haven't gotten to it yet_. * * * In order to "somehow" encode reasons for a value being absent, I have seen various schemes:   1. **Use a TEXT(3) field for booleans** and use `n/a` to express that "the data really isn't available" (e.g. because the blood test wasn't performed) and `NULL` to express "Maybe the data is somewhere, I just haven't looked for it yet".   2. **Use an additional field in the same table** , e.g. a boolean field "bloodtest_perf" where "perf" stands for "actually performed".  I dislike the first approach because it allows you to enter "yes", "y", "ja", "YES", etc. and you end up spending most of the time cleaning instead of analyzing data. The second approach isn't much better either, because you end up with dummy data at best and inconsitent data at worst:               __ TBL_TEST1 __________________________________     | patID | test1_perf | test1_date | test1_res |     +---------------------------------------------+     | 12345 | no         | NULL       | NULL      |     | 12345 | yes        | 2011-05-13 | 20.0      |     +---------------------------------------------+      The most sensible solution in my opinion would be to create a `TBL_TEST1_METADATA` which contains an entry IFF test1 was not performed which specifies why not, but the people (clinicians with rudimentary MS-Access knowledge) aren't educated well enough to & are not willing to invest a serious amount of time to program the logic required to write values to two tables from one Access form. My dilemma is that I see patient-decades of data going lost because of insufficient data quality, while I can't find a pragmatic solutions "DB- amateurs" can implement in an acceptable timeframe because I'm (too?) obsessed with doing it the _right way [tm]_. Am I missing the obvious? Or is the only way to improve the situation to send physicians to programming classes or provide them with a "programming minion" that does it for them? PS: I'd love to ask this question **onhealthcare IT.SE.com**, but the proposal hasn't received enough attention yet to go beta.


Is it an absolute must that we ignore/delete all compiled files before committing?

I am working on a Drupal theme. I am going to be using "intermediary" languages to develop it, ie Stylus for styles, and CoffeeScript for some of the front-end scripts. I am going to be using a git hosting service to be able to share the code among colleges. I am also going to be using it to update the code locally and then push onto hosting service, to be later pulled by the live drupal site. This makes things really elegant. However, I have noticed that a lot of developers tend to .gitignore all compiled code. If it were a good practice, I would've loved to follow it, if and only if there wasn't this one issue: recompiling all the code that is needed in order for the theme to work out correctly. This means that when I do a pull, I will have to recompile all the CSS and JavaScript code. Now, if I were to do a pull on the live site, there's a risk that a user goes to the site right at the moment I do the pull. No styles and scripts will be loaded on the user's end, so long as the code hasn't compiled. Of course, compiling takes about a second, and the user might probably think to him/herself "meh, it was just my internet connection." But there is also the issue that the server doesn't have the compilers installed to begin with. So now, I would do a pull, but there will be no styles, and no scripts. Is it an absolute must that I delete all compiled code, or can I go ahead and include them in the commit?