title: Find product using summation C# Problem?

text: I am trying to write a simple program to find the product of two numbers (X, Y) without using multiplication. Meaning that I will only use summation to find the product. I am trying to use the "Divide-and-Conquer" technique, and am using the obviously known concept that: 5*6 = 5+5+5+5+5+5               Multiply(uint X, uint Y)     {              if (Y < 1)             return 23423432453; //any very big random number              if (Y == 1)             sum = sum + X;              else // if (Y != 1)         {             halfY = Y / 2;             if (Y % 2 == 0) // if Y is even #                 return Multiply(X, halfY);             else //if Y is odd #                 return Multiply(X, halfY) + Multiply(X, 1);         }         return sum;     }      **EXPLANATION** 1) I see the problem as (for example) a 5x6 grid. My idea is to keep recursively dividing the number of columns Y until I reach that Y=1 (Y=1 is the base case). When Y=1, the number of rows in each column would be simply "X" and I can just add X+X+X ... according to the #of columns Y, and save the result in the variable               sum      , then I just return "sum" at the end. 2) In this part of the code,                else //if Y is odd #            return Multiply(X, halfY) + Multiply(X, 1);      I added "Multiply(X, 1)" to compensate for the "1" that will be lost due to the integer division operation. \----- As an illustration: For example 5*6, where X=5, Y=6:                                               Multiply(X,Y)                            //Y=6                               /                       \                    Multiply(X, Y/2)                   Multiply(X, Y/2)       //Y=3, Y=3                  /         |        \               /      \          \        Mult(X,Y/4) Mult(X,Y/4) Mult(X,1)  Mult(X,Y/4) Mult(X,Y/4) Mult(X,1) //Y=1,1,1,1,1,1             |           |           |           |            |        |     //BASE CASE!      sum= X + X + X + X + X + X = 5+5+5+5+5+5 = 30 * * * The code seems pretty logic to me, but it won't give me the right output. Is the idea incorrect? Any help in what is wrong would be greatly appreciated. Thanks.


title: How to start learning Spring framework with all its associated functionalities?

text: I am going to delve into the nuances of Spring. I have a little information about this framework. So I am not going in blind. But still I will like to start it as a beginner and then move up the levels to all the associated functionalities. I have RAD and apache tomcat installed. Does anyone know of any good sites or pdfs that will give me a good bottom up approach with proper examples?


title: Why Firefox caching work will reset in version 3 but version 16 don't?

text: I am developing a web application and have the app deployed into Tomcat server. Tested on IE and Firefox and are working fine. Meaning when I close the browser and reopen the app, the data will be reset. When deploy to Websphere, the data is reset only in IE but Firefox don't. Meaning Firefox will cache the old data. I did try to clear the cache in FF but still failed. I did a test in FF3 and FF16, FF3 will reset the value but FF16 doesn't, I am just so curious why this could happened? Now I don't know whether this is my code problem or is actually the FF caching problem. Any clue on this?


title: Advantages of Scala vs. Groovy with JAVA EE 6 Applications

text: Please let me first emphasize that I am not looking for flame wars. I just want advice from people who have real experiences. I started learning JAVA EE 6 as real newbie and am having a difficult time choosing what tools to use. The first question I have is - what are the advantages of using Scala vs. Groovy with Java EE 6 apps over Java? I've seen on some blogs people mentioning Scala can mean writing less code but as a newbie I don't know what other advantages and disadvantages there are. The second question is whether I'm better off choosing Netbeans 6.9 or Helios 3.6.1? I realized that with eclipse I can easily mix EE 6 applications with Groovy or Scala without any problems (I only did this by displaying a String message from Scala and Groovy classes.). With Netbeans the only advantage I can think of is having separate Java project libraries and using the jars in my web app. But I also realize to the extent of my little knowledge Netbeans has better support for Java EE 6. Please need your expert advice. Thanks.


title: What are your recommendations for porting a huge VC++6 project to later VS version?

text: We have a huge legacy C project which runs in VC++6. And I hope this will be ported to later versions of visual studio. But I think it will be a huge work. Actually, I just tried to recompile the project with VS2005 and got so many errors. So, do you have any experience of this type of porting? Any recommendations?


title: What are the various premature optimizations traits / types?

text: For code review technique training, I have to cover various topics. One of them is premature optimization. I found 3 traits of it as:   1. It's generally evil; causing **inverse effects**.   2. It's an **unnecessary pain** , causing no gain.   3. It demands lot of effort to achieve **little benefits** Is there any other trait which am I missing ? Also, to illustrate them, I usually get a good examples for only 1st scenario. Can someone suggest any solid example for 2nd and 3rd scenario also ? Example for 1st scenario: > Using char instead of int for smaller loops to save bytes!               for(char c = 0; c < 20; c++) {} //Evil: Accessing 'char' costlier than 'int'      [Note: I am not worried about the fact that compilers usually itself takes care of premature stuff. This training is meant just for illustration.] This question is not about, "What optimizations are premature?"


title: Should I use an aggregate root when designing my repository?

text: I have an entity that is called Master which is composed of a number of Slave entities. There can only be one Master in my database and I want to query repositories to get the Slave for a given id. I initially created a SlaveRepository and queried that by id. That seems fine and works and other developers could use my repository. Then I thought about aggregate roots and created a MasterRepository and returned the Master and then did a loop on that to get the required Slave entity. The problem I felt here is once I expose this to other developers they would have to do the same, so I through about having a method on the MasterRepository called GetSlaveByID(string id) and then I could get the Slave directly (hides the loop functionality). Now, should my repository return a Slave even though it is called a MasterRepository? And more importantly which is the right way to go? I am in the early stages of trying to apply DDD and TDD so there are probably lots of things I need to think about before deciding which is the correct way I guess.


title: Less vs Stylus vs Sass

text: I'd like to start using a CSS pre-processor to cut down development time. Which one of these is the fastest from this perspective?


title: What are the advantages of programming to under an OS as opposed to bare metal executive?

text: Assume you are presented with an embedded system application to program, in C, on a multi-core environment (think a Cavium or Tilera) and need to choose between two environments: Code the application under Linux in SMP mode or code the application under a thin bare metal executive (something like a very minimal RTOS), perhaps with a single core running UP Linux that can serve control tasks. For the purpose of this question, assume that both environment provide the same level of performance guarantees in any measurable aspects of run time performance, including number of meaningful action per second, jitter, latency, real time considerations - the works. (and yes, I realize this is by far not a trivial assumption at all, bare with me). How would you justify going with a Linux SMP based solution rather then a bare metal thin executive solution? The question may seems silly. It certainly seems obvious to me - but I have to convince someone that does not think the same. Could you help make a list of arguments in favor of choosing a real SMP aware OS (Linux) vs. a bare metal executive assuming performance guarantees are NOT an issue? Many thanks


title: Business person turned into coder? How and why? Inspire the non-technical

text: I graduated with a Business degree. Two years later, I finally realized the power of programming - the power to "invent." I wish I realized this in high school. Nevertheless, I tried to self-teach C# but found it difficult. Then I pivoted to learn PHP two months ago and I have been able to build things I thought was beyond my abilities. Has anyone had the same experience? Or self-taught programming? What lessons did you learn?


title: Are these good reasons for moving to Microsoft web development platform?

text: **Background** I do PHP and Ruby on Rails development in my spare time, and have learned quite a bit on my own. I chose those technologies because of the low cost of entry, since everything is open-source and freely available. I develop on Linux and have been learning that from using it too. **Problem** Now I'm at a place where I want to get deeper in my knowledge of web development, but I'm personally having a hard time learning, because:   * I'm finding that since everything is community-maintained there is no real "structure" to advancing knowledge.   * So far I've learned from doing, and looking up specific problems as I encounter them. I don't know if that's the right way to do it in general, or if it's just not the best way for me. What I don't like about this approach is that you don't get any insight into the problem, because you just need to fix it and get moving with the project you're actually working on! As an example, working in Rails hasn't given me more than just basic knowledge of Ruby, because I can't learn both Rails and Ruby to an advanced level at the same time (maybe that's just my brain's limitation?)   * I find that a significant portion of my time gets spent just getting set up, resolving LAMP-stack issues for PHP/MySQL, or Ruby gem dependencies and conflicts **Question** I am considering trying out C# and the .NET world for a few reasons, and I would like _more experienced developers' thoughts on whether my thinking is sound or flawed_. My main reasons for wanting to switch are:   * it seems like a more structured environment, I guess specifically because it's not community-driven. Does that make for a more linear learning experience?   * I personally prefer working in visual environments, and Microsoft has Visual Studio. I've used several IDEs for PHP and Ruby and they're quite good, but just going by what I've heard Visual Studio is excellent to work with.   * Microsoft has free "Express" versions of their software to try out, so there's a low cost of entry there now too   * since Microsoft's is a "closed"/integrated environment, do you save time in the initial set up? I.e., do you spend less time setting up Apache/nginx, MySQL, MongoDB, version control, etc.


title: Should an image be able to resize itself in OOP?

text: I'm writing an app that will have an `Image` entity, and I'm already having trouble deciding whose responsibility each task should be. First I have the `Image` class. It has a path, width, and other attributes. Then I created an `ImageRepository` class, for retrieving images with a single and tested method, eg: `findAllImagesWithoutThumbnail()`. But now I also need to be able to `createThumbnail()`. Who should deal with that? I was thinking about having an `ImageManager` class, which would be an app-specific class (there would also be a third party image manipulation reusable component of choice, I'm not reinventing the wheel). Or maybe it would be 0K to let the `Image` resize itself? Or let the `ImageRepository` and `ImageManager` be the same class? What do you think?


title: Best way to remove list items from an existing record

text: Ok more of a conceptual question here: Say I have an existing record of type Meeting. When I go to edit the meeting I have a listbox with all current meeting participants, and one with all employees. I then add a few employees from the master list and remove a couple from the meeting list. What is then the best approach to update my MeetingParticipant database with the new roster? The add records are no problem, but when I go to update, my callback doesn't know which items I have removed. Here are the solutions I've considered/implemented so far, but I'm hoping someone has a better answer :).   1. Immediately resolve the record deletion when the employee has been removed from the list. (this is what I usually implement, but I'd rather find a way where I can simply update the entire collection upon form submission)   2. Remove all MeetingParticipant records for the meeting and repopulate with the new list. (could possibly cause some referential integrity problems for employees who's status did not change)   3. Iterate through each of the MeetingParticipant records, searching the new list to see if it's still on the list or not. (seems like a lot of overkill) If it matters, we're working w/in the .Net framework using MVC & LINQ.


title: Using XML as data storage

text: I was thinking about the XML format and the following quote: > “XML is not a database. It was never meant to be a database. It is never > going to be a database. Relational databases are proven technology with more > than 20 years of implementation experience. They are solid, stable, useful > products. They are not going away. XML is a very useful technology for > moving data between different databases or between databases and other > programs. However, it is not itself a database. Don't use it like one.“ > -Effective XML: 50 Specific Ways to Improve Your XML by Elliotte Rusty > Harold (page 230, Part 4, Item 41, 2nd paragraph) This seems to really stress that XML should not be used for data storage and should only be used for program to program interoperability. Personally, I disagree and .NET's `app.config` file that's used to store a program's settings is an example of data storage in an XML file. However for databases rather than configurations etc XML should not be used. To develop my point, I will use two examples:   A) Data about customers with fields that are all on one level i.e. there are a number of fields all relating to one customer with no children   B) Data about configuration of an application where nested fields and properties make a lot of sense So my question is, Is this still a valid statement and is it now acceptable to store data using XML? EDIT: I've sent an email to the author of that quote to ask for his input/extra context.


title: Why does shared state degrade performance?

text: I've been working under the share-nothing principle of concurrent programming. Essentially, all my worker threads have immutable read-only copies of the same state which is never shared between them ( _even by reference_ ). Generally speaking, this has worked really well. Now, someone has introduced a no-lock singleton cache ( _e.g. a static dictionary_ ) that all the threads are accessing concurrently. Since the dictionary is never altered after startup there are no locks. There haven't been any Thread-Safety issues, but now there is a performance degradation. The question is... since there are no locks why does the introduction of this singleton create a performance hit? What exactly is going on under the covers that could explain this? To confirm, accessing this new singleton is the only change and I can reliably recreate this simply by commenting out the call to the cache.


title: User Stories with design elements in Scrum

text: We're implementing a Scrum workflow and I'm trying to wrap my head around user stories, when they're completed, iterations, etc. One thing we often do is work on a story during an early iteration, get it fully working but "ugly". We use plain buttons, no images, just the text to show that it's working the way they should. We show our customer, make sure they are happy with how it's working, then we usually use images they provide to finish up the design of the feature and complete it. In this instance, would we complete the user story when it's functionally complete, and make a second user story that says something to the effect of "as a user I want xyz to be visually appealing" to take care of the design phase? Or would we just move the user story from the first iteration to later on in the project once we get the design elements and can complete it? If that's the case, I can see us only completing maybe one or two stories in the first few iterations and completing a TON of stories in the final few iterations. How do you all handle this scenario?


title: How to implement a simulation pattern for a repository?

text: Let's say I have a repository of functions. These functions work with business objects within a database, CMS or other third party API. For example, my repository interacts with virtual files and documents in a document management system. I want to be able to implement a simulation mode in my repository such that when I execute commands, I want to see the result of it without it actually doing anything. This is to reduce the risk of someone executing a series of commands in my repository and doing something dangerous. I want them to first see the output and confirm before executing. My question is, what are some good patterns to implement a simulation mode for a repository? I can think of a few off the top of my hat: Wrap all business objects in another class, such that when you would call File.Delete, your actually calling the wrapper class and it checks in simulation mode is enabled. The problem is that many third party libraries and SDKs don't let you subclass their business objects. How would you pass in the the simulation mode (everytime an object is instantiated?). Another option would be to implement a SimulatedRepository. However, I don't want to duplicate any existing code in the repository. Meaning, I don't want to simulate everything to the point that it does nothing, I only want to simulate create, update and delete commands, not the business logic. Perhaps I need to implement another layer in my application? Suggestions would be appreciated. I also wonder if this design philosophy is popular in most enterprise environments and how its done. I would think that allowing administrators to run a simulation and measure results before actually executing them is vital in a mission critical scenario where you are working with another client's data.


title: Is restricting sessions to an absolute IP likely to have a wide impact on mobile networks?

text: Our website currently restricts a cookie-based session to the IP address that was originally sent the Set-Cookie HTTP header. In the past a user's IP would rarely change, so this didn't present much inconvenience. However, some of our clients accessing via 3G devices are experiencing session failures due to this IP restriction. I know little about the network infrastructure used for mobile networks. Do the majority of providers attempt to route connections to a common public IP in order to maintain compatibility with websites like ours, or should I consider restricting sessions to an IP range instead?


title: Software design by pseudocoding?

text: Do you know a good way to design (i.e. write down) software with a method based on pseudocode? I'm new to software design and read some information about UML. My humble class hierarchies are good so far, however, after it gets complex I notice that with "seeing the whole" picture I could have used a different structure for more future extendability. As Python is good to prototyping I'm almost fine with just starting to write, but not quite. So I tried UML class diagrams, but they don't seem to help me much. The problems I solve there I can trivially do in my head. But I do notice additional design requirements once I start to pseudocode the actual methods. So if you wanted to design by pseudocode, how would you do it? I believe for me a method which is roughly 1-to-1 with code works best. But most UML software doesn't even show the method's code (as opposed to pictures in e.g. GoF). Someone claimed UML is for documentation and presentation only and not that great for design? I also get that feeling. I thought pure UML and some simplistic whiteboard sketches were the way to design software until googling I found Envision APDT. So is agile development something I should look out for or do they randomly call that agile - I thought agile is about schedule only? Or am I designing incorrectly (with UML) - does anyone design by pseudocode? How can I find a good tool for that?


title: Proper Data Structure for Commentable Comments

text: Been struggling with this on an architectural level. I have an object which can be commented on, let's call it a `Post`. Every post has a unique ID. Now I want to comment on that Post, and I can use ID as a foreign key, and each PostComment has an ItemID field which correlates to the Post. Since each Post has a unique ID, it is very easy to assign "Top Level" comments. When I comment on a comment however, I feel like I now need a PostCommentComment, which attaches to the ID of the PostComment. Since ID's are assigned sequentially, I can no longer simply use ItemID to differentiate where in the tree the comment is assigned. I.E. both a Post and a Post Comment might have an ID of '5', so my foreign key relationship is invalid. This seems like it could go on infinitely, with PostCommentCommentComment's etc... What's the best way to solve this? Should I have a field in the comment called "IsPostComment" or something of the like to know which collection to attach the ID to? This strikes me as the best solution I've seen so far, but now I feel like I need to make recursive DataBase calls which start to get expensive. Meaning, I get a `Post` and get all PostComments `where ItemID == Post.ID && where IsPostComment == true` Then I take that as a collection, gather all the ID's of the `PostComments`, and do another search `where ItemID == PostComment[all].ID && where IsPostComment == false`, then repeat infinitely. This means I make a call for every layer, and if I'm calling 100 Posts, I might make 1000 DB calls to get 10 layers of comments each. What is the _right_ way to do this?


title: can I sell a software that uses a GPL library and another BSD licensed library?

text: This is the first time I have dealt with licensing issues so I am sorry if I am making any stupid assumptions. My issue is that I have written a program in Python that uses PyQT for the GUI and also uses another library licensed under BSD. PyQT comes with GPL v2 and GPL v3 as well as a commercial license. From what I have read until now (including the GPL license), I understand that you can sell a software that is licensed under GPL. However, there is an issue if you're not the original author and you are reusing source code that is licensed under GPL. So here are my questions:   1. In my case since I am using PyQT I believe that I should license my program under GPL as well? Also if this is the case I can sell my software provided that I release the source code as well right?   2. If PyQT is released under GPL which as far as I understand gives you freedom to sell your software if you use the library why do they also provide a commercial license? Is it only for the case where you do not want to release the source code?   3. Since I am also using a library that is licensed under BSD it is OK to license my software only under GPL and mention that my program uses this library in the License.txt and the About section of my program?


title: Is rotating the lead developer a good or bad idea?

text: I work on a team that has been flat organizationally since it's creation several months ago. My manager is non-technical and this means that our whole team is responsible for decision-making. My manager is beginning to realize that there are several benefits to having a lead developer, both for his sake (a single point of contact and single responsible party for tasks) and ours (dispute resolution, organized technical guidance, etc.). Because the team has been flat, one concern is that picking one lead developer may discourage the others. A non-developer suggested to my manager that rotating the lead developer is a possible way to avoid this issue. One developer would be lead one month, another the next, and so on. **Is this a good idea? Why or why not?** Keep in mind that this means _all_ developers -- All developers are good, but not necessarily equally suited to leadership. And if it is **not** , how do I recommend that we avoid this approach without seeming like it's merely for selfish reasons?


title: Fixed window size app development for Mac OS X

text: I am developing a rather eye-candy application which is to be released on Mac App Store. Due to its graphics intensive use, it would save a great deal of time on UI end if the app could be released with a fixed size main frame-dialog. I did try doing a search regarding App Store policies on the matter but could not find anything. Is the distribution of fixed-size frame [productivity] apps are allowed within the App Store if they conform with other design guidelines?


title: Why is SQL's BETWEEN inclusive?

text: Semi-open intervals (`[a,b)`, where `x`belongs to the interval iff `a <= x < b`) are pretty common on programming, as they have many convenient properties. Can anyone offer a rationale that explains why SQL's `BETWEEN` uses a closed interval (`[a,b]`)? This is esp. inconvenient for dates. Why would you have `BETWEEN` behave like this?


title: What popular "best practices" are not always best, and why?

text: "Best practices" are everywhere in our industry. A Google search on "coding best practices" turns up nearly 1.5 million results. The idea seems to bring comfort to many; just follow the instructions, and everything will turn out fine. When I read about a _best practice_ \- for example, I just read through several in Clean Code recently - I get nervous. Does this mean that I should _always_ use this practice? Are there conditions attached? Are there situations where it might _not_ be a good practice? How can I know for sure until I've learned more about the problem? Several of the practices mentioned in _Clean Code_ did not sit right with me, but I'm honestly not sure if that's because they're potentially bad, or if that's just my personal bias talking. I do know that many prominent people in the tech industry seem to think that there are no best practices, so at least my nagging doubts place me in good company. The number of best practices I've read about are simply too numerous to list here or ask individual questions about, so I would like to phrase this as a general question: **Which coding practices that are popularly labeled as "best practices" can be sub-optimal or even harmful under certain circumstances? What are those circumstances and why do they make the practice a poor one?** I would prefer to hear about specific examples and experiences.


title: Explanation of satellite data from a programmers perspective

text: I have started reading Part 2 of Introduction to Algorithms and in the section **The structure of the data** the author/authors says in the context of sorting a sequence of numbers: > In practice, the numbers to be sorted are rarely isolated values. Each is > usually part of a collection of data called a record. Each record contains a > key, which is the value to be sorted, and the remainder of the record > consists of satellite data, which are usually carried around with the key. > In practice, when a sorting algorithm permutes the keys, it must permute the > satellite data as well. If each record includes a large amount of satellite > data, we often permute an array of pointers to the records rather than the > records themselves in order to minimize data movement. Can some one explain what the authors mean here ? Why the term _satellite data_ ? What is the intuition behind this concept ? And also how this concept relates to a higher level programming platform like Java ?


title: What does &callback= do

text: I am trying to create a timer that ever x minutes it will call to a server, get a JSON file and do something with it. The merits of that system are not in question right now, the question involves getting the JSON file. Currently I am using kimonify from KimonoLabs to create a JSON file from some other site. They suggest I use               function kimonoCallback(data) {         // do something with the data         // please make sure the scope of this function is global       }            $.ajax({         "url":"http://www.kimonolabs.com/api/9ey3ljcs?apikey=d753b0c5546495826e7aaa5422f59e30&callback=kimonoCallback",         "crossDomain":true,         "dataType":"jsonp"     });      At the same time I was pursuing other methods and was getting a parse error, and I found this solution. So far both used `&callback=` what is so special about `&callback=` that makes it more preferable to something like `.done()` or `success:` I am guessing it has something to deal with Access-Control-Allow-Origin.


title: Which Continuous Integration for Selenium 2 with TestNG

text: So I have a Selenium Automation project (using Maven). I'd like to be able to set my tests to run overnight and possibly email a report daily to the team. Which CI would be most suitable for TestNG.xml suites? I tried Hudson but I couldn't figure out a way to execute TestNG files from the build? Thanks in advance.


title: What are the implications of the cache when using notifyDataSetChanged?

text: I use Volley to return JSON from an API. I parse this JSON and add `StoreItem` objects to a List, then use an adapter to display in a listview. I use the cache functionality in Volley, and I'm wondering how I can approach the issue of deleting/adding items. I know I'll need to make a POST/DELETE request with Volley to actually save/destroy the items in the database, but for user experience purposes I don't want to have to reload the view with a fresh Volley request. I also don't want the cache to update the view without recognizing the item that was just added/destroyed. The android documentation for notifyDataSetChanged says: > Notifies the attached observers that the underlying data has been changed > and any View reflecting the data set should refresh itself. In this case is the underlying data the cache, my server database, or the Items in the list? Please let me know if I can clarify this question.


title: Best datatype to store a ternary, or three-state variable

text: _Disclaimer: I know that datatypes are a little bit subjective to which scripting/programming language you are using, I like to write in Python as a matter of preference; though I am happy to hear about any lanugage/implementation._ What is the best datatype to store a three-state variable? Something capable or representing Positive, Neutral, and Negative. Example: Integers `-1`, `0`, `1`.   * Pro: Very concise.   * Pro: Potentially efficient, Could be stored as a single 2-bit signed integer.   * Pro: could be used as a scale, such as a floating point multiplier. Example 2: `0`, `null`, `1` (or any permutation)   * Pro: Non-neutral use case can be binary.   * Con: Requires dynamic datatype    * Con: Potentially not concise. Example 3: `+`, `` (empty string), `-`   * Pro: Very concise.   * Con: May utilize string logic to determine state.   * Pro?: Intuitive graphical representation.  Perhaps there is some clever binary logic that can do something clever that I can't even imagine, perhaps there relies too much considerations of the use case. Also, are there any considerations when adapting a ternary state to store in a database engine? Like Innodb for reference.


title: Methods to keep an external service up to date that polls your service periodically?

text: Sorry if the title is hard to understand, it is easier if I describe the scenario to get the question across. I have a service that collects data, performs business logic and does all the normal stuff. I now have to perform an integration that will provide a set of data (for sage accounts) via an endpoint (`http://example.net/import-feed`). This endpoint can be polled by the external service at any time to pull the latest changes. When a piece of data is updated, say a payment or a date this needs to be added to the feed. This payment or date could be changed multiple times before the service gets polled. The question is what is the best methods to keep track of **all** or the **last change (probably best)** made to the record/row/data and pull all of these changes into the feed. The external service will then send notifications back to my service letting me know if adding that update was successful or not. Currently the only method I can think of is track the last modified time and the last time it was imported, and a status saying if it needs to be imported/updated. These imports/updates would then be pulled from the feed. I hope you understand the problem, I have had a hard time trying to find information on this type of integration. It may just be me not using the correct terms. So, what are the methods for this?


title: What is meant by 4 GL?

text: I came across the term 4GL(generation language) in reading about Oracle ADF Busniess components . I want to know what exactly is 4GL ? This is the actual quote from the book Oracle Fusion Guide: > Oracle ADF Business Components is the business services layer of choice in > Oracle Fusion application development. Compared to other persistence layers, > ADF Business Components provides exceptional built-in business application > functionality and maximally declarative experience that makes it a perfect > match for those who seek an end-to-end fourth generation language (4GL) Java > EE development architecture.


title: RESTful API design - should a PUT return related data?

text: I have an API which allows a user to update their system status; and a separate call to retrieve system status updates from other users. Would it make sense to unify them under a PUT request where a user would request a PUT update with their own status update, and they would receive the status updates of other users? My solution would allow the PUT request to call the GET request method internally. The reason behind this is that when a user updates their system status they should be informed of other users status immediately, and I don't feel that having 2 seperate requests is necessary - and should be optional. I intend to keep the GET request for other users status as a status update for a user is not necessarily required in order to retrieve other users status', but once they update their own status is it vital that they get information about other users.


title: Different database for Membership and our web data or use just one?

text: Is better to keep our Membership stuff on the DefaultConnection and create another connection (another database) for our data? Or just one database for all? If I have a _MyAppContext_ and I want migrations for that context, It seems that I cannot have migrations for _UserContext_ (In other words, I can just migrate one context) So, having two different databases I can migrate or the users (maybe membership migration is weird) or the web data. Or, I can mix the _UserContext_ and _MyAppContext_ in one _UserAndAppContext_ and migrate all in one place, but this mixing also seems weird. What's the normal way to do this, one or two databases and what should be migrated?


title: Immutable Method in Java

text: In Java, there is the `final` keyword in lieu of the `const` keyword in C and C++. In the latter languages there are mutable and immutable methods such as stated in the answer by Johannes Schaub - litb to the question How many and which are the uses of “const” in C++? > Use const to tell others methods won't change the logical state of this > object. >   >   >     struct SmartPtr { >         int getCopies() const { return mCopiesMade; } >     }ptr1; >   >     ... >   >     int var = ptr.getCopies(); // returns mCopiesMade and is specified that > to not modify objects state. >   How is this performed in Java?


title: Why does Javascript treat days and months differently?

text: I've noticed that in JavaScript, when creating a `Date`, months are zero based, and days aren't. For example:               var foo = new Date(2012, 1, 1)      produces February 1st 2012 Why is this?


title: Handling REST Response Formats

text: It seems that newer websites (and API's especially) make use of request formats by adding the expected format to the end of the URL path.               /path/to/resource.html     /path/to/resource.json     /path/to/resource.xml      Are their any problems with this approach? Are there any studies or outlines of the pros and cons of doing this instead of just listing the resource without a file type extension?


title: What is the point of dynamic allocation in C++?

text: I really have never understood it at all. I can do it, but I just don't get why I would want to. For instance, I was programming a game yesterday, and I set up an array of pointers to dynamically allocated little enemies in the game, then passed it to a function which updates their positions. When I ran the game, I got one of those nondescript assertion errors, something about a memory block not existing, I don't know. It was a run-time error, so it didn't say where the problem was. So I just said screw it and rewrote it with static instantiation, i.e.:               while(n<4)     {     Enemy tempEnemy = Enemy(3, 4);     enemyVector.push_back(tempEnemy);     n++;     }     updatePositions(&enemyVector);      And it immediately worked perfectly. Now sure, some of you may be thinking something to the effect of "Maybe if you knew what you were doing," or perhaps "n00b can't use pointers L0L," but frankly, you really can't deny that they make things way overcomplicated, hence most modern languages have done away with them entirely. But please-- someone -- What _IS_ the point of dynamic allocation? What advantage does it afford? Why would I ever not do what I just did in the above example?


title: Using ng-init to initialize data in Angular controller

text:
Recently I came across the following in one of our projects. In one of our mvc views they are passing model data to an Angular controller through ngInit directive               In xxx.cshtml
      I pointed out that according to Angular documentation ngInit directive is not to be used to to initialize controllers. https://docs.angularjs.org/api/ng/directive/ngInit Instead what I suggested was to send the ID in ngInit directive and
      Then after that use $http [https://docs.angularjs.org/api/ng/service/$http] service to get the remainder of data from the Angular controller. The developer is refusing my idea saying it's faster to just send all the data through ngInit directive instead of having to do another call to get the data inti the Angular controller. What do you guys think about this scenario? The only point I have right now is that this code is FUGLY and it not according to standards. How would you convince a developer to follow the path I suggested. Or am I completely wrong here?


title: Delphi IcmpPing Exception only in release, ok in debug

text: The following code is a test of the IcmpPing routine called from the icmp dll. In debug it works fine but in release it throws an error. The error is caused by the "IcmpCloseHandle" call because calling IcmpSendEcho has somehow changed the handle. It has the feel of a memory problem but so far the only fix I have found it to take a copy of the handle and use that for the close handle call. I have trimmed the code to down to minimum including having the ip address as an integer (127.0.0.1 = $0100007F little endian). What am I doing wrong? I have tested this problem on 2010, XE2 and XE4 all with the same problem. Any ideas * * *               unit icmptest1;          interface          uses     //  Windows, Messages, SysUtils, Variants, Classes, Graphics,     //  Controls, Forms, Dialogs, StdCtrls;       Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,       Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;          type       TSunB = packed record         s_b1, s_b2, s_b3, s_b4: byte;       end;            TSunW = packed record         s_w1, s_w2: word;       end;            PIPAddr = ^TIPAddr;       TIPAddr = record         case integer of           0: (S_un_b: TSunB);           1: (S_un_w: TSunW);           2: (S_addr: longword);       end;           IPAddr = TIPAddr;            PICMP_ECHO_REPLY = ^ICMP_ECHO_REPLY;       ICMP_ECHO_REPLY = packed record         Address : IPAddr;         Status : ULONG;         RoundTripTime : ULONG;         DataSize : WORD;         Reserved : WORD;         Data : Pointer;       end;            PIP_OPTION_INFORMATION = ^IP_OPTION_INFORMATION;       IP_OPTION_INFORMATION = packed record         Ttl : byte;         Tos : byte;         Flags : byte;         OptionsSize : byte;         OptionsData : Pointer;       end;          type       TForm34 = class(TForm)         Button2: TButton;         procedure Button2Click(Sender: TObject);       private         { Private declarations }       public         { Public declarations }       end;          function  IcmpCreateFile : HWnd; stdcall; external 'icmp.dll';     function  IcmpCloseHandle(const IcmpHandle : HWnd) : longbool; stdcall; external 'icmp.dll';     function  IcmpSendEcho(const IcmpHandle: HWnd; const DestinationAddress: IPAddr ;const RequestData: Pointer;const RequestSize : WORD;const RequestOptions : PIP_OPTION_INFORMATION;const ReplyBuffer : Pointer;const ReplySize : DWORD;const TimeOut : DWORD) : DWORD; stdcall; external 'icmp.dll';          var       Form34: TForm34;          implementation          {$R *.dfm}     {$T+}          function IcmpPing1(): Boolean;     var       dwSize : DWORD;       DW: DWord;       IPAddr: TIPAddr;       EchoReply: ICMP_ECHO_REPLY;       hICMP : HWnd;       Hc: HWnd;          begin       Result := False;       hICMP := IcmpCreateFile;       Hc := hICMP;            if hICMP <> INVALID_HANDLE_VALUE then       begin         try           dwSize := SizeOf(ICMP_ECHO_REPLY) + 8;                IPAddr.S_addr := $0100007F; // 127.0.0.1                ShowMessage(Format('1: %x',[hICMP]));           DW := IcmpSendEcho(hICMP, IPAddr, nil, 0, nil, @EchoReply, dwSize, 500);           hICMP := Hc;           ShowMessage(Format('2: %x',[hICMP]));                Result := (EchoReply.Status = 0);         finally           try             IcmpCloseHandle(hICMP);           except             on e:exception do               ShowMessage(e.Message);           end;         end;       end;     end;          procedure TForm34.Button2Click(Sender: TObject);     begin       ShowMessage(IntToStr(Byte(IcmpPing1())));     end;          end.


title: How do people write so many lines of code per day?

text: I know that many websites, video games and other software contain thousands of lines of code while being developed by a single person in a short amount of time. How are those people able to write thousands of LOC day after day? For me, it seems a huge number: I rarely write more than a few hundred lines per day, and often spend my time _removing_ code instead of adding LOCs. Is it really written by hand, or do they use some code generators?


title: Question I was asked during a job interview

text: I was asked during a job interview the following question, to which I couldn't find an answer then, and this thing is still bothering me. I was hoping someone might know the answer here: Consider two banks that communicate through an encrypted channel, where you are able to listen to the communication between them: ![enter image description here](http://i.stack.imgur.com/rUNov.png) Bank A is about to send some credit card numbers to Bank B (you can refer to the credit card numbers as decimal or binary number of some length of your choice - it doesn't matter). Now, suppose that you somehow gained access to Bank A's database, where it holds credit card numbers, and you are given a chance to plug your dok into it, and run any code you'd like on it. How will you then be able to steal Bank A's credit card numbers? I hope I didn't omit any important details (I should've write that down). Is it doable?


title: GDI + double rendering

text: I know that GDI custom controls are usually implemented as window controls and they receive WM events as a normal window, if a control receives the WM_PAINT it needs to repaint itself. My question is: if I were to render with GDI my window client area and create all the controls there by rendering them on (without using window controls) in double buffering, will there be problems regarding "which area needs to be redrawn"? There would be no more WM_PAINT events to redraw a specific control


title: R chart in a C# windows form

text: I see that R has very nice plotting capabilities that I would like to use in a C# windows form. There is some integration between C# and R but is it also possible to have a R chart in a windows form? Basically doing all calculations in C# and pasding results to R to plot and see everything in the windows form app. Any idea to help me on this? Thanks.


title: Multi-lingual support implementation in a website

text: I'm developing a **Multi-lingual** website which is being developed in custom `PHP` and using `MySql`. To implement the multi-language support, I've come to think of this approach (steps below). Please criticize and give your opinion and suggestions on the implementation technique. You can also suggest any better solution, if any. **METHOD 1**               1- Store the user preferred language id/code in `Cookie` (on first visit, the default language code).     2- The **database** will have a table named `languages` with the following columns:          ---------------------------------------------      lang_id | language | lang_place | lang_text     ---------------------------------------------         1    | eng      | menu[1]    | Home         2    | eng      | menu[2]    | Options         3    | eng      | menu[2][1] | My Account         4    | eng      | menu[2][2] | Settings         5    | eng      | menu[2][3] | Logout         6    | eng      | menu[3]    | Orders                              .                         .              So on for other languages      **METHOD 2**               1- Same as of method 1     2- The **database** columns will be:          ---------------------------------------------      lang_id | language | lang_data      ---------------------------------------------         1    | eng      | {                               "menu1":"home",                             "menu2":{                                   "name":"options",                                 "button1":"my account",                                 "button2":"settings",                                 "button3":"logout"                              }                           }                              .                         .              So on for other languages      I highly appreciate your help in this regard.


title: What Things are Most Conducive to a Productive Programming Environment?

text: Many of us have worked in multiple environments over the years, and have found that some are more productive than others. In many cases, it's not directly related to the abilities of the developers, but instead to their environment. I myself have experienced this, being in places where I seemed to develop faster, and better. And yet other places I seem to be dragging time, and developing less thoughtfully. What do you think creates a productive development environment?


title: Should mock objects for tests be created at a high or low level

text: When creating unit tests for those other objects, what is the best way to create mock objects that provide data to other objects. Should they be created at a 'high level' and intercept the calls as soon as possible, or should they be done at a 'low level' and so make as much as the real code still be called? e.g. I'm writing a test for some code that requires a `NoteMapper` object that allows Notes to be loaded from the DB.               class NoteMapper {              function getNote($sqlQueryFactory, $noteID) {             // Create an SQL query from $sqlQueryFactory             // Run that SQL              // if null              //     return null             // else             //    return new Note($dataFromSQLQuery)         }     }      I could either mock this object at a high level by creating a mock NoteMapper object, so that there are no calls to the SQL at all e.g.               class MockNoteMapper {              function getNote($sqlQueryFactory, $noteID) {             //$mockData = {'Test Note title', "Test note text" }             // return new Note($mockData);         }     }      Or I could do it at a very low level, by creating a MockSQLQueryFactory that instead of actually querying the database just provides mock data back, and passing that to the current NoteMapper object. It seems that creating mocks at a high level would be easier in the short term, but that in the long term doing it at a low level would be more powerful and possibly allow more automation of tests e.g. by recording data in an out of a DB and then replaying that data for tests. Is there a recommended way of creating mocks? Are there any hard and fast rules about which are better, or should they both be used where appropriate?


title: How to conciliate OOAD and Database Design?

text: Recently I've studied object oriented analysis and design and I liked a lot about it. In every place I've read people say that the idea is to start with the minimum set of requirements and go improving along the way, revisiting this each iteration and making it better as we continuously develop and contact the customer interested in the software. In particular, one course from Lynda.com said a lot of that: we don't want to spend a lot of time planning everything upfront, we just want to have the minimum to get started and then improve this each iteration. Now, I've also seen a course from the same guy about database design, and there he says differently. He says that although when working with object orientation he likes the agile iterative approach, for database design we should really spend a lot of time planning things upfront instead of just going along the way with the minimum. But this confuses me a little. Indeed, the database will persist important data from our domain model and perhaps configurations of the software and so on. Now, if I'm going to continuously revisit the analysis and design of the model, it seems the database design should change also. In the same way, if we plan all the database upfront it seems we are also planning all the model upfront, so the two ideas seems to be incompatible. I really like agile iterative approach, but I'm also looking at getting better design for the database also, so when working with agile iterative approach, how should we deal with the database design?


title: What are the qualifications for working with development of operating systems?

text: I always saw a lot of ads of programming jobs before. But I never saw an ad of operating systems development job before. I also never met personally someone who worked as operating system's programmer or something related to osdev before (I once saw a teacher at college talking about it, but I can't remember if she was talking about osdev). I would like to know:   1. What are the qualifications for an osdev position (years of experience, college/university, languages, etc)?   2. What a beginner that wants to work in this area should do?   3. How the work a of an OS developer looks like?


title: Alternative to XML / XSLT for artifact generation?

text: ## The scenario: A system needs to produce a variety of artifacts to present to end-users during the normal course of business. Examples of these artifacts would be permits, invoices, or receipts -- imagine any online app that gives you one of those "print this page for your records" pages. I'm working on a system that produces artifacts like this, but we're expected to be able to recall a previously-generated artifact and present it again when it's needed. Currently, the system retains transactional data and recreates the "artifact" page as needed from that online data. This presents a number of problems:   * More data is needed during transactional processing than is used in artifact generation. Once the transaction is complete, though, we're unable to archive the transactional data because it may be needed to reproduce the artifact at some point in the future.   * Artifact generation is slightly more expensive than it needs to be, because each time we pull up one of these artifacts, we're re-generating it. Frankly, this isn't a huge deal in practice, but it bugs me.   * If we ever change the way a specific artifact is generated, an old artifact will be "upgraded" if it's reproduced. Although this seems like a virtue, I maintain that since the whole objective is to show the artifact as it was originally generated, this is a detriment. The two most reasonable design fixes that leap to mind are PDF generation and XML / XSLT. I'm not very excited about the PDF option because I really don't think I need to store the static portions of each artifact over and over again. The XML / XSLT option still seems to have merit. In this approach, I'd need to assemble an XML document for each artifact containing only the data needed for that artifact plus a reference to the proper XSLT document. New versions of the artifact would be deployed with a new XSLT, such that old XML uses old XSLT, and new XML uses new XSLT, and so on. ## The question: Is there another killer design or technology I'm missing that would fit this need? This is a .Net system, for what it's worth.


title: Software Architecture and MEF composition location

text: **Introduction** My software (a bunch of webapi's) consist of 4 projects: Core, FrontWebApi, Library and Administration. Library is a code library project that consists of only interfaces and enumerators. All my classes in other projects inherit from at least one interface, and this interface is in the library. Generally speaking, my interfaces define either Entities, Repositories or Controllers. This project references no other project or any special dlls... just the regular .Net stuff... Core is a class-library project where concrete implementation of Entities and Repositories. In some cases i have more than 1 implementation for a Repository (ex: one for azure table storage and one for regular Sql). This project handles the intelligence (business rules mostly) and persistence, and it references only the Library. FrontWebApi is a ASP.NET MVC 4 WebApi project that implements the controllers interfaces to handle web-requests (from a mobile native app)... It references the Core and the Library. Administration is a code-library project that represents a "optional-module", meaning: if it is present, it provides extra-features (such as Access Control Lists) to the application, but if its not, no problem. Administration is also only referencing the Library and implementing concrete classes of a few interfaces such as "IAccessControlEntry"... I intend to make this available with a "setup" that will create any required database table or anything like that. But it is important to notice that the Core has no reference to this project... **Development** Now, in order to have a decoupled code I decide to use IoC and because this is a small project, I decided to do it using MEF, specially because of its advertised "composition" capabilities. I arranged all the imports/exports and constructors and everything, but something is quite not perfect in my "mental- visualisation": **Main Question** _Where should I "Compose" the objects?_   I mean: Technically, the only place where real implementation access is required is in the Repositories, because in order to retrieve data from wherever, entities instances will be necessary, and in all other places. The repositories could also provide a public "GetCleanInstanceOf()" right? Then all other places will be just fine working with the interfaces instead of concrete classes... **Secondary Question** _Should "Administration" implement the concrete object for "IAccessControlGeneralRepository" or the Core should?_


title: What type of Password Reset/Forgot Password (verification) mechanism would you recommend

text: I am looking for ways to verify the user in order to reset their passwords. 2 commonly used ones:   * Email verification   * Secret question I wonder which will you recommend? I am trying to avoid having to use email at all (users won't need to provide emails, most hosts limit emails sent). But Secret Question alone seems a little unsecure. What do you think?


title: Are there any notable programmers that started late in life?

text: So I'm starting to get disgruntled... I'm 25 and trying to learn programming and am having trouble grasping some of the concepts and I feel its because I'm getting started so late in life. So I'm just curious if there were any notable programmers that got their start late in life?


title: Parallel computing and mobile computing

text: I have been working as software developer for past 4 years on a variety of software products (Financial ERP system, Online Web development, Trading software and now a Supply Chain mgmt software). Most of the work has been in Core Java. Lately, I do feel that I should start looking into specific technical "principles" and/or domain such as Parallel Computing and Mobile Computing and not be working for long just on a software solution for the sake of working as a software developer. In short, I want to give a direction to my existing skill set so that I know more than just the programming language. Can anyone please guide me on how I should go about learning these domains? I am really interested in parallel computing, but I am not much aware of other such domains I can look into.


title: Are there open source alternatives to Bitbucket, Github, Kiln, and similar DVCS browsing and management tools?

text: I am aware of several tools/services that provide DVCS browsing and management such as Bitbucket, Github, Kiln, SCM-Manager and Rhodecode. However, the use case I am considering is one such that:   1. Any source code must reside on an employers internal servers.   2. The solution must be open source.   3. It should provide a Bitbucket or Github like experience, including a project wiki, repository browsing and management, and social coding aspects such as code review.   4. The solution should have mercurial support (if not support for other DVCSs). Of these, only SCM-Manager and RhodeCode come close as they can be installed on your own servers and are open source. However they do not have the Bitbucket or Github experience. There is no issue tracker or wiki and the UI, while functional, is not up to par with Github or Bitbucket. I can get close with Trac or Redmine with their repository browsers but unfortunately they do not have any repository management capabilities. Are there other open source tools out there that would provide a similar experience to Bitbucket, Github or Kiln?


title: Is it recommended to use DocBlock even if I'm not using phpDocumentor?

text: I'm developing a simple website for a client. I have read about **phpDocumentor** and **DocBlocks** , and I thought that documenting my classes and functions will be very useful. I'm almost sure I will **not** generate any documentation for the site, since it's a pretty simple website, and guess what? It doesn't have an API... But is it still recommended to write DocBlocks in my code? From what I know many programmers even don't write simple comments, but DocBlocks.   I'm not going to generate any readable documentation by the client/ next programmer but I still think that making some comments that are more than just simple text will be better. _edit -_ If you think that DocBlocks are redundant in my case, are there any other "standards" for writing comments / documentation?   The last time everything that doesn't have a standard makes me feel stupid, that I'm not sure if it's better to write `if(){` or `if () {`, `/* */` or `//`, etc. I'm new to the documentor and DockBlocks, and I'm still not sure if I have to write this question here or in StackOverflow. Thank you very much anyway!


title: What to put in a Stored Procedure documentation?

text: I was tasked to document our stored procedures.   * Target audience: Technical    * Purpose: To have a good documentation in preparation for migration. I'm assuming someone has already done it.


title: Difference in orientation of Sobel mask gives different edge detector result

text: I am implementing a Canny Edge detector for a class which I have based off the code found here. For the first derivative mask that I will convolve with the image, I am using the Sobel mask, although the website uses the Prewitt. As you can see in the samples on the website, the code is perfectly functional. However, I noticed different results when I changed the "orientation" of the Sobel gradient mask as I explain below. The typical mask for taking the derivative in the x direction in my class notes is shown to be:               [-1 0 1]     [-2 0 2]     [-1 0 1]      For the y direction it is:               [-1 -2 -1]     [0 0 0]     [1 2 1]      For an experiment, I changed the orientation for the x direction to:               [1 0 -1]     [2 0 -2]     [1 0 -1]      And for the y direction:               [1 2 1]     [0 0 0]     [-1 -2 -1]      Oddly enough, this gives me two different results, which I did not expect, since I don't think the "direction" that I am using for taking the gradient should give me a different result. First result:   ![Default_mask_orientation](http://i.stack.imgur.com/rFD0y.jpg) Second result:   ![enter image description here](http://i.stack.imgur.com/HroFv.jpg) Why am I getting this different result? Where should I investigate next?


title: Why is Adobe Air so underrated for building mobile apps?

text: I've worked with Adobe Flash-related technologies for the past 5 years. I've seen small bugs in some apps, but I don't understand why many big companies don't consider Adobe Air for their mobile apps. I've seen many mobile developer job postings that require Android or iOS expertise, but not too many that require Adobe Air expertise. This puzzles me because you can deploy Adobe Air apps to Blackberry, iOS **and** Android. Also, in my opinion, it's much easier to develop a game with Flash, than it is with the Android SDK, for example. Does Adobe Air really have weaknesses that I've never seen?


title: How to develop on Windows and test and run on Linux?

text: I am one of two developers for some internal software (written in python) in my company. Software is a server application designed to run on a dedicated Linux box. Currently, we have one box holding our SVN repository and this box is also used for testing. The problem is that I am developing it on my workstation using Eclipse on Windows and this app can't run on Windows. How to properly organize such environment so that you can don't lose valuable time on transferring the project and code around so that you can test it? Currently I am doing svn checkout, change some code and then upload it to the development server for testing (not via svn). Test it on the server, change something, test it again etc. After all of that comes the commit. This constant uploading and testing is driving me crazy. I've tried to keep the project on the server (checkout to home dir) but this causes a whole lot of problems with Eclipse. Obviously I don't have a lot of experience in this, so I am asking what are the best practices concerning this kinds of problems?


title: Performance: recursion vs. iteration in Javascript

text: I have read recently some articles (e.g. http://dailyjs.com/2012/09/14/functional-programming/) about the functional aspects of Javascript and the relationship between Scheme and Javascript (the latter was influenced by the first, which is a functional language, while the O-O aspects are inherited from Self which is a prototyping-based language). However my question is more specific: I was wondering if there are metrics about the performance of recursion vs. iteration in Javascript. I know that in some languages (where by design iteration performs better) the difference is minimal because the interpreter / compiler converts recursion into iteration, however I guess that probably this is not the case of Javascript since it is, at least partially, a functional language.


title: Why is there a new() constraint in C# but no other similar constraint?

text: In C# generics, we can declare a constraint for a type parameter `T` to have a default constructor, by saying `where T : new()`. However, no other kinds of constraints like this are valid - `new(string)` for example, etc. **From a language design and/or implementation perspective, what is the reason for this?** Is there something in the way constructors work or in the way the type system is implemented that forbids this (or at least makes it harder)? If so, what is it? I recall reading somewhere that `default(T)` actually compiles to `new T()` for `T : struct`. Is it related to this, maybe? Or is it simply a design decision made in order to avoid making the language too complicated?


title: Why the name 'continue'

text: The 'continue' keyword in Java (and probably in many other programming languages) is used to skip further execution of the current iteration. Why was the name 'continue' chosen? Why not something more straightforward like 'skip' ?


title: Developer name in the copyright notice of files contributed to open source project?

text: I am developing a small application which I want to make open source. Currently only my work is on the application, and so in all the files I have put up a copyright notice in my name. Now when I make the project open source and say a developer Sam does some enhancements to some existing files. Then should he be allowed to put up a copyright notice in his name as well? And what if a new file is added by Sam which is entirely his work. So should he add his copyright or mine? I feel that all files should have only my name as copyright irrespective of the work done by anybody. This is because say I have added some code which depends on Sam's copyrighted code and the application is running on it. Now in future if Sam is approached by some organization then he can sell the code under his copyright. If this happens then my application will stop working because I will have to remove Sam's code and all the depending code of mine. This is just what I feel. What is the common practice in the Open Source Community? Note I want to use GNU LGPL as my license. I am maintaining a list of contributors which can be viewed by clicking a button in the About Dialog.


title: Course Map Generator

text: My university lists the rotation of courses each semester/year. Therefore, it is possible to predict when every class will be taught. I am trying to create a JavaScript (language is irrelevant, really) program that will have the user select all the courses they would like to take, for how many semesters, and the max (or maybe exact) number of classes they'd like to take during each one of those semesters. So, for instance, my university offers: 12 courses in Fall (varies between even and odd years) 10 courses in Spring (varies between even and odd years) 6 courses in Summer (varies between even and odd years) essentially, 6 different semester patterns Basically, the user will choose their preferred 16 or so courses, enter 6 semesters, the semester they would like to start in, and the max number of courses per semester. From there, I would like to generate all the possible course maps the user could take in order to graduate in 6 semesters. I want them to be able to vary the number of courses in each semester--like 3 courses one semester, 2 courses in another, etc. I also want to check previous classes to make sure classes aren't duplicated, as well as ensure that the classes meet their respective pre-requisites. My instincts say to go with recursion in order to do this, but I'm not exactly sure how I would go about it. So far, I have only been able to come up with: generate all the sets per semester based on home many courses the user would like in that semester (if the user picks 3 courses for the first semester, then create all the sets of 3 out of the 12 courses). Do this for each semester. Then, loop through all these combinations to see which ones work. Seems very inefficient and slow to me. As this is Programmers SE, I'm not really looking for any code, but maybe an algorithm or a more efficient approach to this problem. Any help would be greatly appreciated. I can post a link to my university's course rotation if that would help.


title: When should I use ZeroMQ and when should I use Akka?

text: My _understanding_ of Akka is that it allows you to define groups of mini- threads (" **Actors** ") and then have them communicate with each other (and do work) using events. My _understanding_ of ZeroMQ is that its a TCP socket library that allows threads to communicate with each other over TCP/ports. My question: these seem like very similar concepts. However, I'm sure that in reality, they are meant to solve entirely different problems. So: **Intention-wise, what is the difference between these two tools?** What different problems do they solve? Are there clear/concrete use cases where one is preferable to the other?


title: Why is Software Development so far from being an engineering discipline?

text: I'm a strong advocate for Software Engineering, but even I must admit that we do not have many of the same tools, priniciples, and laws as other engineering disciplines. Why is this? And, what should we do to get there?


title: Forking an application for an "enterprise" customer

text: _Note: this is mostly a technical question but I have to explain the business background first._ **THE BUSINESS PART** I have a really interesting situation on my hands, at least interesting for me. For the last 3.5 years I've been building a business/application called Snip Salon Software. It's scheduling software for hair salons. Significantly, I've specifically targeted _hair_ salons as opposed to nail salons or tanning salons, which have different needs. The business has experienced a certain level of success but nothing spectacular so far. I have 6 salons in my local area using the product. Some time ago I was approached by a couple of entrepreneurs in the _lash_ salon industry, which has different scheduling needs from hair salons. (The beauty industry is a surprisingly complex space!) These guys would basically like me to white-label my product for them so they can sell it as part of a "business in a box" type package they offer to start-up lash technicians. **THE TECHNICAL PART** So the challenge I'm faced with is:   * I don't want to have one application that serves both hair salons and lash salons. I think it would quickly turn into a nightmare.   * I don't want to have applications running mostly the same code. That would be silly. And it's not just the features - all the branding, etc. will almost certainly be different for each version. So what I think I want to do is first fork the codebase and set up separate hosting, etc. for the lash salon application. Then, over time, maybe I want to factor out the common parts (e.g. appointment reminder emails) into modules (I'm using Ruby on Rails, so I'm talking Rails engines) and then let each fork of my application use the same copy of each module. I would of course situate it so that each engine only contained functionality that was common to the two forks of the application. **My question: from a technical perspective, how would you handle this situation?** Feel free to chime in on the business side, too.


How should older programmers respond when interviewed and 'confronted' with questions similar to "we are a young bunch, will you be able to fit into our culture?". What about the experience an older programmer packs? (says it all really) [edit] Read this on slashdot \- whoo-haa - we're like wine! ;)


title: Recommended Abstraction to transfer data over a nework than byte[] array?

text: I was curious, why do we prefer byte[] array to transfer data over the network and not anything else? Or if I am missing anything, what are the other ways to transfer the data over a network.


title: Generics vs IoC

text: One of the "Service Locator" pattern drawbacks is that a caller can be misleaded about dependencies of a callee. Ok, but what if I put dependencies as generic parameters at a class level:               class Node<T> where T : ISomeInterface, new()     {       ISomeInterface obj       public Node()       {          obj = new T();       }     }      I have found a couple of opinions here. But I want a discussion to be continued. The most significant counterargument is that dependency injecting using generics makes late binding unavailable. But who cares in most cases? What if my app does not need this feature? I want to find some solid counterarguments. p.s. new() constraint is not necessary, as you understand.


title: Why am I seeing so many for(;;) constructs?

text: To my way of thinking, a for loop is used to iterate over a known or determinable range.               String[] names = //something;     for ( int i = 0; i < names.length; i++ ) { //do stuff }      which is equivalent (scoping of i aside) to :               String[] names = //something;     int i = 0;     while (i < names.length )     {        // do stuff        i++;     }      In other words, the `for` loop is simply a (highly useful) syntactic sugar for a commonly used `while` construct. However, I'm seeing a lot of `for(;;)` constructs on the web which are functionally equivalent to `while(true)` What is the reasoning for this? Why would the infinite for loop be preferred over the infinite while loop? // I even saw a java textbook that didn't use while loops at all! Leading to such monstrous constructs as:               String input = getInput();     for( ; !inputIsValid(input) ; )     {        //redo;     }


title: Avoiding inline JavaScript with dynamic content

text: I read here that you should avoid coding JavaScript inline (see item #1). It sounds like a great idea; however, I'm not sure how to use js to select dynamic content without setting the id in the function call inline. For example, I have a simple blog. The comments are hidden, but can be displayed by clicking an anchor (generated dynamically) that calls a JavaScript function to toggle the comments for that specific post:               $commentsButton = "id . "' href='#comments" . $post->id . "'> comments (" . count($comments) . ")";      `toggleComments()` function:               function toggleComments(id) {         $('#' + id + ' .commentsContainer').toggle(500);     }      How do you keep from doing this kind of thing? Is it always appropriate to avoid inline JavaScript? Or is this a case where it's necessary? **Update:** I ended up using this:               $('.commentButton').each(function() {         $(this).click(function() {             $(this).parents('.post').find('.commentsContainer').toggle(500);         });     });      with this:               $commentButton = " comments (" . count($comments) . ")";


title: What are the best patterns/designs for stateful API development?

text: I am about to implement a API for my TCP/IP server written in Java. Right now I have a temporary method that takes a String, executes a command based on the String and returns a String basically like the following.               public void communicate(BufferedReader in, PrintWriter out) {         while(true) {             out.println(handleCommand(in.readLine()));         }     }          private String handleCommand(String command) {         if (command.equals("command1") {             // do stuff             return "Command 1 executed";         } else if (command.equals("command2") {             // do some other stuff             return "Command 2 executed";         }     }      I really want to do something more extensible, smarter and stateful, so I could handle more complex and stateful commands and without the method/class getting bloated. How would you start? Suggestions, ideas, or links for further reading are very welcome.


title: What is the best aproach for coding in a slow compilation environment

text: I used to coding in C# in a TDD style - write/or change a small chunk of code, re-compile in 10 seconds the whole solution, re-run the tests and again. Easy... That development methodology worked very well for me for a few years, until a last year when I had to go back to C++ coding and it really feels that my productivity has dramatically decreased since. The C++ as a language is not a problem - I had quite a lot fo C++ dev experience... but in the past. My productivity is still OK for a small projects, but it gets worse when with the increase of the project size and once compilation time hits 10+ minutes it gets really bad. And if I find the error I have to start compilation again, etc. That is just purely frustrating. Thus I concluded that in a small chunks (as before) is not acceptable - any recommendations how can I get myself into the old gone habit of coding for an hour or so, when reviewing the code manually (without relying on a fast C# compiler), and only recompiling/re-running unit tests once in a couple of hours. With a C# and TDD it was very easy to write a code in a evolutionary way - after a dozen of iterations whatever crap I started with was ending up in a good code, but it just does not work for me anymore (in a slow compilation environment).


title: Declaring Clean Data

text: $clean = array();          $email_pattern = '/^[^@\s<&>]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';          if (preg_match($email_pattern, $_POST['email']))      {      $clean['email'] = $_POST['email'];      }      The example code above (Source) uses an array called `$clean` to store the filtered value from `$_POST`. It's considered a security good practice. What are the advantages of using such an approach?


title: Writing cross-platforms Types, Interfaces and Classes/Methods in C++

text: I'm looking for the best solution to write cross-platform software, aka code that I write and that I have to interface with different libraries and platforms each time. What I consider the easiest part, correct me if I'm wrong, is the definition of new types, all I have to do is to write an hpp file with a list of `typedefs`, I can keep the same names for each new type across the different platforms so my codebase can be shared without any problem. `typedefs` also helps me to redefine a better scope for my types in my code. I will probably end up having something like this:               include     |-windows     | |-types.hpp     |-linux     | |-types.hpp     |-mac       |-types.hpp      For the interfaces I'm thinking about the same solution used for the types, a series of hpp files, probably I will write all the interfaces only once since they rely on the types and all "cross-platform portability" is ensured by the work done on the types.               include     |     |-interfaces.hpp     |     |-windows     | |-types.hpp     |-linux     | |-types.hpp     |-mac     | |-types.hpp      For classes and methods I do not have a real answer, I would like to avoid 2 things:   * the explicit use of pointers   * the use of templates I want to avoid the use of the pointers because they can make the code less readable for someone and I want to avoid templates just because if I write them, I can't separate the interface from the definition. What is the best option to hide the use of the pointers? I would also like some words about macros and how to implement some OS- specifics calls and definitions.


title: What is the rationale behind Apache Jena's *everything is an interface if possible* design philosophy?

text: If you are familiar with the Java RDF and OWL engine Jena, then you have run across their philosophy that everything should be specified as an interface when possible. This means that a _Resource_ , _Statement_ , _RDFNode_ , _Property_ , and even the RDF _Model_ , etc., are, contrary to what you might first think, _Interfaces_ instead of concrete classes. This leads to the use of Factories quite often. Since you can't instantiate a _Property_ or _Model_ , you must have something else do it for you --the Factory design pattern. My question, then, is, what is the reasoning behind using this pattern as opposed to a traditional class hierarchy system? It is often perfectly viable to use either one. For example, if I want a memory backed _Model_ instead of a database-backed _Model_ I could just instantiate those classes, I don't need ask a Factory to give me one. * * * As an aside, I'm in the process of writing a library for manipulating Pearltrees data, which is exported from their website in the form of an RDF/XML document. As I write this library, I have many options for defining the relationships present in the Peartrees data. What is nice about the Pearltrees data is that it has a very logical class system: A tree is made up of pearls, which can be either Page, Reference, Alias, or Root pearls. My question comes from trying to figure out if I should adopt the Jena philosophy in my library which uses Jena, or if I should disregard it, pick my own design philosophy, and stick with it.


title: Is a programmer's gut instinct an acceptable answer with regard to design decisions?

text: There are times where I can immediately recognize and suggest a fix for a problem design pattern. However, there are other times where putting it into words just isn't possible. I know something isn't right based upon my experience and "gut instinct", but it might not be possible to pinpoint and refactor the offending code without writing tests or some R&D. For example, someone might say there are performance issues, or, the application is "slow". I know where to start looking, and I might even make a recommendation, but it's almost a subconscious effort. When is this acceptable (if ever)?


title: which sorting algorithms is using OrderBy

text: I am litle curious about what sorting algorithm is using OrderBy (linq to objects). quicksort? heapsort? introspective sort ? As i see in MSDN documentation List.Sort is using introspective sort: see: http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspx Maybe OrderBy use the same? If we go to order by documetation i don't see much information: http://msdn.microsoft.com/en- us/library/system.linq.enumerable.orderby(v=vs.110).aspx


title: Architecture for interfacing multiple applications

text: Let's say you have a Master Database and a few External/Internal applications that use WebServices to interface data. What would be your preferred architecture to interface data from and to those applications? Would you put some sort of Enterprise Service Bus in between? Like BizTalk? Or something cheaper? We don't want to block applications while they are interfacing, but we do want to use return codes from the interfaces to determine if we need to take some actions in the originating application or not.


title: Relationship between Repository and Unit of Work

text: I am going to implement a repository, and I would like to use the UOW pattern since the consumer of the repository could do several operations, and I want to commit them at once. After read several articles about the matter, I still don't get how to relate this two elements, depending on the article it is being done in a way u other. Sometimes the UOW is something internal to the repository:               public class Repository     {         UnitOfWork _uow;              public Repository()         {            _uow = IoC.Get<UnitOfWork>();         }              public void Save(Entity e)         {             _uow.Track(e);         }              public void SubmittChanges()         {             SaveInStorage(_uow.GetChanges());         }     }      And sometimes it is external:               public class Repository     {         public void Save(Entity e, UnitOfWork uow)         {             uow.Track(e);         }              public void SubmittChanges(UnitOfWork uow)         {             SaveInStorage(uow.GetChanges());         }     }      Other times, is the UOW whom references the Repository               public class UnitOfWork     {         Repository _repository;              public UnitOfWork(Repository repository)         {            _repository = repository;         }              public void Save(Entity e)         {             this.Track(e);         }              public void SubmittChanges()         {            _repository.Save(this.GetChanges());         }     }      How are these two elements related? UOW tracks the elements that needs be changed, and repository contains the logic to persist those changes, but... who call who? Does the last make more sense? Also, who manages the connection? If several operations have to be done in the repository, I think using the same connection and even transaction is more sound, so maybe put the connection object inside the UOW and this one inside the repository makes sense as well. Cheers


title: An alternative to multiple inheritance when creating an abstraction layer?

text: In my project I am creating an abstraction layer for some APIs. The purpose of the layer is to make multi-platform easier, and also to simplify the APIs to the feature set that I need while also providing some functionality, the implementation of which will be unique to each platform. At the moment, I have implemented it by defining and abstract class, which has methods which creates objects that implement interfaces. The abstract class and these interfaces define the capabilities of my abstraction layer. The implementation of these in my layer should of course be arbitrary from the POV view of my application, but I have done it, for my first API, by creating chains of subclasses which add more specific functionality as the features of the APIs they expose become less generic. An example would probably demonstrate this better:               //The interface as seen by the application          interface IGenericResource     {         byte[] GetSomeData();     }          interface ISpecificResourceOne : IGenericResource     {         int SomePropertyOfResourceOne {get;}     }          interface ISpecificResourceTwo : IGenericResource     {         string SomePropertyOfResourceTwo {get;}     }          public abstract class MyLayer     {         ISpecificResourceOne    CreateResourceOne();         ISpecificResourceTwo    CreateResourceTwo();              void UseResourceOne(ISpecificResourceOne one);         void UseResourceTwo(ISpecificResourceTwo two);     }          //The layer as created in my library          public class LowLevelResource : IGenericResource     {         byte[] GetSomeData()         {}     }          public class ResourceOne : LowLevelResource, ISpecificResourceOne     {         int SomePropertyOfResourceOne {get{}}     }          public class ResourceTwo : ResourceOne, ISpecificResourceTwo     {         string SomePropertyOfResourceTwo {get {}}     }          public partial class Implementation : MyLayer     {         override UseResourceOne(ISpecificResourceOne one)         {             DoStuff((ResourceOne)one);         }     }      As can be seen, I am essentially trying to have two inheritance chains on the same object, but of course I can't do this so I simulate the second version with interfaces. The thing is though, I don't like using interfaces for this; it seems wrong, in my mind an interface defines a contract, any class that implements that interface should be able to be used where that interface is used but here that is clearly not the case because the interfaces are being used to allow an object from the layer to masquerade as something else, without the application needing to have access to its definition. **What technique would allow me to define a comprehensive, intuitive collection of objects for an abstraction layer, while their implementation remains independent?** (Language is C#)


title: How do Text User Interfaces (TUI) work?

text: Hello   I have recently been assigned to port and old cobol programm.   I am used to GUI and it i cant understand how TUI work!! I searched a lot through google but could find something....   I knew that console applications could output line by line but how colors etc draw to the terminal screen????How all this stuff is being drawn? .. Do terminals support it somehow?? Is there a standard??? I am really confused !


title: Should "tests" be kept out of the main merge pipeline?

text: We all know sometimes a e.g. merge can go wrong. If our [unit / integration] tests are in the same repository as the merge, is there then a weakness there that if the tests have merged incorrectly and do not appear in the final code then "we don't know what we don't know". Should the unit test project then instead be a complete separate item? In many ways I'd say no as it could litter a master branch with feature tests which are not yet relevant. In compiled languages then the compilation will fail if the test's reliant code is missing, so will help to a certain degree. But perhaps a non-compiled language is better as it would highly specific missing items when running the test. Does anyone have a workflow which it is possible to know which features may of merged incorrectly?


title: Would you choose a database or a dvcs as storage for a documentation wiki?

text: I'm about to start coding a documentation oriented wiki, as a pet project. The core features are:   * Extremely easy grouping of documents per version    * Markdown syntax (subset of)   * Multiple authors & projects I'm still undecided on storage options. The obvious approach would be a database. Since this is a pet project, I will probably go with a NoSQL solution, probably MongoDB. Most work related projects are based around MySQL, and I want to keep this fun, i.e. not do the same stuff I do at work all day. The less obvious approach would be Mercurial, in similar fashion to git-wiki. Mercurial would offer obviously tighter integration with the code and I won't have to build versioning. I still need some sort of database, to store repository info and possibly other stuff, but Mercurial would be the main storage for texts. I've compiled a small list of the major points for each approach: **Database**   * Can shape it as I want, without caring for Mercurial workflow.   * Code integration could be as easy as putting a link to the repository (but nothing more).   * Quite easy to switch databases at any point, if need be (abundance of native tools).   * Natural choice (more people are used to it, not coupled to a vcs). **Mercurial**   * Versioning and diff by default.   * Tight integration with code means lots of cool stuff are possible, like a code review plugin.   * I'll have to write a wrapper, I'm not happy with every ready made library I've evaluated (not necessarily a bad thing).   * Some sort of database still needed.   * Several valid workflows, the one I choose for the tool might not be very compatible with those people will choose for their code. I want to make this as small and fun as possible, and I am a little bit stuck on the two approaches. Thoughts? Is there something obvious I'm missing? If this is too fuzzy to decide, what should I better define before I choose?


title: Reinventing the wheel, or the technology that drives it?

text: I recently asked a question on StackOverflow that was related to string splitting and pattern matching in .NET. Some beady eyed developers that viewed the question said: " _It looks like you're trying to parse a JSON string...why don't you just use JSON.NET or JavaScriptSerializer_ ". The conversation went off at on a tangent, (and was voted down, most likely because they could not see the point of writing some functionality, which has already been done.) I have my reasons for writing this functionality...my implementation so far is slick, and super-fast (though suffers a little with string splitting, hence the StackOverflow question). I think the point these developers were trying to make was, " _why reinvent the wheel?_ " I might equally argue: " _Why bother developing NHibernate, when Microsoft have built a perfectly good Entity Framework?_ ", or " _Why bother building Windows 8, when Windows 7 is a perfectly suitable desktop operating system?_ " The same principle applies, does it not? When an automobile company designs a new car, they are not re-inventing the wheel; rather, they are improving on the technology that drives it. Similarly, my JSON parser is a nice, neat and fast implementation (although, as states above, suffers a little on string splitting), therefore, when my parser is ready, should I be shunned for writing something that has already been done, or praised for doing it better? **EDIT:** Consider the following Q/A : Is reinventing the wheel really all that bad?


title: So we've got a code review tool, now what can we use for software documents?

text: We're using Subversion as a full CM for code and also for related project documents. We have JIRA and Fisheye. When we wanted to add a peer review tool, we looked at and tested several candidates. Our weighted requirements included both code and document review, but ultimately, the integration with JIRA slanted the scores in Crucible's favor. Atlassian has slammed the door on ever supporting Word or PDF in Crucible. I've tested several workaround methods to make Crucible work for documents without success. (The Confluence/Crucible plug-in was deprecated by Atlassian, so that option is out, too.) I haven't found a plugin for Crucible that adds this functionality, so short of writing my own plug-in, Crucible for documents is unworkable. Word Track Changes doesn't provide a method for true collaboration and commenting. Adobe PDF Comment and Markup is interesting, but doesn't provide a great way to keep a permanent quality record of the conversation. We can't go cloud-based, our documents must be locally hosted on our own server only. We're only on Sharepoint 2007. Help! Anyone have a suggestion?


title: How to avoid code duplication for a system which has logic that may change year wise?

text: What would be the way to design a system which has logic that may change year wise? There is an application which conducts online exams. There are five questions for a particular subject. The questions may (or may not) change year wise. As per my current design, the questions in database are stored year wise. There are some year specific code logic as well. In order to enable the application for another year, the year specific database records and code will be copied or duplicated. How to avoid this code duplication?


title: Why do some projects not use generics

text: I've been looking at a number of OSS java projects and a number of them still have not adopted generics. They're using raw types (e.g. `List foo`) instead of generic types (e.g. `List<string> foo`). Other projects have only begun using generics in the last few years even thought they've been around for a long time. I'm interested to know why people and projects eschew the use of generics when there appears (to me) to be now downside in using them instead of rawtypes. For those of you who use java, but not generics, what (if anything) would make you switch?


title: Testing my model for hybrid scheduling in Embedded Systems

text: I am working on a project for school, where I have to analyze the performances of a few fixed-priority servers algorithms (polling server, deferrable server, priority exchange) using a simulator in the case of hybrid scheduling, where we have both hard periodic tasks and soft aperiodic tasks. In my model I consider that:   * the hard tasks have a period equal to their deadline, with a known worst case execution time (wcet). The actual execution time could be smaller than the wcet.    * the soft tasks have a known wcet and random interarrival times. The actual execution time could be smaller than the wcet.  In order to test those algorithms I need realistic case studies. For this reason I'm digging in the scientific literature but I am facing different problems:   * Sometimes I find a list of hard tasks with wcet, but it is not specified how the soft tasks parameters are found.   * Given the wcet of a task, how can I model its actual execution time? This means, what random distribution should I use considering the wcet?   * How can I model the random interarrival times of soft aperiodic tasks?


title: Is sending data to a server via a script tag an outdated paradigm?

text: I inherited some old javascript code for a website tracker that submits data to the server using a script url:               var src = "http://domain.zzz/log/method?value1=x&value2=x"     var e = document.createElement('script');                       e.src = src;      I guess the idea was that cross domain requests didn't haven't to be enabled perhaps. Also it was written back in 2005. I'm not sure how well XmlHttpRequests were supported at the time. Anyone could stick this on their website and send data to our server for logging and it ideally would work in most any browser with javascript. The main limitation is all the server can do is send back javascript code and each request has to wait for a response from the server (in the form of a generic acknowledgement javascript method call) to know it was received, then it sends the next. I can't find anyone doing this online or any metrics as to whether this faster or more secure than XmlHttpRequests. I don't know if this is just an old way of doing things or it's still the best way to send data to the server when you are mostly trying to send data one way and you need the best performance possible. **So in summary is sending data via a script tag an outdated paradigm? Should I abandon in favor of using XmlHttpRequsts?**