title: How can I write HTML, CSS, and JavaScript to make back-end developers work easier?

text: When I get a design from a designer, I get it as a PSD (Photoshop) file. I always expect proper layer and folder names, basically a clean and managed PSD. From this desigbn I develop HTML, CSS and JavaScript and deliver it to the back-end developers. To make it easy for them to understand, I   * write semantic code,   * keep JavaScript and CSS in external files,   * add useful comments in HTML, CSS and JS files,   * use CSS sprites (though developers don't like it),   * use HTML5 boiler plate,   * use jQuery for JavaScript,   * try to use new HTML5 tags and CSS3 whenever possible and   * sent a Zip file containing the HTML, CSS, JS and images. I expect that if small changes will need to be made to the layout, the developers can handle that. I would like to hear from back-end developers and other CSS ninjas what more one could do in terms of organization of files and mark-up to make the integration with back-end systems easier (i.e. back-end technologies, PHP, .NET, Ruby etc.) Different client uses different systems.


title: Are there general rules or best practices for building a new framework?

text: I need to start the design and development of a new framework to interact with an open source ECM. This inludes a customized data model to help web site developers interacting with this ECM, so they don't need to care about the details of nodes manipulation and other low level details. That's just a bunch of classes and methods to develop. I have some doubts about how to handle the organization and managment of that project: Are there some general rules to follow, tips, best practices or something to keep in mind for developing this kind of project? I'm sure there are some difference between the development of a framework or library and an application.


title: "Extends is evil" vs. OCP?

text: As far as I have understood(?), the "Extends is evil" idea is in direct opposition to the Open Closed Principle? In here, the concept of OCP is presented as inherently using Extends:   http://www.oodesign.com/open-close-principle.html While in for example this article, the act of extending is considered a capital offense?   http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html?page=1 What is the correct way to satisfy both OCP and not using Extends? Consider a simple BulletinBoard class that has Posts, which can be either NewsPosts or GuestbookPosts with different properties, but same methods/behaviour.


title: How to apply one of the OOP concepts (Closed for Modification and Open for extension)?

text: Days before, I created Question, Quiz, and Main classes. One Quiz has one or more Questions. From the main class I first create Question objects (the constructor accepts an array of numbers). The Quiz is like when I display the questions I omit the last number of the array and the user will try to figure out that number. Then from Main I created a Quiz Object. From Main I only call methods of the Quiz class and from Quiz Class I only call methods in Question class. Then I also created a web application (with JSP and Servlets) which uses the same Question and Quiz classes but not Main. Instead of Main I used JSP and Servlets to display the data. So without modifying the model classes(Quiz and Question) I am able to use them from other applications. But now, I need to add a HINT, which will give the user hints for every questions. If I go and modify those 2 model classes, I am going to violate the Open-Close principle. If I am going to create a class called Hint(one hint per question) and extend from question class, it doesn't make a sense because Hint is not a Question. But Question has a hint. Can you please guide how to have a HINT in my application so that I will use the previous classes without modification and violating any OOP concepts?


title: What are the disconnected scenarios in Entity Framework?

text: I'm not sure I understand what all fall under the disconnected context scenarios in EF (See this and this). This link says use Web API or WCF services to avoid the complexities of disconnected tier EF solutions. Here's my understanding. If I create a new DbContext, get some entities, pass it to another process/machine (anything outside the scope of the current context), and there I make some changes to these entities and try to save them, then this is a disconnected scenario. EF will not know whether it is an Add or Update or what fields have changed, unless I explicitly tell it. Suppose I have an MVC app, with a UserController. The UserController takes in a IUsserService through dependency injection. UserService, the concrete implementation of IUserService takes in a UnitOfWork. My DbContext is instantiated for the UnitOfWork, and SaveChanges() is called only on Commit() of the UnitOfWork. I also set the lifetime of the DbContext in Unity as PerRequestLifetime -> which means one instance is created for each HttpRequest. My UserService works with different entities required to do its job. I believe this is not a disconnected scenario, **since my context is the same throughout**? If my MVC controller were in one machine (web), and the UserService in another machine(app - http endpoints exposed using webapi), does anything change? In this case, I need the DbContext only starting with ApiController, and everything will stay within the app layer. So I still avoid disconnected contexts. Am I right? If I'm not clear, I can put some code, but nothing different in there.


title: Is it a bad idea to return different data types from a single function in a dynamically typed language?

text: I come from a statically typed language background (Java). In Java, you have to return a single type from every method. For example, you can't have a method that conditionally returns a `String` or conditionally returns an `Integer`. But in JavaScript, for example, this is very possible. In a statically typed language I get why this is a bad idea. If every method returned `Object` (the common parent all classes inherit from) then you and the compiler have no idea what you're dealing with. You'll have to discover all your mistakes at run time. But in a dynamically typed language, there may not even be a compiler. In a dynamically typed language, it's not obvious to me why a function that returns multiple types is a bad idea. My background in static languages makes me avoid writing such functions, but I fear I'm being close minded about a feature that could make my code cleaner in ways I can't see. * * * **Edit** : I'm going to remove my example (until I can think of a better one). I think it's steering people to reply to a point I am not trying to make.


title: Why is it suggested stories be sized to 2-3 days?

text: If sprints are on average 10 days, why is it often suggested stories be sized to 2-3 days? **Related Question:** How to handle backlog-items that are longer than one sprint?


title: Is it a bad practice to use GUI designer tools with code generation for application programming in Java/C++?

text: In a stackOverflow question I have read that using a GUI designer program can generate lots of messy code and is considered to be a bad practice unless you're making smaller programs. My question is why and how. Is it bad to use a GUI designer program? Why? Additional details:   * Programming on a Windows platform;   * Only programming in C++/Java for windows programs.   * For IDE I've been using visual studio 2010 (Not the express edition) since it comes with the GUI designer.


title: Is there any work into the application of the Halstead complexity measures to determine software quality?

text: In 1977, Maurice Howard Halstead introduced his complexity measures for software systems, which included measurements of the program vocabulary, program length, volume, difficulty, effort, and an estimated number of bugs in a module. According to Wikipedia, difficulty relates to the difficulty of understanding the program when reading or writing it and effort can be translated into the time it takes to code an application where Time = (Effort / 18) seconds. A measurement is useless unless the data and calculations relate to some aspect of software development. However, I haven't found any work which states that a difficulty of a certain value or higher tends to a statistically significant increase in defects or a relationship between difficulty and time to read code (a difficulty of N yields an average of M hours spent understanding the code base) or any analysis of being able to compute Time after the fact being useful in determining quality (especially since time to write should have been recorded as a measurement already). I'm especially interested in Halstead's bug estimation (which is not mentioned on Wikipedia) - the number of bugs in an application can be estimated by Volume/3000 or Effort^(2/3)/3000. I'm looking for two things:   * Has anyone used Halstead's software complexity measures in a real-world application to assess software quality? If so, how did you apply them and did they turn out to be a useful, valid, and/or reliable measurement?   * Is there any academic research in the form of surveys, analyses, or case studies that discuss the validity (or invalidity) of Halstead complexity measures when applied to software quality?   * Is there any academic research in the form of surveys, analyses, or case studies that demonstrate the use of Source Lines of Code (SLOC) to compute something similar to the Halstead metrics of Volume, Difficulty, Effort, Time, and Bugs? I would suspect that Volume might just correspond to a SLOC count and Difficulty might correspond to cyclomatic complexity (and possibly other measures). I'm also well aware that measuring effort, productivity, or time in SLOC is potentially misleading.


title: Fixing a security exploit - but then everyone knows about it

text: Earlier, I was messaged about a potential security risk in one of my projects. I checked it and found that it allows for "arbitrary code execution". (Quotes because it is running in a VM, but the damage that can be done is huge nonetheless) Since it is an open source project, I imagine other people have found it and exploited it already. However, I am reluctant to fix it, because everybody will be able to see the commit and know about the exploit. Since I have no way of contacting the users and no way of forcing an update (updates are manual), I am at a loss at what to do here. If I let it stay, people are going to exploit it. If I fix it, people are going to exploit it even more. How can I proceed?


title: Subset sum problem is NP-complete?

text: If I know correctly, subset sum problem is NP-complete. Here you have an array of n integers and you are given a target sum t, you have to return the numbers from the array which can sum up to the target (if possible). But can't this problem be solved in polynomial time by dynamic programming method where we construct a table n X t and take cases like say last number is **surely** included in output and then the target becomes t- a[n]. In other case, the last number is **not** included, then the target remains same t but array becomes of size n-1. Hence this way we keep reducing size of problem. If this approach is correct, isn't the complexity of this n * t, which is polynomial? and so if this belongs to P and also NP-complete (from what I hear) then P=NP. Surely, I am missing something here. Where is the loophole in this reasoning? Thanks,


title: Should all foreign table references use foreign key constraints

text: Closely related to: Foreign key restrictions -> yes or no? I asked a question on SO and it led me to ask this here. If I'm faced with a choice of having a circular reference or just not enforcing the restraint, which is the better choice? In my particular case I have customers and addresses. I want an address to have a reference to a customer and I want each customer to have a default billing address id and a default shipping address id. I might query for all addresses that have a certain customer ID or I might query for the address with the ID that matches the default shipping or billing address ids. I'm not sure yet how the constraints (or lack of) will effect the system as my application and it's data age.


title: As a .NET WPF developer what are key differences I should be aware of when working with ASP.NET MVC?

text: I'm a fairly experienced desktop .NET developer with a solid feel for MVVM and WPF, and I've worked with JavaScript, jQuery and HTML/CSS in the past - though I'm pretty dated and haven't had a ton of experience with the new frameworks (Angular, et al). My question is, for anyone who has had to do it, what are the key pain points and differences I should be aware of when working on an ASP.NET MVC project? I have a general sense of the MVC pattern and where it differs from MVVM, but ASP.NET tricks me by looking familiar, but with subtle and not-so-subtle differences in implementation and execution. I'm helping out with an ASP.NET project at work, and while my C# knowledge helps, my desktop habits seem to be a liability. Links to material I can review would be appreciated, or a succinct summary of what I need to change about my mindset.


title: Separation of presentation and logic

text: I'm now writing a program, which will allow processing data expressed in the form of graphs. These graphs will determine workflow of the processing and they are actually an essence of this program (in terms of being the main object being edited by the user). It is very, _very_ tempting to put all the processing, data containment and presentation in a single control, which will also display these graphs and handle user interaction. From one side it seems to be violation of the presentation/logic rule, but from the other I'm certain I will write surely at least 2x or 3x less code, because I won't have to take care of constant synchronization between data model and the control, which will present this model (+encapsulation, interfaces, proxy classes etc.) I'm wondering how it is done in editors like Word. Is the data displayed by the control really physically separated from the presenter or are they combined? If you use the Word document control in your program, you ask the control to perform operations on text, what would suggest, that there is no separation (but we don't know how does it work under the hood). So the question: is separation between data presentation and logic worth it _even_ if it requires like 2x or 3x more code to keep everything consistent and synchronized? (yes, I mean 2x or 3x). * * * I've described the situation in more detail in the next question: How to separate logic from presentation?


title: How to ensure method finishes running before being run again

text: I'm new and I am trying to figure something out. I have a simple program which executes a method either when an event happens or when my timer ticks. Lets just say the method takes 5 seconds to complete. During that 5 seconds an event could happen. **What would I use/do to make sure my method isn't called while its already running.** Or is this something I would not have to worry about in a simple program, as it wouldn't run until the method is done anyway ? A little background and example. I am using System.Windows.Forms.Timer, I am not using any threads or anything, and I just have a simple windows form application with a timer, a method to do stuff, and two event handlers.               Program{       public Program(){         DoSomething();         Event.EventHappened += HandleEvent;       }       void DoSomething(){         MyTimerVariable.Stop();         InitMyTimer();         //Just do something check network, access db write line, something         //that in this example takes 5 secs for example purposes         MyTimerVariable.Start();       }       void HandleEvent(){         DoSomething();       }       void InitMyTimer(){         // Create Timer, and add Timer tick event       }       void TimerTickedEvent(){         DoSomething();       }     }      I left a few things out of that program, but just was trying to show how simple it is. I was just thinking about making it more efficient so that say in the middle of doing "DoSomething()" an event is triggered, I wouldn't want two "DoSomething()"s method running.


title: Utility Functions Best Practices

text: **Update:** Most answers are about how to write a wrapping interface or what is a good wrapper around ADO. but my question is more about when to do so and when not. I never found a good rule for deciding when to write a wrapper and when not. As nobody came up with a suggestion I think the reviewers are right in that this question has no general answer and is to broad. Even in the specific case of ADONET the answer may depend on the use case and for most use cases a wrapper has been written already. Dapper and Orseis for e.g. as MainMa points out. I would like to remove the question but I do not want to steel any ones points 8-) **Original Question** Let's take code executing a query using ADONET as an example.               var cmd = connection.CreateCommand();     cmd.CommandText = "SELECT 1 FROM DUAL";     cmd.CommandTimeout = 1000;     var dataReader = cmd.ExecuteReader();      Many will want to write this as a one-liner and create a bunch of utility functions in this example called as follows (or extension classes):               var cmd = connection.CreateCommand();     Utility.SelectToReader (connection, "SELECT 1 FROM DUAL", 1000);      So what are good rules to introduce or deprecate utility functions? Apart from ADONET this question arises using almost any framework.


title: Building complex algorithms with TDD

text: I'm trying to adopt TDD in my daily programming practice. I use it at work very effectively, but I'm having trouble with my personal projects where I'm using some complex algorithms. The particular algorithm that makes me ask this question is the Extended Kalman Filter. It's complex enough that I'm not confident in the code I've written, but it's simple enough that it's hard to break up. I could write a test for the algorithm with an input and the expected output, but I'll do a lot of thrashing and shotgun coding in the middle because I don't have confidence in those intermediate steps. If you've worked with reasonable complex algorithms and use TDD, what is your approach?


title: Design pattern for bidirectional signals/events

text: This problem feels rather basic, yet I've never known a great solution. I'm looking for a way for components in an application to notify each other while being as decoupled as possible (both at build/compile and run time), but also **avoiding circular notifications** in a way that components do not need to self-mitigate against. I happen to be hitting this issue (for the hundredth time) in JavaScript right now, but that is incidental. Some means of decoupling include:   * **Dependency injection (DI)**. In this case I use `require.js` which allows, for instance, substituting mock implementations in unit tests by creating alternate `require.config()` setups.    * **Event dispatching**. E.g. `fooInstance.listen('action string', barInstance.actionHandler)`   * **Publish/subscribe** (aka pub/sub). The last two are basically variants of the Observer pattern with different pros and cons. The problem I want to solve is not specifically addressed by these patterns, and I'm not sure if its an implementation detail or if there is a pattern to apply:   * `fooObj` sends a message (fires an event, whatever) that the `"baz"` property has changed   * `barObj.bazChanged()` handles this event by calling its own `setBaz()` method   * `barObj.setBaz()` fires an event that "baz" has changed   * `fooObj.bazChanged()` handles this event ... As a real case, imagine `fooObj` is a GUI component, with a slider for `"tempo"`, and `barObj` is a music sequencing component that plays back a score. The slider should affect the tempo of the sequencer, but the score can contain tempo changes so when playing the sequencer should affect the slider position. A solution should be modeless. One approach is to add guards, for example:               function handleTempoChanged(tempo) {         if (this.tempo == tempo) return;         ...     }      This works but feels like a poor solution because it means every event handler needs to either assume it needs a guard, which is ugly boilerplate and often not required, OR needs to be aware of the other components in the system that would make a cycle possible. Arguably, this point is wrong, guards should always be used _if_ the handler is going to fire a changed event directly or indirectly, but this still feels like boilerplate logic. This may be the only answer to my question... Is there general case pattern to deal with potential cycles as described? Note that this is _not_ about synchronous vs. asynchronous; either way the cycles can occur. EDITED to reflect insight from commenters: I realize it is possible to eliminate the boilerplate, using some sort of mixin. In pseudo-code:               class ObservablePropsMixin:              // generic setter with gaurd         function set(propName, value):             if this[propName] = value: return             this[propName] = value             _fire(propName, value)               // generic method to add listeners         function observe(propName, handler):             _observers[propName].add(handler)                  // private event dispatching method         function _fire(propName, value):             foreach observer in _observers[propName]:                     observer.call(propName, value)              ...      This is simplified to focus on my question, but a real mixin would implement other pubsub or event or signal semantics, analogous to any event dispatcher implementation. Components needing to be observers or observables would inherit/extend from the mixin (the above assumes some form of multiple or aggregate inheritance is possible in the language. This could be modified to work with composition instead, e.g. ObservableMixin.constructor(observedObject) rather than using "this".


title: Including front end designers in enterprise web development

text: We are developing a web application using Java EE. The stack is heavy, the deployment is complex and now we want to include a purely CSS designer in the team. We want to include this designer without having him have to understand the build and deployment of our application. We want him to be included in the projects version control. What is an effective way of allowing a designer to work without being exposed to to the rest of the project? Simply working from browser inspectors is insufficient, as it does not give him the ability to upload images.


title: How do random number generators work?

text: I am a Programmer out of Oregon, I currently work as a web developer for a local company, and am starting college this winter for Computer Science. I was just pondering about php `rand()` function, and thinking about how I could remake it, and I came up completely stupified. How the heck do random number generators work?


title: What is the difference between SOAP and Web Services?

text: Keep getting confused about these two. Anyone care to explain the difference(s)?


title: Developing JSON API for a Carpool Engine

text: I am developing a new set of API methods for carpooling/cab booking, so if a developer needs to develop an app or webportal for carpooling, he can call my JSON API. Basically making it easy for developers. My API current has:   * `AddVehicle`   * `AddJourney`   * `SearchJourney`   * `SubscribeToThisJourney(journey)`   * `SubscriberList(journey)` to get list of people who have subscribed for this journey   * `AcceptSubscription(subscriber)`   * `AcceptedSubcriberList`   * `SubscriberList` to get list of providers I have subscribed to I need help with replacing subscriber with something else. It's difficult to remember, and confusing when you see 3 methods that mean very different things: `SubscriberList`, `SubscribedToThisJourneyList` and `AcceptedSubscriberList`. Confusing to remember.   * One is a list of who I have subscribed to   * Who has subscribed to me   * Whose subscription I have accepted How can I name these methods to make them easier to understand and remember?


title: Game programming : C# or C++?

text: I've decided what I really want is to do game programming. So the question is, as a 18 years old who wants to learn self taught programming, what is the most suited programming language between C# and C++? (I should state that I don't care about Unix because I believe windows will be still the most used OS) I know the basics of C++, but none about C#. I know that C++ has more tutorials guides, dlls and stuff like that, while C# doesn't, but it's far easier to learn and to use for a single person to develop a program, but I've read even if the program is obfuscated it's easy to get the source of it. Well, I kinda want to focus on basic a lot first, I must say that I have a preference for C++ just because it feels more suitable to me, but I must consider that I work alone. So even if I like it, it may not be the best thing to do. I am really not sure of which one to go for, I've read a lot of threads on various websites and it looks like C# is becoming more popular than C++. But yeah, that said, I also specified I want to do game programming. So I need to know some better points than just "C# is easier because of .net memory handling while C++ isn't" because I couldn't just find it.


title: DB Schema for packaging products / services together under a single pric / Offer

text: I'm trying to 'conceive' the business logic of this website that have many activities, that the users can build their "combo" and get discounts depending on their choices and how long they are willing to pay for their plan (1, 3, 6 and 12 month plans). I'm having a hard time trying to come up with a solution, while keeping the database normalized and with proper relations, without having to resort to JSON encoded data in the database fields. The system must stay generic enough to fit many businesses types that relies on plans / activities. **I need to know how to do the structure of my tables**. Scenario: For example, in case of a gym, will have bodybuilding, yoga, boxing, body pump. If the person choose bodybuilding and boxing, they will have a discount, if they add yoga, boxing and bodybuilding will keep the discount but will add the yoga without any discount to the price, but if the person decides to pay 12 months upfront, they will get a bigger discount. Bodybuilding + Body Pump   * `Bodybuilding..$70 | 28% discount`   * `Body Pump.....$70 |`   * `Total.........$100`   * `1 month - $100 / month`   * `3 months - $91 / month`   * `6 months - $75 / month` Bodybuilding + Body Pump + Yoga   * `Bodybuilding..$70.00 | 28% discount`   * `Body pump.....$70.00 |`   * `Yoga..........$90.00 | No discount`   * `Total.........$190`   * `1 month - $190 / month`   * `3 months - $171 / month`   * `6 months - $158 / month` I'll be using PHP and MYSQL, but that doesn't matter much, only the RDBMS part. * * * **Edit for clarification:** What I really looking for is a DB Schema for Packaging products (or in this case services) together under a single price\Offer. Each product must also exist in the systems as a stand alone product. I Still need the ability to report on sales (& Profit) by product even if that product was sold as part of a package. I would Need the ability to report on Package performance.


title: Having error codes option in C++ library for performance

text: I have written an open source and cross-platform C++ File Library which have exception and error codes. Exceptions can be disabled when the program is running. In that case, the user have to check the error codes. Of course, when exception throwing is enabled, error code won't be returned because exception is thrown before the called function returns. Currently, exceptions still could be thrown when disabled (bug). I'll fix that soon. Someone comment to me that it is considered bad design to have both exception and error codes. I agree with him and I am about to remove the error codes and have library throw custom derived exceptions with more error information. But I hesitate. I like to have this hybrid approach for performance reasons. This is what I am thinking of doing: keeping exception throwing and error codes but exception throwing is disabled through macro at compile time instead of runtime. If user define the following in a common config file               #define ELMAX_EXCEPTION 1      The follow code               int Write(std::wstring str) ELMAX_THROW_OR_NOT;      would expand to either of the 2.               // under C++11 compiler     int Write(std::wstring str) noexcept;          // under C++98 compiler     int Write(std::wstring str) throw();      If `ELMAX_EXCEPTION` is not defined or is zero, the macro would expand to nothing.               int Write(std::wstring) ;      The reason I want to do this, is for library user who wants the performance gain of not having the compiler generating the stack unwinding code (for exception) and compiler can better optimize such functions. My C++ file library is using C file API and the only thing which could throw exception is `new` keyword, which I intend to add `nothrow`. The UTF-8 code can also throw exceptions (need to be changed too)               char *parr = new (nothrow) char[num];          if(parr==NULL)         // handle it either through error code or throw exception (if enabled)      Please kindly advise if I should have a pure exception approach or a hybrid approach (as mentioned), for my library errors?


title: IUserType like feature inEntity Framework

text: I'm working on a new project, we want to build a new, modern, application working with our legacy data sources, and especially, legacy databases. We want to use an ORM and we want advanced features so the obvious choice seems to be between NHibernate and EF 6. We can eventually make some minor changed to the databases but not totally modified the model since it's used by many other apps. Now, obviously since it's legacy stuff, it sucks. The database has many flaws and at the moment, I'm writing some basic code to test EF and NH and see if we can work around these flaws. My current problem is with Entity Framework. In my database, many fields are used in a "non-standard" way. For example, I have fields that are representing datetime with special format strings, or xml data in string. I'd like to let EF do the convert work without exposing these special fields to my API and without using another layer on top of EF. I could solve this problem with IUserType in NHibernate but I didn't find a way in EF. Here's an example, let's say I have a field representing a date in my DB, and it should be formatted like this : ddmmyy (090214 for today). I don't want to expose this string in my object but I want to be able to manipulate this date with classical datetime like : var comp = ctx.Companies.First(c => c.Id == 1); comp.Date = DateTime.Now; ctx.SaveChanges(); And it automatically saves the date with the special format in the DB. I can do this by mapping a DateString property for example and makes my Date field with a getter/setter that do the transform but I don't want to expose this DateString property and it's a bit painfull to do it with all my Date fields across all my tables. IUserType in Nhibernate was perfect to solve this kind of problems, is there something equivalent in EF? Thanks


I looked at it in my field of work, which is film and pretty much every software we use comes with python as a scripting language: http://en.wikipedia.org/wiki/List_of_Python_software That made me assume it's the most popular. How did Python become popular as a scripting language? Especially as an embedded language into standalone applications. What's the reason for this? There are others like Lua, Ruby, etc. but yet it looks like Python came on top. If it's because of a particular thing or just a matter of getting out there at the right time?


title: Memory management for fast message passing between threads in C++

text: Suppose there are two threads, which communicate by asynchronously sending data messages to each other. Each thread has some kind of message queue. My question is very low level: What can be expected to be the most efficient way to manage the memory? I can think of several solutions:   1. Sender creates the object via `new`. Receiver calls `delete`.   2. Memory pooling (to transfer the memory back to the sender)   3. Garbage collection (e.g., Boehm GC)   4. (if the objects are small enough) copy by value to avoid heap allocation completely 1) is the most obvious solution, so I'll use it for a prototype. Chances are that it is already good enough. But independent of my specific problem, I wonder which technique is most promising if you are optimizing for performance. I would expect pooling to be theoretically the best, especially because you can use extra knowledge about the flow of information between the threads. However, I fear that it is also the most difficult to get right. Lots of tuning... :-( Garbage collection should be quite easy to add afterwards (after solution 1), and I would expect it to perform very well. So, I guess that it is the most practical solution if 1) turns out to be too inefficient. If the objects are small and simple, copy by value might be the fastest. However, I fear that it forces unnecessary limitations on the implementation of the supported messages, so I want to avoid it.


title: What is Java's primary focus? Why does it take so long to get new features?

text: I have been exploring the new features in the JDK8, like the lambda expressions, the extension methods, and the new stream API. Evidently none of these features are new in the programming world and that made wonder why are getting all these things in Java until now. We had lambda expressions in Lisp (1958), SML (1973), Haskell (1990), Python (1991), JavaScript (1994), Ruby (1995), Scala (2003), C# (2007) and 55 years after Lisp and practically everyone else, in Java (2013). And I had read about streams in SIC (1996). I have been wondering why now? The evidence suggests that competing with other languages is not the motivation. It would seem that all the cool new features in this release of Java are just a by-product of implementing parallelism. We have lambdas because they make writing parallel algorithms simpler, and we have extension methods because we needed them to give support to the changes that lambda expressions required, etc., etc. So, my question is: can we safely affirm that the main topic in this upcoming release of Java is actually parallelism? Or can we justify other reasons for the appearance of the oldest tricks in the book until now in Java?


title: Brittle unit tests due to need for excessive mocking

text: I've been struggling with an increasingly annoying problem regarding our unit tests that we are implementing in my team. We are attempting to add unit tests into legacy code that wasn't well designed and while we haven't had any difficulty with the actual addition of the tests we are starting to struggle with how the tests are turning out. As an example of the problem let's say you have a method that calls 5 other methods as part of its execution. A test for this method might be to confirm that a behavior occurs as a result of one of these 5 other methods being called. So, because a unit test should fail for one reason and one reason only, you want to eliminate potential issues caused by calling these other 4 methods and mock them out. Great! The unit test executes, the mocked methods are ignored (and their behavior can be confirmed as part of other unit tests), and the verification works. But there's a new problem - the unit test has intimate knowledge of _how_ you confirmed that behavior and any signature changes to any of those other 4 methods in the future, or any new methods that need to be added to the 'parent method', will result in having to change the unit test to avoid possible failures. Naturally the problem could be mitigated somewhat by simply having more methods accomplish less behaviors but I was hoping there was perhaps a more elegant solution available. Here's an example unit test that captures the problem. **As a quick note 'MergeTests' is a unit testing class that inherits from the class we are testing and overrides behavior as needed. This is a 'pattern' we employ in our tests to allow us to override calls to external classes / dependencies.**               [TestMethod]     public void VerifyMergeStopsSpinner()     {         var mockViewModel = new Mock<MergeTests> { CallBase = true };         var mockMergeInfo = new MergeInfo(Mock.Of<IClaim>(), Mock.Of<IClaim>(), It.IsAny<bool>());              mockViewModel.Setup(m => m.ClaimView).Returns(Mock.Of<IClaimView>);         mockViewModel.Setup(             m =>             m.TryMergeClaims(It.IsAny<Func<bool>>(), It.IsAny<IClaim>(), It.IsAny<IClaim>(), It.IsAny<bool>(),                              It.IsAny<bool>()));         mockViewModel.Setup(m => m.GetSourceClaimAndTargetClaimByMergeState(It.IsAny<MergeState>())).Returns(mockMergeInfo);         mockViewModel.Setup(m => m.SwitchToOverviewTab());         mockViewModel.Setup(m => m.IncrementSaveRequiredNotification());         mockViewModel.Setup(m => m.OnValidateAndSaveAll(It.IsAny<object>()));         mockViewModel.Setup(m => m.ProcessPendingActions(It.IsAny<string>()));              mockViewModel.Object.OnMerge(It.IsAny<MergeState>());                  mockViewModel.Verify(mvm => mvm.StopSpinner(), Times.Once());     }      How have the rest of you dealt with this or is there no great 'simple' way of handling it? **Update - I appreciate everyone's feedback. Unfortunately, and it's no surprise really, there doesn't seem to be a great solution, pattern, or practice one can follow in unit testing if the code being tested is poor. I marked the answer that best captured this simple truth.**


title: I'm creating my own scalable, rapid prototyping web server. How should I design it?

text: I'm going to create my own web server that focuses on scalability, rapid prototyping and the use of JavaScript as the server's scripting language, much like node.js. It will use a Model-View-Controller design pattern so a web application can support more concurrent users just by adding hardware -- and not having to redesign the software. Basically, I'm aiming to produce a framework that allows for fast and easy development of cloud applications without the need to write lots of boiler plate code. I've got some questions about this...   1. How hard will it be to put MySQL in the cloud? How could I go about implementing this and make the resulting product free? Will I have to write my own engine or modify an existing one, if I do what should I watch out for?   2. To make this scalable I need to adjust from one server to hundreds of servers this creates the requirement for the servers to be load balancing, how should I do this? If I balance based on the work load per server I would need gateway to handle all the incoming requests. Is it the right idea to have all the servers check into the gateway and update there status.   3. By having the servers run through a gateway if the gateway dies all the incoming requests are ignored. I'm thinking that having all the servers maintain a list of each other, or at least a few I could rebuild the list of servers and establish a new gateway. Is it worth it? Or should I have a backup gateway that could switch out? Should I let the user choose?   4. How should I pick which server handles the database and which handles the page serving? Should I spread the database so that queries are preformed on multiple servers? Which would theoretically improve performance.   5. The servers would need to mirror the database at least once so that if a server goes down the database isn't corrupted. So this brings up writing another question, should I broadcast SQL queries so that all the servers can take a bit of the work load? If I do it that way wouldn't a query clog up the network so that other queries couldn't be preformed? What are my alternatives?   6. Finally, is there a free solution already out there that might need a little modification that suits my needs?


title: Which string search algorithm is actually the fastest?

text: I have been stuck for some time on which is the fastest string search algorithm, heard many opinions, but in the end I'm not sure. I have heard some people saying that the fastest algorithm is Boyer-Moore and some saying that Knuth-Morris-Pratt is actually faster. I have looked up for the complexity on both of them but they mostly look the same `O(n+m)`. I have found that in the worst case scenario Boyer-Moore has an `O(nm)` complexity compared to Knuth-Morris-Pratt which has O(m+2*n). Where n=length of text and m=length of pattern. As far as I know Boyer-Moore has a linear-worst case-time if I would use the Galil Rule. My question, Over all which is actually the fastest String search algorithm (This question includes all possible sting algorithms not just Boyer-Moore and Knuth-Morris-Pratt). **Edit:** Due to this answer What I'm exactly looking for is: Given a text `T` and a pattern `P` I have to find all the appearances of `P` in `T`. Also the length of P and T are from `[1,2 000 000]` and the program has to run under 0.15 sec. I know that KMP and Rabin-Karp are enough to get a 100% score on the problem but I for one wanted to try and implement Boyer-Moore. Which would be best for this type of pattern search?


title: Optimal storage space calculation for name, address, phone, fax and email data

text: Given the following assumptions:   * The amount of available data storage is highly limited   * All data is international    * As much storage as possible must be preserved since it will be used for something else Is there any widely accepted standard or best practice which defines how much storage should be allocated for those items? **Note** : I'm not looking for assumptions but for facts like "97.5% of all names fit into 70 bytes using UTF-8" and "An international address must at least contain field1, field2 and field3 of size1, size2 and size3". **Edit** : I'm looking for the fields/lengths to use in the user interface. Not a technique to store it efficiently.


title: How important are UML diagrams for a successful project?

text: I'm in the middle of a project and I was asked to write UML diagrams (use cases,class diagram,etc). The project isn't very complex. I was wondering if this be a waste of my time? Should I just be doing other fun stuff like writing code? And when is it not ok to build something without going through all of the conceptual phase? Is it all about complexity? And if so, how to measure it?


title: Low Latency Unix/Linux

text: Most low latency/high frequency programming jobs (based on job specs) appear to be implemented on unix platforms. In a lot of the specs they make particular request for people with "low latency linux" type of experience. Assuming this does not mean a real-time linux OS, could people give me help with what this could be referring to? I know you can set CPU affinity to threads, but I am assuming they are asking for much more to it than that. Kernel tuning? (although I heard manufacturers like solarflare produce kernel bypass network cards anyway)? What about DMA or possibly shared memory between processes? If people could give me brief ideas I can go and do the research on google. (This question will probably require somebody familiar with High Frequency Trading)


title: Difference between lexical scoping and passing variables in JS

text: There are several ways to reach the same end point in JS, for example:               (function (foo, bar) {       return {run: function () {return foo(bar);}};     } (foo, bar));          (function (foo, bar) {       return (function(foo, bar) { return {run: function () { return foo(bar); }}} (foo, bar))     } (foo, bar))          (function (foo, bar) {       var Fizz = function (foo, bar)  { this.run = function () { return foo(bar); }; };       return new Fizz(foo, bar)      } (foo, bar))      Now for these, I know that one difference is that the prototype in the third case for the returned object would be different, but other than that, all three paths lead to an object which provides the same api. And since Javascript is a duct typed language, what a thing is is usually defined by its behavior. Are there any other implications of choosing any one approach of the three that I am ignoring ?


title: Bug fixing in Scrum, at the end of the project

text: We have a project that is reaching a deadline for the final production release. It's a fixed price project and up till now we've managed to work in 2 week iterations, doing regular releases to our "inner test environment" where BAs and people acting as POs from the client's side had a chance to have a look, give feedback etc. We're now at the point where we have only 4 weeks to end this project and as we go to deploy the separate modules of this application to the client's environment, we've been struggling with a lot of bugs appearing. We have some functionality to be done still but my question is - what is the best way to handle those bugs as they appear? Since there's really a lot of them (due to project specifics, we didn't have the ability to test it on client's environment earlier) and it's impossible to estimate them up front + we have only 4 weeks till the end, does it make sense to keep Scrum or switch to Tech Lead dispatching work daily to the devs directly?


title: Will the portions of Boost that are incorporated into the new C++ standard continue to be developed?

text: What will happen to the portions of the Boost library that are incorporated into the new C++ standard? Will they continue to evolve and any changes be reincorporated into the standard which follows C++0x?


title: Is collective code ownership mandatory in Scrum?

text: Is is an absolute must when following the Scrum methodology to practice collective code ownership, instead of for example weak code ownership?


title: How does a fresher with a clean slate turn into a good programmer?

text: As a graduate fresh out of college with a clean slate, how can one go about being a good programmer who writes good maintainable code? How does one learn good coding practices and apply them? Can one get these skills by reading any specific books on Software development or is it something that comes purely from experience? (I don't like to believe that it's purely experience based since I see people here complaining about bright co-workers with years of experience writing bad code). What are some suggestions on getting good at writing clean code? Passion and ability are assumed.


title: Do Web Applications and The Cloud provide better Career Opportunities than Systems Programming?

text: As the years progress , I can't help but see how web apps and the cloud is replacing normal computer software. Developers of systems programming languages like C/C++ are going down the hill and PHP / ASP.NET(C#) is rising to the skies (cloud?). Since I am a serious C++ fan and like to develop mostly in C++, I was wondering whether it is prudent to say on this path. Will there be employment for C++ programmers after , say , 10 years? I have seen a lot of unemployed C++ programmers while there are no .NET programmers or Web Developers going downhill. So should I move to the web and/or cloud now, when there is still time, or should I continue going down the C++ path? Will there be enough employment for C++ and other Systems (offline?) Programming Language developers?


title: When is a loop "non-trivial"?

text: Is it correct to call a loop that you do not know the limit at compile time `"non-trivial"`? If you know that you will be using a value from a class that will be in a range e.g. between 0-1000, is that still non-trivial? e.g. Where ISomeInterface.MAX_LIMIT is always between 1-1000:               public bool someMethod(Type someType, int someId, int someVariable)     {         bool returnFlag = false;         int maxLimit = (Activator.CreateInstance(someType) as ISomeInterface).MAX_LIMIT;              for (int i = 0; i < maxLimit; i++) //is this a non-trivial loop?         {             if (_someSerivce.SomeOtherMethod(someType, someId, someVariable, i))             {                 returnFlag= true;             }         }         return returnFlag;     }      * * * **Edit:** Was uncertain as to whether this was a meaningful piece of terminology. I originally read it in one of Jon Skeet's pieces from yoda.arachsys: http://www.yoda.arachsys.com/csharp/stringbuilder.html (see the section headed _Rules Of Thumb_ ). Do you use this as technical terminology at all?


title: Who extends interfaces? And why?

text: AFAIK, my class `extends` parent classes and `implements` interfaces. But I run across a situation, where I can't use `implements SomeInterface`. It is the declaration of a generic types. For example:               public interface CallsForGrow {...}          public class GrowingArrayList <T implements CallsForGrow>  // BAD, won't work!                                   extends ArrayList<T>       Here using `implements` is syntactically forbidden. I thought first, that using interface inside <> is forbidden at all, but no. It is possible, I only have to use `extends` instead of `implements`. As a result, I am "extending" an interface. This another example works:               public interface CallsForGrow {...}          public class GrowingArrayList <T extends CallsForGrow>  // this works!                                   extends ArrayList<T>       To me it seems as a syntactical inconsistancy. But maybe I don't understand some finesses of Java 6? Are there other places where I should extend interfaces? Should the interface, that I mean to extend, have some special features?


title: Is inline SQL still classed as bad practice now that we have Micro ORMs?

text: This is a bit of an open ended question but I wanted some opinions, as I grew up in a world where inline SQL scripts were the norm, then we were all made very aware of SQL injection based issues, and how fragile the sql was when doing string manipulations all over the place. Then came the dawn of the ORM where you were explaining the query to the ORM and letting it generate its own SQL, which in a lot of cases was not _optimal_ but was safe and easy. Another good thing about ORMs or database abstraction layers were that the SQL was generated with its database engine in mind, so I could use Hibernate/Nhibernate with MSSQL, MYSQL and my code never changed it was just a configuration detail. Now fast forward to current day, where Micro ORMs seem to be winning over more developers I was wondering why we have seemingly taken a U-Turn on the whole in-line sql subject. I must admit I do like the idea of no ORM config files and being able to write my query in a more optimal manner but it feels like I am opening myself back up to the old vulnerabilities such as SQL injection and I am also tying myself to one database engine so if I want my software to support multiple database engines I would need to do some more string hackery which seems to then start to make code unreadable and more fragile. (Just before someone mentions it I know you can use parameter based arguments with most micro orms which offers protection in most cases from sql injection) So what are peoples opinions on this sort of thing? I am using Dapper as my Micro ORM in this instance and NHibernate as my regular ORM in this scenario, however most in each field are quite similar. What I term as _inline sql_ is SQL strings within source code. There used to be design debates over SQL strings in source code detracting from the fundamental intent of the logic, which is why statically typed linq style queries became so popular its still just 1 language, but with lets say C# and Sql in one page you have 2 languages intermingled in your raw source code now. Just to clarify, the SQL injection is just one of the known issues with using sql strings, I already mention you can stop this from happening with parameter based queries, however I highlight other issues with having SQL queries ingrained in your source code, such as the lack of DB Vendor abstraction as well as losing any level of compile time error capturing on string based queries, these are all issues which we managed to side step with the dawn of ORMs with their higher level querying functionality, such as HQL or LINQ etc (not all of the issues but most of them). So I am less focused on the individual highlighted issues and more the bigger picture of is it now becoming more acceptable to have SQL strings directly in your source code again, as most Micro ORMs use this mechanism. Here is a similar question which has a few different view points, although is more about the inline sql without the micro orm context: http://stackoverflow.com/questions/5303746/is-inline-sql-hard-coding


title: How can I justify my disclaimer of warranties license to a customer?

text: I'm selling a software that lets users manipulate critical information. In my licence contract (redacted by a lawyer specialized in this field), I've got a standard clause reading : > THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED > WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF > MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO > EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, > PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; > OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, > WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR > OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF > ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. I've seen equivalents in almost every single software I've been using so far. So far, all of our clients accepted that without difficulty, but now one potential client is contesting it. Actually he's telling me something along the lines of : > You mean that if I use your software to buy something at $10 to a third > party company, and there's a bug in your software (as you don't guarantee > there aren't any), and you transmit a $20 order, I shall pay the $10 > difference, not you? I'm a bit stuck between what seems like common sense on his part, and the fact that my insurance companies would probably not insure me for those kind of risks, and if you consider we're talking millions, not plain $, it doesn't feel comfortable being responsible for that kind of potential losses. So far, the best answer I've come up with is that everybody does it in the industry (Microsoft doesn't guarantee that the mail you've sent using Outlook won't be altered, eg by turning all the $10's in $20's ...) Any advice on how to handle this ? (apart from doing our best to ship bug-free software, of course :p)


title: Should programmers help testers in designing tests?

text: How much should programmers help testers in designing tests? I don't think they should help at all. My worry is that if they help testers in designing tests for their own code, they'll 'infect' the testers with their own prejudices and blind spots about that code. I feel that the requirements should be sufficient for giving the information needed for testers to create their tests. If there is some part of the implementation that the programmers find worrisome, then I think it's their duty to implement unit tests to test that part or even run their own informal system tests to test that part. Not everyone I know agrees with this though (and I understand some of their points to a certain extent). What do others think about this? Is this discussed in the literature anywhere?


title: Should we be using functional and/or logic programming languages more?

text: I've programmed a bit of Haskell and Prolog as part of a couple of uni courses, but that's about it. And I've never seen it been used in industry (not that I've had much of working experience to begin with but I've never seen an ad where you are required to know them). So should we be using functional and/or logic programming languages more often? Are there any advantages or disadvantages for using or not using them?


title: Store the result of a complex but frequent database query, in another temp persisting table

text: I have a slightly complex SELECT query which uses a number of JOINs and variables inside it and the query is run frequently throughout the application. The result varies when one column is updated. Eg: When the product quantity is updated only, the result set changes. So my question is, is it a good idea to run a trigger and update a temporary table in the database, with my SELECT queries results, whenever the product quantity is updated? Or to run the complex SELECT query every time? Right now I tested with ~10 rows of data and the query execution time is 0.001 seconds. I want to use the best possible method which won't hinder the performance as the DB grows. Thank you!


title: What are the rules for permissible names on google app engine?

text: When I create a new application, and I am choosing a name, most common dictionary words appear to be unavailable, along with even some of the more esoteric ones including 'aaaaaa' (I've tried variable length, and different letters). However, most of these applications don't actually seem to exist. So either all of these names have been taken, but none of these people have bothered to build even a hello world app on it, or there are additional naming rules that app engine enforces beyond > Application Identifier must be between 6 and 30 characters. Lowercase > letters, digits, and hyphens are acceptable characters. Leading and trailing > hyphens are prohibited. I'd like to rule out the later -- are there any additional naming rules that GAE imposes?


title: What is the one bit of computer science theory I should know?

text: Speaking as someone with an Electronic Engineering rather than Computer Science degree, what is the **one bit** of computer science I should know to make me a better **real world** programmer? (By real world I mean something I'm going to use and benefit from in my day to day job as a programmer - for instance I'd suggest understanding database normalisation is of more practical use than understanding a quick sort for which there are lots of libraries).


title: How do you avoid disrupting the flow of work when the Product Owner asks for a release?

text: My team has been using Scrum for years with a goal to deliver a potentially releasable build each sprint. We recently started using a Kanban board moving away from time-boxed delivery to feature-boxed delivery. So far, this seems to better fit the teams natural way of working. With feature-boxed delivery, stories are pulled from the backlog when an individual feels they are comfortably ready to begin working on it. The teams average story lead time is three weeks. So, theoretically, at the moment the product owner asks for a release, the team should be able to deliver it three weeks later. When the PO sets the "stop development" trigger, individuals who have time are supposed to start helping with stories already underway to begin clearing out the board. The people freed up first are typically the "front-end" folks... Those more skilled at analysis and development. They are typically asked to help with back-end work, like system testing. The teams work flow, or cadence changes each time the stop trigger is set. What do you do to minimize this change and keep the team working as efficiently as possible? How do you avoid the disruption caused by the Product Owner asking for a release?


title: Correct pattern for Worker Processes involving Queues & Tables

text: Edit: OK, so, people said it is unclear what I am asking. I am asking for feedback on this design. Here is an example user story: As a group admin on the website I want to be notified when a user in my group uploads a file to the group. Easiest solution would be that in the code handling the upload, we just directly create an email message in there and send it. However, this seems like it isn't really the appropriate level of separation of concerns, so instead we are thinking to have a separate worker process which does nothing but send notifications. So, the website in the upload code handles receiving the file, extracting some metadata from it (like filename) and writing this to the database. As soon as it is done handling the file upload it then does two things: Writes the details of the notification to be sent (such as subject, filename, etc...) to a dedicated "notification" table and also creates a message in a queue which the notification sending worker process monitors. The entire sequence is shown in the diagram below. My questions are: Do you see any drawbacks in this design? Is there a better design? The team wants to use Azure Worker Roles, Queues and Table storage. Is it the right call to use these components or is this design unnecessarily complex? Quality attribute requirements are that it is easy to code, easy to maintain, easy to debug at runtime, auditable (history is available of when notifications were sent, etc...), monitor-able. Any other quality attributes you think we should be designing for? Original: We are creating a cloud application (in Azure) in which there are at least 2 components. The first is the "source" component (for example a UI / website) in which some action happens or some condition is met that triggers a second component or "worker" to perform some job. These jobs have details or metadata associated with them which we plan to store in Azure Table Storage. Here is the pattern we are considering: ![enter image description here](http://i.stack.imgur.com/fLIs4.png) Steps:   1. Condition for job met.   2. Source writes job details to table.   3. Source puts job in queue. Asynchronously:   1. Worker accepts job from queue.   2. Worker Records DateTimeStarted in table.   3. Queue marks job marked as "in progress".   4. Worker performs job.   5. Worker updates table with details (including DateTimeCompleted).   6. Worker reports completion to queue.   7. Job deleted from queue. Please comment and let me know if I have this right, or if there is some better pattern. For example sake, consider the work to be "sending a notification" such as an email whose template fields are filled from the "details" mentioned in the pattern.


title: How do I overcome paralysis by analysis when coding?

text: When I start a new project, I often times immediately start thinking about the details of implementation. "Where am I gonna put the DataBaseHandler? How should I use it? Should classes that want to use it extend from some Abstract superclass..? Should I use an interface? What level of abstraction am I going to use in my class that contains methods for sending requests and parsing data?" I end up stalling for a long time because I want to code for extensibility and reusability. But I feel it almost impossible to get past thinking about how to implement perfectly. And then, if I try to just say "screw it, just get it done!", I hit a brick wall pretty quickly because my code isn't organized, I mixed levels of abstractions, etc. What are some techniques/methods you have for launching into a new project while also setting up a logical/modular structure that will scale well? - _-_ EDIT - _-_ Well, this is already the type of question that is difficult to accept an answer to, but wanted to get some more feedback, see if there's some consensus. TDD sounds really cool and, frankly, I've been meaning to get more up to speed on using JUnit, etc. At the same time, what do the fans of TDD think about the fact that one legitimate point with relation to TDD solving my particular issues, is that TDD doesn't really seem to address the question of design. Sure, I agree TDD will help me define what I want to do and then I can gradually work through the how, but there are many different overall design patterns/structures that could all pass through unit testing. That's just it: it tests single UNITS. I guess I'm a bit confused... I dunno. Maybe I'm just trying to procrastinate even more by trying to figure out some magical formula, but I would like to hear how some of the veterans approach this area... Thanks!


title: Creating an Interface To a Language's Standard Library?

text: In the process of learning test-driven development, I've been introduced to dependency injection and the use of interfaces, and have started using these concepts in my own PHP code in order to make it more testable. There have been times when I've needed to test code that was doing things like calling the PHP `time()` function. In order to make these tests predictable, it seemed logical to create an interface to the standard PHP functions I use so that I can mock them out in my tests. Is this good software design? What are the pros and cons of doing this? I've found myself groaning at how quickly my PHP interface can stick its fingers into everything I do. Is there a better way to make code that relies on PHP- accessed state and functions more testable?


title: Does FitNesse improve product quality and collaboration?

text: I heard about a tool named FitNesse, which is supposed to promote better collaboration between development, testing, and product groups. What are your experiences with it? Does it really improve program quality? Are there any drawbacks to using it?


title: Generating tests from specification

text: I am reading "The Pragmatic Programmer" . The book has the following paragraph > Dave once worked on an international telex switch. Quite understandably, the > client demanded an exhaustive test specification and required that the > software pass all tests on each delivery. To ensure that the tests > accurately reflected the specification, the team generated them > programmatically from the document itself. When the client amended their > specification, the test suite changed automatically. Once the team convinced > the client that the procedure was sound, generating acceptance tests > typically took only a few seconds. I am curious to know how he created tests from specification . What format was the specification in ? How to write a program that will automatically read the specification and write test cases. Have I misunderstood the above paragraph ?


title: How do you overcome your own coding biases when handed legacy code?

text: As programmers, we often take incredible pride in our skills and hold very strong opinions about what is 'good' code and 'bad' code. At any given point in our careers, we've probably had some legacy system dropped in our laps, and thought 'My god, this code sucks!' because it didn't fit into our notion of what good code should be, despite the fact that it may have well been perfectly functional, maintainable code. How do you prepare yourself mentally when trying to get your head around another programmer's work?


title: What would be the most efficient way to reduce the complexity of a set of rotations to a cube?

text: Despite the long title, my question is fairly simple. Let's say you have a cube in 3D-space and you want to rotate it along the three axes based on the set of instructions provided by a user or elsewhere in the program. How would you simplify, if you will, that set of rotations? For simplicity's sake, we'll use the notation involved in rotating a Rubik's cube. (And also because that's what I'm programming.. But that's unimportant.) So, X would be a clockwise rotation along the X axis, X' would be a counterclockwise rotation along the X axis, and X2 would be two clockwise rotations rotations along the X axis. Now, let's say I have a set of instructions `X Y X'`. That set of instructions did the same thing that the single instruction of `Z` would have done. Or, in a simpler case, if I had `X X'` or `X2 X2`, those rotations cancel out. My question is, what is the best way - from a programming perspective - to simplify these sets of instructions?


title: Web Services exposed by url

text: Lets take some random internet site which i am not aware of any API it exposes for it's web services if there are any , is there a way to query that URL for exposed web services ?


title: Is it advisable to create an ad-hoc open source software license?

text: IANAL I have several private projects that I _might_ be needed to show to my prospective employers. I haven't uploaded them to any online version control system because not only do I not have the patience to filter the many many licenses available and choose the most appropriate one (as I am not yet sure how I would want my open source code to be used), I also feel the projects aren't fit enough for upload in public domain as they are not tested rigorously enough for me. I could create a private repository somewhere and allow access to the prospective employers, or I could simply take a USB stick with me, but the question still remains about licensing. So, I thought of creating an ad-hoc license to the effect of saying "this code is made available to you and no part of it shall be reproduced from memory...", which is almost like signing a NDA. I know it might sound silly, or inane, but I want to protect my IP in someway (you never know what your code could become!). What is the best way of going about this? If indeed license creation is an option, how would the creation work? Would merely writing a prologue at the beginning of every source file suffice, or is there some long winding legality involved?


title: State Pattern Code for embedded device - Dependency Injection of Device Objects in Context and State Classes

text: I'm wrestling with some code and I think I've finally gotten some state pattern code working with my events. I've got a _simplified_ system that will work like this: ![State Diagram](http://i.stack.imgur.com/LzxdG.jpg) This is my first go with State Pattern code and the examples I found were too simple or just not related to my type of device. **Q:** Is the context class supposed to do all of the controlling of peripherals of the device or should the active state directly control them? For instance, Drive the display, read the sensors, etc. To me, either way would work, but don't have enough experience here to choose what's correct. I mention DI because I'm having to pass all of my peripherals into the context then into each state to provide control. OR do I just pass them into context and make the calls to the context from the active state(mentioned above)? The way I see it, the active state and the context are constantly communicating with each other via DI to control the device. I hope this is clear. Context Class Code:               //context     //the context will capture the interrupt events and delegate the response     class ModeContext     {         private int rotationCount;         private string direction;         private State state;         public RotaryEncoder rotaryEncoderInstance;         public Tlc5940 Display;              //public event NativeEventHandler rotationEventHandler;// = null;              public ModeContext(RotaryEncoder re, Tlc5940 display)         {             this.State = new Mode1(this);             rotaryEncoderInstance = re;             rotaryEncoderInstance.RotationEventHandler += OnRotationEvent;//attach to Context's Handler             rotaryEncoderInstance.MomentaryButtonEventHandler += OnButtonEvent;             Display = display;             rotationCount = 0;         }              public void RunStateTask()         {             state.MainTask(this);         }              public State State         {             get { return state; }             set { state = value; }//debug state change         }              //Event Handler                 public void OnButtonEvent(uint clickCount, uint zero, DateTime time)         {             switch (clickCount)             {                case 0:                                                     state.OnButtonHold(this);                             break;                case 1:                             state.OnButtonSingleClick(this);                             break;                //default:                //             throw new Exception("Something went wrong!");                //             break;                  }                   }              public void OnRotationEvent(uint data1, uint data2, DateTime time)         {             rotationCount++;             if (data1 == 1)              {                  direction = "Clockwise";                 state.OnCWRotationEvent(this);             }             else             {                  direction = "Counter-Clockwise";                 state.OnCCWRotationEvent(this);             }             //Debug.Print(rotationCount.ToString() + ": " + direction + " Context Mode Rotation Event Fired!");         }          }      Example State Class:               class Mode1 : State//, IDisposable     {              public Mode1(ModeContext mode): base(mode)         {             Display = mode.Display;            }              public override void MainTask(ModeContext mode)         {             Debug.Print("Mode1 Main Task Running...");             //read Sensor             //display the value to Display             //let the context determine how to display it??             //or call a method in the context that encapsulated all of it's functions?             //Thread.Sleep(500);         }              #region event handlers         public override void OnCCWRotationEvent(ModeContext mode)         {             //change state             mode.State = new Mode2(mode);             Debug.Print("Changing State");         }         public override void OnCWRotationEvent(ModeContext mode)         {             //change state             Debug.Print("Changing State");             mode.State = new Mode0(mode);         }         public override void OnButtonSingleClick(ModeContext mode)         {             Debug.Print("Mode1: Single Click!");         }         public override void OnButtonHold(ModeContext mode)         {             Debug.Print("Mode1: Press and Hold Detected!");         }              #endregion               }


title: Multiple remote views of a C# application

text: I have a C# application (Desktop based application for Windows OS), which I wanted to use from Web browser. The application is a kind of analyzing tool, which takes some input values and performs set of calculations over it then displays an animation of the results. Since the application can't be coded again in a new language, Can anyone suggest me, how I can view and interact with this C# application from browser (like the way we interact with Java Applets)? Also the application can be used by more than one user at a time, so there must be multiple views for this web application.


title: Small companies and software licensing

text: Small companies with small budgets may not have have the money to invest in expensive software licenses that they may need for a given development project. This is even more so if the project was a loss-leader to drum up more business and the price of the development product cannot be renegotiated without potentially harming relationships, when it is discovered later that some proprietary expensive software license is needed for a very small yet crucial part of the application. I have dealt with this in the past by cleverly using trial versions of software in potentially unethical ways just trying to delay or prevent purchasing the license. What creative ways do smart software engineers work around this problem when the money to invest would be hard to acquire without breaking laws or stealing? **UPDATE:** To give some context of a situation where free or open source isn't available, you have a signature pad peripheral device that comes with an integration plugin to Adobe Acrobat Professional. To use this device properly a PDF needs to be created with Acrobat and its accompanying plugin. The trial works fine for creating the PDF but what happens if the customer wants to modify the PDF a year from now? You basically just punted that problem down the road.


title: Can I use aac in an commercial app for free?

text: I was wondering if I can use the aac codec in my commercial app for free (through lgpl ffmpeg). It says on the wiki: > No licenses or payments are required to be able to stream or distribute > content in AAC format.[36] This reason alone makes AAC a much more > attractive format to distribute content than MP3, particularly for streaming > content (such as Internet radio). However, a patent license is required for > all manufacturers or developers of AAC codecs.> For this reason free and > open source software implementations such as FFmpeg and FAAC may be > distributed in source form only, in order to avoid patent infringement. (See > below under Products that support AAC, Software.) But the xSplit program had to cancel the AAC for free members because they have to pay royalties per person. Is this true (that you have to pay per each person that uses aac)? If you do have to pay, which company do you pay to and how does one apply?


title: Question regarding approach to programming and testing

text: I have read somewhere that the cost of resolving bugs increases if it is not resolved at the initial stage. My question is: Which approach should I take while creating programs:   1. Divide program development in modules. Complete coding one module. Fix ALL bugs of that module before starting coding other modules.   2. Divide program development in modules. Complete coding all modules. Then start fixing bugs in the whole program. Please let me know your experiences in which approach you found better.


title: More productive alone than in a team?

text: If I work alone, I used to be superproductive, if I want to be. Running prototypes within a day, something that you can deploy and use within a few days. Not perfect, but good enough. I also had this experience a few times when working directly with someone else. Everybody could do the whole thing, but it was more fun not to do it alone and also quicker. The right two people can take an admittedly not _too_ large project onto new levels. Now at work we have a seven person team and I do not feel nearly as productive. Not even nearly. Certain stuff needs to be checked against something else, which then needs to also take care of some new requirement, which just came in three days ago. All sorts of stuff, mostly important, but often just a technical debt from long ago or misconception or different vocabulary for the same thing or sometimes just a not too technically thought out great idea from someone who wants to have their say, and so on. Digging down the rabbit hole, I think to myself, I could do larger portions of this work faster alone (and somewhat better, too), but it's not my responsibility (someone else gets paid for that), so by design I should not care. But I do, because certain things go hand in hand (as you may experience it, when you done sideprojects on your own). I know this is something Fred Brooks has written about, but still, what's your strategy for staying as productive as you know you could be in the cubicle? Or did you quit for some related reason; and if so where did you go?


title: Why should I use a web framework's template language over python's templating options?

text: I'm coming from a python CGI background and was wanting to move into something more contemporary and think I have decided upon `web.py` as the framework I would like to use. In regards to templating, previously I used formatted strings and the `string.Template` module to effect most of my templating needs. After reading through a few of the templating options I have heard mentioned, I began wondering what the main benefits of using something like the `Django` or `jinja` templating options over "native" Python templating options were? Am I just going to be replacing `$tmpl_var` with `{{ tmpl_var }}` and `s.substitute(tmpl_var=value)` with `t.render(s)`, i.e., alternate syntax? or will I gain additional advantages from using these templating systems?


title: Anyone know of any parallelizing compilers following the approach of the Dragon Book?

text: In _Compilers: Principles, Techniques, & Tools_, Aho _et al_ describe an approach for optimizing for parallelism (chapter 11 in the second edition). Is anyone aware of any existing compilers which follow that approach?


title: Is rapid prototyping incompatible with software requirements specification?

text: From what I've learned last term on SWE courses, a big part of it is writing documents, so it seems that a software requirements specification (SRS) should earn points for my end-of-course project. However, I will be more comfortable if I use prototyping, i.e., I make a small thing that works for the most trivial of situations and gradually add up features and improvements. LVS 68:1996 doesn't seem to recommend mixing these two things together. Is it possible to still maintain my preferred approach to development, and have some usable requirement specification document?


title: Git, rebase and stay synced with remote branch

text: I have something of an annoyance in my Git workflow. I do the usual thing where I branch off master, into a branch called feature. I work on this feature branch for a while, meanwhile possibly master has commits of its own, which I might merge into feature. As I do this, I have a remote branch for feature (origin/feature) that I use so I can build and run my code on multiple machines. Now, when I finish with the feature branch, I need to push the code to our code review system. This means rebasing feature off master, and squashing all the commits into one. I do this, resolve conflicts if necessary, great. Here's the problem: feature and origin/feature now have different histories, and I'm not able to push. I tried push with -f to force it even, and this did not work either. Is there some convenient way to rebase feature off master, and keep feature and origin/feature synced? What I'm considering is doing another branch for the code review. In other words, before the rebase and squash, branch into featurecodereview. Then rebase featurecodereview off master, and if I like I can push this upstream to a new remote branch. I was wondering if there was something cleaner than opening another branch.


title: How to Detect Sprites in a SpriteSheet?

text: I'm currently writing a Sprite Sheet Unpacker such as Alferds Spritesheet Unpacker. Now, before this is sent to gamedev, this isn't necessarily about games. I would like to know how to detect a sprite within a spriitesheet, or more abstactly, a shape inside of an image. Given this sprite sheet: ![](http://www.gotoandplay.it/_articles/2006/06/beatemup/pixel_splatter.gif) I want to detect and extract all individual sprites. I've followed the algorithm detailed in Alferd's Blog Post which goes like:   1. Determine predominant color and dub it the BackgroundColor   2. Iterate over each pixel and check ColorAtXY == BackgroundColor   3. If false, we've found a sprite. Keep going right until we find a BackgroundColor again, backtrack one, go down and repeat until a BackgroundColor is reached. Create a box from location to ending location.   4. Repeat this until all sprites are boxed up.   5. Combined overlapping boxes (or within a very short distance)   6. The resulting non-overlapping boxes should contain the sprite. This implementation is fine, especially for small sprite sheets. However, I find the performance too poor for larger sprite sheets and I would like to know what algorithms or techniques can be leveraged to increase the finding of sprites. A second implementation I considered, but have not tested yet, is to find the first pixel, then use a backtracking algorithm to find every connected pixel. This should find a contiguous sprite (breaks down if the sprite is something like an explosion where particles are no longer part of the main sprite). The cool thing is that I can immediately remove a detected sprite from the sprite sheet. Any other suggestions?


title: Microsoft Public License vs MIT?

text: I'm working with a new plugin (flexbox), and I ran into the MS-PL license, which I had not run into before. In the past, I've used mainly MIT and Apache licensed projects, so I have no idea what the main differences are with this one. Here's a link to it: http://opensource.org/licenses/MS-PL Can anyone help explain the differences to me? I'm usually wary of Microsoft, so the fact that this product comes with this makes me nervous.


title: Using a "dead man's switch" to manage time-sensitive code

text: In our software environment, we often run a/b tests, as is probably good practice. However, our environment is set up such that, in very short order, the code starts to become very crufty with dead tests. The testing registry is little more than a collection of internal wiki pages. I thought of a "dead man's switch" style of defunct code management. If you're not familiar with the term, it refers to a switch that must be reset periodically in order to keep something from triggering -- in essence, if you don't responde, the switch triggers, and whatever you wanted the switch to trigger is performed. For example, I would write some code, register it with this system in some way, and when a date of my predetermined choosing rolled around, I would get a notification that this code would be removed (automatically cleaned up) unless I intervened (manually clean up, or snooze). What are the pros, cons and viability of incorporating such a system? Is it possible or wise? What might be some alternative ways to manage code against rotting?


title: Java or c++ for math intensive graphics application?

text: Lets say my friend needs to write an incredibly math heavy application. He has thought about using C++, but he wants to write it in Java. Just how slow is Java compared to C++? His application will need to solve something like a 10000 by 10000 matix per frame, so performance is important. What should I tell him? Make it in Java or C++? And why? (He really really wants to use Java, but if the application is going to run at snail speed, he's going to be extremely disappointed.)


title: SUN Java and GPL V2 licence issue for linked applications

text: I have recently noticed that the Sun Java code has been released as GPL V2 code (see Google code repo). Does that mean that all applications written in Java and linked to Sun APIs (beans, and so on) are also in GPL ? If we strictly follow the GPL then this should be the case (Libs should be in LGPL, not GPL if we want to build proprietary software on top of it). Is there another commercial licence which can avoid such an issue ? I cannot believe this is the case. There must be an explanation on this. Regards, Apple92


title: Is creating a full application in Silverlight advisable?

text: Is creating a huge public site fully in Silverlight really advisable? for eg. an ecommerce site. I don't want to start any debate but actually I feel Silverlight shouldn't be used for full website because the biggest loss you incur is of SEO. No search engines till today can parse the xap file and index it based on it's content. You can get around it by doing ifs and thens like if Silverlight is not supported then make an Asp.Net equivalent page for it but that only doubles our effort of making application, more than anything else. Why write double code in 2 applications meant for the same purpose. If that is the only option why not create Asp.Net application only. What are your views? Thanks in advance :)


title: ASP.NET web-application example for newbies

text: I want to learn ASP.NET web-application development by example. I want to learn it from an already developed web-application that is good as a tutorial for newbies. A fully functional web application that is small but powerful enough to teach newbies the development effort required for web-application development. I am looking for some application that is made using software engineering principles and not just a code written haphazardly.


title: Are "Compile to JavaScript" Frameworks Hostile to Continuous Integration?

text: Lately we've been looking at ways to improve automated testing and related tooling of our enterprise-level GWT web app. I've realized that in some ways, GWT is a bit hostile to automated testing, mainly because of the nature of the long GWT compile times from Java to JS. This makes unit testing somewhat challenging, but it also puts some roadblocks up for testing in a CI environment. I've also found out that some of our build and deployment processes are somewhat complicated due to the nature of GWT's compile process. Is this a general problem for "compile to JS" frameworks for webapps? I don't have much experience with them, but I can see some potential problems for automated testing and continuous integration and deployment. Some issues I see:   * Long build and compile times preventing quick deployments   * Language the app is developed in != JS, preventing good unit testing   * Obfuscated JS in the actual app makes it more like a executable than a web app Are these issues present in other similar frameworks, or is this more a GWT issue?


title: High-level description of how experimental C++ features are developed?

text: Herb Sutter in a video answers a question about the concepts proposal considered for C++11 and from his remarks it sounds like multiple groups offered prototype implementations but all of them left concerns about slow compile times. The comment surprised me because it suggests that, at least in some cases, the prototypes being developed are not just proofs of concept -- they're even expected to perform. All the work that must take has me curious. For mature languages, especially C++, how are experimental language features developed? Is it much different from developing a compiler that implements a standard? Does a developer have a sense of if it will work and perform or even if it ever could? What are the most time consuming parts and are any parts surprisingly easier than one might expect? The question is not what does the C++ standards committee do, but rather the part that comes before. When an experimental implementation for a proposal is being put together and there aren't any completely solidified rules, how is the sausage made? I'm not a professional compiler developer nor do I expect answers with step by step accounts. I'd like a high-level idea of how this would be done or if there are any general patterns at all. I don't know what to expect from the answers but even if there are no rules to the process and the small number of people who do this just cowboy it and then, for stuff that worked out, write up the "official version" as a proposal, that answer would still be informative.


title: Is ATL a deprecated language?

text: I currently developing some M2M-transformations with the Atlas Transformation Language (ATL). During studying the language constructs and properties I have often read, that ATL is a prototype for QVT, but was not used for QVT. This leads me to the question, if ATL is a deprecated language. Personally, I claim that ATL is not deprecated because there are some indications for this:   1. If I look at the website of ATL the last Update was August, 26th 2011. The first specification of QVT was 2008. So I think the development of ATL seems to proceed.   2. There are also some papers since 2011 on google scholar: http://scholar.google.de/scholar?q=atl+m2m&btnG=&hl=de&as_sdt=0&as_ylo=2011   3. It is still part of the M2M-frameworks of Eclipse What would you say? Would it be better to user another M2M language or is ATL future proof? If not, do you know possibilities to transform ATL into other M2M-languages?


title: Load Balancer impact on web development

text: This question has it's roots in a SharePoint site that I am help with. ### Background on the issue I dealt with: The dev box and integration server are not setup behind a load balancer. The links were being built using the HttpRequest.Url value from the current context. Note that the links weren't relative links but full URIs. Once we deployed to testing (which has a LB, amongst other things) we received errors on the links being built since the server had an address of "http://some.site.org:999" while the address at the LB as "https://site.org" (SSL was off-loaded at the LB). The fix was easy enough by using relative URIs. ### The Question: Since this is the first site I've worked with that's behind a Load Balancer on I'm wondering if there are other gotcha's that I need to consider when developing a site behind one?


title: Caching large amount of ajax returned objects

text: I'm building an application which fetches large amount of items with ajax requests via other application API. It returns me 6k - 30k js objects which are used multiple times across various application views (sorting, filtering etc.). I would like to avoid querying API every time for such big list so I decided to cache this data somehow. I was thinking about various solutions:   * saving it to localstorage,   * using some caching library (e.g. locachejs),   * storing in js var. I'm not an expert so I would like to hear Your suggestions about each (or one of these) solution, about its pros and cons. Every help will be very appreciated.


title: event source calls methods in a interface

text: I am using Java. How does an event source like a (button in a GUI) knows which method to call in an interface? For example, I am listening to Mouse Events and have implemented a Mouse Listener interface in my class then how would the event source know whether it should call `mousePressed()`, `mouseReleased()` or some other abstract method in the in the interface? I am aware that using `addMouseListener(this)`, provides a way for the event source to call the method of an interface.


title: Learning Python is good?

text: > **Possible Duplicate:**   >  Is Python worth learning? Is it a useful tool? Recently I have seen some videos from MIT on computer programming topics. I found it's really worth watching. Especially the concepts of algorithms and fundamental stuffs. The programs were written and explained in Python. I never had looked into this language before as I learned and doing stuffs with C/C++ programming. But the cleanliness and better readability of syntax attracted me. Of course as a C++ programmer for long time it's the most readable language for me. Also I heard Python library contains solid algorithms and data-structures implementations. Can you share your experience in this language?


title: Why do so many libraries have no/poor documentation?

text: In a similar vein as the Why do many open source projects have no documentation about their design or architecture? question, I'm curious: Why are so many libraries so lacking in end user documentation? My view is this:   1. Most everyone agrees that reading source code is more difficult than writing source code.   2. Without documentation, one must read the library's source code in order to use that library.   3. Therefore, using the undocumented library is more work than just recreating the library from scratch.   4. As a result, if you want to have people use your library, you'd damn well better make sure it's documented. I know lots of developers don't like writing docs, and I'll agree it can be tedious work. But it's essential work. I'd even say it's more important that a library have good documentation than have the best programmer's interface in the world. (People use shitty libraries all the time; few use undocumented libraries) Oh, note that when I say documentation, I mean real documentation. Not Sandcastle/Javadoc/Doxygen boilerplate.


title: Consequences of not using an open source license?

text: Lets say you don't use a license for your open source project. And you don't put anything about a license anywhere in the code..is this okay to do?


title: Enforcement of returning non-null

text: We are implementing some web services, and need to ensure that some of our methods **always** return non-null values. We've investigated two ways of doing this:   * Using code contracts, and returning the default value using `Ensures` constraints on the return value.   * Using an aspect-oriented programming approach using PostSharp. Both approaches work, but I'm wondering whether there are any other approaches that we should consider. How would you enforce non-null return values? * * * Looks like there was a similar question on SO, and Jon Skeet recommends the Code Contract approach.


title: Should you bring up commercial projects in an interview?

text: I am not sure if it's a good idea or not to mention commercial software projects. Right now, I have one desktop software site selling (not enough to support myself yet) and I am not sure what is a good way to use it as a way to convey my skills and experience? Speaking of experience, I've never had a developer job. I've worked by myself developing applications with intention to sell, and one one hand I feel like if I mention this, I might come across as someone who is not serious about getting a developer job, which is not true, my mind is set on getting a developer job. Should I say I gave up the project to look for a job? Or does this appear weak? I just don't know how to tie up my involvement in self started software projects in an interview situation in a relevant manner.


title: Implementing a machine learning algorithm to detect the region of an address

text: I have 10,000 addresses from a city, which all have a region field in the database. When a new address is entered, then I want my software to automatically detect the region of the address . I think it should be implemented with some sort of machine learning algorithm. How can I do this? And with every newly inserted address, the machine should learn to detect the region of the new address. Is there any library for machine-Learning algorithms (like aforge.net for neural networks)?


title: Will there be any official LINQ like lambda based library for C++?

text: Given C++('11) has lambdas now, will there be any LINQ like higher order function library officially supported later? Is there any such library now being used in any production level code? Obviously I'm not expecting the SQL-like expression tree based LINQ query syntax in C++. I am talking about the lambda based one. So, no new language feature in needed in C++'11, just a library will do.