title: How much mocking is "just right?"

text: I titled the question jokingly because I'm sure that "it depends," but I have some specific questions. Working in software that has many deep layers of dependency, my team has become accustomed using mocking fairly extensively to separate each code module from the dependencies beneath it. Therefore I was surprised that Roy Osherove suggested in this video that you should be using mocking only something like 5% of the time. I'd guess that we're sitting somewhere between 70-90%. I've seen other similar guidance from time to time as well. I should define what I consider to be two categories of "integration tests" which are so distinct that they really should be given different names: 1) In- process tests which integrate multiple code modules and 2) Out-of-process tests which talk to databases, file systems, web services, etc. It is type #1 that I am concerned with, tests which integrate multiple code modules all in- process. Much of the community guidance I have read suggests that you should prefer a large number of isolated, fine-grained unit tests and a small number of coarse-grained end-to-end integration tests, because unit tests give you precise feedback on exactly where regressions might have been created, but the coarse tests, which are cumbersome to set up, actually verify more end-to-end functionality of the system. Given this, it seems necessary to make rather frequent use of mocking to isolate these separate units of code. Given an object model as follows: ![enter image description here](http://i.stack.imgur.com/SIvbe.png) ... Also consider that our application's dependency depth goes much deeper than I could fit in this image, so that there are multiple layers N between the 2-4 layer and the 5-13 layer. If I want to test some simple logical decision being made in unit #1, and if every dependency is constructor-injected into the code module that depends on it such that, say, 2, 3, and 4 are constructor injected into module 1 in the image, I would much rather inject mocks of 2, 3, and 4 into 1. Otherwise, I would need to construct concrete instances of 2, 3, and 4. This can be more difficult than just some extra typing. Often 2, 3, and 4 will have constructor requirements which can be challenging to satisfy and according to the graph (and according to the reality of our project), I'll need to construct concrete instances of N through 13 to satisfy the constructors of 2, 3, and 4. This situation becomes more challenging when I need 2, 3, or 4 to behave in some certain way so that I can test the simple logical decision in #1. I might need to understand and "mentally reason about" the entire object graph/tree all at once to get 2, 3, or 4 to behave in the necessary way. It often seems much easier to do myMockOfModule2.Setup(x=> x.GoLeftOrRight()).Returns(new Right()); to test that module 1 responds as expected when module 2 tells it to go right. If I were to test concrete instances of 2 ... N ... 13 all together, the test setups would be very large and mostly duplicated. Test failures might not do a very good job of pinpointing the locations of regressions failures. Tests would not be independent (another supporting link). Granted, it is often reasonable to do state-based, rather than interaction- based, testing of the bottom layer, since those modules seldom have any further dependency. But it seems that mocking is almost necessary by definition to isolate any modules above the bottom-most. Given all of this, can anyone tell me what I might be missing? Is our team overusing mocks? Or is there perhaps some assumption in typical unit testing guidance that the layers of dependency in most applications will be shallow enough that it is indeed reasonable to test all of the code modules integrated together (making our case "special")? Or perhaps differently, is our team not bounding our bounded contexts adequately?


title: Is C++ not suitable for OOP?

text: I read somewhere in one of the answers to a question here (can't remember which) that C++ is not suitable for object-oriented programming. There was some mentioning that you could make use of its feature or something like that, but not in a purely OOP sense (I actually didn't really understand what the person meant). Is there some truth in this; if so, why?


title: PHP-based indexing and search implementation

text: Is there such thing? I designed a while back a rudimentary form based app for my users. We receive from our suppliers hardware manufacturing data in XML files: file name is made of eleven fields separated by tildes, with each field having its own meaning. R&D guys wanted to be able to search each field of the file names so I used regex() with decent results. Problem is that we have now in the upwards of 2.5 million files. And my app can't hack it anymore. I looked at Apache Lucene & Solr. Though it seemed like the best solution to my problem, the fields in the filenames are not peers to the file content. Big no-no with Solr. What is the best way to implement a PHP app with indexing and search capability with such large number of files? Do I have to buy Zend and use Zend_Search? Is it the only way? Thanks for your input.


title: Choosing the right version control system for .NET projects

text: I'm getting ready for my first "bigger" .NET project (ASP.NET MVC 3/4) on which I'm going to lead another 2 programmers and right now I'm choosing the right version control system for the job (plus I'm gonna use it for my future development too). My problem is that I did't use any version control system before, so I would like it to have as fast learning curve and intuitive merging as possible. So far I quickly looked at VisualSVN (I like the Visual Studio integration in it), but I'm reading everywhere how Git is awesome and dunno which one to choose (not limited to these two).. Maybe I'm ovethinking this but I like when everything goes smoothly:) I'd like to hear some opinions from people who used multiple version control systems (preferably on VS projects) **what do you think is the less complicated and effective version control system for such a use (one to 5 man projects)?**


title: 2D linked list vs. multidimensional array/vector

text: I hope that programmers is the correct stack exchange for this, as it is quite a concept based question. I'm working on a data structure in C++ that is a represents data in 3D space. The x-y plane is large (say 0 - 10 000) while the z-axis has a very small range (0 - 10). All the data is located on integer (x,y,z) points. However there can be more than one than one data point on an (x,y,z) coordinate. I have thought of three ways of approaching this subject, and don't have the necessary experience to choose between them.   1. Using a 2D linked list inside vectors (dynamic arrays) `vector<vector<structureA*>> Data` where the first list item for that (x,y) point can be accessed using `Data[x][y]`. structureA contains an its z value, its actual data, as well as a pointer to the next structure in the list (that may, or may not have a different z coordinate, but is located on the same line defined by x and y). Accessing elements at the middle and end of this list is slow.   2. Using a three dimensional array/vector: `vector<vector<vector<structureB>>> Data`. In this case the first two vectors define the x and y coordinates (as before) and the third vector gives us an array of all of the elements on that line defined by x and y. We can quickly determine how many elements are on this line (by querying the third vector) and can iterate from the back and the front. `structureB` contains, the point's z value and its data. This seems like a fairly good and safe (regarding memory allocation) solution to me.   3. Using a three dimensional array/vector and a linked list. In this case the data could be accessed as such: `Data[x][y][z]` and would point to the first element of a linked list of data that resides at this coordinate. The structure pointed to would not contain its z value here as this is already dealt with in its address in the array. However, many (x,y,z) points have no data, whereas most of those that do have data have 10+ data structures. (All lines defined by a specific (x,y) contain at least one structure). This seems the worst solution to me as in many cases I would have to iterate through empty z coordinates, before hitting a linked list to iterate through. The emphasis in this program is speed, my data set is less than 100MB on a modern computer, so even an inefficient method of storing it in RAM is fine. Option 2 seems the best to me, although in the past I've normally seen people more inclined to go with option 1. I'm interested to hear your opinions on the best way to handle this along with your reasoning. Many Thanks. **Update** Thanks for the responses, I stand to learn quite a lot from your comments as I am a hobby programmer, having taken only one short course on the fundamentals of C a few years back. @MorphingDragon The array is not jagged, all z "slices" have the same range of x and y. The values also don't seem sparse enough for a hash table (which IIRC slow down significantly on hash collision - which is guaranteed as multiple elements have the same (x,y,z)). The dimensions of the set are known on file load (they are included in the file header along with an md5 hash of the file for error checking and a few bit relevant to the analysis). @J Trana / Florian F The data set is pre-built and is infrequently modified by the program - a piece of data may need to be moved or deleted. For adjusting data particularly just adjusting its z-value (or removing it), which are the most frequent operations. The linked list will be faster as these operations are O(1) as opposed to O(n) in a vector. However, I believe these changes are infrequent enough that having O(n) for changes may be worthwhile if the lookup speed is even marginally faster (as this is the more frequent operation). The majority of the time the data will be accessed iteratively, taking an n*p slice from the x-y plane. Pseudocode example:               for each y between startY and (startY + p)       for each x between startX and (startX + n)         read all nodes in Data[x][y] //gets nodes for each z on an (x,y) line         analyse(&nodes) //possibly modify the nodes, possibly just compute something based on their values      Data access is **always** related to the (x,y) line an element is on, but we don't always need all the nodes on that line (dependant on their z). So we either have a structure that doesn't require us to retrieve all of them (just the ones we want) or we perform a secondary sort. The data on file represents a sorted list in ascending z for each (x,y). I will also look into those other data structures. I've never met them, as with very little training, my method is to use STL vectors or lists for everything. I'd like to spend the time to do this properly this time though. I spent a fair amount of time thinking about this last night after posting the question and seeing the first responses. I realised that "if one piece of data from a point (x,y,z) is required, then all elements from that point are required at the same time." This has led me to think that option 3, my least preferred when I started this yesterday afternoon, is actually the best of the options I've enumerated. If I use a three-dimensional dynamic array of pointers to linked list, I don't exactly lose much speed or heap space setting a pointer to NULL rather than attaching a struct. This also allows full access to any 3d, which while not currently _required_ may reduce some operations from O(n) to O(1). Having had a brief look over octaves/r-trees, I feel safe saying that my data set is not complex enough to require such an engineering heavy solution. When it comes down to it, i am fairly sure that any of the three options I outlined would work, even if not the fastest, but I would like to learn a good and relatively efficient method, rather than just relying on the awesome power of modern computers to brute force a problem like I normally do. Thanks for the replies and suggestions so far. :)


title: A scheme to check only one namespace in an XML document

text: I want to validate an XML document against some XML scheme, but ignore all elements (and probably attributes) which are not of a given namespace. Does such a XML scheme language exist?


title: Help with Abstract Factory Pattern

text: I need help with a abstract factory pattern design. This question is a continuation of: Design help with parallel process I am really confused where I should be initializing all of the settings for each type of medium (ex: RS232, TCP/IP, etc). Attached is the drawing on how I am setting up the pattern: ![enter image description here](http://i.stack.imgur.com/mDfjH.png) As shown, when a medium is created, each medium imposes a **ICreateMedium** interface. I would assume that the Create() method also create the proper object, such as SerialPort serialPort = new SerialPort("COM1", baud); however, TCPIPMedium would have an issue with the interface because it wouldn't need to initialize a serial port object. I know I am doing something majorly wrong here. I just can't figure it out and have been stuck for a while. What I also get confused on show the interface **IMedium** will get access to the communication object once it is created so it can write out the appropriate byte[] packet. Any guidance would be greatly appreciated. My main goal is to have the **Communicator** class spit a packet out without caring which type of medium is active.


title: Which approach would be better for persisting these overridable configuration keys and values? A simple key-value store, or a graph database?

text: I'm creating a system where there are config keys and values. So for example:               config.key = 10      Is an example of a configuration key and a value. These keys can also have overrides based on "dimensions". So for example, if we wanted to apply `config.key` to applications with the dimension `foo`, the overridden key would essentially be:               config.key.foo = 20      In future we may have multiple dimensions in arbitrary order, so this could be a possibility in future:               config.key.foo.bar = 30      A more concrete example would be if we had a key/toggle called `display.pintrest.feed` that has a `boolean` value. So the default value would be `false`, but you could have overrides like so:               display.pintrest.feed = false     display.pintrest.feed.femaleUser = true      Here `femaleUser` is a dimension (so we want to set the value of this config to `true` for only female users). This is essentially what I am trying to do. My question is regarding persistence. What would be the best way to persist this kind of data? This is data that will be queried somewhat frequently but written to less often. The naive solution would be to use MySQL or PostgreSQL and create a table like this:               +----------------------------------+-------+     |                Key               | Value |     +----------------------------------+-------+     | config.key                       | 10    |     | config.key.foo                   | 20    |     | display.pintrest.feed            | true  |     | display.pintrest.feed.femaleUser | false |     +----------------------------------+-------+      But we lose the type safety of `Value` and also have a single point of failure. We also have a lot of redundancy (the base part of the configuration key is repeated each time). So I wondered about perhaps representing it as a graph so that I could write it to a graph database. I was thinking of modeling it like so: ![enter image description here](http://i.stack.imgur.com/X8Evj.png) Is this viable or overkill? I don't mind using a simple key-value store either but it should be fault- tolerant and should be able to be clustered. Also we only really care about eventual consistency (i.e., don't mind it taking time to propagate changes to all the nodes). So my question is what kind of data store should back this kind of data? Is a simple key-value store enough or should I go for a graph database? My rationale for the latter is simply to mitigate the redundancy from keys but I don't know if that's strong rationale.


title: Is my sequence diagram correct?

text: NOTE: I am self studying UML so I have nobody to verify my diagrams and hence I am posting here, so please bear with me. This is the problem I got from some PDF available on Google that simply had the following problem statement: **Problem Statement** : A library contains books and journals. The task is to develop a computer system for borrowing books. In order to borrow a book the borrower must be a member of the library. There is a limit on the number of books that can be borrowed by each member of the library. The library may have several copies of a given book. It is possible to reserve a book. Some books are for short term loans only. Other books may be borrowed for 3 weeks. Users can extend the loans. Draw a use case diagram for a library.      I already drew the Use Case diagram and had it checked by a community member. This time I drew **sequence diagrams** for borrowing a book and extending the date of return.   Please let me know if they are correct.   I drew them using _Visual Paradigm_ and I dont know how to keep a control of the sequence numbers. If you do, please let me know :)      **Diagrams** ![Borrowing](http://i.stack.imgur.com/WebPr.png)    ![Extending the date](http://i.stack.imgur.com/6YWMt.png)


title: Wpf: Event driven vs MVVM design pattern

text: I'm a beginning coder and I've been working on a WPF app for several months now and struggled to implement anything in MVVM due to time constraits to learn so I coded my program the only way to knew how: with code behind, tight coupling, and a whole bunch of spaghetti code. My program has grown into 20,000+ lines of messy (but working) code that is mostly event driven. The app I am building will probably be used and continue to be developed for years to come, but I will be the only one working on the code. However, now that I have time to start learning MVVM, I'm wondering how useful it really is to follow the MVVM pattern. I'm considering refactoring my code into the MVVM pattern but everything seems 100x difficult to do with little documentation. With using code behind and tight coupling, I can make the UI do exactly what I want it to do and everything seems like it can be coded so much faster through the event-driven methods. How important is it to follow the MVVM design pattern for WPF apps, especially in the long run? Do you think it's a good idea for me to invest my time to redesigning this app and following an MVVM pattern?


title: Learning new thing and implementing new thing in a company

text: In my new company, I wanted to use Doctrine DBAL for data abstraction. But it's not working due to the PHP Version 5.2 we are using on our development server. Here it's all about rights issues. You don't have access to anything. I can't use anything new due to this rigidity of the product! What can I do about this? How should I talk to my TL and project manager about this?


title: Creating a new database with Active Record

text: Please tell me if this is mad, but basically, I've created a custom rake task, and before it does its thing, it gives the user a warning message:               Warning, please back up your database before continuing      Just in case something does go wrong. But I thought this would be awesome:               Warning, please back up your database before continuing. Do you wish to create it now [Y/N]      and upon pressing Y, the existing database would be replicated. I don't want to create to duplicate the tables, I literally want to create a new, pristine, isolated database so that their architecture is identical, just in-case something does go wrong. I don't want any dependencies though, I only want to use libraries included with Rails. Could I have a simple example of how to create an empty database with RoR, if this is possible? I can create a new database like this:                 require 'sqlite3'            db = SQLite3::Database.new( "test.db" )      However, this will only work if the user is using sqlite3. I can detect which database they're using with               database_type = ActiveRecord::Base.connection.adapter_name #=> sqlite3      and then use a case statement to execute slightly different commands for each database type, but that seems a bit elaborate, and not very dynamic. (Every single database will have to be thought up before-hand). So can I do it through Active Record?


title: Why is (f . l) not allowed and equal to (apply f l)?

text: In scheme when defined               (define f (lambda (a b c d) d))          (define l (list 'a 'b 'c 'd))      Why it does not do argument destructuring? I mean arguments should evaluate first, why destructuring is not part of that?               (f . l)      What are reasons that this expression is not equal with following?               (apply f l)        * Edited to make it clearer, according suggestions in comments


title: How do you organize highly customized software?

text: I'm working on a large software project which is highly customized for various customers arround the world. This means that we have maybe 80% code which is common between the various customers, but also a lot of code which has to change from one customer to the other. In the past we did our development in separate repositories (SVN) and when a new project started (we have few, but large customers) created another repository based on whatever past project has the best code basis for our needs. This has worked in the past, but we ran into several problems:   * **Bugs** which are fixed in one repository are not patched in other repositories. This might be a problem of organization, but I find it difficult to fix and patch a bug in 5 different repositories, keeping in mind that the team maintaining this repository might be in another part of the world and we don't have their test environment, neither know their schedule or what requirements they have (a "bug" in one country might be a "feature" in another).   * **Features** and improvements made for one project, which might also be useful for another project are lost or if they are used in another project often cause big headaches merging them from one code base to another (since both branches might have been developed independently for a year).   * **Refactorings and code improvements** made in one development branch are either lost or cause more harm than good if you have to merge all these changes between the branches. We are now discussing how to solve these problems and so far came up with the following ideas on how to solve this:   1. **Keep development in separate branches** but organizing better by having a central repository where general bug fixes are merged into and having all projects merge changes from this central repository into their own on a regular (e.g. daily) basis. This requires huge discipline and a lot of effort for merging between the branches. So I'm not convinced that it will work and we can keep this discipline, especially when time pressure puts in.   2. **Abandon the separate development branches** and have a central code repository where all our code lives and do our customization by having pluggable modules and configuration options. We are already using Dependency Injection containers to resolve dependencies in our code and we are following the MVVM pattern in most of our code to cleanly separate business logic from our UI. The second approach seems to be more elegant, but we have many unsolved problems in this approach. For example: how do handle changes/additions in your model/database. We are using .NET with Entity Framework to have strongly typed entities. I don't see how we can handle properties which are required for one customer but useless for another customer without cluttering our data model. We are thinking of solving this in the database by using satellite tables (having a separate tables where our extra columns for a specifiy entity live with a 1:1 mapping to the original entity), but this is only the database. How do you handle this in code? Our data model lives in a central library which we would not be able to extend for each customer using this approach. I'm sure that we are not the only team struggling with this problem and I'm shocked to find so little material on the topic. **So my questions are the following:**   1. What experience do you have with highly customized software, what approach did you choose and how did it work for you?   2. What approach do you recommend and why? Is there a better approach?   3. Are there any good books or articles on the topic that you can recommend?   4. Do you have specific recommendations for our technical environment (.NET, Entity Framework, WPF, DI)? **Edit:** Thanks for all the suggestions. Most of the ideas match those that we already had in our team, but it is really helpful to see the experience you had with them and tips to better implement them. I'm still not sure which way we will go and I'm not making the decision (alone), but I will pass this along in my team and I'm sure it will be helpful. At the moment the tenor seems to be a single repository using various customer specific modules. I'm not sure our architecture is up to this or how much we have to invest to make it fit, so some things might live in separate repositories for a while, but I think it's the only longterm solution that will work. So, thanks again for all responses!


title: What is spreadsheet useful for?

text: I have been in computer business for 15 years in various roles (sysadmin, developer, researcher), and I have never encountered someone using excel for something more advanced than for formatting tables, or as an ad-hoc database that could have been maintained in a text-file. I had to do heavy data-processing and plotting and for that I used some perl scripts + gnuplot, got tiredof it, and went over to R eventually. 2D spreadsheet just didn't seem well-suited for doing statistical analyses over 5-dimensional datasets (not to mention that it produces _UGLY_ plots). I attempted to use spreadsheet for time-tracking, and found out that I would have better been served by a relational database, so I gave up on using excel for that too. For example, it's important to consistently name tasks, and I needed to find out unique task names in a given column across several sheets (I had one timesheet for each month). How do you make such "query" in a program that essentially evaluates independent cells and has little notion of relations between them? So, what _are_ spreadsheets useful for? Why do they have a bunch of mathematical stuff built into them when, AFAICT, people use them mostly as table formatters or bad substitutes for databases?


title: How do I know if I have a good programming professor?

text: Today I begun my second programming course. The professor seemed a bit different from the others - we had some fun saying things like _"he's probably a misunderstood genius"_. He criticized some other (long gone) professors (with good reasons). Then it struck me to ask him _"how do I know if **you** are a good professor?"_ ... but I decided to save it for later... Now, however, such question has developed a lot in my mind. I'm very curious - **how do I know if my programming professor is good**? Some observations:   * Apparently, very few students do finish the course with him with aceptable scores - but it is possible it is the students' fault, not his.   * From our brief first class, I understood very well whatever he said (he talked a bit about everything). But I feel it might be because I was already prepared and had good experience programming before, and not necessarily the fact that he's good at expressing his ideas.   * He has a tendency to make jokes. Like most professors I've met. Unfortunately, he is the least funny.


title: Senior software developer

text: I'm not sure if this is the place of my question or not. I'm working in a software company as senior software engineer, but my team leader is controlling everything in the development life cycle. I can't give my opinion on anything. I'm just forced to tasks only without any discussion. I can't even apply any design patterns or UI guidelines. Is that OK in my career position now? What is the responsibilities of senior engineer?


title: Proper Response to HTTP Request When Too Much Data is Requested

text: 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


title: High-level language to assembly

text: 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?


title: How ad retargeting works?

text: 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?


title: How to effectively share projects with other developers

text: 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!


title: Would Using a PHP Framework Be Beneficial in My Context?

text: 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.


title: Are some NOP codes treated differently than others?

text: 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?


title: How to avoid javascript becoming spaghetti code?

text: 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"?


title: Advantages of Scrum for the developers themselves?

text: 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?


title: Software Health Check Audit Template / Checklist

text: 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


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

text: 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.


title: C# Algorithms for * Operator

text: 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#?


title: Should I switch tech.?

text: 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


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

text: 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?


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

text: 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.


title: Text search - big data problem

text: 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


title: Architecture : am I doing things right?

text: 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, ...)


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

text: 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


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

text: 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?


title: Is functional programming a superset of object oriented?

text: 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).


title: Specific reasons for still using Subversion?

text: 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?


title: Pitfalls of using MySQL as your database choice?

text: 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?


title: Single responsibility principle - am I overusing it?

text: 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


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

text: 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?


title: What is the difference between skill level amongst programmers?

text: 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.)


title: Open Source License that prevents re-selling

text: 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?**


title: Programming SOLID Principles

text: 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)


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

text: 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.


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

text: 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)


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

text: 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


title: Adding a forum to an existing site

text: 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.


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

text: 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?


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

text: 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.


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

text: 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?


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

text: 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?


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

text: 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?


title: Programming with voice recogition software

text: 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.


title: Do DVCSes discourage continuous integration?

text: 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?


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

text: 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.


title: Open source from protected rights

text: 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?


title: Assigning responsibility for cancelling an Order

text: 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?


title: Checked vs unchecked exception when validating documents in this service

text: 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.


title: Scaling Azure across subscriptions

text: 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?


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

text: 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.


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

text: 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...


title: Reverse subarray of an array with O(1)

text: 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?


title: How to write a good exception message

text: 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.


title: Running time question

text: 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))      }


title: Fixing sudden serious problem in software

text: 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?


title: How to promote code reuse and documentation?

text: 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.


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

text: (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.


title: Training a newbie tester

text: 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.


title: Obsession, how much is too much?

text: 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?


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

text: 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.


title: What should be the Roadmap for JAVA EE

text: 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 ?


title: Planning to move to financial sector

text: 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


title: How to incrementally update a database when deploying a website?

text: 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?


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

text: 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?


title: Access items of a container with a pattern

text: 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?


title: Concurrency checking with Last Change Time

text: 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?


title: How does Google plus page loading work

text: 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?


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

text: 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?


title: Why not use the word bug instead of exception?

text: 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.


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

text: 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?


title: Hosted Mercurial with Project Management tools

text: 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.


title: How would you approach this Domino problem?

text: 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.


title: moving from development to quality assurance

text: 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.


title: How to manage IDE project files on a forked repository

text: 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.


title: How can I manage my ViewControllers in my game?

text: 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.


title: Referencing countries via Foreign Key Constraint

text: 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?


title: Working alone on a project

text: 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?**


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

text: 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._


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

text: 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?)


title: Usefulness of Javadocs with unit testing?

text: 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.


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

text: 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. :)


title: Why use sealed instead of static on a class?

text: 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.


title: Question about a voting system implementation

text: 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?


title: Converting to a mac-book pro for multi disciplined development

text: 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?