Too complex/too many objects?

I know that this will be a difficult question to answer without context, but hopefully there are at least some good guidelines to share on this. The questions are at the bottom if you want to skip the details. Most are about OOP in general. Begin context. I am a jr dev on a PHP application, and in general the devs I work with consider themselves to use many more OO concepts than most PHP devs. Still, in my research on clean code I have read about so many ways of using OO features to make code flexible, powerful, expressive, testable, etc. that is just plain not in use here. The current strongly OO API that I've proposed is being called too complex, even though it is trivial to implement. The problem I'm solving is that our permission checks are done via a message object (my API, they wanted to use arrays of constants) and the message object does not hold the validation object accountable for checking all provided data. Metaphorically, if your perm containing 'allowable' and 'rare but disallowed' is sent into a validator, the validator may not know to look for 'rare but disallowed', but approve 'allowable', which will actually approve the whole perm check. We have like 11 validators, too many to easily track at such minute detail. So I proposed an `AtomicPermission` class. To fix the previous example, the perm would instead contain two atomic permissions, one wrapping 'allowable' and the other wrapping 'rare but disallowed'. Where previously the validator would say 'the check is OK because it contains allowable,' now it would instead say '"allowable" is ok', at which point the check ends...and the check fails, because 'rare but disallowed' was not specifically okay-ed. The implementation is just 4 trivial objects, and rewriting a 10 line function into a 15 line function.               abstract class PermissionAtom {     public function allow(); // maybe deny() as well     public function wasAllowed();     }          class PermissionField extends PermissionAtom {     public function getName();     public function getValue();     }          class PermissionIdentifier extends PermissionAtom {     public function getIdentifier();     }          class PermissionAction extends PermissionAtom {     public function getType();     }      They say that this is 'not going to get us anything important' and it is 'too complex' and 'will be difficult for new developers to pick up.' I respectfully disagree, and there I end my context to begin the broader questions. So the question is about my OOP, are there any guidelines I should know:   1. _is_ this too complicated/too much OOP? Not that I expect to get more than 'it depends, I'd have to see if...'   2. when is OO abstraction too much?   3. when is OO abstraction too little?   4. how can I determine when I am overthinking a problem vs fixing one?   5. how can I determine when I am adding bad code to a bad project?   6. how can I pitch these APIs? I feel the other devs would just rather say 'its too complicated' than ask 'can you explain it?' whenever I suggest a new class.


Is it OK to let invalid arguments slip to another method?

For example lets take this method:               public List<string[]> ReadAll(int listCapacity)     {         List<string[]> list = new List<string[]>(listCapacity);              while (Read())         {             list.Add(GetCurrentRow());         }              return list;     }      If `listCapacity` is less than zero, an `ArgumentException` will be thrown by the constructor of `List<T>`. Does it make sense to double check this? Passing the argument to `List<T>` immediately seems careless, but checking it seems silly because `List<T>` will definitely check it. Important note: the code snippet is not just a copy-paste method, its part of a full utility.


Any good hackathons/competitions to refresh my programming skill?

I spent this summer as a PM, so my programming skills may have gotten a little rusty. I want to refresh those skills, and I'm looking for things like online hackathons or competitions. Preferably ones that happen every week or day so I can practice often. Where should I look ?


Are UML class diagrams adequate to design javascript systems?

Given that UML is oriented towards a more classic approach to object orientation, is it still usable in a reliable way to design javascript systems? One specific problem that I can see is that class diagrams are, in fact, a structural view of the system, and javascript is more behaviour driven, how can you deal with it? Please, keep in mind that I'm not talking abot the real world domain here, It's a model for the solution that I'm trying to achieve.


Starter BOOKS On Data Analytics and Algorithms in Computer Science

Am Programmer cum Co-Founder of Start-up,Am a computer Science Graduate though am not good at Algorithms,I want to learn and sharp that side.Please suggest me some nice books for starters and Advance Level.


Link between tests and user stories

I have not see these links explicitly stated in the Agile literature I have read. So, I was wondering if this approach was correct: Let a story be defined as _"In order to [RESULT], [ROLE] needs to [ACTION]"_ then   1. _RESULT_ generates system tests.   2. _ROLE_ generates acceptance tests.   3. _ACTION_ generates component and unit tests. Where the definitions are the ones used in xUnit Patterns which to be fair are fairly standard. Is this a correct interpretation or did I misunderstand something?


Should we use JavaScript and CGI variables to weed out bots from our visitor reports?

I am using ColdFusion 8 and jQuery 1.7. ** This is a programming question, because the solution I am questioning requires programming. It may not be the right solution to the problem, but if it is, then I need to figure out how to best program the concept. ** When a user comes to our site, we track their session by writing various CGI variables to a database using a CFC and stored procures. First we filter out non human traffic by keywords in the user agent such as "bot". Unfortunately a lot of bots and spammers mask their user agents. Later, we try to exclude from our visitor reports the bad bots and a few other known entities that are scraping pages and such. But this is a manual process. We are considering using an additional/alternate method of tracking usage. Once the user's page loads, we will use JavaScript to send the CGI variables from the client back to our server and store them. Specifically, we'll write the server variables to JavaScript on each page and then have JavaScript send them right back to us. If a bot or user doesn't fully view the page or have JavaScript enabled, the usage won't be counted is a real user. Correct me if I am wrong, but this is the same method that Google Analytics uses to track user behavior. Our goal is to eliminate good and bad bots from being counted as visitors in our reports. Does using JavaScript on a page like this minimize bots being counted? Is there a gaping hole in this plan?


Rights and use of developed software

I have been working on a piece of software for a company, that they wish to resell. There was an mail-based agreement upon a flat hourly rate for my work, and eager me chose to accept a rather low fee. Due to the stress and tempo of the task, a direct contract was never formed or signed. The software was developed locally on my machine, and I was pretty much alone with it, except by excellent help from StackOverflow when I got stuck. Now, the software is nearing completion, I suddenly hear that they have hired a new developer to make the same piece of software as me, and that I was expected to resign within long. Confused I ask around, and realize that the CEO of the company had informed the rest of the company that I was terminally ill and had cancer, and was expected to leave the company soon. Since I'm perfectly healthy, this confused me even more, until I realized what was going on. When I confronted my boss with this, I was no longer seen as a member of the company, and I left the same day, never to return. Later, I raised the question about my missing pay, since I had been working for quite a bit, and not received any payment for my software. I saw that they had already sold a fair copy of my software, and since it's not exactly sold cheap, the company should have plenty of gold to pay me. The company refused, and said that they owned the software, and everything it contained. That was a lot of drama, but my question is this: **Who has the rights to the software ?** The source code had my personal watermarks and copyrights inprinted, but they have since simply deleted it. The company claim that they have all the rights, because they have a website made about the product, where they write that they have "All rights reserved" in the bottom. My instinct tells me that if a company buys a service like this, and then refuses to pay their developer, then they should not be allowed to keep, and much less resell the product. I have not signed any agreements about giving the company the use of this product, I have made it in my own time and without help from the rest of the company. This all takes place in Denmark, Europe, but I would guess that the rules about this is somewhat universal. Im not the strongest person to legal-talk, so I might be wrong.


best and most used algorithm for finding the primality of given positive number

When I was in college and as a programming language learner I wrote program for finding out prime numbers but then I never mind the program performance in terms of speed. Now after long time just started solving the problems from projecteuler.net. Now I wonder is there any best and most used algorithm for finding the primality of a given positive number which produces the result fast? Thanks


What specifications in software development are relevant to the clients?

Say your company develops software, and a client wants you to handle their development. It just so happens, that they have their own IT-team, but it is fully tied up, so they outsource to you. The project is in a quotation phase, and your client's Head of IT now asks for a requirement specification (SRS), an architectural specification, and so on. The Head of IT wants to know functions, modules and other decisions that will be in construction. Other than the SRS for analysis, is your company obliged to provide these specifications, even before the project has been confirmed?


Sending e-mail from a web application without being filtered out

For a web application I'm working on right now it's very important that automated e-mails arrive at the recipient. I've set up the mail server on the VPS that the application is going to run on. I've taken all the regular precautions to make sure that the e-mails it sends are not going to be filtered out: SPF, DKIM, e-mails have both a plain text and html part, html part is valid html etc. etc. Still some services - in particular Microsofts outlook.net addresses - either block the message or automatically mark it as junk mail. I've read up a little on how Microsoft determines if a message is junk and in our case it's most likely the reputation of the mail server. Since it's a new server it doesn't have any reputation yet. How do other developers deal with this type of problem? Do you use external SMTP services like Google Apps to send mail from your application? Any ideas or tips?


Is there such thing as an example driven parser generator or ad-hoc DSL development?

I'm intrested to know if there exists a tool that lets you input examples of valid documents and lets you then generalize from that to a reusable parser. I can imagine this, but everytime i start learning about parsers it gets to the granularity of something like lex and yacc and it seems more complicated than my instincts say it should be. So I'm left wondering if   * a) it's just fundamentally that complicated and I need to see it or    * b) there's a way to build ad-hoc DSLs for relatively simple tasks that I could learn about Update: a simple example of an "ad hoc" dsl i might like to make quickly. Instead of the XML               <foo>       <item>bar</item>       <item>bat</item>     </foo>      I might want something like:               foo       bar       bat        * lines contain data items   * indentation produces parent-child relations My imaginary tool lets me convey the above information. Then, in my imaginary tool, I might highlight "foo" above and right click, at which point it would prompt me to restrict the values to a choice list.... Then I might extend the first one to:               foo       bar(5)       bat        * in a line, '(' and ')' surround a sub item The above might be qualified with a boolean value that specifies recursion or not, if set to true then bar(lala(4)) might work... This is the kind of train of thought I generally have that led me to ask the question. It's possible that now I've qualified it, the answer changes - if so I apologize in advance.


Is there a good Cognitive Architecture for implementing intelligent software agents?

So, I like dabbling in intelligent agent design (mainly video-game 'bots' but also some general task automation), but as a budding psychologist, I'd be really interested in a platform for developing such agents in a cognitively plausible setting. Such a platform would probably take the form of a cognitive architecture, but since these are meant to be implementations of psychological theories above all else, I'm worried that none of them are up for actually acting as an intelligent agent in a complex software environment like a video-game. Has anyone tried using such an architecture to produce an agent of the kind I've been describing? Failing that, do any cognitive architectures look particularly suitable for this sort of job? My current hunch is that a hybrid architecture like CLARION might work, but not having any experience with it, I'm still hesitant. I know that SOAR has famously been used to simulate a fighter pilot, but that took years of hand-coding production rules, and thus seems like an impractical platform from my standpoint.


Single Responsibility Principle Implementation

In my spare time, I've been designing a CMS in order to learn more about actual software design and architecture, etc. Going through the SOLID principles, I already notice that ideas like "MVC", "DRY", and "KISS", pretty much fall right into place. That said, I'm still having problems deciding if one of two implementations is the best choice when it comes to the Single Responsibility Principle. Implementation #1:               class User         getName         getPassword         getEmail         // etc...          class UserManager         create         read         update         delete          class Session         start         stop          class Login         main          class Logout         main          class Register         main      The idea behind this implementation is that all user-based actions are separated out into different classes (creating a possible case of the aptly- named Ravioli Code), but following the SRP to a "tee", almost literally. But then I thought that it was a bit much, and came up with this next implementation               class UserView extends View         getLogin //Returns the html for the login screen         getShortLogin //Returns the html for an inline login bar         getLogout //Returns the html for a logout button         getRegister //Returns the html for a register page         // etc... as needed          class UserModel extends DataModel implements IDataModel         // Implements no new methods yet, outside of the interface methods         // Haven't figured out anything special to go here at the moment         // All CRUD operations are handled by DataModel          //   through methods implemented by the interface          class UserControl extends Control implements IControl         login         logout         register         startSession         stopSession          class User extends DataObject         getName         getPassword         getEmail         // etc...      This is obviously still very organized, and still very "single responsibility". The `User` class is a data object that I can manipulate data on and then pass to the `UserModel` to save it to the database. All the user data rendering (what the user will see) is handled by `UserView` and it's methods, and all the user actions are in one space in `UserControl` (plus some automated stuff required by the CMS to keep a user logged in or to ensure that they stay out.) I personally can't think of anything wrong with this implementation either. In my personal feelings I feel that both are effectively correct, but I can't decide which one would be easier to maintain and extend as life goes on (despite leaning towards Implementation #1.) So what about you guys? What are your opinions on this? Which one is better? What basics (or otherwise, nuances) of that principle have I missed in either design?


GPL- How much source must be released?

Suppose I have a GPL v2-licensed library that is of interest to a closed- source project (e.g. Wolfram Alpha). If some of my code were used in Wolfram Alpha, or a product that interfaces with Wolfram Alpha, would they have to release all of their code for Wolfram Alpha under the GPL v2 license?


How to stop switching between keyboard and mouse

I touch-type since several years, but very often I need to switch between different applications. For text editing I don't need the mouse, but as soon as I need a web browser, I switch to the mouse. I guess I loose a lot of time and energy doing this. Since I do web development I often switch between keyboard and mouse. Do you have a working solution? Please don't tell me about browser plugins you have never used yourself. Thank you.


DataMapper for a MMO game plugin to send packets

I am working on an plugin for some game-server. The information about the plugin is not really necessary. _Few points you might find helpful to answer to this question:_ **The server** The server is programmed very badly. The whole design structure and how it handles things, therefore I cannot implement anything that will need to make me change how the server handles packets. The server has a list of all "being-sent" packets, and **sends them to the client every 600ms** So basically, the client is being updated every 600ms if there are incoming packets from the server. **My plugin** My plugin needs to update a few UIs of the client, such as new player names, change the current opened interface window, and so on. I can use a `DataMapper` class, which contains the object which has ability & access to add new packets to the list (it's not really a list; it's just a list of bytes and frames). Now look at this _dummy_ snippet (Note - this is not my plugin, but just a simple example of what I mean):               public class MyPluginPlayer {              private DataMapper mapper;         private int state;              public void setState(int state) {             this.state = state;         }              public void getState() {             return this.state;         }              public void selectWindowForState() {             if (this.state == 5) {                 mapper.createLongWindow();             }             else if (this.state == 4) {                 mapper.createWideWindow();             }             // .... etc ....         }     }      In my _dummy_ example, `MyPluginPlayer` is the lass which is responsible to handle business logic for the player that is part of my plugin, let's say my plugin is a small mini-game, like a cards game. So basically, imagine there is a manager class, which contains a List of `MyPluginPlayer` objects, and it loops through them all and works them out, setting the current state, and then calls `selectWindowForState()`. `selectWindowForState()` method basically reads all possible states, and then reads which state is the current state, and then calls the suitable method in the `DataMapper`, to send the right packet. The `DataMapper` class basically does all the dirty work such as creating new packet frame, writing the bytes, `int`s and whatever that is needed for the specific packet. **The problem** I call the use of `DataMapper` above bad, because I don't feel like the domain class should really have direct access to the `DataMapper`. I thought of making a `Queue` list and instead of calling `mapper.createWideWindow()` or whatever, it will add the action to the queue list, and then the `DataMapper` will access that list, and process all these packets to the server's global outgoing packet list. The `DataMapper` will do that at the end of every loop cycle that's done in the manager class.               for (Player p : players) {         MyPluginPlayer domain = p.getDomain();         // ...... management ..... //              p.getMapper().update(); //goes through the Queue list and adds all packets to the server outgoing packets     }      But I am not really sure on how to define these packet updates. The only method I can think of is, every packet will have an own class which implements an interface. But I will need to create a class for each packet, and I don't really like the design of many many classes for a small thing. What do you think of both of these methods? Could you suggest something better?


What advantages switching to ruby might give me as a python programmer?

This is my first question on stackoverflow, so please bear with me. I'm trying to stay away from any form of trolling or flame baiting as i have a tremendous respect for both languages. I'm a python programmer (though not an expert) and i love it. My first language was C++. My line of work (web development) is pushing me towards other languages like php and javascript. Recently, I've been very excited by Ruby's increasing popularity. However I used to be under the impression that Python and Ruby were so close that there was little point in trying to learn and master both. But I get the sense that I was wrong, hence my question : I'd like to hear from python programmers who have either switched entirely to ruby or added ruby to their toolset. What specific benefits did you get from switching (entirely or partially) to Ruby from Python ? Ideally I'd like to hear from real world experiences.


Java for loop: why can't I declare two variables in the for loop 'header'?

I always wondered, why doesn't this compile?               for(int i=0, int q=0; i<a.length; i++){        ...     }      Why doesn't Java allow me to declare more than one variable in the for loop 'header'? Is there a logical reason behind this?


The age-old question about beginning programming hasn't been answered for me

I've been wanting to learn how to program for years but thus far, every book and video has gotten over head very quickly. I eventually want to learn C# for both Windows software development and game development (Unity3D to be specific - it's a game engine that uses C#). I know absolutely nothing about programming/scripting, other than generally what can be achieved. I've been a web developer for years and know HTML very well, CSS semi-well, and Javascript not at all. I'm a pro at breaking scripts. :) I've sort of shifted away from web development and want to focus on learning programming itself. It's like a vicious cycle for me - every 6 months or so I get into the "Ok I'm prepared to learn" phase, find a tutorial or book, get overwhelmed, then give up. I'm writing this just after I saw a video series about C# fundamentals, but after 3 videos I was completely lost. It's like they all mention a concept like conditional strings, breeze over it, then assume you understand it. Although C# is the end-goal, is it worth learning an easier language like VB as a complete and utter novice at first? I know there's not a ton of difference and learning new languages gets easier and easier as it's mostly about syntax, but I feel like I can't wrap my head around even the most basic of concepts as a foundation. For example, I know exactly what I want a program to do and when I explain it to a programmer they normally code it very quickly. If I could write it in plain English I could do it myself. :) Should I keep trying to learn C# or should I delve into another language to get more of a basic understanding of coding itself then transition to it? Every house needs a foundation but I feel like I can't even grasp how concrete is made when building it.


To find the oldest/newest element in a heap

I want to find the oldest/newest element added into a heap of size k. At any given point of time if I have to find say the oldest element in the heap is there any approach with O(1) space and O(1) time. I was thinking of an approach of having a queue of the same size as that of the heap and add all the element into the queue as they are added to the heap. This yields a constant time solution but this requires an extra O(k) space. I would like to know if this problem can be solved with constant space.


Should I give the answer to a failed interview coding exercise?

We had a senior level interview candidate fail a nuance of the FizzBuzz question*. I mean, really, utterly, completely, failed the question - not even close. I even coached him through to thinking about using a loop and that `3` and `5` were **really** worth considering as special cases. He blew it. Just for QA purposes, I gave the same exact question to three teammates; gave them 5 minutes; and then came back to collect their pseudo-code. **All of them** nailed it and hadn't seen the question before. Two asked what the trick was... On a different logic exercise, the candidate showed some understanding of some of the features available within the language he chose to use (C#). So it's not as if he had _never_ written a line of code. But his logic still stunk. My question is whether or not I should have given him the answer to the logic questions. He knew he blew them, and acknowledged it later in the interview. On the other hand, he never asked for the answer or what I was expecting to see. I know coding exercises can be used to set candidates up for failure (again, see second link from above). And I really tried to help him home in on answering the core of the question. But this was a senior level candidate and Fizz-Buzz is, frankly, ridiculously easy even with accounting for interview jitters. I felt like I should have shown him a way of solving the problem so that he could at least learn from the experience. But again, he didn't ask. What's the right way to handle that situation? * * * * _Okay, that's not the link to the actual FizzBuzz question, but it is a good P.SE discussion around FizzBuzz and links to the various aspects of it._ _Footnote 2_ : To help clarify, this is the nuance of Fizz-Buzz I asked and it's from Project Euler's first problem. Substitute printing Fizz | Buzz for summing the numbers and you have the same fundamental question. `If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.   Write a function that finds the sum of all the multiples of 3 or 5 below 1000.` _Footnote 3_ : This question attracted more attention than I had expected, and I appreciate all of the replies. Some of the later answers have really gotten to the core of my question, so I'll allow the community to review and up-vote before assigning "the" answer. _Footnote 4_ : I selected "the" answer based upon community votes at that point in time. And I think Yannis' answer is appropriate for interviews with newer devs. I think the collective response focusing on the lack of asking for the answer is spot-on as well.


What is meaning of the term "Sans" in a class name?

I was reading code of a java project where I found a class name like "UserSansXml". This class is dealing with user objects. I wanted to know the meaning of "sans".


Java Cryptography Extension

I was told that in order to support AES256 encryption inside my Java app that I would need the JCE with Unlimited Strength Jurisdiction Policy Files. I downloaded this from Oracle and unzipped it and I'm only seeing 2 JARs:   * `local_policy.jar`; and   * `US_export_polic.jar` I just want to confirm I'm not missing anything here! My understanding (after reading the `README.txt`) is that I just drop these two into my `<JAVA_HOME>/lib/security/` directory and they should be installed. By the names of these JARs I have to assume that its not the Java Crypto API that cannot handle AES256, but it's in fact a **legal** issue, perhaps? And that these two JARs basically tell the JRE " _yes, it's legally-acceptable to run this level of crypto (AES256)._ " Am I correct or off-base?


C simple arrays and pointers question

So here's the confusion, let's say I declare an array of characters               char name[3] = "Sam";      and then I declare another array but this time using pointers               char * name = "Sam";      What's the difference between the two? I mean they work the same way in a program. Also how does the latter store the size of the stuff that someone puts in it, in this case 3 characters? Also how is it different from               char * name = new char[3];      If those three are different where should they be used I mean in what circumstances?


How much time should jquery wait?

I'm programming a jQuery functionality for doing a search on articles while the user is typing in the search field. I implemented a bind in jQuery that at every `keyup`, it sets a `clearTimeout` and a `setTimeout` to the actual function doing the `post` to the server. This is because users can be writing something and I want to avoid multiple `post`s. I got "stuck" with: from the user interface point of view, what time should I set for the `setTimeout`? I tried different times (1s, 1.5s, 0.5s) but I have to admit the choice seems kind of random to me. This raised the broader question: Is there any reference or study that answers the question of what are the "optimal" times for dynamic web interfaces? I only now noticed that I've used more timers before (e.g. slides), that were also chosen "randomly". Putting in other terms, does anyone knows how to _justify_ why a given event in web interface has (or should have) a specific delta-time or range of delta- times? (I'm sorry if this question is not adequate to here, It seemed to me closer than SO.)


Why using FMOD?

I'm creating a music player using C++ and QT, everyone says use FMOD. But QT has all the components, I can play audio, create playlist, and everything i need, so what does FMOD offer me, that can't be done with QT? I did some research, here and here and here, and so many other results; in fact if you just google _"create music player"_ you get _"use fmod and qt as GUI"_.


Best practices for team workflow with RoR/Github for designer + coder?

My friend and I have started to try to collaborate on some projects. For background, I come from a PHP/Wordpress/Drupal coding background, but recently I've become more experienced with the RoR framework, while he is more experienced as an HTML/CSS designer, working with PHP and WordPress. We're both relatively new to RoR I think, and so we're trying to figure out our collaborative workflow, but we have no idea where to start. For instance, we were trying to figure out how he could do some minor edits to the CSS file without having to do a full RoR deploy on his box. We still haven't figured out a solution, so I think it's best if we start to set some sort of workflow based on best practices. I was wondering if you guys have any insight or links to articles/case studies regarding this topic?


Java regex patterns - compile time constants or instance members?

Currently, I have a couple of **_singleton_** objects where I'm doing matching on regular expressions, and my `Pattern`s are defined like so:               class Foobar {       private final Pattern firstPattern =         Pattern.compile("some regex");       private final Pattern secondPattern =         Pattern.compile("some other regex");       // more Patterns, etc.       private Foobar() {}       public static Foobar create() { /* singleton stuff */ }     }      But I was told by someone the other day that this is bad style, and `Pattern`s should **always** be defined at the class level, and look something like this instead:               class Foobar {       private static final Pattern FIRST_PATTERN =         Pattern.compile("some regex");       private static final Pattern SECOND_PATTERN =         Pattern.compile("some other regex");       // more Patterns, etc.       private Foobar() {}       public static Foobar create() { /* singleton stuff */ }     }      The lifetime of this particular object isn't that long, and my main reason for using the first approach is because it doesn't make sense to me to hold on to the `Pattern`s once the object gets GC'd. Any suggestions / thoughts?


Finding the order of a set's elements

A little rephrased, in the form of a game, real-life problem: Suppose there is a set of elements {1, 2, ..., n}. Player A has chosen a single permutation of this set. Player B wants to find out the order of the elements by asking questions of form "Is X earlier in the permutation than Y?", where X and Y are elements of the set. Assuming B wants to minimize the amount of questions, how many times would he have to ask, and what would be the algorithm?


How to Implement a Parallel Workflow

I'm trying to implement a parallel split task using a workflow system. I'm using .NET but my process is very simple and I don't want to use WF or anything heavy like that. I've tried using Stateless. So far is was easy to set up and run, but I may be using the wrong tool for the job because I'm not sure how you're supposed to model parallel split workflows, where you have multiple sub-tasks required before you can advance to the next state, but the steps don't require being performed in any particular order. I can easily use the dynamic configuration options to check my data model manually to see if the model is in the correct state (all sub-tasks completed) and can transition to the next state, but this seems to completely break the workflow paradigm. What is the proper, orthodox way to implement a parallel split process? Thanks


Structural pattern for an unconventional use of a database

I'm writing a game client as a personal project and using using it as a vehicle to learn about Java database access, specifically Neo4j, and possibly Spring Data Neo4j if I decide it's appropriate. I'm well aware that my application is a bit unconventional, and this has raised questions that are hard frame narrowly. I hope this question is appropriate for this site. Maybe the best way to ask this is to first explain what I'm thinking of doing and why. My main reason for incorporating a database is persistence, not queryability. Because reaction times are critical, my plan is for the primary model of the game state to be an in-memory POJO graph. I want to update the persistent database in an asynchronous, eventually-consistent way. If I understand correctly, this is the reverse of most database applications, in which the database is authoritative and the in-memory data is just a snapshot copy. Is there a name for this pattern? If you've written something like this, what are some of the pitfalls I may encounter? Is it naive to even try this?


Business rule to display data in all uppercase - how to handle?

Part of a system I am working on manages some securities information (stocks, bonds, etc...) and business rules specify certain fields be displayed only in all CAPS (stock symbols and CUSIPs for example). Users will have to look at data displayed on the screen as well as perform create/edit data-entry operations. Where is the best place to deal with this? _1\. Presentation layer only_ user enters "ibm" as stock symbol, stored in database as "ibm", converted to uppercase when displayed in app ("IBM") _2\. Convert to CAPS before storing in DB_ user enters "ibm", model class converts to uppercase and sends to database, stored as "IBM" Something like a custom setter:               private string _StockSymbol;     public string StockSymbol     {         get { return _StockSymbol; }         set          {             if (value != null)                 value = value.ToUpper();             _StockSymbol = value;         }     }      _3\. Convert to CAPS at DB_ user enters "ibm", database insert query converts to "IBM" (for example, using the `UPPER` function in SQL) The end result is the same for the users - they see their data in all CAPS and the system doesn't care if their data input is in the proper case or not. The most "MVC compliant" answer seems to be #1, but if this data will never be used in any other format other than all CAPS, I would argue it should be validated as such before being stored in the database. That then becomes more of a controller or view model concern, right? I've heard people speak about accomplishing this client-side with Java (and even CSS), but that seems like a very poor solution. I think the question is language/system-agnostic, but if it matters, I'm using MS SQL with Entity Framework/ASP.Net MVC. What I'm scratching my head over is whether or not a presentational business rule like this should influence how the data is stored in the DB (CAPS vs no CAPS). The application doesn't care if the stock symbol IBM is input as "iBm" or "ibM" but it seems wrong to store the data like that (it will only ever be used/displayed in CAPS). Would you consider this a data validation issue to be handled at the controller/model level, or a presentational detail to be handled only at the view?


Make Return Type an Interface - Problem with Initialization

I would like to make the return type of my method an interface rather than a class for similar reasons stated in c# List or IList, however I am having trouble figuring out how to initialize the interface to return it. I cannot use `new IA()` and `(IA) new A()` does not work as I cannot cast the result to `B`.               interface IA{}        class A: IA{}     class B: IA{}          class UseIA     {       public IA DesiredMethod()       {         return ???;// new IA()       }       public A UndesiredMethod()       {         return new A();       }     }


storing map template in database

I am working on an application that displays choropleth maps. These maps are of all different types, some display state by county, country by state/province, or world by country. How should I handle storing the map information in the database? **My Thoughts:** I won't need to do queries to find POI inside a region, so I don't think there is a need to use spatial datatypes. I am considering storing a map as a geoJSON object (I am using JS mapping library that accepts geoJSON). The only issue is what if I want a map of the US northeast. Then I would have geoJSON for the US and a separate one for the US northeast, which would be redundant. Would it make sense to have a shape database where I had each state then when I needed a map of the US I could query for each state, and when I needed a map of the US Northeast I could again query for what I need? **Note** : I am not concerned with storing the data for each region, just the region itself. I will query for the data on the fly for the specific region.


Configuration data: single-row table vs. name-value-pair table

Let's say you write an application that can be configured by the user. For storing this "configuration data" into a database, two patterns are commonly used.   1. The _single-row table_                CompanyName  |  StartFullScreen  |  RefreshSeconds  |  ...     ---------------+-------------------+------------------+--------       ACME Inc.    |        true       |       20         |  ...        2. The _name-value-pair_ table                ConfigOption   |   Value     -----------------+-------------      CompanyName     | ACME Inc.      StartFullScreen | true (or 1, or Y, ...)      RefreshSeconds  | 20      ...             | ...      I've seen both options in the wild, and both have obvious advantages and disadvantages, for example:   * The single-row tables limits the number of configuration options you can have (since the number of columns in a row is usually limited). Every additional configuration option requires a DB schema change.   * In a name-value-pair table everything is "stringly typed" (you have to encode/decode your Boolean/Date/etc. parameters).   * (many more) Is there some consensus within the development community about which option is preferable?


What does cheap copying/branching mean for a versioning system like SVN?

One of the advantages of SVN over CVS as given here is **cheap copying and branching**. What does " _cheap copying and branching_ " mean in SVN parlance? How is it different from CVS copying and branching?


licensing a ' Sharepoint bug-Fix' to reserve it

My friend recently finished his personal work on a project that fixes a known bug in `sharepoint 2010`. The guy spent significant time\effort to reach this point   He consulted me on how to license this `fix` and asked if this possible and is it accepted for a such type of solutions! Actually I don't have any experiences in this area, especially that he is willing to start selling the `fix` and don't want to be lost in the market P.S.: his current location is U.A.E TIA.


DI and hypothetical readonly setters in C#

Sometimes I would like to declare a property like this:               public string Name { get; readonly set; }      I am wondering if anyone sees a reason why such a syntax shouldn't exist. I believe that because it is a subset of "get; private set;", it could only make code more robust. My feeling is that such setters would be extremely DI friendly, but of course I'm more interested in hearing your opinions than my own, so what do _you_ think? _I am aware of 'public readonly' fields, but those are not interface friendly so I don't even consider them. That said, I don't mind if you bring them up into the discussion_ **Edit** I realize reading the comments that perhaps my idea is a little confusing. The ultimate purpose of this new syntax would be to have an automatic property syntax that specifies that the backing private field should be readonly. Basically declaring a property using my hypothetical syntax               public string Name { get; readonly set; }      would be interpreted by C# as:               private readonly string name;     public string Name     {         get         {             return this.name;         }     }      And the reason I say this would be DI friendly is because when we rely heavily on constructor injection, I believe it is good practice to declare our constructor injected fields as readonly.


How do I get from a highly manual process of development and deploy to continuous integration?

We have a development process which is completely manual. No unit tests, interface tests are manual, and merging and integration are as well. How could we go from this state to implementing continuous integration with full (or at least close to full) automation of build and test? We have a pretty intense development cycle, and are not currently using agile, so switching to agile with CI in one move would be a very complicated and expensive investment. How can we take it slowly, and still moving constantly towards a CI environment?


Smartphones and tablets for testing

In my work I have started development of a website/webapp that will be viewed primarily on smartphones and tablet. I have now been given the task of buying the necessary hardware for testing the webapp. As I'm not really a mobile-nerd, I'm not really up to date with the latest and greatest on the mobile market. So I need some advice on which units to buy. Some initial thoughts   1. I would like to cover the browsers in the most common systems; iOS, Android and Symbian? (are there any more I should know about?).   2. I would like each browser in both Phone size and tablet size. iPhone and iPad seems like a given choice, but after that my knowledge is limited. I hope this is in the realms of this site, feel free to move this question to another SE site if this question fits better somewhere else. Thanks in advance! **Edit:** In this scenario there aren't really any customer who can pay, this is an app that shall be used by our customers but is developed on our own initiative. Secondly, I get the feeling that for example the iPhone simulator uses the safari desktop browser for rendering the content (am I wrong?), if that is the case, how does it cope with the slight defferences in the desktop version and the phone version (for eaxample videos not being able to autostart on the phone and stuff like that). I can be totally wrong here, just raising the question.


Is there ever a reason to use C++ in a Mac-only application? I not talking about integrating external libraries which are C++, what I mean is using C++ because of any advantages in a particular application. While the UI code must be written in Obj-C, what about logic code? Because of the dynamic nature of Objective-C, C++ method calls tend to be ever so slightly faster but does this have any effect in any imaginable real life scenario? For example, would it make sense to use C++ over Objective-C for simulating large particle systems where some methods would need to be called over and over in short time? I can also see some cases where C++ has a more appropriate "feel". For example when doing graphics, it's nice to have vector and matrix types with appropriate operator overloads and methods. This, to me, seems like it would be a bit clunkier to implement in Objective-C. Also, Objective-C objects can never be treated plain old data structures in the same manner as C++ types since Objective-C objects always have an isa-pointer. Wouldn't it make sense to use C++ instead in something like this? Does anyone have a real life example of a situation where C++ was chosen for some parts of an application? Does Apple use any C++ except for the kernel? (I don't want to start a flame war here, both languages have their merits and I use both equally though in different applications.)


Under what circumstances should error messages be presented to the user?

Should error messages ever be presented to an end user and if so what rules or advice should you have about what should be in them?


How to keep a team well-trained?

I'm currently mentoring a small team of 4 junior dev in small software company. They are very smart and often achieve their tasks with a high-quality job but I'm sure they still can do better - actually I have exactly the same feeling for myself :) -. Besides some of them are more "junior" than other. So I would like to find of a funny way to improve their CS skills (design, coding, testing, algorithmic...) in addition to the experience they acquire in their daily work. For instance, I was thinking of setting up weekly sessions, not longer than 2 hours, where we could get together to work on challenging CS exercises. A bit like a coding dojo. I'm sure the team would enjoy that but is it really a good idea? Would it be efficient in a professional context? They already spend all their week to code so how should I organize that in order for them to get some benefits? Any feedback welcome !


To integrate git versions as build numbers or not?

A colleague and I have been taking turns debating/discussing the issues/merits of integrating a version derived from the current git repository into our code whenever it builds. We think the merits include:   * No need to worry about human error in updating a version number   * Traceability between what we find in a device and the source code it was derived from The issues that have arisen (for us) include:   * IDE derived build systems (e.g. MPLABX) can make it hard to figure out where to put these kinds of hooks in (and it can end up pretty cheesy in the end)   * More work to actually integrate this into the build scripts/makefiles   * Coupling to a particular build approach (e.g. what if one person builds with XCode and the other MPLABX) may create downstream surprises So we're curious where others have landed on this debate. It's really easy for the discussion to become anecdotal. There are lots of people out there who are insistent on end-to-end automation, hang the amount of up front work and coupling it creates. And there are a lot of others on the other side of the debate, who just do the easiest thing that works and live with the risks. Is there a reasoned answer to which side is best to land on?


Why the sudden rise in popularity of Lua?

Does anyone know why the Lua progamming language has seen such a rise in popularity recently? I am going by the TIOBE ratings. http://www.tiobe.com/index.php/paperinfo/tpci/Lua.html I've used Lua in the past when I worked at a game development shop, but did not think it was used outside of that arena. Now it is the 11th most popular language according to TIOBE http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html Has there been any recent activity or news that might have caused this sudden surge? Thanks! EDIT: I am particularly interested in the extreme increase over the last year as shown in this chart: ![Lua History](http://i.stack.imgur.com/krjpB.png)


Forbidding or controlling "Hidden IT..." Who should write and maintain ad-hoc software applications?

Bigger companies usually have the problem, that it is not possible to write all programs employees want (to save time and to optimize processes) due to a lack of staff and money. Then hidden programs will be created by some people having (at least some) coding experience (or by cheap students/interns...). Under some circumstances these applications will raise in importance and spread from one user to a whole department. Then there is the critical point: Who will maintain the application, add new features, ...? And this app is critical. It IS needed. But the intern has left the company. No one knows how it works. You only have a bunch of sources and some sort of documentation. Does it make sense to try and control or forbid application development done ad-hoc outside of the IT department (with the exception of minor stuff like Excel macros)?


How are Apache HTTP Server and Apache Tomcat related? (If at all)

I currently have Apache httpd running on a production Ubuntu VPS server. I write php scripts. I'm interested in learning Java and I was wondering how I would go about writing some server-side Java to work on my current set-up. How are _Apache Tomcat_ and _Apache HTTP Server_ related to each other? Can Tomcat be a module of httpd? Or are they simply just two very different projects that happen to be steered by the same organisation (Apache Software Foundation)?


Entry point to Mobile Computing

I'm a novice programmer who has just learnt some languages and want to experiment & sharpen my skills. I've learnt quite a few languages like C, C++, Python, VC++, Java. I want to learn to program on Mobile(Hand-held) devices.What would be the best way to start? Could anyone please suggest me from where to start? I have heard that I would have to work on Emulators, but googling it didn't help. I know that there are quite a few experienced programmers who could help me and show me the appropriate path. As you'll must have guessed by just reading my question that I don't have a perfect picture of what I want, so may be my question isn't Bang On!! ... Please Help


Is it appropriate to try to control the order of finalization?

I'm writing a class which is roughly analogous to a CancellationToken, except it has a third state for "never going to be cancelled". At the moment I'm trying to decide what to do if the 'source' of the token is garbage collected without ever being set. It seems that, intuitively, the source should transition the associated token to the 'never cancelled' state when it is about to be collected. However, this could trigger callbacks who were only kept alive by their linkage from the token. That means what those callbacks reference might now in the process of finalization. Calling them would be bad. In order to "fix" this, I wrote this class:               public sealed class GCRoot {         private static readonly GCRoot MainRoot = new GCRoot();         private GCRoot _next;         private GCRoot _prev;         private object _value;         private GCRoot() {             this._next = this._prev = this;         }         private GCRoot(GCRoot prev, object value) {             this._value = value;             this._prev = prev;             this._next = prev._next;             _prev._next = this;             _next._prev = this;         }         public static GCRoot Root(object value) {             return new GCRoot(MainRoot, value);         }         public void Unroot() {             lock (MainRoot) {                 _next._prev = _prev;                 _prev._next = _next;                 this._next = this._prev = this;             }         }     }      intending to use it like this:               Source() {         ...         _root = GCRoot.Root(callbacks);     }     void TransitionToNeverCancelled() {         _root.Unlink();         ...     }     ~Source() {         TransitionToNeverCancelled();     }      but now I'm troubled. This seems to open the possibility for memory leaks, without actually fixing all cases of sources in limbo. Like, if a source is closed over in one of its own callbacks, then it is rooted by the callback root and so can never be collected. Presumably I should just let my sources be collected without a peep. Or maybe not? Is it ever appropriate to try to control the order of finalization, or is it a giant warning sign?


Using Node.js with Heroku to make a chat server?

I currently have a goal of creating a sort of chat website. I just finished trying with PHP and long polling, which hit a resource limit on my webhost's server. I was told that I should use Node.js and that it can be hosted with Heroku. I honestly have very little understanding of what Node.js or Heroku are. From what I've been told and have read after looking this up is that you can install Node.js and run apps online with it. The tutorial here: http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/ goes over installing and executing a script on heroku with Node.js. I have NO experience with command line, and wouldn't be able to do anything but copy the exact commands in that tutorial. I also don't understand when he accesses the script with localhost if the app is supposed to be on Heroku. Can anyone explain what Heroku is, and provide some resources on how to use it? How can I work my way up to knowing how to use it?


What are the London and Chicago schools of TDD?

I’ve been hearing about the London style vs. Chicago style (sometimes called Detroit style) of Test Driven Development (TDD). Workshop of Utah Extreme Programming User's Group: > _Interaction-style_ TDD is also called _mockist-style_ , or _London-style_ > after London's Extreme Tuesday club where it became popular. It is usually > contrasted with _Detroit-style_ or _classic_ TDD which is more state-based. Jason Gorman's workshop: > The workshop covers both the _Chicago school_ of TDD (state-based behaviour > testing and triangulation), and the _London school_ , which focuses more on > interaction testing, mocking and end-to-end TDD, with particular emphasis on > _Responsibility-Driven Design_ and the _Tell, Don't Ask_ approach to _OO_ > recently re-popularized by Steve Freeman's and Nat Pryce's excellent > _Growing Object Oriented Software Guided By Tests_ book. The post **Classic TDD or "London School"?** by Jason Gorman was helpful, but his examples confused me, because he uses two different examples instead of one example with both approaches. What are the differences? When do you use each style?


Practical size limits of a Hashtable and Dictionary in c#

What are the practical limits for the number of items a C# 4 Dictionary or Hashtable can contain and the total number of bytes these structures can reasonable contain. I'll be working with large numbers of objects and want to know when these structures start to experience issues. For context, I'll be using a 64 bit system with tons of memory. Also, I'll need to find objects using some form or 'key'. Given the performance demands, these objects will need to reside in memory, and many will be long-lived. Feel free to suggest other approaches/patterns, although I need to avoid using third-party or open-source libraries. For specification reasons, I need to be able to build this using native C# ( _or C++\CLI_ ).


Hooking up a Business Layer and Repository using Unit of Work Pattern

I am having a bit of trouble explaining precisely the question I have here so bear with me. it is similar to the unanswered question found here: http://stackoverflow.com/questions/5580651/what-is-the-correct-way-to-use- unit-of-work-repositories-within-the-business-laye Apologies if this is too rambling. Scenario: \+ .Net solution \+ IRepository used to retrieve objects from DB \+ IUnitOfWork used to allow transactions across multiple repositories This makes sense to me and I have implemented something along these lines that works fine. Now I want to introduce a business logic layer and am having trouble organising the three elements (BLL, UnitOfWork and Repository) in my mind. My understanding: \- Repository - data retrieval, manipulation \- UnitOfWork - persistence \- BLL - logic relevant to the business ('real world') (dislike that term!) Consider we have an ASP.Net MVC front end. I guess the question is: what does a BLL look like and what does the MVC controller that uses it look like? For reference: I wonder if perhaps my IUnitOfWork/IRepository implementation might be the underlying cause of my confusion.               public class IRepository<T>      {         private IObjectSet<T> objSet;         public IRepository<T>(IUnitOfWork uow)         {             objSet = uow.CreateObjectSet<T>();         }              public IQueryable<T> Add(T entity)         {             objSet.Add(entity);         }         //etc. etc. for delete, attach, getall     }      So I feel like if I have a BLL, I should be passing it the IUnitOfWork, so that it can use that to create the IRepository instances that it needs. But how will the BLL (separate DLL from the front end) 'know' what implementation of IRepository to build?


How do I get over my .NET hump?

I've been teaching myself how to write code with the help of a very talented friend, who unfortunately is talented enough that he has never free time. I've read and worked out of a couple books, but I feel more like I'm going through motions, rather than elegantly solving real world problems. What did you guys do to get out of your larval stage? Is there a course or educational product out there that isn't quite the $1500 all encompassing lecture, but more than just a dry,"regurgitate this example," type book?


Leaving a contract from a recruiter for a permanent position

So after months of searching, I finally get an offer. It's a contract position through my recruiter. Then all of a suddenly I get another offer from one of the MAJOR software engineer companies. I already accepted my position at the first place, but this other offer gives me so much more money and it has benefits. Can I leave the contract from my recruiter to go to this other company?


Is this an example of a pattern or an algorithm?

I feel like I have a reusable "something" here and I'm not sure whether to think of it as a pattern or an algorithm (or neither). It's characterized by having an unknown amount of work to accomplish a task because the subtasks can encounter various conditions which cause them to add "Issues" to a global queue. Then, the command is run repeatedly coupled with a round of "Issue Fixing" until either there are no issues left or the number of issues does not change. I'm just putting enough code here to show what I'm talking about - there's a bit more to it (let me know if I should post more).                       public void FindNewCampaigns()             {                 var findNewCampaigns = Locator.Get<ICommand<IEnumerable<Campaign>>>("FindNewCampaigns");                 var campaigns = findNewCampaigns.Execute();                 var issues = Locator.Get<ICollection<Issue>>("CommandIssues");                 while (issues.Count > 0)                 {                     int before = issues.Count;                     FixIssues(issues);                     issues.Clear();                     campaigns = findNewCampaigns.Execute();                     int after = issues.Count;                     if (before == after)                     {                         System.Console.WriteLine("No issues got fixed, quitting ({0}/{1}).", before, after);                         break;                     }                 }                 if (issues.Count == 0)                 {                     CreateCampaigns(campaigns);                 }             }                  private void FixIssues(ICollection<Issues.Issue> issues)             {                 foreach (var issue in issues)                 {                     System.Console.WriteLine("ISSUE: " + issue.GetType().Name + " - " + issue.ToString());                          if (issue is AdvertiserDoesNotExist)                     {                         var specificIssue = (AdvertiserDoesNotExist)issue;                         var command = Locator.Get<ICommand<string, DirectAgents.SynchService.Model.EomDatabase.Advertiser>>("CreateAdvertiser");                         command.Execute(specificIssue.AdvertiserName);                     }                     else if (issue is AccountManagerDoesNotExist)                     {                         var specificIssue = (AccountManagerDoesNotExist)issue;                         var command = Locator.Get<ICommand<string, DirectAgents.SynchService.Model.EomDatabase.AccountManager>>("CreateAccountManager");                         command.Execute(specificIssue.AccountManagerName);                     }                     else if (issue is AdManagerDoesNotExist)                     {                         var specificIssue = (AdManagerDoesNotExist)issue;                         var command = Locator.Get<ICommand<string, DirectAgents.SynchService.Model.EomDatabase.AdManager>>("CreateAdManager");                         command.Execute(specificIssue.AdManagerName);                     }                     else if (issue is MediaBuyerDoesNotExist)                     {                         var specificIssue = (MediaBuyerDoesNotExist)issue;                         var command = Locator.Get<ICommand<string, DirectAgents.SynchService.Model.EomDatabase.MediaBuyer>>("CreateMediaBuyer");                         command.Execute(specificIssue.MediaBuyerName);                     }                 }             }      Here's the code for `FindNewCampaigns`. It adds issues as it finds them. An _Issue_ is supposed to be something that needs to happen before a new campaign is able to actually get created in a target store.                   public class FindNewCampaigns : Command<IEnumerable<Campaign>>         {             private IFactory<CakeEntities> cakeEntities;             private IFactory<DADatabase> eomDatabase;                  public FindNewCampaigns(IFactory<CakeEntities> cakeEntities, IFactory<DADatabase> eomDatabase)             {                 this.cakeEntities = cakeEntities;                 this.eomDatabase = eomDatabase;             }                  public override IEnumerable<Campaign> Execute()             {                 using (var eom = eomDatabase.Create())                 using (var cake = cakeEntities.Create())                 {                     // Get EOM campaigns                     var campaigns = eom.Campaigns.Select(c => c.pid).ToList();                     // Get Cake offers                     var offers = cake.CakeOffers.Select(c => c.Offer_Id).ToList();                     // Get Cake offers that don't match to EOM campaigns                     var newOffers = offers.Except(campaigns).ToList();                     // Get default values                     int accountManagerID = DefaultAccountManagerId(eom);                     int adManagerID = DefaultAdManagerId(eom);                     int advertiserID = DefaultAdvertiserID(eom);                     int campaignStatusID = DefaultCampaignStatus(eom);                     // Create new campaigns in memory                     var newCampaigns = (from offer in cake.CakeOffers                                         where newOffers.Contains(offer.Offer_Id)                                         select new                                         {                                             Offer = offer,                                             Campaign = new Campaign {                                                 pid = offer.Offer_Id,                                                 campaign_name = offer.OfferName,                                                 campaign_status_id = campaignStatusID,                                                 account_manager_id = accountManagerID,                                                 ad_manager_id = adManagerID,                                                 advertiser_id = advertiserID,                                             }                                         }).ToList();                     // Set campaign status                     var campaignStatus = eom.CampaignStatus.ToDictionary(c => c.name, c => c.id);                     campaignStatus.Add("Private", campaignStatus["Active"]);                     campaignStatus.Add("Apply To Run", campaignStatus["Active"]);                     campaignStatus.Add("Inactive", campaignStatus["default"]);                     foreach (var item in newCampaigns)                     {                         string statusName = item.Offer.StatusName;                         if (campaignStatus.ContainsKey(statusName))                         {                             item.Campaign.campaign_status_id = campaignStatus[statusName];                         }                         else                         {                             AddIssue(new CampaignStatusDoesNotExist(statusName));                         }                     }                     // Set advertiser                     var cakeAdvertisers = cake.CakeAdvertisers.ToDictionary(c => c.Advertiser_Id);                     foreach (var item in newCampaigns)                     {                         int offerAdvertiserID = int.Parse(item.Offer.Advertiser_Id);                         var offerAdvertiser = cake.CakeAdvertisers.FirstOrDefault(c => c.Advertiser_Id == offerAdvertiserID);                         string offerAdvertiserName = offerAdvertiser.AdvertiserName;                         var eomAdvertiser = eom.Advertisers.FirstOrDefault(c => c.name == offerAdvertiserName);                         if (eomAdvertiser != null)                         {                             item.Campaign.advertiser_id = eomAdvertiser.id;                         }                         else                         {                             AddIssue(new AdvertiserDoesNotExist(offerAdvertiserName));                         }                     }                     // Set account manager                     foreach (var item in newCampaigns)                     {                         int offerAdvertiserID = int.Parse(item.Offer.Advertiser_Id);                         var offerAdvertiser = cake.CakeAdvertisers.FirstOrDefault(c => c.Advertiser_Id == offerAdvertiserID);                         string offerAccountManager = offerAdvertiser.AccountManagerName;                         if (offerAccountManager != null)                         {                             AccountManager am = eom.AccountManagers.ToList().SingleOrDefault(c => c.NameIsEquivalentTo(offerAccountManager));                             if (am != null)                             {                                 item.Campaign.account_manager_id = am.id;                             }                             else                             {                                 AddIssue(new AccountManagerDoesNotExist(offerAccountManager));                             }                         }                         else                         {                             AddIssue(new OfferHasNoAccountManager(item.Offer.OfferName));                         }                     }                     // Set ad manager                     foreach (var item in newCampaigns)                     {                         int offerAdvertiserID = int.Parse(item.Offer.Advertiser_Id);                         var offerAdvertiser = cake.CakeAdvertisers.FirstOrDefault(c => c.Advertiser_Id == offerAdvertiserID);                         string offerAdManager = offerAdvertiser.AdManagerName;                         if (offerAdManager != null)                         {                             AdManager ad = eom.AdManagers.ToList().SingleOrDefault(c => c.NameIsEquivalentTo(offerAdManager));                             if (ad != null)                             {                                 item.Campaign.ad_manager_id = ad.id;                             }                             else                             {                                 AddIssue(new AdManagerDoesNotExist(offerAdManager));                             }                         }                         else                         {                             AddIssue(new OfferHasNoAdManager(item.Offer.OfferName));                         }                     }                     return newCampaigns.Select(c => c.Campaign).ToList();                 }             }


Difference between functional test and integration test

I am deeply confused the difference. I've read so many definitions and they always explain functional test as testing the requirement is satisfied. Well, that's just rephrasing the name `functional test`. That doesn't clarify the difference. I am interested in some real code to demonstrate the difference. Suppose we have a function in a library performs hashing:               def custom_hasher(scheme, val):         # use many hashing libraries...               def hasher(inlist, scheme):         """ Take a list and outputs the hashed values of a list. """              output = list()         for val in inlist:             output.append(custom_hasher(scheme, val))         return output      Now for a functional test, I am guessing we want to test `['a', 'b']` is returned as something like `['jask34sdasdas', 'asasjdk234sjdk']` given some scheme. But that's just about what an integration test can do! I know exactly what type input I want (I want good execution so I pass in a list), or I want it to raise `Object has no append method` exception if I pass in a dictionary. I can do that in both. Where's the distinction? Another example is some web app:               @logged_in   # only logged in user can do this     @route("/invite", method=['POST'])     def send_invite(request):        recp_email = request.data['recp_email']             # now do a bunch of logics before and after sending an email      So in my integration test, I will definitely do this over a network (have the server running). Send some request to this url. Same for functional test. How to draw a line? For this case, I can write a functional test that tests to find an email is sent by looking at the send log in some table. But that's a different function than what I am testing (the view `send_invite`). So I don't see how to differentiate the two. They both assert something. Please help.


What is the connection between literate programming and the semantic web?

I was (casually) researching semantic / ontology based approaches to technical documentation, when I stumbled upon this gem: > Literate Programming and the Semantic Web are ideas from different times, > which do have a connection. The linked paper, Literate Programming in XML by Norman Walsh, discusses XML technologies that are central to semantic web, however I fail to see the conceptual connection between literate programming and the semantic web _or_ ontology based documentation. Help?


Pseudocode for Brodal queue

I'm trying to find more resources regarding Brodal heap. All I found is a haskell implementation of Brodal-Okasaki heap, but I _think_ that they are skew heaps, is this correct? Furthermore, I'm illiterate in Haskell so that does not help much. Does anyone have (or know of) an Brodal queue implementation in pseudocode, C, C++, Python? Also please correct if my assumptions above are wrong.


Is my first employer expecting too much?

This is my first job as a programmer. I am working using the following technologies:   * ASP.NET   * C#   * HTML   * CSS   * Javascript   * JQuery I work for a firm which develops software for small banking firms. Currently they have their software running in 100 firms. Their software is developed in Visual Fox Pro. I was hired to develop an online version of this software. I am the only developer. My boss is another developer, the only other developer in the firm. Therefore, my employer has a total of two developers. My boss does not have any experience with .NET development. I have been working on this project for 8 months. The progress is there, but has been very slow. I try my best to do what my boss asks. But the project just seems too ambitious for me. The company has not done have any planning for the project. They just ask me to develop what their older software provides. So I have to deal with front end, back end, review code, design architecture, and more. I have decided to give my best. I try a lot. But the project sometimes just seems to be overwhelming. **Question:** Is it normal for a beginner programmer to be in this place?   * Are my employers just expecting too much of a new programmer?    * As a programmer, am I lacking skills one needs to deal with this? I always feel the need to work in at least a small team, if not big one. I am just not able judge my condition. Also I am paid very low salary. I do work on Saturday as well. Please, help to clarify my judgment. Any suggestions are welcome.


Aggregation vs Composition

I understand what composition is in OOP, but I am not able to get a clear idea of what Aggregation is. Can someone explain?


What is the industry definition of an interpreter (as opposed to a compiler)?

In my compiler design courses, I have learned about and worked with a clear academic definition of an interpreter and a compiler, with an interpreter being > a program Pi from a language M capable of taking a program i from a language > I and an input and executing i with the given input and the correct > semantics for I on a machine capable of running programs from M and a compiler being > a program Pc that, when given a valid program i from a language I as an > input, produces a semantically equivalent program o in a language O This definition would clearly put the usual execution of Java bytecode by a JVM in the domain of interpretation, no matter how much JIT compilation is done. (Of course, Java is also compiled before, from Java code to Java bytecode.) I have encountered opinions in discussions on this site that clearly and vehemently state the opposite, i.e. that Java Bytecode execution thingies are compilers. Since I am about to make the leap from academics to industry, I am a little bit confused here: Is the above definition of interpreters false from the viewpoint of industry people in general? Or is it just false for Java people? Is the view of Java as a fully compiled language an alternate, but minority view? Or just a few loonies? (PS: Please do not move this to cstheory. I have deliberately put this question here since I would really like to get the view of the professional industrial, not the academic community.)


What is the preferred way to protect ownership of one's code (e.g. copyright, licenses, etc)

I posted some open source code on soureforge, and someone got in contact with me stating they intended to use my algorithms for a commercial product. I don't want this to happen, what should I do? According to us copyright.gov site: "Your work is under copyright protection the moment it is created and fixed in a tangible form that it is perceptible either directly or with the aid of a machine or device." Which seems to grant some legal protection by doing nothing. I looked at getting an official copyright from them, and its more than I'd like to spend ($135). Is that what I need to get for my work? Or are licenses a cheaper and safe/legal alternative? Or something else? Or nothing at all?


You're hired to fix a small bug for a security-intensive site. Looking at the code, it's filled with security holes. What do you do?

I've been hired by someone to do some small work on a site. It's a site for a large company. It contains very sensitive data, so security is very important. Upon analyzing the code, I've noticed it's filled with security holes - read, lots of PHP files throwing user get/post input directly into mysql requests and system commands. The problem is, the person who made the site for him is a programmer with family and children who depend on that job. I can't just say: "your site is a script kiddie amusement park. Let me redo it for you and you'll be fine." What would you do in this situation? ## Update: I followed some good advice here and politely reported to the developer that I've found some possible security flaws on the site. I pointed out the line and said there could be a possible vulnerability for SQL injection attacks there, and asked if he knew about it. He replied: _"sure, but I think that to exploit it the attacker should have information on the structure of the database; I have to understand better"_. ## Update 2: I said that's not always the case and suggested he follows this Stack Overflow question link in order to deal with it properly: How to prevent SQL injection in PHP? He said he would study it and thanked me for telling him before. I guess my part is done, thanks guys.


Tender vs. Requirements vs. Solution Design

Conventionally, which of the above documents is deemed to hold the most weight when it comes to system acceptance? I recently had a conversation along these lines: It was argued that the initial requirements / tender documentation should be used to determine system acceptance. It was said that the solution design only serves to describe the way in which the system will solve the problem, not the problem it will solve. Furthermore, it was argued that if requirements are missed during solution design, the requirements should be referenced during system acceptance _and_ that if any requirements were missed then the original tender should be referenced. Conversely, I suggested that - while requirements may be based on the original tender - they supersede it once agreed with the stakeholders. Furthermore, during solution design, analysis is performed to address and refine these initial requirements, translating them into a system capable of meeting the actual requirements. Once signed off by the relevant users, this solution design should absolutely represent the requirements (by virtue of the fact that it's designed upon them) but actually supersedes them as the basis for system acceptance. Is one of the above arguments more valid than the other? _EDIT: Apologies for the ambiguous terms. In this situation, tender is the document the customer took to market when shopping for a provider - it includes details of all the high-level features they're looking for. Solution design is not a technical document, it's the functional specification._


Requirement refinement between two levels of specification

I am currently working on the definition of the documentation architecture of a system, from customers needs to software/hardware requirements. I encounter a big problem with the level of refinement of requirements. The classic architecture is : PTS --> SSS --> SSDD --> SRS/HRS with PTS : Purshaser Technical Specification SSS : Supplier System Specification SSDD : System Segment Design Description SRS / HRS : Software / Hardware Requirement Specification. Requirements from PTS are reworked in SSS, this document only expressed the needs (no design requirements are defined at this level). Then, the system design is described in SSDD : we allocate requirements from the SSS to functions from the design and functions are then allocated to component (Software or hardware) (we are still at the SSDD level). Finally, for each component, we write one SRS or one HRS. Requirements in SRS or HRS are refinement of requirements from SSS (and traceability matrix are made between these two levels). My problem is the following one : Our system is a complex one, and some of the requirements in the SSS needs to be refined twice to be at the right level in the SRS (means that software people can understand the requirement to make their coding). But, with this document architecture, I can only refine once the requirements from the SSS. The second problem is that only a part of the requirements from the SSS needs to be refined twice. The other part only need one refinement. On the picture below, the green boxes are requirements at the right level for SRS or HRS. And purple boxes are intermediate requirements which can not be included in SSS since they are design requirements. Where can I put these purple requirements ?? Is there someone who has already encountered this problem ? Should I write two documents at SRS level ? Should I include intermediate requirements in SSDD ? Should I includes the two refinement levels (purple and green) in the same SRS document (not sure that's possible since a SRS is only for one component) ??? Thanks for your help and expertise ;-) ![Requirement refinement](http://i.stack.imgur.com/3xHyM.png)


Why were annotations introduced in Spring and Hibernate?

I would like to know why were annotations introduced in Spring and Hibernate? For earlier versions of both the frameworks book authors were saying that if we keep configuration in xml files then it will be easier to maintain (due to decoupling) and just by changing the xml file we can re-configure the application. If we use annotations in our project and in future we want to re-configure application then again we have to compile and build the project. So why were these annotations introduced in these frameworks? From my point of view annotations make the apps dependent on certain framework. Isn't it true?


How much should I worry about modeling/analyzing a web application?

I'm developing kind of a modern web application - scalable, robust and fast. I need to develop it as fast as I can. How much should I worry about the analysis phase or writing UML diagrams or ER diagrams for it? And what should be the flow on that? What should I start drawing?


Should I bother to write unit test for UI/UX Components?

So I am building an application with Angular and have started to get into UI testing with DalekJS (http://dalekjs.com). As I have been writing these tests I have been thinking to myself, should I even bother with writing unit test that that are UI/UX components. Now my angular services generally don't have anything to do with the DOM or directly rendering stuff on the page so those I unit test and it make sense however angular directives are components that render things directly to the page and writing unit tests seems like 1. It is not an effective way to test UI/UX components and 2. It would overlap with UI/UX Tests. For point #1, unit test (at least ones I have seen) don't actually write anything to a browser and render it. For thing that require DOM, you generally mock the DOM in a variable and use that to test whatever you need to test. If you have an error with a test, you can't load it up in a browser and play around with it like you could with UI/UX tests (which in my experience runs against code that is the true application that renders and everything). For point #2, one of my directives has a property called contentVisible. Now I can write a unit test that make sure that property is the correct value at certain points but that really don't not test what I truly want to test because even if contentVisible is set to false, the content still might be rendering to the screen which UI/UX test would pick up. Is it still worth the effort to write unit test for UI/UX Components where UI tests would be able to pick up everything the unit test would plus also do a better job since it can test what is actually rendered? **Exception** The one exception case where I would need a unit test is for certain ajax requests. For example, making sure an ajax request is not made of that an ajax request that does not make and changes to the UI are things that can only be tested with unit tests.


Distributing cryptographic software on GitHub

I am developing a cryptographic program and i am planing on distributing it using GitHub, But there are some regulations on the export of cryptographic software, how do make myself not liable if someone takes it out of the county? what disclaimer should i include with my software when i distribute it?


What would be a good "umbrella" term for HTML, CSS, SQL, JavaScript and the like?

There appears to be a pretty clear consensus on the question about whether HTML and CSS are programming languages. They are not. HTML is a markup language and CSS is a stylesheet language. You could probably also argue that SQL isn't really a programming language either, and JavaScript is as the name implies more a scripting language than a programming language. However, what's a good "umbrella" term for these? Could i just say they are "technologies"?


How to factor out data layer in nopCommerce and replace MS SQL with RavenDB?

I am new to nopCommerce and ecommerce in general but I am involved in an ecommerce project. Now from my past experiences with RavenDB (which mostly were absolutely pleasant) and based on the needs of the business (fast changes with awkward business workflows) It seemed to be an appealing option to have RavenDB handling all sort of things related to the database. I do not understand design and architecture of nopCommerce fully so I did not reach to a conclusion on how to factor data parts, since it seems the services layer actually does not abstract data-layer concepts away; like bringing in EF working model to other layers. I have found another project which used NuDB as it's database as a nopCommerce fork. But it did not help because NuDB still has the feeling of a RDBMS and is not as different as RavenDB. Now first how can I learn about the internals of nopCommerce (other than investigating the code)? It's workflows? It's conventions? Second has anyone tried something similar before with a NoSQL database (say like MongoDB or RavenDB)? Is it possible to achieve this in a 1 (~2) month time frame? Thanks in advance;


What is the "Free Monad + Interpreter" pattern?

I've seen people talking about _Free Monad with Interpreter_ , particularly in the context of data-access. What is this pattern? When might I want to use it? How does it work, and how would I implement it? I understand (from posts such as this) that it's about separating model from data-access. How does it differ from the well-known Repository pattern? They appear to have the same motivation.


Mutual observer pattern in Java

I want to improve my multi-threading and design pattern skills. As such I'm designing an Instant Messaging server. I'm writing the Server first. My plan so far is to have Client "Proxy" Classes to handle the socket connection for each Client. I want to have an "Exchange" Class that takes a message from a Client Proxy and hands it to the recipient Client Proxy. I was thinking of having both the Client and Exchange observe each other in this situation via the Observer Pattern. Mutual observers as it were, with Client Proxy and Exchange being Observer and Subject. On further thinking, should I instead have just the Exchange be the Observer and the Client Proxies as multiple Subjects for the Exchange? \-- Further thoughts It seems people quite like the idea of mutual observation between Proxy and Exchange. I was planning on each Client Proxy running in a separate thread. Would the Exchange become the bottleneck if there's only one Object? It sounds to me like I might need a pool of exchange objects, but I'm unsure how that would then map to the Observer pattern, even if I had some kind of broker in front of my pool of workers.


Memory allocation of Classes that don't have any global data and locks

static void Main(string[] args)         {             var c2 = new Class2();             var c3 = new Class3();             var c1 = new Class1(c2, c3);             c1.Method1();         }              class Class1         {             readonly Class2 _class2;             readonly Class3 _class3;             public Class1(Class2 class2, Class3 class3)             {                 _class2 = class2;                 _class3 = class3;             }             public void Method1() {                 _class2.PerformM1();                 _class3.PerformM2();             }         }         class Class2         {             public void PerformM1()             {                 //do some operation             }         }         class Class3         {             public void PerformM2()             {                 //do some operation             }         }      **Question based on above code:**   1. How much memory does object of Class1 has when it is created?   2. Does any memory increases or decreases when I perform c1.Method1(); keeping in mind that none of the classes have any global fields that might acquire any space. * * * **Edit** Expanding with one more question:   1. If creating new objects of Class1 and calling methods of c1 object does not involve much memory usage, then is it correct to say that I don't need a lock in the above provided sample code.  I can simply create n number of objects and assign individual object to individual Task( or thread)?


Is choosing ASP.NET WebForms to design web applications now a bad practice?

I have no time to code in MVC and jQuery, I just want this job to "get done", and honestly I like WebForms after 3 years of MVC programming. So my question is, technically, is it bad practice to choose ASP.NET WebForms over MVC ?


External libraries licensing

The problem I have might seem trivial for some of you but in general I have a question about all those "free" software licenses (mainly for PHP libraries). Let's assume that I want to create project for end-user and I want to sell it to them and if possible encrypt my source code. For example for Zend Framework licence is New BSD License and for Laravel it's MIT license. On Zend framework there is such short info: > Redistributions of source code must retain the above copyright notice, this > list of conditions and the following disclaimer. > > Redistributions in binary form must reproduce the above copyright notice, > this list of conditions and the following disclaimer in the documentation > and/or other materials provided with the distribution. but it means nothing for me. What does it mean the first one? Should I simple download Zend Framework and put in directory and when I don't do anything with it I can forget about it or maybe I should tell my client that I used framework and my software may not working because > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" > AND ANY EXPRESS OR IMPLIED WARRANTIES ... I really don't understand how those licenses work and what are differences between those licenses. Could you provide me some help or external resources where this issue is explained in a simple way?


Data structures for bioinformatics

what are some data structures that should be known by somebody involved in bioinformatics? I guess that anyone is supposed to know about lists, haseshes, balanced trees etc, but I expect that there are domain specific data structures. Is there any book devoted to this subject? Thanks, Lucian


Get a Programming Internship if you don't know programming? Learning instead?

Is it possible to get an internship to learn programming if you've say only had one classs in visual basic? For example, I want to learn any programming language, but I've only taken 1 class in visual basic and SQL....can I be at a company to learn on the job?


Format for getting clear directions on data paramters from users

As part of my job, I regularly get ad-hoc requests from users for snapshots of our very large database. However, there's no fixed format for delivering these and they usually come through in the form of bullet-pointed text, for example:   * All customers    * All active in last 0-24 months (including non-contactable customers)    * All committed In this instance, "committed" is a flag, and "active/non-contactable" is both a text-based status and a dynamic status based on their last purchase. So this request could be interpreted as:   * All customers who made a purchase in the last 24 months, regardless of status   * All customers who have a "active" or "non-contactable" status regardless of last purchase.   * One of the above and then "either" having a committed flag, or "and" having a committed flag. I won't labour the point - you see the problem. And it's worth adding that the possible range of parameters is quite large. Normally I have to talk to the requestor and go through a rigmarole of explaining the problem and trying to clarify the requirements. This situation can't be that uncommon. Is there a more effective way of capturing these details, with a checkbox-style grid or other visual aid? Does anyone have any examples of experience of useful solutions?


Is the "exposer (hack) pattern" a newly identified pattern or does it have another name?

**EDITED FOR CLARIFICATION** In the past, I have seen a whole manner of resolutions and fudges. Some really stand out. One particular resolution that I initially thought of as a fudge possibly deserves a category of its own. It could be considered a hack or a pattern, as a design pattern is just a piece of reusable code. So, it still conforms to the definition: http://en.wikipedia.org/wiki/Software_design_pattern It possibly already has a name but I have not seen it in the literature. I was wondering if anyone knows another name for what I labelled the "exposer (hack) pattern". I have included an example of it below. This code is used to expose data that is not available to a data source. Instead, the results are not generated until a data bind method is called. Unfortunately, these results are not stored anywhere in the data source after execution. This is due to an oversight (or bad design) in the third party API. So, the results are passed a repeater to store locally, before returning these out as a populated PageDataCollection:               public static PageDataCollection Search(this SearchDataSource searchDataSource)     {                 PageDataCollection results = new PageDataCollection();                      //This is a dummy repeater whose only purpose is to provide a way of                 //iterating over the search results                 Repeater dummy = new Repeater();                      dummy.ItemDataBound += delegate(Object sender, RepeaterItemEventArgs e)                 {                     if (e != null && e.Item != null && e.Item.DataItem != null)                     {                         PageData pageData = e.Item.DataItem as PageData;                              if (pageData != null)                         {                             results.Add(pageData);                         }                     }                 };                      dummy.DataSource = searchDataSource;                      dummy.DataBind();                      return results;             }


Taxonomy / Classification of real world objects. Development suggestions

I have to develop a taxonomy/classification program based on classification algorithms and i would like to have some suggestions. The aim is to help the one using the program to categorize an object (could be a plant, a coin, an animal,...) and to teach what to look for in every step. The program is likely to be coded in PHP. The algorithm also should be able to be module based (multiple types of classification can exist at a determinare level and types of classification should be interchangeable). Example: ![Example of classification](http://i.stack.imgur.com/N8rrC.jpg) Should the program/algo be object oriented? can it be imperative (if/else, case)?


Solution for multiple versions of one Software

I'm sorry if the title is a little hard to get. I've never built an entire big software my self, just some small apps in my free time, i was more familiar with the do-what-my-boss-told-me things. And our approach is a little amateur, obsolete also (Foxpro 8.0 and MS SQL 2000). Now i've started to work at another company and been assigned to build a software in C#.Net, but the problem is i'm not sure with the program's architecture My problem is, we're building a software. But we have variety of clients, and for example, we have a CalculateCostOfProduct funtion, and it might be different for each client. Says for party A, the function is :               function CalculateCostOfProduct()     return 5;       for party B :               function CalculateCostOfProduct()     return 10;       ... And there should be extra modules for specific needs also ! So there will be customized versions from the original standard. How should i manage this ? But we can't build different exe for different client! So please give me some ideas, or solutions that might solve this problem.