Proper Response to HTTP Request When Too Much Data is Requested

I'm building an API for an ad serving platform that will allow you to request tracker data for ad campaigns. Campaigns often exceed hundreds of millions of requests, which means there will be many terabytes worth of data. Therefore we need to prevent API consumers from requesting too much data at once (such that the request times out), but I'm not sure what the best practice is for doing so is. **Options I've already identified are:**   1. add an extra parameter to the request that indicates which section of the data is desired   2. truncate the data and somehow tell the client that they need to use more specific filters   3. respond with HTTP status code 413 (but this appears to be for large request bodies, not responses)   4. switching to a streaming API (like twitter's streaming APIs) **But my question is, what is the standard practice / proper response for this kind of situation?** Note: DoS attacks aren't much of a concern since this will not be a public API


High-level language to assembly

If assembly language is only a readable way to represent machine code, then why are HLLs converted to assembly first and then to machine code? Shouldn't HLLs be directly converted to machine code?


How ad retargeting works?

Recently, I read that Facebook ads are moving towards retargeting and got interested deeper into subject. Essentially, retargeting is technique advertisers use that tracks purchase intent by putting cookies into your browser and when you visit another website within ad network you will see ad for item you "wanted to buy". In order this to for, both publisher and advertiser need to work together. Publisher needs add couple of lines of javascript and publisher need to be able to read this info across sites. In most cases, javascript inserts iframe from adnetwork domain. Iframe script sets cookies for both host domain and remote adnetwork domain. However, Same Origin policy do not let iframes read/set content from parent domain. Is there something I'm missing here? Can someone explain how this technique actually works?


How to effectively share projects with other developers

I'm thinking of working with some other people on a c++ or java project. Usually for small projects, we collaborate mostly through emailing source code files back and forth, but on a larger scale, it becomes too easy for things to go wrong. I read up on version control systems such as git and it seems to fit my needs of collaboration, but the problem is that tutorials show these tools being used through the command line, which could probably become tedious very quickly. I could use the git integration included in most IDEs, but I don't know what to do in the case of working in different IDEs or more importantly on different OS's. How do most teams handle problems like this? What tools do they use? And how do they handle linked libraries? Any advice would be extremely helpful!


Would Using a PHP Framework Be Beneficial in My Context?

I've just started work at a small start-up company who mainly uses PHP to develop their front-end apps. I had no prior PHP experience before joining, and this has led to my apps becoming large pieces of spaghetti code. I essentially started by adding code to implement an initial feature, and then continued to hack in more code to implement further features – without much thought for the overall design. The apps themselves output XML to render on small mobile devices. I recently started looking into frameworks that I could use. I reckon an advantage would be that they seem to force developers to modularise their programs using good-practice design patterns. This seems great for someone in my position. The extra functions they provide, for example: interfacing with databases in such a way as to make SQL injection impossible, would be very useful too. The downside I can see is that there will be a lot of overhead for me in terms of the time taken to learn the framework itself (while still getting to grips with PHP itself). I'm also worried that it will be overkill for the scale of the apps we develop. They tend to be programs that interface with a fairly simple back-end DB, and will generate about 5 different XML screens. Probably around 1 or 2 thousand lines of code. The time it takes just to configure the frameworks may not be worth it. The final problem I can see is that developers in the company – who have to go over my code, and who do not know the PHP framework I may use – will have a much harder time understanding it. Given those pros and cons, I'm still not sure on what the best course of action will be; so any advice will be greatly appreciated.


Are some NOP codes treated differently than others?

I'm curious about this, let's say I have:               00000000001 90                              nop             00000000002 90                              nop             00000000003 90                              nop       Is it executed exactly the same as this?               00000000001 0F1F00                          nop        dword [ds:rax]      What effect would the second example have as opposed to the first?


How to avoid javascript becoming spaghetti code?

I've done quite a lot of javascript over the years and I'm using a more object-oriented approach, specifically with the module pattern. Which kind of approach do you do use to avoid a bigger code-base to becoming spaghetti. Are there any "best approach"?


Advantages of Scrum for the developers themselves?

Scrum being a project management methodology, how would you 'sell' it to the developers in a team that is reasonably happy with its current situation? It seems easy to me to explain to our Product Manager how Scrum will allow him to get regular releases, to amend requirements, and get the team to focus on the high-priority stories first. I found it easy to explain what TDD or Continuous Integration bring in a developer's day-to-day life. But how can developers be convinced to embrace Scrum? How would Scrum make their life easier?


Software Health Check Audit Template / Checklist

Does anyone know of a template / checklist that can be used to conduct a software health check. My team supports a number of legacy applications and we have been asked to present a score card to senior management on the health of the applications. The template would be used to:   * Identify you have performance or stability issues that may cause production outages, delays or financial impacts.   * Identify data, authorization or authentication security holes / shortcomings in the application / service.   * Identify the backup, disaster recovery and business continuity compliance of the application / service.   * Identify the compliance of the application / service to a reference architecture or predefined set of technical standards.   * Identify the current and required monitoring and alerting of the application / service.   * Identify the level of transaction support and potential for data corruption or error of the application / service.   * Identify licensing concerns of the application / service.   * Identify the minimum hardware requirements of the application / service.   * Identify the technology, vendor support and community support for the application / service.   * Provide a recommendation on all findings. A quick search on Google didnt seem to realize anything useful, other than this template to purchase http://www.it- checklists.com/application_health_check_toc.html


Is it possible to get into quantum computing as a hobby?

I'd like to begin working with quantum computers as a hobby. Is this possible?   1. Where can I buy a quantum (personal) computer so I can run (my) quantum computer programs?   2. What quantum computing programming languages are out there? Is there something like a compilable quantum computing programming language? Any pointers to resources, tutorials are very appreciated. I've read Quantum Computing for Computer Scientists and it's very interesting! Can't wait to begin programming.


C# Algorithms for * Operator

I was reading up on Algorithms and came across the Karatsuba multiplication algorithm and a little wiki-ing led to the Schonhage-Strassen and Furer algorithms for multiplication. I was wondering what algorithms are used on the * operator in C#? While multiplying a pair of integers or doubles, does it use a combination of algorithms with some kind of strategy based on the size of the numbers? How could I find out the implementation details for C#?


Should I switch tech.?

I am a PHP developer. I have 1 years of experience in PHP in a middle scale company. now I just realize that there is no top MNC use this technology. So for a better opportunity should I switch technologies and I should learn new technology?   Actually I am worried because I have already learned Zend and Magento... It will get totally wasted if I switch... But I have to think about my career too. :( please suggest Thanks! Richa


What are the conditions to convert BSD-licensed code to another language?

I'm in the process of writing a library in PHP, based on a Java package that comes with a BSD license. The code will obviously not be the same as the original, but most class/method names, and the in-line documentation, will be the same. Is a link the original Java library in the code documentation enough? Can I then release my code with an MIT license?


What's the word for an operation that can be applied multiple times and never change state beyond the initial application?

I'm trying to remember a word, I _think_ it's related to computational or database theory. The closest synonym is `atomic` but that's not exactly it. Basically it's a kind of computation that should produce the same result even when run multiple times in a row, meaning it doesn't create side effects for itself. I specifically ran across this word in a Stack Overflow answer about a chmod command (or some other permission related operation). Hopefully that's enough to go on. Poking around Wikipedia isn't much help.


Text search - big data problem

I have a problem I was hoping I could get some advice on! I have a LOT of text as input (about 20GB worth, not MASSIVE but big enough). This is just free text, unstructured. I have a 'category list'. I want to process the text, and cross-reference the items in the category list, and output the categories for each match, e.g. ## Input text The quick brown fox ran over the lazy dog. ## Category lookup _Colour_ Red | Brown | Green _Speed_ Slow | Quick | Lazy | Fast ## Expected Output Colour - Brown Speed - Quick, Lazy To add to the complexity of the problem, the source text probably doesn't match the categories exactly, e.g. there will have to be a fuzzy match algorithm of sorts applied here. I want to use 'Big data' tech to solve this (whether or not it TRULY NEEDS big data isn't the question - it's a secondary objective). My thoughts are to utilize Hadoop Map/Reduce with Lucene to do the fuzzy- matching. What do you think? Am I way off base? Thanks a lot - ANY advice appreciated!! Duncan


Architecture : am I doing things right?

I'm trying to use a '~classic' layered arch using .NET and Entity Framework. We are starting from a legacy database which is a little bit crappy:   * Inconsistent naming   * Unneeded views (view referencing other views, `select *` views etc...)   * Aggregated columns   * Potatoes and Carrots in the same table   * etc... So I ended with fully isolating my database structure from my domain model. To do so EF entities are hidden from presentation layer. The goal is to permit an easier database refactoring while lowering the impact of it on applications. ![Assemblies are drawn as components](http://i.stack.imgur.com/5wjcD.png) I'm now facing a lot of challenges and I'm starting to ask myself if I'm doing things right.   1. My Domain Model is highly volatile, it keeps evolving with apps as new fields needs are arising. Complexity of it keeps raising and class it contains start to get a lot of properties.   2. Creating include strategy and reprojecting to EF is very tricky (my domain objects don't have any kind of lazy/eager loading relationship properties):              DomainInclude<Domain.Model.Bar>.Include("Customers").Include("Customers.Friends")     // To...     IFooContext.Bars.Include(...).Include(...).Where(...)        3. Some framework are raping the isolation levels (Devexpress Grids which needs either XPO or `IQueryable` for filtering and paging large data sets) I'm starting to ask myself if :   * the isolation of EF auto-generated entities is an unneeded cost.   * I should allow frameworks to hit `IQueryable`? Slow slope to hell? (it's really hard to isolate DevExpress framework, any successful experience?)   * How can I lower the volatility of my domain model? ## Precisions **EF Isolation and fields that should or should not be included on service calls** Here is how I isolate EF Entities. Presentation layer is an isolation layer as no presentation can access to repositories class.               // Inside a service class. For this sample Customer is defined in the service model     // And Person is autogenerated by Entity Framework     /// Get the customers who bought an item ///     IEnumerable<Customer> GetCustomers(Item item){         var query = from person in _personRepository.GetItemBuyers(item.Id)                     select new Customer {                       Id = person.CustomerId                       , FirstName = person.FirstName                       , LastName = person.LastName                       , Sex = person.Sex == 'M' ? Sex.Male : Sex.Female};         return query;     }      It can get time consuming especially when you need to include (or not) some relationship properties. There is multiple solutions for including:                1. GetCustomersWithOrders(Item item);       2. GetCustomers(Item item, IncludeStrategy<Customer> include);      3. GetCustomers(Item item, params string[] fieldsIncluded);        1. Will obvioulsy result in service class containing thousands of GetCustomersWith...With...   2. Will create a lot of IncludeStrategy inherited class. I'm still working on a dynamic fluent approach `DomainInclude<Customer>.Include("Orders").Include("Friends")`   3. Will need the creation of some mapping dictionnary "Orders" => "CustomerAccount.PayedOrders" **Framework hitting IQueryable** Repositories don't expose IQueryable, the goal is to hide entity framework. Devexpress datagrids need an IQueryable to allow paging/filtering without loading the whole table in memory. Finding a workaround is nearly impossible as it will be really time consuming and the portability of the workaround is not assured with new devexpress releases. My question here is: Is it a big deal to allow devexpress going through the layers up to the EF context class. Should I drop Devexpress instead and use a more flexible datagrids (Sencha ExtJs, ...)


What to study at Grad School if I want to know about Programming Languages?

I listening to the latest podcast in This Developer's Life and before that I was watching this talk with Uncle Bod, The Last Programming Language, and, along with that, I have been having thoughts on getting back to school, so, based on the fact that I like programming languages a lot, thought: why not getting back to school to study programming languages?? I have a degree in computer systems (that's how it is called in Mexico, it's degree in which you basically touch a little bit of math, computer science and software engineering) and I really don't have a much of clue what/where to go and especially, what kind of studies to do? I mean, should I study **linguistics**? should I go and get a degree in **Computer Science**? Thanks for your answers! ={D


Is it a bad practice to quit a company only to begin as a consultant?

Like the title says; is it a bad practice to quit a company after a few years, only to begin as a consultant for the same 'customer'? I've been lucky enough to come in to a company in the oil business from the beginning, developing software for relatively new and unused technology. Long before I even got this job, I've wanted to start my own consulting firm. Is it morally wrong of me to quit my job after a few years, only to hire myself out as a 'specialist' or consultant on our systems?


Is functional programming a superset of object oriented?

The more functional programming I do, the more I feel like it adds an extra layer of abstraction that seems like how an onion's layer is- all encompassing of the previous layers. I don't know if this is true so going off the OOP principles I've worked with for years, can anyone explain how functional does or doesn't accurately depict any of them: Encapsulation, Abstraction, Inheritance, Polymorphism I think we can all say, yes it has encapsulation via tuples, or do tuples count technically as fact of "functional programming" or are they just a utility of the language? I know Haskell can meet the "interfaces" requirement, but again not certain if it's method is a fact of functional? I'm guessing that the fact that functors have a mathematical basis you could say those are a definite built in expectation of functional, perhaps? Please, detail how you think functional does or does not fulfill the 4 principles of OOP. Edit: I understand the differences between the functional paradigm and object oriented paradigm just fine and realize there are plenty of multiparadigm languages these days which can do both. **I am really just looking for definitions of how outright fp (think purist, like haskell) can do any of the 4 things listed, or why it cannot do any of them. i.e. "Encapsulation can be done with closures"** (or if I am wrong in this belief, please state why).


Specific reasons for still using Subversion?

I want to choose a version control system for my company. So far I know I have Git, Subversion and Mercurial. These days I see that Git is the most used, so I'm left wondering: would there be any specific reason to still use Subversion, or should I go directly to Git?


Pitfalls of using MySQL as your database choice?

I've read online on multiple occassions that MySQL is a bad database. The places I've read this include some threads on Reddit, but they never seem to delve in on _why_ it's a poor product. Is there any truth to this claim? I've never used it beyond a very simple CRUD scenario, and that was for a university project during my second year. What pitfalls, **if any** , are there when choosing MySQL as your database?


Single responsibility principle - am I overusing it?

For reference - http://en.wikipedia.org/wiki/Single_responsibility_principle I have a test scenario where in one module of application is responsible for creating ledger entries. There are three basic tasks which could be carried out -   * View existing ledger entries in table format.   * Create new ledger entry using create button.   * Click on a ledger entry in the table (mentioned in first pointer) and view its details in next page. You could nullify a ledger entry in this page. (There are couple more operation/validations in each page but fore sake of brevity I will limit it to these) So I decided to create three different classes -   * LedgerLandingPage   * CreateNewLedgerEntryPage   * ViewLedgerEntryPage These classes offer the services which could be carried out in those pages and Selenium tests use these classes to bring application to a state where I could make certain assertion. When I was having it reviewed with on of my colleague then he was over whelmed and asked me to make one single class for all. Though I yet feel my design is much clean I am doubtful if I am overusing Single Responsibility principle


Do real-world algorithms that greatly outperform in the class below exist?

Last night I was discussing with another programmer that even though something may be O(1), an operation which is O(n) may outperform it if there are is a large constant in the O(1) algorithm. He disagreed, so I've brought it here. Are there examples of algorithms which greatly outperform those in the class below it? For example, O(n) being faster than O(1) or O(n2) being faster than O(n). Mathematically this can be demonstrated for a function with an asymptotic upper bounds, when you disregard constant factors, but do such algorithms exist in the wild? And where would I find examples of them? What types of situations are they used for?


What is the difference between skill level amongst programmers?

I am a beginning programmer and in 5-10 years I'd like to be an expert. I love programming because it is a distinct skill set that you can continually improve on. But then I thought, how can you continually improve? At a certain point, don't you just "know" how to program? I imagine, just like at most things one can be great at, that, at the top, the difference in skill is probably minimal. So what makes a better programmer? Clearer code? Faster understanding of concepts? Being able to write a post on SO without it being closed? (I feel like this post is doomed, but it really is a question I was wondering.)


Open Source License that prevents re-selling

I have an open source project that is a add-in to TFS (ie it is for developers and those using TFS.) It is currently using the GPL. But it occurs to me that the GPL does not really represent what I am trying to do with my license. I want my code to be free to everyone who wants to use it. And if you modify it and use it then that is great too. You should not have to open source your modifications. But I would like to block someone from building my code and selling it. Or modifying it and selling it. (Anyone that wants to do that should have to negotiate a separate license with me.) **Is there an open source license that prevents re-selling, but allows full non-vending use for a person/company that downloads it?**


Programming SOLID Principles

Over time I could understand two parts of SOLID – the “S” and “O”. “O” – I learned Open Closed Principle with the help of Inheritance and Strategy Pattern. “S” – I learned Single Responsibility principle while learning ORM (the persistence logic is taken away from domain objects). In a similar way, what are the best regions/tasks to learn other parts of SOLID (the “L”, “I” and “D”)? References   1. msdn - Dangers of Violating SOLID Principles in C#   2. channel9 - Applying S.O.L.I.D. Principles in .NET/C#   3. OOPS Principles (SOLID Principles)


Integrating feature request functionality directly into the business software you write?

What are relative merits of something like a button on a piece of custom bizware that says, "press me to ask for a feature" or "click here if something didn't work right". The problem I'm trying to remedy is the general lack of formality surrounding feature requests. Most specifically, the rate at which I receive walk-ups from end-users. Taken one at a time, it can be beneficial, but sometimes it can hinder productivity on the larger scale. Has anyone done something like this and has it been a general success or alternately somewhat a waste of time. My instincts are not giving me a hint here.


What are the downsides of implementing a singleton with Java's enum?

Traditionally, a singleton is usually implemented as               public class Foo1     {         private static final Foo1 INSTANCE = new Foo1();              public static Foo1 getInstance(){ return INSTANCE; }              private Foo1(){}              public void doo(){ ... }     }      With Java's enum, we can implement a singleton as               public enum Foo2     {         INSTANCE;              public void doo(){ ... }     }      As awesome as the 2nd version is, are there any downsides to it? (I gave it some thoughts and I'll answer my own question; hopefully you have better answers)


Does anyone have a good example/sample of "goto" spaghetti code?

I've read a lot about how GoTo was considered harmful and removed for other control structures that were more intuitive. Does anyone have a good example / sample of goto spaghetti code? Preferrably, the sample code should be difficult to follow, but realtively easy when rewritten into more conventional control structures. I know I could try to write you some of my own, but I've never really used goto and don't think I could due justice to the headaches its abuse can lead to. I want this for didactic purposes to train junior developers on what to avoid. Mainly, to point to illustrate how OOP is taking the same idea to next logical consequence. EDIT: by **good example** I mean code that is terrible to read and abuses it, rather than code that uses goto for reasonable optimization


Adding a forum to an existing site

I've got a site with ~500 registered members, 300 of which are what you'd call "active". Site data is kept in a MySQL dbase. I'd like to add a myBB forum to the site, but this question applies to any forum really. What I very much want to avoid is requiring my users to register both on the site and on the forum because my userbase is not technically literate and this would confuse a lot of them. However the forum software has its own registration, login, cookie, and password management system which naturally are different from the site's mechanics. I envision the following possibilities:   * install myBB into the existing database and customize the login code to unify the two systems. This would probably mean changing the site's code to use the myBB system as that would likely be less painful to refactor and wouldn't hurt future myBB upgrade ability.   * install myBB into separate database and write a bridging script of some sort that auto-registers existing site users with the forum if they elect to participate. Also check new forum registrations against the site's username list to prevent newcomers from taking existing names.   * run them fully separate and force users to re-register (easiest for ME, but least desirable for them) I would like a suggested course of action from those who have trod this path before.


Why do we need to put N before strings in Microsoft SQL Server?

I'm learning T-SQL. From the examples I've seen, to insert text in a `varchar()` cell, I can write just the string to insert, but for `nvarchar()` cells, every example prefix the strings with the letter N. I tried the following query on a table which has `nvarchar()` rows, and it works fine, so the prefix N is not required:               insert into [TableName] values ('Hello', 'World')      Why the strings are prefixed with N in every example I've seen? What are the pros or cons of using this prefix?


How to structure a XML-based order form using ASP.NET

First question here; please help me if I'm doing something wrong. I'm a graphic designer who's trying to teach himself ASP.NET/C#. My server- side background is PHP/WordPress and some ASP Classic, and when I do code I've hand-coded just about everything since I started learning HTML. So, as I've started to learn .NET, my code has been very manual and procedural. I'm now trying to create a really basic order form that pulls from an XML file to populate the form; there's an image, a title, a price, and selectable quantities. If I was making this form as a static HTML file, I'd have each field named manually and so on postback I could query each field to get the values. But I'm trying to do this dynamically so that I can add/remove items from the form and not have to change the code. In terms of displaying the XML, I rolled my own by loading `XmlDocument` and using `XmlNodeList` and a bunch of `foreach` loops to get things displayed. Then, I learned about `<asp:XmlDataSource>` and `<asp:Repeater>`, which made displaying the XML simpler by a large margin. However, I've had a really hard time getting the data that's been submitted on postback (it was implied on SO that there are better ways to get data than nested RepeaterItems). So, what I've learned so far is that you can do things a bunch of different ways in .NET. that's why I thought it'd be good to ask for answers regarding the best way to use ASP.NET to display a XML document and dynamically capture the data that's submitted. Any help is appreciated! I'm using Notepad++ to code .NET 2.0.


Find the new coordinates using a starting point, a distance, and an angle

Okay, say I have a point coordinate.               var coordinate = { x: 10, y: 20 };      Now I also have a distance and an angle.               var distance = 20;     var angle = 72;      The problem I am trying to solve is, if I want to travel 20 points in the direction of angle from the starting coordinate, how can I find what my new coordinates will be? I know the answer involves things like sine/cosine, because I used to know how to do this, but I have since forgotten the formula. Can anyone help?


If your team does code review, to what extent do you verify that review fixes are carried out?

On my team, we carry out code reviews (without the use of external tools). The reviewer produces a list of items which the developer should address or consider and then essentially leave them to it (after discussing with them the relevant points) without follow up on their subsequent changes. Occasional spot checks suggest that for the most part all the comments are being addressed. However, in a lot of literature on the subject of code-reviews there is a strong emphasis on verifying that the code review comments are addressed. I'm wondering what people's thoughts are on this. Does your team have (or had) issues with people not addressing comments? Does your team behave like mine and not do the verification step? If your team does do the verification step, how often is it just a rubber stamp exercise?


Why can we not insert into files without the additional writes? (I neither mean append, nor over-write)

This occurs as a programming language independent problem to me. I have a file with the content               aaabddd      When I want to insert `C` behind `b` then **my code** needs to rewrite `ddd` to get               aaabCddd      Why can I not just insert `C` at this position? I can not do this in Java, Python, ... . I can not do this in Linux, Windows, ... . Am I right? I do not understand why `C` can't simply be inserted without the additional writes. Would someone please explain why this is so?


Programming with voice recogition software

I used Dragon Naturally Speaking very briefly a few years ago and was thinking if it would be a viable solution for programming? I was thinking more so if you break your arm or something that would be a major hinderance to programming. This same question on SO but was never answered.


Do DVCSes discourage continuous integration?

Say there is a team of ten agile developers. Every day they each pick a task from the board, commits several changes against it, until (by the end of the day) they have completed the task. All developers check in directly against trunk (Google-style, every commit is a release candidate, using feature toggles etc). If they were using a centralized CVS like SVN, every time one of them commits, the build server will integrate and test their changes against the other nine developers' work. The build server will be pretty much running continuously all day. But if they were using a DCVS like git, the developer may wait until they complete the task before pushing all their local commits together up to the central repository. Their changes will not be integrated until the end of the day. In this scenario, the SVN team is continuously-integrating more frequently, and discovering integration problems much faster than the git team. Does this mean DVCSs are less suitable for continuous teams than older centralized tools? How do you guys get around this deferred-push issue?


OOP Design - Possible wrong approach makes it impossible to implement it in code

This last semester i've had lectures about OOP design, i understood most of what i was supposed to   but there is something that i can't get right. I'm pretty sure that the models i create are wrong because they cannot be implemented. I wrote quite a lot because i can't tell where the problem is. This isn't homework , it is a sample of a problem from the past year. An example: Design a "Stackoverflow" like thing for a class. Use case: Posting a question pre-conditions: There is a authenticated student pos-conditions: The question was recorded and everyone that can read the question has been notified. Scenario:               1. The student tells the system he wants to submit a question and supplies the title     2. The system asks for the question body.     3. The student submits the question body.     4. The system records this.     5. The system reports all used question tags on that student's class.     6. The student submits the choosen question tag     7. The system records everything and reports the used tags     8. The student tells if he wants the question to be public     9. The system records everything and notifies the people it should      Steps 6,7 can be repeated until the user tells us he's done. There are extensions but not necessary to demonstrate my problem. How would i do it: System Sequence Diagram               newQuestion(title)     ------------------>          OK     <------------------          submitBody(bodytext)     ------------------->  _                           | LOOP     Existing tags         |     <-------------------  |                           |     choosetag(tag)        |     ------------------->  |                           _     chooseVisibility(b)                             ------------------->          OK     <-------------------      The domain model would have: Student Class Instructor Question Tag StudentCatalog InstructorCatalog The relations between each other's are simple ( i believe ) thats why i'm not sketching it up. I noticed my issue when making the interaction diagram for this use-case. I decided that the use-case controller would be a made up "handler" class QuestionHandler so the first two interaction diagrams i would believe to be something like:               newQuestion(title)      - it has to create a question with the proper title title      submitBody(bodytext)      - it has to set bodytext has the text for the question we are creating ( and i don't know where it is!)      **The actual problem:** From all this i imagine the code to be:               class QuestionHandler      method postQuestion(title) {       newQuestion(title);       submitBody(bodytext);       ... etc      }      And i can't see this working like this, my problem where does "submitBody(bodytext)" gets the currentQuestion from? How do i handle the "context" of each use-case, which in this case i would make it messy ( that's how it feels to me) and use the return values to make it work. But what if i have a use-case "context" that requires lots of things to me change and moved around? Im totally lost, i thought it would solve itself but it turns out o can't see how things would be implemented with this issue.


Open source from protected rights

I've got a question about author rights and open source software. Assuming I want to build a software. A similar software is already created, but isn't free at all and owned by a company. Can a build an open source clone of the proprietary software from scratch? Or is it forbidden by intellectual property? And what if I use proprietary ideas in the open source software?


Assigning responsibility for cancelling an Order

During a conversation with our Domain Expert we can across this feature: > A Customer service agent can cancel an Order by decreasing its quantity. To > cancel an Order we decrease its quantity by the specified quantity, change > its status to either partially cancelled or fully cancelled and log the CS > agent who issued the cancellation. We are currently split between several solutions (assuming we have the `agentId`, `orderId` and `cancelledQty` from the request): **Solution 1:**               CSAgent agent= (CSAgent) EmployeeRepository.getById(agentId);     Order order= OrderRepository.getById(orderId);     agent.cancel(order,cancelledQty);      vs   **Solution 2:**               CSAgent agent= (CSAgent) EmployeeRepository.getById(agentId);     Order order= OrderRepository.getById(orderId);     order.cancel(cancelledQty,agent);      **Solution 1** really captures what the requirements is conveying and reads really well; however, **solution 2** seems more natural when coding the implementation of the cancel() method as I'll mostly update fields in the `Order` class itself which I hope to keep `private` with no public setters.   The only thing I need from the `CSAgnet` class is a snapshot of its data to be stored with the `Order`. So how should I determine the best course of action from a DDD perspective?


Checked vs unchecked exception when validating documents in this service

I have a service that allow users to add dynamic content to a repository. So basically I have a generic Document class that contains a list of property for that specific object depending on what type of document the user is adding (eg. an invoice document has an invoice number property while a wiki document has an author property, and so on). The service is comprised of different layers and at some point I have a class that has to check if the document to be added is compliant to the rules configurer, evaluating if all required properties are provided, if they are all of the right type, etc. If any of these validations fail I want to throw a custom exception which contains the validation status. The question is:   * Should my ValidationException be checked or unchecked?  I read a lot of best practice on how to decide what kind of exception use. I was thinking about using RuntimeException but in this case the exception is not caused by error in coding or stuff like that but just by the user input... On the other hand using a checked exception would mean to propagate the "throws" syntax in all the above layer of the application and probably in the 90% of the service's methods making the code much less readable and maintainable.


Scaling Azure across subscriptions

I've been doing a lot of work with VMs recently and can see the massive advantages of the platform. It's my understanding that subscriptions are a very good way of managing your clients. For example I have some software which requires a VM, a SQL database and two websites. When I sign up a new client I create a new Subscription which they pay for and deploy my various components to it - they get the hosting bill. However, it seems to me that where Azure doesn't scale particularly well is when I have a hundred or a thousand clients. It's my understanding I'd need a publish profile for each one and every time we do a release I'd need to deploy 400 components. Is there a better way of managing multiple instances of your solution?


This is something that's been troubling me for a while now. Is it actually worth unit-testing an API client? Let's say you're creating a small class to abstract-away the calls to a petshop REST API. The petshop is a very simple API, and it has a basic set of methods:   * `listProducts()`   * `getProductDetails(ProductID)`   * `addProduct(...)`   * `removeProduct(ProductID)` In testing this, we'd have to either create a mock service or mock the responses. But that seems overkill; I understand that we want to make sure that our methods don't stop working through typo/syntax errors, but since we're writing functions that call remote methods and then we're creating fake responses from those remote methods, it does seem like a waste of effort and that we're testing something that can't really fail. Worse, if the remote method changes our unit tests will pass while production use fails. I'm pretty sure I'm missing something, or I've got the wrong end of the stick, or I'm not seeing the wood for the trees. Can someone set me on the right track?


Why use binary files to stack up different versions on DMSs?

I've used both Liferay and Alfresco trying to use them as the Document Management System for an intranet. I noticed the following:   * They use the file system and the database to store files   * They use a GUID to name the file on the filesystem and that GUID is used as an Id in the database.   * The GUID-named file is a binary file   * The GUID-named binary file stores all versions for a given file   * The path for the file in the DMS doesn't match the one in the file system   * The URL makes reference to the GUID when a certain file is requested What I want to know is why is this, and what would be the best way of doing it. Like how to would you create the binary file (zip?), and what parts would you keep in the binary file and what parts would you store in the database (meta-data, path?). I'm assuming some of the benefits of doing it like this. As having the same URL for a file, regardless of its current document path. And having only one file even if the file has changed names over time.


Is it a bad idea to release software on the night before Christmas?

We're about to go live with a new version of our system. It's getting really close to Christmas. I work in a very small company. Everyone will be on leave or sporadically available over the next week or so. I've argued with my boss that this is very risky and that we should go live in the new year when everyone is back and when we can provide full support. He is unflinching - he argues that we need to go live sooner - so that we can get new users and more revenue which we need. The number of new users will be minor amount over the next week or so. There has been a decent amount of system testing performed on the system. However a new live system, in my experience, needs a lot of care and attention in the first few days. Am I being pessimistic or realistic? Update - January: The system did not go live over Christmas. Ongoing system testing revealed various problems. So no support issues to deal with. Still preparing for release...


Reverse subarray of an array with O(1)

I have an idea how to implement sub array reverse with O(1), not including precalculation such as reading the input. I will have many reverse operations, and I can't use the trivial solution of O(N). **Edit:** To be more clear I want to build data structure behind the array with access layer that knows about reversing requests and inverts the indexing logic as necessary when someone wants to iterate over the array. **Edit 2:** The data structure will only be used for iterations I been reading this and this and even this questions but they aren't helping. There are 3 cases that need to be taking care of:   * Regular reverse operation   * Reverse that including reversed area   * Intersection between reverse and part of other reversed area in the array Here is my implementation for the first two parts, I will need your help with the last one. This is the rule class:               class Rule {         public int startingIndex;         public int weight;     }      It is used in my basic data structure City:               public class City {         Rule rule;         private static AtomicInteger _counter = new AtomicInteger(-1);         public final int id = _counter.incrementAndGet();              @Override         public String toString() {             return "" + id;         }     }      This is the main class:               public class CitiesList implements Iterable<City>, Iterator<City> {              private int position;         private int direction = 1;         private ArrayList<City> cities;         private ArrayDeque<City> citiesQeque = new ArrayDeque<>();         private LinkedList<Rule> rulesQeque = new LinkedList<>();                   public void init(ArrayList<City> cities) {             this.cities = cities;         }              public void swap(int index1, int index2){             Rule rule = new Rule();             rule.weight = Math.abs(index2 - index1);             cities.get(index1).rule = rule;             cities.get(index2 + 1).rule = rule;         }              @Override         public void remove() {             throw new IllegalStateException("Not implemented");         }              @Override         public City next() {             City city = cities.get(position);             if (citiesQeque.peek() == city){                 citiesQeque.pop();                 changeDirection();                 position += (city.rule.weight + 1) * direction;                 city = cities.get(position);             }             if(city.rule != null){                 if(city.rule != rulesQeque.peekLast()){                     rulesQeque.add(city.rule);                     position += city.rule.weight * direction;                     changeDirection();                     citiesQeque.push(city);                 }                 else{                     rulesQeque.removeLast();                     position += direction;                 }             }             else{                 position += direction;             }             return city;         }              private void changeDirection() {             direction *= -1;         }              @Override         public boolean hasNext() {             return position < cities.size();         }              @Override         public Iterator<City> iterator() {             position = 0;             return this;         }          }      And here is a sample program:               public static void main(String[] args) {             ArrayList<City> list = new ArrayList<>();             for(int i = 0 ; i < 20; i++){                 list.add(new City());             }             CitiesList citiesList = new CitiesList();             citiesList.init(list);                  for (City city : citiesList) {                 System.out.print(city + " ");             }             System.out.println("\n******************");             citiesList.swap(4, 8);                  for (City city : citiesList) {                 System.out.print(city + " ");             }             System.out.println("\n******************");             citiesList.swap(2, 15);                  for (City city : citiesList) {                 System.out.print(city + " ");             }         }      How do I handle reverse intersections?


How to write a good exception message

I'm currently doing a code review and one of the things I'm noticing are the number of exceptions where the exception message just seems to reiterate _where_ the exception occurred. e.g.               throw new Exception("BulletListControl: CreateChildControls failed.");      All three items in this message I can work out from the rest of the exception. I know the class and method from the stack trace and I know it failed (because I've got an exception). It got me thinking about what message I put in exception messages. First I create an exception class, if one does not already exist, for the general reason (e.g. `PropertyNotFoundException` \- the _why_ ), and then when I throw it the message indicates what went wrong (e.g. "Unable to find property 'IDontExist' on Node 1234" - the _what_ ). The where is in the `StackTrace`. The _when_ may end up in the log (if applicable). The _how_ is for the developer to work out (and fix) Do you have any other tips for throwing exceptions? Specifically with regard to the creating new types and the exception message.


Running time question

I have an array A of n integers, sorted from min to max, and two numbers a<=b, which are known to be in A. I would like to write a pseudo-code for a procedure whose running time is c1+c2log(n) and which returns the number of elements in A which satisfy a<=A[i]<=b. I wrote the following but am not sure it satisfies the requirement for the running time and would appreciate some help: _NB <\- denotes an arrow_               LBound(Input: integer n, sorted array of integers A, integer a) {       min  ← 1       max  ← n       while (min <= max) {     mid  ←  |_(min + max) / 2_|         if (A[mid] < a)           min  ←  mid + 1     else           max  ←  mid - 1       }       output(min)     }     LBound(Input: integer n, sorted array of integers A, integer a) {       min  ← 1       max  ← n       while (min <= max) {     mid  ←  |_(min + max) / 2_|         if (A[mid] > b)           max  ←  mid - 1     else           min  ←  mid + 1       }       output(max)     }     Range(Input: integer n, sorted array of integers A) {      output (1 + UBound(n,A,b) – LBound(n,A,a))      }


Fixing sudden serious problem in software

For example, company that uses our software suddenly has found a serious bug and can't continue to work. The bug has exposed a big problem in software design and fixing it will take few days. What is the best approach to solve such problems? What developers should do: start to rewrite code to fix the bug, writing a quick hotfix first, etc?


How to promote code reuse and documentation?

As a team lead of about 10+ developers, I would want to promote code reuse. We have written a lot of code-- a lot of them are repetitive over the past few years. The problem now is that a lot of these code are just duplicate of some other code or a slight variation of them. I have started the movement ( discussion) on how to make code into components so that they can be reused for the future projects, but the problem is that I afraid the new developers or other developers who are ignorant of the components will just go forward and write their own thing. Is there anyway to remind the developers to reuse the components/ improve the documentation/ contribute to the underlying component instead of duplicating the existing code and tweaking on it or just write their own? How to make the components easily discover-able, easily usable so that everyone will use it? Edit: I think every developer knows about the benefit of reusable components and wants to use them, it's just that we don't know how to make them discoverable. Also, the developers when they are writing code, they know they should write reusable code but lack of the motivation to do so.


Does low latency code sometimes have to be "ugly"?

(This is mainly aimed at those who have specific knowledge of low latency systems, to avoid people just answering with unsubstantiated opinions). Do you feel there is a trade-off between writing "nice" object orientated code and writing very fast low latency code? For instance, avoiding virtual functions in C++/the overhead of polymorphism etc- re-writing code which looks nasty, but is very fast etc? It stands to reason- who cares if it looks ugly (so long as its maintainable)- if you need speed, you need speed? I would be interested to hear from people who have worked in such areas.


Training a newbie tester

I am training an engineering fresh out of college to work on testing (both manual and automated testing). What are some possible ways to go about it? (books, videos, beta testing sites, etc.) Obviously I will be using the person on our codebase too, but I am also interested in them gaining a larger breadth of testing knowledge that they can then bring into our project.


Obsession, how much is too much?

I'm 17 and I've started programming and reading SE all day, every day. I absolutely love it and want to program for a living, but how much is too much? Is it unhealthy to sit at a computer all the time? Is this just a phase? Did this happen to you? If so, what did you do about it?


Expected behavior when an request for a collection will have zero items

Let's say you are given the following...               List<Thing> theThings = fubar.Things.All();      If there were nothing to return, what would you expect fubar.Things.All() to return? Edit: Thanks for the opinions. I'll wait a bit and accept the entry with the most ups. I agree with the responses so far, particularly those suggesting an empty collection. A vendor provided an API with several calls similar to the example above. A vendor who did $4.6 million in revenue via their API(s) last year, BTW. They do something I fundamentally disagree with -- they throw an exception.


What should be the Roadmap for JAVA EE

I have done Java SE and want to start JAVA EE. But i am very confused, from where i have to start .So please tell me the roadmap from where to start Java EE ?


Planning to move to financial sector

I am planning to get a job in the financial software domain. I have plenty programming experience(10 years) but none in financial software. I have some basic knowledge of financial concepts but I wonder what financial software companies look for when selecting employees. Thanks


How to incrementally update a database when deploying a website?

We use JSF over Tomcat along with a backing proprietary DB. I want to know how the addition of new database fields or/and stored procedures should be handled when we deploy a new version of the application. We deploy by sending a WAR file to the hosting Team, as such our WAR should be able to setup the stored procedure when it starts. What are the possible appropriate strategies to be able to incrementally update the database?


Do we tell the object to do something or do we do something (on/with/to/etc.) the object?

Take the (unprecedented and groundbreaking) example of the calculator:               public class Calculator     {         public double Add(double augend, double addend)          {             return augend + addend;         }     }      When I write `calculator.Add(val1, val2)` which of the following am I doing?   * Telling the calculator to add the inputs   * Adding the inputs with the calculator (One could also ask: "Is it a method _of_ the object or is it a method _on_ the object?") Other examples: do we tell the repository to add the entity or do we add the entity to the repository? Do we tell the message service to deliver a message or do we send a message through the message service? Do we tell the can of paint to mix itself or do we mix the can of paint?


Access items of a container with a pattern

I've two C++ classes with a relation: a container class which has a list of items. For example a library has got many books. The classes are the library and the book. Now from the external world I have to create, update and delete books. In addition there other classes that are interested to know when an event on a book happens and these (observers) instances can be created at run-time. Now I've got different ways to proceed: 1) Use always the container to do the operation: central point of management but I have to create couples of methods for example setTitle(bookID) that call setTitle() on the book, bad; 2) Use a getBook() on the container to return a reference of the book, allow the modification, at this point I have to use a commit method to notify the container which can notify the observer but in this way the pattern doesn't force a "commit", I mean if the external caller doesn't call commit() I loose :) 3) Use a getBook() on the container to return a copy of the book and an update method of the container to overwrite the book, central point of management again but the book if big is a problem, a lot of copies are really bad. Any tips? Is there any pattern that covers this use case?


Concurrency checking with Last Change Time

I have an app with the following three tables   1. Email (emailNumber, Address)   2. Recipients (reportNumber, emailNumber, lastChangeTime, status)   3. Report (reportNumber, reportName) I have a `C#` application that uses inline queries for data selection. I have a select query that selects all reports and their Recipients. Recipients are selected as comma separacted string. During updating, I need to check `concurrency`. Currently I am using **MAX(lastChangeTime)** for each reportNumber. This is selected as maxTime. Before update, it checks that the               lastChangeTime <= maxTime. --//It works fine      One of my co-developers asked why not use `GETDATE()` as “maxTime” rather than using a `MAX` operation. That is also working. Here what we are checking is the records are not updated after the `record selection time`. Is there any pitfalls in using `GETDATE()` for this purpose?


How does Google plus page loading work

On Google plus, when I click on a Google plus profile or any Google plus link the page gets redirected to that link without a full page load but the URL changed and a record added to browser history. How this can be done? Is there any tutorial or document?


What language was "standard" for Apple development before Objective C?

I don't think Objective C was in use from the beginning of Apple hardware development. What languages did app developers use for the earlier Apple computers, such as Apple II or Mac Classic?


Why not use the word bug instead of exception?

If we refer to exceptions as bugs, why not just call it a bug in the first place instead of an exception? If in the code it's called exception and as soon as it occurs it's called a bug. Then why not call it a bug in the first place? Thank you for any answer or comment.


How often is software speed evident in the eyes of customers?

In theory, customers should be able to feel the software performance improvements from first-hand experience. In practice, sometimes the improvements are not noticible enough, such that in order to monetize from the improvements, it is necessary to use quotable performance figures in marketing in order to attract customers. We already know the difference between perceived performance (GUI latency, etc) and server-side performance (machines, networks, infrastructure, etc). How often is it that programmers need to go the extra length to "write up" performance analyses for which the audience is not fellow programmers, but managers and customers?


Hosted Mercurial with Project Management tools

I have used a couple of the hosted SCM's like Unfuddle and Codespaces before and I like that they have Project Management tools built in. I've started using Mercurial and really like it, I would like to make the switch to it, but I can't seem to find any hosted mercurial solutions that contain project management tools. Does anyone know any hosted solutions that have mercurial repositories with project management solutions? Similar to Aseembla, CodeSpaces, Unfuddle, etc. I know there is BitBucket, but I don't see any project management tools. EDIT: Details about the types of tools I'm looking for. It is for a very small team, 2-5 people. Looking for Agile (or close to Agile) tools. For example, in CodeSpaces there is a card wall, Assembla has a robust ticketing system that you can create swim lanes in, etc.


How would you approach this Domino problem?

This is a problem from an algorithmic competition from a few years back. It has a very simple description, but I don't see any algorithm to solve it efficiently. I am not looking for an implementation, but a general idea how to solve this problem. > Description: We would like to build a domino chain from all tiles we are > given (as in domino two tiles can be joined iff the same number appears on > its adjacent sides). This isn't always possible. Therefore we should output > the minimum number of tiles it is necessary to add to build the chain. > > Input: n pairs of integers in the range [0, 10000] n <= 1000000 (so the > algorithm can be O(nlogn) at worst) > > Output: How many tiles (at least) should be added. > > Example: Input: >   >   >     2 1   >     2 3   >     4 5   >   > > Output: >   >   >     1 >   > > Explanation: (1 2) (2 3) ! (4 5) It's impossible to build the chain without > adding any tiles. Adding one tile ((3 4)) where "!" stands creates a correct > chain containing all tiles, therefore the answer is 1.


moving from development to quality assurance

I'm looking for advice on the best way to move from software engineering to quality assurance type of jobs. Let's imagine a middle aged developer who is not up to date on all the current technologies and is having hard time finding a software engineering jobs because he's not really senior/principal engineer type and all the non- managerial positions seem to be taken by younger folks. He has some decent scripting background in Perl/Python/Shell. I would think that he might be very useful on a QA team as a QA/scripter. Does this make sense? Is it possible to find a QA job like that with no pure QA experience on the resume? What's a good way to write a cover letter explaining this? Looking for ideas/good sounding phrases for the cover letter/general feedback on the direction I'm thinking about.


How to manage IDE project files on a forked repository

I recently forked a Git repository, and locally I created a project in my IDE to compile with. My IDE creates a variety of artifacts that I would like to keep saved somewhere. The obvious place would be in the VCS. If I add these files then they will be in the history for my fork. If i want send a pull request to merge upstream I wouldn't want these files included. What would be a recommended workflow for managing these changes that I would never want to go upstream.


How can I manage my ViewControllers in my game?

I'm building a very simple iOS game that doesn't require any fancy OpenGL; I'd like to stick with Core Graphics & Core Animation. I'd like to make this a fullscreen game, and my question is of ViewController hierarchy + management: It seems as though I should have two types of ViewControllers: Basic VCs for navigating between menu screens (ie. Settings, Main Menu, Level Select, etc.), and Gameplay VCs for managing all my UIViews and CALayers. What's a good way to manage these? Is it best practice to have one hierarchy of VCs like a traditional `UINavigationController`-based app, covering the NavBar when I'm displaying a Game ViewController? Or instead should I be removing all other ViewControllers from the stack when I enter "game mode", and setting it as my `window.rootViewController` property? Any alternatives / downsides to continually resetting `window.rootViewController`? My gut tells me the latter is better on resources+performance, but advice + direction here would be appreciated.


Referencing countries via Foreign Key Constraint

To make things simple to explain: I've got two tables: `Table1` and `Countries`. The `Countries` table contains a nice flag and some information, such as DisplayName, the ISO3166 ALPHA3 code and the phone code (+49, +xx). `Table1` contains customers with a column `Country`. Is it (in terms of usability, normalization and common human sense) okay to reference from `Table1.CountryId` to `Countries.Id` via a foreign key instead of having a plain `Table1.Country` `nvarchar(255)` field and insert a `string` into that?


Working alone on a project

So I am working on a small Project at my company, I am a mere trainee engineer (halfway through a Software Engineering degree), where we are developing an intranet - based project management and people management system - it incorporates Employee appraisals, personal skill management and development and so on. Ive been working on this project for a little while, under the direction of a more senior engineer and there has been another trainee working on it too. However soon, a big contract is coming up and the other two have been press- ganged for some of the work, which will tie them up for a long, long time. This leaves me alone to work on this (really fun and full of learning) project alone. Dream come true! Or is it? I've been worried about how I'm simply going to manage the work of three people, are there techniques, tools I can use? The more I think about it, the more intimidated I am (but still relishing the idea of a good challenge). I have to think about planning, diagramming, release notes, test specs and my own hallways testing (where I grab a random person and say "break it!"), not to mention the actual programming work! So in short, **how can one person adapt to taking on the workload of three people?**


Why most "well-known" imperative/OO languages allow unchecked access to types that can represent a 'nothing' value?

I have been reading about the (un)convenience of having `null` instead of (for example) `Maybe`. After reading **this article** , **I am convinced that it would be much better to use`Maybe`** (or something similar). However, I am surprised to see that all the "well-known" imperative or object oriented programming languages still use `null` (which allows unchecked access to types that can represent a 'nothing' value), and that `Maybe` is mostly used in functional programming languages. As an example, look at the following C# code:               void doSomething(string username)     {         // Check that username is not null         // Do something     }      Something smells bad here... Why should we be checking if the argument is null? Shouldn't we assume that every variable contains a reference to an object? As you can see, the problem is that by definition almost all variables can contain a null reference. What if we could **decide** which variables are "nullable" and which not? That would save us a lot of effort while debugging and looking for a "NullReferenceException". **Imagine that, by default, no types could contain a null reference**. Instead of that, you would **state explicitly that a variable can contain a null reference** , only if you really need it. That is the idea behind Maybe. If you have a function that in some cases fails (for example division by zero), you could return a `Maybe<int>`, stating explicitly that the result may be an int, but also nothing! This is **one reason to prefer Maybe** instead of null. If you are interested in more examples, then I suggest to read **this article**. The facts are that, despite the disadvantages of making most types nullable by default, most of the OO programming languages actually do it. That is why I wonder about:   * **What kind of arguments would you have** to implement `null` in your programming language instead of `Maybe`? **Are there reasons at all** or is it just "historical baggage"? _Please ensure you understand the difference between null and Maybe before answering this question._


what is the benefit of using key/value stores with respect to database sharding?

What has key/value stores got to do with making database sharding easier? Because if I do not use a key/value store, I can easily shard my database too right? (Like say, I can easily say users with names that start with this character will have their data stored in this server, and those tables themselves aren't key/value stores. so what exactly had key/value stores got to do with database sharding?)


Usefulness of Javadocs with unit testing?

I am sure some else has experienced the problem of documentation regarding unit tests. I was wondering if anyone has used javadocs with their unit testing to generate their own internal javadoc files to keep track and document their unit tests? If so, did you find it successful? Or you think this a bad way to document unit tests, please let me know. If you have any suggestion for a better way for unit test documentation, it would be greatly appreciated.


How to deal with changes that need further testing while working on another test?

TDD means to test before you start writing production code. So I start writing a test for `MyClass` called `MyClassTest`. It fails and I start to implement the wanted functionality in `MyClass`. During the implementation phase of `MyClass` I encounter that changes on another class (e.g. `MyClassUtils`) are needed to be done. `MyClassUtils` has a test class of its own. Following TDD I should test first before implementing any new functionality. So should I interrupt the work on `MyClass` for the first test and implement the needed methods in `MyClassUtilsTest` first? Or is it better to somehow track (e.g. writing it down on paper, TODOs in the code etc.) the test methods that need to be added and disregard "test first"? I often encounter that problem and I am not sure what is the best way to deal with it. The first possibility leads to bigger and messed up commits with changes in at least four classes and longer time periods without commits. The second one disregards the test first principle, leads to a backlog of unimplemented tests and lowers the code coverage. How do you deal with it? I am thankful for any advice. :)


Why use sealed instead of static on a class?

Our system has several utility classes. Some people on our team use (A) a class with all-static methods and a private constructor. Others use (B) a class with all-static methods (these the juniors). On code analysis, (A) and (B) raise warning CA1052, which recommends marking the class as sealed. Included in the MSDN documentation there is the following advice: > If you are targeting .NET Framework 2.0 or earlier, a better approach is to > mark the type as static. Why does this make any sense? I would have thought the opposite; AFAIK, previous to 2.0 there was no way to mark a class as static.


Question about a voting system implementation

I am implementing a voting system and need some input from fellow programmers. Do you see anything that could go wrong by having users input a valid email and perhaps have a captcha to stop automated voting instead of a traditional login and vote?


Converting to a mac-book pro for multi disciplined development

I am in a bit of a bind. I have been contracted to create a small suite of applications for Android, iOS and WP7. Currently I am also on the market for a new notebook for development. Now the issue I have is I can either buy a consumer grade macbook and a laptop or I could just buy an 8gb Ram, SSD, i7 mackbook and virtualise windows 7. I have never used a mac or macbook before so before I go purchase anything I would like to know what your thoughts are on this. Has anyone any experience with this?


How can I make an in-house user group successful?

I would like to launch an in-house user group/forum for the developers in my company, but I'm not sure how to get started. We have several teams of developers spanning many technologies and levels of experience. I envision this as an opportunity for all of us to come together and share techniques, best practices, lessons learned, pain points, new technologies, or anything else a dev finds interesting. This could also be a great way for new hires to integrate, learn how we do things, and share some of the expertise they bring with them. This is my first attempt at anything like this and I'd like to do it right. I'm interested in things like:   * Driving participation   * Keeping things interesting for both 20-year veterans and fresh, green graduates   * Avoiding pitfalls known to be toxic to user groups Has anyone done this successfully? If so, what can you share about the experience?


Work load balance/Task distribution algorithm

I'm looking for an algorithm to either use or as a jump point for load balancing. Environment: We have ~7 job types that can be scheduled at any time by our users. Some jobs are fast, others are slow (lot of data processing). We have a single instance of a "job processor" that will discover jobs that have been scheduled and then execute them. The "job processor" will run up to 5 jobs at a time, "threads". The problem is that one job could consume so many resources that the other 4 jobs don't get processed and even worse, the other scheduled jobs are delayed for long periods of time. Some jobs can be scheduled as "run immediately" which makes them next in line. Solution: Add more instances of the "job processor". We have a big VM server that IT is rolling out 3 VM's to each handle an instance of this "job processor". By default, it's going to help but I believe that there should be more thought behind it. My solution: In addition to making the "job processors" scale horizontally, I think there needs to be a way to determine which jobs an instance will grab based on current load of the instance and also allow for a bias. I suggest we determine statistics for each job type (avg run time, etc) and give it a score of 1-5 (5 being long running). Each instance will determine what its current load is either based on the total score of the jobs its running currently and then factoring in it's bias. For example, I think we should be able to set an instance to be biased toward small jobs so it avoids larger jobs while another instance is biased toward medium jobs, etc. I'm looking for advice on how to go about this. Jobs can consume large amounts of time, cpu and/or memory. My goal is to make sure each instance is only pulling down the work it's capable of doing while keeping the scheduled job queue moving along as quickly as possible. One of the other devs suggested we leave the "job processors" alone to just pull whatever is in the queue next or "round robin". I say that this could lead to a potential issue where a single instance has pulled down too many large jobs and is struggling to get them done while the other instances are idle.


What is better done in Ruby and what is better done in Haskell?

If you have experience with both Ruby and Haskell, which of the following best describes the applicability and comparative power of the two languages?   1. The two languages better suit different kinds of programs, i.e. Ruby is better for x and Haskell is better for y.   2. They are both general-purpose, and one language better for almost all applications than the other.   3. They are both general-purpose, and whether one language is better than the other is mostly just a matter of personal preference. Or feel free to add your own conclusion. I know Ruby well, and have been studying Haskell for a few weeks without having written any serious applications with it. I primarily want to know which bits of my production Ruby applications I should try rewriting in Haskell, and also what future applications (not toy applications, but real production applications) I ought to consider writing in Haskell rather than Ruby.


When is it okay to log filename/line information for errors?

We have a closed-source commercial C++ application. Some of our logged error messages are in plain English like "ERROR: could not read file 'foo'". While others use a macro to print filename/line information like ""SplineReticulator.cpp(423): out of bounds". This is not an assert or a crash, the application recovers fine, but it's an error we want to log. What is a good rule of thumb when plain-English error message is appropriate vs. a filename/line one? Or are filename/line type errors even appropriate for closed-source commercial software? We've heard the argument they are unprofessional looking, but they are handy for debugging.


Two HTML elements with same id attribute: How bad is it really?

Just browsing the google maps source code. In their header, they have 2 divs with id="search" one contains the other, and also has jstrack="1" attribute. There is a form separating them like so:
         <form action="/maps" id="...rest isn't important">             ...
...      Since this is google, I'm assuming it's not a mistake. So how bad can it really be to violate this rule? As long as you are careful in your css and dom selection, why not reuse id's like classes? Does anyone do this on purpose, and if so, why?


When NOT to use a framework

Today, one can find a framework for just about any language, to suit just about any project. Most modern frameworks are fairly robust (generally speaking), with hour upon hour of testing, peer reviewed code, and great extensibility. However, I think there is a downside to ANY framework in that programmers, as a community, may become so reliant upon their chosen frameworks that they no longer understand the underlying workings, or in the case of newer programmers, never learn the underlying workings to begin with. It is easy to become specialized to a degree that you are no longer a 'PHP programmer' (for example), but a "Drupal programmer", to the exclusion of anything else. Who cares, right? We have the framework! We don't need to know how to "do it by hand"! Right? The result of this loss of basic skills (sometimes to the extent that programmers who **don't** use frameworks are viewed as "outdated") is that it becomes common practice to use a framework where it is not required or appropriate. The **features** the framework facilitates wind up confused with what the base language is capable of. Developers start using frameworks to accomplish even the most basic of tasks, so that what once was considered a rudimentary process now involves large libraries with their own quirks, bugs, and dependencies. What was once accomplished in 20 lines is now accomplished by including a 20,000 line framework AND writing 20 lines to use the framework. Conversely, one does not want to reinvent the wheel. If I'm writing code to accomplish some basic, common little task, I might feel like I am wasting my time when I know that framework XYZ offers all the features I am after, and a whole lot more. The "whole lot more" part still has me worried, but it doesn't seem that many even consider it anymore. There has to be a good metric to determine when it is appropriate to use a framework. What do you consider the threshold to be, how do **_you_** decide when to use a framework, or, when not.


Does “notification center” pattern encourage good or bad program design?

Sometimes I come across these message-hub-style APIs, for example the Cocoa NSNotificationCenter: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class/Reference/Reference.html Usually these APIs provide a global access point on which you subscribe to or broadcast messages/events. I'm thinking this is a problem because it encourages a flat and unstructured program architecture, where dependencies are not explicit in the API, but hidden in the source code. You are not forced to think about object ownership and hierarchies, but can rather make any object in your program result in any code anywhere being called. But maybe this is a good thing? Does this pattern generally encourage good or bad program design, and why so? Does it make the code harder or easier to test? Forgive me if this question is too vague or broad. I'm trying to wrap my head around the potential consequences of extensive use of an API like this, and the different ways you could use it. Edit: I guess my biggest issue with this pattern is that the API "lies" about dependencies and object couplings, and can be illustrated with this example:               myObj = new Foo();     myOtherObj = new Bar();     print myOtherObj.someValue; // prints 0     myObj.doSomething();     print myOtherObj.someValue; // prints 1, unexpectedly, because I never indicated that these objects had anything to do with each other


Python MVC framework for desktop applications

I'm used to program with Python and GTK using pygtk library. I feel like my programs are not well separated according to MVC model. I think following a framework it would help me to design better desktop applications. I'd like to know which Python MVC framework for desktop apps you're using and why.


Choosing the right Design Pattern

I've always recognized the importance of utilizing design patterns. I'm curious as to how other developers go about choosing the most appropriate one. Do you use a series of characteristics (like a flowchart) to help you decide? For example: > If objects are related, but we do not want to specify concrete class, > consider Abstract > > When instantiation is left to derived classes, consider Factory > > Need to access elements of an aggregate object sequentially, try Iterator or something similar?


Low level programming - what's in it for me?

For years I have considered digging into what I consider "low level" languages. For me this means C and assembly. However I had no time for this yet, nor has it EVER been neccessary. Now because I don't see any neccessity arising, I feel like I should either just schedule some point in time when I will study the subject or drop the plan forever. ## My Position For the past 4 years I have focused on "web technologies", which may change, and I am an application developer, which is unlikely to change. In application development, I think usability is the most important thing. You write applications to be "consumed" by users. The more usable those applications are, the more value you have produced. In order to achieve good usability, I believe the following things are viable   * **Good design** : Well-thought-out features accessible through a well-thought-out user interface.   * **Correctness** : The best design isn't worth anything, if not implemented correctly.   * **Flexibility** : An application A should constantly evolve, so that its users need not switch to a different application B, that has new features, that A could implement. Applications addressing the same problem should not differ in features but in philosophy.   * **Performance** : Performance contributes to a good user experience. An application is ideally always responsive and performs its tasks reasonably fast (based on their frequency). The value of performance optimization beyond the point where it is noticeable by the user is questionable. I think low level programming is not going to help me with that, except for performance. But writing a whole app in a low level language for the sake of performance is premature optimization to me. ## My Question What could low level programming teach me, what other languages wouldn't teach me? Am I missing something, or is it just a skill, that is of very little use for application development? Please understand, that I am not questioning the value of C and assembly. It's just that in my everyday life, I am quite happy that all the intricacies of that world are abstracted away and managed for me (mostly by layers written in C/C++ and assembly themselves). I just don't see any concepts, that could be new to me, only details I would have to stuff my head with. So what's in it for me? ## My Conclusion Thanks to everyone for their answers. I must say, nobody really surprised me, but at least now I am quite sure I will drop this area of interest until any need for it arises.   To my understanding, writing assembly these days for processors as they are in use in today's CPUs is not only unneccesarily complicated, but risks to result in poorer runtime performance than a C counterpart. Optimizing by hand is nearly impossible due to OOE, while you do not get all kinds of optimizations a compiler can do automatically. Also, the code is either portable, because it uses a small subset of available commands, or it is optimized, but then it probably works on one architecture only.   Writing C is not nearly as neccessary anymore, as it was in the past. If I were to write an application in C, I would just as much use tested and established libraries and frameworks, that would spare me implementing string copy routines, sorting algorithms and other kind of stuff serving as exercise at university. My own code would execute faster at the cost of type safety. I am neither keen on reeinventing the wheel in the course of normal app development, nor trying to debug by looking at core dumps :D   I am currently experimenting with languages and interpreters, so if there is anything I would like to publish, I suppose I'd port a working concept to C, although C++ might just as well do the trick.   Again, thanks to everyone for your answers and your insight.


How to store prices that have effective dates?

I have a list of products. Each of them is offered by N providers. Each providers quotes us a price for a specific date. That price is effective until that provider decides to set a new price. In that case, the provider will give the new price with a new date. The MySQL table header currently looks like:               provider_id, product_id, price, date_price_effective      Every other day, we compile a list of products/prices that are effective for the current day. For each product, the list contains a sorted list of the providers that have that particular product. In that way, we can order certain products from whoever happens to offer the best price. To get the effective prices, I have a SQL statement that returns all rows that have `date_price_effective >= NOW()`. That result set is processed with a ruby script that does the sorting and filtering necessary to obtain a file that looks like this:               product_id_1,provider_1,provider_3,provider8,provider_10...     product_id_2,provider_3,provider_2,provider1,provider_10...      This works fine for our purposes, but I still have an itch that a SQL table is probably not the best way to store this kind of information. I have that feeling that this kind of problema has been solved previously in other more creative ways. Is there a better way to store this information other than in SQL? or, if using SQL, is there a better approach than the one I'm using?


Is C++ really going out of fashion?

The TIOBE index claims that the popularity of C++ is waning, and is currently way below C and Java. Echoing this claim, a blogger suggested today, that because C++ is going out of fashion, C++ programmers might be a bargain relative to other programmers. As a C++ programmer, I don't want to be left behind, if the industry moves on to something else, and I certainly don't want to be a "bargain". I've been programming in C++ for many years, and clunky as C++ may seem, in my current field (scientific/numeric programming), I just don't see any good alternatives, even though I've looked at dozens of languages. They seem to be either slow, less portable or even clunkier than C++. So, my question is, **are there reliable figures for the popularity of different languages, and C++ in particular** , in the industry? I'm skeptical that C++ is on its way out, because 75% of the qualified Google Code Jam entries were in C++ this year (This does not include the C entries)


Could Most Software Companies & Users Benefit From Rolling Versions

Having used Google Chrome now for a couple of years, I've really gotten to like rolling/automatic updates. I know that most modern software has "automatic updates", but many large pieces of software only have "minor version automatic updates", leaving you to pay to for each major version. Obviously, these companies get you hooked with version 1 and then get you to buy each subsequent version since you're often locked in and/or you're used to the product. Is there a viable business model for "automatic major version updates"? For instance: "Is there a business model in which Microsoft could just sell Office"? There would be no version number. As new features come out, they're automatically added. How could/would they continue to make just as much money?


If I accept contributions under a CLA, can I write "Copyright (c) My-Name"?

I'm thinking about open sourcing a project of mine. I'd accept contributions under a CLA that grants me a copyright license (I'll explain what I mean at the end of this question). — Now, if someone submits a contribution, is it then okay that I write `Copyright (c) 2013 My-Name` at the top of each file? And mention any contributors in a separate document only, and refer people to the Git commit log and to GitHub statistics if they want details on individual contributors? I think this should be fine with `Copyright (c) My-Name`, since I've been granted a copyright license? If it's not okay, then I suppose the copyright-info-preamble of each source code file would have to include the name of all contributors to that file? Which doesn't seem practical (if there are very many contributors). * * * Here I'll try to explain what I mean with a _"a CLA that grants me a copyright license"_. This is an edited excerpt from a CLA by Google: > .2. [...] You [ _that is, the contributor_ ] hereby grant to [ _My-Name, > that is, me_ ] and to recipients of software distributed by [ _My-Name_ ] a > perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable > copyright license to reproduce, prepare derivative works of, publicly > display, publicly perform, sublicense, and distribute Your Contributions and > such derivative works.


Having two sets of infrequently changing data or converting on the fly

I am currently working on a small project in which I work with some "static data", which is extracted from one source. The data might change from time to time (up to once a week). I don't need all of the information the data includes in my project so to allow easier and a more logical access to it I wrote some small tool that converts the extracted data into my desired format. The conversion is mostly dropping data I don't need, and splitting some strings into arrays. No intensive calculations or anything. But, I drop more than 50% of the original data because their is no need for it. Now since it is static data would it make more sense to just store that converted data and do all further operations from this data or would it make more sense to convert from the raw data on the fly? Since the project is in JavaScript speed of course is important, but if converting on the fly has significant advantages it might make more sense to go with that approach. It is static data from a computer game that defines several units and other objects within the game. They are stored in JSON therefore I can easily use them in JavaScript. But I don't need a lot of the information, just some parts of it to build a kind of "encyclopedia", now since the data is already present in JSON I was wondering if I should just use it or convert it before usage.


What role does .ini play?

I am working with a MFC application for the first time and I have lots of doubts the biggest at the moment is What is .ini file and why is it there? What exactly is the role it plays? Can some tell me the required? Edit : What if I make an application and do not have .ini file, what do I loose on?


Handling scripting in windows

I worked in Linux environment before and I have to work in windows XP for my current project. In linux, I enjoyed using script files for automating tasks(even smaller ones), and it did save me a lot of time. I see windows command prompt is severely handicapped in terms of power and the number of commands available. I came across Power shell, but I think it is a overkill , because I am not a windows admin or something. Have you been in my situation before? Do you work on windows and automate tasks? Is there any place where I can learn them ?


How to work with badly written and formatted code

I was wondering how people deal with working in a project with badly written and formatted code, I'm talking mixed tabs and spaces, unnecessary parentheses and newlines and a whole bunch of warnings appearing on the code from the IDE. For context I have this problem on java projects, where no formatting was agreed upon. Also, in my case they are projects that have not gone public yet. The possible solutions I can see are:   1. Try and talk to the team leader/code owner, agree to a formatting and reformat everything in one commit. (my preferred choice)   2. Format the piece or pieces of code that you have to change, commit, then make the change and commit (second best)   3. Deal with it, make your changes as minimal as possible, leaving everything else as was.. (worst choice, for me)


xml parser vs JSON parser performance in Java / C / C++

I am trying to understand which data format is better on embedded device communicating with Server over REST API. XML or JSON?. Is JSON parsing faster than XML parsing in Java / C and C++? I understand for web client JSON is way to go since java script has inbuilt support for JSON but not sure about embedded device(Java/C/C++).


Freelance web development vs. design

Do web design freelancers (I'm thinking individuals, not companies) typically do all development _and_ design work themselves? What are the options for those with a strong base in back-end web development but less with web design, color schemes, layouts, graphic design, etc.?


TDD: Where should I start?

I've read a lot about TDD and I've tried to develop using TDD without success ... I always stop staring at the screen... I've learned that I should not write tests for methods or class. I should write tests for behaviors. That's because objects interact with each other and this interaction should be tested. Following the example bellow: > Imagine that, I, as a company owner, would like to save my customers > information to consult that later. That's my business value. Just to learn, I would not like to use any framework or library, just plain PHP and PHPUnit. Ok, now, where should I start? I think that my users must enter an url to go to the form ... So should I test if it's loading the page? Is this a good start? If it's true, how could I test it?


Logic design question for SQL query

Was wondering if you could help me on a SQL problem I’m having. I have a set of records of events where each event has a start time and end time. No event has the same start time, and the end time for each event is greater than or equal to the preceding event. What I want to be able to do is pull out the set of records that are not overlapping – where the start time for an event is not between the start/end for any other event. In the example below, the start time for B/C/D are in- between A’s start and end, so I want to keep A, and get rid of B,C,D. Then start over again, keeping E, and get rid of F, then start over and keep G, getting rid of H/I, etc. Seems like this requires a self join but I can’t figure out the criteria for that would identify the records this way. Any ideas?               Event |  Start  | End     A             1            10 (keep)     B             2            11 (discard because start time of 2 < 10)     C             5            15 (discard because start time of 5 < 10)     D             9            12 (discard because start time of 9 < 10)     E             10           13 (keep -  this starts a new set because it’s the first record after A with start >= A end)     F             11           20 (discard because 11 < 13)     G             14           22 (keep -  this starts a new set because it’s the first record after E with start >= E)     H             15           22 (discard because 15 < 22)     I             17           27 (discard because 17 < 22)     J             22           27 (keep -  this starts a new set because it’s the first record after G with start >= G)


What do you put into an Architecture Specification?

I'm currently revising a number of document templates for my company. One thing we've never had is a formal Architecture Specification, so I'm starting to put one together. What sort of things do you put into your architecture specs? Feel free to copy and paste a table of contents - that would be helpful. Are there any good templates already available on the web?


The relation between Business Rules Engines and Constraint Programming languages

If one looks at (perhaps older) manuals of Drools or some other rule engines, one of the illustrations of their added value is solving puzzles such as the Miss Manners puzzle (manual of Drools). Now, such puzzles are naturally formulated and solved using Prolog or the more recent Constraint Programming languages, and one wonders why would anyone would use Drools for this purpose. The added value which Prolog and CPL give in this case is their ability to naturally formulate the puzzle as a set of logical predicates and to automatically search the space of solutions (with CPL being more efficient in this respect). But what is the added value of product such as Drools (I mean besides of the bells and whistles of taking, for example, an Excel file and translating it into a set of rules)? More specifically, Prolog implements backtrack search, CLP implement backtrack search with constraint propagation, and therefore instead of searching, so to speak, the whole Cartesian product of spaces for individual variables, they prune away large portions of this product space. This what makes them effective and useful. Both Prolog and CLP are discussed amply in the literature. On the other hand, while it is clear that Rete algorithm caches the set of rules in the form of some data structure(s), thus (to my understanding) making it more effective to evaluate the output if some of the inputs have changed, and giving means to efectively update this data structure for incremental changes, it is difficult (for me) to understand the basic idea, and even more so, its efectiveness (compared to what? to Prolog? to CLP)? Unfortunately, it is hard to find good references that view Rete algorithm in this wider context. The documentation of Drools is unfortunately not very informative in this respect. The most I could find was "The Rete algorithm, Leaps algorithm, and its descendants such as Drools' Reteoo (and Leaps), provide very efficient ways of matching rule patterns to your domain object data. These are especially efficient when you have datasets that do not change entirely (as the rule engine can remember past matches). These algorithms are battle proven". Very efficient - compared to what? Battle proven - could one point to real world applications? I would appreciate if one could throw some more light on this subject or give a valid reference.