What do you do when a client requires Rich Text Editing on their website?

As we all know by now, XSS attacks are dangerous and really easy to pull off. Various frameworks make it easy to encode HTML, like ASP.NET MVC does: > `<%= Html.Encode("string"); %>` But what happens when your client requires that they be able to upload their content directly from a Microsoft Word document? Here's the scenario: People can copy and paste content from Microsoft word into a WYSIWYG editor (in this case tinyMCE), and then that information is posted to a web page. The website is public, but only members of that organization will have access to post information to a webpage. What is the best way to handle this requirement? Currently there is no checking done on what the client posts (since only 'trusted' users can post), but I'm not particularly happy with that and would like to lock it down further in case an account is hacked. The platform in question is ASP.NET MVC. The only conceptual method that I'm aware of that meets these requirements is to whitelist HTML tags and let those pass through. Is there another way? If not, is the best way to let them store it in the Database in any form, but only display it properly encoded and stripped of bad tags? > **NB** : The questions differ in that he only assumes there's one way. I'm > also asking the following questions:   >  1\. Is there a better way that doesn't rely on HTML Whitelists?   >  2\. Is there a better way that relies on a different view engine?   >  3\. Is there a WYSIWYG editor that includes the ability to whitelist on the > fly?   >  4\. Should I even worry about this since it will only be for 'private > posting' (Much in the same way that a private blog allows HTML From the > author, but since only he can post, it's not an issue)?   > **Edit #2** : > If suggesting a WYSIWYG editor, it must be free (as in speech, or as in > beer). **Update** : All of the suggestions thus far revolve around a specific Rich Text Editor to use: Only provide an editor as a suggestion if it allows for sanitization of HTML tags; and it fulfills the requirement of accepting pasted documents from a WYSIWYG Editor like Microsoft Word. There are three methods that I know of: 1\. Not allow HTML. 2\. Allow HTML, but sanitize it 3\. Find a Rich Text Editor that sanitizes and allows HTML. The previous questions remain (1-4 above). * * * ### Related Question > Preventing Cross Site Scripting (XSS)


Should strategy objects have state?

I have an application object that needs to validate some data. The particular validation algorithm isn't known until runtime, so I pass a validation object to it, using the strategy pattern. The application might need to reuse the validation object; for example, it might need to perform two validations simultaneously. So ideally, the validation object wouldn't contain any state; it would be purely an algorithm. But what if the validation algorithm itself needs some state? For example, it might need to keep a list of validation errors. What's a good approach in this situation? It seems like overkill to create a factory just for this specific validation object. (Assume this is in a language like Java or PHP.)


Will hosting documents on AWS reduce our load?

Due to partnerships, we are required to host our website through our partner company. However, we had an idea that perhaps we could offload the document storage to an AWS document server. The thinking is that we could serve the html from our server, and serve any large document files from the AWS server, which would greatly reduce our bandwidth load. Having never used AWS, can I simply provide a relatively secure AWS URL to the browser which will pull the document from AWS and bypass our web server altogether?


Micro-services and data replication

I am building a new application and was reading about micro-services architecture. The architecture itself makes lot of sense from a development, deployment and life cycle management point of view. However one issue that came up was with regards to how to handle master data. For example, I have 2 apps - say Sales app and a Ticketing app. Assume that both of these apps are built as own micro-services. However both of these apps, when deployed (assuming that they are deployed separately say Sales uses MongoDB and Ticketing uses MariaDB), would need to have access to the same master data instances e.g. Accounts, Products. This would mean that there would be a owner app for a given master data entity (e.g. for Accounts it might be the Sales app) and an interested party (e.g. Ticketing app would need to have information about Accounts). There are multiple ways in which this can be achieved: \- Data replication from master to interested party \- Synchronous read from interested party to master (sync dependency is not recommended by the micro-services architecture paradigm) \- Own centralized repository Also even within Accounts, there can be a core part which is common for both Sales and Ticketing (e.g. account name, address etc.). However some aspects of the Account might ONLY be relevant for Sales and others ONLY relevant for Ticketing. Any thoughts / best-practices / opinions regarding any of the above mentioned options ?


Best Version Control Habits For Solo Developer?

I'm a sole developer at my work and while I understand the benefits of VCS; I find it hard to stick to good practices. At the moment I'm using git to develop mostly web apps (which will never be open sourced due to my work). My current workflow is make lots of changes to the development site, test, revise, test, be happy and commit changes, and then push the commit to the live site (so if I'm working on a big new change; I may only commit once a week; but my IDE has a good undo history for uncommitted stuff). Basically, I'm only using git when switching between machines (e.g., work dev computer to home dev computer or to live machine), but during the day I don't really see the benefit. This leads me to have long laundry lists of changes (and I have trouble finding good msg for each commit; and whenever I'm in a rush - I tend to leave crappy messages like 'misc changes to admin and templates'). How often should I be committing? Should each one-line change get a commit? Should I commit before any test (e.g., at least for syntax/compiling errors and then have to totally undo it; as the idea didn't work or the message is a lie)? Should I make sure I commit each morning/afternoon before I stop working for dinner while its still fresh? What I am missing out on by having bad VCS habits?


What to look for in Startup employees

I am an engineer but don't have a computer science background. I am proficient with Python, Django, use Mongo and know a bit of C++ / C#. Dabble with NGinx here and there. My weekend project, a nifty webapp, just saw explosive growth. And am looking to expand the team. What should I look for in potential hires beyond the obvious (code samples etc) ? Should I hire someone who wears many hats and bigger pay or break it up into smaller roles?


Jumping around to work on different features when you get stuck, is it a source of project failures?

On personal projects (or work), if one gets stuck on a problem, or waiting to figure out a solution to the problem, if you jump to another section of your code, don't you think it will be a good reason your application will be buggy or worse yet never get completed? Assuming you are not using git and code each feature to a specific branch, things can get out of hand since you have 3 different features you are working on, and you have unresolved issues in each. So when you get done to work, you get stressed out because you have these hanging issues and half-baked code lingering about. What's the best way to avoid this problem? (if you have it) I'm guessing using something like git and creating a branch per feature is the safest way to avoid this bad habit. Any other suggestions?


Should use of VSS be a dealbreaker in an employment offer?

I've been reading some of the horror stories about VSS recently, and it seems like a poor choice for anyone to continue to use. This is sort of a two-part question:   * Are there any objectively good reasons to use VSS?   * If not, should it be a dealbreaker for employment? I only have personal experience with one company presently using VSS (in my pre-developer days, so I didn't use it), and the culture there was extremely reactionary and adverse to change. I don't want to project my experience with this company on other organizations if there are legitimate reasons for using VSS these days, but I can't think of any reason other than being stuck in a rut that a place would use VSS 7+ years after support was dropped when it seems that there are relatively painless migration options.


Testing activities carried out in an OO development project

Does anyone know the testing activities carried out in an Object-Oriented development project that uses an incremental approach to development and delivery?


What kind of JavaScript design pattern is that?

In our workplace we use simple ajax library for getting page data and submitting changes to server ,on certain occasions we do need to change the forms fields values ,now we know that fields can be of any type (dropdown , textbox and radiobuttons etc) and one of the most annoying and tedious task I find was remembering various fields id so could do the manipulation (the task can exceed for few days,so I had to keep the ids in notepad) ,then I made this design pattern for easy working with the fields.                function FormFieldsManager() {                 var FormMgr = {                     txtGradeName: function (txt) {                         if (txt) {                             $('#txtGradeName').val(txt);                         }                         else {                             return $('#txtGradeName').val();                         }                     },                     txtGradeDesc: function (txt) {                         if (txt) {                             $('#txtGradeDesc').text(txt);                         }                         else {                             return $('#txtGradeDesc').text();                         }                     },                     ddStatus: function (txt) {                         if (txt) {                             if (isNaN(txt)) {                                 $("#ddStatus").val(txt);                             }                             else {                                 $("#ddStatus")[0].selectedIndex = txt;                             }                         }                         else {                             return $('#ddStatus :selected').val();//selected value: A                         }                     }                 };             return FormMgr;             };      In order to use that function,I just call the method and I could navigate the form fields and I get full JavaScript intellisense.               var form = FormFieldsManager();     form.txtGradeName('Software Developer');//to set the field value     form.txtGradeName();//to get the field value      **So my questions are,**   1. What specific design pattern is this?   2. What suggestion for improvement you guys can give? **PS:** I like to call it jsPageObject :)


How does API design differ from general web application development design?

If I was working on a web application designing and writing an API how does that differ from a general web application development? What things would I need to consider and take into account? Are there any standard processes to follow when creating an API that could be used by thousands of clients?


How to select drawing system when requirements not yet known?

We're developping an application for 2D data processing and display. At the moment data is displayed by converting each point to a color depending on intensity, so in rather low level code. This works well. A new feature is displaying a grid and a bunch of lines that can be moved with the mouse on that image. As usual when new technologies are going to be picked, I made a little demo to test some things out: using the current data plot, a line is drawn on top that can be moved up/down with the mouse, and at the same time there is text displaying the cursor coordinates. I tried some different ways: using a Canvas, using a somehwat lower level DrawingContext and using the low level WriteableBitmapEx api. To me, there was no real difference in ease of coding nor display speed. Yes the Canvas option had a couple of lines less code than the others, while I had the impression the lower level options were somewhat faster to display. But no huge differenes making me pick one immediately. So the problem now is: I have no idea how to select the most suitable system for the job, but it is a very important decision to make since the graphical part of the app will likely continue to grow. Needless to say it would be a small disaster if we pick A now, and in one year we figure out B would have been way better. Normally I'd select the fastest or most convenient option, or look at future requirements and use the system that seems to fit best, but in this case there is simply not enough difference, and future requirements are not exactly known: for now we think it's sufficient if we can draw lines, circles and some text, and update speed is not that important. However the application is in it's early stage, so is the underlying hardware and there are less than 100 customers. That however, might change rapidly. And so can requirements. Question is simple: what to do? Some options I've been thinkig about:   * pick one that 'feels' best (WriteableBitmapEx but probably just because I have an affinity with lowlevel stuff)   * pick the one with the least amount of code (Canvas, also seems very easy on the UI level with effects and mouse events and what not)   * make a more extensive demo so differences become more clear pick one, but put everything behind an interface so the implementation can be swapped later (might be quite some work)


How do you study for MCPD?

my employer is encouraging us and even require us to take MCPD and get certified. They offer online ebook and practice exam from measureup.com but I get bored and tired when I read those self-paced training kit and stray away to do something else. I like the way Zed's "learning python the hard way" teach. Is there some similar book like Zed's? How do you guys study for MCPD?


Storing a drawn graph information in database for web application

Well while developing a web application that allow users to draw graphs (flow charts, ER diagram , UML, .... etc) the information of drawn items and their relation to each other and position on canvas is expressed as JSON object The question is: 1- is saving such graph in database as raw (json object text) is enough (in one field of a table) 2- or is it always required to break down the json object into logical pieces and store them into a well built database structure! option 1- other than making devilopers life easier it will eleminate the need of recreating json object from small bits and pieces of information when the user open a graph he have built and saved long time ago option 2- will have fine grain details in proper structure but will cost kind of heavy processing while opening a saved graph from Database which way is correct way to go ?


Why do ruby and python seem to have more community contribution than PHP?

In a recent blog post by Roy Osherove, it is pointed out that his switch from primarily .Net development to ruby development has seen a huge difference in community involvement and really enjoys it. The quote that spawns this question is : > there is no master overlord that dictates what you will or won’t work with. I don't spend a great deal of time working with php, but I do spend about the same amount of time working with ruby. From the time that I spend working and communicating with people who work with both technologies it seems like Ruby has the feeling Roy describes much more than PHP does. I don't deal with Python a great deal, but those I know who do all say it has a similar community feeling. This strikes me as odd since every ruby and python programmer I know tend to have learned php somewhere along the way but they have no similar feeling about the php community. I understand there are justifiable complaints with earlier versions of php, but people were still able to use it to build some very large sites and many companies use it. What separates these communities that ruby and python seem to have such a different vibe compared to php? (This question could be subjective but I'm hoping there is a solid impartial answer to explain the difference)


What is Google's intention to fund Firefox while developing Chrome?

My understanding is that Google funded Mozilla Firefox although it develops its own Chrome browser. This looks redundant. What is the motivation for Google doing this? Another potentially related question: Why did Google not unify Google Video with Youtube when it acquired Youtube?


What is the traditional way to maintain extensibility in a database-driven application like this?

I'm working on a simple application for a game in Java that allows a user to record whether they have collected a given item and how much experience it contains. This will work for multiple item types (weapons, armor) and each will have its own tab with a list of all items that qualify under it. Making changes as new types are added is not such a big deal (if a clothing slot is added, for instance), but new items are added to the game all the time in biweekly patches, and I'm not sure what the traditional/customary way to make sure the application is user-extensible without requiring me to would be. Whether that would be adding a configuration menu that allows users to add news items (new rows to the local SQLite database) or a text file with something similar, but I'm certain there's a well-accepted way to do this that I'm not aware of. I'm new to databases and ignorant of the solution, so what's the professional/futureproof way to do this?


Is it useful to learn CVS before learning SVN? Does much of that knowledge carry over to SVN or are they too different?


Trying to understand what Travis CI does and when it should be used

I am very new to Git and I am planning to contribute to some open-source project on GitHub after discovering a small error in it. Upon forking it and fixing the error, I purposed a pull request and I noticed this showing up: > Failed — The Travis CI build failed Looking into the details I discovered it was caused by `Could not find .travis.yml`, which made perfect sense since I had not signed in to Travis Cl with and add .travis.yml to the repository. This is my first time hearing about Travis CI. And it sounds pretty cool so in order to learn more about it, I looked it up on Wikipedia. > Travis CI is a hosted, distributed continuous integration service used to > build and test projects hosted at GitHub. Travis CI automatically detects > when a commit has been made and pushed to a GitHub repository that is using > Travis CI, and each time this happens, it will try to **build the project > and run tests**. This includes commits to all branches, not just to the > master branch. My current understanding of Travis CI is that what it does is automatically pushing the project upon `git commit -am ".."` and I don't quite understand some part of it.   1. By **building the project and run tests** , what tests is it going to run? And how is it going to "build" the project? (like compiling it to binary?)   2. It states that "This includes commits to all branches" - but what if I don't want to commit to all branches?   3. Is it alright if I don't use Travis Cl at all? Under what circumstances is it best to use it (or it must be used)?


Static analysis config and convenience scripts in source control

1) Should static analysis tool config be placed in source control? This config is not needed to compile/run software and some developers can have different preferences (even within coding convention). On the other hand placing such config in source control and declaring static analysis tool as "official part of project" can encourage everybody to test his code and help keep it very consistent. This question is mostly about open source because in commercial projects you will establish strict workflow anyway. 2) Should convenience scripts (generating documentation, running analysis, running tests, deploying, generating installer) be placed in source control? Theses scripts have to be cross-platform and may not work well on every system. People may just use IDE to accomplish some of these tasks. But requiring everybody to write his own boilerplate seems somewhat stupid to me. This question is mostly about interpreted languages because when working with compiled languages this is usually achieved using build tool which is not needed to build program in dynamic languages.


How to define constants with PECL hidef?

I've recently convinced the team that we could upgrade from php5.4 to 5.5 -- but, unfortunately, it seems I overlooked that php-apc is no longer supported in php 5.5 -- which is fine and dandy, but we could use a replacement for apc_define_constants() Thus, I've heard about the wonders of hidef -- but, I cannot seem to find any documentation for it, anywhere -- I got it installed, after a bit of kajiggering, but I'm not sure what to do next... How could I go about unwrapping the various functions included in the pecl hidef package ? Or, at the very least, how can I use it to define constants?


Taking a course in ASP.NET

Soon, I'm going to take a course in ASP.NET. But "unfortunately" the course is based on ASP.NET 3.5 using Murach ASP.NET 3.5 as textbook. I'm a bit concern since the current latest version is ASP.NET 4.0. There's a chance that the course will upgrade to 4.0 next semester, should I do it now or wait until next semester for version 4.0? My long term goal is to get a MCPD WEb developer cert. Thanks


Sending e-mails without using an e-mail server

JavaMail sends e-mails using an e-mail server, typically through the SMTP interface of an e-mail provider. Is it necessary to use an e-mail server to send e-mails? I have a web site that will send e-mails and if possible I'd like to send the e-mails directly from the web site code without using an e-mail server. The JavaMail FAQ says that an e-mail server is required. Is there a way to send e-mails without using an e-mail server, either with JavaMail or another API?


Learning about design

How do you improve your ability to design your applications? Where do you get your design ideas from? (I am asking about code design - not about a specific language and not about visual appeal). When I started programming, I found Design Patterns to be very helpful. These days I mainly poke around open source projects to see what other people did whenever I need to solve similar problems. What do you do?


Make a change that is ignored by future merges

I have a git repository, and I'd like to make a "debug" branch. In the "debug" branch, I'd like to add a line:               debug = true;      But I want to make sure that any merges back to master ignore that change. Is there any way to set that up in way that doesn't require me to manually handle all future merges?


Our flavor of Scrum

In my organization we almost never finish all the stories in the Sprint, and most of the stories are finished about 80%. One reason for this, is that many times testers don't have enough time to test all the stories, and developers don't want to test. Another reason is that the teams are usually too optimistic so they commit to more than they can complete, and no one really cares about that, so they continue to do it each Sprint. Usually testing, bug fixes and last polishes remain on the task board after the Sprint is over. The R&D manager believes that its not that bad to leave some bugs unfixed or to skip some non critical implementation, because then he can have usability test for the new features faster. Nevertheless I think he would be happy if the team could finish all the testing and bug fixes, but if not that's completely okay for him as well, because there are always some stabilization (hardening) sprints at the end in which the smaller stuff will be taken care of. I'd like to ask you, what do you think about this development method (which is not pure Scrum, but a more flexible/weak version of it). Thank you.


Rapid code analysis

I have recently moved to a new company where I am tasked (in part) with evaluating the existing code base and coming up with patterns and best practices. Our development team consists of around 20 programmers and we have nearly as many projects. The bulk of the code is done in C# and SQL (Stored Procedures). Naturally, I speak to the guys writing the code. However, I need to read through the code to get a proper idea of what is going on. Given the number of projects, it is extremely time consuming; especially if you're simply trying to get a high-level view of what is going on. At the moment I am using Enterprise Architect to import the classes into class diagrams. This helps to an extent, but I guess something like a flow diagram would be more useful. I suspect team leads deal with this same problem often when it comes to code reviews. How do you manage to speed-up code analysis?


Validating time-limited HMACs

I'm exploring using HMAC style secret-key authentication with timestamp expiry, but am struggling to get my head around how you validate the timestamp portion. On the client side you would do:               my_hmac = hmac(my_secret, my_values)      Where you would have a `timestamp` field in `my_values`. On the server (where you also know `my_secret`) you would attempt to rebuild the HMACd string with the request parameters:               my_hmac_to_compare = hmac(my_secret, my_values_from_http_request)      Is it simply a case of embedding the timestamp as a parameter so it's hashed in to the HMAC string and then ensuring the timestamp is within N minutes of when we process the request? I have odd visions of having to iterate over 5 minutes worth of timestamps, rebuilding the HMAC string on the server attempting to find the needle-in-the- haystack that will generate the correct HMAC string. **Bonus question:** Is there a consensus on how you would initially transfer the secret key to a client from a server? It obviously becomes "dirty" after it goes over the wire, but in a user facing application you can't have someone pasting in an extensive secret key, especially if it's a mobile client.


how do you style content when querying a data structure nested n-levels deep?

This question has come up while writing a simple text adventure game where your character has an inventory, which can include containers that also have things in them. I want a clean way to style the inventory output, like so:               You are carrying:         a bag containing:             a ring         a backpack containing:             a loaf of bread      Currently I just include the formatting in the result returned by the query, all in one shot. For example,               DoInventoryCommand():         result = QueryInventory(...recursively checks inventory adding multiples of tabs depending on nesting level...)         print(result)      What I would like is a cleaner separation between content and presentation so that the query would just return a data structure that a separate pass could style. But how should the styling pass handle the n-levels deep data structure? Just for example, how would a styling tool like CSS handle it? Do you need to procedurally generate the CSS once you have the data structure?


Generating presentation elements with Javascript vs PHP

What are the pros and cons of generating dynamic pages with javascript vs doing it in PHP? As an example, I want to display certain records from some database in a table and I'm considering the following approaches:   1. Use Javascript to get some response in JSON from some PHP page, then dynamically build the table in Javascript.   2. Write some PHP in the page which will make the query and iterate through the result set echoing the table markup. What are the pros and cons of each approach?


Query Language for Java Code Analysis

I want to write a refactoring tool for the Java programming language. For this reason I need to do structural queries against the abstract syntax tree. Given this AST how do I get answers to the following statements:   * Get superclasses of an object.   * Give me the expression where I call a method x() on type XClass   * Is method x() is called without arguments (check overloading)   * Is method x() called anywhere in the execution path of object of type XClass (eg. is close() called anywhere)


How should HTML data formats be applied in everyday situations?

Given Google's shift towards a stronger focus on page markup data, how do the data formats used in Schema.org work alongside those for Microformats? How do these (and other specs) compliment each other and which should be used in preference in different situations? **Edit:** It seems from established content on the subject that opinion seems to be divided between those who believe Schema.org is doom, hellfire and brimstone and those who think it will ultimately be a good thing either way regardless of uptake. Both articles agree at least that the different formats can coexist happily without causing search engines undue grief. The question about how the different options might be used in specific cases still remains though.


Should unit test expected results be hardcoded?

Should the expected results of a unit test be hardcoded, or can they be dependant on initialised variables? Do hardcoded or calculated results increase the risk of introducing errors in the unit test? Are there other factors I haven't considered? For instance, which of these two is a more reliable format?               [TestMethod]     public void GetPath_Hardcoded()     {         MyClass target = new MyClass("fields", "that later", "determine", "a folder");         string expected = "C:\\Output Folder\\fields\\that later\\determine\\a folder";         string actual = target.GetPath();         Assert.AreEqual(expected, actual,             "GetPath should return a full directory path based on its fields.");     }          [TestMethod]     public void GetPath_Softcoded()     {         MyClass target = new MyClass("fields", "that later", "determine", "a folder");         string expected = "C:\\Output Folder\\" + string.Join("\\", target.Field1, target.Field2, target.Field3, target.Field4);         string actual = target.GetPath();         Assert.AreEqual(expected, actual,             "GetPath should return a full directory path based on its fields.");     }      **EDIT 1:** In response to DXM's answer, is option 3 a preferred solution?               [TestMethod]     public void GetPath_Option3()     {         string field1 = "fields";         string field2 = "that later";         string field3 = "determine";         string field4 = "a folder";         MyClass target = new MyClass(field1, field2, field3, field4);         string expected = "C:\\Output Folder\\" + string.Join("\\", field1, field2, field3, field4);         string actual = target.GetPath();         Assert.AreEqual(expected, actual,             "GetPath should return a full directory path based on its fields.");     }


Exit interview - what is and isn't OK

There's a lot of questions about hiring interviews, but the same cannot be said about exit interviews. As I'm going to embark on a new challenge in the near future, I'm going to go through an exit interview. My question is - **what should you say in an exit interview and what should you avoid?** For privacy reasons, and because this question doesn't only apply to me, I'm not going to give specifics. I'll get started - I think it's OK to complain about:   * infrastructure (i.e. hardware used)   * overtime (if it's regular)   * unreasonable deadlines But not about:   * management :)   * remuneration These are just off-the-top-of-my-head examples. My opinion is that you shouldn't burn any bridges when you leave, especially if the company you're leaving is really OK, but also remaining silent over existing issues defeats the purpose of the feedback - maybe some of the suggestions or complaints will be considered and fixed. I hope this is the right place to ask this :)


UML representation of specific factory pattern

I have to create an UML class diagram from the following example code (Perl). I don't think that the standard factory pattern match in my case or I don't understand it correctly. I don't have `AbstractFactory` and `ConcreteFactory` but a single `Factory`. What does this example looks like in UML class diagram? **Edit** : This is only a very flat and simple example. The real application has many "Types" with totally different workflows. The class diagramm is to get an overview over the hole structure. Not realy for internal workflow like sequence diagrams does.               package Module::Factory;     sub new { bless { type => $_[1] }, $_[0]; }     sub create {         my( $self, $name ) = @_;         my $object = "Module::Types::$self->{type}"->new( $name );         return( $object );     }          package Module::Types::Test1;     sub new { bless { name => $_[1] }, $_[0]; }     sub test {         my( $self ) = @_;         say "Hello, $self->{name}.";         return( $self );     }          package Module::Types::Test2;     sub new { bless { name => $_[1] }, $_[0]; }     sub test {         my( $self ) = @_;         say "Bye, $self->{name}.";         return( $self );     }          # even more Module::Types::TestN packages...          package main;     foreach my $type ( qw( Test1 Test2 ) ) {         my $factory = Module::Factory->new( $type );         foreach my $name ( qw( World John Peter ) ) {             my $object = $factory->create( $name );             $object->test();         }     }


AJAX event, prevents other page actions

Here's a fairly average scenario, using JSF as an example, but this same concept I have observed in ASP.NET, Apache Wicket, and other frameworks with ajax capabilities.               <h:inputText id="text1" value="#{myBacker.myBean.myStringVar}" styleClass="goodCSS">         <f:ajax event="change" listener="#{myBacker.text1ChangeEventMethod}" update="someOtherField" />     </h:inputText>          <h:selectBooleanCheckbox id="check1" value="#{myBacker.myBean.myBoolVar}" />      Let's suppose that the 'text1ChangeEventListener' is essential to 'someOtherField' and perhaps toggles its disabled attribute, or changes its available options, based on the value of 'myStringVar.' The particulars aren't important, let's just accept that for some reason we need an ajax call when the 'text1' value is changed. So Jane User is working her way down the form. She arrives at the 'text1' field and types some value. The cursor focus is still in the text field, as she moves her mouse to the 'check1' box and clicks. It appears to her that nothing has happened. She clicks again, and this time the checkbox highlights and the icon indicating a selection appears in the box. Jane has to do several entries in the form today, and sees this happen every time, and it becomes very frustrating for her. Likewise, Jeff Admin is also perusing this form, and begins to type in 'text1.' He then realizes he doesn't really want to enter this data, and so moves his mouse to the "cancel" button elsewhere on the page, and clicks. Nothing seems to happen. Jeff clicks again, and after confirming he really does want to cancel, is returned to the home page. Jeff scratches his head. The problem is simply that the first thing the system does after 'text1' looses focus is run the listener and perform the ajax operation. It may only take a fraction of a second, but still, you can click other buttons all you want, but until that ajax has finished, everything else is ignored. I've spent the morning searching and reading, and it seems no one else has even noticed this. I could find not one article, blog, past question here or at SO, or anyting that addresses this obvious and glaring deficiency in ajax. So first of all, am I truly alone in thinking this is a big problem? Second, does anyone have a solution?


Configurable tables in sql database

I have the following tables in my database: Config Table:               ======================================     Start_Range | End Range | Config_id           10           |        15        |      1     ======================================      Available_UserIDs               ==========================      ID | UserID | Used_YN   |                1 |   10      |        t          |       1 |   11      |        f          |       1 |   12      |        f          |       1 |   13      |        f          |       1 |   14      |        f          |       1 |   15      |        f          |     ==========================          Users         ==========================          UserId | FName | LName  |                      10     | John    |    Doe    |         ==========================      This is used in a reservation system of sorts... which lets an administrator specify a range of numbers that will be assigned to users in the config table. Once the range has been defined, the system then populates the Available_userIDs table with all the numbers in between the range, and sets the Used_YN flag to false As users sign up, they grab the next user_id number that's not in use... and reserve it. Then the system adds a record to the Users table. Once the admin has specified a range, it is possible that they can change it. For example, they can start with 10-15... and then when the range is used up, they should be able to specify another range like 16 - 99. I've put a unique constraint on the Available_UserIDs table, as well as on the Users table - to ensure that UserIds can't be duplicated. My questions are as follows:   1. What's the best way to prevent the admins from using a range that's already in use? I thought of the following options:  \-- check either the Users table to see if the start range or ending range numbers are being used. If they are, assume that all the numbers in between are in use too, and reject the range. \-- let them specify whatever they want, try to populate the Available_UserIDs table. If there are duplicates, just ignore that specific error message from the database and continue on.   2. How do I find gaps in the number ranges? For example, if they specify 10-15, and then 20-25, it'd be nice to be able to somehow suggest on my web page that 16-19 is currently available. I found this article: http://stackoverflow.com/questions/1312101/how-to-find-a-gap-in-running-counter-with-sql But it only seems to return the first available number... so in my example above, it would only return the number 16.  I'm sure there's a simpler way to do things that I'm overlooking!


Virtual machine for a high level programming language vs an operating system

It struck me recently that a virtual machine for a high level programming language is very much like an OS. It manages resources, e.g. stack, heap, etc. similar to how an operating system manages resources and if the programming language supports threads then the virtual machine also does time-sharing and context switching similar to how an operating system does it. How far can this analogy be taken? Why is that we don't have a bare-metal implementation of the JVM? It seems like all the pieces are there so what exactly is the reason such things are not more prevalent?


How would one build a relational database on a key-value store, a-la Berkeley DB's SQL interface?

I've been checking out Berkeley DB and was impressed to find that it supported a SQL interface that is "nearly identical" to SQLite. http://docs.oracle.com/cd/E17076_02/html/bdb- sql/dbsqlbasics.html#identicalusage I'm very curious, at a high-level, how this kind of interface might have been architected. For instance:   * since values are "transparent", how do you efficiently query and sort by value   * how are limits and offsets performed efficiently on large result sets   * how would the keys be structured and serialized for good average-case performance


Implementing `let` without using a macro

I'm learning Lisp, and I've just gotten to `let`, which I don't quite understand (the implementation of). A common definition for it is given in terms of `lambda` as a macro. However, nowhere have I seen that `let` **must** be implemented as a macro or in terms of `lambda`. Is it possible to define `let` without using a macro or `lambda`? I know it can be implemented as a primitive, but I want to know whether it can be implemented **in Lisp** without creating a macro -- by creating a special form or a function.


Should programmers prefer making wide libraries or thin libraries?

For classes and functions, it is clear cut: each should do only one thing. For libraries though, this is less clear. If you have a library with collections, it might have multiple collections. It might have useful functions like sorting, which aren't strictly collection based but users would expect. Each of these results in a 'wider' library. On the other side is having a library for the specific collection type and/or with little built-in functionality. If you want a queue, it gives you a queue. If you want to sort that list, then the library lets you do that yourself. What is the best practice here (if any)? I can see arguments for each side.


Behavior Driven Development and Unit Testing in Python

We might be interested in starting to incorporate a unit test suite to our project, which is coded in Python (and it uses Redis, PostgreSQL and some third-party libraries, if that bears into the solution). The benefits we want to achieve are:   1. Once the project is up to speed, we want to be able to specify new behavior quickly and efficiently, to help improve communication and team productivity. Read: **We want BDD, but have already started coding without it**.   2. Excellent textual support (i.e. the tests can be read almost as natural text), so as to make it **easier to write and read tests**.   3. Ability to **automatically run tests** (at the very least, to be able to include the running in a Bash script or something like that). We use Windows and Linux for development, and Linux servers, so Linux support is our primary requirement.   4. **Integration with github**. I don't know if it is possible, but I've seen some projects in github which have a "Passing" or "Failing" status on them and it would be great to have that for our project. What are good tools / libraries that can help us do this, and, most importantly, what are good ways to incorporate BDD into a Python project? Thank you very much! Any suggestions are appreciated.


Combinatorial explosion of interfaces: How many is too many?

I'm a relative newcomer to OOP, and I'm having a bit of trouble creating good designs when it comes to interfaces. Consider a class A with N public methods. There are a number of other classes, B, C, ..., each of which interacts with A in a different way, that is, accesses some subset (<= N) of A's methods. The maximum degree of encapsulation is achieved by implementing an interface of A for each other class, i.e. `AInterfaceForB`, `AInterfaceForC`, etc. However, if B, C, ... etc. also interact with A and with each other, then there will be a combinatorial explosion of interfaces (a maximum of n(n-1), to be precise), and the benefit of encapsulation becomes outweighed by a code- bloat. **What is the best practice in this scenario?** Is the whole idea of restricting access to a class's public functions in different ways for other different classes just silly altogether? One could imagine a language that explicitly allows for this sort of encapsulation (e.g. instead of declaring a function public, one could specify exactly which classes it is visible to); Since this is not a feature of C++, maybe it's misguided to try to do it through the back door with interaces?


What should a domain object's validation cover?

I'm trying to figure out how to do validation of domain objects that need external resources, such as data mappers/dao Firstly here's my code               class User     {         const  INVALID_ID = 1;         const  INVALID_NAME = 2;         const  INVALID_EMAIL = 4;         int    getID();         void   setID(Int i);         string getName();         void   setName(String s);         string getEmail();         void   setEmail(String s);         int    getErrorsForInsert(); // returns a bitmask for INVALID_* constants         int    getErrorsForUpdate();     }      My worries are about the uniqueness of the email, checking it would require the storage layer. Reading others' code seems that two solutions are equally accepted: both perform the unique validation in data mapper but some set an error state to the DO `user.addError(User.INVALID_EMAIL)` while others prefer to throw a totally different type of exception that covers only persistence, like:               UserStorageException     {        const  INVALID_EMAIL = 1;        const  INVALID_CITY = 2;     }      What are the pros and cons of these solutions?


Is it OK to return HTML from a JSON API?

On my current project I am responsible for the implementation of a service which involves the consumption of newly created RESTful APIs, documented as solely supporting JSON. The client consistently makes requests with the accept header of 'application/json' and content-type of 'application/json'. However some endpoints send a response with a content-type of HTML, even a HTML body. To me this is clearly the wrong approach and can never be justified. Throughout the project this same practice has been applied across two different vendors and two different services. I found myself having to justify why the services needed to be changed. The vendors stated that the client should cope with this and even my REST library of choice has been questioned (RestEasy) because it doesn't cope with this by default 'out the box'. This has been a major point of frustration. I can't find many references to back up my argument, I assume this is because the point is mute as it's so obvious. The question is am I missing something? I'm I being pedantic about this? Is it OK to have a JSON API that doesn't have a content-type of application/json in this scenario? References would be appreciated. How do you resolve this situation from a commercial point of view?


Drawing a biggest possible circle inside a polygon - JSXGRAPH

I manage to create a circle inside triangle with this code, but circle inside other polygons are not maximum size:               var p1 = board.create("point", [0.0, 2.0]);     var p2 = board.create("point", [2.0, 1.0]);          //var pol = board.create("regularpolygon", [p1, p2, 3]);     var pol = board.create("regularpolygon", [p1, p2, 4]);     //var pol = board.create("regularpolygon", [p1, p2, 5]);          board.create("incircle", pol.vertices);      What is the easiest way to draw a maximum circle inside square and pentagon? How about smallest circle around the polygon?


What do you use to manage servers you SSH to in OS X?

Coming from Windows, I used Putty a lot since it could store a list of hosts I often connect to, provide me with an easy to use double click and then spawn a terminal. Is there a preferred solution for OSX?


What false ideas are there that puts people off using threads?

Implementing threading in a program is hard, yes, however why is it that some people will not implement them even when there is an obvious need for it. An example: Program has to load a dataset from a database, the thing to do would be to make the connection and get the data from the database in a worker thread and then load it into the GUI, leaving the GUI thread responsive for the user. But no, I've talked to people whom seem to think that threads are evil and bad and whatnot and one should avoid them at all costs. I've even heard that some class instructor advised against to use of threads and therefore did not want cover their use. WHAT??? With the hardware going into multi-core, I think that we need to understand threads better and not be afraid to use them. I find it a fascinating subject personally. So what are things you've heard about threading that are false?


How to structure process description documentation?

I'm writing a document describing process improvement recommendations. I have some best practices I've learned so far. I use those practices most of the time. But I suppose there are other ways to approach the task of writing formal process description document. So, how do you usually structure your documentation? As you could already find out, I'm especially interested in structuring formal process description documents which are usually created by QA and sometimes Project Managers. What sections should it contain? My documents usually contain following sections:   1. Content   2. Goal    3. Scope   4. Terms and abbreviations   5. Inputs   6. Process description   7. Artifacts   8. Outputs What else should there be? Did I forget something? Are there other approaches for structuring formal documents? Link to best practices descriptions are greatly appreciated.


Passing an object into a method which changes the object, is it a common (anti-) pattern?

I am reading about common code smells in Martin Fowler's Refactoring book. In that context, I was wondering about a pattern I am seeing in a code base, and wether one could objectively consider it an anti-pattern. The pattern is one where a object is passed as an argument to one or more methods, all of which change the object's state, but none of which return the object. So it is relying on the pass by reference nature of (in this case) C#/.NET.               var something = new Thing();     // ...     Foo(something);     int result = Bar(something, 42);     Baz(something);      I find that (especially when methods are not named appropriately) I need to look into such methods to understand if the object's state has changed. It makes code comprehension more complex, since I need to track multiple levels of the call-stack. I'd like to propose to improve such code to return another (cloned) object with the new state, or anything that is needed to change the object at the call-site.               var something1 =  new Thing();     // ...          // Let's return a new instance of Thing     var something2 = Foo(something1);          // Let's use out param to 'return' other info about the operation     int result;     var something3 = Bar(something2, out result);          // If necessary, let's capture and make explicit complex changes     var changes = Baz(something3)     something3.Apply(changes);      To me it seems the first pattern is chosen on the assumptions   * that it is less work, or requires less lines of code   * that it allows us to both change the object, **and** return some other piece of information   * that it is more efficient since we have less instances of `Thing`. I illustrate an alternative, but to propose it, one needs to have arguments against the original solution. What, if any, arguments can be made to make the case that the original solution is an anti-pattern? And what, if anything, is wrong with my alternative solution?


What is the term for this type of refactoring

I am sure there is a term for the following bit of refactoring, but I can't remember it and my Google-fu is failing me! The refactor moves if statements to where they are going to have most impact, for example changing this               $test = someFunctionThatReturnsABool();     for($x = 0; $x < 10000; $x++) {         if ($test) {              echo $x;          }     }      To this               $test = someFunctionThatReturnsABool();     if ($test) {         for($x = 0; $x < 10000; $x++) {             echo $x;          }     }


What happens differently when you add a task Asynchronously on GAE?

Google's doc on async tasks assumes knowledge of the difference between regular and asynchronously added tasks. > `add_async(task, transactional=False, rpc=None)`   >  Asynchronously add a Task or a list of Tasks to this Queue. How is adding tasks asynchronously different to adding them regularly. I.e. what is the difference between using `add(task, transactional=False)` and `add_async(task, transactional=False, rpc=None)` I've heard that adding tasks regularly **blocks** certain things. Any explanation of what it blocks and how, and how **async** tasks don't block would be greatly appreciated.


What algorithms would suit image colour summarization?

I would like to analyse a set of hundreds of thousands of product images (clothing, electronic goods etc) and retrieve the dominant colours in each. I'm only interested in the top 3 or 4 colours. The aim is to achieve a degree of certainty that x image is mostly red or image y is mostly orange and blue. The images are likely to be colour jpegs of reasonable quality and approximately 100kb in size. I would like to use C# and the solution should run on a Linux server, preferably using open source libraries. What image processing algorithms or techniques might help me achieve this?


Why aren't web frameworks simple, elegant and fun like programming languages?

When I think of pretty much any programming language - like C, C++, PHP, SQL, JavaScript, Python, ActionScript, Haskell, Lua, Lisp, Java, etc - I'm like awesome I would love to develop a computer application using any of those languages. But when I think of web frameworks(I do mostly PHP) - like Cake, CI, Symfony, Laravel, Zend, Drupal, Joomla, Wordpress, Rails, Django, etc - I'm like god no. Why aren't there web frameworks that provide me with simple, fun and powerful constructs like a programming language?


Inspiration resources for desktop UI design

For desktop application, does anyone has a good website showcasing best desktop application UI? Looking for some inspiration for my application. There are a lot of website for Web application ... i can't find any for desktop application.


What's the best approach to Facebook integration?

I have a new site/app going live next week (or somewhere close). I know there will be a relatively small (15,000?) very dedicated group of people on Facebook who will be very likely to be interested in the site, so I know I need Facebook integration of some kind. I won't be doing Facebook logins or pulling/posting to profiles yet, but I plan to... The question:   * Do I just do a Facebook "Page" for now? This is faster/easier to set up and seems a little less buggy.. and then migrate to a Facebook App later? or   * Do I create a "Facebook App" (with the api key/id/secret, etc.) now even if I'm doing nothing but using the "like" button. This means I don't have any migration later and I can use the javascript api to log "like" button clicks to Google Analytics, etc. Thoughts? Experiences? Is there a migration process to move your old Page users to your new "App"? What's the advantages / disadvantages of each.


What's the canonical retort to “You can't submit a patch to this open source project because you're not a committer”?

Some projects only allow committers to submit patches because they wish to keep their IP "clean." not only can non-committers not submit patches, but committers are forbidden from looking at your code lest they become tainted by intellectual property of unknown provenance. instead, you are invited to start a discussion on their listserv or submit a ticket, and then the committers will decide if your feature is worthy.


Are there any good use-cases for variable variables?

Today I encountered this little PHP gem called variable variables.               $literal = "Hello";     $vv = "literal";     echo $$vv; // => prints "Hello"      Are there actually any real use-cases for this language feature?


What's the best approach to develop a cross-browser JavaScript app?

As one of my summer projects I'd like to build an AJAX program on my own. Not too big. I'm new to the whole matter, however I have general knowledge in programming and a good understanding of the Web workflow. As for W3C standards, is it wrong sticking to them as if they were a _platform_? Is it a good idea to code having a single platform in mind (i.e. Firefox 3 + Win7) and make it cross-browser _after the initial code is finished_? In general, to what extent is browser compatibility a problem these days?


Methods of learning / teaching programming

When I was in school, I had a difficult time getting into programming because of a catch-22 in the learning process:   1. I didn't know how to write anything because I didn't know what keywords and commands meant. For example (as a student, I would think), "what does this `using namespace std;` thing do anyway?   2. I didn't know what keywords and commands meant because I hadn't written anything. This basically led me to spending countless long night cursing the compiler as I made minor tweaks to my assignments until they would compile (and hopefully perform whatever operation they were supposed to). Is there a teaching/learning method that anyone uses that gets around this catch-22? I am trying to make this non-argumentative, which is why I don't want to know the 'best' method, but rather which methods exist.


Adding a minimum rectangle overlap threshold

I have a function that works perfectly for detecting whether or not r1 overlaps with r2:               boolean overlaps( Rectangle r1, Rectangle r2 ) {         return r1.x < r2.x + r2.width && r1.x + r1.width > r2.x &&             r1.y < r2.y + r2.height && r1.y + r1.height > r2.y;     }      But now I would like to add a minimum threshold so that it would return true if r1 overlaps r2 by at least a given length. Here's what I have so far but haven't had any luck:               boolean overlaps( Rectangle r1, Rectangle r2, float threshold ) {         return r1.x < r2.x + r2.width && r1.x + r1.width > r2.x + threshold &&             r1.y < r2.y + r2.height && r1.y + r1.height > r2.y + threshold;     }


Getters and Setters in Functional Languages

One of the tenets of Functional Programming is the use of Pure Functions. A Pure function is one that is side-effect free and referentially transparent. **Getters** are not referentially transparent - if a Setter is called between calls to the Getter, the Getter's return value changes even though its parameters have not (typically no parameters) **Setters** produce side-effects - Calling a Setter typically manipulates a value that is not its return value (in fact, traditionally a setter returns nothing) I know in Scala we just kind accept the fact we are meshing together two paradigms (functional and object oriented) and use getters/setters as we would in a language like Java. In a language like Haskell (which I'm not fluent with, but I'm told holds truer to a "Pure" functional language) I'm just curious, how you would model properties on objects such that Getters are referentially transparent and Setters are side-effect free? Would the solution be to pass back a copy of the object the setter was invoked on as the setter's return value, and this copy contains the change to the property value?


Is it worth learning either GWT or Vaadin?

I consider myself a decent java/web developer. In my career I have always used servlets and ejb's with a web front end, most recently incoporating jquery and ajax. I can see the theoretical benefit of using GWT or Vaadin: it is my understanding they convert Java code to the required JavaScript/HTML. So the developer gets the benefit of cross browser compatibility and compile time error checking (of web GUI elements). My question is threefold:   1. Are there any other benefits I am missing that would be gained using Vaadin or GWT?   2. I am actually quite confident and productive using HTML and JavaScript - so will I actually see any benefit? Or will it just make my knowledge of these areas redundant (as they are handled by GWT/Vaadin)?    3. Will the end result be that I can create enterprise scale data driven websites in a reasonably short time? I can however already do this, and I have not wasted any time learning GWT/Vaadin.


Developing a team of programmers

So, I have a web application that I need to build. The application will be done in a LAMP environment. I'm being given the resources to bring in 2 other programmers to work on my team. I have team lead and architecture experience before, so taking charge isn't a problem. The roadblock that I am experience is that I am currently living in a developing country. They have plenty of Software Engineer programs at universities, but no training/classes on really anything relating to LAMP. It is all C++/Java. So, I have a set of resumes I've culled as experience programmers that seem intelligent sitting in front of me. They come from various backgrounds, which include a couple Java developers, an old-school C++/MFC type guy, some C# devs, and a whole bunch of young out of school C++/Java developers. I'm honestly already leaning one way on which skillset I think would mold the easiest to web dev, but as I am not an application developer (exposure in school, but that was a while ago), I though I might open it up and ask you guys: Which skillset of these do you think would lead into the easiest transition to web development? I'm especially curious to hear from anyone who moved from application side over to web development.


C# Single Instance of a Form

I have 3 forms. Form 1 has information inserted into Form 2. After clicking a button on Form 2 to get to Form 3; on Form 3 I pull data and put it on Form 2. The problem with this is that I don't know how to get a single instance of Form 2 so that I can keep the data from Form 1 after pulling data from Form 3. This is a WinForms application. Any help would be much appreciated. I have looked into the Singleton way of doing it but everything I research seems too confusing to follow. Thanks!


Get 100 highest numbers from an infinite list

One of my friend was asked this interview question - > "There is a constant flow of numbers coming in from some infinite list of > numbers out of which you need to maintain a datastructure as to return the > top 100 highest numbers at any given point of time. Assume all the numbers > are whole numbers only." This is simple, you need to keep a sorted list in descending order and keep a track on lowest number in that list. If new number obtained is greater than that lowest number then you have to remove that lowest number and insert the new number in sorted list as required. Then question was extended - > "Can you make sure that the Order for insertion should be O(1)? Is it > possible?" As far as I knew, even if you add a new number to list and sort it again using any sort algorithm, it would by best be O(logn) for quicksort (I think). So my friend told it was not possible. But he was not convinced, he asked to maintain any other data structure rather than a list. I thought of balanced Binary tree, but even there you will not get the insertion with order of 1. So the same question I have too now. Wanted to know if there is any such data structure which can do insertion in Order of 1 for above problem or it is not possible at all.


How do you know a company is worth-working at or not?

I'm leaving my current company, and I'm looking for a better place to work. But this time I'm confused. I don't want to walk in and out in six months again. I want to find a company which I can work in long-term, and this trouble me much... There is a problem, in my city, there's a lot of small companies (30-50 employees), so finding employee's feedback on Internet is nearly impossible. So I need to find it myself. So, I want to ask that, when you walk in an interview of a completely new company, what do you look at the job description? look at the company itself? look at its current employees? what do you ask your interviewer? How do you determine a company is worth-working for or not?


Open source project, should I post "... will give you licenses to ..." or not?

I have just accepted the second developer into an open source project. I'm not going to say which it is, for obvious reasons ( _read the rest of this question_.) The project is a C# / .NET projectl A while ago I contacted JetBrains, authors of ReSharper, dotCover, and TeamCity. Since I am the leader of the open source project, I got "open source" licenses for ReSharper, dotCover, and TeamCity. The important part is that the licenses I got for the project, for those products, are for **all** members of my project, not just me. The question is this:   * When advertising that the project requires more people (it does), should I mention the licenses involved? On one had, I feel that mentioning the licenses might make people not really interested in the project apply for it, because they would get those licenses, and thus be people more interested in the licenses than the project, i.e. "noise". On the other hand, the licenses could be a bonus, an ... "upshot" ... and thus might make more people interested in my project, in other words I might attract people that could be a bonus to the project, that weren't aware of it before. So... Should I advertise the licenses involved? Or not? * * * **Edit** : Ok, it's late at night (in my small corner of the world) and having re-read my question, le me make it clear what my question really is about: **Does anyone have any experience, or knowledge, or barring that, thoughts, about what difference it would make if I openly posted that becoming a member of my project would give them licenses for products X and Y, as opposed to not mentioning it until they're already members?**


Question about college vs. university in Canada

So I read a post on here asking about college vs. university and the consensus seemed to be that University was worth it. My question is, does that by extension make college worthless? \---the details-- I'm at a point in my life where I want a change of careers, I've always done web-dev on the side and now I want to program as a career. My 2 options are a computer programming diploma at humber, seneca (or similar) or computer science at UofT. I can get into both courses (as I was formerly a student at UofT) but the University route is far more costly and will take 4 years instead of 2. I realize that in a perfect world the university option would be better (the general concensus in the other threads I read), but the extra money and time would be very difficult to reconcile since during this time we will need to rely solely on my wife's income. If university is the only possible option there is a chance I might need to scrap this dream all together since it might not be doable. If taking the 4 years in university isn't possible for me, is there any point in getting the college diploma? The college diploma has some Java and even Android specific courses so I could see the potential career path, but the previous threads have me discouraged on that option. I don't want to spend two years to end up with nothing.


Compiler warnings and errors

I come from a C# background before my existing role. I am developing a VB.NET app. The code I inherited had option strict set to off and all other directives set to 'None'. I have recently switched option strict on and corrected all the errors. It will take me about one day to correct all the warnings. I am trying to decide whether this is time well spent. The application is mature and is working very well. What is the guidance for setting option strict to ON and correcting warnings. I assume that you should not ignore them. However, I read online today (I think it was on here) were one questioner said he/she never bothers with warnings. Surely this is wrong?


Advantages & Disadvantages of using Class Diagrams

Any and all advantages/disadvantages would be appreciated!


IT Research & Development project and team organization

I have seen a lot of different project organizations in different tertiary sector businesses, but I have never felt that IT R&D projects were well organized. I understand that R&D projects need flexibility, and less time-constraints to give free rein to innovation. My guess is R&D projects organization needs to be revised at a certain stage. What is your experience about IT R&D organizations/methodologies - especially planning and resource management?   * Do you or your boss plan them from the beginning?   * Do you or your boss ask for time reports?   * When do you think it's time for a R&D project to enter a "standard" project organization stage?   * Omitting time limit, when do you think its time to get things done even if the goal is not totally reached?   * Omitting time limit, when do you think its time to give up if the goal is not reached? Both last ones are subjectives, I know :/


Did a bunch of wrong work, should I keep it?

I have forked a repo and branched that clone to code a story, and because I didn't understand the problem, wrote code that isn't solving my task at hand, but may prove useful later. Should I:   1. Delete it, and don't worry about it. Then commit without the extra code.   2. Make yet another branch for just that work, commit it, but don't post a pull request on it.   3. Just commit it with the existing code, and worry about the extra "fluff" later. I was thinking #2. If I understand correctly, I could just keep the extra code on a branch I never use on my clone, and dig it up later if something comes up that may benefit from using it.


How to determine the right amount of up front design?

Software developers occasionally are called upon to write fairly complex bits of software under tight deadlines. Often, it seems like the quickest thing to do is to simply start coding, and solve the problems as they arise. However, this approach can come back to bite you--often costing time or money in the long run! How do we determine the right amount of up front design work? If your work environment actively discourages you from thinking about things up front, how do you handle that? How can we manage risk if we eschew up-front thinking (by choice or under duress) and figure out the problems as they arise? Does the amount of up front design depend entirely on the size or complexity of the task, or is it based on something else?


What is the difference between use case, user requirements and user stories?

I'm wondering what the difference is, and at what stage these different terms are used within the Agile/Scrum methodology? `use case`, `user requirements` and `user stories` Am I right in thinking they start off in the requirement elicitation stage as `use cases` then become the `user requirements`, which are pretty much the same as the `user stories` used in the `products backlog`? Trying to write a university report and haven't been able to find anything defining all of these terms in the same place, which has made it difficult to understand the differences. Are some of these terms even required within an Agile approach?


Should each unit test be able to be run independently of other tests?

Say you have tests for two methods of a class. The first method gathers data from another tier and puts it into some sort of storage independent of the runtime (such as a SQL table), so all of the data handled by this test is hardcoded into the test. The second method is responsible for taking data from where the first method left it and transforming it in some way (calculation, moving certain parts elsewhere, etc.). Now this second method could have hardcoded inputs like the first one, or it could be assumed that the two tests would be run sequentially and it could pick up where the 1st test left off, taking the data that was really stored by the first test. If you went with the second option, you would really have a good idea that the two methods play well together, however, if the 1st test failed, all tests after it would fail, taking away testing benefit of helping to isolate bugs more quickly. If you went with the first option, each method would be isolated and tested independently, but you would never really know that they can really work together properly. Which is the better option here? Is there some sort of alternative like having a single test for each isolated method with hardcoding, and then bigger tests that contain both methods in one?


Minified version of JavaScript library under LGPL used on a site without copyright notice

On this site hackfind.com the autor put minified version of my library without any copyright notice. Is this violation of the LGPL. Note that using on a site is not a copy.


What process will you use to clarify functional requirements and to gather non-functional requirements?

I am confused with what's the different between clarify and gather. I know using interview, observe or questionnaire can to elicit the requirement we want, but how to clarify the functional requirement?


Should I switch from deprecated library?

For example, some library (in my case it's ruby gem) became deprecated. And my app is using this library. It's ok and I have not any problems with how it works. When should I switch from deprecated open-source library to something new? Or should I at all?


What could be the best way to generalize data from Facebook and Twitter?

I am not sure if this is the best subsite to ask this question, but I'm pretty sure it doesn't fit on the normal or facebook SO page... I've been asked to make a general API for connecting to several Social Media platforms (at the moment Facebook and Twitter). I have already realised both of them seperately. Meaning I retrieve the data I need from both Facebook and Twitter and hold the data in it's own dataclass. In my case a list of FacebookTimelineItems and a list of TwitterTimelineItems. now the hard part is taking the parts that are used in both (username, id, message and such) and make 1 general class that is eventually passed on to who/whatever sent the call to my API. these are two pics of the data classes I have: http://imageshack.us/photo/my-images/703/facebookdata.png/ http://imageshack.us/photo/my-images/204/twitterdata.png/ probably not 100% correct but it gives an idea what it looks like. Now I've been having several idea about how to go about and generalize the two, which is harder then I thought at first.   1. Create an interface (TimelineItem) and let the other classes extend that one. this way I'll always be sure I have a class that contains at least the basic info I need. downside is that deserializing the JSON seems to be a nightmare.   2. Use the two dataclasses I have and combine them into a new class afterwards, then pass that one back to whoever requested it. This would probably work but I get the idea it's not the best way to tackle this problem, and is pretty dodgy IF I get it working.  Or, in case of the other two being nearly impossible. Keep the two seperated in the front end, and go sit in the corner crying because I've just figured out you can't lump together facebook and twitter... Note: I don't have to make the front end part (view), I just make sure the Model is nicely filled with data :) I hope I placed this in the right section, if I didn't I apologise and would like to know where I should go with my question. Thanks in advance for any replied/ideas/opinions on this.


What is the best/easiest way to get my degree, already being an experienced developer?

I have been an active professional software developer (mostly utilizing .NET) for the past five years and, without being too full of myself, I would say I'm a very competent developer. I stay intimately up to date with the latest tools, the industry, and modern standards/practices. I work for a fairly high- level IT company and I swing just fine with the rest of them. I am even up to date on the latest team dynamic methodologies and feel like I have good leadership/management/people skills. However, I never got my degree. I learned and am learning everything I know on my own from hundreds of books and experiences. I ran my own software company for a while until it took a big hit from the economy a year or so ago. It took a LONG time and A LOT of applications, but I finally found the job I have now. Like an idiot I dropped out of college to forgo paying more tuition and I started my company and as life goes, I now wish I had stayed and got the degree. I have student loans that are in default and I'm working my hind end off to pay off those debts now that I am making a fair amount of money again. I have hit too many ceilings without this degree. For one, I will never make as much as someone with the same level of knowledge and experience, but also has a degree. Also, the amount of effort it took to get a job in the industry without a degree was exhausting and depressing. Now I am wondering what the best way for me to go about getting my degree is?   1. Are there online schools that would offer this degree?   2. Would an online school even be a good choice?   3. Would my knowledge and experience in the industry help me finish schooling faster/cheaper?   4. Have any of you ever found yourself in a similar position? If so, how did you overcome all the barriers put in front of you?   5. Have any of you ever had student loans in default and tried to go back to school later? How did you deal with that and how did it affect you?


Capitalization of hierarchical constants

If constants are structured hierarchically, do the "folders" also need to be capitalized? Take for example a Javascript object that needs to store constants for a video player. Is the convention to capitalize the "folders"?               PLAYER = {      VIDEO: {       WIDTH: 640,       HEIGHT: 480       ENCODING: 'h264'      },      AUDIO: {       BITRATE: 128       ENCODING: 'mp3'      }      };          // usage:     alert('The player's video width is: ' + PLAYER.VIDEO.WIDTH);      Or only capitalize the leaf nodes?               player = {      video: {       WIDTH: 640,         HEIGHT: 480,       ENCODING: 'h264'      },      audio: {       BITRATE: 128,       ENCODING: 'mp3'      }     };          // usage:     alert('The player's video width is: ' + player.video.WIDTH);


What is a programmer's role in error-checking text content?

As a primarily web-based programmer, a lot of my projects involve significant amounts of text content. In my previous job, I frequently worked with a project manager notorious for his unwillingness to proof-read, or to even use basic spell-check software. I regularly corrected the text content he provided for grammar, punctuation, and spelling, as I felt that the website represented both the company and myself, and I was not willing to let his laziness contribute to a negative user experience. However, text content was limited, and was almost exclusively legal disclaimers and technical instructions related to the product. At my current job, we have a much larger emphasis on text content. However, we also have a much higher standard of quality and proof-reading. All printed content from our department uses the AP Stylebook standards, and I believe that standard should be extended to our web-based content as well. I fully expect that my previous problems with low-quality text content, and lack of basic proofreading, will not be repeated here. However, I have gotten into the habit of proofreading every bit of text content I publish. I am considering studying the AP Stylebook to make sure that I know what the expected conventions are. Is this going beyond my responsibility as a programmer? Should I be sticking to only the most basic of errors (e.g. spelling, punctuation, etc.) instead of trying to expand to AP Stylebook conventions? Or should I just leave all proofreading tasks to the people who give me the content to publish?


Environment naming standards in software development?

My project is currently suffering from environment naming issues. Different people have different assumptions as to what environments should be named or what the names designate, and it's causing confusion when discussing them. I've done a bit of research and I haven't found any standards out there. The terms include "Local", "Sand", "Dev", "Test", "User", "QA", "Staging" and "Prod" (plus a few more that different people have asked about) I'm not looking for just opinions, though if there's one out there that "everyone" has I'll take it - I'm trying to find definitions advanced by some sort of authority, even if it's unofficial. Here's the environments we currently use:   1. **Environment on the developer's PC**   2. **Shared Environment where developers directly upload code to self-test**   3. **Shared Environment where standards and functionality are tested by QA people**   4. **Shared Environment where completed and QA-checked code is approved by project requesters**   5. **Environment that mirrors the final environment as a final check and to prepare for deployment**   6. **Final Environment where code is in use** I know what _I'd_ call them, but is there some sort of standard on this? Thanks in advance.


Is this a good use for ThreadPool.QueueUserWorkItem?

I have an application that, among other things, imports documents, then emails necessary parties to let them know that a document has been imported. It turns out that determining whom to email, then performing the emailing, is what's taking the longest. I was thinking of doing something like this:               var document = ImportDocument();     ThreadPool.QueueUserWorkItem(s => SendEmail(document.Id));     return document;      ... similar to DelayedJob in Rails, if that helps. Does that make sense in this context? What would you do?


Is "send us a page with code" a typical interview requirement?

Recently I was asked to show "a page with code" for a job interview. Being mainly a back-end programmer, and that's the position I applied for, I first said to the person I was talking to exactly that: PHP is executed at the server and therefore not visible by just giving a "page". However, following their desire, I sent links to the pages I've worked on before. Obviously they couldn't see anything except for the HTML, CSS, JS... They said it was not enough, they could not see the PHP. Understanding that they probably just wanted to know my skills and/or interest I sent them my Stack Overflow profile. Among all my questions and answers, most of them with code, certainly the PHP is there. But it seems this is not what they wanted. Well, I don't have any code put together that I can simply publish for someone to see. And I would never do it for the code I have deployed, obviously. So my question is/are: What does "send us a page with code" mean? What should I send? Is this a typical interview requirement?


Why to declare a String (as final) and then use it?

In a typical spring mvc validator class, while inserting an errorCode value in the Errors object, what difference does it make between using a String (`props.somefield.req`) like so               errors.rejectValue("elementId", "props.somefield.req");      verses a declared static final String ?               private static final String SOMFIELD_REQ = "props.somefield.req"; ...     errors.rejectValue("elementId", SOMFIELD_REQ);      Does it improve the performance even in a slightest way? I have read a few questions on stack overflow (String and final, Does it make sense to define a final String in Java?) but no one got around to answering this questions update question.


Data retrieval and indexing

I have around 800,000 rows of data stored in the boost shared memory from the database. The data are in the form:               Id        Color        Length          Size          1        1                 2            4     2        3                 4            5     3        2                 2            0     4        1                 2            4......and so on      The Colors can be the value from 1-12 the length 1-4 and the size 1-5. The Id,Length,Color,Size are stored in seperate vector of 800,000 size in the shared memory. So there is Id vector for Id, Color vector for Color and so on. I want to filter the data before I perform some computation. So I want data for which Color is 1 and length is 2 and Size 4 i.e row 1 and 4 in above case. Is there any efficient way to filter the data without using for loop and going through all the 800,000 images and checking the condition? Right now I am just using mysql statement to get the Ids of the data which satisify the condition.               "select Id from features_table where Color=1 and Length=2 and Size =4"      But is there a faster way to do this? Or should I stick to this method? I am looking for a faster method so I am not sure whether fetching the Ids from the database will increase the execution time of the algorithm. What are the other options that I can consider in this case? I read about Hash table, B-Tree, Binary Search tree and I am confused which is suitable for this case. Will kd-tree be helpful in this case? Because many images may have the same combination of color,length and size. I am not sure if kd-tree is the right thing to do. I read about FLANN in opencv used for kd-tree. Is there any example or resources which may be helpful in this case? Or are there any built in c++ libraries?


Searching in a large dataset

I am working on a model of social interactions in mice. I have mice and boxes and a simulation that outputs which mouse stays in which box during which time period. The problem is how to obtain, in the end and from this, the meetings of two mice which were in the same box in an overlapping period. Right now I have a MySQL database where the simulation directly inserts each stay result. And then another tool,written in Scala, just retrieves all stay result, in portions of a few hundred, loops through them and for each asks the database which stays were overlapping with it, and inserts each pair into the database, like this: `box`,`id1`, `res_id1`, `id2`, `res_id2`, `from`, `to`, `dt`, `typ` This means that mice id1 and id2 were in the box "box" in the interval between "from" and "to" with duration "dt" and the meetings was of type "typ". There could be four types of meetings depending on when each mouse was in the box (e.g. when the one entered and exited relative to the other). "res_id1" and "res_id2" tell which stay results were used to generate the meeting result. Obviously, this is very inefficient. What would be a better way of doing it? I am not constrained to using a RDMS, but I though this would be the easiest as I am reading and further analysing the data in R afterwards. Would it make sense to output the stays in a text file and then use Hadoop to generate the meetings somehow? Or anything else? For the duration of an approximately one quarter of one trial of the simulation I generate around 1.5 million stay results.


How do you explain NP-Completeness/Unsolvability to a non-technical supervisor?

You fix problems. You can do the _impossible_. Co-workers come to you with a wide range of questions and problems they want you to solve; which can usually be done with some simple custom program or script. Most things are fairly simple, and they are amazed at how you can take ten minutes of your time to write a little script that saves them hundreds of hours of work in a given year. People come to you with a problem and, having seen your past work, expect that you'll be able to take care of even the _impossible_ in short order. But every now and again, the problem they want you to solve is one of those ones that give programmers a headache - they're NP-Complete or otherwise computationally unsolvable. It could be an automated scheduling program, warehouse packing sorter, a system that predicts the company's stock price three years in advance, what have you. If you tell them it's **impossible** , it sounds like you're just trying to get out of doing the work, or they think that **impossible** means _impossible_ (as in "kind of hard, but I could do it in a few hours"). Likewise, you can't just point them to the CS theory section of your bookcase and tell them to read up on it. How do you explain to a non-technical co-worker (or supervisor) that some task they want you to complete is literally **impossible** not merely the same-old _impossible_ that you successfully deal with every day? _[Note: Offering a compromise (i.e. offering a near-optimal, not perfectly optimal, solution) or giving them what they really need, not what they think they want, is generally what I end up doing; but my question is about explaining why what they are precisely asking for isn't feasible without resorting to using highly technical terms, hand-waving, or "losing" that help ticket.]_


Pros/Cons for getter and setters of collections

I'm creating a model where one element can contain other elements. I'm currently writing the interface to the model, and I'm not sure which is the best of the two options: **Option 1**               interface Container {       List<Element> getElements(); // returns an unmodifiable list.       void addElement(Element e);       void removeElement(Element e);     }      **Option 2**               interface Container {       List<Element> getElements(); // returns an unmodifiable list.       void setElements(List<Element> elements);     }      What are the pros/cons of each option? Furthermore, are there "accepted" naming conventions in these cases, like using `children` instead of `elements`?


What's a good developer workflow for teams? (VM based)

I normally work by myself as a freelancer, and the setup I use has worked pretty well for me so far. I'm not sure if it's the optimal setup for a team though. I develop on Windows, and I setup a Linux VM on my local machine, running the same OS/stack as our production machines (CentOS, Nginx, PHP-FPM). I setup Samba, and map my webroot to a drive in Windows. Locally, I setup host shortcuts such as `http://someproject.local/`. To share with the team, I use my IP address or an internal DNS name such as `http://brandon/someproject`. I was thinking a possible change to this workflow would be to move the VMs onto one of our internal virtualization servers. One of the sysadmins could spin up a new one based on a VM image and that way all devs are using the same setup. Also means everything is backed up properly. Another one I've read about would be a single dev VM, where each dev gets a folder full of projects they map to their local drive, and any other dev could see the project by going to `http://thedevbox/developer_name/project_name`. I dislike this approach though, as I would not be able to play around with the server stack if I wanted/needed too. What setups to you use at your job?


Which iOS developer account should I sign up for

I am currently working on an app for a local hospital. The hospital wants a rough version of my app to test on their employees before committing to full application development. I am currently enrolled in the iOS developer program but I don't know if I can use this account to push a rough draft to about 40 different devices, I'm afraid the app may get rejected. I have no experience with the enterprise program and I don't want to spend an additional $300 unless its absolutely necessary.


Manage query strings in JDBC methods

I am trying to find out which is the best practice when organising the `PreparedStatement` strings in a application which uses JDBC to connect to the database. Usually this is the way I retrieve the data from the database:               PreparedStatement select = null;     String prepQuery = "SELECT * FROM user JOIN details ON user.id = details.user_id WHERE details.email = ? AND details.password = ?";     select = con.prepareStatement(prepQuery);     select.setString(1, email);     select.setString(2, pass);     ResultSet result = select.executeQuery();     // Handle the result.      This is a method which retrieves a user entity using the email and a password. For all my methods this is how I save the query strings. The first drawback which comes to mind is that this is quite messy and difficult to manage if I'm changing the SQL provider (Maybe if I would place all the queries in a Constants file would be a better solution). Furthermore JPA offers tools like `@NamedQuery` which is said to improve the performance of the application. Is there a best practice when it comes to organising the query strings in an application using JDBC. Thank you!


When should one consider learning a framework?

I have recently started to learn PHP and while reading through a bunch of different articles and questions posted on Stack Exchange I noticed everyone recommends learning a framework. While I am up for the task and already selected Zend as the framework I will start learning at some point, I have only just scratched the surface when it comes to PHP and from what I know one should have some experience in a language before learning a framework. I want to learn the language the right way since I want to get a job as a PHP developer (I already know HTML, CSS, Javascript). At the moment my knowledge of PHP is limited to it's syntax, OOP, cookies, sessions and form validation. I have also developed a blog which contains a search panel, login system and a forum. What I want to know is how much experience with core PHP should I have before starting to learn Zend? In what parts of PHP should I concentrate my efforts to become a good developer? I remember when I started learning Javascript I didn't pay enought attention to the language itself and went directly to jQuery, something that didn't go very well for me on the long run I don't want to make the same mistake again. I have found a similar question here but it didn't seem to answer my question.


REST partial bad request

I'm implementing a REST method that allows you to post a list of items. If all data is correct I obviously return a 201 and if all data is incorrect a 400. What would be an appropriate response code if some items are correct and others are not?


how to expose certain tables of an internal database on a public site

I have an internal database at my work. At the moment we are using excel to import data, but this is very error prone, so I would like to replace this with some javascript based application which exposes some of the data in lookup tables in dropdown menus, for our customers to fill in, on a public website. So my internal database lives on an internal server not viewable by the public. How should I go about building an application that communicates with the internal database, and only exposes certain tables? Is some middleware like Django, that rather than using an SQL database uses some other way of getting the lookup values (I have a REST interface set up on the main database). (To clarify, I am looking for a server side technology that I can put on a public facing server, that will communicate with the internal server).


What is the best approach for overriding fields in a database?

I have a database that contains projects and each project contains many samples. I want a project level threshold value, to trigger highlighting when a field on the sample is above this threshold. I also want to be able to override the threshold at the individual sample level. So I can see two ways to implement this:   1. keep the threshold field (only) on the sample, and trigger this to get filled in when the project is saved.    2. have both sample and project level threshold fields, and only use the sample field when it is relevant (there seems to be some redundancy with this model, though it more accurately represents the situation)? Are there advantages / problems with either approach?


Does groovy call partial application 'currying'?

Groovy has a concept that it calls 'currying'. Here's an example from their wiki: `def divide = { a, b -> a / b }` `def halver = divide.rcurry(2)` `assert halver(8) == 4` My understanding of what's going on here is that the right hand argument of `divide` is being bound to the value 2. This seems like a form of partial application. The term currying is usually used to mean transforming a function that takes a series of arguments into a function that only takes one argument and returns another function. For example here is the type of the `curry` function in Haskell: `curry :: ((a, b) -> c) -> (a -> (b -> c))` For people who haven't used Haskell `a`, `b` and `c` are all generic parameters. `curry` takes a function with two arguments, and returns a function that takes `a` and returns a function from `b` to `c`. I've added an extra pair of brackets to the type to make this more clear. Have I misunderstood what's going on in the groovy example or is it merely misnamed partial application? Or does it in fact do both: that is to say convert `divide` into a curried function and then partially apply `2` to this new function.


Is it ever too early to learn a new language?

Personal context: I've been learning C++ formally the last 6 months at university. Prior to this I dabbled in JavaScript for a year. Now I am considering learning Python during a month off school. By splitting my focus early in the learning process am I degrading the efficiency of my learning? Should I spend the month off continuing in C++? Or is it never too early to learn a new language?


Is it worth converting a Django project to Rails?

I have a project I shelved a while back- it was essentially a working web app built in django but I stopped working on it to work on something else. I plan on starting it up again in my spare time, but I'm wondering if it's worth converting a django project with about 5kloc to Rails. I'm considering this because I've been told that it'll be easier for other people to work on and easier to work on myself. I don't have any ruby or rails experience: is it worth learning ruby, rails and then converting my django project to Rails? I understand it's a bit of a loaded / language war kind of question but would appreciate any input.


How to learn programming from very basic level to advanced level?

I know many programming languages ,skills and concepts in very basic, such as PHP, Java, Object-oriented technology. Using PHP, I can build a simple website with CRUD, login function. Using Java, I can make an basic swing csv/plain text editor in which user can switch between 2 different views. In term of object-oriented Technology, I clearly understand what encapsulation, inheritance and Polymorphism are I want to know more about programming. Sometimes I "google" some of the topics I am interested at , the more I see on the internet, the more I feel I am a small potato in the world ( indeed I am ). The codings/concepts are difficult to understand. I lacks confidence right now so I am asking this question :( What is the best way to learn programming to advanced level? Just buy a book and read it page to page? Thanks for any helps