To be strict or pragmatic?

I'm beginning to realize that developing software is (amongst others) a process of constantly asking yourself questions. Questions regarding quality of code, separation of concerns, minimizing dependencies, ... But the main question is: how far can you go without ending up in a mental hospital? I'm applying for a new job. Yesterday I was with a possible future employer who wanted to test my programming capablities. One of the exercises was: explain what this code does. I went through some code of the application (winforms in vb.net) that they develop (it's an administrative application for a hospital). This gave me the opportunity to actually see how they approach things and it was rather disappointing. Some examples:   * I saw somewhere: Call [insert name of subroutine here] -> I was struck: isn't that something from VB6?   * They have a separate datalayer, using ado.net, but one method I had to examine returns a dataset to the calling layer. So separate datalayer or not, the application is tied to ado.net (which could also never be a problem if they never switch to another data access approach).   * That dataset is read as-is, so it still is a data-centric approach (of course, one can argue how much logic/behaviour you can put in classes like "Patient" or "LabAnalysisRequest".   * I also believe to have seen the construction of an sql query by string concatenation.   * They use stored procedures (which, to me, means: scattering of logic)   * no mention of views/controllers: it's all form driven   * The most ugly thing I saw was:                   If TestEnvironment.IsTesting then            someVar = [some hard coded value]         else            someVar = [some dynamically retrieved value]         end if         [remainder of the function here]      It's all so different from what I learned in school: (persistence agnostic) domain layer, persistence layer, presentation layer, unit testing, ... So I rephrase my question: how fundamental or dogmatic should one be? To what extent should a programmer stick to his or her principles or just write code that does the job?


What to do when your work colleague doesn't understand the design trying to be maintained

A software project that I am working on involves me and another programmer. The project involved an engine backend with an MVC front end. Initially I did alot of the work on the project and so setup some simple design methodologies mainly surrounding abstraction and template strategy. For quite a while I have been off the engine backend and working on the website. However I have still maintained an interest in the engine as I was informed that I might be back on it at some point. The project is under a very tight deadline so we are all rushing like made to get it finished on both the front end and back end. I don't consider myself to be a great programmer and so I never try and enforce any particular design or set of methodologies on people as I'm not always sure I'm right and like to have other people offer their opinions to try and come up with better solutions. However I have noticed changes being made to this engine code that is really starting to irk me. When I confronted the developer to suggest he do the work another way he said he didn't see the point as there seemed little benefit considering the tight deadlines. I had to try and explain that the haack he had put in could mean further development after release and I didn't think it was fair to make others pick up the slack when we could fix it now. I spent about 30mins going through what I had done and at the end of it he asked me to pretty much write the code so he could just copy it. The basis of what was I had initialy setup was:   * An abstract class x   * An abstract factory class to create concrete instances of x What had happened was he had put a couple of if statements that could easily have been put as virtual/abstrace methods on the abstract class and then implemented accordingly as the new change followed the same principle of other methods on the abstract class already. This seems trivial to me, however he couldn't even grasp this even when I showed him the classes involved. Now my question is:   1. Is this unfair to assume he should have grasped this concept. I realise that we are on tight deadlines but I thought it was trivial. The programmer is supposed to be at least an intermediate level.   2. This has happened in a number of places and I have constantly tried to get him to change but he doesn't seem to. Should I just ignore it?   3. Should I raise this issue elsewhere, or just suck it and when I'm put back on the project just go around changing all these things. His part of the project is not going to be finished which is why I will have to go back on and help him out. I really don't want too, as he has taken a project with not great, but ok architecture and really put in alot of messy code that more than often didn't follow what was trying to be achieved. If the question is too vague or ranty, please let me know and I'll try and edit accordingly. EDITED: The project is expected to continue after the initial deadline as there is already follow up work planned and work that we did not fit in and has been agreed to be implemented later.


How to visually document interactive user interfaces for fast consumption

I'm writing documentation for some interactive Ajax user interface but instead of writing everything in words I would rather provide diagrams that are faster consumed than whole paragraphs of text. I did provide page navigation flow diagram but that's very high level before you drill down to individual pages and their inner workings. ## Example Suppose I have to document a typical search panel:   * is collapsed by default and can be expanded on click   * has basic search fields that provide basic search criteria over my model entity   * has advanced fields as well that show when one clicks a particular link which expands search with additional fields   * has two actions Search and Reset that are pretty much self explanatory, but have particular behaviours attached to them I know you will say that this already is documentation, but it's usually not this simple and trivial. Search panel is just an example. I can see that most of my interfaces (or interface components) need two types of documentation:   1. **properties** related to contained controls (i.e. drop down field with these and those values of which that particular one is selected by default)   2. **actions and behaviours** that describe what happens when user interacts with controls related to those properties ### What would be the best diagram or documentation format to describe these kind of interactive interfaces so that it's easy and quick to consume by implementers?


do asp.net mvc tools let you make sites faster than php frameworks

I generally use cakephp but after watching some MS videos of MVC3 it seemed to go fairly quick. I understand the intellisens in VS2010 works classes and for databases. It seems like once you know the editor and framework basics this would be very handy. My question is, do things like intellisense actually speed things up noticeably?


Too much to learn, dealing with overwhelming varieties of technologies

I am about to graduate, and I am already working as a web developer in our library IT department. When I look at job postings I am absolutely overwhelmed by the sheer variety of technologies out there. Some companies care about math + algorithms + data structures. Some care about experiences in technology stack XYZ. SQL, css, html, frameworks, javascript, design patterns etc.. etc... etc... At some point I realized I just need to start at mastering a foundation to become employable at a better place and go from there. But the skill-set to get me in the doors varies and I just don't have time to learn everything. How do you deal with this issue? What is the essential stack to become employable? Say in php or ror arena. Perhaps a smarter move would be to move to a technology stack with less variety like .net?


Should I pay my developers for bugs fixes for a project or work that's still in progress?

We are working with a group of developers on a project. The project is still in progress (not completed) and these developers charge us for time spent on fixing bugs on codes that were not written valid in the first place. I understand that we should pay for changes/new requests if any, but not bugs fixes for a work in progress. We also understand that once the assignment is being deployed to the live site, we may be liable for bugs fixes that may arise after a support period is being exhausted. The question now is, is it appropriate for such charges to be levied upon us while the project is still in progress?


How can I correct html for missing closing tags in c# ?

I have html stored in database received from text editors and because of some mistakes in the code the html is not valid, it is missing some closing tags. and due to this I am not able to process this html for some other operations like generating pdfs. So I need to write some code in c# that can check for tags that are missing closing tags and insert a closing tag at the correct place.


Is this RabbitMQ / sockjs pub/sub connection setup a comet solution?

My company is attempting to set up a pub/sub connection using RabbitMQ and sockjs, on Windows servers. I have two questions:   1. My supervisor is calling this setup a comet solution, I was wondering if that is the right terminology?   2. Is there a better solution stack for having a data server asynchronously ship data to a client without the client requesting data (besides the initial subscription)?


Can all code be represented as a series of Map / Filter / Reduce operations?

I have recently been refactoring large chunks of code and replacing them with Linq queries. Removing the language bias - Linq is essentially a set of Map / Filter and Reduce operations that operate on a sequence of data. This got me thinking, how far would I theoretically be able to take this. Would I be able to rewrite the whole code base into a series (or even a single) of Map / Filter and Reduce operations. Unfortunately I get paid to do useful stuff, so I haven't been able to experiment much further, but I can't think of any code structure that couldn't be re structured as such. Side effected code can be dealt with via monads.. Even output is essentially mapping memory addresses to screen addresses. Is there anything that couldn't be (theoretically) rewritten as a Linq query?


Windows Azure vs Amazon EC2 vs Google App Engine

From a developer point of view which platform would you consider for a large social web application? If you could provide some details on what you consider to be the strengths of which alternative it would be great.


MVVM, DDD, and WPF Layered Application Project Structure Guidance

I am trying to setup my application's structure in VS and I want to "try" and future proof it to a reasonable level. This application will be a WPF re-write of an old Winform app that had followed no conventions. No Layers, Tiers, Acronyms, etc... It is a fairly largish Enterprise Application. I planned to use Linq To SQL as my DB's are and will most likely always be MS SQL. Also I have an existing skill set with it. I want to follow MVVM and DDD the best I can but I get confused on the structure of my application when combining these. Let me try and illustrate with some examples. When I follow MVVM my folder structure may look like this:               Views     Models     ViewModels     Helpers      but how does that fit into a simplistic DDD layered approach where my Project Structure might resemble this:               MyApp.UI     MyApp.Domain     MyApp.Data      Do I put the `Models` in the Domain layer or do I have 3 versions of say `Person`? This leads to another question of where would I put my Repository and mappings of DB Object to Domain Object? I would assume Data... `Views` I get would go in UI but would `ViewModels` also? Finally, where would I be embedding my Business Logic? I found the following on CodePlex,DDD Example ,and it has been some help but seems to be for a Web App though that may not matter and is my ignorance shining through. Don't get me wrong, I know I can have as many folders and call them whatever I want. I am trying to figure out where to place things so that this will be scale-able, not what those places necessarily are called. The heart of my question might be shown like this.   I have `tblPerson` object generated by `*.dbml`. This is obvious and would belong in my "Data" layer.   Now I would have Model, DTO, Domain Model, or whatever it's called in a seperate Layer(project?) called `Person`. I would need a `Mapper` for `Person` to `tblPerson` that I'm not sure where to put.   Then, I'll have a ViewModel for, say, `EditPerson` that would have it's own properties that it pulls from `Person` but possibly more as well.   Finally I'd have a View that was bound to that ViewModel.... To be clear that paragraph is FILLED with my assumptions and guesses and I am hoping someone will help clear the air for me or offer there insights so that 6 months to a year from now I am not kicking myself more than I need to.


Safest way (i.e. HTTPS, POST, PGP) to send decryption keys through the web?

I am in the final stages of development for my Revit plugin. This plugin is programmed in C#, and distributed via a DLL. One of the DLLs is an encrypted SQLite database (with proprietary data) that is in the form of a DLL. Currently, in development stages, the decryption key for the SQLite database is hardcoded in my main DLL (the program's DLL). For distribution, since DLLs are easily decompilable, I am in need of a new method to decrypt the DLL. My solution is to send our decryption keys from our servers securely to the host's computer. I was looking in POST, thinking it was more secure than GET, but upon research, it appears it's similarly insecure, only more "obscure" than GET. I also looked into HTTPS, but Hostgator requires extra money for HTTPS use. I am in need of some advice - are there any custom solutions I can do to implement this?


How can I be most productive in Visual Studio when limited to small screen space?

I'm a student, and I do a lot of code on a small (12.5", 1366x768) laptop screen that I carry from class to class. Most programming environments are designed with the idea that someone has large screen size available, because most programmers do in fact have access to large screens. However, large screens are difficult to carry to class all day, and my previous laptop (15", 1920x1200) often got left in the dorm just because it was so friggin heavy. I'm pretty much locked in to Visual Studio at this point; no program I've ever used is as productive for the kind of code I work with (after installing Whole Tomato's Visual Assist and Jared Par's VsVim, of course :) ) (I've seen other questions about small screens but they all pretty much go with "leave Visual Studio" -- which is hard given some of the kinds of development I've been doing....


Considerations for accepting contributed code to an Open Source project

I’m working on a "for fun" project in my spare time. I may end up making it Open Source and this makes me wonder what I need to think about if someone cares enough to contribute to it.   * Do I need to have some sort of legal mumbo jumbo about “if you give me yer code, it accepts the same license as the project, bla bla bla” (what is the norm here?)    * Is there a way to check contributed code to make sure it is not plagiarized or would that liability fall on the contributer?    * Are there any other gotchas, standard/common practices I should follow, recommendations, things I need to think about?


Mercurial release management. Rejecting changes that fail testing

Researching distributed source control management (specifically mercurial). My question is more or less **what is the best practice for rejecting entire sets of code that fail testing?** **Example:** A team is working on a hello world program. They have testers and a scheduled release coming up with specific features planned.               Upcoming Release:        Add feature A        Add feature B        Add feature C      So, the developers make their clones for their features, do the work and merge them into a QA repo for the testers to scrutinize. Let's say the testers report back that "Feature B is incomplete and in fact dangerous", and they would like to retest A and C. ![Repo Doodle](http://i.stack.imgur.com/DteiT.png) **End example.** What's the best way to do all this so that feature B can easily be removed and you end up with a new repo that contains only feature A and C merged together? Recreate the test repo? Back out B? Other magic?


Ergonomics of Apple keyboard for long programming hours

I am programming with an apple keyboard (the one all aluminium with flat keys). it's quite some time I observed I occasionally mistype, and I feel pain in my hands. Is it the keyboard's fault, or am I just getting old ? Does any of you have experience with hours of programming with the apple keyboard ?


How do OSes work on multiple CPUs?

Assumption: "OS es (atleast in some part) should be written in assembly.Assembly programs are CPU specefic." If so how can one os run on different CPUs ? For example: how is that I can load Ubuntu on different systems having different CPUs (like intel i3,i5,i7, amd a8,a6,etc) from the same bootable disk?   1. Does the disk contain seporate assembly programs for each CPU?   2. Are these CPUs 'similar' enough to run the same assembly program?   3. Is my assumption wrong?   4. Something else.... Thanks for responding.   1. I tried to find out in what way are the CPUs that I mentioned 'similar'. I came across the concepts of Instruction Set Architecture and Microarchitecture of CPUs.A CPU will understand a program if it is combatible with its ISA. Even if CPUs are 'wired up' differently (different microarchitecture) , as long as the ISA implemented on top is same ,the program will work. ARM and x86 have different ISA ( that why there are 2 windows 8 versions, right?). And if an app program is written in an HLL with compilers for both platforms we will saved from wasting time writing 2 programs. Did I understand anything wrong?   2. Are there programs that can take a compiled program as input and produce a program executable on another CPU as output? Is it possible? (Virtualisation?)   3. 32 bit windows programs do install on 64 bit windows ,dont they? Arent 64 bit CPUs 'differerent' from 32 bit CPUs? They do get seporate OS versions, right?   4. Is this backward combatibility achieved using programes mentioned in (3) ?


Are multi-line comments a critical facility in a modern language?

I'm trying to convince the designers of a language that multi-line comments with an arbitrary start and end are important, and should be included. Currently there is only a "comment-to-end-of-line" primitive. Their line of argumentation reminds me of what some say about why you should use spaces instead of tabs. Basically that editor features can pick up the slack and remove the requirement for a different construct. _(So if you wanted to comment out more than one line, you'd select what you wanted and run a macro of some kind...to add or remove a to-end-of-line comment to each line. I just read thatthis feature exists in Visual Studio, despite C/C++ offering a multiline comment.)_ Other suggestions about removing blocks of code from execution wind up being things like "cut the code out, try it, and use the redo queue". I think this is not a very easy way to keep track of "invisible" information you might want back, and redo queues are quick to lose information the moment you hit even a stray key on accident. So this does not sway me. I can live with the space vs. tab thing and putting that on the editor, and it's now pervasive. But to me this is different, and I'm dissatisfied with these answers. For me, being able to comment out code with just a start and end marker like `/*` and `*/` is extremely useful. Passing the buck to editor magic doesn't let you position your starts and ends arbitrarily _(how would you comment out the middle of a line if all you had was`//`?)_ And I also don't like leaning that much on editor features. Sorry to ask a question with overtones of an opinion poll, or about something subjective. But what I'm looking for are any more objective arguments I am not thinking of, which could provide more ammunition backing this feature I think is important. _(Or I guess I could accept a powerful argument favoring NOT having a multi-line comment format, which overrides my strong desire to have it... I'm not putting high odds on that, though.)_


Thoughts on refactoring a generic DAO

I have designed a generic DAO in Java and am having confusion about whether to refactor it to different design or not. **PS** Don't say to use already existing 3rd person framework. I know there are some present but I am learning Java and design patterns so I need all the practice I can get. If there's any confusion then please ask and I'll clarify. **The current Architecture** * * * **DAOFactory.java**   * Contains the `abstract` methods for creation of `DAODelete`, `DAOUpdate` and 2 other interfaces to be implemented by concrete implementation classes   * `public` Class method for creating the concrete Factories for producing the concrete implementaton of the interfaces mentioned before. **DAORead.java**               public abstract <T> T getPojoForPrimarKey(Connection con,             TableName tableName, String primaryKey) throws SQLException;      Similarly in my other interfaces I have generic methods.   * Here `Connection` is passed by the service layer and closed there for transaction management.    * `TableName` is a enum that I am using to have a switch case in lower layer of DAO for calling Table Specific functions. Also using an enum is helping me in type checking. **OracleRead.java**               @Override         public <T> T getPojoForPrimarKey(Connection con, TableName tableName,                 String primaryKey) throws SQLException {             T currentPojo = null;             PreparedStatement ps = null;             ResultSet rs = null;             try {                 String queryString = OracleSpecifics.queryString(tableName,                         primaryKey, QueryType.READ);                 ps = con.prepareStatement(queryString);                 rs = ps.executeQuery();                 if (rs.next()) {                     currentPojo = OracleSpecifics.getPojoFromResultSet(tableName, rs);                 }             } finally {                 DAOFactory.closeAll(ps, rs);             }             return currentPojo;         }      This is how I have implemented the `deleteFrom` function from the interface in concrete class. Here `OracleSpecifics` is the lower layer of DAO that I was talking about. It basically contains `switch` cases to check for specific Table. **OracleSpecifics.java**               // These functions call table-specific functions         @SuppressWarnings("unchecked")         static <T> T getPojoFromResultSet(TableName tableName, ResultSet rs)                 throws SQLException {                  switch (tableName) {             case ASEEM_MASTER:             case ASEEM_MASTER_TEMP:                 return (T) SpecAseemMaster.getPojo(rs);             case AUTHENTICATE_TABLE:                 return (T) SpecAseemRole.getPojo(rs);             default:                 return null;             }         }      Here `SpecAseemMaster` and `SpecAseemRole` are Table Specific (specifically schema specific) layer producing the required fields **SpecAseemRole.java**               public static AuthenticationDetails getPojo(ResultSet rs)                 throws SQLException {             AuthenticationDetails cur = new AuthenticationDetails();             cur.setUserName(rs.getString(1));             cur.setPassWord(rs.getString(2));             cur.setRole(rs.getString(3));             return cur;         }      * * * **In service layer** The type by which the DAO's method is called is the Pojo representing the schema's data fields. e.g.               myFactory.getDAORead().<AuthenticationDetails> getPojoForPrimarKey(con, CUR_TABLE, primaryKey);      Here `AuthenticationDetails` is my Pojo aka DTO for communicating between my Controller and service layer (in Model). * * * **Please Note** that I am giving just a overview in the simplest way. There are 4 interfaces in the abstract DAOs containing total of 8 `abstract` methods implemented by 4 concrete classes. All these generic classes depend on a lower layer in DAO for getting specific queries, `PreparedStatement`s etc. which further calls functions in auxiliary utility class's functions depending on the `tableName` passed down this hierarchy. The bottom layer is schema- specific. **My Confusion about refactoring**   * I am satisfied with the upper layers of DAO but I think that at the the lower level specifically at the `OracleSpecific` the things which should have strong coupling has weak coupling. e.g. there are different methods for getting `PreparedStatement` for insert and update. Each of these in turn have `switch` case for calling the functions in lower utility class.    * **Although** the `schema-specific` methods are tied together in different utility classes the method call themselves in `OracleSpecifics.java` do not have any coupling.   * I am thinking whether I should change the enum `TableName` to contain a _specific state_. The state I am thinking for the schema-specific lowest level utility classes.   * These `specific states` contained in enums can be used to change the state of DAO and the DAO can then call the specific functions based on an interface implemented by all such states. Thus depending on the state the behavior can change automatically.   * Is this design decision correct or would it be meaningless?   * Any other thing that I might have overlooked?    * Any thoughts about the design itself?   * Would I lose type safety introduced by generics due to this change?


What is a web API? (Application Programming Interface)

What is a web Application Programming Interface? Many common sites provide APIs. Why are they needed, and what function do they provide? How does one access a web API?


Best way to re-platform MS access application to java application

I have a requirement where MS Access application needs to be re-platformed to java application.The MS access app has about 45,000 records and 53 columns with SQL connectivity.These record data need to be edited,data used to send email with pdf report attachment.Report is designed using SQL reporting services.I need to create UI to call the reporting service and generate reports.The customer wants all the 45000 records to be loaded in the single stretch in the datatable. Can anyone please suggest which is the best way to mimic this in java.Do i need to go with swing app or a web app.


How to TDD test that objects are being added to a collection if the collection is private?

Assume that I planned to write a class that worked something like this:               public class GameCharacter {         private Collection<CharacterEffect> _collection;              public void Add(CharacterEffect e) { ... }         public void Remove(CharacterEffect e) { ... }         public void Contains(CharacterEffect e) { ... }     }      When added an effect does something to the character and is then added to the _collection. When it is removed the effect reverts the change to the character and is removed from the _collection. **It's easy to test if the effect was applied to the character, but how do I test that the effect was added to _collection?** What test could I write to start constructing this class. I could write a test where _Contains_ would return true for a certain effect being in _collection, but I can't arrange a case where that function would return true because I haven't implemented the _Add_ method that is needed to place things in _collection. Ok, so since _Contains_ is dependent on having _Add_ working, then why don't I try to create _Add_ first. Well for my first test I need to try and figure out if the effect was added to the _collection. How would I do that? The only way to see if an effect is in _collection is with the _Contains_ function. The only way that I could think to test this would be to use a _FakeCollection_ that Mocks the Add, Remove, and Contains of a real collection, but I don't want _collection being affected by outside sources. I don't want to add a _setEffects(Collection effects)_ function, because I do not want the class to have that functionality. The one thing that I am thinking could work is this:               public class GameCharacter<C extends Collection> {         private Collection<CharacterEffect> _collection;              public GameCharacter() {             _collection = new C<CharacterEffect>();         }     }      But, that is just silly making me declare what some private data structures type is on every declaration of the character. **Is there a way for me to test this without breaking TDD principles while still allowing me to keep my collection private?**


Sending files via HTTP to web service

I am bit frustrated at the lack of information about this online. Here is the issue: I am in charge of creating a iOS application which sends sound data back and forth between the server and the app. The Audio is in small files and thus does not need to be streamed over, but rather it can be sent. Right now, I am using a TCP server I wrote to handle applications like this. However, I want to keep the system as simple as possible and writing your own server and client sockets can get a bit complex and leaves room for crashes. Overall it slows down development because I need to account for packet structure and other things. My question is, can I write an ASPX or PHP web service that lets me pass the files back and forth through GET or POST?


Practical Primes In P

Or rather, practically _applying_ PRIMES in P. I've heard a lot about "PRIMES in P", or the "AKS algorithm". It is, to oversimplify slightly, a very fast way of finding prime numbers. However, while I've tried reading the original paper (the revised "V3" seems to have vanished from the internet), it's a bit above my comprehension. I've also tried using Google to find practical implementations of the algorithm, but they too are incomprehensible (which is to say, they're all written in comment-free C++). Can someone produce a hobbyist/freshman-level explanation of how to implement the AKS algorithm? Or am I misinterpreting exactly what it it does and is for?


Entity Framework - Loading Related Entities Explicitly

I have been using Entity Framework for a few years. I have flip-flopped between calling out to repositories in my business logic or using lazy loading to retrieve data as I work my way through the code. The problem with the first approach is that a single business object can end up relying on a lot of repositories (in the case of repository per table). The resulting logic is heavily mixed with calls out to the data layer, which makes it harder to test (lots of mocks). The problem with the second approach is that lazy loading leads to surprises sometimes. Novices call out to the database within loops without realizing it. Even using `Include` requires a lot of care. Too many `Include`s and the generated query can be very slow. So I was getting a little frustrated. A few weeks ago, I discovered the newer `DbEntityEntry<TEntity>` classes in Entity Framework. This allowed me to load related entities explicitly and check if they were already loaded. This led to a hybrid approach where I pass a single root object and a "loader" class. Before accessing a navigation property, I would ask the loader to load it. If the object was already loaded, it would just do nothing. Since it didn't cost anything, I just called it every time I referenced a navigation property. I have added this class to an existing open source project for anyone wanting to see it: https://github.com/jehugaleahsa/TestMvcApplication/blob/master/DataModeling/EntityLoader.cs. A co-worker pointed out this class really only solved some problems. Just like lazy-loading, it meant either using `Include`s or dealing with multiple database hits within a loop. Then the other day I had another idea: I could grab the related entities for a collection of entities. For instance, getting all of the roles for a list of users. This way, I can grab the all of the related entities in a single database hit outside of a loop. I ended up with this class: https://github.com/jehugaleahsa/TestMvcApplication/blob/master/DataModeling/EntityCollectionLoader.cs. This class dynamically builds a query based on the entities. Under the hood, it builds a join that filters the related entities by the main entities' primary keys. Both loader classes provide methods that return an `IQueryable<TRelated>` to allow for further filtering, sorting, etc. The problem with these methods is that it is impossible to know whether the related entities have already been loaded, so they always result in a database hit. This is still useful for doing multiple `Include`s in a single query. My business objects now just accept a loader factory in their constructors. The business object method getting called just takes the top-level object(s). So, I really only have a single dependency on my data layer. This dependency is hidden behind an interface. I am wondering what the drawbacks are to this approach. It still mixes calls to the data layer object, throughout, except now I can navigate to the results from the top-level object's navigation properties. Plus it is a single dependency that is easily mocked out (everything becomes a no-op). It can be used right along with lazy-loading so it won't be a disaster if you forget to call `Load` first. At first I was concerned that I would be building queries in my business layer, but I realized I was just saying `Load(u => u.Role)` and then immediately accessing `user.Role`. The loader class and Entity Framework are dealing with how to populate the navigation property. Am I missing something? This seems like a really awesome compromise between pure lazy-loading and eager-loading.


Moving between sites using SAML

I'm tasked with developing an SSO system, and was guided towards using the SAML spec. After some research I think understand the interaction between a Service Provider and an ID Provider and how a user's identity is confirmed. But what happens when I redirect the user to **another** Service Provider? How do I ascertain the user's identity there? Do I send his SAML assertion tokens along with the redirect request? Or does the second Service Provider need to contact the ID Provider all over again?


What language is better for working with databases?

I am going to develop a software that works with different databases and I'm considering whether to use .NET languages or C++. I've known that .NET features LINQ and ADO.NET but are there features like that in the native C++? Which one works better, faster with databases?


Why are structs/arrays zero based?

How was it decided that if you have an array/struct or anything similiar in a programming language it should be zero-based? Wouldn't it have been easier if it was 1-based. Afer all, when we are taught to count, we start with one.


How would a new language look if it was designed from scratch to be easy to TDD?

With the some most common languages (Java, C#, Java, etc) it sometimes seems that you are working at odds with the language when you want to fully TDD your code. For example, in Java and C# you will want to mock any dependencies of your classes and most mocking frameworks will recommend that you mock interfaces not classes. This often means that you have many interfaces with a single implementation (this effect is even more noticeable because TDD will force you to write a larger number of smaller classes). Solutions that let you mock concrete classes properly do things like alter the compiler or override class loaders etc, which is pretty nasty. So what would a language look like if it was designed from scratch to be great to TDD with? Possibly some way language level way of describing dependencies (rather than passing interfaces to a constructor) and being able to separate the interface of a class without doing so explicitly?


Automated Testing Using Virtual Machines

I am working on making a system for the automated testing of student assignments. The biggest hurdle I am facing right now is figuring out how to sandbox the testing of the code yet still get and process the results of the test. I need to run it on a VM as there is no guarantee the code will not be malicious. I would like to have a process similar to the following:   1. Student submits assignment   2. VM is created and is given the source code submitted by the student   3. VM runs the tests on the source code   4. VM returns results of the test back to the host operating system   5. Results are processed Steps 2 and 4 are the ones I am looking for a good solution for. I am not sure what would be a good way automate the passing of files to the VM and the passing of results back from the VM. It seems like this is a problem that might have a solution already and I would rather not reinvent the wheel.


How can I ensure a portion of my project's code remains in all derivative works?

I had an idea for a website. After much coding and thinking out the idea, I've got it to a decent stage. If I were someone else, potentially a more commercially-minded person, I might want to sell it, or slather it with ads. However, I've fallen somewhat in love with open-source, and I'd like to host the project on GitHub and give it a nice open-source license. However, the project seems to be getting better all the time and, in fact, I think that it'll quickly grow to be fairly popular. So I want to put ads on it that benefit charity. How can I ensure that one small text advertisement benefiting charity remains in all derivative works? Are there any licenses that would let me do this? p.s. My other requirement for a license is that it gives me attribution (in the same form as the MIT license would be fine) [EDIT] I've decided to just let it be Apache licensed. I'm hoping that people will just leave charity-benefiting ads in.


Why are there proxy processes between clients and logic processes in C/S application?

In real world networking software following c/s model, there are always proxy server processes between clients and server processes dealing with business logic, why we need proxy to isolate the logic part and clients? What's the benifit of this architecture?


How to render RSS feed in a desktop RSS reader?

Consider one feed like this: http://feeds.feedburner.com/codinghorror It has the entire content inside the description tag of the feed, so you don't need to access the website to read the post. Now I have the problem of creating an interface for a feed like this on a desktop client. What's the best way to render the text in a pleasant way to the user? My first thought was to parse the entire HTML as if I was a web browser, but that looks really hard to do in a satisfying way. Are there any better (faster) alternatives? Rephrasing: how a desktop rss client such as feeddamon parses the input to display it nicely? Does it have a web browser inside it?


UML: Going from Use Case to Class Diagram

In simple steps how can one make the transition from a Use Case diagram to a Class diagram?


What happens between sprints?

I'm working on a project loosely following the scrum model. We're doing two week sprints. Something I'm not clear on (and don't have a book to consult) is exactly what is supposed to happen between sprints: there should be some "wrap" process, where the product gets built and delivered, but:   * how long does this typically take?   * should the whole team be involved?   * does it strictly have to finish before developers start working on the next sprint items?   * is this when code review and testing take place? There are three developers, adding up to about 1 FTE. So the sprints are indeed very short.


Program to verify all words in a crossword puzzle are valid

I have my own solution and wanted to check it against something online but couldn't find any examples. How would you solve this one. (I can post my code if necessary). I just want to see if someone has a better approach that I didn't think of or if my code misses any edge cases. This is for practice for a programming interview. I've written it in Java so I'd prefer to see other code in Java but any language would be fine- or even just an english explanation of what you'd do if you don't want to actually code it (but I'd prefer code since you might not realize certain things that you'd realize once you started coding). The grid is represented by a 2d array.


Working on someone else's code

I have hardly a year's experience in coding. After I started working, most of the time I would be working on someone else's code, either adding new features over the existing ones or modifying the existing features. The guy who has written the actual code doesn't work in my company any more. I am having a hard time understanding his code and doing my tasks. Whenever I tried modifying the code, I have in some way messed with the working features. What all should I keep in mind, while working over someone else's code?


Longest subsequence without string

Does there exist a dynamic programming algorithm to find the longest subsequence in a string X that does not contain Y as substring? Just that this problem seems so similar to other DP string algorithms such as longest common subsequence and string. It must be able to handle occurrences of Y that overlap. It seems that this might be a 2-state DP problem, with the state [s_pos, t_pos] being the longest subsequence of string S starting at s_pos that does not have sting T[t_pos..M] as a substring. N is the length of string S and M is the length of string T. However, my transitions are not correct: it does not get the case where S=`aaabc` and T=`aabc`. The problem is in the _else_ statement - I don't know how to transition if the characters are equal. **Actually I feel that the if branch is wrong... anyone know what could be wrong?** It even fails the case S=`aaab` and T=`aab`. I can explain why it fails: assuming I call solve(0, 0). solve(0, 0) calls solve(1, 1). solve(1, 1) calls solve(2, 2). Since s[2] != t[2], it restarts the search from solve(3, 0). However, aab is a substring and it never checks this or considers this case...               int solve(int s_pos, int t_pos)     {         if (s_pos >= N || t_pos >= M) return 0;         if (t_pos == M - 1 && s[s_pos] == t[t_pos]) return 0;         int ret = 0;         if (s[s_pos] != t[t_pos])         {             int tmp = solve(s_pos + 1, 0);             ret = max(ret, tmp + 1);         }         else         {             for (int i = s_pos + 1; i < N; i++)             {                 int tmp = solve(i, t_pos + 1);                 if (tmp != 0)                 {                     ret = max(ret, 1 + tmp);                 }             }         }         return ret;     }


How do I inject test objects when the real objects are created dynamically?

I want to make a class testable using dependency injection. But the class creates multiple objects at runtime, and passes different values to their constructor. Here's a simplified example:               public abstract class Validator {         private ErrorList errors;              public abstract void validate();              public void addError(String text) {             errors.add(                 new ValidationError(text));         }              public int getNumErrors() {             return errors.count()         }     }          public class AgeValidator extends Validator {         public void validate() {             addError("first name invalid");             addError("last name invalid");         }     }      (There are many other subclasses of Validator.) What's the best way to change this, so I can inject a fake object instead of ValidationError? I can create an AbstractValidationErrorFactory, and inject the factory instead. This would work, but it seems like I'll end up creating tons of little factories and factory interfaces, for every dependency of this sort. Is there a better way?


Search substring using suffix array (and LCP)

I'm searching for a best way to improve suffix array run time using LCP. My text (about 2 500 000 chars) seems like: 0ricco0eric0america0polo0.... My thoughs:               SA=suffixArray     char=firstChar(input)     s = suffix array index of a first value char           currentWord is area (string) in the text from 0 to next 0 where the substring is found, hence: for founded substring icco would be currentWord ricco          repeat         if pattern in text[SA[s]:SA[s]+len(input)]             break         s+=1     results.append(currentWord)          repeat         if lcp[s]>=len(input)             results.append(currentWord)             s+=1         else:              break      Is this a correct way? Or could you give me an advice how it should be?


How to learn from open source

I see this problem quite often. I like a certain value proposition of an open- source project. I try out the basic tutorials. Great. It works! But if I move on to more complex problems, I spend hours of doing research, debugging, frustrations, etc. What are your strategies to keep motivation in open-source going? What is the reward of open-source after success of basic tutorials? What "success" of open-source did you experience?


How to protect intellectual property when oursourcing software development?

I'm a small company needing to outsource software development. I've written both functional and technical specifications for GUI developers and back-end (C or PHP) developers to implement my software application. I'm a little nervous handing over copies of these documents to request bids from numerous companies. Looking for recommendations to protect my work while outsourcing. What's the conventional wisdom? Is there generic NDA someone could send me a link to. How do others handle this situation. What would the outsource companies expect, or not expect, from me?


Why is + so bad for concatenation?

Everybody keeps saying that one of JavaScript's problems is using `+` [example] for string concatenation. Some say the problem is not using `+`, it's type coercion [see the comments from the previous example]. But strongly- typed languages use + for concatenation and coerce types without any problem. For example, in C#:               int number = 1;     MyObject obj = new MyObject();          var result = "Hello" + number + obj;     // is equivalent to     string result = "hello" + number.ToString() + obj.ToString();      So why is it that string concatenation in JavaScript is such a big problem?


New sequential testing framework with the same rigor as xUnit?

Looking for books (published or upcoming) and frameworks (preferably free/open-source) for sequential tests. My understanding of sequential tests is that it is very similar to a Workflow System, with the following elements:   * A collection of Setup/Exercise/Verify routine-sets (suites) - same as in xUnit      * Optionally, a routine-set may also contain:        * Teardown - which marks the end of the sequential test, after which the entire software state will be unrolled to the beginning.       * Undo - which rolls back just a single operation, back to before the "Setup" of the current routine-set.       * If a programmer provides an Undo, the programmer vouches for the correctness of that Unfo. (Assertions can be used, though it is best not to use any unreliable Undo.) If programmer is not certain, don't provide an Undo.   * Each routine-set must _either_ provide a StartUp, or one or more "preceding step(s)" - the new part for sequential tests      * A StartUp basically re-initializes the entire software state in a guaranteed way.     * The "preceding steps" are references to other routine-sets.   * **Unlike unit testing, sequential tests are allowed to pass on objects to the next step, in a carefully-controlled way.** **Example:**   * Routine A      * Create an empty "readme.txt". (stop the test if it already exist; preconditions not met.)     * Verify "readme.txt" exists.     * Undo function: Delete "readme.txt" if it exists.    * Routine B,      * `follows` routine A     * Open file "readme.txt" for writing (erase previous content) *  Related: Are scenario tests groups of sequential unit tests? * * * Dear all, sorry the question was lost in the midst of an unexpected machine failure; so this was recovered from a previous autosave draft. Since that crash I had extended the idea a little bit, and I'll need several days to clean it up and update this question. * * * The keywords are:   * `Initial` [new] (initializes the whole world)   * `Setup` (checks for pre-conditions are met for the beginning of one step, and create temporary objects that help with this one step - these temporary objects will cease when this one step finishes. You may call these "local" objects)   * `Exercise`   * `Verify` (assertions that the step has been successful)   * `Undo` [new] This optional method, if provided, means that there is a way to fully revert the world state to before this step. If one is provided, the programmer vouches for the correctness of that Undo. If unsure, don't provide one.   * `Final` [new] Wraps up the whole world for disposal. After that, Initial can be called again to re-initialize a second new world.   * `Follows` [new] this defines how steps can be chained together.      * Each test step that is not an `Initial` step must have one or more `Follows` statement. Each statement can include one or more peer steps - those peer steps need to happen first before this step can be invoked. **Now the gist. Once you specify all those rules, the sequential test execution engine enumerates ALL of possible sequencing of those sets of steps.** It enumerates all paths from `Initial` to `Final`, using whatever intermediate steps that allows a path to be formed. It will also warn you about loops and other potential problems, and let you choose how to deal with those loops.


Using Git in Enterprise environment

Git is an excellent version control system. If we exclude the fact that, it doesn't have an excellent GUI support, it's really good and fast. But the source controls like Clearcase has large support for enterprise customers. Companies are investing huge amount for source control servers and licesense. Of late most of the large companies like Google are adopting Git over other version control system. But this company has a strong open source group which consistently provide development and support for the tool (They might even have a custom version of Git of their own). At the same time, large companies are not really bothering about adopting open source projects and making them relevant to them.   * Is Git really a reliable tool for enterprise environment, especially on Windows Platform?   * The support is in question for Git as it's an open source product.   * Are there any company that provides solutions and support? How are the server costs compared to other version controls like Clear-case?


Are ads within average Android applications profitable?

I presume this question is acceptable here-- because it's a part of software development but not specific to programming. If it's better suited for another area, could someone kindly help move me? I know ads can be profitable for some incredibly popular applications, but how do average applications fare? I am about to release an application and I think it will be pretty popular, but it's not the next Angry Birds. I guess there will be a few thousand users. Would a few thousand users that use the application about 15~20 minutes once or twice a day net any actual profits? What are you experiences with ads like? What kinds of numbers do we need to net anything worthwhile? Thanks~


Has "Not everyone can be a programmer" been studied?

An old adage that many programmers stick to is "It takes a certain type of mind to learn programming, and not everyone can do it." Now I'm sure that we all have our own trove of anecdotal evidence, but has this been studied scientifically?


How can I close my Open Source project and what is required from me in order to make it closed source?

Let's say I wanted to close my "GPL v 2.0 (or similar)" licensed project, to which I'm the only contributor, and make it closed source.   * Do I still need to make the existing "GPL v 2.0 (or similar)" licensed code available after closing the project or can I refuse giving out the source code for old revisions that was previously "GPL v 2.0 (or similar)" licensed?   * Can I theoretically keep the the code "GPL v 2.0 (or similar)" licensed even after removing the public source code or do I have to distribute the source code if I'm using a "GPL v 2.0 (or similar)" license?


Suggestions for finding code to review, that is for CodeReview.SE

Looking for suggestions on finding code to review, or to be more clear, code on SE sites with excepted working code -- to suggest be posted to CodeReview.SE for optimization. The source of this question was another question I posted on CodeReview.SE.meta Growing Code Review, One Idea... :-) In which I got this reply: * * * > Sure, you can, as long as people are clear what code review is for -- > essentially, functioning, working code that needs to be improved in some > subjective, perhaps even aesthetic, way. > > If the code is in any way broken or does not work, that is not the purpose > of Code Review. > > Jeff Atwood * * * If anyone has suggestions on how to improve this question, just comment.


How do you keep emails short but complete?

I'm the odd kind of developer that likes writing and explaining - emails, specs, you name it. I enjoy helping people understand things deeply. I hate ping-pong communications where groups go through 30 or 40 emails, phone calls and meetings because 25% of the group misunderstood the previous dashed-off email in which the writer only half-explained their position, or was in a hurry and miswrote a critical word or left out a negative or two. This trait is great for documentation, but my emails are long, so people simply don't read them. A couple strategies I've used are formatting long emails as attached Word documents to encourage people to view them as documentation (works surprisingly well sometimes), or trying to use more bullet points instead of free paragraphs. These strategies increase readership, but the content is still long. Of course I want to yell and scream that complex technical topics require a lot of exposition and clarification, but that doesn't help anyone. Obviously there are tradeoffs that can be made, but I have a hard time justifying making statements that aren't clear or that will result in a million questions, misunderstandings, or added "terms and conditions" later on. How do you keep your communications short but complete?


JavaScript for a non-programmer

2 years ago I starded learning AS3 in order to get hired at a web design company. A few months later, I ditched it, because I discovered that I'm better at design; so now I'm a web designer. Recently, I decided that knowing JavaScript would be nice and helpful, so i started with Essential JavaScript Training from Lynda.com. Untill today, I was under the impression that my knowledge of programming was somewhat basic. What happened today...? I learned (through trial and error) that variables are only valid in the functions that they're defined in. This turned my world upside down. I was like: "that makes sense now..." thinkin of the all the headaches that the lack of this specific piece of knowledge gave me. How could I have missed such a fundamental thing while learning AS3 (and now JS)? I didn't. And I remember reading a at least three books on AS3, but none of them taught me about programming. So what I want to ask you, is if you could recommend me a good JavaScript book from which i can learn programming, too, besides syntax. Thanks! And sorry for my bad english :)


Unix as opposed to Windows (Java and C++)

Firstly I should explain the background. I am interested in high frequency trading programming roles. After looking at many job specs it is very clear that there is a big demand for programmers who have programmed Java and C++ on Unix as opposed to Windows. My question is what are the differences a High Freq programmer would come across? It cannot be something in the language itself because syntactically they do not differ over OS? Therefore I thought it must be something which the programming language has to interface, resources etc? Could anyone please help me out as I am trying to improve my C++/Java on Unix, in order to aim for this type of career? ps I'm guessing part of this answer lies with the socket infrastructure on Unix?


Java code generation from class diagram

I'm on the way developing a Java application where user can provide a class diagram and get the corresponding Java code. I don't know how can I let the user interactively _draw_ a class diagram in Java. I am currently getting the required parameters like attributes, functions directly from the user, and then I render a class diagram for him. I show the class diagram on a jdialog.But when it comes to multiple class diagrams, it screws me. Is there a better way to do this? This is an example of a class diagram, I need to generate this from a Java program, given the values and relationship. ![enter image description here](http://i.stack.imgur.com/MgwsJ.jpg)


What is the pattern behind respond_to / respond_with in Rails?

Is there a specific name to this? For me it looks like a view router, or a presenter router (I would name it like that) but maybe there is a better name and explication.


Is using something other than XML advisable for my configuration file?

I have a small tool I'm designing which would require a configuration file of some sort. The configuration file in my case is really more of a database, but it needs to be lightweight, and if needed the end-user should find it easily editable. However, it also will contain a lot of things in it. (depending on certain factors, could be 1Mb or more) I've decided I'd rather use plain ol' text, rather than trying to use SQLite or some such. However, with using text, I also have to deal with the variety of formats. So far, my options are   * XML   * JSON   * Custom format The data in my file is quite simple consisting for the most part of key-value type things. So, a custom format wouldn't be that difficult... but I'd rather not have to worry about writing the support for it. I've never seen JSON used for configuration files. And XML would bloat the file size substantially I think. (I also just has a dislike of XML in general). What should I do in this case? Factors to consider:   * This configuration file can be uploaded to a web service(so size matters)   * Users must be able to edit it by hand if necessary(ease of editing and reading matters)   * Must be able to generate and process automatically (speed doesn't matter a lot, but not excessively slow)    * The "keys" and "values" are plain strings, but must be escaped because they can contain anything. (unicode and escaping has to work easily)    * **Multiple** configuration files. Basically, each config file is tied to one "project"


Help identify terminology for pattern substituion?

This is a badly titled question...maybe a moderator can make it better. Nearly two decades ago, I took a computer graphics class as an undergraduate. We got to do whatever we wanted for a final project as long as it demonstrated what we learned about CG. So, I read a book (I can't think of the name at all) that described a methodology to generate fractal images starting with a simple shape and mutating it using substitution. It described abstract fractals and tree/flower fractals. I do recall implementing the Sierpinski Triangle in one of my sample imputs as well as a 3D tree. The input to the program was basically a series of arbitrary symbols defined by the program. `-----=` might represent a rose. Then you apply some substitutions for a given pattern. `--= > -+=---=` might represent a longer rose with thorns. So, applying that pattern to the initial string you get `----+=---=`. Finally you loop over this string `N` number of times to create some desired effect. The book itself offered a ton of inputs with sample pictures, but no actual source code. The implementation was completely left up to the developer. I would like to know if somebody can help me with the terminology for this technique and bonus points for the name of the book (or a book) that described this process?


When are request headers read by ASP.NET code

I've got an issue with my MVC 4 website where iOS Safari is automatically sending the DNT header with the first request to the site. Here's my question on StackOverflow. Even though the iPhone has the DNT setting turned off, it still sends this header. So, my hack to fix this is to create an ActionFilter that will remove that header if it exists. My first attempt was to just add my custom ActionFilter to the FilterConfig.RegisterGlobalFilters method. That did not work (though I didn't have Fiddler in front of my at the time to see what was really going on). As long as my browser (iOS Safari) stays open, it will always remember me, but I want it to remember me between browser sessions. So my next thought is to try adding the removal of that header inside either the Application_BeginRequest, or Session_Start methods in Global.asax file. Here's a handy site that showed what methods were available in the Global.asax file and what order they process in. That leads to my question, at what point in the process of processing a request, do the headers (specifically the DNT header) get analyzed that are used by Forms Authentication [session/cookie]? It would seem that by the time the request gets to my ActionResult method, that the DNT header has already been read and "processed". I want to be able to strip it out at the earliest possible moment. Btw, I'm not at my home computer right now which is where my code is. I'm not going to be able to start working on this until the wife goes to bed (11:00pm) so I want to make sure I have all my eggs in a row before I start working so I can get as much accomplished as quickly as possible. I need to have a big production release tonight, and I'd LIKE to get this fixed as well... Thanks for any help/input if you're able... Edit: Any other suggestions for either this question, or the one that I have referenced/linked above on StackOverflow?


How important is the Acid3 Test anymore and what should replace it?

For a long while the default guide to latest standards support for browsers was the Acid 3 Test. I've just run this on Windows 7 (x64) for Chrome 15.0, Firefox 7.0, Safari 5.1 and IE 9.0 and they all score 100. Some of the animations could be smoother but on the whole there's not much to differentiate them. I've then looked at the scores for html5test.com which show much wider variation:   * 343/450 : Chrome 15.0    * 298/450 : Firefox 7.0   * 293/450 : Safari 5.1    * 141/450 : IE 9.0 Are there other tests that are a useful measure for browser feature support? What minimum score on the HTML5 test is a 'good' score? How important is the HTML5 test score and can it really test all the new features properly? Is it a good replacement for the Acid 3 test? Are the modern browsers now compliant enough that the end user can remain ignorant of the level of standards support?


Is there a way to run javascript on a present webpage

I don't have programming background. I have started learning javascript recently. I'm wondering if there is a way to run javascript on a webpage ? for example I would like to write a javascript on this webpage which runs through all the questions posted in past 1 hour and does something. Is it even possible ?


What camera to choose for using with JMF (Java Media Framework)

For the past 2-3 weeks I've been searching for different ways to implement custom video streaming and in more general video capturing and manipulating, going through DVR-cards, Video Capture Cards and stuff like that. Somehow JMF was able to stay out of my sight for all this time, but since I find out about it I'm more and more sure that this is a comfortable level for me to start playing around with video and stuff. One major topic that occurs to me while searching for more info was the presence of many posts where people were complaining about the fact that any particular camera ( most of the time I think they mean web cameras) doesn't work with JMF. Even though there are a lot of different cameras (not necessarily a web cam) that are not that expensive I want to play it safe and buy one that is proven to work well with the JMF. Also due to lack of experience maybe this is irrelevant but since I'll buy the camera mostly for learning and experimenting I want to have the maximum freedom possible to mess with different features, options and so on.


Why friend in C++ should be in the header file?

Friend function/class, FriendOfX for some arbitrary class X is an implementation detail of class X. Why in C++ we have to declare them in the header file? Are there any compelling reasons to make this contract (between X and FriendOfX) explicit? I understand there could be valid reasons to make this contract explicit but in some cases I would not want my client using interface class X to know about FriendOfX since FriendOfX happens to handle certain collaboration aspects of interface class X which are implementation specific


Quality Assurance tools discrepancies

It is a bit ironic, yesterday I answered a question related to this topic that was marked to be good and today I'm the one who asks. These are my thoughts and a question:   Also let's agree on the terms: QA is a set of activities that defines and implements processes during SW development. The common tool is the process audit. However, my colleague at work agrees with the opinion that reviews and inspections are also quality assurance tools, although most sources classify them as quality control.   I would say both sides are partially right: during inspections, we evaluate a physical product (clearly QC) but we see it as a white box so we can check its compliance with set processes (QA). Do you think it is the reason of the dichotomy among the authors? I know it is more like an academic question but it deserves the answer :)


How to tell the View to create a cookie?

I have a `LoginService` class with `loginUser($email, $password, $remember = false)` method in the application layer of my model layer. Now, if `$remember` is `true` it needs to create a persistent user login cookie on the client's browser, but since that is the responsibility of the View, what is a good way of reaching the view through the controller to let it know it should create the cookie for it?


PHP frameworks - should I use them?

First of all let me explain who I am: I am a PHP Developer working for a company developing their CMS which handles online stores, data feeds and other content like blogs. I have been programming for 6 years and 4 of those have been in PHP. (I used to be a C# developer). My question is regarding PHP frameworks. I see so many jobs asking for zend, cakephp and other MVC types of frameworks. However, even as an experienced developer I have never used a PHP framework. Should I start learning? If so where do I even start as there are so many. I am about to re-write so much of my work's CMS and I'm wondering whether I could help myself a lot by using a framework. What do people think? Considering I will be re-writing a lot of the online store stuff... I am experienced in OO and I have used the .NET framework in the past. Thanks in advance for the replies.


Minimal Refresh(F5) Web App Development

Although questions similar to this one has already been asked and I can perhaps assemble the answer for myself by reading already posted materials. Still I am going ahead with the question, cause I feel it has elements of new flavor and I would like to see the views of others on how to tackle this. I have developed several Web Applications of various scale. In some of them, I was only Developer, in another I led small teams and was part of a big team in another. Most of these were developed using PHP. One of them used Kohana Framework, the rest were all developed using Raw PHP. The main difficulty that I faced in regards to speedy development was, whenever a small change was done to fix a bug or modify a feature, I had to refresh my web browser, go through several pages until I reached the page which included the fix. I would like to know, what should be the development approach so that I can test out my code without having to, or at least minimize the number of refreshes required to test out changes in code. Although, the concepts maybe applicable for developments of any nature, for this question, let us stick to PHP and it's framework.


The benefits of using RAII in C++

Suppose I'm a teacher and I want to explain to my students what are the benefits of using RAII in C++: I need a very good example, full of details, but that is easy to understand.   Which approach would you use?


How do you educate your customers?

Customers need some education because they think different. Customers think:   * changes are not a problem in any time of the project   * details are not important (exceptions even less)   * time does not cost money (they have a fix price agreed)   * one sentence in the specification can be extended/read freely to fit the actual needs - and this does not affect the contract. (here we see often the "common sense" discussion - example: "Of course we need a invoice management screen when we talk about accounting managment - this is common sense!")   * the list goes on... The main problem is that customer (no matter if external or internal/department) do not want or can not understand. It took me many years to understand software creation process and I am still learning, so how can they in just a few months. What is your experience, what is the best approach to educate customers?


Play or Lift: which one is more explicit?

I am going to investigate web development with Scala, and the choice is between learning Lift or Play: probably I will not have enough time to try both, at least at first. Now, many comparisons between the two are available on the internet, but I would like to know how do they compare with respect to being explicit and involving less magic. Let me explain what I mean by example. I have used, to various degrees, CakePHP, symfony2, Django and Grails. I feel a very clear distinction between Django and symfony2, which are very explicit about what you are doing, and Grails and CakePHP, which try to do their best to guess what you are trying to achieve and often feel "magical". Let me give some examples comparing Django and Grails.   * In Django, views are functions that take a request as input and return a response. You can instantiate explicitly an instance of `HttpResponse` and populate its body with a string, or you can use shortcut functions to leverage the template system. In any case the return value from your view always has the same type. In contrast, the `render` method from Grails is highly polymorphic. You can throw a context at it and it will try to render a template which is found by convention using that context. Or you can pass it a pair of a template path and a context and that will work too. Or a string. Or XML. Grails tries hard to make sense of whatever you return from your controller.   * In the Django ORM, each model class has a static attribute representing the manager for that class. That manager exposes a fluent interface to build querysets. In Grails, you can have a similar functionality by composing detached criteria. Still, the most common way to query objects seems to be the use of runtime-generated methods like `FindUserByEmailNotNull` or `FindPostByDateGreaterThan`. I will not go further, but my point is that in Django-like frameworks you have control over the whole flow of the request/response process, while in Grails- like ones I feel I only have to feel the blanks and the framework will manage the rest of the flow for me. This is not to criticize Grails or CakePHP; which type you prefer is mainly a matter of preference. In fact, I happen to like some aspects of Grails, but I feel more comfortable with a framework which does less for me. Back to the point of the question: which one among Play and Lift is more explicit about what you do and which one tries to simplify more what you have to do with a layer of "magic"?


Multiplayer Game Listen Servers: Ensuring Integrity

I'm making a simple multiplayer game of Tic Tac Toe in Python using Bridge (its an RPC service built over a message queue - RabbitMQ) and I'd like to structure it so that the client and the server are just one file. When a user runs the game, he is offered a choice to either create a game or join an existing game. So when a user creates a game, the program will create the game and also join him as a player to the game. This is basically a listen server (as opposed to a dedicated server) - a familiar concept in multiplayer games. I came across a really interesting question while trying to make this - **how can I ensure that the player hosting the game doesn't tamper with it (or atleast make it difficult)**? The player hosting the game has access to the array used to store the board etc., and these must be stored in the process' virtual memory, so it seems like this is impossible. On the other hand, many multiplayer games use this model for LAN games.


Recursion -- is it "divide and conquer" or "code reuse"

_**Recursion_** \-- as we all know -- is one of those problems -- that wrapping your head around feels like achieving a "milestone" in your programming voyage. But when it comes to actually using it in real world problems -- knowing the mechanics of recursion is NOT enough -- one must also understand the nature of the problems where recursion is the most suitable solution. So my question is this...   * what are the "problem patterns" that call for the solution of recursion   * is recursion a form of "divide & conquer" strategy or a form of "code reuse" -- or, is a design pattern in its own right   * can you give us an example of a real world problem where recursion comes to mind as an immediate solution _**\-- UPDATE --_** a lot of answers are referring to "real problems" as tree traversing, of factorial, etc. I would prefer "the REAL real problems" -- let me give you an example... We had a LARGE chuck of text (about 30 MB of text as a linked list of `structs`), and we needed to make an index of it for full text searching. We needed keep the entire index in the memory and re-index the text every 10 minutes. Every 10 minutes we'd compare the entire text (two linked lists, line by line) with a newly generated chunk of text -- to see what line was changed -- and then we would re-index only that line -- that way we could avoid having to re- index the ENTIRE text. Remember -- we needed to find the diff points between two 30 MB linked lists. One of my colleagues came up with a fantastic program which used HEAVY recursion to compare the lines -- and then collect the positions where the chucks differed in an array -- yes i know it sounds puzzling -- how could recursion help here -- but it did. The point is -- how could he see that this problem could be solved smartly with heavy use of recursion?


DDD + POCO does this makes sense?

DDD promotes rich domain models with behavior in it, POCO naked objects without any objects in it. **Is it possible to have them both combined?** I have a Multi Layer Solution   * Core - has POCO Entieties, interfaces for Repositories and Services   * Data - Repository implementations   * Service - Service Implementations   * Infra - IoC Locator/registrar, viewmodels, (could be merged to webui)    * WebUI - asp.net mvc presentation layer I was saying that I use DDD but recently I've been told that I'm not because my Entities don't have behavior, **is this true?**


So I've gotten the hang of iOS app development, but how do I become a great app developer?

I've spent the past 2 years teaching myself and taking classes on object oriented programming. I have done quite a bit of Java programming, and lately I've been spending a lot of time doing objective-c. I really enjoy programming, but one thing that I have noticed (with some frustration) is that I'm not amazing at finding elegant solutions to problems. I'm beginning to notice that it isn't enough to just solve a problem, but that the way you approach and implement a solution says a lot about you as a developer and depth of your knowledge and understanding. Being that I am looking to make a career out of iOS development (I'm still in college), I want to be sure that I am doing everything I can to learn elegance, as opposed to just getting it done. Case in point: For one of my first programming projects for school (this was a long time ago!), we needed to populate arrays with tons of information. I went through and added each element line by line just hard coding the index! When the TA came by he laughed at me and was like: "Why didn't you just use a for- loop?" and I thought to myself, well who cares? It works doesn't it? **My Question to iOS devs out there:** What are some things that I can study/try to implement to increase the elegancy of my design habits? What are examples of things that are often done in the app development world by rookies that just shouldn't be done? Instead of just being able to throw a quick and dirty hack job of a solution together, I want to be able to consistently come up with awesome ways to solve problems! And I've realized that those types of solutions don't always come quickly to me. Is this skill something that can only be acquired through experience and doing it wrong tons of times before you realize that there is a better way? Are there any areas that you can recommend I try to cover and make a point of understanding? While I am happy that I can keep up with many of the q's posted to sites like this, I get frustrated when I see some that are just in a whole different universe! I want to close the gap, and so I am throwing this out there to any who may be interested/able to help. Thanks!!


Java Phones: How to set up JTAPI?

I want to use JTAPI (1.4 - latest) to create an app that will call my phone whenever I need it to. I downloaded JSR043 (JTAPI specification) and have been reading the API docs and it seems pretty straight forward with respect to _how to code JTAPI_. However I seriously doubt that getting a Java app on my laptop to call my cell phone doesn't require some 3rd party or middle man service provider and possibly other entities/configurations as well. So I ask: besides using the JTAPI in my Java code, what do I need to install or set up to have a Java app that calls my phone? Thanks in advance!


Are there any special advantages of SQL Server with Visual Studio?

I have seen the forum dba.StackExchange, but this question involves Visual Studio as well, therefore I wanted to post this question here. One of my old application was built on VS-2008 and MySQL back-end. After three years, I don't have any major issues with it and the database performance is also good. I am scaling this application to a WPF application and want to know whether SQL Server has any added advantages when used with VS-2010, other than that it is from Microsoft, over MySQL? In most scenarios, I notice query execution in MySQL is faster as compared to SQL Server.


Web Application that is independent of web server software

# Scenario I haven't faced this requirement before, so I'm not confident with my solution. Our team drew up a plan to design a web application using a basic HAT stack for a project with a 4 month development time. We presented it to the client, who added two big new requirements. The requirements were:   * The application must be runnable on any web server (IIS, Apache, Nginx, Lighttpd, etc...)   * The application must be able to work with any database (MySQL, MongoDB, etc...) His reasoning is that he has no control over the environments where the web application will be installed on. He plans on re-selling our solution to other customers. We pushed back to the client saying that this would increase development time, but he has already committed to his clients. However, he said he is willing to put as much money into it to get it done. ## Possible Solution? The only solution I could think of was building the application in Perl CGI script as that seems the most universal, then having a variety of database adapters to plugin into an ORM, which is customized through a config file. ## Question   * What alternatives are there to creating a web application where we have no control over what modules, etc.. are installed in the web server?   * Is this even possible?


Version control workflow for semi-bespoke software

I have a web app product (PHP, MySQL) for which I offer a bespoking service. That is, you can buy the main product, which is quite extensive, and then have it customised however you like. This might include new features, adjusting fundamentally how existing features work, disabling features, making changes which require a different database schema, etc. I want to find a sensible way of managing a large number of different releases of the product in version control such that I can make changes to the core and pull changes out to the releases as required, and also make changes to a release independently. Sometimes I might want to pull a change from release back into the core. My instinct was to use Git, and have the releases as branches. It is possible to pick specific commits to merge back into the trunk, so I think this could work. However everywhere I have looked suggests that it is a bad idea to have permanently separate code in branches. The suggestion is to use a single codebase and have all the differences in features configurable, so that each release can behave separately. This sounds fine for software which is sold in multiple editions, which have different features enabled, but I think it would be a complete mess for my software. I'm looking for a good development workflow for a setup like this, which may or may not be based on version control.


What is the best approach for Single Sign On Application Development that is lightweight? By lightweight I mean not too much javascript. I know stackexchange does use single sign-on. Basically is the login credential stored as cookie? Or combination of IP-Address and other specific information about the logged in user?


Can we still consider that Moore's law still holds true regarding the consequence on CPU speed?

Moore's law is an empirical law and in simple terms states that the number of transistors on integrated circuits doubles approximately every two years. One of the consequences of Moore's law is that CPU performance doubles every 18 Months. I've seen 'Why is Moore's Law seen as an absolute truth?' and although curious does not answer my question. Currently we are partly achieving that by making multi core CPU's. **Can we still consider that speed of CPU's doubles every 18 months?** Multi-core CPU's can be looked at just as distributed computing. A "good old" single threaded sofware/algorithm won't be able to take full advantage of such CPU as before and It's not true that all algorithms are paralelizable with speed gain.


Criteria for selecting timeout value?

Situation: a piece of software reads frames of data from a file in a seperate thread and puts it on a queue, emptied by another thread. That second thread periodically checks on the queue and fails rather gracefully, by showing an error message stating the read timed out, if no data is available within a certain amount of time. Initially this timeout was set to 200mSec. There was no real reasoning behind that constant though, but it worked fine. We measured on a couple of machines and for large data frames, larger than what would be used by customers, a read took like 20mSec whith no other load on the machine. However one customer now gets timeout errors now and then (on the second try all is fine, probably the file is in cache or the virus scanner leaves it alone). The programmers are like 'well, yeah, but that customer's machine is full of cruft, virus scanners, tons of unneeded background processes etc'. Of course the customer is like 'hey this should just work, shouldn't it'? While the programers have a point, since the software is heavy enough to validate the need for a dedicated machine, that does not make the customer happy. Increasing the timeout to 2 seconds, for example, solves the problem. But I'd like to make a proper decision now instead of just randomly pick some magic constant that is probably ok in 99% of cases. What criteria should be used for that? We could just pick a large number, but that feels wrong. (and then we end up with a program that has the horrible bahaviour of hanging when trying to read from a disconnected drive for instance, whereas we'd rather make it show an error right away). Or we could make the timeout value a user setting, but then we need to ducument it clearly and even then not all customers are tech savy enough to really understand what it does. Or we could try and wait until another customer reports timeouts and increase the value again. And again. Until we find something ok for 99.99% of the cases.. Any good practice for this type of situation?


DDD: Developing the Domain Model alone

In DDD examples it seems the common method for developing the domain model is to sit with domain experts and iterate over versions of the model, say on a whiteboard, continually modifying it and changing it until presumably an agreement is made on how the model looks. On my project I've spent a couple of days with a domain expert, discussing the domain, and now I want to lock myself away and produce a draft model based on my understanding, rather than producing the model collaboratively with the domain expert. He could then review it, and I could update it according to our subsequent discussions. Has anyone else worked like this, or does anyone think its a good / bad idea? I think maybe I just find it easier to think creatively when alone.


Problem in working with async and await?

I am trying to upload files to Azure Blob Storage and after successful upload adding the filename to a list for my further operation. When i am doing synchronous it works fine but when i am doing async the error occured. Error : Collection was modified; enumeration operation may not execute.               foreach(var file in files)     {        // .....        await blockBlob.UploadFromStreamAsync(fs);        listOfMovedLabelFiles.Add(fileName);     }     if (listOfMovedLabelFiles.Count > 0) // error point     {         // my code for further operation     }      Is there any way to wait till all the async operations get completed.


Is adding support for another operation system a minor version or a patch?

Let's say I use Semantic Versioning for a my project. I'm developing it under FooOS, but the language uses virtual machine(either interpreted language or bytecode based) so any operation system can run it. The thing is, the project interacts heavily with OS-managed things(e.g. pipes, processes, the file system) so if you try running it under a different operation system - BarOS - it gets so buggy and so many things don't work that the project is practically useless. Now, at some point I want to make my project work for BarOS, and I want to release a version just to add that support. The question is - does that count as a _minor version_ or as a _patch_? It seems like it's a patch:   * All I do is fixing all the bugs that appear when running the project under BarOS.   * Users of my project shouldn't notice any change in functionality, since they are using FooOS in the first place.   * For BarOS users my whole project is new - but getting new users is not something that should result in a version increment. But even with all that reasoning, it just doesn't seem right to label a release as big as new OS support as a patch...


Defining error codes

We are designing an error-handling framework for a cryptographic library written in C. The approach we are taking is that relatively few errors are propagated back to the user since on most occasions he cannot do anything about them (notable exception: parameter validation errors. Of course we tell the user if a call succeeded. We'd also create log entries for fault investigation.) In short, just because we have an error condition somewhere inside the library it does not mean that we need a public (user-facing) error code for it. Also, from past experience we think that a significant portion of error conditions that require error codes pertain to very narrow areas of code, it is often the case that a particular error is only returned from (or set by) one function. Therefore we would like to define error codes at the lowest possible level. For example, if only one function can return/set a particular error code we would define that code in the .h file where the function prototype is declared. However, in such case we might get error code conflicts - the same error code value for different errors. Can someone please propose an elegant approach to avoid such conflicts? Or at the very least an automated mechanism to check for such conflicts (which can then be fixed by hand)?


Dealing with API and error messages

We are in the process of constructing an API (using WCF). So far I noticed 2 ways in which methods could go wrong due to problems with the parameters sent.   1. wrong format, for example we have a string date parameter which should be in a certain format, if it's in a different format the method cannot continue.   2. if a method role is to do something identified by an ID, but that ID does not exist in the application (DB) First we thought throwing an exception, but I realize now that this is not truly an "exceptional" situation, these kind of things is pretty common. Right now we deal with it in the following way: We have an abstract class which is called APIResponse. it has a boolean success variable, and an array of messages for the API's client. Each group of methods has a corresponding implementation of this class and that will be the returned object. **is this kind of approach ok?**


Is there a limit on how many global consts are used before an application is considered bad programming?

Basically, I develop websites, some large with many crud operations, etc... However I've gotten into the habit of storing re-usable data as a constant in my PHP applications I currently have 44 constants defined in one application. These range from:   * Database config   * Home page for admin and guest   * url slug names   * declaring development mode   * declaring maintenance mode   * a few directory shortcuts ( instead of writing /admin/templates/images ill use const ADM_IMAGES )   * session names   * cookie names   * random things like MAX_IMAGE_SIZE, THUMB_SIZE and MAX_LOGIN_ATTEMPTS I don't have any problems using all these constants... It's kind of helpful having all these in my application. I just wanted to know if its a 'good practise' to use them in this excess If not, how else could this data be encapsulated to be useful AND easy enough to reach in my application? Also bearing readability in mind.


How to explain that sample size does not influence project length

We have big enterprise projects they normally involve copying data from a source database to a destination database and then setting up a number of additional applications that sync this data etc. The last project contained 250,000 items (rows of data). The next project will only contain 4,000 items. Project managers / business people believe the project should be 1/10 the time to complete because its only a fraction of the size of the last project. What is a good **analogy** I can use to explain that writing code to transfer data from one system to another takes the same amount regardless of the number items - writing it for 1 item or for 100,000,000 will take roughly the same amount of time from a programming point of view.


Alternative methods for maintaining JavaScript source

I'm looking for other options for maintaining my personal JavaScript namespace. The problem I'm having boils down code _Organization_ Vs. _Performance_. I would simply LOVE to be able to separate major sections of my code into a more "traditional" style. But I haven't because if I were to do that I would probably quadruple the amount of HTTP requests I send out. Essentially I am including two different js files. `jQUery/jQueryUI/my namespace` in one and my implementation in the other. Great for performance in my web-apps... but looking at my JavaScript source makes me scared, confused, and horrified all at the same time. What am I missing here?


Rails application - how to optimize/reduce database calls when iterating over a collection

What's the best way to optimize a Rails app where you need to pull info from the database for a collection of items? For example, if I am building an online forum system... I would have a number of `Posts` and the posts would have_many `:recommendations` and `:comments` and `:favorites`. When I display the posts in my view, I might need to display this info - like a count of how many comments there are, and whether or not my current user has favorited/recommended the post. I was playing around with this and it seems there are a huge number of DB queries being executed! First I'm grabbing my collection of posts - then, iterating through each one, I am going to the comments table, the favorites table, etc... to get counts or see if records exist for that particular post. So for every post I have, I'm executing 3 separate queries! **Is there a more efficient way to get this data, or are tons of queries like this normal for a scenario like I describe?**


Exception Handling in Java web application

I know exception handling is a topic often discussed in the world of Java. I've read a few threads on here and SO as well. http://stackoverflow.com/questions/2169339/exception-handling-in-a-java-web- application I find myself identifying with principles such as _Do not suppress or ignore exceptions_ , _Do not catch top-level exceptions_ , and avoid anti-patterns like _Log and Throw_. http://today.java.net/article/2006/04/04/exception-handling- antipatterns#throwingException http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html?page=2 **Question #1, is there a different standard of practice when it comes to web applications?** For example, is it a legitimate use case to catch `Exception` for logging purposes and then throw it up the stack?               function void xyz() throws Exception {         try {         } catch (Exception e) {             LOG.error("ERROR: " + e);             throw e;         }     }          function void otherFuncA() throws Exception {         xyz();     }          function void otherFuncB() {         try {             xyz();         } catch (Exception e) {             LOG.error("ERROR: " + e);             throw e;         }     }      I am finding it very hard to accept as a practice because it is generating so much unnecessary code (see `otherFuncA` and `otherFuncB`), affecting the function calls all through the different layers (DAO, Service, Controller, etc.) **Question #2, do I lose information about an error (let's say what caused a`NullPointerException`) if I let unexpected, unchecked exceptions float up to the Controller layer and then, and ONLY then, handle it there (catch `Exception` and throw stack trace)? As opposed to logging immediately, and re- throwing (seen above).**   Of course, I will still check for specific exception types where applicable. I seem to find the stack trace is often a better indicator of what went wrong vs. which specific field was causing an error... I am really interested in input from more experienced developers and what best practices/reasoning guide your exception handling.


How do I visualise the feature space partitioning in random forest?

I am learning about random forest and found this video https://www.youtube.com/watch?v=gdnIqGbqiYs&list=UUb9svouAi1XHRqlOs8LXbBg very useful. The first 8 minutes explain how to visualise how the feature space is partitioned as the tree is populated during training. In the video however, the partitioning is only explained with respect to two feature vectors throughout the entire tree. It was pretty easy to understand how the feature space is partitioned for two features, as the feature space plots feature 1 vs feature 2. However if I have multiple features selected at random to be used in any node of a given tree, how do I visualise the feature space and how it is partitioned? For example if one branch contains 5 nodes, with 5 features being selected before reaching the leaf node, how is the feature space partitioned to include all 5 features?


Writing java doc comments for unit test cases

In my opinion, the unit test cases itself serve as a documentation for the code. My company wants me to write detailed java doc comments on top of unit test cases. Is it necessary to do so? Do you write comments like that ?