Using prefix incremented loops in C#

Back when I started programming in college, a friend encouraged me to use the prefix incrementation operator `++i` instead of the postfix `i++`, citing that there was a slight chance of better performance with no real chance of a downside. I realize this is true in C++, and it's become a general habit that I continue to do. I'm led to believe that it makes little to no difference when used in a loop in C#, regardless of data type. Apparently the ++ operator can't be overridden. Nevertheless, I like the appearance more, and don't see a direct downside to it. It did astonish a coworker just a moment ago though, he made the (fairly logical) assumption that my loop would terminate early as a result. He's a self-taught programmer, and apparently never came across the C++ convention. That made me question whether or not the equivalent behavior of pre- and post- fix increment and decrement operators in loops is well known enough. **Is it acceptable for me to continue using`++i` in looping constructs because of style preference, even though it has no real performance benefit? Or is it likely to cause confusion amongst other programmers?** * * *   * Note: This is assuming the `++i` convention is used consistently throughout all code.


Getting URLs from search results

After 1 months research I basically give up on getting all URL's from a search results programmatically, I looked at Google Search API to find a way to get millions of search results "URL's" to be specific to a text file or something relative but no success, but I am 100% there must be a way or trick of doing it. Real Question : Is there anyway programmatically or manually I can get 1000+ search results (URLs using search query e.g. "Apple" returns million of results on google and I want as much as possible URLs of them results in a text file) Note : Don't care for any specific search engine or programming language or technique or software or just point me to right direction, but yeah I tried it with google API i can't get more then 100 results at all.


Roadblock-confused about structure of program

I'm new to programming, and I'm working in C. I know that this is structured programming but if I use blocks, say for local variables:               {      int i;      for(i=0; i<25; i++){        printf("testing...\n");        }     }      Doesnt this make it kind of object oriented-like? Is this still structured?


Who should train new programmers? Junior or senior programmers?

On my team, we often require the most senior programmers to train/mentor the brand new junior programmers. However, these same senior programmers are the ones who are doing the bulk of the real, important work. I've tried to argue to my manager that it makes sense to have the junior programmers, who are showing a high aptitude, take the new programmers under their wing. First off, it will free up the senior developers to work on more important initiatives (not that mentoring isn't important). Next, it will give the junior programmers a bit of pride in their job that they would be looked to for such a responsibility and they may learn something in teaching. Finally, it will save the company money, as senior developers cost a great deal more than juniors. My boss has failed to be persuaded since this is how it has worked on this team since the beginning of time, apparently. Assuming that the decision has been made that some sort of training/mentoring is mandatory, can anyone provide me with some better arguments or tell me why I am wrong? What does your team do? **We can all agree that seniority does not necessarily denote competence so just assume by "senior programmers" i mean "top programmers".


Can I re-license Academic Free License code under 2-Clause BSD / ITC?

I want to fork a piece of code licensed under the Academic Free License. For the project, it would be preferable to re-license it under the ISC License or the 2-Clause BSD license, which are equivalent. I understand that the AFL grants me things such as limitation of liability, but licensing consistency is much more important to the project, especially since we're talking about just 800 lines of code, a quarter of which I've modified in some way. And it's very important for me to give these changes back to the community, given the fact that this is software relevant to security - I need the public scrutiny that I'll get by creating a public fork. In short: At the top of the file I want to say this, or something like it:               # Licensed under the Academic Free License, version 3     # Copyright (C) 2009 Original Author          # Licensed under the ISC License     # Copyright (C) 2012 Stefano Palazzo     # Copyright (C) 2012 Company      Am I allowed to do this? My research so far indicates that it's not clear whether the AFL is GPL- Compatible, and I can't really understand any of the stuff concerning re- licensing to other permissive licenses. As a stop gap, I would also be okay with re-licensing under the GPL, however: I can find no consensus (though I can find disagreement) on whether this is allowed at all, and I don't want to risk it, of course. * * *   * Wikipedia: ISC License   * Wikipedia: Academic Free License


GPL - what is distribution?

An interesting point came up on another thread about _alleged_ misappropriation of a GPL project. In this case the enterprise software was used by some large companies who essentially took the code, changed the name, removed the GPL notices and used the result. The point was - if the company did this **and** only used the software internally then there isn't any distribution and that's perfectly legal under GPL. Modifications by their own employees for internal use would also be allowed. _So At what point does it become a distribution?_   Presumably if they brought in outside contractors under 'work for hire' their modifications would also be internal and so not a distribution. If they hired an external software outfit to do modifications and those changes were only used internally by the company - would those changes be distributed? Does the GPL apply to the client or to the external developers? If the company then give the result to another department, another business unit, another company? What if the other company is a wholly owned subsidiary? ps. yes I know the _answer_ is ask a lawyer. But all the discussion I have seen over GPL2/GPL3 _distribution_ has been about webservices - not about internal use.


Python Coding standards vs. productivity

I work for a large humanitarian organisation, on a project building software that could help save lives in emergencies by speeding up the distribution of food. Many NGOs desperately need our software and we are weeks behind schedule. One thing that worries me in this project is what I think is an excessive focus on coding standards. We write in python/django and use a version of PEP0008, with various modifications e.g. line lengths can go up to 160 chars and all lines should go that long if possible, no blank lines between imports, line wrapping rules that apply only to certain kinds of classes, lots of templates that we must use, even if they aren't the best way to solve a problem etc. etc. One core dev spent a week rewriting a major part of the system to meet the then new coding standards, throwing away several suites of tests in the process, as the rewrite meant they were 'invalid'. We spent two weeks rewriting all the functionality that was lost, and fixing bugs. He is the lead dev and his word carries weight, so he has convinced the project manager that these standards are necessary. The junior devs do as they are told. I sense that the project manager has a strong feeling of cognitive dissonance about all this but nevertheless agrees with it vehemently as he feels unsure what else to do. Today I got in serious trouble because I had forgotten to put some spaces after commas in a keyword argument. I was literally shouted at by two other devs and the project manager during a Skype call. Personally I think coding standards are important but also think that we are wasting a lot of time obsessing with them, and when I verbalized this it provoked rage. I'm seen as a troublemaker in the team, a team that is looking for scapegoats for its failings. Since the introduction of the coding standards, the team's productivity has measurably plummeted, however this only reinforces the obsession, i.e. the lead dev simply blames our non-adherence to standards for the lack of progress. He believes that we can't read each other's code if we don't adhere to the conventions. This is starting to turn sticky. Now I am trying to modify various scripts, autopep8, pep8ify and PythonTidy to try to match the conventions. We also run pep8 against source code but there are so many implicit amendments to our standard that it's hard to track them all. The lead dev simple picks faults that the pep8 script doesn't pick up and shouts at us in the next stand-up meeting. Every week there are new additions to the coding standards that force us to rewrite existing, working, tested code. Thank heavens we still have tests, (I reverted some commits and fixed a bunch of the ones he removed). All the while there is increasing pressure to meet the deadline. I believe a fundamental issue is that the lead dev and another core dev refuse to trust other developers to do their job. But how to deal with that? We can't do our job because we are too busy rewriting everything. I've never encountered this dynamic in a software engineering team. Am I wrong to question their adherence to coding standards? Has anyone else experienced a similar situation and how have they dealt with it successfully? (I'm not looking for a discussion just actual solutions people have found)


How do I Export to excel on aspx page?

I am trying to take data that I request from an access database and put it into and excel file on the client computer. I usually use ajax to request a summary of the data I need. It is formatted into an html table. I need that table to be in an excel format for the user to download. What I have tried already is to use the vb.net code to open excel and silently save the data to a file, however I realized it's the server side that opens excel, not the client side, in my locally testing of the code, excel would open on my machine and create the file. When running this on the network, I realized excel isn't on the server, I am not sure if I should just install it or try stream the file?


Laptops or Notebooks in a meeting?

Is taking the laptop to the meeting a good idea? Of course, the project leader needs to have one -- but the programmers -- especially those who only need to get straight instructions on what to do next on the project -- do they need to take laptops? I feel it takes longer to save notes in a software -- and it's lot easier to just jot down "things to do" in a simple note book. That way you can keep up with the discussion and not lose track of what someone else is saying by spending too much time entering text in the machine.


is Microsoft LC random generator patented?

I need a _very_ simple pseudo random generator (no any specific quality requirements) and I found Microsoft's variant of LCG algorithm used for rand() C runtime library function fit my needs (gcc's one seems too complex). I found the algorithm here: http://rosettacode.org/wiki/Linear_congruential_generator#C However, I worry the algorithm (including its "magic numbers" i.e coefficients) may by patented or restricted for use in some another way. Is it allowed to use this algorithm without any licence or patent restrictions or not? I can't use library rand() because I need my results to be exactly reproducible on different platforms


Rails-API gem, Is there such thing as an API only application?

I've built a few API's using the complete rails stack. In each project there have been multiple uses for rails core features. Each of the API has had management screens for monitoring usage, managing authentication keys, etc. Is there such thing as an API without a management front end?


Why use typedefs for structs?

in C (ANSI, C99, etc.), structs live in their own namespace. A struct for a linked list might look something like this:               struct my_buffer_type {        struct my_buffer_type * next;        struct my_buffer_type * prev;        void * data;     };      It seems quite natural however for most C programmers to automatically typdef those structs like the following               typedef struct tag_buffer_type {        struct my_buffer_type * next;        struct my_buffer_type * prev;        void * data;     } my_buffer_type;      And then reference the struct like a normal type, i.e. `get_next_element(my_buffer_type * ptr)`. Now my question is: Is there a specific reason for this? Wikipedia says http://en.wikipedia.org/wiki/Typedef#Usage_concerns > Some people are opposed to the extensive use of typedefs. Most arguments > center on the idea that typedefs simply hide the actual data type of a > variable. For example, Greg Kroah-Hartman, a Linux kernel hacker and > documenter, discourages their use for anything except function prototype > declarations. He argues that this practice not only unnecessarily obfuscates > code, it can also cause programmers to accidentally misuse large structures > thinking them to be simple types.[4] > > Others argue that the use of typedefs can make code easier to maintain. K&R > states that there are two reasons for using a typedef. First, it provides a > means to make a program more portable. Instead of having to change a type > everywhere it appears throughout the program's source files, only a single > typedef statement needs to be changed. Second, a typedef can make a complex > declaration easier to understand. I personally wonder if there is not enough benefit of having the separate `struct` namespace to sometimes not use typedef'd structs and since there are several C programming cultures around (Windows C programming has different traditions than Linux C programming in my experience) if there are other traditions that I am not aware of. Then I am interested in historical considerations (predecessors, first versions of C).


Why does Javascript use JSON.stringify instead of JSON.serialize?

I'm just wondering about _"stringify"_ vs _"serialize"_. To me they're the same thing (though I could be wrong), but in my past experience (mostly with asp.net) I use `Serialize()` and never use `Stringify()`. I know I can create a simple alias in Javascript,               // either     JSON.serialize = function(input) {         return JSON.stringify(input);     };          // or     JSON.serialize = JSON.stringify;      http://jsfiddle.net/HKKUb/ but I'm just wondering about the difference between the two and why stringify was chosen. * * * for comparison purpose, here's how you serialize XML to a String in C#               public static string SerializeObject<T>(this T toSerialize)     {         XmlSerializer xmlSerializer = new XmlSerializer(toSerialize.GetType());         StringWriter textWriter = new StringWriter();              xmlSerializer.Serialize(textWriter, toSerialize);         return textWriter.ToString();     }


Naming variables with fixed point units

What should I name a variable that has units with a fixed point?               int herpLimitLo_psig2 = 6000; // 60.00 psig     int derpLimitLoPsigwithtwodigits;     int herpLimitHiPsigfixedtwo;     int herpLimitHi_psig_timesOneHundred;      Apparently I suck at naming things.


Use Generic of Specific Function names for similar objects

Is there a school of thought on putting focus on using generic names for functions, opposed to naming functions based on the things they do? **Example** Say we have a `Bill / Price Sheet` object, that has line items               Bill:     * Shipping Charge  $5.00     * Crate Charge $6.00     * Tax Charge $8.00      Generic function names would be:               //function's code knows how to add a line item     bill->addLineItem("Shipping Charge", 5);     bill->addLineItem("Crate Charge", 6);     bill->addLineItem("Tax Charge", 8);      Specific function names would be:               //function's code reflects knowledge of this specific line item     bill->addShippingCharge(5);       bill->addCrateCharge(6);     bill->addTaxCharge(8);      This can be extended to any set of similar actions where something similar is being done. A more generic function takes the actual parameter, and can be deemed more flexible - any new line item can be added using the same function. A more specific function can only be used for that particular line item. Adding a new type of line item requires a new function. Something tells me that the specific way is more preferred, but I can't verbalize why, and maybe I am wrong. But perhaps it makes the code more clear as to what this line item is intended to do. So if specific naming is superior, and I am writing code for a restaurant with 600 items on the menu (such restaurants do exist), I am not sure I want to have 600 unique functions for each menu item. But in that case maybe a different approach is warranted. So what I am asking here, is if I have a reasonable class of items (i.e. 10-20) for my specific possible line item list, would you recommend any particular approach from the ones described (specific vs general), or does it all depend on my project specifics?


Is there a general pattern that could be used to describe Data Migration?

In our company we have to dismiss a software and introduce a new one. I have received the task to follow and take care of the whole data migration.   We use 3 different data sources (each containing different kind of information), whose records have to be merged into a unique target DB. Since the new DB has a different schema also some mapping steps are required to coincile data from the two environments. Technically it is everything clear, but I have to describe in a "proof of concept" the migration process. **About data migration is there a general pattern that could be used to describe it?** I will describe the involved systems, which data will be moved, the mapping tables used and the planned tests to ensure data quality. However can anyone suggest a different approach? Maybe in this way I can realize that I am missing something in my documentation.


Javascript MVC application design (canvas)

I'm having difficulty grasping how to structure/architect a canvas application using an MVC like approach in Javascript. UI will be fairly fluid and animated, the games fairly simplistic but with heavy emphasis on tweening and animation. I get how MVC works in principle but not in practice. I've googled the buggery out of this, read an awful lot, and am now as confused as I was when I started. Some details about the application area:   * multi screen game framework - multiple games will sit within this framework common UI "screens" include: settings, info, choose difficulty, main menu etc.   * multiple input methods   * common UI elements such as top menu bar on some screens   * possibility of using different rendering methods (canvas/DOM/webGL) At the moment I have an AppModel, AppController and AppView. From here I was planning to add each of the "screens" and attach it to the AppView. But what about things like the top menu bar, should they be another MVC triad? Where and how would I attach it without tightly coupling components? Is it an accepted practice to have one MVC triad within another? i.e. can I add each "screen" to the AppView? Is "triad" even an accepted MVC term?! My mind is melting under the options... I feel like I'm missing something fundamental here. I've got a solution already up and running without using an MVC approach, but have ended up with tightly coupled soup - logic and views and currently combined. The idea was to open it up and allow easier change of views (for e.g. swapping out a canvas view with a DOM based view). Current libraries used: require.js, createJS, underscore, GSAP, hand rolled MVC implementation Any pointers, examples etc., particularly with regards to the actual design of the thing and splitting the "screens" into proper M, V or C would be appreciated. ...or a more appropriate method other than MVC _[NB, if you've seen this question before it's because I asked it in 2 other incorrect stackexchange communities... my brain has stopped functioning]_


Jenkins: .NET website XML transforms, but no .sln or build file

We're setting up Jenkins for CI and deployments. We have .NET website that isn't managed through visual studio. Its a Logi Analytics application, so we develop exclusively through LogiStudio. As such, there are no build files (.sln). However, there are web config and other XML files that need to change depending on the environment they are deployed in. Slow Cheetah looks like a good solution for transforming non-web.config xml files, but again the problem is we aren't managing this as a visual studio solution, ergo no .sln file. In the past I would have used NAnt for this kind of thing, but I like the MS convention used by slow cheetah for defining transformations. I'd hate to have to put the application in a solution just to make this work, and I'm hoping to get away from NAnt since I'm the only one around here that is comfortable using and maintaining NAnt scripts. Are there any great options out there that I'm missing?


Mimicking a bluetooth disconnection

I've written a program to control a bluetooth device. I'm trying to test cases when the bluetooth disconnects, i.e. if its out of range. Physically taking the device out of range is one possibility, but its quite cumbersome and I have to go outside my office to achieve this. What can I do to trigger a disconnection? Is there, for example, an interferer I can setup, say with an Android phone, that would make the connection drop? Or limit the Bluetooth transmit power? Any other possibilities?


Why are exception specifications bad?

Back in school some 10+ years ago, they were teaching you to use exception specifiers. Since my background is as one of them Torvaldish C programmers who stubbornly avoids C++ unless forced to, I only end up in C++ sporadically, and when I do I still use exception specifiers since that's what I was taught. However, the majority of C++ programmers seem to frown upon exception specifiers. I have read the debate and the arguments from various C++ gurus, like these. As far as I understand it, it boils down to three things:   1. Exception specifiers use a type system that is inconsistent with the rest of the language ("shadow type system").   2. If your function with an exception specifier throws anything else except what you have specified, the program will get terminated in bad, unexpected ways.   3. Exception specifiers will be removed in the upcoming C++ standard. Am I missing something here or are these all the reasons? My own opinions: Regarding 1): So what. C++ is probably the most inconsistent programming language ever made, syntax-wise. We have the macros, the goto/labels, the horde (hoard?) of undefined-/unspecified-/implementation-defined behavior, the poorly-defined integer types, all the implicit type promotion rules, special- case keywords like friend, auto, register, explicit... And so on. Someone could probably write several thick books of all the weirdness in C/C++. So why are people reacting against this particular inconsistency, which is a minor flaw in comparison to many other far more dangerous features of the language? Regarding 2): Isn't that my own responsibility? There are so many other ways I can write a fatal bug in C++, why is this particular case any worse? Instead of writing `throw(int)` and then throwing Crash_t, I may as well claim that my function returns a pointer to int, then make a wild, explicit typecast and return a pointer to a Crash_t. The spirit of C/C++ has always been to leave most of the responsibility to the programmer. What about advantages then? The most obvious is that if your function tries to explicitly throw any type other than what you specified, the compiler will give you an error. I believe that the standard is clear regarding this(?). Bugs will only happen when your function calls other functions that in turn throw the wrong type. Coming from a world of deterministic, embedded C programs, I would most certainly prefer to know exactly what a function will throw at me. If there is something in the language supporting that, why not use it? The alternatives seem to be:               void func() throw(Egg_t);      and               void func(); // This function throws an Egg_t      I think there is a big chance that the caller ignores/forgets to implement the try-catch in the second case, less so in the first case. As I understand it, if either one of these two forms decides to suddenly throw another kind of exception, the program will crash. In the first case because it isn't allowed to throw another exception, in the second case because nobody expected it to throw a SpanishInquisition_t and therefore that expression isn't caught where it should have been. In case of the latter, to have some last resort catch(...) at the highest level of the program doesn't really seem any better than a program crash: "Hey, somewhere in your program something throwed a strange, unhandled exception.". You can't recover the program once you are that far from where the exception was thrown, the only thing you can do is to exit the program. And from the user's point-of-view they couldn't care less if they get an evil message box from the OS saying "Program terminated. Blablabla at address 0x12345" or an evil message box from your program saying "Unhandled exception: myclass.func.something". The bug is still there. * * * With the upcoming C++ standard I'll have no other option but to abandon exception specifiers. But I would rather hear some solid argument why they are bad, rather than "His Holiness has stated it and thus it is so". Perhaps there are more arguments against them than the ones I listed, or perhaps there is more to them than I realize?


Function declaration as var instead of function

More and more I'm seeing functions being declared like               var foo = function() {              // things     };      Instead of how I had learned, like               function foo() {              // things     }      What's the difference? Better performance? Scope? Should I be using this method?


Handling internal IT issues

In the company I work at, developers also serve as internal tech support. This means we have to do three types of things:   * **Development:** writing actual code to implement new features and new products   * **Maintenance:** handle bugs and minor changes with existing customer-facing software   * **Tech support:** handle internal issues other employees have e.g. locked out of AD, network drive is missing, internet is down, new software installation, need permissions changes, etc. The tech support aspect of my job is the most troubling right now. This is because:   * someone with a problem will likely interrupt you immediately, taking you away from development   * problems come in too many ways: email, google chat, phone call, post-it notes on your desk, etc.   * people often cannot or do not determine the severity or scope of their problem before asking for help, i.e. simple problems that inconvenience one person might come in the same way -- and often with the same urgency -- as major customer-facing issues that could affect thousands **My question is: What are the proven methods for dealing with internal IT issues?** Should we use software designed for this purpose? If so, how should it be separated from any software used for customer-facing issues or bug tracking software? How can the IT/development department ensure it's used properly? Also, is it a problem that developers handle these internal problems in the first place? Would it be ideal to have a separate person or department to handle these types of problems?


Sequel vs S-Q-L

> **Possible Duplicate:**   >  What's the history of the non-official pronunciation of SQL? I hear it every so often, "In sequel server...", and for some reason I cringe every time. Maybe it's because SQL doesn't mean sequel, it means Structured Query Language. However, I hesitate to mention anything because it is a little bit nitpicking after all. I do see the resemblance between SQL and sequel, but it's still wrong, is it not? Where does this way of phrasing come from?


PHP function __autoload($class_name) how to Load two class path directories

I am using following function to autoload classes, it works fine if i am using only one directory called 'classes' however when i try to use Smarty lib also it fails and give me the error               Fatal error: Class 'Database' not found in /home/...      for ex:               require_once(DOC_ROOT."/libs/Smarty.class.php");     function __autoload($class_name) {            require_once( CLASS_LIB."/".$class_name . '.class.php');     }     $db = new Database();     $session=new Session();     $smarty = new Smarty();      but if i do this it give me the error unable to load the smarty class..               function __autoload($class_name) {            require_once( CLASS_LIB."/".$class_name . '.class.php');         require_once(DOC_ROOT."/libs/Smarty.class.php");     }          $db = new Database();     $session=new Session();     $smarty = new Smarty();          Warning: require_once(/home/.../classes/Smarty_Internal_TemplateCompilerBase.class.php) [function.require-once]: failed to open stream: No such file or directory in /home/.../includes/init.php       Any idea what i am i doing wrong here ? i need to be able to load classes directory automatically but needs to make sure i dont loose smarty path too..


How to validate information on server without using database or session

Each user has multiple sites they can access reporting data for in an application I am working on. To prevent having to go to the database on every single request, I validate that they have access to the site only when they change sites and I then store the the current site id in the session. **I am trying to eliminate session state so that my async ajax requests are not synchronized and also so that the user can have a different site open on each browser tab. I also don't want to go back to calling the database on every request to validate that the user has access to the given site making a request.** I've seen implementations where people will encrypt the id on the client, but it's not sure what would prevent a third party from looking over someone's shoulder (seeing the id on the query string perhaps) then using that same id with their own login to make a request. **I have two ideas:** 1) Encrypt the id with the persons authenticated user name as the seed... Then encrypt it again with some private key. When the request comes in I would decrypt with the private key then try to decrypt with the current user name and get the id back. Or perhaps I would combine the user name with the id like username@username.com_[SITEID] then encrypt that with the private key and split them to see if the current username matches the first part. The problem with this though is that it never expires really, so they could in the future make a request even if they have lost access as long as they have the id around. 2) Similar to idea 1, but I would use the session id with encryption as a third key perhaps. The problem here though is if the session expires and they leave a tab open, all the requests would fail from the tab that was left open even though a session is active. 3) Use a cache so that async requests are not affected and just store keys like username@username.com_[VALIDATED_SITE_ID] then see if the key exists when the request comes in and if not, hit the database to establish the validation key. **Has anyone addressed this type of scenario where you need to validate the user can make a specific type of request, yet you doing it without session or hitting the database every time a request is made?**


What's in the "contrib" folder?

Often open-source software projects have a folder called "contrib". For example, Django has one. What is it for?


Where should you put functions and variables that are only needed by one function in a class?

Say you have a Car class. Properties that make sense for a Car class might be:               var make;     var model;     var year;     var turnOn; // a function      But the `turnOn` function is very complicated and ends up needing a static variable and a couple sub functions:               var isTurningOn; // too specific to be a class variable     function turnOn() {         // 30 lines to start the engine         // 30 lines to start the air conditioner         // 30 lines to start the radio     }      So now we have a function that maybe isn't really suitable to be made into its own class and it's polluting the Car class with a variable that only the `turnOn` function ever uses. Plus the function contains sections of code that should be made into their own functions. So what do you do in situations like this?


What is the proper way to implement the OnClickListener interface for many buttons

My Android Activity contains multiple buttons that all need an OnClickListener. I've seen lots of different ways of doing this such as::   * Implementing the interface in activity class   * Creating a separate class that implements the interface   * Defining an anonymous inner class for each button. I've seen many examples of each approach. However, its not clear to me why one approach would be used instead of another. Are the differences between these approaches stylistic or are there reasons that make one approach better?


How do mashups work with same-orgin policy?

If Javascript is only allowed to access scripts from the same domain, how can a website create mashups which must read and modify content from another domain?


How can I design an efficient moderation system for comments?

Here's the job I want to do: My project is a website where there will be a **lot** of comments. Those comments will be moderated: a moderator will connect, see comments and accept or refuse them. I need those things:   * the comments won't have any "moderator" associated. Which implies that when a moderator connects, the system "assigns" the 20 first comments to this moderator then sends them via an AJAX/JSON request   * of course, this implies that those comments musn't be assigned to other moderators How can I make a design so that I'll be sure "getting the 20 first comments for a moderator" can be an atomic operation? And there's another thing to think of (I don't know if it may have an impact or not on my problem): if there are say 10 moderators connected, one of them has 20 comments to validate, and this guy leaves his PC for the whole day. I may implement kindof a "timeout" for this moderator, then, when he tries to validate, a message will tell him "sorry this comment has already been moderated by another moderator", and the AJAX script will get a "fresh new 20 comments). My first idea was the simplest idea:   * a moderator connects   * a jQuery AJAX script asks the server for 20 comments   * the server (1) makes immediately a request of the 20 first free comments to the database   * the server (2) "freezes" the 20 free comments   * the server (3) makes up a JSON response and sends it But the operations (2) and (3) are not atomic, what happens if, in-between, another operator asks for the 20 first free comments? They both will get the 20 first free comments. That's not a good solution. I think this is a classical problem of atomic operation on db. Any idea how to design this (or where to look)? Thank you very much indeed!


How to gradually improve on an old IBM Host C++ framework

Imagine a C++ framework as a business layer, but with controlling logic as well. E.g. user rights, state of the webflow etc. With some plain C code to access DB2. The whole framework is host based. We are looking for a way to replace the existing framework gradually with a java framework. The main challenges are: the application is already huge, there are several application clients connected to the c++ framework at the same time (it's one web application with many instances), my knowledge of what is possible today with java on host is very limited (since all people I work with stick with C++) Do some good ideas exist for gradually moving the old framework without breaking existing code? I guess as entry one would expect a web service or RMI server for transactions. But how to replace the business/controlling logic gradually is still a black box to me.


i am "scared" to learn a new language

I have be developing in c# for the last about the last 8 years.   I feel that i am quite experienced and knowledgeable in the whole .net platform. I have got to the point where i want to start learning objective-c. I have been watching dev videos, reading books and researching online. So far i am getting a good idea of the development principals. BUT. I have not written 1 line of code. For some silly reason i have some type of mental block about writing code. I keep thinking: But what if i am not as good as when i do c# coding.   This leaves me in a endless spiral where i cannot code. If you have been in this kind of situation what was the best way to get out of it.


What does the term day-one-bug mean?

I came across this term recently in a mail chain. Google tells me there is a term zero-day bug and that Microsoft and Adobe are the frontrunners :) Is there such a term as **day one bug**? What might that mean?


I am programming in Windows Forms and MySQL. If I declare this in the program, I can use the connection and command objects in the whole .cs page:                MySqlConnection connection = null;      MySqlCommand command = null;      MySqlDataReader Reader;      But if I write the code below, connection and command objects are declared twice:                private void cmbo_class_SelectedValueChanged(object sender, EventArgs e)             {                 string clas = cmbo_class.SelectedItem.ToString();                                  try                 {                     MySqlConnection connection = new MySqlConnection(hp.myConnStr);                     MySqlCommand command = connection.CreateCommand();                     MySqlDataReader Reader;                     command.CommandText = "select id,code from reg_class_master where name ='" + clas + "' and Delete_Status=0";                     connection.Open();                     Reader = command.ExecuteReader();                     while (Reader.Read())                     {                         class_id = Convert.ToInt32(Reader[0].ToString());                         class_code = Reader[1].ToString();                     }                     connection.Close();                 }                 catch(Exception ex)                 {                     MessageBox.Show("Error in ","Information",MessageBoxButtons.OK,MessageBoxIcon.Information);                 }                      cmbo_division.Items.Clear();                      try                 {                     MySqlConnection connection = new MySqlConnection(hp.myConnStr);                     MySqlCommand command = connection.CreateCommand();                     MySqlDataReader Reader;                     command.CommandText = "select name from reg_division_master where class_id = " + class_id + " and Delete_Status=0 order by display_index";                     connection.Open();                     Reader = command.ExecuteReader();                     while (Reader.Read())                     {                         cmbo_division.Items.Add(Reader[0].ToString());                     }                     connection.Close();                 }                 catch                 {                 }      I think one object declaration is the best way. Do more object declarations affect the program?


Does having more classes necessarily increase the memory requirements of the app?

When we add .edmx files to a DLL, the physical size of the DLL increases. DLL's are loaded into memory. However, the .NET infrastructure with functionality such as JIT compilation and the GAC complicates things. Is it true that having a larger DLL automatically increase the memory requirements of an application? In other words, are memory concerns a good reason to split generated code such as entity framework into N DLL's?


Am I misusing instance initialization?

I often write tests when I need to set data object for integration tests involving a few pages with forms. Herein each form on a page could be represented by a different data object class. There are are times when test end up in filling same data for a specific page while varying it for other pages and validating the overall flow. I thought instead of setting data object each time from test method I can take advantage of instance initialization block to set data for tests. Herein I have listed a smaller version of tests I usually write - This my data class which holds data for form values - textbox, drop down etc. I have not kept setters for sake of brevity -               public class DataClass {          private int i;     private int j;          public DataClass() {         i=1;         j=1;     }             public int getI(){         return i;     }          public int getJ(){         return j;     }     }      Following is the helper class which is used by test class to fill form data on page -               public class WorkerClass {          private DataClass data;          public void setData(DataClass data){         this.data = data;            }          public int add() {         return data.getI()+data.getJ();     }          public int substract() {         return data.getI()-data.getJ();     }     }      And here is the test method. Notice that instead of calling setData of WorkerClass in each test method I used instance initialization block -               public class TestClass {          private DataClass data = new DataClass();     WorkerClass workerClass = new WorkerClass();          {         workerClass.setData(data);     }          @Test     public void testAddition() {         assert workerClass.add()==0:"addition Failed";          }          @Test     public void testSubstraction() {         assert workerClass.substract()==0:"substraction failed";             }        }      My question is, am I misusing instance initialization block and should rather be calling it from each test method, even if all the test method require same set of data?


Is it worth listing testing or self-learning repositories on my résumé?

I have a GitHub repository with toy programs that I write when I learn something. For example, when I read an about an algorithms or data structures, I write up a quick implementation of of it to make sure that it works and I understand it. I sometimes solve algorithm and data structure puzzles and that gets pushed into the repository. Would this repository be worth linking on my résumé, or would it actually be a detriment to my chances of getting hired?


What is the biggest weakness of students graduating with degrees in Computer Science?

This question is directed more toward employers and graduate student advisors/professors but all opinions are welcome. What do you find is a common weakness of new hires and/or new grad students? Is it entirely variable dependent on the student and his or her university? Is there a particular skill or skillset that you wish new hires/researchers had expertise in and how can we remedey this deficiency? I realize that this question is general and really encapsulates two questions, one more about the weaknesses of new software engineers and one about the weaknesses of new researchers. However, both types of people tend to come from similar courses of study so I'm wondering if there is any overlap. Note: I am not a professor but I'm interested in how best to revise the undergraduate curriculum in CS.


How can I gauge a candidate's ability to learn in an interview?

We are hiring for a small development department within a medium sized company for which software is not the main line of business. As such, we are attempting to recruit what we have labeled a _Senior Programmer_. The goal is to find someone that can design, implement and maintain entire new and existing systems from the database through to the front-end. Regardless of a candidates claim to experience (read: massively spun CVs), or the results of the technical test, what I really care about is their ability to learn and the speed at which they will pick up technologies or concepts they are not familiar with to fill any gaps they might have in their knowledge. How can I go about getting an idea as to a candidates ability to (or speed of) learning?


How is Python used in the real world?

I'm looking to get a job as a Python programmer. I know the basics of the language and have created a few games with it using pygame. I've also started to experiment with Django. However, looking at the job market, it doesn't seem very many Python jobs are web-related. On the desktop side of things, it doesn't seem like very many companies use the popular GUI libraries like pyQt or wxPython. How are companies actually using Python? What areas should one focus on to land a job as a Python programmer?


What scenarios are implementations of Object Management Group (OMG) Data Distribution Service best suited for?

I've always been a big fan of asynchronous messaging and pub/sub implementations, but coming from a Java background, I'm most familiar with using JMS based messaging systems, such as JBoss MQ, HornetQ, ActiveMQ, OpenMQ, etc. I've also loosely followed the discussion of AMQP. But I recently became aware of the Data Distribution Service Specification from the Object Management Group, and found there are a couple of open-source implementations: OpenSplice OpenDDS It sounds like this stuff is focused on the kind of high-volume scenarios one tends to associate with financial trading exchanges and what-not. My current interest is more along the lines of notifications related to activity stream processing (think Twitter / Facebook) and am wondering if the DDS servers are worth looking into further. Could anyone who has practical experience with this technology, and/or a deep understanding of it, comment on how useful it is, and what scenarios it is best suited for? How does it stack up against more "traditional" JMS servers, and/or AMQP (or even STOMP or OpenWire, etc?) Edit: FWIW, I found some information at this StackOverflow thread. Not a complete answer, but anybody else finding this question might also find that thread useful, hence the added link.


Use null object as argument to method

Consider the following piece of code               class Foo         {         public:         //...             bool valueFirstGet(int& value) const                 {                 if(this==nullptr)                     {return 0;}                 value=values[0];                 return 1;                 }         //...              private:             int* values;             size_t n_values;         };          int main()         {         Foo* obj=findObject("key");         int value;         if(!obj->valueFirstGet(value))             {printf("key does not exist\n");}              return 0;         }      findObject returns nullptr if it cannot find the object. Is it ok to let the member function do the null check instead of its caller. In my code, there are several calls to findObject directly followed by a call to valueFirstGet so leaving the check to the caller makes the code ugly. EDIT: Is there a cleaner way to avoid all null checking besides having findObject to throw an exception instead of returning null? EDIT 2: What about a static wrapper?


Best Method of function parameter validation

I've been dabbling with the idea of creating my own CMS for the experience and because it would be fun to run my website off my own code base. One of the decisions I keep coming back to is how best to validate incoming parameters for functions. This is mostly in reference to simple data types since object validation would be quite a bit more complex. At first I debated creating a naming convention that would contain information about what the parameters should be, (int, string, bool, etc) then I also figured I could create options to validate against. But then in every function I still need to run some sort of parameter validation that parses the parameter name to determine what the value can be then validate against it, granted this would be handled by passing the list of parameters to function but that still needs to happen and one of my goals is to remove the parameter validation from the function itself so that you can only have the actual function code that accomplishes the intended task without the additional code for validation. Is there any good way of handling this, or is it so low level that typically parameter validation is just done at the start of the function call anyway, so I should stick with doing that.


What is the best way to understand code in a project with null documentation?

It is our first game and we are a start-up. We had a programmer who suddenly is seeming to be a dead weight. Though we knew him personally we thought that he was as motivated as we are and hence I never looked for a code review or documentation. Now it seems that he is slacking a lot and we want him out. Now during a conversation he said that he would not document the code so as we could be dependent on him. I looked at the code and there is no documentation. The code is all over the place. What would be the best way to understand his code? Details of the code:   * Written in C# and targeting a mobile platform using Unity3D.   * The game play mechanic and camera is scripts are the main and they have no documentation.   * Too much of Send/Broadcast messages so I am not able to see the references through Mono.   * Again hefty use of strings in either invoking methods or passing parameters   * Update function everywhere which could have been reduced to coroutines.   * Naming is poor and inconsistet    * Absolutely no pooling with usage of destroy and instantiation. I am expecting memory leaks. What protocols should I adopt to understand the code and work on top it?


Why are brackets required for try-catch?

In various languages (Java at least, think also C#?) you can do things like               if( condition )         singleStatement;          while( condition )         singleStatement;          for( var; condition; increment )         singleStatement;      So when I have just one statement, I don't need to add a new scope with `{ }`. Why can't I do this with try-catch?               try         singleStatement;     catch(Exception e)         singleStatement;      Is there something special about try-catch which requires always having a new scope or something? And if so, couldn't the compiler fix that?


Get system info from C program?

I'm writing a little program in C that I want to use to output some system stats to my HD44780 16x2 character display. The system I'll be working with is a Debian ARM system and, although irrelevant, the display is on the GPIO header.(The system is a Raspberry Pi). As an initial (somewhat unambitious) attempt, I'd like to start with something simple like RAM and CPU usage (I'm new to C). I understand that if I make external command calls I need to fork() and execve() (or some equiv that will let me return the results), what I would like to know is how I go about getting the information I want in a nice clean format that I can use. Surely I will not have to call (for e.g);               free -h      And then use awk or similar to chop out the piece I want? There must be a cleaner way? The question should be seen as more of a generic, what is best practice for getting info about the system in C (the RAM/CPU usage are just an initial example).


Asp.Net MVC CMS or Shopping Cart or any other type of System

I have been learning Asp.Net MVC for a while now and have gone through numerous tutorial ranging from MVC Music Store to Code-First to Custom Membership to Data Annotations. In essence, I have a firm grip on how things work in this new framework. But, there are few things which i am not able to realize and understand on my own. Stuffs like achieving pagination, product Catalog, AJAX and some other things. Therefore i was thinking of learning and knowing these aspects via any opensource CMS, shopping cart or any other type of system. This way I can see the code and understand how these things can be achieved in Asp.Net MVC. Things were pretty easier in regular Asp.Net as we weren't dealing with the HTML so i am bit sluggish in these departments and need help in small matters like pagination. **So, Are there any available opensource Asp.Net MVC CMS or any other type of system utilizing razor ?**


Multiple threads and single output source

For the sake of an exercise, say you have an input file with a series of lines of text with the objective of reversing their respective character sequences. Now introduce 5 threads that will each do the reversing, thread 1 taking care of line 1, thread 2 taking care of line 2 and so on. If the aim is to save these reversed lines in order, how would you save them to the same file ? P.S: I've thought of having some kind of queue but there is no guarantee on the order. Also, I'm wondering if there's some way to lock the file temporarily and have a thread wait it's turn. I imagine I should keep track of which line is being saved.


Abstracting a zip as a filesystem - C++

I would like to access in read and write mode to a zip without decompressing it on disk: what options do I have? I need to perform the usual IO actions reserved for a filesystem like reading, writing new file, deleting them. If it's possible I would like to stick with the zlib library.


How to read and understand ER diagrams

I've been handed the ER diagram for a quite complex database. Complex to me at least, 849 tables. One of the architects says to understand the code, you need to understand the database and relationships. Now I am basically a Java programmer hence not too familiar with this How do I start? Should I start from something basic like USER or ORDER and see which relationships they have with other tables around them? Any tips or tutorials would help a lot


What would you define as sensitive user data?

A recent previous question of mine had an answer that sparked a different and unrelated question in my mind: Customer wants to modify the .properties files packaged in our WAR file The question that I thought of after reading this answer is, just how low-risk is the data being collected on people (non-users, lets just say, "people") in my application?   * A first name and last name   * Company or organization that person currently is employed at.   * (Optional) An email address   * (Optional) A persons phone number   * A photograph of the persons face   * An digitally signed PDF document physically signed with electronic signature pad (a persons hand written signature) No other sensitive data like social security numbers, credit card numbers or anything that can accurately identify a person with 100% accuracy. How sensitive would you rate the data types listed above? Is identity theft even remotely possible with the above information? In light of all the recent news outbreaks of hacking successes and data breaches, if such a thing were to happen to my application (assume that I have reasonable security measures, SSL, encrypted passwords with salt, account lock after so many failed attempts, etc...), what kind of a response would be appropriate for my organization in your opinion? Should every attempt be made to notify the persons that this information has been compromised? Is it worth it? Thanks for sharing your thoughts.


Is it worth it to translate an Android app into Spanish and other languages?

I have the "user's side" of the story, I think they want it better if it's on Spanish. But, what about the programmers? Do you make your programs multi- language? Why? Why not? Who translate your software? Are you ok with paying somebody to translate your app or you prefer doing it yourselves? Is the benefit bigger than the costs?


Area calculation of irregular shapes

Is there any algo that can help splitting irregular shape into regular shapes, and eventually calculate the area of the main object by summing the areas of those regular objects?


Does a group of Select Statements count as a valid model?

I'm making a facebook app and I'm trying to follow MVC properly. But I was wondering if I had a class that was a bunch of fql queries (getting data from facebook) should I have keep these in a controller or a model? According to Codeigniter's user guide "Models are PHP classes that are designed to work with information in your database". Since fql interacts with facebook's databases and not my own, would having a class full of what is basically just SQL Select statements count as valid model?


what is best way to learn latest technology

We have too many technologies in IT world today. How can be best be able to clear technical funda conceptually ? How do we able to find all the concept available within technology & required to be learnt ? Programming Experince always matters, but I want to know the ideas keeping experince aside. I mean like if I start developing a project on my own hand, how do I be able to find out about which latest technology & concepts tha I should use with ? Please suggest.


What problems can be solved using Generics?

I haven't used Generics in C# for a long while. Every time I think I need to use them I either go in the wrong direction and give up or find that I don't really need them. I feel that I'm missing out or ignoring a technique which could be useful and powerful. I'm aware of how generics are meant to be used (or at least I think I am). If you have three methods that are all doing the same thing with different types, then using generics enables you to have just one method that will work with these three types. EDIT (in response to comment) **Are there any code smells or patterns that I should be looking out for?** Note I use `List<>` a lot, so I'm not ignoring generics in the the standard library. It's just that I've not written custom code using Generics for a while.


Audit trails and recording actions

**Background** A discussion that has come up at work recently is how we handle audit logging and the recording of events. We are integrating with a 3rd party app so triggers are a no no from the off so we are handling it in code. We've written a number of prototype components for handling it but nothing feels right as yet. The main issue being we want to create Facebook style time lines for the users to see what action have happened recently but these don't seem to fit well with how we record audits. My question is how would be best to handle this type of scenario?   * Should we tailor the audit log tables to fit the requirements of the front end?   * Should we have separate tables to handle the "Actions" and have the events and auditing separate   * Should we look to a more message based architecture so this will be more like an Event sourcing type component?  Input from somebody who has done this type of system would be much appreciated.


Want to do some damage control

I applied for a job in a company. The initial conversation went well.They sent me an assignment and asked me to write a web application, and send it in a specified time. It seemed fairly simple. I completed and sent it to them. Now my mind is completely revolving on the code that I wrote, and now I feel that, there was one small requirement which I did not fulfill. Before they give the verdict shall I be proactive and admit it. Definitely they will find it and I am certain of it. I can send them email saying that I forgot to add that. What shall I do? Is there anything I do for damage control?


For Which Kind of Cache will this Program not run well? How can it be optimized?

Consider the following code fragment:               int a[8192], b[8192], c[8192];     int i;     for(i = 0; i < 8192; i++)         c[i] = a[i] + b[i];      For what kind of cache will this program not run well (set associative, direct, associative)? I've been thinking about how to optimize this, but can't really see how it can be done. How can I change this code to have fewer cache misses?


Correct terminology in type theory: types, type constructors, kinds/sorts and values

In an answer to a previous question, a small debate started about correct terminology for certain constructs. As I did not find a question (other than this or that, which is not quite the right thing) to address this clearly, I am making this new one. The questionable terms and their relationships are: _type, type constructor, type parameter, kinds or sorts, and values_. I also checked wikipedia for type theory, but that didn't clarify it much either. So for the sake of having a good reference answer and to check my own understanding:   * How are these things defined properly?   * What is the difference between each of these things?   * How are they related to each other?


How and when do you scale Azure instances?

When dealing with Azure instances that are under-performing, how do you decide when to scale the instances? Do you scale horizontally by adding more instances or vertically by making the existing instances more powerful?


Function that modifies an argument, should I return the modified object?

We have a function that modifies a JS object, by adding some custom properties to it. The function doesn't return antyhing               addTransaction: function (obj) {          obj.transactionId = this.getTransactionId;          obj.id = this.recordId;     },      Somebody said they preferred that `addTransaction` return the `obj`. Here's what I thought   * If I don't return anything (and document that the object is going to be modified), it's kind of clear that the object is going to be modified, as if the name were addTransactionToObj   * If I do want to add a return value, I shouldn't modify the incoming object, I should clone the given object, add my properties to the clone and return the clone.   * Having a return value that just returns one of the (modified) parameter just sounds wrong Does anybody have a preference in this matter?


Naming classes, methods, functions and variables

There are 3 important naming conventions:   1. `with_underscores`   2. `PascalCased`   3. `camelCased` Other variants are not important because they are not commonly used. For variables it seems that the one with underscores is the most used by developers so I'll stick with that. I think it's the same for functions. But what about class, and method names? Which of these 3 is the most used by developers for such constructs? (personally, it's 3. for methods and 2. for classes) Please do not post things like "use what you feel is right", because the code I'm writing is API for other developers, and I'd like to adopt the most popular coding style :)


ASP.Net MVC ambigious action methods - why the path choosen

Is there someone who could shed a light on why ambiguous methods are not allowed in ASP.Net MVC?   I updated my question just to clarify it (using Carson63000 example from his answer), the question itself remains the same. So, lets say we have the following action               /article/list/sport      which calls               public ActionResult List(string category) { }      and want to be able to have the following action as well:               /article/list/sport/20110904      which we would like to call accompanying method               public ActionResult List(string category, DateTime date) { }      Currently the framework throws an `AmbiguousMatchException` since it found two methods called List. That's the only reason for throwing the exception, that more than one method with was found that matches the actions name. After the framework has figured out what method to use and decided that it is not ambigious, it will then try to map the supplied data from the request to the parameters of the method. Why not do this the other way around? First get all applicable methods, and then try to find the best fit by mapping parameters. If ambiguous methods where allowed, I think the following is still possible to do.   Given that `/article/list/sport` uses the route `/{controller}/{action}/{category}` and that `/article/list/sport/20110903` uses the route `/{controller}/{action}/{category}/{date}`   it would then still be possible to map data for url `/article/list/sport?date=20110903` since it will match the route for just category, but can still map the data for method `public ActionResult List(string category, DateTime date) { }`. At the moment I fail to see the reason for not allowing ambiguous methods from a design perspective. The only thing I can think of myself is that it will slow down the framework too much, and therefor the current solution is the more logical one. Or am I missing another point here?


Is it ever OK for a conditional to have side effects?

I'm taking intermediate data structures course as a prereq for entry into the CS MS program at a University everyone in America has heard of. One line of code that was written in class caught my eye: `if (a > 33 | b++ < 54) {...}` This would never pass a code review at my workplace. If you wrote code like this in an interview, you would not be hired. This is not an exaggeration. (In addition to being a conditional with side effects, it's being clever at the expense of clarity.) In fact, I've never seen a conditional with side effects, and Googling doesn't turn up much, either. Another student stayed behind after class to ask about it, too, so I'm not the only one who thought this was weird. But the professor was pretty adamant that this was acceptable code, and that he would write something like that at work. (His FT job is as a Principal SWE at a company you've all heard of.) I cannot imagine a world in which this line of code would ever be acceptable, let alone desirable. Am I wrong? Is this OK? What about the more general case: conditionals with side effects? Are those ever OK?


Where to start in developing a game engine as a web app

I have to create a web application, preferably I would host that on Google App Engine. it is a multiplayer game, So it needs to be interactive. I am only familiar with C/C++ coding, and have started learning python. I have made multiplayer games before too(multi-player and single player) but with no GUI. Someone told me that the webapp interface would have to be written in JavaScript. And the back end could be in python or any other language. Please note, I have no issues in coding up the back-end, the game engine, of thew web app. Just that I do not know what are and how to, etc about web apps. And basically how to integrate the back end code into the web application (which I have to build from scratch) (I would also be writing the back end, so there is complete flexibility as of now) So please show me the light! I have absolutely no clue about where to start! Please tell me where to begin, and what all to read up which can quickly give me some insight into development work! How to go about the GUI. And what all possible language combinations can I use? The easier to use, the better.


Seperable Kernel, MMX/SSE and TCP Transmittal of them?

So I was reading about Java Convolve and someone said that it may be faster than the MMX / SSE implementation. In it one of the comments had a kernal array and said it was seperable.   1. What is a seperable kernel? How is this useful for image processing?   2. What is MMX/SSE? The wikipedia page lists them as instruction sets. Are they specificially designed for image processing?   3. How would you transmit a MMX/SSE format (I assume) data set through TCP? Thanks.


How do you read other's code?

Almost every advanced programmer says that it's very useful to read the code of other professionals. Usually they advice open source. Do you read it or not? If you do, how often and what's the procedure of reading the code? Also, it's a bit difficult for newbies to deal with SVN - a bunches of files. What's the solution?


How to stop a .NET application from being duplicated?

I have created a .net windows form application that I want to restrict from being duplicated. I want this application to be portable, so I would like to allow it to be moved. How would I be able to do this without managing it through a remote server?


Writing jenkins plugin: where is the documentation?

On my current project we're using Jenkins to monitor our builds. Now they want me to write a Jenkins plugin to add some more monitoring parameters. I've taken a look at how the status monitor plugin works, and I can't figure some things out. I've tried to look for documentation for writing a plugin, but that seems to be sorely lacking. (the site only mentions how to generate the base project, and refers to a tutorial that's not that informative) What I'm trying to do is just add some options to each build, add a link, and a monitoring page. Adding to the main page is apparently done by adding the action, but I'm still trying to figure out the rest. And how it all ties in. Does anyone have any pointers, or a place where I can find some decent documentation?


Stuff to read up on pricing applications

I'm about to release an app and I have no idea what would be the ideal pricing point. I'm not sure how pricing high and selling few copies will compare in revenue to pricing low and selling lots of copies in my case. Can somebody point me to books/articles/blog posts/etc that elaborate on the subject, preferably taking into account stuff like competition, number of features, being the first one to the market, research if this kind of app is even needed, etc?


Use switch statements for application flow?

I generally use switch statements to simplify a block of multiple if statements - for example - returning a feedback string to a user based on a multiple choice input. I also tend to construct classes so that there is one "management" method, to avoid sequential steps or chained method invocation within other methods of the class. I've found this helps to keep methods flexible and focussed - i.e.               class MyClass{              // this method does nothing more than invoke the relevant method         // depending on the status following the previous. It's entire purpose         // is to control application flow         public function manageFlow($input){             $status = $this->stepOne($input);             if($status == false){                 //exit routine             }                  $status = $this->stepTwo($input);             if($status == false){                 //exit routine            }         }              // this method has several sequential steps implemented direcly within it,          // for example to a user logging in         // it makes it impossible to re-use any of the intermediary steps         public function tangledFlow($input){              if($input == 'something){              //100 lines of code              }              //then handing on to the next bit              if($this->User->Authenticated){              //another 100 lines...              }         }     }      Then it occurred to me that I could use a switch statement to control this kind of sequential execution - so my question is: has anyone used a switch statement for this kind of flow control?


Object-Oriented Operating System

As I thought about writing an operating system, I came across a point that I really couldn't figure out on my own: Can an operating system truly be written in an Object-Oriented Programming (OOP) Language? Being that these types of languages do not allow for direct accessing of memory, wouldn't this make it impossible for a developer to write an entire operating system using only an OOP Language? Take, for example, the Android Operating System that runs many phones and some tablets in use around the world. I believe that this operating system uses only Java, an Object-Oriented language. In Java, I have been unsuccessful in trying to point at and manipulate a specific memory address that the run-time environment (JRE) has not assigned to my program implicitly. In C, C++, and other non-OOP languages, I can do this in a few lines. So this makes me question whether or not an operating system can be written in an OOP, especially Java. Any counterexamples or other information is appreciated.


Best way to estimate cost related to porting code from language A to language B?

Have a client thinking about estimating the cost of porting a project from language A to language B. What's the best way to put together an request for proposal to do this?


How should I approach doing similar work on the side to what I do at work during the day?

Currently got a good job, spending 70% of my day doing what I love, the downside of this is of course that I am working for someone else and not my self. Ideally would love to get something of my own going, a night project etc which could trickle in some funds. The downside of this of course if that it would be a conflict of interest. I could of course just go ahead an start up my own little thing but if it got discovered I could risk my job. I could quit my job, but then I would miss the income (family + mortgage) and my ideas might not pan out. Thinking about it tonight, I will discuss it with my boss tomorrow - he's a good guy but I just hope he doesn't burry it or just offer over time. Anyone in this boat? Do what you love during the day (for someone else) and can't peruse it during the night.... Edit: Just to clarify, that what I want to do at night is very similar to what I do during the day. It's not a 'I love programming' in general, but I like doing data mining - and thats what I do at work. Very closely related.


Preventing a parser from turning into a (seemingly) god-sized object

So I have a program whose purpose is to take text files and parse them into a binary format that an embedded system understands. However, the text format I've inherited that I need to parse is sufficiently complex enough that after refactoring the main `parse` routine I'm left with a class with more than 50 methods that almost all look something like `parseChannel`, `parseWCommand`, `parseVCommand`, `parsePCommand`, `parseLoop`, `parseHex`, `parseInt`, etc. etc. etc. Needless to say, the class, from its declaration, looks huge and daunting. However, the methods to interface with the class are extremely simple, just `parse` (compile the text, figure out its compiled size) and `link` (fix the pointers once the location in memory is known, return the finalized raw binary data). Really, to the user the class has virtually no other reason for existence besides those two functions, but there's so much seemingly useless fluff in the class declaration that it's hard to even see what it's supposed to do. There's a similar situation going on with the rather massive number of data members that, again, are useless to everything but the class's internal methods that need them to talk to each other, though I don't know if that's as much of an issue. I've considered making a separate class solely for parsing that's used within the `parse` method, but it seems strange to me to build an entirely separate class that's only used in a single method in a single class. It seems a bit...superfluous, I guess? And I don't even know if that's attacking the right problem.    I guess in the end, here's what I'm asking:   1. Is this seemingly-huge class actually a problem? I don't think it's strictly a "god object", but it superficially looks like one.   2. If it is a problem, what are the best method(s) to fix it?


How do I limit the resources available to a program?

I'm delving into multi-threaded programming with Java, but I'm finding it hard to test my program for bugs. My computer simply has too many resources and cores, making it hard to see how my program acts under stress. Is there any way to limit the resources available to my program? It seems ridiculous that my only option right now is to open another application and render HD video in order to starve out the application I'm debugging.


What's expected of a web-developer?

I've been getting into more web development later and talking to people often I'll get "Can you make me a website [for my book]?" types. "Yes. But.... Well, what do you want from it?" "I want it to look nice and attract people and people will want to buy my book." "..." **What all does making a website for somebody really entail from the designer/developer end?**   * How responsible are we for graphics? Are we expected to make them a nice header with their name/logo and pretty like?    * Color scheme? Overall feel of the site? (I mean, do we decide by ourselves or have some back and forth with the client?)   * Specific wording of content (such as homepage flavor text. Obviously we wouldn't be expected to write the About the Author section.)?   * Additional functionality that we think the user may appreciate?   Ideally you'd talk to the client and figure out what they want, but really--do clients ever _really_ know what they want? **What is expected of the client in order to be able to make a website for them?** **Are web-designer and web-developer essentially interchangeable in casual speak, or...?** * * * I guess this question really stems because I'm learning I don't like doing most of this. I don't program to be a designer. My artistic skills are probably better than the average programmer, but that isn't the point. I would actually prefer it if a client came to me and said "I want it to look like this" and handed me a paper copy, which I could then duplicate. What _does_ interest me is more of the behind the scenes functionality of websites. Is it smooth, functional, does the user have to navigate all over or rely on 'search' to find what he's looking for? Please shed some light on this perceived division of tasks for me.


Must strong developers carry the weight of the world on their shoulders?

As developers we constantly strive to solve problems of the masses. We also constantly look for new methodologies, languages and possibly organizations to help us further our ability to solve problems. I feel as if I've always been one of the top members on my team. I also feel that I look for ways to improve my work in ways others often do not care to. I'm starting to feel a little burnout from ~6 years of supporting technology. I blame the fact that I do work so hard and hold myself to high expectations. Some of the greatest devs on the planet do not even write code for a living any longer. Often, its burnout. Some have said they grow tired of "the game", but I wonder if the problem is a bit simpler. One of "carrying the weight of the world on our shoulders". If you feel you are a strong developer and also feel that this is not a problem for you, please enlighten me with your approach. How do you stay up to date with tech, help others and solve problems quickly/accurately without getting all wound up?


Where is the golden mean between language monoculture and polyculture?

My company has been using Java (as a language and a platform) for many years. We have lots of products varying greatly in size, purpose and complexity. Whatever the requirements, the answer is always the same - Java. This stance obviously has advantages and disadvantages. On a plus side, there is no context switching between work assignments on different projects, every developer in the company can be relatively productive on many projects; on a minus side, a small tool might end up being "crushed" by Hibernate. On one hand, packaging, deployment and execution environments could be standardized; on the other hand, we might loose agility of the mind and miss out on optimal solutions by always "thinking in Java". I could go on and on and on. Polyglot programming has become quite common in the recent past, as much as I can observe. Sayings like "right tool for the job" always ring loud in my ears as well. A desire to open up and expose ourselves to more "right tools" is quite strong, but where is a catch? Better yet, where is the golden mean? It's always dangerous to go from one extreme to another. I dread a day of waking up into an incomprehensible mess of a giant pile of Java, Groovy, Python, Ruby, PHP, Scala, etc. with all their corresponding tools, frameworks, servers and philosophies. Do you have a practical experience working in language and platform polyculture for at least two years? What are your main observations? What are you still excited about and what do you dread?


Software engineer, already in late thirties, would I have trouble finding a new position?

> **Possible Duplicate:**   >  Is ageism in software development based on anything other than bias? I have been a software engineer in the U.S for about 10 years now and I am already in my late thirties. I still have the passion and dedication for this industry and I am still trying to improve myself every day at work. For family reasons, I have to relocate to another state where I need to find a new job. Since I am a pure technical guy I would still like to find a software engineer job. However I am a bit worried about my age since I am already in my late thirties. I am confident about my past experience and my technical strength however the age factor is something beyond my control. My question is: Will I be discriminated because of my age when looking for a software engineer position? If I am really as good as I think, would the employers be interested in hiring me anyways? Any comments/suggestions for improving my chances of being hired are also welcomed! No suggestions like “try to become a manager” please, since I am not interested in any management related jobs. Thank you!


When to take that leap and program

I've been studying a beginners guide to ASP.NET 4 for the past month and a half, and I'm at the end of the books. The next book will be one up (Professional guide). As yet I've only programmed exercise that are in the books, not my own code. When should I start developing my own code? After reading both books? Also I'm still confused over Object-Oriented and how it works with ASP.NET 4.


Is there any practical use for the empty type in Common Lisp?

The Common Lisp spec states that `nil` is the name of the _empty type_ , but I've never found any situation in Common Lisp where I felt like the _empty type_ was useful/necessary. Is it there just for completeness sake (and removing it wouldn't cause any harm to anyone)? Or is there really some practical use for the _empty type_ in Common Lisp? If yes, then I would prefer an answer with code example. For example, in Haskell the _empty type_ can be used when binding foreign data structures, to make sure that no one tries to create values of that type without using the data structure's foreign interface (although in this case, the type is not really empty).


What are some good ways to get familiar with .Net's IL?

I recently accepted a job where I will be working with the IL a lot(on the team of a certain obfuscator that's included with Visual Studio). They know I have little knowlegde of it, so I'll have some time to learn it on the job. But, I want to get a bit of a jump start on it in the interim. For my background, I've never wrote any IL and read very little of it. I do understand what it is though and such. I know x86 assembly and such as well, so I'm not dumb as far as assembly-type code goes. But anyway, what are some good ways of getting familiar with IL and learning the usual opcodes and such and also how it's garbage collection and such magically works at an assembly level?


Where do you put scenarios on a scrum board?

So traditional scrum board looks something like this               Backlog       |       Story    notStarted   inprogress    Done     story 1               Story1   tasks            Story 2               Story2   tasks     Story ..     Story n     Epic  x     Epic  x+1      However in general a story has many scenarios and when working with BDD you want to write each scenario for a story as Given, when and then. Also the scenarios don't belong in the notstarted column, inprogess or Done as a scenario is not a task. So you realize that a scenario/s should have their own column between "story" and "notstarted", as a scenario can have many task to be considered done. If you are going to build your task from scenarios then why would you need the story on the scrum board in the first place, maybe they should be left in the backlog. Some people put scenarios on the back of each story. This is a on going debate in my team and I wanted to see if anyone has solved this differently. Cheers!


Website or any material to practice algorithms that explains the solution

I know some projects and web pages for practicing algorithms like TopCoder and Project Euler. However, they just dictate the solution of a particular problem. I wonder if there is a resource, website or any material, that doesn't only give away the code, but also explains the solution thoroughly ?


What's the copyright status of boilerplate code?

I check Open Source Compliance for commercial code. I have recently found a few examples where the commercial source is matched against quite a few OSS projects. The matches are very similar, but not exact, say about 30 lines of code with about 4 methods, a few variables names differ, some extra lines in the commercial code, ... but substantially the same. I don't think this is auto-generated code, nor copy-pasta, because things like comments will differ. Rather it just looks like boilerplate - the developers say that Grails (and these examples always seem to come up in Grails, but it could be any framework) requires a specific script format for CRUD operations (and these examples are also predominantly CRUD operations). If one adds in a standard source-code style, then it amounts to boilerplate - even if it is original it's going to end up as very similar looking across a number of codebases. Which leaves me with 2 questions:   1. Is this a reasonable defence against accusations of copyright infringement?    2. How would one form a judgement that codeX is such boilerplate, but codeY is not (as a non-expert in the language+framework)?


Why do we have postfix increment?

_Disclaimer_ : I know perfectly well the semantics of prefix and postfix increment. So please don't explain to me how they work. Reading questions on stack overflow, I cannot help but notice that programmers get confused by the postfix increment operator over and over and over again. From this the following question arises: is there any use case where postfix increment provides a real benefit in terms of code quality? Let me clarify my question with an example. Here is a super-terse implementation of `strcpy`:               while (*dst++ = *src++);      But that's not exactly the most self-documenting code in my book (and it produces two annoying warnings on sane compilers). So what's wrong with the following alternative?               while (*dst = *src)     {         ++src;         ++dst;     }      We can then get rid of the confusing assignment in the condition and get completely warning-free code:               while (*src != '\0')     {         *dst = *src;         ++src;         ++dst;     }     *dst = '\0';      (Yes I know, `src` and `dst` will have different ending values in these alternative solutions, but since `strcpy` immediately returns after the loop, it does not matter in this case.) It seems the purpose of postfix increment is to make code as terse as possible. I simply fail to see how this is something we should strive for. If this was originally about performance, is it still relevant today?


automated acceptance testing / BDD & workflow for designing a system

Recently, I started reading the book Specification by Example, which relates to automated functional testing and BDD (from what I've understood till now). I've tried using Concordion (.Net), and seems very interesting. I've been having issues with keeping any form of useful documentation for any designed system, and this might help My issue is, how would one suggest that the workflow in designing a complete system is? Some questions that arise are:   * Is it ideal to try to design the entire whole system in the beginning?    * Should you design a very high level overview of the system, and then create specifications one main feature at a time, i.e create detailed specifications -> develop -> test -> move to next main feature?   * Should you create BDD-style specifications for **each and every** method in the system, even trivial ones like some `GetProductByReferenceCode`? The issue is that most of the times when you actually start developing, you start to realise something's that need to be done differently than originally thought, or omissions not noticed during the initial design. I find that sometimes the initial design stage takes a lot of time, only for the actual design of the system to be very different once the product is launched. My current workflow for designing a system is:   1. First start with the user-interface, creating mockups of each and every screen the users will be dealing with. I find this to be the most visual method that the business users can understand.    2. Define logic that is directly related to the user-interface   3. Define any logic that happens _in the background_ , for example notifications, etc.  Does this make sense? Any ways this could be improved?


How should I organize programming files into directories?

Sometimes, one creates a exploratory prototype and forgets about structure in the directories... What are good tips on dividing the programming files over (several levels of) directories?


URI Representing a Single Resource with Two Possible Identifiers

I have a resource that can be represented in one of two ways:   1. Big Serial Number, or   2. Small Serial Number Is it closer adherence to REST principles to:   * A: have a query string specify the type (https://acme.org/api/widget/aaa-111-aaa?type=big vs https://acme.org/api/widget/aaa?type=small), or   * B: have query strings specify the type as search parameters (https://acme.org/api/widget?serial=aaa-111-aaa?type=big vs https://acme.org/api/widget?serial=aaa?type=small), or   * C: in the URI (https://acme.org/api/widget/big/aaa-111-aaa vs https://acme.org/api/widget/small/aaa), or   * D: something else (ex: headers)? To me, it seems like having it in the URI (option C) specifies an entirely different resource, and in this case, they should represent the exact same resource. Is option A the best way to represent this?


Conditional construct for a kleenean data type

I was thinking of an hypothetical programming language with a `kleenean` data type which would implement Kleene's three-valued logic. To sum up, it's an extension of the boolean data type with the three constants `true`, `false` and `unknown` where `unknown` means that the value is either `true` or `false`, but we don't know which. The truth tables for a kleenean type are well-known and the logic is quite easy to understand. However, I was wondering how one would design a conditional construct to take in account this `unknown` value. A basic `if-then-else` conditional construct is almost always as follows:               if (boolean condition) then         condition is true, do something     else         condition is false, do some other thing     end      However, I have troubles seeing what a kleenean `if` construct would look like. How could we interpret the `unknown` constant? Technically speaking, it could satisfy the `true` condition as well as the `false` condition since it is one of these two. However, we can't have it match any of those since it could be the other, it is not really `true` nor `false`. Is there a well-known way to implement such a construct? **EDIT:** To specify a little bit, I would prefere something different than the way `boost::tribool` works, or from a simple `switch` as if was an enum. Answers about quantum superposition and semantics are welcome.


When is a script no longer a script?

I write many a PowerShell script for the organization I currently work for. Most recently I have been co-writing a tool that, in the end, will have a lot of functionality (beyond a single purpose), will be configurable, and will have both a CLI and GUI, all in PowerShell. So when does a script stop being a script and when can you call it an application or a program. Is this just kind of in the eye of the beholder?


How assertive should I be in handling exceptions in objects?

I have been writing in C# 4.0 a lot lately and trying to write as lean as possible. As such, I have not been using the classic `try/catch` blocks and `using` statements as often. I understand the general function of .Net's garbage collection and exception handling - _I want to bulletproof my code and be efficient with objects, but I am trying to achieve this with the minimum amount of 'extra code'_ (since 'bloat' pissed people off). And to be clear, I understand `using()` is fundamental for relinquishing resources to handles and other code and its relationship to the `IDisposable` interface. But I am trying to get a better grip about how assertive a programmer should be in exception handling objects. Are there key places in code you'd say `try/catch` blocks and/or `using` statements are inarguably necessary? Within the contexts of garbage collection and exception handling, what common-use objects/scenarios would you recommend explicit attention? Should you simply make a catch block for every possible exception an object might through? How deep should they be nested? Are there steps I can take to proactively collect garbage (for example, to combat the example in comments of waiting for `Dispose()` to be called)?


What are good keyboards for programming?

Programmers tend to type a lot of code, bashing a lot of shortcuts and a lot of other things. What keyboards are good for programming?


How do you respond to "Tell me a little bit about yourself." question in interviews?

I've been asked this in a few interviews. And it always catches me off guard.My professional and academic background are already in the resumé, which the interviewer has obviously looked at. What more to tell him/her? Should I start with my hobbies? I like gardening, or looking at NSFW pictures on reddit in my free time? What and how do you answer to this specific question? Do you have a prepared answer for it? Am I wrong if I think this question is a bit silly? **UPDATE** There have been a lot of great answers to this question. I'm in pickle which to choose as the 'correct' answer, because most of them are very insightful. I found a great writing on this subject matter. It's a bit crazy for my taste, but it's interesting: How To Introduce Yourself… I Mean Practically


Licensing a JavaScript library

I am developing a free, open-source (duh) JavaScript library, and wondering how to license it. I was considering the GNU GPL, but I heard that I must distribute the license with the software, and I'm not sure anymore. I would like the library to be available much like jQuery: In a free, downloadable script, preferably in either original or minified form. Am I mistaken about the GNU GPL license terms? jQuery is dual licensed under GNU GPL or MIT licenses. How does the GPL apply to single script files like that? Can I license my library with nothing more than a few sentences in the script file? Is there another license that better suits my needs? What would be nice is a license that allows you to put the URL in the source, for people to read if they want. I don't know that many do, unless I am mistaken. I am generally looking to release the library as free software like the GPL specifies, **but don't want to have to force licensees to download the full license unless they wish to read it.**


Which is more valuable in product development: an action-oriented or visionary bent?

As a software development professional in a fairly conservative large-firm, I always had a much more action-oriented bent, as my job was fairly stable and all that mattered was doing as I was told and completing tasks that were germane to the career of a benevolent dictator (i.e., my boss' boss). Now that I'm no longer working for "the Man", I find it just as important to use the left side of my brain and wrap my head around this whole "vision thing". Which do you think is more important for software product development in a small, yet feisty start-up: Knowing the path or walking (or running) it?