title: Queue of jobs in a different states and with different services around

text: I need to design a 'queue' of jobs (in a a very much UI oriented application) that can be run by a user and I need some other thoughts to pick optimal approach from ground up. My jobs can be in a different states (imported, sent from elswhere, created by user, even to be just simulated with their imported recorded progress - following a whola different workflow), etc. Therefore they can also pass thru the different states of their lifecycle, like being created, running, paused, validated or edited by a user (in case of invalid job parameters), imported or even in the process of being deleted (at least for logging or auditing). Because of this, all jobs have to have their state at each point of time and they need to be managed somehow by a common logic. There are also domain and application rules, that only one can be running/stopped/params edited in a time state, etc... My main question is, whether to implement some kind of monolithic singleton controller for all states where it can answer state guards of each one of them (can/cant transition to other state) for all states and can call actions (other services) upon them, or whether to implement state machines inside of the jobs themselves and somehow call the services and related conditional logic from themselves (delete me/ edit me and so on). I also need to tie this tightly to the UI, so that I have a list of tasks with the states visible for the user but I also have the separation of the concerns (job itself as a domain object of parameters - not states, UI). This is just a brief description of my main problem, so I might update the requirements as suggestion or more questions that I forgot to address arrive.


title: write my own or choose a framework for link sharing website

text: I'm a PHP programmer and I've done any projects based on PHP and MySQL without using any framework so far. Now I'm going to create a big link sharing system (excel- able,modular,fast,theme based,secure etc.). But I have no experience to use any frameworks before. I need to know which is better to me.Choose a framework (easy to use and learn it fast) or still do my method?


title: Should I refactor a F class from code climate?

text: According to code climate, a class is `F`, aka the worst mark you could be granted. I did submit a pull request to rearrange it here Which has been refused because the new code is supposedly too abstract. I'm utterly convinced a `F` has a real meaning and should be fixed, above all when it's one of the main class of a project. What's your point of view?


title: Do the benefits of Resin/Quercus outweigh the overhead?

text: Lately, I've been looking more and more into Resin + Quercus as a technology to develop an application of mine. The reason I started looking into it was that this application has high reporting needs, a lot of which cannot (or realistically, should not) be created in real-time. Java would offer a nice backend to queue and generate reports. Also, with Quercus I would be able to develop my data models in Hibernate, and use them "from PHP", thus effectively stretching these models across front and back-end. This same concept would also apply to any front/back-end common business logic, which could be developed in Java libraries. Now, the downside is that whichever front-end (PHP) MVC Framework I choose (my goal was Symfony 2), it is unlikely to work without some heavy modification, if it can work at all. Quercus is a pretty close implementation of PHP, and is supposed to be compatible with PHP5.3, so namespaces and closures SHOULDN'T be a problem, but when I tried to run an existing Symfony 1.4 app, I failed miserably. So, my question to you is, do you think the benefits of Resin + Quercus outweigh the overhead of using a not-so-perfect/stable implementation of PHP? If this were your application, and your goal was and end-product, rather than educational purposes, what would you decide?


title: Suggestions on switching from lamp based web design-development to game design-development

text: I have around 2.5 years of experience as a web developer cum designer working mainly on the LAMP platform. Now, I want to try out game development (of the likes of First Person Shooter games like Call of Duty (COD)). It is one of my dreams to some day succeed in making a profitable, popular, commercial game of this type. However, I have never done any kind of business nor even freelancing yet even in the web domain. Okay, first things first, I am just starting and I don't yet have any idea about the technologies, languages, engines (game engines) etc involved in that. I would like this question to be a complete guide for people with similar interests. **Best resources for getting hold really fast** What would be the best approach to get the basic hold of the domain really fast? Any resource(s) for programmers coming from other domains/experienced in other domains would be the ideal ones for me. E.g., if anybody would ask me some good resource for quickly learning PHP/Mysql, I would suggest books like "How to do everything with PHP & MySql" - ![How to do everything with PHP & MySql](http://i.stack.imgur.com/8KDz4.jpg) because -   * it introduces all the basics of the domain (not the advanced things which can be later learnt by practice and also a lot by searching in stackoverflow questions)    * it contains some very nice working projects in the end, which help in applying the skills learnt in the chapters of the book. This is the best way for self learners, I feel. I would appreciate some similar resource which connects all concepts together to get the bigger picture. I have read about C, C++, C#, JAVA being used in game programming but not sure which language to go for (I have previously learnt a little of C and JAVA). I have also read about game engines but there would be various other concepts. **Commonly accepted ways of learning**   Should 3D games like these be tried after 2D games? Are there some commonly accepted ways of learning such kind of games? Like in web development, we should go for frameworks after practising well with basic language, AJAX after getting properly done with simple page-reload processing etc. Apart from these, any useful tips (like language choices etc.) would be much appreciated. Like it is highly recommended to contribute to open source web projects for getting recognition, are there similar open source game projects? Thanks,   Sandeepan


title: Is this an example of recursion?

text: I am implementing inheritance of something called Contexts. Each Context holds a link to its parent context. If that Context is the root Context, its parent is null. In order to walk up the inheritance tree and get the data from each Context, I want to do this (in pseudocode)               private Hashtable getDataAsMap() {         Hashtable map  =  this.parent != null  ?                                 this.parent.getDataAsMap()  :                                 new Hashtable();              // add my data              return map;          }      Is this recursion? I'm calling the same method, but on a different object. Does that still count? If not, what would you call it?


title: CQRS applicability when some commands need to block the UI

text: I am working on an app which I would dearly love to transition from a fairly traditional layered architecture to CQRS, for a number of reasons, not least fo which is that having a robust event log will make adding a couple of feature requests I can see barrelling towards me trivial to accomodate. Now, I have a conceptual problem: of around 40 commands the user can initiate, there are three which the user _needs_ to be sure have successfully completed before the UI lets them do anything else. Everything else fits into the "submit a request, query for success later" model, except for these three commands. How is this handled in CQRS-land? Do I separate the three blocking commands to effectively a third service, so I have Commands, Queries, and BlockingCommands? Do I have a two-stage event processor with an in-request blocking first stage which only gets used for the blocking commands? Does the existence of these three commands mean that the whole idea of applying CQRS is invalid? Should I just pretend they _aren't_ blocking and poll for success in the UI? I'm sure this must come up on other projects, how is it usually handled?


title: Is it important to know C/C++ for Android development?

text: Is it possible to use only Java (without C++ /NDK) for building good, fast, beautiful Android apps (including 3D development)? When I look for Android developer position requirements (vacancies), I see that knowledge of C/C++/NDK is very important. Some companies even require to build their test tasks using only C++ (OpenGL).


title: log4net - roll my own singleton, use LogImpl, etC?

text: Reposting here... hopefully the better place to seek opinions on the matter. :) Writing my own log4net wrapper class using C#. I want to create a lib such that I can reference it from any project/assembly in a given solution with a minimum of effort. ie: include the reference, maybe throw in a using statement and then make calls like MyLogger.Debug(blahblah); with perhaps a property (MyLogger) being set from a "main" method somewhere. From reading the docs, I'm not sure if I should be writing my own or using LogImpl? The latter seems to include all of what I'd want to put in my own wrapper, so, why reinvent the wheel? But, there is also a note in the help that says thast an instance member of type logimpl is not thread safe whereas a static member is... OTOH, if I make my own, I'd be looking at a singleton class I can create once and use throughout my solution (by passing the singleton ref to objects which require it) but I gotta rewrite all those Debug, Error, etc sections. So... not sure what approach to take. What would you folks suggest as a beginning?


title: Standardised Programming Techniques / Procedures

text: I don't know if this is a question, or a start of a conversation or even a completely irrelevant topic. Why isn't programming more standardised? Im really new to this and I find it hellish difficult to find the answer to even basic questions. Things like--   * How do I add validation to multiple texboxes in asp.net c# without using individual validation controls?   * How do I add the input of a texbox to an ongoing array? I'm talking about fundamental things that get used all the time. I would expect answers like "oh yeah, see jones' validation method (link) or peters' textbox to array function (link). I just thought there would be standard techniques, like in chess, for doing things that are similar. I hope this makes sense and someone can point me in the right direction if there ARE directories of standard programming technniques.


title: Can I sell forked GPL code?

text: I know that it is possible to sell GPL code, but I wanted to know if it was possible to sell GPL code that has been forked and modified. The forked and modified code will still be available to use, modify, and redistribute.


title: self referencing tables, good or bad?

text: Representing geographical locations within an application, the design of the underlying data model suggests two clear options (or maybe more?). One table with a self referencing parent_id column uk - london (london parent id = UK id) or two tables, with a one to many relationship using a foreign key. My preference is for one self-refercing table as it easily allows to extend into as many sub regions as required. IN general do people veer away from self referencing tables, or are they A-OK ?


title: Non-English-based programming languages

text: The University of Antioquia in Colombia teaches its introductory programming courses in Lexico, a Spanish-based, object-oriented .NET language. The intent is to teach programming concepts in the students' native language before introducing English-based mainstream languages. There are many other Non-English-based programming languages and there is even a related question in Stack Overflow. I have several questions regarding these languages:   * Has anyone on this site learned to program using a non-English-based language? If so, how difficult was the transition to the first English-based language?   * Is there any research-based evidence that non-English speakers learn programming faster/better using languages with keywords in their native language instead of English-based languages?


title: Is using non-standard single-line comments fine in C?

text: I noticed Visual C++ 2010 (my current environment) and XCode both allow non- standard single-line comments in my C programs. Since these are both my target platforms, I assume it's fine to use it? VC++ 2010 doesn't support C99, so I'm limited to C89, though I know C99 added support.


title: Static vs. dynamic memory allocation - lots of constant objects, only small part of them used at runtime

text: Here are two options: Option 1:               enum QuizCategory {              CATEGORY_1(new MyCollection<Question>()                         .add(Question.QUESTION_A)                         .add(Question.QUESTION_B)                         .add...),              CATEGORY_2(new MyCollection<Question>()                         .add(Question.QUESTION_B)                         .add(Question.QUESTION_C)                         .add...),               ...              ;              public MyCollection<Question> collection;              private QuizCategory(MyCollection<Question> collection) {             this.collection = collection;         }              public Question getRandom() {             return collection.getRandomQuestion();         }          }      Option 2:               enum QuizCategory2 {              CATEGORY_1 {                  @Override             protected MyCollection<Question> populateWithQuestions() {                 return new MyCollection<Question>()                                     .add(Question.QUESTION_A)                                     .add(Question.QUESTION_B)                                     .add...;             }         },              CATEGORY_2 {                  @Override             protected MyCollection<Question> populateWithQuestions() {                 return new MyCollection<Question>()                                     .add(Question.QUESTION_B)                                     .add(Question.QUESTION_C)                                     .add...;             }         };              public Question getRandom() {             MyCollection<Question> collection = populateWithQuestions();             return collection.getRandomQuestion();         }              protected abstract MyCollection<Question> populateWithQuestions();          }      There will be around 1000 categories, each containing 10 - 300 questions (100 on average). At runtime typically only 10 categories and 30 questions will be used. Each question is itself an enum constant (with its fields and methods). I'm trying to decide between those two options in the mobile application context. I haven't done any measurements since I have yet to write the questions and would like to gather more information before committing to one or another option. As far as I understand: (a) Option 1 will perform better since there will be no need to populate the collection and then garbage-collect the questions; (b) Option 1 will require extra memory: 1000 categories x 100 questions x 4 bytes for each reference = 400 Kb, which is not significant. So I'm leaning to Option 1, but just wondered if I'm correct in my assumptions and not missing something important? Perhaps someone has faced a similar dilemma? Or perhaps it doesn't actually matter that much?


title: Why is CS taught to be memorized?

text: I have been taking Advanced Placement Computer Science for this past year in high school. It seems as though we are taught simply to **memorize** code and functions and **not** how to be resourceful and efficient in using documentation and the like. Practically, I imagine many (if not all) programming jobs would allow you to flip through documentation, review past code and the code of others, essentially doing what my teacher would consider "cheating." While I do agree core concepts are essential to memorize (in any subject matter), it seems superfluous and impractical to me to give a pen-and-paper exam for a CS class, especially when practically you would have a compiler, debugger, reference manuals, and the **entire internet** to refer to in any real-world work situation. **Why is CS taught focusing on the _memorization_ of code and functions as opposed to teaching useful skills including how to use and interpret documentation, sample code, the debugger and such?**


title: How do I decide what testing framework to use?

text: The situation is this. I'm a junior developer for a small government IT project. We don't have anything of continuous integration or a automated testing framework. But the idea is to be developing this kind of thing/improving our developing environment. The product is a data processing algorithm that then displays information to the end user via a webapp. So coming up is a bunch of work modifying the webapp javascript. As such we want to implement a unit testing for the javascript. I've looked at this stack overflow question which outlines several different unit testing frameworks for javascript. The question is - how do I decide between which framework to start using?   * What is a list of criteria for choosing a testing framework?   * Is it practical to try them all out?   * Spend a lot of time reading forums/etc about how they're used?


title: How effective are programming challenges in the recruiting process?

text: I think our company can create challenges designed to find software engineer candidates who are:   * Good at solving problems, not at wowing recruiters.   * More likely to be afraid to come up to us at a career fair.   * More likely to be underutilized in their current programming job but are too introverted to do anything about it. For an example see this article that discusses Facebook hiding an email address in an image using Piet. I just can't find any studies or hard data on whether this actually works or not.


title: How to use a MessageBox using the MVVM pattern?

text: I am implementing a UI application using the MVVM design-pattern. The thing is, sometimes when you detect that something is wrong with data that was inputted by the user, you'd like to notify him somehow. The solution I used so far was to have a "messaging framework" which allows me to basically show messages in a `ListView` I integrate within the window. However, sometimes the windows get a bit "overloaded" with graphical elements, and I would like to be able to show the messages in a message box (basically a modal window). As the `ViewModel` is not supposed to be aware of anything about the UI, I cannot instantiate any window "explicitly". Ideally, this modal window would also use the MVVM pattern and hence I would implement a `ViewModel` for that window, which would be instantiated within the "main" windows's `ViewModel`, and passed to the modal window through the `DataContext`. I would like to have a "simple" example of how to do such thing? Or should this approach be banned from an MVVM application? **EDIT** : Would the use of the Unity Framework be something you recommend?


title: Dirty hack to avoid GPL licensing

text: I've just found something strange in a code written by company which I work for. In an embedded software where dynamic linking doesn't exists, shared library (released on a GPL licence) is copied into an object which is statically linked then. Here is a piece of a makefile:                $(TARGET_DIR)/$(PHOST)_P_LIBxxxxxx.o: $(TARGET_DIR)/$(BINIMAGE)      $(ECHO) --- Storing dynamically linked library as ELF object ---      $(QUIET)cd $(TARGET_DIR) && \      powerpc-eabi-objcopy --input-target binary --output-target \      elf32-powerpc --binary-architecture powerpc:common \        --keep-global-symbol=_binary_$(PHOST)_P_LIB_xxxxxx_start \        --keep-global-symbol=_binary_$(PHOST)_P_LIB_xxxxxx_end \        --keep-global-symbol=_binary_$(PHOST)_P_LIB_xxxxxx_size \        --rename-section .data=.rodata,alloc,load,readonly,data,contents \        $(BINIMAGE)  $(PHOST)_P_LIBxxxxxx.o      $(RM) $(TARGET_DIR)/$(BINIMAGE)      $(ECHO)      $(ECHO) --- P library ready ---      Does it somehow bypass GPL rules? Or simply it's illegal?


title: From where did the symbols *args and **kwargs in Python originate?

text: I know that `*args` and `**kwargs` are ways to feed more arguments into a function in Python. I am wondering where these terms stem from. Why have all the asterisks in the beginning? What does the kw in kwargs stand for?


title: what are the main differences between a web server and application server?

text: I am new to web development and just started exploring the things. I read about how web page is processed and sent to client by a web server but I got confused with application server. what is the difference between them ? why app. server is needed ? and few examples of both of them .


title: Is this simple XOR encrypted communication absolutely secure?

text: Say Alice and Peter each have a 4GB USB flash memory stick. They meet and save on both sticks two files named `alice_to_peter.key` (2GB) and `peter_to_alice.key` (2GB) which contain randomly generated bits. They never meet again, but communicate electronically. Alice also maintains a variable called `alice_pointer` and Peter maintains variable called `peter_pointer`, both of which are initially set to zero. When Alice needs to send a message to Peter, she does (where `n` is the nth byte of the message):               encrypted_message_to_peter[n] = message_to_peter[n] XOR alice_to_peter.key[alice_pointer + n]     encrypted_payload_to_peter = alice_pointer + encrypted_message_to_peter     alice_pointer += length(encrypted_message_to_peter)      ~~(and for maximum security, the used part of the key can be erased)~~ Peter receives `encrypted_payload_to_peter`, reads `alice_pointer` stored at the beginning of message and does:               message_to_peter[n] = encrypted_message_to_peter[n] XOR alice_to_peter.key[alice_pointer + n]      ~~And for maximum security, after reading of message also erase the used part of the key.~~ \- EDIT: In fact this step with this simple algorithm (without integrity check and authentication) decreases security, see Paŭlo Ebermann post below. When Peter needs to send a message to Alice they do the reverse, this time with `peter_to_alice.key` and `peter_pointer`. With this trivial schema they can send each day for the next 50 years 2GB / (50 * 365) = ~115kB of encrypted data in both directions. If they need more data to send, they could use larger keys, for example with today's 2TB HDs (1TB keys) it would be possible to exchange 60MB/day for the next 50 years! That's a lot of data in practice; for example, using compression it's more than hour of high quality voice communication. It seems to me that there is no way for an attacker to read the encrypted messages without the keys, because even if they have an infinitely fast computer, with brute force they can get every possible message under the limit, but this is an astronomical number of messages and the attacker doesn't know which of them is the actual message. Am I right? Is this communication scheme really absolutely secure? And if it is secure, does it have its own name? XOR encryption is well-known, but I'm looking for the name of this concrete practical application using large keys on both sides? I am humbly expecting that this application has been invented someone before me. :-) ~~Note: If it's absolutely secure then it's amazing, because with today's low cost large storage devices, it would be much cheaper to do secure communication than with expensive quantum cryptography, and this has equivalent security!~~ **EDIT:** I think this will be more practical in the future as storage costs decrease. ~~It can solve secure communication forever.~~ Today you have no certainty if someone successfully attacks existing ciphers even a year later and makes its often expensive implementations insecure. In many cases before communication occurs, when both sides meet personally, that's the time to generate the keys. I think it's perfect for military communication, for example between submarines which can have HDs with large keys, and military central can have a HD for each submarine. It could also be practical in everyday life, for example to control your bank account, because when you create your account you meet with the bank etc.


title: Question about casting a class in Java with generics

text: In Java 6               Class<? extends ArrayList<?>> a = ArrayList.class;      gives and error, but               Class<? extends ArrayList<?>> b = (Class<? extends ArrayList<?>>)ArrayList.class;      gives a warning. Why is (a) an error? What is it, that Java needs to do in the assignment, if not the cast shown in (b)? And why isn't `ArrayList` compatible with `ArrayList<?>` I know one is "raw" and the other is "generic", but what is it you can do with an `ArrayList<?>` and not with an `ArrayList`, or the other way around?


title: How to factor in responsive design when providing an estimate for web applications?

text: In the past usually I have only had to estimate web applications based on browser support. But for more recent projects device and platform support are also very important as well (screen resolution). I am having a hard time providing an estimate to account for "responsive design". How much additional time (estimate only) is needed to account for this over the entire implementation of a web based project?


title: Is this method pure?

text: I have the following extension method:                   public static IEnumerable<T> Apply<T>(             [NotNull] this IEnumerable<T> source,             [NotNull] Action<T> action)             where T : class         {             source.CheckArgumentNull("source");             action.CheckArgumentNull("action");             return source.ApplyIterator(action);         }              private static IEnumerable<T> ApplyIterator<T>(this IEnumerable<T> source, Action<T> action)             where T : class         {             foreach (var item in source)             {                 action(item);                 yield return item;             }         }      It just applies an action to each item of the sequence before returning it. I was wondering if I should apply the `Pure` attribute (from Resharper annotations) to this method, and I can see arguments for and against it. **Pros:**   * strictly speaking, it _is_ pure; just calling it on a sequence doesn't alter the sequence (it returns a new sequence) or make any observable state change   * calling it without using the result is clearly a mistake, since it has no effect unless the sequence is enumerated, so I'd like Resharper to warn me if I do that. **Cons:**   * even though the `Apply` method itself is pure, enumerating the resulting sequence _will_ make observable state changes (which is the point of the method). For instance, `items.Apply(i => i.Count++)` will change the values of the items every time it's enumerated. So applying the Pure attribute is probably misleading... What do you think? Should I apply the attribute or not?


title: How to prevent intentional over-estimation in user stories?

text: I am asking this from a purely hypothetical standpoint. According to the Sprint Planning Meeting section in the Scrum Guide: "The number of items selected from the Product Backlog for the Sprint is solely up to the Development Team. Only the Development Team can assess what it can accomplish over the upcoming Sprint." Questions:   1. What is there to stop the development team from over-estimating intentionally the time it takes to complete user stories?   2. If there is a long-term contact with the product owner and development team, should this be defined in the contract as some sort of violation or breach of contract?   3. Who would be responsible for discovering such a violation?   4. How could the product owner prove that such a violation was taking place? Thank you for reading.


title: What's wrong with relative imports in Python?

text: I recently upgraded versions of pylint, a popular Python style-checker. It has gone ballistic throughout my code, pointing out places where I import modules in the same package, without specifying the full package path. The new error message is W0403. > W0403: Relative import %r, should be %r > > Used when an import relative to the package directory is detected. * * * ### Example For example, if my packages are structured like this:               /cake       /__init__.py       /icing.py       /sponge.py     /drink      and in the sponge package I write:               import icing      instead of               import cake.icing      I will get this error. * * * While I understand that not all Pylint messages are of equal importance, and I am not afraid to dismiss them, I don't understand why such a practice is considered a poor idea. I was hoping someone could explain the pitfalls, so I could improve my coding style rather than (as I currently plan to do) turning off this apparently spurious warning.


title: What Exactly is a Model Relative to the ModelAndView Class in Spring

text: What exactly does the "Model" part mean? Is it the same as the domain model? I've read that it's a map, but I'm having a hard time understanding the concept.


title: What does it mean by expected running time  and average runnnig time of an algorithm?

text: Let's say we want to analyze running time of algorithms. Sometimes we say that we want to find the running time of an algorithm when the input size is n and for the worst possible case it is denote it by O(n). Sometimes though I see books/papers saying that we need to find the **expected time** of an algorithm. Also sometimes the **average running time** is used . What is "expected time"? In which cases is it useful to find _expected time_ instead of worst case time? **Edit** : I think there is a subtle difference between _expected running time_ and _average running time_ but I am not sure . Through this post I want to know the exact difference if any .


title: Is Clojure's syntax really simpler than Scala's?

text: Argument which is always made in favour of Clojure is that. The syntax is simpler and there is only one way of expressing code with no complicated rules. However Scala has loads of different types of syntax and constructs as compared to Clojure. But from last one week while trying to learn Clojure, I have noticed that the list of inbuilt macros are endless, Even though we write them with the same parenthesis syntax we need to learn how each works. So in what sense is Clojure's syntax simpler ? For LISPers it might be but for people from a different background learning different constructs in Scala seems simpler. So from a neutral point of view, which syntax is simpler and readable?


title: When creating an api should I stick with small functions and many calls, or a few calls and large functions?

text: I have a rails platform that I maintain. It has a lot of different web applications built on top of it. However now a client is asking for an API so that they can keep users on their site, but take advantage of some of the automated tasks we have. The platform is used to build insurance applications and allows for their purchase online, as well as providing ways to download documentation related to your policy. So my question when building the API is this: When I have to do a lot of things, like `validate`, create a `user`, `user profile`, and `policy`, pretty much at the same time. Should I make 4 separate API calls, and make the client build 4 calls on their side. OR should I have one call that excepts a lot of parameters, that validates the client and creates all 3 of those things at the same time, simplifying things for the client? The client, in this case, gets all of the required information at the same time, so its not like there is a natural flow in their application where it pauses and they can make an API call to my platform. Having been on the client side using many API's before, my gut is to make it as simple for the client as possible and have them make just one call. However this is leading to rather large `functions` in the API, which I'm not a fan of either. How do you suggest I tackle this? As a note, I am not very confident in the clients ability to implement a complicated API on their side.


title: Strategies to manage multiple clients able to simultaneously edit same data

text: How can I deal with situations when multiple clients might edit same object at the same time? For example, I have a web app with admin console, which lets you edit profile data. Several users want to open the same profile and edit it. If I just let the things go as they do, I`ll get "the last who saves wins" situation and all the other users will lose their changes. Blocking object for edit on client, when someone enters edit page, seems relatively easy and overall acceptable for simple objects. However, for complex objects, when different users may want to change different parts of object, merging would be much better. I've read a paper on Conflict-free Replicated Data Types and it seems to be pretty complex and does not cover conflict situations. Are there any other ways to merge objects? Or maybe there are totally different strategies to deal with the situation?


title: Passing multiple errors back from service layer

text: I am using Spring for a web application. To validate a user's input in a form such as for creating a Person entity I user JSR 303 validation to check for not null/empty or valid patterns etc.. Some things however I check in the service layer such as making sure a field is unique in the database and if not throwing an exception. I catch this exception in the controller and add an error to the field. This is basically what Ben J is doing in Option 1 here http://stackoverflow.com/questions/3224749/passing-errors-back-to-the-view- from-the-service-layer Service Layer               public Person createPerson(String username, String fullName, String specialCode)             throws DuplicateUsernameException {         // Check if username exists and throw exception otherwise create person.         if (checkUsernameExists(username)) {             throw new DuplicateUsernameException();         }         Person person = new Person(username, fullName, specialCode);         return personDao.create(person);     }      Controller               void createPerson(Form form, Errors errors) {              try {             service.createPerson(form.getUsername(), form.getFullName(),                     form.getSpecialCode());         } catch (DuplicateUsernameException e) {             errors.add("username", "This username exists");         }              // render view         ...     }      Up until now this has served me well but I now have a requirement to check two fields are individually unique and want to inform the user. In the above example if I wanted to check the specialCode was also unique I could add another check below the existing one in the service layer and throw a separate DuplicateSpecialCodeException. Service Layer               public Person createPerson(String username, String fullName, String specialCode)             throws DuplicateUsernameException, DuplicateSpecialCodeException {         if (checkUsernameExists(username)) {             throw new DuplicateUsernameException();         }         if (checkSpecialCodeExists(specialCode)) {             throw new DuplicateSpecialCodeException();         }         Person person = new Person(username, fullName, specialCode);         return personDao.create(person);     }      Controller               void createPerson(Form form, Errors errors) {              try {             service.createPerson(form.getUsername(), form.getFullName(),                     form.getSpecialCode());         } catch (DuplicateUsernameException e) {             errors.add("username", "This username exists");         } catch (DuplicateSpecialCodeException e) {             errors.add("specialCode", "This special code exists");         }              // render view         ...     }      The problem is if the user submits a duplicate Username and a duplicate SpecialCode they will only be informed of the duplicate Username. I want to shown both fields. What is a neat way of doing this? My ideas so far are:   * Throw an exception that contains all the errors.   * Pass the Errors object to the service and added values to this. Both of these methods would rely on the service layer knowing about the name of the fields and a suitable error code which seems to go against keeping the layers separate.


title: What is ASM.js and what does it mean for everyone?

text: I'm starting to hear rumblings about this project called ASM.js. Currently their web site is terrible and confusing. Here's what I know from my research on the web.   * It is a subset of JavaScript that can be highly optimized. I'm guessing because it avoids the more dynamic parts of the language.   * Performance of code compiled to ASM.js runs at about half the speed of C (not light).   * The intention is for compilers to make their target language ASM.js.   * Firefox is going to be shipping with ASM.js optimization baked in.   * The Mozilla and Unreal teams ported the _Unreal Engine to the web with it_ and its running in a build of _Firefox_ at near-native speeds. There doesn't seem to be any concrete information on the web about what this really _is_ or the usefulness or ultimate purpose. Is it that I can compile my otherwise server-side code bases and have it run in the browser at close-to- native speeds? What are the ramifications for developers?


title: Do you consider quitting your job if you cannot add anything new to your resume for a long time?

text: > **Possible Duplicate:**   >  When do you know it's time to move on from your current job? I just realized that I cannot add any new programming skills to my resume, for like 10 months. I am not sure whether this is a bad sign or not about my current job. How would you interpret this situation if you were a junior .NET developer at the age of 27?


title: Move on and look elsewhere, or confront the boss?

text: > **Possible Duplicate:**   >  When do you know it's time to move on from your current job? **Problem:** I had no prior experience when I interviewed, so I didn't know exactly what to ask _them_ about the company when I was hired. I've spotted a number of warning signs and annoyances since then, such as:   * Four developers when I started, with everyone talking about "Ben" or "Ryan" leaving. One engineer hired thirty days before me, one hired two weeks after me. Most of the department has been hiring a large number of people since I started.   * Extremely limited internet access. I understand the idea from an IT point of view, but not only is Facebook blocked, but so it Youtube, Twitter, and Pandora. I've also figured out that they block all access to non-DNS websites (http://xxx.xxx.xxx.xxx/) and strangely enough Miranda-IM.   * Low cubicles. Which is fine because I like my immediate coworkers, but they put the developers with the customer service, customer training, and QA department in a huge open room. Noise, noise, noise, and people stop to chitchat all day long. Headphones only go so far.   * Several emails have been sent out by my boss since I started telling us programmers to not talk about non-work-related-things like Video Games at our cubicles, despite us only spending maybe five minutes every few hours doing so. Further digging tells me that this is because someone keeps complaining that the programmers are "slacking off".   * People are looking over my shoulder all day. I was in the Freenode webchat to get help with a programming issue, and within minutes I had an email from my boss (to all the developers) telling us that we should NOT be connected to any outside chat servers at work.   * Version control system from 2005 that we must access with IE and keep the Java 1.4 JRE installed to be able to use. I accidentally updated to Java 6 one day and spent the next two days fighting with my PC to undo this "problem".   * No source control, no comments on anything, no standards, no code review, no unit testing, no common sense. I literally found a problem in how they handle string resource translations that stems from the simple fact that they don't trim excess white spaces, leading to developers doing: getResource("Date: ") instead of: getResource("Date") + ": ", and I was told to just add the excess white spaces back to the database instead of dealing with the issue directly. Some of these things I'd like to try to understand, but I like having IRC open to talk in a few different rooms during the day and keep in touch with friends/family over IM. They don't break my concentration (not NEARLY as much as the lady from QA stopping by to talk about her son), but because people are looking over my shoulder all day as they walk by they complain when they see something that's not "programmer-looking work". I've been told by my boss and QA that I do good, fast work. I should be judged on my work output and quality, not what I have up on my screen for the five seconds you're walking by So, my question is, even though I'm just barely at my 90 days: **How do you decide to move on from a job and looking elsewhere, or when you should start working with your boss to resolve these issues? Is it even possible to get the boss to work with me in many of these things?** This is the only place I heard back from even though I sent out several resume's a day for several months, and this place does pay well for putting up with their many flaws, but I'm just starting to get so miserable working here already. Should I just put up with it? **Edit:** I appreciate all the responses! First: I'm in the United States, and I'm salaried, and I'm about 5 days away from hitting the end of my 90 day probation. While it is my immediate boss sending out the emails I mentioned, I believe it is actually the department manager doing the majority of the arm-bending. He's also the only one with an office. My immediate boss is a nice guy, he is just complacent. As I mentioned, the Facebook/Twitter/Youtube makes sense from an IT (and management) point of view. Some people _do_ need to have these things limited, otherwise they would waste time on them. However, on occasion, I've come across Youtube videos that very well could be useful, such as when doing Android development (which I am). It would also be useful when it comes to the "research" part of the "R&D" department I work in. It could just be my naievity here, but I feel people should be judged on their work (speed and quality), not what they happen to be doing when you walk by. If I'm getting my work done, and the work is good, then does it matter what website I'm on? Related to above, but I _do_ understand the reasoning for limiting IM and/or IRC access while at work, and I do understand that they're paying me to be here and can dictate to me what I can and can't do. Though, again, judge me on my work not what's on my screen. Is this really so uncommon in a software development field? It is my understanding and my experience that staring at an IDE for 8 hours, typing all the while, is completely unrealistic. I can chat on IM/IRC, enjoying my time at work more simply because of this, without dumping my "short term memory", continuing to work on the problem in my head. I can't do that when Becky from QA stops to talk to me about lunch. I feel I did luck out with this job, and I'm glad I have it. This place does have it's positives: Lax on the dress code, lax on when we have to be to work (before 9am ideally, some leeway here), great benefits. But, I'd seriously take less money if it meant that I could enjoy my day more just in the simple things that, I admit, _are_ mostly me whining about. I just feel that if I'm going to be sitting behind a PC for 8+ hours a day, I'd like it to be as enjoyable as possible.


title: Visualize flowchart diagram with multiple end symbols

text: I am looking for a standardize way to visualize the following hierarchical logic: The state of the thread is represented by the answers to the hierarchical set of question You can read this listing like a flowchart, you iterate over the questions decide, go one step deeper and so on. Therefore I thought the best way to visualize it, using a flowchart. The problem is, in this hierarchical set it is possible to end in more than one state and its totally valid. I have never seen a flowchart where you can enter more than one state. Is it still possible and I am missing the right symbol to present this logic or are flowchart not fitting anyway? What other graphical representation could I use, is there something fitting in UML? A non-deterministic state machine seems not to be intuitive enough, transfering it into a deterministic state machine would result in to many states, and so on.


title: "Super" vs "protected method" for running common code

text: In many langauges, `super()` lets you call the parent method which you have overridden. I've been using `super` in my Javascript (with fake object oriented implementation) to run common code for a long time without problems. Now I've finally hit a case where calling a `protected` base class method would have been better than calling `super`. Here's a concrete example. > Grandparent -> Parent -> Kid I needed to add a Kid. It's identical to Parent except for one method called someMethod. Kid's someMethod needed to do Grandparent's common stuff, but not Parent's specific stuff. So Kid's someMethod could not call `super` because that would trigger Parent specific code. Instead of changing my grand class structure, I just made Kid duplicate Grandparent's common code.               Grandparent {      someMethod {       do common stuff      };     }          Parent: Grandparent {      someMethod {       super();       do parent specific stuff      }     }          Kid: Parent {      someMethod {       duplicate of common stuff       do kid specific stuff       }     }      In my book, duplicate code is bad. If only Grandparent wrote its common stuff as a protected method, I wouldn't need to duplicate code.               Grandparent {      protected commonMethod      virtual someMethod     }          Parent: Grandparent {      someMethod {       commonMethod       do parent specific stuff      }     }          Kid: Parent {      someMethod {       commonMethod       do kid specific stuff      }     }       Should I just completely stop using `super` and switch to `protected` methods for running common code? Are there any pitfalls to protected methods for running common stuff?


title: Custom templating in a web application

text: I want to understand the pros and cons in generating dynamic web application controls. The idea is to generate all the controls dynamically based on the database procedure output and populate the controls to a say a grid structure / independent controls. I know that creating user controls and populating to layout is one option. Say, if we don't know what is the structure of controls the procedure is going to generate based on complex logic; what all should be considered in generating a layout structure? Is what I am thinking of is not logical in web application sense? Do I need to tackle the issue in a top down approach than a bottom up approach?


title: What defines "software developer" role

text: I am a junior software developer and I have been working for a company less than a year. While I always thought being a software developer means to develop software and CODE something, my tasks are more in administration type of work, such as setting up Jenkins, SQL Replication and etc. Are these type of jobs included in a Developer role, or a developer only develops software? Should I be talking to my manager about this? Is this a common way for companies to evaluate "developing" skills?


title: Appropriate selection of security framework

text: I have a web application to be developed using RESTeasy API and for this I have to implement security (Form based authentication). So i am not sure about the most appropriate fit for this. As I googled, I found Apache Shiro, Spring Security, etc. Also I have read something about Rest provided authentication jars. Please help me with this. EDIT: My requirements:   1\. I should be easily able to use framework with RestEasy API.   2\. It should provide authentication and authorization at least


title: Sockets intricacies in TCP and UDP

text: I am quite familiar with TCP and UDP. I understand the process by which TCP establishes connections and other theoretical facts about TCP but when reading up about TCP hole punching for NAT Transversal, I have become stumped by how connect(), accept() and listen() is done in TCP. Is it a single or multiple sockets that are used for all this in TCP and is is this done the same way in UDP


title: Loading chunks around center

text: I am making a voxel game like Minecraft. I am able to load chunks using multithreading with the code...               for (int x = 0; x < WorldSettings.WORLD_WIDTH_IN_CHUNKS; x++)     {         for (int y = 0; y < WorldSettings.WORLD_LENGTH_IN_CHUNKS; y++)         {             chunks[x, y].BulidVertexData();             Thread.Sleep(50);         }     }      this works fine, it starts by loading the far away chunk and loads them back and forth like a windshield wiper that gets closer, but I would rather have it load in a circle around the player by loading the near chunks first. Any ideas?


title: Should I use parentheses in logical statements even where not necessary?

text: Let's say I have a boolean condition `a AND b OR c AND d` and I'm using a language where `AND` has a higher order of operation precedent than `OR`. I could write this line of code:               If (a AND b) OR (c AND d) Then ...      But really, that's equivalent to:               If a AND b OR c AND d Then ...      Are there any arguments in for or against including the extraneous parentheses? Does practical experience suggest that it is worth including them for readability? Or is it a sign that a developer needs to really sit down and become confident in the basics of their language?


title: Is looking at random code snippets useful to quickly determine the quality of a project?

text: To get an idea of the quality of a project that I've never seen before (usually open source projects that I'm considering whether or not to use), I often start by opening random files and eyeballing fine details of the code. I look for things like:   * Style (does it follow accepted conventions for the language and is it consistent)   * Quality and consistency of comments   * Common language specific gotchas (e.g. consistently not using `===` in javascript)   * Does it _look_ logically structured I find this gives me a good idea of the skill of the developer/s that wrote the code, even if I know absolutely nothing about what the code is meant to be doing. Do people think this is useful? What does one need to take into account for quickly assessing the quality of a project's code base, assuming no knowledge of how it actually works?


title: How to verify data from localStorage on a server

text: On my mobile app, I am storing the username of a logged in person, and downloading some data for the given/stored username. When the user checks for updates to his data content on the server, the server dishes out a delta of the content, based on the username. The app then updates its local display accordingly. The problem is, since I am using localStorage, there is no guarantee that someone will not edit the username stored locally and try to request data meant for someone else. What would be the best way of getting around this possible security hole? Please comment on this method that I am planning to implement:   1. Each time you login, a random string is generated and stored for future checking in a database, along with your username, and date/time of request.   2. Whenever a request to download data for a username comes in, it must be accompanied by the string from the previous attempt. Also, each fresh update for the client is accompanied by a new random string, which is stored in the database and the old one is deemed expired.   3. If the random string is not provided correctly, the user is logged out of the mobile app (as this could potentially be someone tampering with the app). The advantage I see for this method is that I have an audit trail as well for later verification and forensics. What are the flaws?


title: Bulk commits vs Quick commits

text: I know that most of you would advice to go with the strategy and methodology of the project. However I just have a quick question, from Senior point of view, what would be better to see quick small commits from a developer, or large chunk of code pushed to the branch?


title: Why did the ISO 8601 committee choose Monday as the first day of the week?

text: Sunday is considered the first day of the week in the United States and countries that followed the Greco-Roman tradition.


title: I have data that sends in "bursts" of 100 records with a significant delay. How do I structure my classes for multithreading?

text: My datasource sends information in 100 batches of 100 records with a delay of 1 to 3 seconds between batches. I would like to start processing data as soon as it's received, but I'm not sure how to best approach this. Some ideas I've been playing with include:   * `yield`   * Concurrent Dictionary   * ConcurrentDictionary with INotifyProperyChanged   * Events   * etc. As you can see I'm all over the place, and would appreciate some tested guidance on how to approach this


title: Tool to identify (and remove) unnecessary website files?

text: Inevitably I'll stop using an antiquated css, script, or image file. Especially when a separate designer is tinkering with things and testing out a few versions of images. Before I build one myself, are there any tools out there that will drill through a website and list unlinked files? Specifically, I'm interested in ASP.NET MVC sites, so detecting calls to (and among many other things) @Url.Content(...) is important.


title: Dynamic Forms: Pattern or AntiPattern?

text: I'm sure you've seen it. The database has a bunch of tables called `Forms`, `Controls`,`FormsControls`, `ControlSets`, `Actions` and the program that queries these tables has a dynamically generated user interface. It will read all the forms, load a home page that has links to them all, or embed them in some tabbed or paged home page, and for each of those forms it will read the various text boxes, check boxes, radio buttons, submit buttons, combo boxes, labels and whatnot from the controls and form-to-control join tables, lay those elements out according to the database and link all the controls to logic according to other rules in the database. To me, this is an anti-pattern. It actually make the application more difficult to maintain because the design of it is now spread out into multiple different systems. Also, the database is not source controlled. Sure, it may make one or two changes go more quickly, after you've analyzed the program anyway to understand how to change the data and as long as you don't stray from the sort of changes that were anticipated and accounted for, but that's often just not sustainable. What say you?


title: What are my options for selling software independently on Windows?

text: I am looking to port a tool from the Mac app store over to Windows, the platform where I spend most of my time these days. I've spoken with the author of the original app and we've begun talking about licensing options should I decide to sell the application, and it seems like it would be feasible. I've never sold software independently, let alone on Windows. That I know of, there is not (yet) an equivalent app store for Windows (maybe one coming with Windows 8). Assuming my product was done today and I was ready to go to market, what options do I have for selling software for Windows as an independent developer or Micro-ISV? I know can sell it through my own website and accept PayPal, but are there options that will offer more visibility, similar to that of the Apple app stores? Any options to avoid?


title: How can a PHP programmer best prepare for a C++ course?

text: I have never programmed in C++, but am going to be taking a class that involves programming in C++ in January. I want to be able to excel in the class, and looking for advice, as I come from a PHP background. How can I best prepare myself for success?


title: Scrum - What and How meetings

text: My team and I are struggling with the what and how meetings. It's hard for us to choose what to work on when we don't know how it is going to be done. Our estimations may be way off when pointing an estimated level of effort. At this point it's being discussed if we should do the how before the what so that pbi's will be at least reasonably well estimated. What are some other options that don't require changing the order of the accepted scrum practices?


title: Where does the term "Front End" come from?

text: Where does the term "front-end" come from? Is there a particular presentation/talk/job-posting which is regarded as the first use of the term? Is someone credited with coining the term? The Merriam-Webster entry for "front-end" claims the first known use of the term was 1973 but it doesn't seem to provide details about that first known use. Likewise, the Wikipedia page about front and back ends is fairly low quality, and cites very few sources.


title: Are all View Models supposed to be accessed through the Main View Model in MVVM?

text: I am currently working on a WP8 application. My current design is to have each view bind against a specific view model directly. Looking through the samples though, it seems that another way is to have all the view models accessed through the Main View Model and then have all the views to their view models through the MVM. Is this the correct way to do it (So that it doesn't cause flexibility and other issues in the future)?


title: Why does VBA / VBScript require "Set" prefix

text: When I set a variable to an object in VBA / VBScript, I always need to prefix the statement with "Set" such as: `Set Dict = CreateObject("Scripting.Dictionary")` If I set a variable to a primitive or array value, I have to omit the "Set" such as: `Num = 123` This is different from languages such as JavaScript, PHP, Python etc. Is there some technical reason why they have this requirement in VBA / VBScript?


title: What is a realistic way to handle customer-specific software patches?

text: I'm trying to gather effective ways that others have solved the following problem. At work we've been forced to release a software patch (to be installed on end-user systems) that we only want visible to a specific customer. The custom code is in its own source-control branch. The problem is we have two parallel code lines (and build scripts) to keep in sync, and every time we patch the original code we have to patch and test the customer- specific code. I'm curious, how do other organizations handle this scenario? We're open to business solutions and not _just_ technical (source-control related) ones. For example, we've talked about telling the customer they can't receive updates on that branch. Our branching strategy is like this (based on the Visual Studio TFS Branching Guide, although we're using Subversion for it) ![enter image description here](http://i.stack.imgur.com/XXtU0.png)


title: Review quality of code

text: I have been asked to quality review two code bases. I've never done anything like that, and need advice on how to perform it and report it. **Background** There are two providers of code, one in VB and one in C (ISO 9899:1999 (C99)). These two programs do not work so well together, and of course, the two suppliers blames each other. I will therefore as a independent person review both codes, on a comprehensive level review the quality of the codes to find out where it is most likely that the problem lies. I will not try to find problems, but simply review the quality and how simple it is to manage and understand the code. **Edit** : I have yet not received much information about what the problem consists of. I've just been told that I will examine the code in terms of quality. Not so much more. I do not know the background to why they took this decision.


title: How to tell SignalR Notifications Hub that there is a new notification without having SignalR poll on that table

text: I'm developing a push-notifications system for my ASP.NET MVC app. The idea is to use Redis for queueing, ServiceStack for queue processing and SignalR for push-notifications to implement a system that's able to distribute different types of notifications. I've put together a quick prototype where I have a ServiceStack service which listens on the Redis queue. When it receives a message it looks at the ReplyTo property on the message, which contains the URL of the worker (subscriber) that can process the message. It then formulates a response for that worker and drops it into the Redis queue. Here, essentially ServiceStack is using PUBSUB feature of Redis to notify that worker that it has a new item to process. The worker then begins processing the message. An an example, if it's a connection request message, it'll try to pull all required data from SQL DB based on identifiers in the message. Lastly, it saves the message into a "Notifications" table. I'm guessing there would be multitude of these workers, processing different notification types coming out of all kinds of background jobs. Here is the problem. I have no idea how to tell SignalR Notifications Hub that there is a new notification without having SignalR poll on that table. I could use SQL dependencies here, but it seems ugly. Ultimately it'd be cool to hit that Hub with a HTTP request from my worker, but i don't know if that's even possible. What would you guys suggest?


title: If I unite many web apps into one, will I save resources?

text: I'm comparing 2 different approaches of J2EE application architecture:   1. Divide independent parts as modules of one big web app.   2. Divide independent parts as different web apps running on same server. Between these approaches I prefer the second one because it allows me to make changes without redeploying the whole application. Imagine that you want to change something in app2. In the case of one big app you have to redeploy the whole application. In the second case you have to only redeploy app2. But I have some doubts about resources consumption such as memory usage and CPU usage. I personally think that each J2EE application, no matter how large it is, has some minimal limit of memory it will necessary use. This minimal limit is what is needed for context loading, web framework config files, jar libs and other things. My hypothesis sounds like "Having many web apps running on same server leads to multiplication of wasting of default minimal resources." Is the picture below correct? Does one big application save me from default resorces overhead multiplication shown on the picture? ![Description](http://i.stack.imgur.com/j0fgq.png)


title: Advice on refactoring PHP Project

text: I have a small SAS ERP that was written some years ago using PHP. At that time, it didn't use any framework, but the code isn't a mess. Nowadays, the project grows and I’m now working with 3 more programmers. Often, they ask to me why we don’t migrate to a framework such as Laravel. Although I'd love trying Laravel, I’m a small business and I don't have time nor money to stop and spend a whole year building everything from scratch. I need to live and pay the bills. So, I've read a lot about this matter, and I decided that doing a refactoring is the best way to do it. Also, I'm not so sure that a framework will make things easy. Business goals are:   * Make the code easier to new hired programmers   * Separate the "view", in order to:     * release different versions of this product (using the same code), but under different brands and websites at the minimum cost (just changing view)     * release different versions to fit mobile/tablet.   * Make different types of this product, selling packages as if they were plugins.   * Develop custom packages for some costumers (like plugins/addon's that they can buy to put on the main application). Code goals:   * Introduce best pratices, standards for everyone   * Try to build my own MVC structure   * Improve validation of data/forms (today they are mixed in both ajax and classes)   * Create automated testing routines for quality assurance. * * * My current structure project:   * class\   * extra\   * hd\   * logs\   * public_html\   * public_html\includes\   * public_html\css|js|images\  * * * ## class\ There are three types of classes. They are all “autoloaded” with something similar with PSR-0, but I don’t use namespaces. **1\. class.Something.php** Connects to Database using specific methods. I.e: Costumer->list(); It uses “class.Db.php”, that it’s an abstraction of mysql on every method. **2\. class.SomethingProc.php** Do things that “join” things that come from “class.Something.php”. Like IF/ELSE, math operations. **3\. class.SomethingHTML.php** The classes with “HTML” suffix implements only static methods and HTML code only. **A real life example:** All the programmers need to use $cSomething ($c to class) and $arrSomething (to array). Costumer.php (view)               <?php     $cCosumter = new Costumer();     $arrCostumer = $cCostumer->list();     echo CostumerHTML::table($arrCostumer);     ?>      ## Extra\ Store 3rdparty projects/classes from others, such MPDF, PHPMailer, etc. ## Hd\ Store user’s files outsite wwwroot dir. ## Logs\ Store phplogs and the system itself logs (We have a static Log::error() method, that we put in every method of every class) ## Public_html\ Stores the files that people use. ## Public_html\includes\ Store the main “config.php” file and all files that do “ajax things” ajax.Costumer.php, for example. ## Help is needed ;) So, as you can see we have some standards, and also for database things. But I want to write a manual of our rules. Something that I can give to any new programmer at my company and he can go on. This is not totally a mess, but it could be better seeing the new practices. What could I do to separate this as MVC, to have multiple views. Could you give me some tips considering my goals? Keep im mind the different products/custom things for specific costumers without breaking the main application. URL for tutorials, books, etc, would be nice.


title: Do software developers write SQL?

text: Do software developers write SQL or database developers provide the SQL and the software developers use it? I am a novice to software development. I am just trying to understand the software development process because I have to do an internship this summer. I apologize in advance if this is a basic question.


title: Data structure for fast StartsWith filtering of a dictionary

text: I have a list of english words. I'm trying to come up with a data structure that allows me to do fast StartsWith filtering, like:               var words = dictionary.StartsWith("foo");      I was thinking of creating a data structure like this: ![Data Structure](http://i.stack.imgur.com/ZhA1A.png) But I wanted to ask first: a) Does the above data structure already have a name? b) Is this the fastest way to implement what I'm looking for? Edit: The data structure will be built at the beginning and not change. I'll only need to do the equivalent of StartsWith and Contains.


title: Should I learn in c++ or c# (for computer science degree)?

text: I'm about to start a "Bachelors of Science (Computer Science)" degree (in Australia, semester starts in march) and I'm presented with the option to learn c# or C++. First of all, I already know C#, and I love C#. It is just so easy to use. Not having to worry about memory management or garbage collecting makes my brain tingle. I've made plenty of apps / games in C# and I find the syntax easy to follow, I love intellisense (which I think C++ doesn't have), and it seems just to be a nice language in general. I've been trying to wrap my head around C++. First thing I can say... IT'S HARD. Half the time I'm thinking to myself: "Do I need to include a ^ symbol after String?", etc. The syntax just seems hard to follow and I get really aggravated over it. This is simply with me trying to teach myself, however, without a teacher. My goal after my degree is to join a game firm, and assist in making games, so that has to be a top factor in my decision making. Can you guys give me some advice? Thanks.


title: SOAP traffic generator

text: I'm trying to build a SOAP message generator that will generate SOAP messages of different kinds that I have specified. Each of these messages also has a reply that will be coming back. The meaning of this generator is to generate SOAP messages and measure performance on some equipment that the messages are being sent over. I therefor need to be able to generate messages at a high pace and while sending them I also need to confirm how many messages where dropped, if any. My basic plan in this project is to send and receive the SOAP messages (and replies) in different Threads to allow for maximum performance. I've tried to read up on SOAP by reading the Wikipedia and W3Schools articles here: http://www.w3schools.com/soap/default.asp http://en.wikipedia.org/wiki/SOAP http://www.w3schools.com/wsdl/wsdl_intro.asp http://en.wikipedia.org/wiki/Web_Services_Description_Language I still haven't got a clear picture on how SOAP works though. **Is it possible to send and receive replies in different Threads? How could this be done?** If it's not possible I guess the SOAP message/reply would have to go through the same "socket". **Is it possible to send multiple messages without waiting for a reply over the same "socket"? How could that be done? (just keep looping and sending?)** Java and Apache CXF will be used in the implementation. I would greatly appreciate any thoughts, guidelines or general ideas on this subject. EDIT: There are a lot of recommendations on using other tools but however silly it might sound I really would like to invent the wheel again and write my own little performance testing environment. What I really wish to know is about the **message flow** in SOAP. I've clarified the questions a bit.


title: Why doesn't monad take `(M a -> M b)`?

text: All apologies -- I'm still very much on the outside of Haskell looking in. Why does the bind for a monad have this signature: > M a -> (a -> M b) -> M b and not > M a -> (M a -> M b) -> M b i.e. a function that takes `M a` instead of just `a` `a` is available to the function in both, but the context that `M` provides is not available to the function in the 1st. Just the lifted value itself. (If that's a silly question, just downvote me a lot & I'll delete it... like I say, still very much on the outside looking in)


title: Effective design analysis

text: Our team redesigns the legacy software and there are a lot of design meetings going on. Many of them are not very effective and lack good analysis of the proposed design. Is there any formal way to approach this kind of discussions to make them more effective? I heard about SWOT for example, but afaik it is used more for business projects.


title: How to write junit test case for the program

text: I have a method which has external dependencies within the method. Please help me in writing a junit test case for the below program.                   @Override         public void methodToTest(String user){                //fetch the values from the properties file. Config class has a static method called           //getProperty which reads the values from the environment specific property file.           String url = Config.getProperty("serviceurl");           String username = Config.getProperty("serviceusername");           String password = Config.getProperty("servicepassword");                //Connect to an external service.           Service service = new Service(url, username, password);                //invoke the method on the service.           String returnValue = service.registerUser(user);                if (returnValue.equals("failure")){             throw new Exception("User could not be registered");           }         }      **Note:**   1. The method overrides the superclass method so that I cannot change the arguments to contain the url, username and password.   2. The method also connects to an external service. which is environment specific. The environment details is taken from the properties file.


title: What are the most appropriate algorithms for downscaling images extremely while maintaining recognition?

text: I want to create a window icon (128x128 at most, the icon in the corner of the window on Windows is 24x24, I believe) from a large image (1024x768 and more). I've tried several algorithms - nearest neighbor, bicubic interpolation, but they all produce a very soft and barely recognizable image. Do I need content-aware resize for this task?


title: Handling unexpected features during sprint

text: Our team is going to adopt scrum and agile technics. We've got a product, which we develop for multiple customers. This customers supplied us with necessary requirements, so everithing is fine to adopt agile techinics. But at some moment (for example during sprint), new customer apears, and he wants to get a demo of product slightly different from what we have now. This may be some new features or minor differences in behavior. And he wants to get this demo for example during the week. It is very important to show that our product supports this features (because otherwise he will address to our competitors), so we have to develop this features (may be partly) during the week. How we must handle this sort of features with agile? Move them to current sprint backlog? Or split one team to two and create another sprint? Or may be there is another way?


title: What are some best practices for securing AWS credentials (or other secrets) for large team?

text: I was _"that guy"_ that pushed his aws keys to github. Ugh. Anyway, I'm doing some research on how to prevent this in the future as this is the third time I've seen this done (my first!) and it was just a headache for the entire company. Everyone gets their own keys that have full access since we need to spin up instances, access s3, etc. Most people store them in environmental variables as do I and when I committed my dot files that's where the issue came in. We'd also like to not have them in code. We can send out memos and make sure people know but accidents will happen so what are some best practices to reduce the risk? I was thinking of storing them password protected and when you decrypt them they go into the environment and maybe providing some git hooks that search for certain keywords. Any other suggestions?


title: Is there just one EventHandler class per application?

text: In a game I'm making I was about to add a `MovementEventHandler`, with events like "pre-character-movement" and "post-character-movement". But this class will do exactly the same as a future `CurrencyChangeEventHandler`. Should I just be creating a `GameEventHandler`, which just handles arbitrary event names? One of the trade offs I can imagine for that is potential clashes in event names, but that's easily handled by namespacing the names of events (prefixing them with something). The benefit is fewer objects hanging around the service container.


title: Best practices for launching a new software version

text: I rebuilt a web app to replace a version that we have been using for the last 3-4 years. We have a few thousand clients and a few hundred active users per day. The functionality is basically the same. The new version is a little bit faster with a few enhancement features and there are a lot of behind the scenes changes that the clients will never see. The UI is quite different but ultimately much easier to use and navigate. How should I go about having our clients stop using the old system and start using the new one? I am currently putting together a video that will play on the web site as well as within the app. The video will go through the pages and focus on some key changes. I was also thinking about an intro page that will display once the user logs in and explains some of the features.


title: Using a Simple/Static Factory vs. instantiating directly: new Thing() vs. factory.createThing() - what's the benefit?

text: Here are two ways to instantiate an object: **Option 1:**               Thing thing = new Thing();      **Option 2:** _(the factory is a Static Factory, but it could also be a Simple Factory)._               Thing thing = ThingFactory.createThing();      Where:               class ThingFactory(){         public static Thing createThing(){             return new Thing();         }     }      * * * Option 2 is said to be better, because using a factory decouples the client code from the concrete implementation of the class it's instantiating. **However what difference does it actually make if I use`new Thing()` or `factory.createThing()`?** The only difference between the two options is that the instantiation code is moved to a different place. As I explained above I know the 'academic' explanation to why using a factory is 'better', but I don't actually see the practical benefit. In both cases, the client knows exactly what it wants: a `Thing`. **The only difference is the exact line of code:`new Thing()` or `factory.createThing()`.** * * * **More sophisticated factories, I can see their benefit.** For example using the Abstract Factory pattern, I could create different `Factory` subclasses that instantiate different concrete implementations of `Thing`, and inject the suitable `Factory` to the client at runtime, without the client worrying about the concrete implementation it receives. `BlueThingFactory` instantiates `BlueThing`, `RedThingFactory` instantiates `RedThing`, but the client only cares that it receives a `Thing`. This is with more sophisticated factories. **But I'm unable to see the benefit of using a _simple factory_ as in the example I described. _All it does is move`new Thing()` to a different place._ I don't understand the benefit of this.** * * * Please explain to me the actual benefits of using a simple factory.


title: Is it OK to introduce methods that are used only during unit tests?

text: Recently I was TDDing a factory method. The method was to create either a plain object, or an object wrapped in a decorator. The decorated object could be of one of several types all extending StrategyClass. In my test I wanted to check, if the class of returned object is as expected. That's easy when plain object os returned, but what to do when it's wrapped within a decorator? I code in PHP so I could use `ext/Reflection` to find out a class of wrapped object, but it seemed to me to be overcomplicating things, and somewhat agains rules of TDD. Instead I decided to introduce `getClassName()` that would return object's class name when called from StrategyClass. When called from the decorator however, it would return the value returned by the same method in decorated object. Some code to make it more clear:               interface StrategyInterface {       public function getClassName();     }          abstract class StrategyClass implements StrategyInterface {       public function getClassName() {         return \get_class($this);       }     }          abstract class StrategyDecorator implements StrategyInterface {            private $decorated;            public function __construct(StrategyClass $decorated) {         $this->decorated = $decorated;       }            public function getClassName() {         return $this->decorated->getClassName();       }          }      And a PHPUnit test                /**        * @dataProvider providerForTestGetStrategy        * @param array $arguments        * @param string $expected        */       public function testGetStrategy($arguments, $expected) {              $this->assertEquals(           __NAMESPACE__.'\\'.$expected,             $this->object->getStrategy($arguments)->getClassName()         )       }          //below there's another test to check if proper decorator is being used      My point here is: is it OK to introduce such methods, that have no other use than to make unit tests easier? Somehow it doesn't feel right to me.


title: Type Safety of Spray.io

text: Yesterday I read a tweet disparaging Jersey with JAX-RS due to run-time errors. Spray.io was mentioned in the tweet: > Not even 5 minutes using Jersey / JAX-RS and already a runtime error due to > a missing annotation. That's why I like @sprayio: type safety. https://twitter.com/gbelrose/status/467295643053338626 How does `spray.io` provide type safety? Could you please give an example?


title: How to bill time working around web hosting issues?

text: My client's web hosting company changed some web server security rules which made the site not work properly. I spent 4 hours diagnosing the problem and emailing their tech support back and forth. I'm thinking of billing my client for this, but it could be counterproductive because it doesn't happen that often that I have to work around web hosting issues. On the other hand, I hate working without getting paid. Should I:   1. bill them for working around web hosting issues (they chose the web hosting company)   2. threaten to bill them next time and advise them to change their hosting company   3. let it go and just incorporate any potential web hosting issues into the price for future jobs How do you do it?


title: Separating UI from logic in JavaScript modules

text: I'm refactoring some custom JavaScript modules written to support our mapping functionality. I'm looking to make them much more unit-testable and be able to plug pieces in and out more easily. My question is related to having UI manipulation and business logic be in the same module. I know that having the UI part makes unit testing a little more difficult. I would think also decoupling the UI part would enable other people to add their own UI layer if they wanted to change the look and feel while still keeping the core functionality. **Edit** : I'm more working with Dojo modules since that what the mapping API is built on top of. I figured since Dojo comes with it we would use that. I'm finding that Dojo modules don't lend themselves to being easily tested (I tried using Doh and it is the most unintuitive testing framework I've ever worked with). I'm thinking of making more vanilla JS modules and only tried to use what I absolutely need to from Dojo. That's where I got the idea to maybe separate the UI layer from the logic for each module as well. Does anyone have suggestions on how those can be decoupled?


title: "t-sql" tool for csv files?

text: Is there a tool that allows to query files based on the following criteria, and change them?   * creation date   * filenames (e.g. filetypeA_YYYYMMDD_data2.blah)   * file content For the example, the workflow could be the following one:   * Get all files created between date x and date y, where the filename contains z and the file itself contains value x under column zzz.   * Update it to be a different value/another column.


title: How to I write tests for code that's driving Robot and other external features?

text: I've got some code I use to take regular screenshots of my screen - it's useful to work out how much of any given day I'm spending on various activities. It looks like this:               /**      * Code modified from code given in      * http://whileonefork.blogspot.co.uk/2011/02/java-multi-monitor-screenshots.html following a SE      * question at      * http://stackoverflow.com/questions/10042086/screen-capture-in-java-not-capturing-whole-screen and      * then modified by a code review at      * http://codereview.stackexchange.com/questions/10783/java-screengrab      */     package com.tmc.personal;          import java.awt.*;     import java.awt.image.*;     import java.io.File;     import java.io.IOException;          import javax.imageio.ImageIO;          // TODO: improve screencapture tool by having it not take a photo when the mouse hasn't moved...          class ScreenCapture implements Runnable {            private int minsBetweenScreenshots = 5;       private String workingDirectory = "";            public ScreenCapture(String string, int i) {         workingDirectory = string;         minsBetweenScreenshots = i;       }                 private void tryWritingScreenshotToFile(int indexOfPicture) {         try {           Image scaledImg = takeScreenshot();           storeImageToFile(workingDirectory + "ScreenCapture" + indexOfPicture, scaledImg);         } catch (IOException e1) {           // skip, move to the next one         } catch (AWTException e) {           // photo didn't work skip and move on.         }       }                 private Image takeScreenshot() throws AWTException {         Rectangle allScreenBounds = getAllScreenBounds();         Robot robot = new Robot();         BufferedImage img = robot.createScreenCapture(allScreenBounds);         return scaleImage(img);       }            private void storeImageToFile(String filename, Image scaledImg) throws IOException {         ImageIO.write(toBufferedImage(scaledImg), "jpg",             new File(filename + ActivityLogger.getDateTime() + ".jpg"));       }            // code from       // http://www.java-forums.org/new-java/2790-how-save-image-jpg.html       private BufferedImage toBufferedImage(Image src) {         int w = src.getWidth(null);         int h = src.getHeight(null);         int type = BufferedImage.TYPE_INT_RGB; // other options         BufferedImage dest = new BufferedImage(w, h, type);         Graphics2D g2 = dest.createGraphics();         g2.drawImage(src, 0, 0, null);         g2.dispose();         return dest;       }            private Image scaleImage(BufferedImage img) {         int scaledWidth = (int) (img.getWidth() * 0.5);         int scaledHeight = (int) (img.getHeight() * 0.5);         Image scaledImg =             img.getScaledInstance(scaledWidth, scaledHeight, BufferedImage.SCALE_AREA_AVERAGING);         return scaledImg;       }            /**        * Okay so all we have to do here is find the screen with the lowest x, the screen with the lowest        * y, the screen with the higtest value of X+ width and the screen with the highest value of        * Y+height        *         * @return A rectangle that covers the all screens that might be nearby...        */       private Rectangle getAllScreenBounds() {         Rectangle allScreenBounds = new Rectangle();         GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();         GraphicsDevice[] screens = ge.getScreenDevices();              int farx = 0;         int fary = 0;         for (GraphicsDevice screen : screens) {           Rectangle screenBounds = screen.getDefaultConfiguration().getBounds();           // finding the one corner           if (allScreenBounds.x > screenBounds.x) {             allScreenBounds.x = screenBounds.x;           }           if (allScreenBounds.y > screenBounds.y) {             allScreenBounds.y = screenBounds.y;           }           // finding the other corner           if (farx < (screenBounds.x + screenBounds.width)) {             farx = screenBounds.x + screenBounds.width;           }           if (fary < (screenBounds.y + screenBounds.height)) {             fary = screenBounds.y + screenBounds.height;           }           allScreenBounds.width = farx - allScreenBounds.x;           allScreenBounds.height = fary - allScreenBounds.y;         }         return allScreenBounds;       }            @Override       public void run() {         int indexOfPicture = 1000;         while (true) {           tryWritingScreenshotToFile(indexOfPicture++);           ActivityLogger.waitForNextSampleTime(minsBetweenScreenshots);         }       }          }      The expected behavior of the class is that it takes a full-screen (including external monitors) screenshot every five minutes... I've recently fallen in love with Test Driven Development on other projects and I've come back to this old code. But being honest - I have no idea where I would start with writing tests for it - everything is so tightly coupled to the outside world that simple tests seam impossible - is the a best-practice approach in such situations?


title: Who are the outspoken critics of Object-Oriented design?

text: Sure, object-oriented techniques are great and have stuck around for a while. I know only less than a handful of critics of the OO principles. It seems as though most non-OO designs and architectures are shunned, yet we continue to write a lot of good software in C and solve a lot of data changes via awk/sed and countless other examples. Correct tool for the correct job, yes? I'm having a hard time finding articles, presentations, or published criticisms of OO (even Fred Brooks has blessed information hiding). Are there any well-known, published and/or outspoken critics of OO?


title: Explanation of the code snippet , keyword operator in , in c++ , use of objects in classes

text: class Vector {                public:                 Vector(int s) :elem{new double[s]}, sz{s} { }                double& operator[](int i) { return elem[i]; } //function 2                int size() { return sz; }                       private:                      double∗ elem;                       int sz;               };      Code snippet from : the c++ prog. language 4th edition , Bjarne IDE : Microsoft Visual Studio Professional 2013 My experience : Newbie , have learned a little using turbo c++ before. I noticed while typing function2 that operator is a keyword(shown in blue color) , but when whole function2 is declared , _operator_ turns white , that is it doesn't remain an keyword anymore. If i try using any other name other than "operator" , an error pops up , which says Error: array of function is not allowed It would be very helpful if someone can explain what is happening in function2, I want to know all that there is about the keyword operator , why,how and when to use this.Ofcourse from a beginner's perspective. Please refrain from overly complex answers , I am complete _newbie_ I tried searching on internet , couldn't find anything else apart from operator overloading , which is not my question.               double read_and_sum(int s) {                              Vector v(s);                     //line 1                             for (int i=0; i!=v.size(); ++i)                              cin>>v[i];                        //line 3                             double sum = 0;                              for (int i=0; i!=v.size(); ++i)                              sum+=v[i];                              return sum;                             }      Here line1 passes the argument "s" of int type needed by constructor of class vector , that's fine. But in line3 how can the statement "cin>>v[i]" be valid ? , since the object v isn't declared as an array of objects. Even if it is valid where does the value go..? Basically it is out of my knowledge , please explain line3 in simplest possible manner, and at the same time as exhaustively as possible , so that I can learn. PS: Do not tell me , that i shouldn't be learning c++ , or i shouldn't be using that IDE or anything else like that. If you can , then answer the question, I shall be very thankful.


title: Design of high performance file processing web application

text: I'm trying to design a web app with ability to scale but can't wrap my heads around few concepts. I want to design it right but im not a experienced programmer, i have more of a system engineering background. Basic architecture look like this: Web Server -> File processing server -> NoSQL DB -> Search server So the main scenario is follows:   * User uploads a file via site   * File is send for processing to a server(python script)   * Results of processing is send to NoSQL DB   * Results processed by search server and returned to user We can scale web frontends via load balancing. Something like nginx+apache.   Database scaling is taking care by Cassandra or MongoDB. Search scaling is taking care by elasticsearch or sphinx clustering. Now I want to be able to add multiple file processing servers in case file uploaded is too big. So I need to somehow split file into chunks and process it simultaneously on multiple nodes plus if node goes down while working it shouldn't affect anything and data must be saved. So I need something else which will be allocating tasks to my file processing servers, balancing load and control execution of tasks. How to design custom applications for that kind of things? Should I use message queuing?


title: Generic/Dynamic objects in JSF

text: I'm starting to learn JSF and I was wondering how could I implement the following: I have an instance of Spring that contains several beans for logical and database operations, for example I have a Person bean with "name", "lastName" and "age" as attributes with operations for storing said data to a MySQL database. Now I want to add a JSF instance to the project from where I can read any appropriate bean in the Spring instance and make a CRUD of the bean's properties. All of this without creating a new bean in JSF. In detail, in JSF I want to have the following views:   * List objects (list)   * Show an object (show)   * A form for adding or editing the object (form) If I go to the URL: http: // host/person/list JSF should to make a petition for a Person bean to Spring and call the method "getAll()" from it and "dump" the result in the "list" view. That view would have logic to build a table iterating through the results and the properties of the Person object. Now, if I go to the URL: http: // host/dog/list JSF should now make a petition for a Dog bean to Spring and call the same method and dump the results into the "list" view. Of course the table displayed should be different since Dog and Person are classes with different attributes. In the URL http: // host/person/new JSF should instantiate a new Person bean from Spring. read its attributes and dump the new object to the "form" view which should iterate through its attributes and show a form with inputs for "name" "lastName" and "age". After clicking "Submit" JSF should call the "save()" method from the Spring bean, which would save the Person with the input values. Is this possible in JSF? If not, what are the alternatives that get closer to this workflow? What is the best strategy that can be followed for this kind of implementation?


title: Real time data feed, what requirements would I need to gather from the client's system interface?

text: How do I go about designing this particular application example below? For example: I have client, who would like to embed my data feed into this GUI interface. The data is made of names and and descriptions fields. If a user comes along and searches a particular name of a products using the client's interface, then the name parameter will be passed down my data feed, and it will return a search for that query name, back to the clients interface, from my database. I assume the my real-time data feed will be constructed as an API service. What requirements would I need to gather from the client's system interface? Would I need to ask them for the list of parameters they require to query through my data feed?


title: Implicit OAuth2 endpoint vs. cookies

text: I currently have an app which basically runs two halves of an API - a restful API for the web app, and a synchronisation API for the native clients (all over SSL). The web app is completely javascript based and is quite similar to the native clients anyway - except it currently does not work offline. What I'm hoping to do is merge the fragmented APIs into a single restful API. The web app currently authenticates by issuing a cookie to the client whereas the native clients work using a custom HMAC access token implementation. Obviously a public/private key scenario for a javascript app is a little pointless. I think the best solution would be to create an OAuth2 endpoint on the API (like Instagram, for example http://instagram.com/developer/authentication/) which is used by both the native apps and the web app. My question is, in terms of security how does an implicit OAuth2 flow compare (storing the access token in local storage) to "secure" cookies? Presumably although SSL solves man in the middle attacks, the user could theoretically grab the access token from local storage and copy it to another machine?


title: If you learned formal methods for software, how useful have you found it?

text: If you have been trained in the use of formal methods (FM) for programming:   * How useful have you found it?    * What did your FM training involve (e.g. a course, a book)?    * What FM tools do you use?    * What advantages in speed/quality has it given you compared to not using FM?    * What kind of software do you create with FM?    * **And if you don't directly use FM now, was it at least worth learning??** I'm curious to hear as many experiences/opinions on FM as can be found in this community; I'm starting to read up on it and want to know more. ## Background Programming and software development/engineering are some of the newest human skills/professions on Earth, so not surprisingly, the field is immature — that shows in our field's main output, as code that is typically late and error- prone. Industry immaturity is also shown by the wide margin (at least 10:1) in productivity between average and top coders. Such dismal facts are well covered in the literature, and introduced by books like Steve McConnell's Code Complete. The use of formal methods (FM) has been proposed by major figures in software/CS (e.g. the late E. Dijkstra) to address (one of) the root causes of errors: the lack of mathematical rigour in programming. Dijkstra, for instance, advocated for students developing a program and its proof together. FM seems to be much more prevalent in CS curricula in Europe compared to the US. But in the past few years, new "lightweight" FM approaches and tools like Alloy have attracted some attention. Still, FM is far from common usage in industry, and I'm hoping for some feedback here on why. ## Update As of now (10/14/2010), of the 6 answers below, no one has clearly argued for the usage of FM in "real world" work. I'm really curious if someone can and will; or perhaps FM really does illustrate the divide between academia (FM is the future!) and industry (FM is mostly useless).