title: Self reference using a new table vs concatenated list of ids

text: At my current workplace there is a common pattern in database design: they don't use foreign keys but they list all corresponding ids in a column like this:               some_table     id  name image_ids     1   a    1,2,3     2   b    4,6,7          images     id url     1  ...     2  ...     ...      They store self references in a same manner:               some_table     id  name  some_table_id     1   a     2,3     2   b     1,3     ...      They encourage me to use this pattern but it does not feel right for me. I would never design a database like that. I have some counter arguments against it:   * What if some day I would add some arbitrary data to a self reference? Using this model I would not be able to.   * It does not ensure referential integrity. I can easily add non-existent ids which will lead to problems   * Searching through strings is not fast either I need to justify my complaints so my question is: What persuasive counter- arguments can you come up with against this hacky design approach?


title: Why should IQueryProvider implementations throw NotSupportedExceptions?

text: Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don't actually support the full `IQueryable<T>` interface, throwing `NotSupportedExceptions` when they encounter something they don't like, such as LinqToSql and `SkipWhile`. My question is this: why do ORM providers opt to throw a `NotSupportedException` instead of letting certain query operators (that do not translate well or at all to the target data source) trip a query execution and then let Linq to objects handle the rest? I understand that some heavy physical resource usage could occur as a result, but if `IQueryable<T>` instances were _truly_ swappable, would we not be better off?


title: Standard practices for an architect

text: I am the architect for my group. Unfortunately I was given this position organically and there are no standards in place for how I should do my job. At different companies, how does the architect role work? I am very interested, for example, in what type of diagrams and documents an architect might provide so that they can assist a developer in doing their job.


title: What's the best approach to building a db schema for profile, but to track changes?

text: I'm working on a site where companies can create a profile then add locations for each profile. Those first two tables are simple enough. But any changes to their profiles or locations have to go through an approval process. This is where I'm torn. The end result would be an employee going through a worklist and seeing the requested changes and clicking "approve" or "deny". Approve applying the new data to the existing record, deny setting a flag on the request record(s) and sending a response. What I'm wondering is the best way to go about the change requests. I would definitely like to keep the change requests in a separate table than the profile or location table. I can't decide if it's best to just create duplicates with a few extra columns of the profile and the location tables and use those for change tracking. Or if I should just create a simple table with just the columns to capture the change target id, field, and value, plus a few extras like changeset, datetime, flag, etc. What do you think?


title: Multi-Thread Return Single SQL Result

text: I am having some difficulty with MySQL and returning a unique row to a thread. I want it so the thread will search for a row from the table where the bit (see below) is false and only one row is returned. But I don't want the other threads to return the same result should there might be some race condition where the same result is returned to the thread; because the thread will then do lots of processing off the back of this result and I don't want duplication. Background: I have a MySQL database that contains 3 columns (id, text, bit). The id is auto-incremented. I have a multi-threaded Ruby application that reads, updates and inserts rows into the table. Pseudo code for the thread is as follows:               select a row from the table where the bit is false     do some processing with the text returned from that row     insert more rows with bit set to false      I have tried a simple test with a multi-threaded script that uses the following:               SELECT id, text FROM table WHERE bit =FALSE LIMIT 1 FOR UPDATE      But each thread returns the same row. I have disabled autocommit as per the recommendation. Since I am omitting any commit I would expect the other threads to have a different result since the row is locked. Am I missing something or should I be looking at using another method?


title: Is Scala ready for prime time?

text: Now that I've done a few trivial things with Scala (which I love for "hello world" and contrived applications!) I am left wondering.. part about maturity of the tools to support development, and part about general applicability. Are the toolsets ready? Is Scala appropriate for use on enterprise / business applications? Would "you" use it on a non-trivial project? Some of my (possibly unfounded) concerns would be:   * are the IDE and toolsets as rich as what we have to develop .net and java applications (eclipse for Scala seems limited compared to eclipse for java)?   * are the build / CI / testing toolsets able to effectively deal with Scala?   * how maintainable is the concise code that _can_ be (encouraged?) written in the language?   * is it possible to find developers with Scala experience?   * is there enough critical mass to get help through on-line reference and books that are more than "intro" to the language? So bottom line - is the ecosystem mature enough to use now, or better off waiting to see how it evolves? EDIT: let's say "non-trivial" is a multi-year, multi-release, 10-20 developers project.


title: Is there a language where collections can be used as objects without altering the behavior?

text: Is there a language where **collections** can be used as **objects** without altering the behavior? As an example, first, imagine those functions work:               function capitalize(str)          //suppose this *modifies* a string object capitalizing it     function greet(person):         print("Hello, " + person)          capitalize("pedro")     >> "Pedro"          greet("Pedro")     >> "Hello, Pedro"      Now, suppose we define a standard collection with some strings:               people = ["ed","steve","john"]      Then, this will call toUpper() on each object on that list               people.toUpper()      >> ["Ed","Steve","John"]      And this will call greet once for EACH people on the list, instead of sending the list as argument               greet(people)     >> "Hello, Ed"     >> "Hello, Steve"     >> "Hello, John"


title: What are best practices to read high level undocumented and uncommented code?

text: There are some opensource projects, that have classes and classes without any significant explanation about what the class does and or why is that class needed. For example, classes in the CppEditor plugin for QtCreator. What are the best practices to read undocumented code? Don't read it, is not an option :)


title: Do you have your own 'misc utils' library? What part are you most proud of?

text: I know that many of us maintain our own little personal library with tools and utilities that we use often. I've had mine since I was 16 years old so it has grown to quite a considerable size. Some of the stuff I've written has since been added to the framework. I wrote my own little implementation of expression trees for use with genetic algorithms long before LINQ, which I quite like and was proud of at the time - of course its pretty useless now. But recently I have been going through it and upgrading to .NET 4.0 and re-kindled an interest. So I'm curious as to what you use your library for. Maybe we could get some cool ideas going for useful little snippets and share them amongst ourselves. So my questions are:   * Do you have a miscellaneous utility library?   * Which part are you most proud of and why? Give an example of code if you like `:-)`


title: Class design, One class in two sources

text: Is it possible define methods from **the same class** in different "CPP" files? * * * I have header file "myClass.h" with:               class myClass     {     public:         // methods for counting         ...         // methods for other         ...     };      I would like to define "methods for counting" in one CPP and "methods for other" in other CPP. For clarity. Both groups of methods sometime use the same attributes. Is it possible? Thanks :).


title: Thoughts of Cloud Development/Google App Engine

text: I use mainly PHP for web development, but recently, I started thinking about using Google App Engine. It doesn't use PHP which I am already familiar with, so there will be a steeper learning curve. Probably using Python/Django. But I think it maybe worthwhile. Some advantages I see:   * Focus on App/Development. No need to setup/maintain server ... no more server configs   * Scales automatically   * Pay for what you use. Free for low usage   * Reliable, it's Google after all Some concerns though:   * Does database with no joins pose a problem for those who used App Engine before?   * Do I have to upload to Google just to test? Will it be slow compared to testing locally? What are your thoughts and opinions? Why would you use or not use App Engine?


title: How do web apps create subdomains?

text: I want to understand the architecture of web apps that use subdomains. I don't think that I'm phrasing this well, so let me explain. Many web apps, like tumblr or shopify create a user's site on a subdomain. Say for example my tumblr account was `johndoe` then you could find my tumblr blog at `johndoe.tumblr.com`. Can someone explain how this is implemented?


title: How do you migrate from one language to another?

text: I know that language is just a tool and it's all about creating product. But if you are all about enterprise and than you change to mobile development - how do you manage it?   If I am used to PHP and it's framework and switch to Ruby - how do I deal with it? With learning and getting experience with Rails, with Ruby language and so on.   What if I was C++ programmer working on standalone programs? And than I switch to Python/Django for web? In general, here are my questions for all the examples above:   1. Is it possible to switch your specialisation as software developer? From web-development to enteprise, from standalone to mobile, etc. If yes, how? Or should I stick with one path to become expert in it?    2. How do you learn new languages? I mean, there are new frameworks you need to learn, and if it's different development sphere - say, mobile after web-development - you need to learn basic stuff for this sphere, right? How do you handle it?    3. Is switching language/career path hard in terms of getting new job since you dont have any experience in this language? Do you downgrade in salarys?  _**Please explain it all to me! How do people handle it? I am 100% sure I love development, atm I love PHP/RoR and web-development, so I use PHP as my main language at fulltime job, but I don't want to stick with it forever and I want to be able to change languages or/and maybe development direction (mobile, standalone, enterprise). How do you do it without hurting your career, or is it impossible?_**


title: Is there any hard data to back up "Human task switches considered harmful"?

text: Joel Spolsky wrote a famous blog post "Human Task Switches considered harmful". While I agree with the premise and it seems like common sense, I'm wondering if there are any studies or white papers on this to calculate the overhead on task switches, or is the evidence merely anecdotal?


title: Moving Old Projects To Newer IDE's and Libraries

text: At work we have a few older projects that are stuck on .NET 1.1 and VS 2003. While these are probably to much work now to move forward I'm wondering if the effort to keep our newer projects up to date will be worth it. Specifically we would be looking at moving about 30 projects from .NET 3.5 to .NET 4.0 and VS2008 to VS2010. My Questions for the community are: **Do you move your projects along as new tools and libraries become available or just start the newest stuff in the newest versions? If you do move forward have you found the benefits out weigh the cost of the upgrade?**


title: What techniques are used in solving code golf problems?

text: ### "Regular" golf vs. code golf: Both are competitions. Both have a well-defined set of rules, which I'll leave out for simplicity. Both have well-defined goals; in short, "use fewer hits/characters than your competitors." To win matches, athletic golfers rely on   * equipment      * Some situations call for a sand wedge; others, a 9-iron.   * techniques      * The drive works better when your feet are about shoulder width apart and your arms are relaxed.   * and strategies      * Sure, you could take that direct shortcut to the hole... but do you really want to risk the water hazard or sand bunker when those trees are in the way and the wind is so strong? It might be better to go around the long way. **What do code golfers have that's analagous to athletic golfers' equipment, techniques and strategies?** Sample answer to get this started: use the right club! Choose GolfScript instead of C#.


title: Most frequently used design patterns in refactoring (my example)

text: I've been doing quite a lot of refactoring of C++ and C# code recently, and found that 90% of the patterns I use are:   * Template method   * Factory   * Singleton Are these generally the most commonly used patterns in refactoring or is it just me? Can you share your refactoring experiences?


title: Why is MVC more popular than PAC?

text: I just stumbled upon a question at SO about PAC and got interested in the pattern. I'm wondering why it's not as widely used as MVC? What is the MVC benefits compared to PAC?


title: What happens if we serialize and deserialize two objects which references to each other?

text: To make it more clear, this is a quick example:               class A implements Serializable { public B b; }     class B implements Serializable { public A a; }     A a = new A();     B b = new B();     a.b = b;     b.a = a;      So what happens if we serialize a and b objects into a file and deserialize from that file? I thought we get 4 objects, 2 of each. Identical objects but different instances. But I'm not sure if there's anything else or is it right or wrong. If any technology needed to answer, please think based on Java. Thank you.


title: Encountering the same issue in an application

text: I've often come across the situation when the same mistake is made in many places in an application. For example, in a web application when the user creates an item and clicks the `Add` button to save it. If they click the button several times, multiple items are added instead of one because UI wasn't blocked and backend check wasn't performed properly. How to create bug tickets in such cases? Here are the solutions I could think of:   * create one single bug ticket and list where the situation occurs   * for every case found create a separate ticket   * when finding the bug tell the development to pay attention, wait till they are finished and test again


title: Is this an appropriate use of Mockito's reset method?

text: I have a private method in my test class that constructs a commonly used `Bar` object. The `Bar` constructor calls `someMethod()` method in my mocked object:               private @Mock Foo mockedObject; // My mocked object     ...          private Bar getBar() {       Bar result = new Bar(mockedObject); // this calls mockedObject.someMethod()     }      In some of my test methods I want to check `someMethod` was also invoked by that particular test. Something like the following:               @Test     public void someTest() {       Bar bar = getBar();            // do some things            verify(mockedObject).someMethod(); // <--- will fail     }      This fails, because the mocked object had `someMethod` invoked twice. I don't want my test methods to care about the side effects of my `getBar()` method, so would it be reasonable to reset my mock object at the end of `getBar()`?               private Bar getBar() {       Bar result = new Bar(mockedObject); // this calls mockedObject.someMethod()       reset(mockedObject); // <-- is this OK?     }      I ask, because the documentation suggests resetting mock objects is generally indicative of bad tests. However, this feels OK to me. **Alternative** The alternative choice seems to be calling:               verify(mockedObject, times(2)).someMethod();      which in my opinion forces each test to know about the expectations of `getBar()`, for no gain.


title: Other than for legacy software, are there reasons for using COBOL?

text: COBOL is still (heavily?) used for financial computing. It is an old language, and AFAIK most programmers hate, or at least dislike, COBOL. This brings a question: is the only reason COBOL is still used that legacy software uses it, or does it have any real advantages over other programming languages? Just curious.


title: Python template engines: What are the real benifits and drawbacks to XML vs custom syntax

text: I'm interested in knowing what are the real difference (benefits and drawbacks) between the two types of python templating engines; XML (like Genshi or Kid) and a custom syntax (like Cheetah or Jinja2). I'm not looking for which is better, or a recommendation. I understand that no one solution will be perfect, and that the best solution will depend on the problem. I do want to better understand the differences between the two types before I choose one for my problem. This list may not apply to all templating solutions. XML Benefits:   * Uses XML, it's mostly familial to developers. There are a few new (ifelse, flow logic) items to learn.   * It works with existing XML toolchains.   * It's more powerful as it is knowledgeable about the data being worked on. (Genshi is context aware) XML Drawbacks:   * The XML based engines tend to be slower than the custom syntax engines.   * Some will argue that XML is more difficult to learn than custom syntax. Custom Syntax Benefits:   * It's fast than XML based engines. (see earlier link)   * It's a simple powerful syntax that should be easier to learn. Custom Syntax Drawbacks:   * It's another syntax to learn.   * It might not work smoothly with existing XML toolchains.


title: Is it possible to read memory from another program by allocating all the empty space on a system?

text: Theoretically, if I were to build a program that allocated all the unused memory on a system, and continued to request more and more memory as other applications released memory that they no longer need, would it be possible to read recently released memory from another applications? Or is this somehow protected by modern operating system? I have no practical application for this, I'm just curious. I realize there are some issues with allocating "all available memory" in real-life. Edit: To clarify, I'm asking specifically about "Released" memory, not accessing memory that is currently allocated by another application.


title: How do I pick which agency to go through?

text: I work in a town where the majority of work comes from the government. As a contractor, I generally have to apply for work through agencies which are on the government's preferred vendor's list. Most jobs are publicly listed and to apply for them, you generally need an agency to represent you by submitting your application with a rate which is usually your rate plus their commission. I've been trying to figure out what the agencies do, and it seems a large part of what they do is 1) get on that preferred vendor's list and 2) forward resumes. So right now, my policy is that since their commission affects how expensive I am, one - I don't work with companies that do not disclose their margin. And two, I go for the agency that takes the least amount of commission for the job I want to apply for. IS that the best approach? I would think applying for a job with the most competitive rate is the best approach but I also wonder whether which agency you're applying through actually matter? I know some agencies actually build personal relationships with senior managers but how do I know which one? How do I know that actually affect my job prospects? What criteria should I use to decide which agent I go through for the job?


title: question, the best data structure and algorithm

text: I have a question about implementing a data structure (with algorithm) that has these features:   1. There are too many places (like stores), and each place can store too many items, I want to store items in the places. The point is we need to have optimized insertion (or deletion) and optimized search feature.   2. Search can be done based on places (return items in the place) or base on items (return places that have the item) I thought to use a hashmap for this, and use places ID as the key and store items as a collection (again a hashmap with item id for both key and value). So based on this, the insertion of each item or place would be O(1) but get or remove of place will be O(n) and for item it will be O(n*k)! (assume we have "n" places and "k" items - I hope this is the correct calculation). Is there any better data structure or algorithm for this problem?


title: Always keep files updated in Eclipse

text: I keep lots of files/editors open in Eclipse. I also love using `git stash` and other git commands that essentially change the contents of my open files. Is there an Eclipse feature or plugin that will always keep the contents of my open files up to date and live? Currently if I put focus in an out of sync editor, I get an awkwardly worded dialog that I have to parse carefully every time. I wish it would just keep me synced like Textmate does.


title: Do you prefer building your interfaces in IB or programmatically? and why?

text: I've been using Xcode and building iPhone apps for two months, but I'm finding it really hard to grasp good application design. I always face problems—like you can't put your tabbarcontroller in another custom viewcontroller, for example—that 'sometimes', of course, would work if you did the creation of the views/viewcontrollers programmatically. So I don't know if I should start writing the creation of my objects or use Interface Builder. What are your experiences?


title: How do you track existing requirements over time?

text: I'm a software engineer working on a complex, ongoing website. It has a lot of moving parts and a small team of UI designers and business folks adding new features and tweaking old ones. Over the last year or so, we've added hundreds of interesting little edge cases. Planning, implementing, and testing them is not a problem. The problem comes later, when we want to refactor or add another new feature. Nobody remembers half of the old features and edge cases from a year ago. When we want to add a new change, we notice that code does all sorts of things in there, and we're not entirely sure which things are intentional requirements and which are meaningless side effects. Did someone last year request that the login token was supposed to only be valid for 30 minutes, or did some programmers just pick a sensible default? Can we change it? Back when the product was first envisioned, we created some documentation describing how the site worked. Since then we created a few additional documents describing new features, but nobody ever goes back and updates those documents when new features are requested, so the only authoritative documentation is the code itself. But the code provides no justification, no reason for its actions: only the how, never the why. What do other long-running teams do to keep track of what the requirements were and why?


title: Avoiding "double" subscriptions

text: I am working on a website that requires a bit of marketing; let me explain. This website is offering a _single_ , say, iTunes 50$ voucher to a lucky winner. To be entered in the draw, you need to invite (and has to join) at least one friend to the website. Pretty straightforward. Now, of course it would be easy for anyone to just create a fake account and invite that account so, I was thinking of some other way to somehow find out of possible cheating. I was thinking of an IP check on the newly subscribed (invited) user, and if there is the same IP logged in the last 24 hours, and if that's the case, investigate more about it. But I was thinking that maybe there is a more clever way around this issue. Has anyone ever though about this? What other solutions did you try? Thanks in advance.


title: Storing images in file system and returning URLs  or virtually resizing and returning byte arrays?

text: I need to create a REST web service to manage user submitted images and displaying them all in a website. There are multiple websites that are going to use this service to manage and display images. The requirements are to have 5 pre-defined image sizes available. The 2 options I see are the following:   1. The web service will create the 5 images, store them in the file system and and store the URL's in the database when the user submits the image. When the image is requested, the web service will return an array of URLs.  I see this option to be a little hard on the hard drive. The estimates are 10,000 users per site, and lets say, 100 sites. The heavy processing will be done when the user submits the image and each image is going to be pulled from the File System.   2. The web service will store just the image that the user submits in the file system and it's URL in the database. When the user request images, the web service will get the info from the DB, load the image on memory, create its 5 instances and return an object with 5 image arrays (I will probably cache the arrays).  This option is harder on the processor and memory. The heavy processing will be done when the images get requested. A plus I see for option 2 is that it will give me the option to rewrite the URL of the image and make them site dependent (prettier) than having a image repository for all websites. But this is not a big deal. What do you think of these options? Do you have any other suggestions?


title: Tips for achieving "continual" delivery

text: A team is experiencing difficulty releasing software on a frequent basis (once every week). What follows is a typical release timeline: During the iteration:   * Developers work on stories on the backlog on short-lived (this is enthusiastically enforced) feature branches based on the master branch.   * Developers frequently pull their feature branches into the integration branch, which is continually built and tested (as far as the test coverage goes) automatically.   * The testers have the ability to auto-deploy integration to a staging environment and this occurs multiple times per week, enabling continual running of their test suites. Every Monday:   * there is a release planning meeting to determine which stories are "known good" (based on the testers' work), and hence will be in the release. If there is a known issue with a story, the source branch is pulled out of integration.   * no new code (only bug fixes requested by the testers) may be pulled into integration on this Monday to ensure the testers have a stable codebase to cut a release from. Every Tuesday:   * The testers have tested the integration branch as much as they possibly can have given the time available and there are no known bugs so a release is cut and pushed out to the production nodes slowly. This sounds OK in practise, but we have found that it is incredibly difficult to achieve. The team sees the following symptoms   * "subtle" bugs are found on production that were not identified on the staging environment.   * last minute hot-fixes continue into the Tuesday.   * problems on the production environment require roll-backs which blocks continued development until a successful live deployment is achieved and the master branch can be updated (and hence branched from). I think test coverage, code quality, ability to regression test quickly, last minute changes and environmental differences are at play here. Can anyone offer any advice regarding how best to achieve "continual" delivery?


title: API for expanation of complicated calculation or business rules?

text: In online shops there are areas with complicated rules. For example   * is a product visible in the product catalog   * is a product sold out   * what is the price for the product (Discounts, Promotions, ...) Is it a good idea to have an additional explanation API for each complicated rule? Example: `boolean isProductVisible()` has an additional `String explainIsProductVisible()`? How to make understanding these rules easier? Background: Yesterday I as a software developer had the problem that my standard- testproduct on my local test system was "sold out" and I needed this product to test the order-confirmation page. So I had to debug the `IsProductAvailable` routine to correct the test data before I was able to do the original task "test the order-confirmation page". In order to find out, why my test product was sold out an explanation message would have been helpful. In a similar situation in the price calculation engine I already added log messages like this               double calculateItemPriceForProduct(Product product, int quantity, Cart cart, ...)     {         double cumulatedPrice = 0;         ...         if (quantity > 1) {             Price price = getScalePrice(product, quantity);             if (price != null) {                 cumulatedPrice = price.getValue();                 if (log.isDebugEnabled()) {                     log.debug("calculateItemPriceForProduct("+                         product.getCode()+                         ") using scalePrice " +                          price.getCode() + " for quantity " +                          quantity + ":" + price.getValue());                 }             }         }         ...     }      As a developer I can look into the server log and hopefully find out what happened. If I were a product manager it would be more comfortable to have role-specific tooltips on the webpage that shows the explanation part. Of course these tooltips would not be available for ordinary customers, just for developers and product managers. My questions:   * Are there other ways to make understanding complicated rules easier?   * Is it a good idea to have an additional explanation API for each complicated rule?   * Does such a feature pay off the cost of developing this feature?


title: How can I find out what a job title means at a company?

text: I am in a dilemma about a job offer from a top 10 semiconductor companies in SF bay area. I have about 10 years of experience at various small to large (> $1 billion) companies in bay area. After my Graduate degree about 10 years ago I started at a big company in Bay area as as Sr Engineer. However, due to job change after a 5 years from that position, more job changes afterward, and not caring too much about titles, I am currently (still) a Sr Engineer at another company. Having had so many years of experience in Hi-tech I now realize that titles are important too. The dilemma is that this offer from another company also is for a Senior Software Engineer, and not a Staff or MTS title, which I after some investigation realize to be higher titles than just Sr engineer. Should I be asking the company (and its recruiter) to give me a higher title than a Sr Sw Engineer; is that expectation reasonable? I had the same Sr Engineer title 7 years ago and after many job experiences and a graduate degree I think I should be acknowledged by the new company making the job offer as a higher staff engineer. **Is there any way to find information about the company hierarchy as I can not trust the information company's recruiter is giving me due to his vested interest?** There are reviews about the company on sites like glassdoor but they do not provide a chance to put questions to employees. Are there any interactive websites/forums for Hi-tech employees (hardware design as well as software) where one could ask such question and hopefully get an answer from someone working at the company? PS: If needed, the company regularly appears in googled list of top 20 semiconductor corporation by sale for every year.


title: Any hard evidence on how much smart phone app developers have actually earned?

text: I am considering making a smart phone app. Before I start, I want to see whether it is worthwhile at all. Unfortunatelly, I find it very hard to find any hard evidence on how much the developers of such apps actually earn either via application purchases, or in-app advertisement. The best research I have found so far states that the average IPhone app earns 682$ per year. Then again, there are loads of apps some of which might not even work and their earnings also count towards this statistic. Therefore, I am after some specific examples of an app and its earnings.


title: What is the point of writing WCF Interceptors, compared to using a helper method?

text: For those of you who don't know, WCF allows you to attach interceptors to methods in the service contract. The interceptor is capable of performing custom logic before and after a method call, and is (as far as I know) used mainly for validating parameters and doing custom authorization schemes. But what's the point of using them if you can just write a helper method to do the same thing?


title: How can I implement an escrow payment system in my website?

text: I'd like to build a web service similar to kickstarter that allows users to pledge money to an idea, tho I'm unsure how I can implement this kind of payment system. If the the idea receives a specified amount of money, then the donors are charged. If it doesn't, the donors are not charged. I've done some preliminary research and have found Amazon Payments to be a possible solution provider for this, but I'm still unsure where to start with this and was hoping someone could point me in some right directions for how I can go about implementing this kind of payment structure in my web site. I should also note that this is primarily a prototype I'm building, so it's ok if the solution is limited to U.S. customers only. Also, I plan to build the site using Ruby on Rails. Thanks so much for your wisdom!


title: How to design a database wherein multiple tags(string) are to be associated with an id?

text: I have to design a database wherein I have to associate an audio_id with multiple tags(words). I am considering following approaches to select one from these: 1) To have multiple fields for multiple tags (columns: tag1, tag2, tag3.... tag10) corresponding to a single audio_id. The number of tags in my application will not be more than 10-15. 2) To save the tags(words) as comma separated single string corresponding to a single audio_id. 3) To save the associations (tag:audio_id) in a separate table. But the issue here is that the associations can be n to n. Multiple tags can be associated with an audio_id and same tag can be in multiple audio_id. Also please let me know if there can be any alternate design for this scenario or its better to consider any other type of database other than MySQL. Total number of tags will be around a million and audio_id are around a few thousands. I am concerned for the performance of the system.


title: "Functional" php indentation

text: I'm a big fan of 1tbs when it comes to c-like languages. Now that php got decent lambdas and closures, though, I'm not sure the style I'm using for them (fundamentally made up, has something to do with the jquery source code) is the most readable/standard option. What do you think? Somebody has some nice examples of 1tbs + lambdas and functions as parameters? Here's a sample of my code.               function bold_search_terms($needle, $haystack) {       return str_replace(          $occurrencies = array_filter (              explode(" ",$haystack),              function ($var) use ($needle) {                 return(levenshtein($var, $needle) < 3);              }          ),          array_map(               function ($var) {                   return "<strong>$var</strong>";               },               $occurrencies          ),          $haystack       );     }


title: Why are inheritance, encapsulation and polymorphism not the pillars of OOP?

text: One day I went to a Stack Overflow chat and saw a phrase, that was stating that inheritance, incapsulation and polymorphism are the pillars of OOP (in the sense that they are fundamental, a construction sole). Also, there's a similar question, that I have been asked very often on college exams and job interviews, and the right answer always was the statement pronounced in the title of the question ("Yes, inheritance, encapsulation and polymorphism are the pillars of OOP). But in the Stack Overflow chat I was severely ridiculed, participants strongly disagreed with such a statement. So, what's wrong with this statement? Does programmers seem to be trained in different things in post-Soviet and United States colleges? Are inheritance, encapsulation and polymorphism not considered to be the pillars of OOP by US/UK programmers?


title: How much times command executed? Looking for mistake

text: I have following piece of code:               int sum = 0;     for (int i = 1; i <= N; i++)         for (int j = 1; j <= N; j++)             for (int k = 1; k <= N; k = k*2)                 for (int h = 1; h <= k; h++)                     sum++;      So I'v calculated how much does each cycle executes and then whole script, and I think I might be wrong for the last one.               1. N     2. N     3.  1 + log2N( means log N to the base 2)     4. N      So the total execution amount of inner cycle would be N^3 * (1 + log2N). Am I right? How I can transform this statement? **UPDATE 1** I have another solution which seems monstrous:               1. N     2. N     3. LOG2(N) + 1     4. 2^(LOG2(2N)) - 1      So total cycles amount would be `n^2 * (LOG2(N) + 1) * 2^(LOG2(2N)) - 1`. Which transforms to n^2 order of growth. **UPDATE 2** I wrote simple test app to check my assumption. it seems that third cycle is already calculated for some reason is fourth one. At least this is the result of test app. I threw away `(LOG2(N) + 1)`. As the result of several transformations I have following equation for total amount of sum++ calls:               N*N*(2*N - 1) = 2 * N^3 - N^2 ~ N^3


title: How to solve circular package dependencies

text: I am refactoring a large codebase where most of the classes are located in one package. For better modularity, I am creating subpackages for each functionality. I remember learning somewhere that a package dependency graph should not have loops, but I don't know how to solve the following problem: `Figure` is in package `figure`, `Layout` is in package `layout`, `Layout` requires the figure to perform layout, so package `layout` depends on package `figure`. But on the other hand, a `Figure` can contain other `Figure`s inside it, having its own `Layout`, which makes package `figure` dependent on package `layout`. I have though of some solutions, like creating a `Container`interface which `Figure` implements and putting it in the `Layout` package. Is this a good solution? Any other possibilities? Thanks


title: Formatting Dynamic Web Pages

text: A page built so that is has server side scripts implemented on the page. Should indentation of the code be according to the server side logic (making it easier to read while coding) or according to the HTML/ASP.NET markup (making it easier to read while debugging etc.)?


title: How to do unit tests on a method that takes the elapsed time into account?

text: I'm currently in the middle of refactoring an important method in a legacy- system. There were almost zero test until I've started working on it, and I've added quite a lot to ensure the correct work after my refactorings. Now I've came across the most crucial part: the algorithm that calculates an indicator. It's something like               indicator = (OneNumberFromA + AnotherNumberFromB) / elapsedTime;      How can I test the correct behavior for this Function with Unit tests? There are also some slightly different algorithms in the functions, that the program reaches in some cases - but in all of them, the `elapsedTime` is vital to the outcome.


title: Porting library, what to do with JavaDoc comments/credits

text: I ported a library to Java, but am wondering what to do with the JavaDoc comments. The original library used javadoc comments too, so do I leave the @author tags from the original code? And how do I give myself credit as the person who ported it over?


title: How can a new programmer impress the software engineer (boss)?

text: I'm working at my first programming job. My boss is a very smart software engineer, and I feel like I have very little to offer compared to him. Problem is, he is always busy, and needs someone to help him out. I feel like I'm not good enough, but I still want to succeed. I want to be a great programmer. What can I do to impress him? Thank you.


title: What strategy to use when starting in a new project with no documentation?

text: **Which is the best why to go when there are no documentation?** For example how do you learn business rules? I have done the following steps:   1. Since we are using a ORM tool I have printed a copy of database schema where I can see relations between objects.   2. I have made a list of short names/table names that I will get explained. The project is client/server enterprise application using MVVM pattern.


title: How can I advocate a semi-strict release schedule in a risk-averse environment?

text: Recently I've been increasingly plagued by what I would have to describe as one of my most frustrating and morale-killing experiences in this profession: Having to _sit on a release_ that has been tested, re-tested, staged, and for all intents and purposes is _ready to ship/deploy_. As an all-around solutions guy and not just a hardcore coder, I do understand and have even advocated the need for proper change control. But lately, the tenuous balance between covering our bases and shipping on time has gone all lopsided, and I've had little to no success in restoring it to something sane. I'm looking for _compelling_ arguments to help convince risk-averse management that:   1. The dev team should (or must) be able to set its own release schedule - within reason of course (1-3 months should be conservative enough for all but the biggest Fortune 500 companies);   2. Software releases are important milestones and should not be treated cavalierly; in other words, _unnecessary_ delays/stoppages are highly disruptive and should be considered only as a last resort to some critical business issue; and   3. External (non-dev/non-IT) entities who want (or demand) to be involved as stakeholders have a responsibility to cooperate with the dev team in order to meet the release schedule, especially in the last week or so before the planned ship date (i.e. user testing/staging). The above are _assertions_ that ring true for me based on experience, but it looks like I'm now in the position of having to _prove_ it - so I'm asking for something a little meatier here, if such a thing exists. Can anyone who has had to "sell" the idea of a fixed (or maybe semi-flexible) release cycle to management give some pointers on what arguments/strategies are effective or persuasive and what is not? Aside from the obvious schedule contention and sunk costs, is there any hard data/evidence that would be useful in making the case that shipping is actually important, even in a "corporate" setting? Alternatively, I'm open to hearing constructive arguments about why schedule flexibility (even over a period of weeks/months) is more important than shipping on schedule; it's hard for me to believe right now but maybe they know something I don't. Note we have staged releases, and this went through every stage except production. Issues are tracked using a commercial bug tracker and every issue - 100% of them - that was assigned to this release was closed out. I realize it's difficult to believe and that's really precisely the point - it makes no sense that a 100%, feature-complete, fully-tested, approved-by-stakeholders release would be delayed by management for unexplained reasons, but that's what happened, that's what's been happening, that's the problem to be solved.


title: Extracting text from various file formats

text: I want to extract text from various files. I used Apache POI for parsing Microsoft documents. It's working and now I want to parse PDFs and extract text from them. Is there a Java API that I could use? I used Apache Tika but it does not provide an API.


title: Years experience over unfinished degree?

text: I'm currently in my placement year and working for a great software development company. It was always my intention of getting to this stage through university, getting enough academic experience as well as the year’s placement and then try to get a full time programming job without the need to finish my degree. I decided this from an early stage as I have never really liked the whole university environment. I was so unhappy at university and I’m so happy now I’m on my placement year, I really don’t know if I can go back. My question is, do you think companies will take me on if I apply for other jobs after my placement year and not penalize me for not finishing my degree? I guess at the end of the day I don't want to look back on my life and think "god, why didn't I just spend one more year being unhappy to have a job I love" but I know that even if I get a degree I could still end up without a programming job and this worries me more than anything.


title: Dealing with data, when your database is under version control

text: Currently my database is not under some kind of vcs, we can get deltas but that's about it. I would like to try and make product deployments more automated, and less time consuming. I understand that placing a db's schema files under source control allow you to manage versions, and that these files are basically for dropping the old tables/indexes/etc and then adding the new versions. My question is, what about the data that's already there? By dropping everything we'd lose all of the data. So, we would have to do a data dump before updating the database, and then re-load the data back after the update has been done. Problem is, some of our largest databases have 80+ GB of data, and we probably have a total of 20 sets of databases (6 DBs per set). I'm sure that this would work, but given the size of everything, is there a simpler solution that would cut out the need to dump and reload everything each time a schema update took place? And, if not, wouldn't we have to dump the data such that reloading it took in to account the new schema?


title: What are the advantages/disadvantages of using record and playback for regression testing?

text: We have a web application that we want to start running regression tests on, and one of the things I'm supposed to look for when choosing an alternative is a tool that has a recorder. However, I get the general feeling that it is frowned upon, and that writing tests in code is preferred. What are the eventual disadvantages or advantages of using a record and playback tool for regression testing?


title: Which recorder do I use for Selenium 2

text: We have a web application that we want to start running regression tests on, and have pretty much decided that we will be using Selenium 2. Not all of the testers are programmer savvy. Is Selenium IDE usable for this? Which other recorder alternatives are best for Selenium 2?


title: Is it ever ok to have an empty catch statement?

text: I thought about it and could not come up with an example. Why would somebody want to catch an exception and do nothing about it? Can you give an example? Maybe it is just something that should never be done.


title: I have a unexceptional exception. That is thrown by a API used in my project. Is it standard to log errors like these or handle them without logging

text: The API has a Throttle on the number of requests you can make. So we queue our requests in a local database and make as many requests as possible until the "Throttle exception" is thrown. Upon catching we exit the program and a scheduled task starts the process over again in 15 minutes. Is it standard to log this type of exception or just exit the program since this exception is expected


title: .NET developer needs FoxPro advice

text: We have a prospect with FoxPro 2.6 (whatever it means) system. Our product integrates with other systems by the means of triggers (usually). We would place couple of triggers on X system and then just pull collected data for our use. This way there is no need to customize customers product and it works great(almost real time - we poll for changes every 30 seconds). Question:   1. Can I put triggers on FoxPro 2.6?   2. Can access FoxPro from .NET? Any catches/caveats?


title: Where should the "not empty field" validation code be written on a 3-layer application?

text: When working with the 3-layer model, where should the validation code be placed? for: not empty fields, unchecked options, null values, wrong-written dates, etc. To keep total isolation between a form (UI layer) and the business rules, this validation should belong to BLL? It's the only work for the UI: grab user data input, without **any** care of verifying, and just send it to next layer.   For example, It's an empty username field, really breaking a business rule, or the BLL doesn't even need to care about getting empty values, sure, UI takes care. Could be this shallow validation, considered as an actual BL rule, or is enough handle it on UI layer?


title: Form, Fit and Function changes in relation to software

text: I am looking at configuration management and the idea of form, fit and function change can determine whether a change is minor or major. I wondered how this definition could be applied when doing software development. Is there a good guideline on whether a change to software is classed as a major or a minor change?


title: xmpp flow -server, client and library

text: My complete requirement is development of a chat engine - including server, clients etc. Currently I am working on things at my desktop only but once done, I have to host it; basically incorporate it with in a site for chatting purpose. So, now my problem is: I am not clear about how the actual data flow is? I have googled and read about xmpp (a book by Peter Andre) also but I am not clear about the flow and what are the actual requirements to do the above mentioned task. What I currently know is:   1. I need a server - so selected ejabberd    2. I need client - still not sure which one to use and one other doubt is how this client thing will work when deployed on some website for chatting purpose.    3. Some library - don't know which one and what is the purpose? Can anyone guide me?


title: How to have a maintainable and manageable Javascript code base

text: I am starting a new job soon as a frontend developer. The App I would be working on is 100% Javascript on the client side. all the server returns is an index page that loads all the Javascript files needed by the app. Now here is the problem: The whole of the application is built around having functions wrapped to different namespaces. And from what I see, a simple function like rendering the HTML of a page can be accomplished by having a call to 2 or more functions across different namespace... My initial thought was "this does not feel like the perfect solution" and I can just envisage a lot of issues with maintaining the code and extending it down the line. Now I would soon start working on taking the project forward and would like to have suggestions on good case practices when it comes to writing and managing a relatively large amount of javascript code.


title: What algorithm pairs blocks so that the weighted average of the two blocks falls within an upper and lower bound?

text: What algorithm would pair parcels with a high proportion of property x to a parcel with a low proportion of property x so that the weighted average of the two parcels falls within an upper and lower bound? The algorithm needs to pair a set of parcels to maximise the quantity that fall into the given range. The parcels are of differing size. For example, suppose I have a table of data that has tonnes of each block and percentage iron in each block. I can process two blocks at the same time to create an average iron percentage. I want to change the sequence of each block to maximise the tonnes that fall inside a percentage iron range.


title: Single-developer GIT workflow (moving from straightforward FTP)

text: I'm trying to decide whether moving to VCS is sensible for me. I am a single web developer in a small organisation (5 people). I'm thinking of VCS (Git) for these reasons: version control, offsite backup, centralised code repository (can access from home). At the moment I work on a live server generally. I FTP in, make my edits and save them, then reupload and refresh. The edits are usually to theme/plugin files for CMSes (e.g. concrete5 or Wordpress). This works well but provides no backup and no version control. I'm wondering how best to integrate VCS into this procedure. I would envisage setting up a Git server on the company's web server, but I'm not clear how to push changes out to client accounts (usually VPSes on the same server) - at the moment I simply log into SFTP with their details and make the changes directly. I'm also not sure what would sensibly represent a repository - would each client's website get their own one? Any insights or experience would be really helpful. I don't think I need the full power of Git by any means, but basic version control and de facto cloud access would be really useful. **EDIT:** I've narrowed it down to the two options that seem most sensible. The first is based on ZweiBlumen's answer, whereby edits are made on the live server and committed from there to the (external) Git server. This has the advantage that my workflow won't change much (there's the extra step of making the commits, but otherwise it's identical). The second option is to work locally using XAMPP, then to commit changes from the local machine. Only when the site goes live do I upload the finished article to the web server from the local machine (immediately after the final commit to Git). This seems okay in theory, but if the site thereafter requires amends and I make them on the live server (as I usually do) then I'll need to manually copy over the changed files in my local repo, then commit those changes to the Git server. This seems unduly complex and is perhaps too much of a departure from my current workflow. I think on balance I'll give option #1 a go, and see how I get on.


title: How to run a F# app in Windows Azure?

text: I have a project that requires me to write a library management system in F# and using Windows Azure for the development. I am quite new to Cloud concept and i don't know what to do as a next step. Is there any way to implement it using webForms? If you can help me with the steps i have to take, i can study them and learn. Thanks


title: What can programmers learn from the construction industry?

text: When talking with colleagues about software design and development principles, I've noticed one of the most common sources for analogies is the construction industry. We **build** software and we consider the design and structure to be the **architecture**. One of the best ways to learn (or teach) are through analyzing analogies - **what other analogies can be drawn from construction?** (whether already in common use in software or not). Please provide a description, or your personal experience, regarding how the programming concept is similar to the construction concept. [Credit to Programming concepts taken from the arts and humanities for the idea]


title: Twitter's new approach of third party application? How would you see this move as developer.... especially you plan to build a twitter client

text: Just today morning I have read news that twitter has issued a warning to developers not to make any new third party client, the official announcement can be read here. As a programmer, how do you see this move of twitter? Does it seems that they want to standardize the behavior of third party client or they don't want any new client in favor of the default clients they have made? What if anybody wants to create a new client? Is there any guidelines that-if followed- ensure that we can create a new mobile client? Or we should stop thinking about it? What are the option for the developers who want to build some clients for twitter? I can realize that I have asked too many questions, but I still think that there can be one common answer.


title: Source code used when supplying this to customer

text: Do you write your code differently when you need to hand it over to a customer?   How does one balance the delivery of good code while at the same time not handing over too much "intellectual property"?


title: How can I improve my user interface and usability design skills?

text: I invested most my time and resources in programming, and now I think it's time I should invest some time in learning about user interface design, user experience, and usability. What are some good resources about usability and designing user interfaces? I'm mainly looking for more theoretical topics, such as color theory and color physiology and how they affect users, along with information about best practices.


title: I've got my Master's in Software Engineering... Now what?

text: Recently I completed a Master of Science in Software Engineering from Drexel University (Philadelphia, PA, US), because I wanted to have _some_ formal education in software (my undergrad is in Math Ed) and also because I wanted to be able to advance my career beyond just programming. Don't get me wrong; I love to code. I spend a lot of my spare time coding. However, for me writing code is just a means to an end: what I **REALLY** love is designing software. Not visual design, mind you, but the architecture of the system. So, ideally I'd like to try to get a job doing software architecture. The problem is that I have no _real_ experience in it besides my graduate course work. So, what should I do to make my "bones" in software architecture? **UPDATE**   Just so it's clear, I have over 5 years of work experience in software development and an MCTS cert in addition to my education, so I'm not looking for the usual "I'm fresh out of school, what should I do?" advice.


title: What rules of etiquette should be followed at software conferences?

text: Whether as an attendee, a speaker, or a vendor I wanted to know what the unspoken rules of etiquette are at software conferences. Other than the blindingly obvious ones (like don't assault the winner of the iPad raffle because you didn't win). What are some of the rules that should be followed, even if you feel they don't need to be said? Please, one rule per answer, with the summary in bold leading the answer. Post multiple answers if you have multiple rules.


title: Dev approaches to complex JavaScript UI's

text: I am trying to understand the landscape of different approaches, and best practices, around the development of complex client-side JavaScript. I'm not sure what to label this class of application, perhaps **heavy AJAX** or **RIA** (but not plugins like Flash/Silverlight). I'm referring to web apps with these characteristics:   * Emulate rich/native desktop UX in JavaScript   * Contain most/all behavior in client-side JS, using the server as a data-API (JSON/Html-Templates). This is in contrast to using the web-server for the UI rendering, producing all HTML in a page-refresh model. Some examples are:   * Google Docs / Gmail   * Mindmeister   * Pivotal Tracker As we move forward into HTML5, I can see this style of RIA development, with heavy JavaScript, becoming ever more common and necessary to compete. **QUESTION: So what are the common approaches emerging around managing these kinds of heavy JS developments?** Client-side code, as an app grows in features, is fiendishly complicated. There are problems scaling a development effort across multiple teams with raw JS (or so I hear, and can well believe it). Google has approached the problem by building GWT that compiles from a higher level language (Java) to JS, leaning on the existing development infrastructure that the higher level language has (Eclipse, strong-typing, refactoring tools), along with abstracting browser compatibility and other issues away from the developer. There are other tools, like Script# for C# that do something similar. All this puts JS more in the role of an IL (Intermediate Language). ie. "You never really write in that 'low level language' anymore." But this 'compile to JS' is not the only approach. It's not apparent that GWT is the dominant approach...or indeed will become it. **What are people doing with rich-client JavaScript?** Some orienting questions:   * Are most shops crafting JS manually (atop libs like jQuery et al)?   * Or are there many many different approaches, with no clear best-practice emerging?   * Are most shops avoiding RIA scale development in favor of the simpler to developer server-side/page-redraw model? If so, will this last?   * Is compiling to JS perhaps an emerging future trend? Or is this just wrong headed?   * How do they manage the complexity and refactoring of client JS?   * Modularization and distribution of work across teams?   * The application, enforcement, and testing of client-side patterns like MVC/MVP etc. **So, what are the emerging trends in this heavy-JavaScript and HTML5 future of ours?** Thanks!


title: How do I design an arbitrary system in an interview?

text: A common question in Tech Interview is to design a particular system, usually an existing product of the company. For example, "Design Google Docs". What is the expected answer for such a question? I mean, such systems surely have a complex design which is beyond the scope of any interview. What are the interviewers expecting in such a short time?


title: Are groups like comp.unix.programmer still alive?

text: If you see the posts at http://groups.google.com/group/comp.unix.programmer/topics?pli=1, most of them are spam. Are these com groups still good places to visit for programmers, if yes, how do you filter the spam? Why aren't they moderated anyways?


title: When to really focus on performance?

text: We've just finishing up the first release of a database driven web application, which is now in regression testing. The application has an advanced search with many different filtering criteria. When the search is first used with only the 3(of 28) minimum required search criteria it takes like 15-20 secs to calculate and retrieve the data for the page to load. This happens only the first time the search(uses a stored proc) is run. The search thereafter take 2-6 secs. The stored procedure has medium complexity around 1500 - 2000 lines. I would like to get it down to run the first time to 6 secs and thereafter like 1-2 secs but I can't seem to find the time to make it faster. My question is, is this acceptable for users if it is only slow the first time the search is run? Has anyone else had a similar experience with creating advanced searches? What was your solution?


title: What is O(...) and how do I calculate it?

text: > **Possible Duplicate:**   >  Plain English explanation of Big O I've seen some questions here and on SO talking about the most efficient way to find or sort this or that. The questions usually talk about the efficiency of a certain algorithms in terms of O(...). As a wannabe-programmer, I would like to start learning how to program algorithmically. So, what is O(...)? How do I calculate it, where can I learn about this?


title: Programming with emacs instead of a debugger-integrated IDE

text: There's a question that might be deemed a duplicate of this one (I use an IDE (Eclipse) to develop software. Why should I switch to vim or emacs?) but I don't think answers my question. I usually program in C++ (not exactly to create GUIs so rather low-level) and I find myself comfortable with editing code into visual studio, compiling it and debugging it. I know that all of this can be done in a linux/unix environment (even on Windows) as well, but I'm wondering how come that many low-level programmers are proficient with tools like emacs which I suppose hasn't any debugger integrated (no breakpoints setting, doing that with gdb seems pretty slow and really unhelpful). How can they develop a complex software with a write-compile-debug cycle in such environments? Am I missing something? I doubt that they develop code in Eclipse, Qt Creator or Visual Studio and then get back to their textual tools.


title: Joining a Team on a Broken and Non-Controlled Project, Possibly Developed by Beginners?

text: Context: A firm which markets oneself with all kinds of partnerships and like a programming firm, but **feels** to me to be a firm employing cheap students at low wages to work on their major product (which looks the part). They market themselves with a lot of praise, but I have never heard about the firm in the open-source community, which makes me skeptical about their level of expertise. Now this firm is looking for some long-time engagement and offering a job to work on this product. But my first impression has been very negative:   * no version control,   * non-running codebase,   * amateurish and inexperienced feel of the codebase. On top of that, they appear to to be dishonest as they push for low wages by minimizing the importance of the problem, but still require a long engagement. I don't think I can ever solve any meaningful problem in such an environment where I face this kind of diversions. It is good to speak about problems honestly and openly. Here, I am afraid about just wasting time. Any experience like that, and recommendations about how to assess the situation or get them to change?


title: Sanity check for design pattern used with an intricate calculation model

text: I am working on a project that generates technical brochures in batch. The 3rd party API that is being used expects POCOs with property names that match field names used in each of the brochure templates. The task I am seeking advice on is with the data source that will be used to populate these POCOs. The data is based on cascading calculations against a Domain Model. I originally entertained the idea of having the Domain be self-calculating, but there are so many calcs required that it seemed obvious to me this needed to be abstracted away. I created some hypothetical code that closely mimics the design pattern in question, and I am open to any suggestions or reaffirmations as to whether I am approaching this correctly. My primary concerns:   1. The constructor for the "AirplaneResultsContext" class, which injects itself to calculation classes which are also publicly exposed properties. Does this create recursive paths?   2. The possible occurrance of circular references with cascading calculation calls to various properties/methods in various other classes. Note that I am re-using most of the calculation logic (as was requested) but I can propose the need for it to be refactored if need be. I noticed I used the word "Intricate", which is usually a telltale warning for code that needs to be abstracted out, but I am struggling to see how I can make this better. * * * **The entity being calculated against**. Picture this as an aggregate root for a larger domain model.               class Airplane : Entity<int>     {         public double WingLength { get; set; }         public double FuselageCircumference { get; set; }         public double FuselageLength { get; set; }         public double SeatWidth { get; set; }         public double SeatDepth { get; set; }         public double SeatHeight { get; set; }         public double IsleWidth { get; set; }         public double LegRoomArea { get; set; }     }      **The calculation context**. The intent is for this object to be passed along as part of a batch process -- an abstract factory which consumes an interface represented by this context class and generates the POCO objects. Note that I also omitted the interfaces and abstract classes that would be used for different calculation strategies for brevity.               class AirplaneResultsContext     {         public AirplaneResultsContext(Airplane airplane)         {             Airplane = airplane;             Fuselage = new FuselageCalculator(this);             Seating = new SeatingCalculator(this);         }              public Airplane Airplane { get; private set; }         public FuselageCalculator Fuselage { get; private set; }         public SeatingCalculator Seating { get; private set; }              public double ComputeWidth()         {             return Airplane.WingLength*2 + Fuselage.ComputeDiameter();         }     }      **Calculators**. In my non-hypothetical project, these methods are private/protected, cached on the first call, and read back by read-only properties, but I only wanted to show a basic representation of some of the calculation complexity.               class SeatingCalculator     {         private readonly AirplaneResultsContext _context;              public SeatingCalculator(AirplaneResultsContext context)         {             _context = context;         }              public int ComputeNumberOfSeats()         {             double isleArea = _context.Airplane.IsleWidth* _context.Airplane.FuselageLength;             double availableArea = (_context.Fuselage.ComputeDiameter()*_context.ComputeWidth()) - isleArea;             double seatArea = _context.Airplane.SeatDepth * _context.Airplane.SeatWidth + _context.Airplane.LegRoomArea;                  return (int) Math.Floor(availableArea/seatArea);         }     }      * * *               class FuselageCalculator     {         private readonly AirplaneResultsContext _context;              public FuselageCalculator(AirplaneResultsContext context)         {             _context = context;         }              public double ComputeDiameter()         {             return Math.PI / _context.Airplane.FuselageCircumference;         }     }


title: Starting Web Development and interactive experiences

text: I'm new to web development and I'm a bit confused about the different languages and technologies in the web. I understand the basic is Html, Javascript, and Css. Then there's jQuery, ASP.net, Html5. I'm confused where I should use each technology and which should I use. For example, here is a video of a WPF application that I built: WPF app demo The app is essentially for students, teaching some lessons. The student can choose a lesson, and listen and see images. The student can also test himself. As you can see, the app has some animation and stlying If I were to attempt at building this application for the web- where should I start from and what should I use? HTML5 (Canvas?), jQuery (jQueryUI?), ASP.net? I would really appreciate it if you can help me. Thanks!


title: is object constraint language worth the effort?

text: so OCL is supposed to extend UML when we as a designer/analyst cannot express something with a diagram, is has a full blown specification still, there is not (at least not that i know) any production-ready compiler supported by any major company (Oracle, MS, IBM, Apple, Google for example) that can translate OCL to any intermadiate/machine language, so why would anyone invest in learning such a thing?, why not invest that time in learning an actual programming language instead ? there are a few easy-to-learn fast-to-pick up languages out there (ruby, php, visual basic) and if its only function is to extend UML diagrams why not just write some pseudocode and get done with it?, do we really need to learn a full blown specificacion just for writing a special case of pseudocode ?


title: Testing my VB.NET code?

text: I'm having trouble developing unit testing approaches to testing both if the "code does what I want it to do", and testing "does my code work". For example, I'm writing code to validate input that will be inserted into a database table, so I need to test if my code does what I want it to do - Good input is accepted, bad input is rejected. Here's some of the code, in VB.NET:                   'Let's check if we are going to update all the fields that must be updated...         If record.table.RequiredMustBeSuplied IsNot Nothing Then             For Each req In record.table.RequiredMustBeSuplied                 If query.UpdateFields(req.Key).value Is Nothing Then                     Throw New ArgumentNullException                 End If             Next         End If      So, for my unit test I would pass in a query without the proper update fields and expect that it would result in a `ArgumentNullException`, and a corresponding test that passes. The problem that happens to me is later on I'll notice a bug, and realize my code doesn't work correctly. For example, the correct code in this case was:                   'Let's check if we are going to update all the fields that must be updated...         If record.table.RequiredMustBeSuplied IsNot Nothing Then             For Each req In record.table.RequiredMustBeSuplied                 If query.UpdateFields(req.Key).value Is Nothing Then                     Throw New ArgumentNullException                 End If             Next         End If      So, I was able to test for problems I know about (missing fields) but not a problem I don't know about (the difference between `dbnull` and nothing). Is unit testing just not very good at finding these kinds of errors, or is there an approach someone could suggest?


title: Task management - how important it is for a entry level developer targeting PM role in the future?

text: I hold masters in CS and now I'm mobile apps developer (entry level), I always start to plan things when starting or doing any project both at work and projects I do at home (for passion) - as I can deliver the project on time but sometimes I am running out of time like 10 tasks a day vs my time forecast will take 2 on that day? As I'm beginner level, I want your suggestions on how important is task management for a person like me and for achieving my goals? My target for the next 3 years will be a Project Manager or similar role - I believe which these time managing skills will be a needed quality.


title: DDD - Does an aggregate root's repository handle saving aggregates?

text: I am using a DDD-like approach for a greenfield module of an existing application; it's not 100% DDD due to architecture but I'm trying to use some DDD concepts. I have a bounded context (I think that's the proper term - I'm still learning about DDD) consisting of two Entities: `Conversation` and `Message`. Conversation is the root, as a Message doesn't exist without the conversation, and all messages in the system are part of a conversation. I have a `ConversationRepository` class (although it's really more like a Gateway, I use the term "Repository") which finds Conversations in the database; when it finds a Conversation it also creates (via Factories) a list of messages for that Conversation (exposed as a property). This seems to be the correct way of handling things as there doesn't seem to be a need for a full-blown `MessageRepository` class as it only exists when a Conversation is retrieved. However, when it comes to saving a Message, is this the responsibility of the ConversationRepository, since it's the aggregate root of Message? What I mean is, should I have a method on ConversationRepository called, say, `AddMessage` that takes a Message as it's parameter and saves it to the database? Or should I have a separate repository for finding/saving Messages? The logical thing seems to be one repository per Entity, but I've also heard "One repository per Context".


title: graph or relational database?

text: I'm starting to think that a lot of my tables could be replaced by only a graph db: For example: I have 4 tables: accounts, votes, posts, relationships but I can represent all these in a graph table with different edges,               NODE1 -> type of relation -> NODE2     account -> vote_+1 -> post     account -> wrote -> post     account -> friend -> account2      is there a difference of performance or other between them?


title: Unit tests tactics

text: The only unit tests tactic I'm familiar with is comparing against golden data _ a predefined set of input data for which output is known (preferably including corner cases). I cannot think of any other reasonable way of unit testing. Trying to unit test using arbitrary input data is (at least) as difficult as writing the application itself. Are there any effective tactics for unit testing other than golden data testing? Note: By saying arbitrary data I mean any `syntactically` valid input which a method can accept (including logically invalid inputs).


title: Should I be afraid of a major corporation stealing my idea?

text: If I have an idea for a website that's really good, but I myself am not experienced enough to execute it well single-handedly, but I get it going with a team of people (guess that's called a start-up), should I be afraid of Google or Microsoft noticing my site, thinking to themselves _That's genius-- we have a thousand times their resources, let's do it better than them_ and hanging me out to dry?


title: Will a degree in progress get past the HR filter?

text: I dropped out of college half way through my final year due to personal reasons. I have 6 modules to repeat but unfortunately I cant afford to go back and finish them for at least another year. Im wondering if i put this down on my resume will it pass the HR filter?               Bachelor of Science in Computing in Software Development     2007 - present


title: How do you quantify competency in terms of time (years)?

text: While looking for a job via agencies some time ago, I kept having questions from the recuitment agents or in the application forms like: How many years of experience do you have in:   * Oracle   * ASP.NET   * J2EE etc etc etc.... At first I answered faithfully... 5yrs, 7yrs, 2 yrs, none, few months etc etc.. Then I thought; I can be doing something shallow for 7 years and not being competent at it simply because I am just doing a minor support for a legacy system running SQL2000 which requires 10 days of my time for the past 7 years. Eventualy I declined to answers such questions. I wonder why do they ask these questions anymore. Anyone who just graduated with a computer science can claim 3 to 4 years experience in anything they 'touched' in the cirriculum, which to me can be equivalent to zero or 10 years depending how you look at it. It might hold true decades ago where programmers and IT skills are of very different nature. I might be wrong but I really doubt 'time' or 'years' are a good gauge of competency or experience anymore. Any opinion/rebuttal are welcome!


title: Audit trails and entity relationships

text: I'm working on an order system and implementing an audit log. Two main concerns are: 1) While auditing a line item , you should only see audits for the line item 2) While auditing an order, you should see audits pertaining to the header information AND line item. For example, a line item would have an audit trail for what was changed to the line item fields, in addition any adding/removing/modification to comments, photos attached , etc would be also be logged. An audit for a order would contain all the things above, plus changes to the actual order (shipping location changes, purchaser name changes, etc). Instead of mirroring the relationships for the audit trails tables, I am planning on having only 2 tables, which are as followed               Audit_Log:         -audit log id         -entity type         -entity id         -audit timestamp         -audit user         -audit message (serialization of object changes most likely)          Audit_Relationship         -audit log id 1         -audit log id 2         -is child of entity      This will greatly simply queries and sorting of audit trails. Big plus is all the audit trails is in one table. You can just sort by timestamp and get an idea of what exactly is going on in the system (although, i think audits are meant mainly to focus on a smaller area , ie a specific order, to see changes). Has anyone tried a similar design? I'm concerned if this confuses entity relationships at all. (Ie, a comment audit long for a line item will also be attached to an order, even though that relationship doesn't exist in the business logic.) The "is child of entity" was used to make this a bit more clear... *I am using php with Doctrine 2, but I think this is an abstract enough idea to work with any ORM. **(ADDED) I am also using MySQL, and considering on using database triggers rather then doing this at the ORM library level. **(ADDED) Using the method described above might be a terrible idea. When attaching a audit trail, we need to get all the entities that will be associated with the audit trail. In order to do so we would need to implement a method to get a list of effected id's. Maybe some special annotations Doctrine uses to figure which properties should be followed when the audit log is "bubbling up" and attaching? Anyways, shifting to longer read times using joins sound much more reasonable then longer write time for this feature.


title: How do you prepare yourself before you start coding?

text: Before you start coding something, how do you prepare yourself? Do you make diagrams, pseudocode, mockups or any of that kind of stuff or you just start coding and see what comes along the way. Personally, I prefer to jump into the code as fast as possible when I am comfortable doing what I have to do. If something is more complicated or a problem occurs, I normally take a sheet of paper and start writing pseudocode down since I have less trouble concentrating that way (I guess that's kinda weird and hard to explain, but whatever...It works!) I guess everybody has there own strategy, so what's yours?


title: Why do programmers write closed source applications and then make them free?

text: As an entrepreneur/programmer who makes a good living from writing and selling software, I'm dumbfounded as to why developers write applications and then put them up on the Internet for free. You've found yourself in one of the most lucrative fields in the world. A business with 99% profit margin, where you have no physical product but can name your price; a business where you can ship a buggy product and the customer will still buy it. Occasionally some of our software will get a free competitor, and I think, this guy is crazy. He could be making a good living off of this but instead chose to make it free.   * Do you not like giant piles of money?   * Are you not confident that people would pay for it?    * Are you afraid of having to support it? It's bad for the business of programming because now customers expect to be able to find a free solution to every problem. (I see tweets like "is there any good FREE software for XYZ? or do I need to pay $20 for that".) It's also bad for customers because the free solutions eventually break (because of a new OS or what have you) and since it's free, the developer has no reason to fix it. Customers end up with free but stale software that no longer works and never gets updated. Customer cries. Developer still working day job cries in their cubicle. What gives? PS: I'm not looking to start an open-source/software should be free kind of debate. I'm talking about when developers make a closed source application and make it free.


title: State Change Tests

text: In Chapter 3 of his book The Art of Unit Testing: with Examples in C#, Roy Osherove describes the concept of testing state change of a system. The example code under test he uses looks like this:               public class LogAnalyzer     {         public bool WasLastFileNameValid { get; set; }              public bool IsValidLogFileName(string filename)         {             WasLastFileNameValid = false;                  if (string.IsNullOrEmpty(filename))             {                 throw new ArgumentException("filename has to be provided");             }                  if (filename.EndsWith(".SLF", StringComparison.InvariantCultureIgnoreCase))             {                 WasLastFileNameValid = true;                 return true;             }             return false;         }     }      and we want to test state of the `WasLastFileNameValid` property. To this end, the author uses the following test:               [Test]     public void IsValidFileName_WhenCalled_ChangesWasLastFileNameValid()     {       LogAnalyzer la = MakeAnalyzer();            la.IsValidLogFileName("badname.foo");            Assert.False(la.WasLastFileNameValid);     }      However, I see the following issues with this test:   1. The 'outcome' part of the test name is `ChangesWasLastFileNameValid`, but the test doesn't really check whether the property value changes; it may have been `false` even before the call to `IsValidLogFileName`.   2. The test is only testing the one case where the last call was an invalid filename. I would use the following test instead (using `xunit.net`)                   [Theory]         [InlineData(true, "fileWithValidExtension.SLF", true)]         [InlineData(true, "fileWithBadExtension.FOO", false)]         [InlineData(false, "fileWithValidExtension.SLF", true)]         [InlineData(false, "fileWithBadExtension.FOO", false)]         public void IsValidLogFileName_WhenCalled_ChangesWasLastFileNameValid(             bool preState, string filename, bool postState)         {             LogAnalyzer analyzer = new LogAnalyzer();             analyzer.WasLastFileNameValid = preState;                  analyzer.IsValidLogFileName(filename);                  Assert.Equal<bool>(postState, analyzer.WasLastFileNameValid);         }      Here I test whether the value changes, and I also test all scenarios. Is this a better test?


title: Why is the minimum value of ints, doubles, etc 1 farther from zero than the positive value?

text: I know it has something to do with 2's complement and adding 1, but I don't really get how you can encode one more number with the same amount of bits when it comes to negative numbers.


title: What's the difference between these property definitions in C#

text: class myClass     {      int age;           public int Age     {      get{return age;}      set{age = value;}     }      Versus               class myClass     {      public int Age{get; set;}     }      What's the difference between these two? Are they both the same?


title: Should I use semicolons to delimit Scala statements?

text: I'm used to delimit statements by a semicolon from Java, so naturally I do it in Scala code too. I also feel that the code is easier to read, because it's evident where one statement ends and another begins. But many times when I post a piece of Scala code on SO, the code gets edited just to get semicolons removed.   1. Should I use semicolons or not? Are there any "official" guidelines or coding style?   2. Are there cases where semicolons are required, otherwise the code is ambiguous?


title: Reaching Intermediate Programming Status

text: I am a software engineer that's had positions programming in VBA (though I dare not consider that 'real' experience, as it was trial and error!), Perl w/ CGI, C#, and ASP.NET. The latter two are post-undergraduate, with my entrance into the 'real world'. I'm 2 years out of college, and have had 5 years of experience (total) across the languages I've mentioned. However, when it comes to my resume, I can only put 2 years down for C#, and less than a year down for ASP.NET. I feel like I _know_ C#, but I still have to spend time going 'What does this method do?', whereas some of the more senior level engineers can immediately say, "Oh, Method X does this, without ever having looked at that method before." So I know empirically that there's a gulf there, but I'm not exactly sure how to bridge it. I've started programming in Project Euler, and I picked up a book on design patterns, but I still feel like I spend each day treading water, instead of moving forward. That isn't to say that I don't feel like I've made progress, it just means that as far as I come each day, I still see the mountain top way off in the distance. My question is this: How did you overcome this plateau? How long did it take you? What methods can you suggest to assist me in this? I've read through _Code Complete_, _The Mythical Man Month_, and _CLR via C#, 2nd edition_ \-- my question is: What do I do now? * * * **Edit** : I just found this question on projects for an intermediate level programmer. I think it adds to the discussion (though it does not supplant my question). As such, I'm adding it to the question as a "For More Information".


title: Questions to ask a 3rd party API provider

text: I'm due to meet with a developer/sales person from a new 3rd party resource we're about to start using. The main topic I'll be interested in, is their API as I will be the developer making use of it and explaining it to the rest of the team. What questions would you recommend asking? Things I'm already thinking about are:   * What happens and how will I be notified when they depreciate a method?    * Is there ever any downtime?   * Who will I deal with first when I have API issues?


title: Is PHP a more simple introductory language to back-end web development over Ruby on Rails?

text: I have a program coordinator for a course I plan to teach who wants to change the "Introduction to Web Development" course from using PHP to Ruby (I assume he means Ruby on Rails). His justification is that Ruby "is the future of web development". Because we can't argue about the future, only trends, I'm hoping to build an argument against this instead based on "teach-ability". My personal experience in learning both PHP and Ruby on Rails is that PHP was more natural to ease into, simply because you can start inserting code wherever you need to and gradually improve your code structure and organization from that point forward. Ruby on Rails however requires a significantly sharper learning curve on code structure and organization (in my opinion). However, I learned Ruby on Rails much later in my programming career, so it was much easier to pick up than a first time student. So my question is, what language would be more appropriate to teach a beginner course on web development given those two options?


title: what are the best tips for storing images in a database?

text: Is it appropriate to store the image files in the database? Or it would be better to store only the path of the file in the database, while keeping the file itself on the server? Are there any other methods for doing this right?


title: How to create a Request Specific Thread Safe Static int Counter?

text: In one of my server application I have a class that look like,               class A     {        static int _value = 0;        void DoSomething()        {              // a request start here               _value = 0;              _value++;              // a request end here        }        // This method can be called many time during request        void SomeAsyncMethods()        {              _value++;        }     }      The problem is SomeAsyncMethods is async. Can be called many times. What I need when a request start set _value = 0 and then asynchrosnously increment this. After end of request I need the total. But the problem is that another request at the same time can access the class.


title: How is the "Infinite Monkey Theorem" different to use than Genetic Programming to solve problems?

text: This might be a little open ended, but I heard an explanation of this talk on how GP could be used to fix bugs, and I wonder: How does this differ from the infinite monkey theorem?


title: How does optimization make code "greener"?

text: It seems clear that whatever the language used, an optimized application consumes fewer resources than a poorly written application, and require fewer servers to manage a similar number of requests for a site with heavy traffic. Similarly, I like to assume that an application written in a compiled language like C++ or. NET require fewer servers than if it were written in PHP, for example, for the same performance reasons. That may be why Facebook has designed a compiler for the application written in PHP. Now, Facebook has recently opened the architecture of its data centers to the public to provoke thought for a reduction in their ecological footprint, but I'm not sure that the equipment is solely responsible if an optimized code needs less servers to address a number of requests. That's why I wonder if quantitative studies have been conducted, with supporting figures to show how the optimization of the code could save resources and machinery thereby reducing the ecological footprint of data centers dedicated to single application like Facebook. If there are examples like "to do or not do" for languages, as well as tips to make the code more "green", I'd be very interrested. Do you have any resources on this or thoughts to share?


title: Use functions inside a loop declaration

text: **What's the best practice?** This :               for ($i = 0; $i < count($array); $i++) {     //stuff     }      Or, what I usually do :               $count = count($array);     for($i = 0; $i < $count; $i++) {     //stuff     }      Is it the same with the magic of compiler optimization?


title: Is it safe to trust emulators when developing multi platform/resolution mobile apps?

text: I'm currently developing some mobile applications using PhoneGap for Android, testing only in 3 different kinds of smartphones, and using emulators to test on the others target phone resolutions. Later on I will probably use a iOS emulator. I would like to know if I will have any problems with that.


title: Distributed/Network application development that is user focused but NOT web application development

text: I was curious, what other architectures exist for business or user focused development that aren't written using web applications. Are these architectures used today? If you are or were in the business world and you need to connect to an application from a remote location, what technology would you use (that isn't web application based)?


title: Why does everybody hate SharePoint?

text: Reading this topic about the most over hyped technologies I noticed that SharePoint is almost universally reviled. My experience with SharePoint (especially the most recent versions) is that it accomplishes it's core competencies smartly. Namely:   * **Centralized document repository** \- get all those office documents out of email (with versioning)   * **User-editible content creation for internal information disemination** \- look, an HR site with current phone numbers and the vacation policy   * **Project collaboration** \- a couple clicks creates a site with a project's documents, task list, simple schedule, threaded discussion, and possibly a list of all project related emails.   * **Very basic business automation** \- when you fill out the vacation form, an email is sent to HR. My experience is that SharePoint only gets really ugly when an organization tries to push it in a direction it isn't designed for. SharePoint is not a CRM, ERP, bug database or external website. SharePoint is flexible enough to serve in a pinch, but it is no replacement for a dedicated tool. (Microsoft is just as guilty of pushing SharePoint into domains it doesn't belong.) _If you use SharePoint for what it's designed for, it really does work._ Thoughts?


title: What to cover in a "introduction to python" talk?

text: I'm in a student team that is focusing on web development. My teammates are interested in Python and I'm the only one that has learned it, so I was asked to give an "introduction to Python" talk next week. I'd like to listen to your advice about what to talk about to make the talk interesting instead of just a bunch of grammar things. PS: my teammates are familiar with PHP and .NET


title: Software Design: Build it fast or build it well?

text: When building a non-trivial application, is it best to focus on getting things working quickly, and taking shortcuts in the code like mixing model logic with your views, breaking encapsulation - typical code smells? Or, are you better off taking the time upfront to build more architecture, build it right, but running the risk that all this extra code might not be used since your design is quite fluid and you might have to throw it away if feedback causes you to go in a different direction? For context, I'm building a desktop application. I'm the only developer, and I'm doing this part-time since I have a day job. Now, for work, I try to do things the right way, schedule permitting. But for this project, which I expect will morph as I get feedback from people, I'm not sure that's the right approach. I spent several hours this week putting in a textbook Model View Controller design in place to communicate changes in the model to the view. This is great in general, but I'm not sure if I need multiple views to display the data and I know that I could have had things displayed more quickly without the additional architecture. With maybe 10-15 hours a week to spend on the project, I feel it will take ages to get something built that I can demo if I follow good software practices. I know that my users won't care that I used MVC internally, they just want something that solve their problem. But I've also been in the situation where you've incurred so much technical debt from short cuts that the code is just incredibly difficult to maintain and add new features to. I'd love to hear how other people approach this kind of problem.