title: How do I handle two algorithms that seem the same but different?

text: I have two algorithms that share a lot of commonalities. One performs an iterative procedure, the other does just the first iteration. The results are, of course, different (one class provides results that the other can't), as well as the setup (the iterative process requires tolerances and max number of iterations, which are irrelevant in the non-iterative one). Should I have a unique class with internal ifs (like `if (iterative) do this else do that`) or should I implement two different classes (and potentially put common code in an accessible place so that it can be shared ?) What do you think ?


title: how to learn Java

text: This question I am asking because I couldn't find any source which gives complete overview of java development. I just want to know where java technology currently in market & what is preferable for development ! Java always remain top programming language for development point of view. However, java is combo of, j2ee, j2me, jsp, jsf, spring, other frameworks, ui components, jndi, networking tools and various other "J" are there ! However, learning java is definitely dependent on the development requirement, but still, to be a well-experienced java developer, what is the organised way of learning java? What is preferable in current technology ? and what is deprecated, currently ?


title: Using nested public classes to organize constants

text: I'm working on an application with many constants. At the last code review it came up that the constants are too scattered and should all be organized into a single "master" constants file. The disagreement is about how to organize them. The majority feel that using the constant name should be good enough, but this will lead to code that looks like this:               public static final String CREDITCARD_ACTION_SUBMITDATA = "6767";     public static final String CREDITCARD_UIFIELDID_CARDHOLDER_NAME = "3959854";     public static final String CREDITCARD_UIFIELDID_EXPIRY_MONTH = "3524";     public static final String CREDITCARD_UIFIELDID_ACCOUNT_ID = "3524";     ...     public static final String BANKPAYMENT_UIFIELDID_ACCOUNT_ID = "9987";      I find this type of naming convention to be cumbersome. I thought it might be easier to use public nested class, and have something like this:               public class IntegrationSystemConstants     {         public class CreditCard         {             public static final String UI_EXPIRY_MONTH = "3524";             public static final String UI_ACCOUNT_ID = "3524";             ...         }         public class BankAccount         {             public static final String UI_ACCOUNT_ID = "9987";             ...         }     }      This idea wasn't well received because it was "too complicated" (I didn't get much detail as to _why_ this might be too complicated). I think this creates a better division between groups of related constants and the auto-complete makes it easier to find these as well. I've never seen this done though, so I'm wondering if this is an accepted practice or if there's better reasons that it shouldn't be done.


title: What's a DRY alternative to c++ header files?

text: In c++, is there any other way, besides header files, to use a function defined in file A.cpp, inside file B.cpp that would be considered good programming practice?


title: mysql, store a single piece of data per row

text: I am preparing to write a database system using PHP and MYSQL which will store every piece of info sent to it as an individual row. Each row will store several piece of meta data (time stamp, who created it, version number, attribute number) and one piece of 'true' data (file name, phone number, username, etc.) Rows my also be used to store serialized data. The goal is to create a system that is easy to incrementally back up, search on single rows, and review based on its state at a particular date. Is this an effective design or should I alter my approach? The database will be used to drive a custom CMS system which is intended to store a interconnected system of data. It will involve customer data, location data and job data. We want to be able to track individual database changes based on time so that we can maintain an on-site backup (the system will be cloud based) which we can use in the event that we lose internet connectivity. The system will be strongly permission based, only allowing people to see/change information that they are authorized to see. Most of the data will be viewed in a timeline format, based on the time that the info is entered into the system.


title: What's so difficult about SVN merges?

text: > **Possible Duplicate:**   >  I’m a Subversion geek, why should I consider or not consider Mercurial or > Git or any other DVCS? Every once in a while, you hear someone saying that distributed version control (Git, HG) is inherently better than centralized version control (like SVN) because merging is difficult and painful in SVN. The thing is, I've never had any trouble with merging in SVN, and since you only ever hear that claim being made by DVCS advocates, and not by actual SVN users, it tends to remind me of those obnoxious commercials on TV where they try to sell you something you don't need by having bumbling actors pretend that the thing you already have and works just fine is incredibly difficult to use. And the use case that's invariably brought up is re-merging a branch, which again reminds me of those strawman product advertisements; if you know what you're doing, you shouldn't (and shouldn't ever have to) re-merge a branch in the first place. (Of course it's difficult to do when you're doing something fundamentally wrong and silly!) So, discounting the ridiculous strawman use case, what is there in SVN merging that is inherently more difficult than merging in a DVCS system?


title: Can Swift be used for anything besides iOS and OSX apps?

text: I'm liking Swift, a lot. But making an iOS or OSX native app isn't totally what I would want to do with it. Is it possible for Swift to be used in other contexts? Like say a web application that runs on a linux server? Or perhaps Arduino micro-controllers? Or is it locked up in the Apple ecosystem?


title: Where does Rails get it's datetime for creating records?

text: I have a rails app with a data model called 'jobs' and i'm faced with a critical design choice crossroads. I don't know enough about Rails and it's inner workings to be able to say for sure what I should do despite a complete read of the rails and ruby docs. I want to be able to accurately display the age of a job record in days. So when a customer logs in, they can see that the job they submitted is 'x' days old. Where does a rails app on Heroku get it's time stamps? From Heroku? or the customers system clock? If a customer has a out of date system clock and submits a job, it could really mess up the sorting of their job list, not to mention me the overseer of job records. Any advice out there? EDIT: Just to be clear, i'm not asking how to list jobs by their date, but to which clock does a rails app on Heroku base it's records.


title: Do computer glasses work?

text: There are a few different types of "computer glasses" available:   * Steelseries Scope   * Gunnar Computer Glasses They seem to be designed for long gaming sessions. Seem a little silly, but thought I'd ask has anyone used them? Do you think they would aide in long coding marathons or reduce eye strain?


title: What is Visual Studio Lightswitch and how does it differ from normal Visual Studio versions?

text: How is Visual Studio Lightswitch different from regular Visual Studio? In what sort of situations would you use this IDE over regular Visual Studio? I'm trying to decide if this is something that would be worthwhile for me to take the time learning since I am currently doing WPF/Silverlight development.


title: Low Level vs High Level Development

text: I really want to start working in OS development, particularly kernel development, with the Open Source Darwin Project - building my own Mac-like operating system, however I am simply not experienced enough to work in the black art of kernel development - I'm constantly deterred by comments : "your code has to be close to spectacular" , "You need to be a programming veteran to write in kernel space" So I Have tried to find other projects. I am working at CryENGINE 3 at the moment, but I just can't get into the API's as I'm constantly wanting to start kernel development. I have no experience in user-land programs, however I have researched and created small assembly based programs. Note: I'm 17 years old. Are there any projects you can recommend me starting, so I can get some experience for user-land applications? I find it almost impossible to build something revolutionary. I have Experience with C, C++ , C# , Java , Haskell , Ruby , Lua and ASM. Plus: What's the chance of creating a business out of software development?


title: lightweight, sustainable processes for good code/design quality?

text: Ok, gang, next question: what do y'all think are the best processes to improve the quality of the code the (corporate) team produces? (The cult of quality question was good, but I'm looking for specific suggestions of things we can do.) Background: the team is diverse, in the usual way: > There's the brilliant coder whose code is impenetrable and undocumented and > whose ability to communicate isn't as good, which manifests itself as > impatience or excuses of busy-ness. > > There's the middle-of-the-road developer who just wants to get his/her work > done and go home. New methodologies would be ok, but he/she won't initiate. > > There's the person who really doesn't want to change (i.e., is hostile to > change, for whatever reason), satisfied with their current level (the old > way). > > There's the person who really doesn't know what the possibilities are, > they're just copying everybody else's code (and that works, too). > > There's me, of course, the handsome, charming, brilliant developer who takes > the time to write good, clear documentation and unit tests and just wants > the best for the group and isn't satisfied with the status quo > (technologically) and couldn't possibly be the problem. There are all these beautiful principles out there: OOP (highly coherent, loosely coupled), functional programming (what I mostly see here is /no side effects or in-out parameters/), strong static typing (no runtime type errors, method not found, etc.), separation of concerns (business logic separate from UI and database). And there's the old school of huge blobs of code that do multiple things all sort of intertwingled together, and global variables and their cousins the singletons and the huge classes with lots of data members. So, how do we get from point A to point B? Grass roots suggestions get ignored. [edit: well, to be more accurate, a single developer running around telling people what they're doing wrong is not the best way, from both managers' and peers' points of view. I don't do that because I don't want to be Cassandra.] Can we do abbreviated code reviews? Like... just call out what your new classes and methods are (ignoring implementations). Or call out (in English) where you added new functionality (i.e., which method did you update to do what)? What if the person(s) who need to review that stuff are constantly in meetings (you know how that goes: new features, partnering, crazy deep bugs that have important customers screaming[2])? Would a wiki or some sort of social thing work, to get more eyes on the new designs? How do we get those who don't want to be involved involved? So... lightweight, sustainable, effective processes? Any ideas? What works for y'all? (I know people are going to say pair programming. Ok, granted, but that ain't gonna fly here.) Thanks. [2] Ok, overblown language. s/screaming/focused on particular bugs/


title: better way to learn programming with the intention of getting a job?

text: > **Possible Duplicate:**   >  How to get a job with no experience? So I've worked on a desktop software coding Swing GUI for past 2 years. I feel that even having a live website selling my java desktop software (customers buy it occassionally) is not enough experience, contrary to opinions from this site, very little of my experience building, running the software business is discussed during interviews. Often jobs have extensive list of qualifications which I think I can cover 70%, but I don't have example projects for each language and framework, rather I've played around with different open source libraries and build things based on what is needed. When I land interviews, sometimes I pass all the technical questions but sometimes I don't when they ask me about experience I don't have. When I do land interviews, I cannot complete the programming tasks in time. I over think the problem, and while I have done more complex problems working on my software project, I cant think quickly enough to do the testing questions fast enough. What other ways can I improve my skills to better showcase my skills? How many portfolio of projects do I need to be convincing? Should I take a course from a local college in Java?


title: Mock Objects for Testing - Test Automation Engineer Perspective

text: How often QA engineers are responsible for developing Mock Objects for Unit Testing. So dealing with Mock Objects is just developer job ?. The reason i ask is i'm interested in QA as my career and am learning tools like JUnit , TestNG and couple of frameworks. I just want to know until what level of unit testing is done by developer and from what point QA engineer takes over testing for better test coverage ? Thanks **Edit** : Based on the answers below am providing more details about what QA i was referring to . I'm interested in more of Test Automation rather than simple QA involved in record and play of script. So Test Automation engineers are responsible for developing frameworks ? or do they have a team of developers dedicated in Framework development ? Yes i was asking about usage of Mock Objects for testing from Test Automation engineer perspective.


title: Difference between a service class and a Helper class

text: I would like to know what differentiates a Service class from a utility class or a helper class? A class only with underlying methods calls the dao's is a service? Doesn't the usage of Helper classes violates SRP?


title: Refactoring two classes from third-party library that could have extended a base class

text: I have two Classes, with very similar behaviors, both from a third party library. Both needs to be populated with some value object and sent to specific queues in order for logging. Please note both of them does not have a common parent. I am scratching my head to find out ways to refactor this. Here is the sceanrio. Class 1 : Apple Class 2 : Orange Unfortunately, Apple and Orange are not child classes of Fruit And I can not change them to extend a base class. Constructors of Apple and Orange have different signatures. Current code:               if(isApple){         Apple apple = new Apple(....);         apple.setColor(Color.RED);         apple.setPrice(10);         apple.setCount(1000);              AppleMQObject applMQObject = new AppleMQObject(apple);         Producer appleProducer = Factory.create("apple-producer");         appleProducer.send(applMQObject);     }else{         Orange orange = new Orange(...);         orange.setColor(Color.ORANGE);         orange.setPrice(30);         orange.setCount(100);         OrangeMQObject oMQObject = new oMQObject(orange);         Producer orangeProducer = Factory.create("orange-producer");         orangeProducer.send(orangeMQObject);     }      I can move the MQ code out to a common method. But how to handle the apple/orange situation.


title: Need help understanding UML diagram

text: I'm focusing on trying to understand UML diagrams and learning to interpret them in order to implement the designs they describe. In the following diagram, I am not clear on what the implementation for `Port Operation` should be. ![enter image description here](http://i.stack.imgur.com/IMimV.png) It looks like it should be a class/entity the same as the others in the diagram. I understand the relationship between Leg and `Port Operation` is bidirectional. But it seems that it does not make sense to have a class just for port operations, and having Load() and Unload() methods in Leg doesn't make much sense since a Leg class does not represent a port or its' operations. When reading UML diagrams, is it expected that there are multiple ways for someone to implement it? i.e some ways are better than others, and it's a judgement call as to how someone implements it? What would be the recommened implementation for the above diagram with regards to Port Operation?


title: How do I explain that we're wasting developer time adding unnecessary features?

text: So I've lead the charge with my fellow engineers to, at the very least, start "thinking" Lean. We hit on a few major areas of waste, and 2/3 lead to the exact same point..."Extra Features". We dogfood our own software on two fronts, sales and project management. It works great for sales, because that's what a CRM is great for. It's not so great for managing projects, and we're often tasked with adding extra features to make it work for this use case. Does it make more sense to continue adding features that don't add any customer value, or should we accept that having our sales team using our own product is "good enough" and perhaps look for an off-the-shelf solution?


title: How to work on a project with a beginner?

text: I am currently starting work on a personal project that me and a friend are very passionate about. We want to work on it together, but we are on very different programming levels: I'm in my last semester of my education have been through 2 internships and I'm currently working as a student, programming, while he just finished his first year of uni and just got the basics down. The question is How can we work on this together? He is just making the switch from Java to C# at school, and the project will be an ASP.NET project in C#. I could wait a semester so he can get more into the language and learn more programming concepts, but I feel that it would be a waste of time, and I might loose momentum. So the question is **what is the best way to work with a person on a different programming level than you?** Pair programming, making a part of the system as an example that he can follow in making another part? How would you do it?


title: Natural language detection for web application

text: I have my own thoughts how "ideal" multilingual web application or web site should behave. Can you think of better solution? What are the pros and cons of them? What are cons of the solution I am presenting bellow? Any comments? My "ideal" solution:   * application should read browser language (from Accept Language header)   * user should be able to override his/her default language in options (logged-on users will see the web site in this language no matter of current browser settings; useful when one is travelling for example)   * on top of this, when lang attribute is specified in URL (see example bellow), user will see the page in language specified by this attribute (both accept language and user settings would be overridden; this could be useful for book-marking, sharing, RSS feeds selection, web crawlers). Example URL: http://www.example.com/index.html?lang=ex


title: Use a search box that calls on a JSON file?

text: I use a JSON file to populate several drop down lists. The format is:                   {             "value" :"lightyear",             "name" :"Light Year(yl)"         },         {             "value" :"astronomicalUnit",             "name" :"Astronomical Unit(AU, UA)"         },      and so on. I'd like to implement a search box so a user can type "Light year", "lightyear", "lightyears" etc etc. I want to make it possible for them to search for a particular unit. The immediate problem I can see is that I've used camel casing for pretty much all values except those displayed in the drop down boxes. There are two options, I think... Either run the search on the value key of the JSON and search for parts of it so "AU" would still yield Astronomical Unit or to use the value. The other option is to use the value which I think will overcomplicate things. It's not something I've done before and not sure which direction to go in?


title: What to do if you find a vulnerability in a competitor's site?

text: While working on a project for my company, I needed to build functionality that allows users to import/export data to/from our competitor's site. While doing this, I discovered a very serious security exploit that could, in short, perform any script on the competitor's website. My natural feeling is to report the issue to them in the spirit of good-will. Exploiting the issue to gain advantage crossed my mind, but I don't want to go down that path. So my question is, would you report a serious vulnerability to your direct competition, in order to help them? Or would you keep your mouth shut? Is there a better way of going about this, perhaps to gain at least some advantage from the fact that I'm helping them by reporting the issue? **Update (Clarification)** : Thanks for all your feedback so far, I appreciate it. Would your answers change if I were to add that the competition in question is a behemoth in the market (hundreds of employees in several continents), and my company only started a few weeks ago (three employees)? It goes without saying, they most definitely will not remember us, and if anything, only realize that their site needs work (which is why we entered this market in the first place). This might be one of those moral vs. business toss-ups, but I appreciate all the advice.


title: Pair programming business logic with a non-IT person

text: Have you had any experience in which a non-IT person works with a programmer during the coding process? It's like pair programming, but one person is a non-IT person that knows a lot about the business, maybe a process engineer with math background who knows how things are calculated and can understand non-idiomatic, procedural code. I've found that some procedural, domain-specific languages like PL/SQL are quite understandable by non-IT engineers. These persons end up being co- authors of the code and guarantee the correctness of formulas, factors, etc. I've found this kind of pair programming quite productive, this kind of engineering-type users feel they are also "owners" and "authors" of the code and help minimize misunderstandings in the communication process. They even help design test cases.   * Is this practice common?   * Does it have a name?    * Have you had any similar experiences?


title: How do I safely write code in my own 'words' and not plagiarize?

text: I understand plagiarism and paraphrasing fairly well when it comes to writing a research paper, but those equivalent areas in programming seem foreign to me. I've looked up the topics online, and surprisingly there is not as much material on the subject as one would have expected. When writing code and having to implement something I've never implemented before, I'll go online to look for an example. I try to read through the documentation beforehand, but sometimes I find it challenging to follow. So if that fails, I will search for the topic online and be presented with dozens of examples (whether they be on someone's personal blog or a Q&A site like SO). Now I'm usually presented with 5-10 lines of code. I have and will NEVER copy- and-paste that into my own code, but I still worry about copying it down verbatim. I find it hard to reword a certain piece of code, especially when there are only so many ways to do so. I make sure to rename variables, change formatting, etc. - but is this enough? I've always wanted to understand this topic, but now that I'm working with a new language and in a corporate environment I think that it is especially pertinent. If anyone could explain or link to a good explanation elsewhere, I would greatly appreciate that! **tl;dr** I don't understand how much you have to change and reword 5-10 snippets of code found online to avoid plagiarism. What if there is very little that you can change?


title: Backend development philosophy

text: I feel kind of lost in this backend development process I am attempting right now. Most of the usual development practices I use while developing client- side applications don't apply here... Let me provide some context. ### The debugging process While developing a client side application (iOS, Java desktop app, or whatever), it is easy to quickly setup the project on your favorite IDE, get it running on your machine or a testing device, and debug the hell out of it as much as you like. On the other hand, it's not as trivial to hook a debugger to your backend code, and especially if it is python code running on Google App Engine (GAE). That's what I am using, and ... yeah. Linters and all help A LOT, but still, semantic issues cannot be resolved that way, obviously. I am currently going over my recently written backend code and just burying it with logging.debug('msg') statements, asserts and whatnot. This is the only thing I can think of. Is this normal for backend developers? Does logging and digging through logs usually how backend devs iterate on their applications? ### Parallelism and request driven This might be a bit more specific to GAE and other non-blocking backends, honestly. Single threaded servers don't suffer from this problem... Anyways, so when you are dealing with parallelism and everything is driven by socket events, how do backend developers usually test if their backend works? I did the most naive thing of all time, which is to open python console and using the requests library just send requests and test bit by bit. Then, I went ahead and wrote a **kivy** app to help me send the requests from a GUI interface and see what is going on, but it's taking more time to maintain the kivy app than develop the backend!! I tried to check for test frameworks for GAE, but they didn't seem easy to get, so I was wondering if they are worth it? Would I be able to simulate 100s of clients using my backend using test frameworks? What do people use these days (For GAE specifically)? ### Visualizing the "flow" Because of my inexperience with backend development, it is **surprisingly hard** hard for me to keep a clear image of the request/response cycle in my head. I know the basics, I have written a few backend apps, but as soon as it get just a little complex, I have to keep reminding myself where the request goes through by looking at the entry point, and all the steps till the response is made. I am sure if I were able to somehow visualize it, I don't have to keep going back over and over. Instead, I would easily know where a bug would originate, for example, or where is the best place to add a certain feature. In any case, I was wondering if there is some sort of standard "thing" to design the request flow. I don't know, maybe a UML diagram or something? I tried to sketch it out, but I ended up with a mess. Like, I would sketch the backend design based on the features and requirements, but then the actual logic and model would be left out. Then, I try to include those in the diagram, and it becomes overly complex and cluttered with many weird arrows and boxes. **I need something to backend development, like ER diagrams is for relational database design**. Yeah, Sorry. I talk a lot, and I am lost in this world. Help?


title: Supporting early versions of Android

text: What policy do developers have when it comes to supporting earlier versions of Android? I still support , but this means that I am unable to use features such as the action bar. Over 40% of my users are still running versions below 3.0, so I feel somewhat constrained about this. The problem is that 3.x was not very successful, so 2.3.x will be with us for some time. But all new devices will now be shipping with 4.x. I am wondering whether 4.x users are more likely to pay for an app, while most 2.3.x users are just looking. **Update:** With a little effort, I have found that I am able to implement action bars and Holo themes, and still support Android 2.1. All this without recourse to an external library. The only feature that I am still stuck with is tab bars. These do work with action bars, but not in the approved style. For that I would need fragments, which requires Android 3.0. I only have two tab bars though, so it is not a big deal.


title: What do these symbols mean? I'm trying to understand them to make an app

text: What do the symbols `⊞` and `⊕` mean? I'm trying to understand them to make an app. It's on http://en.wikipedia.org/wiki/File:XXTEA.png ![http://en.wikipedia.org/wiki/File:XXTEA.png](http://i.stack.imgur.com/EyUUf.png)


title: Lexer/Parser for multidimensional Languages

text: How does _Lexer/Parser_ work in a 2D programming language like Funciton in order to transform such an unusual source-code to the correct AST?


title: NVI for virtual function implemented in every layer of a deep hierarchy

text: Suppose we have the following class hierarchy:               class Object {     public:         virtual void update() {             // Update position         }     };          class Rocket : public Object {     public:         virtual void update() {             Object::update();             // Orientate towards target         }     };          class SparklingRocket : public Rocket {     public:         virtual void update() {             Rocket::update();             // Create sparkling particles         }     };      For obvious reason this is no good idea. For instance an inheritor of any of the classes might forget to call Base::update() and the behaviour of the program would be incomplete. As I see it, functions that implement important behaviour shouldn't be made virtual, that's something better reserved for replaceable behaviour. So, we would probably change the architecture like that:               class Object {     public:         void update() {             // Update position             afterObjectUpdate();         }          protected:         virtual void afterObjectUpdate() {}     };          class Rocket : public Object {     protected:         virtual final void afterObjectUpdate() override {             // Orientate towards target             afterRocketUpdate()         }              virtual void afterRocketUpdate() {}     };          class SparklingRocket : public Rocket {     protected:         virtual final void afterRocketUpdate() {             // Create sparkling particles             afterSparklingRocketUpdate();         }         virtual void afterSparklingRocketUpdate() {}     };      This is pretty much what I want:   * The public interface of all classes is only the non-virtual update() - method   * When that method is called it is ensured that every update()-"submethod" is called   * Even if the one inheritor forgets to call a afterUpdate() - method, the hierarchy is stable from the base class down. This way a API could ensure its own integrity whilst in the first codeexample it would have to rely on the user to call the Base::update() method I dislike one thing though: The name of each class is part of the after...Update() methodname. That seems like codesmell to me. I think the general goal of keeping virtual call hierarchies stable can't be that uncommon. What is the commonly applied solution that I didn't come across yet?


title: How to avoid unauthorized use of an API?

text: I have to design a "widget", a script that partners will embed in their websites to display some UI and make calls to our API. Basically it will display our data on these sites based on some IDs they provide in our API calls. **What we would like to avoid is someone abusing the API and using it to scrape the entirety of our catalog.** Each partner that embeds our script will be given a public key that must be provided when calling the API. An idea would be to ask them to append this key when loading the script, e.g.:               <script src="//initrode.com/widget/loader.js?key=xxxx"></script>      That way the request for the script can be used to register the key/source IP pair, and answer subsequent API calls only if the key/IP pair matches a registered one (with a limited lifetime, and a limit on requests per day). I'm not sure it's a good idea since it's obviously security through obfuscation (someone reloading the script will completely bypass it) ; but I don't see any other way to restrict access. I cannot provide a unique key to every user, only to partners. I can't use a private-key system since all the code will be available to anyone. It's basically restricting access to a public API, i.e. contradictory in its definition. What do you think of this solution, and what would you do with these constraints?


title: The most human language like programming language

text: I was wondering, there are so many articles about what the best coding languages are. C, C++ Go Haskel lisp java ML F# etc etc. But rarely i see an article about the most human like programming language. It doesn't need to be fast but be closest to the English (or other natural) language. Once it was a goal to create such languages it was seen as a form of AI. But these days AI went a different direction Now there is Siri etc, but those are application not coding languages themselves. Out of curiosity is there still somewhere a language that understand basic English to code with ?


title: Can I safely use an open source library in an internal closed-source project?

text: I m thinking of using iTextSharp, which is licensed under Affero GPL, in an internal closed-source WinForms project. No one outside my company will be using it. GPL (and Affero GPL as well) typically demands that the source be provided with the binary. Given that this is an internal project, do I need to provide my employees with the source code of the project?


title: What is dispatch? Does it imply dynamic resolution?

text: AFAIK, the term _dispatch_ means just a method resolution and calling. It doesn't matter whether it is static or dynamic. I saw many people are using a term like _static dispatch_ and _dynamic dispatch_. What makes me confusing is there're also some mysterious descriptions. I was trying to understand what is _multiple dispatch_ , and it seems just _selecting a subprogram by parameter types_. If I understood it correctly, there can be both of _static multiple dispatch_ and _dynamic multiple dispatch_ , and we can say C++ is providing _multiple dispatch_ via free functions. But, Wikipedia article about _multiple dispatch_ says C++ has no multiple dispatch because it doesn't have dynamic resolution of function by multiple parameters. And I really don't get conceptual difference between Common Lisp example and C++ overloaded function. Because I can't find any conceptual difference unless the term _multiple dispatch_ implies _dynamic dispatch_. And I realized that I am confusing what the _dispatching_ really is I also checked QA entry Multiple Dispatch vs. Function Overloading, and it seems the answer is premising the term _dispatch_ is basically _dynamic_. That also makes me confusing. What is correct meaning of the term _dispatch_? Does it imply _dynamic resolution_? Is this term well defined or just conventional? What am I missing?


title: "Match Making" script, a way without involving the database and php?

text: I am writing a matchmaking script for a game through a web portal. For the past few days I have been looking into the different options and I believe the following approach would be the most optimal but I would like the opinion of others.   1. Get players match requirements through a web form (Method GET) and place the player in queue (mySQL database entry with time stamp and match requirements) for 1 hour.   2. On the submit page run an ajax script every minute that contacts a php script that checks the following:      * Is a player still in the system, if their hour is over or their ajax script has not ran in 5 minutes remove them from the database. Return time out.     * Is the player in queue flagged for a match?        * If yes then place both players in the in match table and remove both players from queue and send match variables.       * If no then continue.     * Do the remaining players match the current players requirements?     * If yes:        * Is the player the same one looking for a match.       * If no: Return match variables. Flag other player.       * If yes: Return match not found.     * If no: Return match not found.   3. When match variables are received the page will be updated with jquery, including a new ajax request that will call a new php script every 30 seconds to find out if both players accept the match. Possible ajax results are: 0 waiting, 1 accepted, 2 declined. There will also be a button that will send the players response immediately to the php script through ajax that will disable itself through jquery when pushed. When both players accept the page will then use jquery again to display the instructions for beginning the match. Is there a cleaner or less intensive way to do this with or without involving the database and php? Notes:   No code is written yet.   The system will not have more than 100 players in queue at any time. (Most likely a peak of 25)


title: Microsoft Reciprocal License: include source even for unmodified binary?

text: The Microsoft Reciprocal License (here taken from the WIX toolset I use) has the following sentence: > For any file you distribute that contains code from the software (in source > code or binary format), you must provide recipients the source code to that > file along with a copy of this license Does that mean I have to provide the source code even if I only use the unmodified (original) DLL in binary format? Note that this unmodified DLL contains code from the software, although it was not compiled by me. What does _provide_ mean? Shall I provide 11 MB of source code as part of my application (install the source on hard disk) or can I provide it as an extra download as well?


title: How can I show aptitude to prospective employers when my all my work is on internal projects?

text: I've been in my current position for a long time (10 years) and in that time, I feel like I've performed well as a designer, system architect, and programmer. However, all that work has been on internal projects that aren't accessible from the outside world. I see a lot of advice like this that suggests 'If you can literally point to something and say "I wrote this" it's very impressive'. What about if you can 'literally point to' nothing at all, because while you're a passionate programmer who (as the classic Joel-ism puts it) "is smart and gets things done", all those things are invisible? Do I need to start frantically committing to open-source projects? Start a "real world" (not corporate-internal) blog? Frankly, I spent most of my 10 years happy here, and only recently have considered leaving for greener pastures. Am I going to be sunk before I start looking because of my focus on work my current employer, at the expense of my "public presence"?


title: What corners have have you cut at work?

text: Have you ever let your coding standards slip to meet deadlines or save time? I'll start with a trivial example: We came up with a coding standard at work around which brackets/formatting to use and so on. I ignore it and use the auto-format tool in netbeans.


title: Are IT and software industry getting more and more litigious?

text: The last couple of years I've been observing an exponential growth in the news related IT companies and individuals taking their cases to court, on one side, and the questions concerning legal matters everywhere on the web, on the other side. I very much doubt people and companies have suddenly started stealing each other's ideas, but something is different. Is it that: 1) IT people on average are getting more legally-educated? 2) Some changes in legal systems of various countries I have missed are causing that phenomenon? 3) IT is now being perceived as the source of potentially unlimited revenue and the trolls and lawyers have turned its attention to it? 4) Any other development in place? * * * The **first part** of my question is **how should an average developer react to this perturbing trend** : a) Continue on as before and ignore everything legal b) Educate themselves in local and international laws related to IT c) Always get a professional legal advice before venturing to do anything programming related d) For any kind of project register an LLC to protect himself even for the most basic and harmless projects * * * A **second part** is a bigger one: **how does this all affect IT companies and start-ups** : e) Is any new company at potential risk? If so, is this risk local like in US with all of its software patents or global? f) Can any new company survive without getting lawyers from the start and applying for all possible patents? g) Is it a risk factor for the registration of a new company to choose a location which supports software patents in its legal code? * * * I admit my question is complex but the matter at hand is even more complex. If you see any restructuring potential, it'd be welcome. I'm also seeking any input either global or related to local markets. We'll figure out the common ground from particular cases.


title: Is there any sorting algorithm which is not inherently sequential and is task distributable?

text: After googling for a couple hours, I came to a conclusion that all sorting algorithms are inherently sequential which can be data distributed but not task distributable. Is there any algorithm which is not inherently sequential and is task distributable?


title: Migration of PowerBuilder application to multiplatform

text: I developed a client/server application with PowerBuilder in the past for medical clinics and done maintenance for it until now. Now, some clients are asking me to develop a release for Mac/Linux and need some advice about what programming language/technology is best suited for it and the learning curve. It’s not a very very big program but I’m the only developer and have done it in my spare time. PowerBuilder is very productive for this kind of projects (database centric), but it’s not multiplatform and it’s hard to sell PowerBuilder application now days (web, .NET, java sells a lot better with his marketing). My programming skills:   * I studied C and C++ in the past (university) but never used it on real projects   * Have some Java experience but not in desktop applications   * Some experience with Ruby on Rails for web projects   * Good skills with PowerBuilder and C# (.NET) (there are my main developing languages) My first dilemma is if I change the desktop application to a web interface, but I think the user will lose some user-experience, and some doctors don’t have a clinic (they are alone at home with my software). I think installing a web application (with webserver) for one user will be overwhelming. If I continue developing desktop application, what is at the moment a good framework/toolset to learn having my skills? Somebody has had similar experiences?


title: Etiquette when asking questions in an IRC channel

text: Many larger OSS projects maintain IRC channels to discuss their usage or development. When I get stuck on using a project, having tried and failed to find information on the web, one of the ways I try to figure out what to do is to go into the IRC channel and ask. But my questions are invariably completely ignored by the people in the channel. If there was silence when I entered, there will still be silence. If there is an ongoing conversation, it carries on unperturbed. I leave the channel open for a few hours, hoping that maybe someone will eventually engage me, but nothing happens. So I worry that I'm being rude in some way I don't understand, or breaking some unspoken rule and being ignored for it. I try to make my questions polite, to the point, and grammatical, and try to indicate that I've tried the obvious solutions and why they didn't work. I understand that I'm obviously a complete stranger to the people on the channel, but I'm not sure how to fix this. Should I just lurk in the channel, saying nothing, for a week? That seems absurd too. A typical message I send might be "Hello all - I've been trying to get Foo to work, but I keep on getting a BarException. I tried resetting the Quux, but this doesn't seem to do anything. Does anyone have a suggestion on what I could try?"


title: SQL Auto Formatting and Auto Capatilize in Vim

text: I'd like to use vim for writing SQL queries, but I haven't figured out yet how to get two key features that I use all the time in programs like SQL Yog. I usually just start up an instance of Yog in the background, cut-and-paste my SQL into it, hit F12 which auto-formats the whole thing. All the SQL keywords are automatically capitalized as soon as the text is pasted. I then copy it back into whatever other tool I'm using (often SQL Query Browser at work) and go from there. The benefits of these two features are worth the extra effort. Anyone know how I can set up vim to do this? I still may need to cut and paste back into Query Browser, which is acceptable to me, but I'd like to stick with vim for all my editing. Thanks.


title: How does enterprise level Flash development work?

text: I started working at a PHP shop and occasionally we have to go and tweak some legacy Flash and actionscript code. It's a small shop; we have about six developers. It seems almost every time we pull a flash file down from SVN, we run into some weird dependency, either with fonts, code suddenly deciding not to compile, or version incompatibility with Actionscript and Flash MX/CS3/4/5. None of the folks who created the flash components are still working for the company (nor are any of the dependencies documented), so we have to slog through the code and it takes FOREVER. This got me thinking: how does enterprise level Flash development work? What tools are used? Is it possible to allow for many people to be working on the same Flash file, and be able to unload that file to a new machine with a minimal setup hassle?


title: What is a combined fragment in a UML Sequence Diagram?

text: Everything is in the question. I just discover this new feature and I don't really understand what it stands for. I know that it can represent loop, alternative in the sequence diagram. Can someone explain me what it is?


title: Is it okay to check in changes to import statement on opensource projects on a commit?

text: There are some guidelines out there (eg scala guidelines) and I'm wondering if it's okay to do some tidying up when committing other changes or if the commits should be more focused and to the point? Eg - remove unused, reorder per style guide. It might make it harder to read the pull request - but it will improve the project quality at least a little. What's your general rule of thumb? I'm not sure if I'm breaking unspoken taboos.


title: How to solve the problem of nested comments

text: It appears in not just one language that comments can't be nested. Do you have a good solution for this problem? One workaround in C/C++ and Java is to only use the single-line comment but it becomes impossible then to comment out a larger block. I'm facing something like this:               </li><!--                     <li><!-- Save -->      So I must manually go through and edit the comments. Can you advice how we should handle this, in many languages? I'm not sure but maybe python has a solution for this with the `'''` way that might be able to include a `#` comment in python? `


title: Strictness in programming methods among Stack Overflow users

text: I've been a member of Stack Overflow for a couple of weeks now and have answered questions and read others answers, mostly in C/C++. True, I have learned about some things. For example, `undefined behavior` which in the past, knowing what's going on from inside the CPU to compiler code generation, all those "seemed" defined and worked as I expected them to. I understand now how conforming to rules such as not evoking undefined behavior are good for you, even though you know in your PC, in your compiler it works without a flaw. However, at times I got negative points for answers involving using macros or certain codes that makes me wonder why among people here, there are such very strict rules. For example, almost any time you talk about macros, people say "use functions instead". I understand that functions are better in many ways, but there are many places macros are more fit. Are macros so frowned upon here? Another example is, if for any reason you write a simple `for` loop to find a character, you get a lot of comments telling you to "use prewritten functions instead" or you get negative points for suggesting the loops. I understand the functions in standard library have all kinds of error checking in them and probably are most efficient in general, but is it such a crime to write a simple loop for your own specific case? What I'm asking is more general than these mere examples. It seems to me that among the users of Stack Overflow, there is "defined" (if not written) standard of coding in C/C++ and that's the only way they accept it. I'm not saying it's bad. I'm not saying that at all. I learned a lot myself about things that made my code not portable. However, almost all of those things turned out to be too much restriction. Things such as "if you do like this, your code won't work in computers that don't encode characters in ASCII". Do you think people will always want their code to run on all possible computers? Isn't that a bit too much? A simpler, faster method that you know works on computers you know your program would run on, seems to me a better solution than a completely portable one. There are great codes out there that seems to me if they were judged here, they would get the worst results. Codes such as the Linux Kernel, implementation of STL that comes with g++, Mesa3D's implementation of OpenGL and so on. Look at these codes and your eyes are flooded with macros and bitwise operations. Do you condemn the programmers of the Linux Kernel too? Would you rather have your OpenGL library drop framerates by 10% but possibly run on a 16bit microprocessor too? So, is what occurred to me true? Are people in Stack Overflow so strict on judging others' codes? Or have I just been unlucky enough to stumble upon a minor few? Edit: I'm a master's student in robotics, my bachelors was in software engineering. My master's project was library/kernel module for a project funded by european union and through that I got offered PhD (in a subject that has to do with writing some software). I also code for fun. It's been 15 years that I'm familiar with C/C++ and 8 years that I actively code. (What I mean is, I didn't start programming just yesterday) Update: After doing some research I found out there are a lot of C programmers, if not most, who hate C++ and a lot of C++ programmers, if not most, who hate C. As someone who finds beauty in both languages and maintains a coding style of a mixture of the two, I find those hatreds absurd. However, as it seems the majority of the programmers in either language have this hatred at least to some extent, I no longer see a reason for continuing this argument. I came to the conclusion that I would write the answers they way I see fit, and _just ignore everyone when they start throwing a fit because I didn't use a`vector` or something_ (Seth Carnegie, the 7th comment). However, I would put a note on the bottom saying: _This code is not meant for copy-paste. There may be lacking error checking. This is just to demonstrate how blabla works, and not necessarily the easiest way to do it._ and other legal stuff. You know, like what you see in a EULA.


title: When does it become overkill?

text: First off, I apologize cause I don't know how to make a community thread; so someone help me out please. As a developer, across many platforms, technologies and even on an infrastructure level; I always find myself asking, when am I doing TOO much?!? It's been a never ending learning process, since I started. One (1) thing I learned is that requirements are barely valid for an extended period of time, and as such a little foresight may go a long way. But where is the balance, and how do you know when you're losing time, not gaining it?!


title: Best practice with branching source code and application lifecycle

text: We are a small ISV shop and we usually ship a new version of our products every month. We use Subversion as our code repository and Visual Studio 2010 as our IDE. I am aware a lot of people are advocating Mercurial and other distributed source control systems but at this point I do not see how we could benefit from these, but I might be wrong. Our main problem is how to keep branches and main trunk in sync. Here is how we do things today:   1. Release new version (automatically create a tag in Subversion)   2. Continue working on the main trunk that will be released next month And the cycle repeats every month and works perfectly. The problem arises when an urgent service release needs to be released. We cannot release it from the main trunk (2) as it is under heavy development and it is not stable enough to be released urgently. In such case we do the following:   1. Create a branch from the tag we created in step (1)   2. Bug fix   3. Test and release   4. Push the change back to main trunk (if applicable) Our biggest problem is merging these two (branch with main). In most cases we cannot rely on automatic merging because e.g.:   * a lot of changes has been made to main trunk   * merging complex files (like Visual Studio XML files etc.) does not work very well   * another developer / team made changes you do not understand and you cannot just merge it So what you think is the best practice to keep these two different versions (branch and main) in sync. What do you do?


title: Database design/relationship for threading messages

text: What's the database design or business logic for creating an app for messaging between users? I am having difficulties with choosing how to approach the relationship between each Conversation of User Thread. I show this figure, but it was really hard to grasp the concept ![enter image description here](http://i.stack.imgur.com/tfvlB.png) How all this threading message works (like Gmail or Facebook)?


title: Representation of time expanded graph

text: I want to build a time expanded graph with time discretization Dt that starts at t = 0 and ends at t = T where between the node (n1, t) and the node (n2, t') is an arc if and only if (n1, n2) were connected in the original graph. How can this be implemented in pseudo-code? The problem I'm stuck on is how to pass from the original graph to the time expanded one. (I use C++ and Boost libraries to write the code)


title: image processing algorithm to find solid square vs square outline in video frames

text: I am working on a system to detect an "embedded" 12 bit number within a series of frames that are recorded inside an mp4 file. The point of it is to automatically identify the "take", and also trim the start of the file to a common offset for synchronization with other files. this is typically done manually, but the nature of the project demands it needs to happen as much as possible automatically. It's not possible to set the timecode in the camera. The number is generated by a smartphone app, which I have coded a prototype for, but as I am new to image processing, I need some help figuring out how to do the other side of the equation. this algorithm, for what it's worth doesn't need to be real time, and will probably happen in a pc based command line utility, not that it's that relevant to the algorithm itself. My original idea was to use a QR Code, but I found the resolution and artifacts from the mp4 stream were too much to cope with it in all lighting situations and frame rates. So I came up with the idea of sending the number serially, by encoding it in a distinctive series of squares, using RGB colours, which seems to be efficiently handled without too many "artifacts" at speed by the mp4 encoder. (This I am determining by manually looking at the video frame by frame, not programmatically) Which whilst it is a slow way to send the number, it can be accurately synced to a known time datum, and the precise frame extrapolated from there (I take precisely 1 seconds to send the 12 bits), which most frame rates can keep up with.) To check the images are "human readable" I have extracted frames, and I am confident that it is now a fairly trivial task to analyse each frame to decode each bit of the number. so breaking it into manageable chunks, here is what I need to be able to do:   * Detect a "solid" red square   * Detect 4 squares within each other that are red,green,blue, and white    * Detect 4 squares within each other that are red,green,blue, and black  The last 2 would effectively be the same algorithm, as i would just change parameters. there's an variation on that theme, but it's not that relevant to the algorithm, i just means swapping the blue and green around, to detect the frame rate. **Solid red square** ![red square solid](http://i.stack.imgur.com/1wZKM.jpg) **Red square, a green square, and a blue square, white square:** ![enter image description here](http://i.stack.imgur.com/vhbKm.jpg) **Red square, a green square, and a blue square, black square:** ![enter image description here](http://i.stack.imgur.com/wyei2.jpg) The algorithm would need to be able to work independent of the previous frame, but would need to return the bounding rect of the red square in each case, for validation purposes. I could in theory attempt this myself, but what i am not sure how to handle is the fact the squares might not be exactly "level". aside from rotating the image multiple times by a few degrees, I can't think how to detect it accurately.


title: Hobbyist transitioning to earn money on paid work?

text: I got into hobbyist Python programming some years ago on a whim, having never programmed before other than BASIC way back when, and little by little have cobbled together a, in my opinion, nice little desktop application that I might try to get out there in some fashion someday. It's roughly 15,000 logical lines of code, and includes use of Python, wxPython, SQLite, and a number of other libraries, works on Win and Linux (maybe Mac, untested) and I've gotten some good feedback about the application's virtues from non- programmer friends. I've also done a small application for data collection for animal behavior experiments, and an _ad hoc_ tool to help generate a web page...and I've authored some tutorials. I consider my Python skills to be appreciably limited, my SQL skills to be very limited, but I'm not totally out to sea, either (e.g. I did FizzBuzz in a few minutes, did a "Monty Hall Dilemma" simulator in some minutes, etc.). I also put a strong premium on quality user experience; that is, the look and feel matters much to me and the software looks quite good, I feel. I know no other programming languages yet. I also know the basics of HTML/CSS (not considering them programming languages) and have created an artist's web page (that was described by a friend as "incredibly slick"...it's really not, though), and have a scientific background. I'm curious: Aside from directly selling my software, **what's _roughly_ possible--if anything--in terms of earning either side money on gigs, or actually getting hired at some level in the software industry, for someone with this general skill set?**


title: Object Oriented Programming: getters/setters or logical names

text: I'm currently thinking about an interface to a class I'm writing. This class contains styles for a character, for example whether the character is bold, italic, underlined, etc. I've been debating with myself for two days whether I should use getters/setters or logical names for the methods which change the values to these styles. While I tend to prefer logical names, it does mean writing code that is not as efficient and not as logical. Let me give you an example. I've got a class `CharacterStyles` which has member variables `bold`, `italic`, `underline` (and some others, but I'll leave them out to keep it simple). The easiest way to allow other parts of the program to access these variables, would be to write getter/setter methods, so that you can do `styles.setBold(true)` and `styles.setItalic(false)`. But I do not like this. Not only because a lot of people say that getters/setters break encapsulation (is it really that bad?), but mostly because it doesn't seem logical to me. I expect to style a character through one method, `styles.format("bold", true)` or something like that, but not through all these methods. There is one problem though. Since you can't access an object member variable by the contents of a string in C++, I would either have to write a big if- statement/switch container for all styles, or I would have to store the styles in an associative array (map). I can't figure out what the best way is. One moment I think I should write the getters/setters, and the next moment I lean towards the other way. My question is: what would you do? And why would you do that?


title: How does a large company make rookie mistakes which leave security holes?

text: Sony was recently hacked with a SQL injection and the passwords of their user's was stored in plain text. These are rookie mistakes. In such a large company, how does this pass QA? How do they not have better teams than to know better than this? The sheer size of the company that was hacked makes this different. It affects all of us because we all may one day find ourselves on a team that is responsible for something like this, and then we get the ax. So what are the factors that lead to this, and how do we prevent them?


title: Javascript based application controller in Javascript-less environments

text: I just got done watching an informative Box tech talk by Nicholas Zakas on a javascript architecture for web development: https://www.youtube.com/watch?v=mKouqShWI4o&feature=youtu.be This image, which I acquired from http://alanlindsay.me/kerneljs/index.html#nav-what , will give you an overview of the architecture: ![enter image description here](http://i.stack.imgur.com/oKTpl.png) However, to give you a brief summary and help you avoid mundane stuff, the Kernel is basically an Application Controller which makes up the C in the MVC. Now I obviously have to take care of the possibility of an environment where Javascript is disabled. I was wondering if that effectively meant developing an application controller in a language such as PHP and maintaining it in parallel to the one written in Javascript along with the ensuing commands/modules? There's something smelly about that, is there a better way to do this?


title: What precisely does "Applicative" mean in computer science?

text: I know what an "applicative Functor" is, but I've been reading papers recently that refer to other "applicative" things, particularly "purely applicative data structures". The trouble is, I'm not sure precisely what "applicative" means in this context, and Google has so far failed me. I can get a general English (ie useless) definition of "applicative", but as soon as I add "computer science" to the search all I get is definitions of computer science. I have a vague sense that this relates to keeping them pesky effects in their place, but I could use a precise definition. I found this - http://foldoc.org/applicative \- but I'm not sure "applicative language == functional language" really helps.


title: Are there any OO-principles that are practically applicable for Javascript?

text: Javascript is a prototype-based object oriented language but can become class- based in a variety of ways, either by:   * Writing the functions to be used as classes by yourself   * Use a nifty class system in a framework (such as mootools Class.Class)   * Generate it from Coffeescript In the beginning I tended do write class based code in Javascript and heavily relied on it. Recently however I've been using Javascript frameworks, and NodeJS, that go away from this notion of classes and rely more on the dynamic nature of the code such as:   * Async programming, using and writing writing code that uses callbacks/events   * Loading modules with RequireJS (so that they don't leak to the global namespace)   * Functional programming concepts such as list comprehensions (map, filter, etc.)   * Among other things What I gathered so far is that most OO principles and patterns I've read (such as SOLID and GoF patterns) were written for class-based OO languages in mind like Smalltalk and C++. But are there any of them applicable for a prototype- based language such as Javascript? Are there any principles or patterns that are just specific to Javascript? Principles to avoid _callback hell_ , _evil eval_ , or any other anti-patterns etc.


title: Design Patterns for Javascript

text: A lot of web frameworks have a MVC-style layout to code and approaching problems. What are some good similar paradigms for JavaScript? I'm already using a framework (jQuery) and unobtrusive js, but that still doesn't address the problem I run into when I have more complex web apps that require a lot of javascript, I tend to just end up with a bunch of functions in a single, or possibly a few files. What's a better way to approach this?


title: JavaScript application design patterns

text: I need to write a PhoneGap application with JavaScript and I'm thinking of the code design patterns. I've read some books of JavaScript design patterns but can't really see the advantages/disadvantages on them and I think I don't understand the implementation and usage right. I would like to have some opinions of which might suit my needs best. I'd like the code to be readable and maintainable. The application itself is quite small and simple. It has a player management (add/remove), a game management (add/remove players from a team, start/stop/reset a stopwatch). In last app I created I had over 30 named functions in a global scope which I think is a big no no. So, now I want to make things right, and was thinking of either using an object literal or a module pattern... something like this perhaps:               var MYAPP = {         init: function() {             $(document).ready(function() {                 MYAPP.bind();              });         },              bind: function() {             // Bind jQuery click and page events         },              player: {             add:            function(name) { ... },             remove:         function(name) { ... }         },              team: {             addPlayer:      function(name) { ... },             removePlayer:   function(name) { ... }         },              game: {             create:         function() { ... },             startTime:      function() { ... },             stopTime:       function() { ... },             resetTime:      function() { ... }         }     };          document.addEventListener('deviceready', MYAPP.init, false);      ... or perhaps this?               var MYAPP = {         init: function() {             $(document).ready(function() {                 MYAPP.bind();              });         },              bind: function() {             // Bind jQuery click and page events         }     }          var PLAYER = (function () {              // Some private variables         var privateVar, privateMethod;              return {             add: function (name) { ... },             remove: function (name) { ... }         };          }());          document.addEventListener('deviceready', MYAPP.init, false);


title: From Java to Javascript?

text: I am primarily a Java programmer. Because of its OO principles and the general paradigm of Java programming, like wrapping things in static variables, and having things return specific types, heavily aids me in "visualizing" a program. Instead of thinking of a big program, I can, instead, focus on smaller organized parts of my eventual program, and add functionality and build up from there. Thus, I have trouble programming in other languages. Or at least, I have not been able to program in the same ability as I do in Java compared to other languages. I know Javascript has OO principles, so I'd like to learn this language in a OO-based like I would program with Java. Is this possible?


title: Object Oriented Programming in JavaScript. Is there life without it?

text: At our company we have pretty large body of PrototypeJS based JavaScript code, which we are porting to jQuery for several reasons (not really important here). I'm trying to set up coding guidelines to make/keep things tidy during the porting. One observation from wading through the prototype based implementation is that a lot of code is written in OOP style (using Prototype's `Class.create`), but the code is not "object oriented" in spirit. The general pattern I've seen: one "constructor" which you are expected to call (but not call twice, because the constructor uses hardcoded DOM id's), a bunch of other "functions" and event handlers, which you are not expected to call (but the because there is no "private" in JavaScript, you don't know that) and data sharing between all these functions through `this`. Seen from the caller's point of view there is just one "callable" and nothing else. I'm starting to believe that _OOP in JavaScript can and maybe should be avoided_ in a lot of cases. At least for our use case, which is not the next generation Goole Wave UI, but simply put: a bit of AJAX based enhancements, registering some event handlers here and there, minor DOM manipulations and such.   * the functionality we need seems to be implementable just fine in the typical jQuery non-OOP way, using closure magic to obtain encapsulation and privateness. As side effect, the minification efficiency of the ported code is much better.   * OOP in JavaScript is non-traditional and confusing if you are coming from a "traditional" background. There are a lot of attempts and frameworks to approximate traditional OOP, but IMHO this makes things even more confusing and fragile.    * One thing that Crockford's "JavaScript the good parts" taught me, is that the true power of Javascript lies in function scopes and closures, much less in OOP patterns. I'm wondering if there is wider support for this feeling that OOP in JavaScript doesn't really cut it as the sacred mantra, like it is in other languages/platforms. And, in extension, what kind of non-OOP/closure based patterns are much more preferable.


title: Go with an object-oriented perspective

text: My OOP JavaScript question is at the very bottom if you want to skip my introduction. In an answer to  the question Accessing variables from other functions without using global variables, there's a comment about OOP that says: > If there's a chance that you will reuse this code, then I would probably > make the effort to go with an object-oriented perspective. Using the global > namespace can be dangerous -- you run the risk of hard to find bugs due to > variable names that get reused. Typically I start by using an object- > oriented approach for anything more than a simple callback so that I don't > have to do the re-write thing. Any time that you have a group of related > functions in javascript, I think, it's a candidate for an object-oriented > approach. That rings true to me from what I've seen some of my old OOP colleague. There are lots of different approaches and different voices leading in different directions. Since I am a front end developer and UI designer, I am a little confused. **Building up to the question** I've heard from a variety of places that global variables are inherently nasty and evil, when doing some non-object oriented Javascript, and that there are three choices available to make a variable from one function, visible and usable by another function, e.g., function A to be visible to function B; or, a variable of Function A to be passed and usable within function B.   1. make it a global   2. make it an object property, or   3. pass it as a parameter when calling B from A. I've read about namespaces, currying, and other approaches... **Question:** With that all said, I was wondering what's the best OOP structure or best code practice in JavaScript that keeps things encapsulated and adds greatest security from having your variables exposed to manipulation?


title: What is the best practice for method parameter validation in a library?

text: I develop a game library in javascript, containing many classes. I hesitate on the behavior that I should follow concerning method parameter validation: **Should I check the validity of parameters passed to each method ?** By example, when a method take only a number between 0 and 100 in parameter, should I check that the value is correct? I have dozens of classes, each with dozens of methods. For a simple getter, I can have more than half lines code only used for checking parameters. Add checks makes my code less maintainable, more heavy. Seeing that it's a library, destined to be used by many other programmers, checking parameters can avoid many mistakes and bugs, and would be a appreciated. So, how do other javascript libraries, handle this and what is the best solution?


title: I'm trying to figure out which functions from one C library are being used by C project. Does anyone have a simple solution?

text: To be specific, I want to know which function/types in libpri and being used in the Asterisk project. I'm not traditionally a C programmer, but I know some basic stuff because I took a class in college.


title: What is a good one-stop-shop for understanding software licensing information?

text: I've learned a fair amount about the various different software licensing models and what those models mean for my own software project. However, I'd like to make sure I understand as many of them as possible for making decisions on how to license my own software and in what scenarios I can safely use software under a licensing model. Do you have a good recommendation for a book/site etc.. that has this information in one location?


title: Maintaining a main project line with satellite projects

text: Some projects I work on have a main line of features, but are customizable per customer. Up until now those customizations have been implemented as preferences, but now there are 2 problems with the system...   1. The settings page is getting out of control with features. There are probably some improvements that could be made to the settings UI, but regardless, it is quite cumbersome setting up new instances for new customers.   2. Customers have started asking for customizations which would be more easily maintained as separate threads instead of having tons of customizations code. Optimally I am envisioning some kind of source control in which features are either in the main project line and customizations per customer are maintained in a repo per customer set up. The customizations per project would need to remain separate but if a bug is found and fixed in a particular project, I would need to percolate the fix back to the main line and into all of the other customer repos. The problem is I have never seen this done before, and before spending time trying to find source control that can accommodate this scenario and implement it, I figure it best to ask if anyone has something less complicated or knows of a source control product which can handle this with very little hair pulling.


title: What should I study to 'learn' Comp Sci?

text: [This question was originally asked on Stack Overflow, but recommended to move the question here.] I can't find anything quite like the question I'm about to ask, so please forgive me if there's something just like it already, please feel free to point me in the right direction. It'll take a bit of background explaining too, please forgive me for that. [backstory] Basically, I graduated from University about 18 months ago with a degree in Business Information Systems and Japanese. The Japanese took up half of the degree so the BIS was only joint. I only learned PHP in terms of languages and basically no computing theory - everything was vocational (Networking, programming basics, CMS development, Office and VBA and then loads of Business theory courses). Since this, I decided to teach myself C# and ASP.Net and try to get a position as a programmer. I created an online shop style website and a small CRM application in Windows Forms to both teach myself and build a portfolio, and luckily I managed to snag a developer position. Bad side? I'm the only developer at my company. Now don't get me wrong, in the last year I've learned loads and loads, I did some devpt. before Uni so knew the basics anyway, but it was very much a "learning from books" job - every night. Now then... I am now at a point where I'm building software on a regular basis, making good judgements for time scales, and have even been told my code and methodology are good by other professionals that have been in the game longer than me, and they have offered me jobs. [/backstory] What this whole thing boils down to, is that I now want to study up on the topics I'll have missed by not doing CS. More importantly, could you recommend books / free online courses? I want to learn about Computer Science theory, not just better coding. Thank you!


title: Organization of DLL linked functions

text: This is a code organization question. I got my basic code working but when I expand it, it will be terrible. I have a DLL which I don't have a `.lib` for. Therefore I have to use the whole `LoadLibrary()/GetProcAddress()` combo. It works great. But this DLL that I'm referencing has 100+ functions. My current process is: 1) Typedef a type for the function. E.g.: `typedef short(_stdcall *type1)(void);` 2) Assign a function name that I want to use such as `type1 function_1;` 3) Load the DLL, then do something like: `function_1 = (type1)GetProcAddress(hinstLib, "_mangled_funcName@5");` Normally I would like to do all of my function definitions in a header file but because I have to use the load library function, its not that easy. The code will be a mess. Right now I'm doing (1) and (2) in a header file and was considering making a function in another .cpp file to do the load library and dump all of the (3)'s in there. I considered using a namespace for the functions so I can use them in the main function and not have to pass over to the other function. Any other tips on how to organize this code? My goals are to be able to use `function_1` as a regular function in the main code. If I have to a `ref::function_1` that would be okay but I would prefer to avoid it. This code for all practical purposes is just plain C at the moment.


title: Release an open-source project under multiple licenses

text: Consider this license I wrote for my software:               Copyright 2014, [my name]          The author(s) of this software intends to provide the users with the     maximum amount of freedom. As such, this software may be used under     any one of the following licenses:          1. MIT: [link to the license]     2. Apache 2.0: [link to the license]     3. BSD 2-clause: [link to the license]     4. BSD 3-clause: [link to the license]          Or, it can be considered released into the public domain in jurisdictions     where this is possible.          In any case, the software comes with absolutely no warranty.      Do you guys see any potential problems with this licence, especially from a legal point of view? Does it succeed in providing the users with the maximum amount of freedom?


title: Why DbContext object shouldn't be referred in Service Layer?

text: I've been looking for some implementations of `Service Layer` and `Controller` interaction in blogs and in some open source projects. All of them seem to refer `DbContext` object in repository classes but avoided to use in service classes. Service classes essentially using a `IQueryable<T>` references of `DbSet<T>`. I want to know why this practice is good and why `DbContext` shouldn't have a reference in Service Layer.


title: What is the origin of the negative term "legacy code"

text: Everyone talks about legacy code in software development and I have heard the term over the last ten years used to paint any codebase as being bad. Where did this term, which has such powerful connotations to programmers alike originate? I am sure there must be some book on software development that pioneered this term. I would love to locate the origin of the term "legacy code".


title: Version control and project management for freelancing jobs

text: Are there version control and project management tools which "work well" with freelancing jobs, if I want to keep my customer involved in the project at all times? What concerns me is that repository hosting providers have their fees based on the "number of users", which I feel is the number which will constantly increase as I finish one project after another. For each project, for example, I would have to add permissions to my contractor to allow him to pull the source code and collaborate. So how does that work in practice? Do I "remove" the contractor from the project once it's done? This means I basically state that I offer no support and bugfixes anymore. Or do freelances end up paying more and more money for these services? Do you use such online services, or you host them by yourself? Or do you simply send your code to your customer by e-mail in weekly iterations?


title: Does the head of any linked list must contain any data

text: Is there any rule that says the head of any linked list should contain data. Is it because by doing it so we save a space for one node. Why for some implementation of head contains data and for other it doesn't.


title: Why does OCaml's (and F#'s) type inference algorithm need tagging functions as recursive?

text: From _Real World OCaml_ (beta): > OCaml distinguishes between non-recursive definitions (using `let`) and > recursive definitions (using `let rec`) largely for technical reasons: the > type-inference algorithm needs to know when a set of function definitions > are mutually recursive, and for reasons that don't apply to a pure language > like Haskell, these have to be marked explicitly by the programmer. Why is this the case (what is the technical reason, exactly), and why does a pure language like Haskell “get away” with not having to tag functions as recursive?


title: How do you get your product owner more engaged on agile projects?

text: During iteration retrospectives on agile projects, one of the topics that comes up most often for us is that the product owner is (or product owners are) not available or engaged in the project at a day to day level. It seems to be a common theme that customers are unwilling to "give up" the necessary amount of their product owner's time to the project, but instead have them answer questions via email, or during product demos only. This has the effect of increasing the length of the feedback cycle and making the project less effective. Have you had to overcome this hurdle? How did you do it?


title: Should a server "be lenient" in what it accepts and "discard faulty input silently"?

text: I was under the impression that by now everyone agrees this maxim was a mistake. But I recently saw this answer which has a "be lenient" comment upvoted 137 times (as of today). In my opinion, the leniency in what browsers accept was the direct cause of the utter mess that HTML and some other web standards were a few years ago, and have only recently begun to properly crystallize out of that mess. The way I see it, being lenient in what you accept _will_ lead to this. The second part of the maxim is _"discard faulty input silently, without returning an error message unless this is required by the specification"_ , and this feels borderline offensive. Any programmer who has banged their head on the wall when something fails silently will know what I mean. So, am I completely wrong about this? Should my program be lenient in what it accepts and swallow errors silently? Or am I mis-interpreting what this is supposed to mean? * * * The original question said "program", and I take everyone's point about that. It can make sense for programs to be lenient. What I really meant, however, is APIs: interfaces exposed to _other programs_ , rather than people. HTTP is an example. The protocol is an interface that only other programs use. People never directly provide the dates that go into headers like "If-Modified- Since". So, the question is: should the server implementing a standard be lenient and allow dates in several other formats, in addition to the one that's actually required by the standard? I believe the "be lenient" is supposed to apply to this situation, rather than human interfaces. If the server is lenient, it might seem like an overall improvement, but I think in practice it only leads to client implementations that end up _relying_ on the leniency and thus failing to work with another server that's lenient in slightly different ways. So, should a server exposing some API be lenient or is that a very bad idea? * * * Now onto lenient handling of user input. Consider YouTrack (a bug tracking software). It uses a language for text entry that is reminiscent of Markdown. Except that it's "lenient". For example, writing               - foo     - bar     - baz      is _not_ a documented way of creating a bulleted list, and yet it worked. Consequently, it ended up being used a lot throughout our internal bugtracker. Next version comes out, and this lenient feature starts working slightly differently, breaking a bunch of lists that (mis)used this (non)feature. The documented way to create bulleted lists still works, of course. So, should my software be lenient in what _user inputs_ it accepts?


title: Environment-aware Code

text: There are situations where the deployed environment ( **development** , **test** , or **production** , for example) might dictate the outcome of certain actions. For example, perhaps a successful "user registration" process will send a notification email to the new user. Environment-specific actions:   * **Development:** Do not actually send the email. Email logs will provide enough for developers.   * **Test:** Send all emails to some testEnvironment@domain.com inbox and not to the user's address.   * **Production:** Send the email to the user. I have listed three possible solutions below. ## **CurrentEnvironment configuration value** One way of solving this, which I have seen a lot, is to have some configuration value (whether it be in some xml config file or in the database) such as `CurrentEnvironment` which specifies the current environment in which the system is deployed to. This would require case/if checks in code to determine the desired action:               if(CurrentEnvironment == Environment.Test)     {         // Send all emails to some testEnvironment@domain.com inbox.     }     else if(CurrentEnvironment == Environment.Production)     {         // Send the email to the user.     }      This is not a maintainable solution in my opinion. ## **Wipe all email addresses** Another method is to run a change script, once restoring a database, to do the following:   * Remove all user email addresses (in development),   * Replace all user email addresses with testEnvironment@domain.com (in test) This is an extra step in the release process which, if missed, could have some dangerous results. Additionally, this solution only fixes the email problem. There are perhaps many other situations where the environment matters. ## **Config transformation** Another idea is to use web.config transformations. This way the config can be different for different environments. For example, we will have the following configs:                web.config        web.Development.config        web.Test.config        web.Production.config      The transformation can then use different "providers" or set certain attributes according to the environment. For example, an `overrideDeliveryAddress` can be set in the `web.Test.config`:               <EmailService>       <providers>         <add            name="EmailServiceProvider"           type="CustomProviders.EmailServiceProvider, CustomProviders"           smtp="smtp.domain.com" password="xyz"           overrideDeliveryAddress="testEnvironment@domain.com"           enabled="true"         />      </providers>     </EmailService>      This solution requires much more work, but is more maintainable and less invasive. Code is now environment-oblivious. What other ways can the above be achieved? Should code EVER be environment aware?


title: Is there a subset of programs that avoid the halting problem

text: I was just reading another explanation of the halting problem, and it got me thinking all the problems I've seen that are given as examples involve infinite sequences. But I never use infinite sequences in my programs - they take too long. All the real world applications have lower and upper bounds. Even reals aren't truly reals - they are approximations stored as 32/64 bits etc. So the question is, is there a subset of programs that can be determined if they halt? Is it good enough for most programs. Can I build a set of language constructs that I can determine the 'haltability' of a program. I'm sure this has been studied somewhere before so any pointers would be appreciated. The language wouldn't be turing complete, but is there such a thing as nearly turing complete which is good enough? Naturally enough such a construct would have to exclude recursion and unbounded while loops, but I can write a program without those easily enough. Reading from standard input as an example would have to be bounded, but that's easy enough - I'll limit my input to 10,000,000 characters etc, depending on the problem domain. tia [Update] After reading the comments and answers perhaps I should restate my question. For a given program in which all inputs are bounded can you determine if the program halts. If so what are the constraints of the language and what are the limits of the input set. The maximal set of these constructs would determine a language which can be deduced to halt or not. Is there some study that's been done on this? [Update 2] here's the answer, it's yes, way back in 1967 from http://www.isp.uni- luebeck.de/kps07/files/papers/kirner.pdf That the halting problem can be at least theoretically solved for ﬁnite-state systems has been already argued by Minsky in 1967 [4]: “...any ﬁnite-state machine, if left completely to itself, will fall eventually into a perfectly periodic repetitive pattern. The duration of this repeating pattern cannot exceed the number of internal states of the machine...” (and so if you stick to finite turing machines then you can build an oracle)


title: Pattern for Accessing MySQL connection

text: We have an application which is C++ trying to access MySQL database. There are several (about 5 or so) threads in the application (with Boost library for threading) and in each thread has a few objects, each of which is trying to access Database for its' own purpose. It has a simple ORM kind of model but that really is not an important factor here. There are three potential access patterns i can think of:   1. There could be single `connection object` per application or thread and is shared between all (or group). The object needs to be thread safe and there will be contentions but MySQL will not be fired with too many connections.    2. Every object could initiate connection on its own. The database needs to take care of concurrency (which i think MySQL can) and the design could be much simpler. There could be two possibilities here. a. either object keeps a persistent connection for its life OR b. object initiate connection as and when needed.    3. To simplify the contention as in case of 1 and not to create too many sockets as in case of 2, we can have group/set based connections. So there could be there could be more than one connection (say N), each of this connection could be shared connection across M objects.  Naturally, each of the pattern has different resource cost and would work under different constraints and objectives. What criteria should i use to choose the pattern of this for my own application? What are some of the advantages and disadvantages of each of these pattern over the other? Are there any other pattern which is better? * * * PS: I have been through these questions:   mysql, one connection vs multiple and   MySQL with mutiple threads and processes   But they don't quite answer exactly what i am trying to ask.


title: Refactoring sought for replacing shared data types in .NET component

text: I am in charge with updating a software product that is made up of two components the Controller process and the UI process. The Controller and the UI communicate via XML messages. Furthermore, the Controller is built on top of a shared library that implements a number of business flows. For builing the messages for Controller-UI communication, somebody decided to use .NET built-in serialization and deserialization and therefore created class types annotated with attributes that control serialization (XmlElement, XmlAttribute, etc) for each message, serializing it and deserializing it by using the default XML serializer. For the first couple of controllers, this was fine. But now, while some of the messages can be reused, the other cannot. They will accomplish the similar functions but are structurally incompatible with the information we need them to contain. Because this decision was made we are stuck with data-types that cannot model the data we need, and cannot be changed because they would break the other controllers. At the same time we need the functionality and messaging sequences implemented in the shared library. I need a way out of this conundrum, one that has the smallest technical cost in relation to changing the other controllers, I need a sort of "structural polymorphism" for these types, where the type is the same but its internal structure different. Perhaps these messages can be changed to 'object' data types, but in that case... I need a way to control from the outside of the shared library the casting that gets made inside the shared library. How do I approach this, I am not experienced enough to find a clean refactoring for this? I feel stuck. We are using .NET 4.5


title: How to fix legacy code that uses <string.h> unsafely?

text: We've got a bunch of legacy code, written in straight C (some of which is K&R!), which for many, many years has been compiled using Visual C 6.0 (circa 1998) on an XP machine. We realize this is unsustainable, and we're trying to move it to a modern compiler. Political issues have said that the most recent compiler allowed is VC++ 2005. When compiling the project, there are many warnings about the unsafe string manipulation functions used (`sprintf()`, `strcpy()`, etc). Reviewing some of these places shows that the code is indeed unsafe; it does not check for buffer overflows. The compiler warning recommends that we move to using `sprintf_s()`, `strcpy_s()`, etc. However, these are Microsoft-created (and proprietary) functions and aren't available on (say) gcc (although we're primarily a Windows shop we do have some clients on various flavors of *NIX) How ought we to proceed? I don't want to roll our own string libraries. I only want to go over the code once. I'd rather not switch to C++ if we can help it.


title: Loosely compare user input with database record

text: I have a database table with 3 columns; id, question and answer. On the front- end, I have a PHP application that shows questions to the user. The application would then compare the user input with the answer on the database. Using only PHP, how do I loosely compare user's input with the record on the database and pass it as correct even though it is not a strict match? For example:- **Question:** What is the structure of a water molecule? **Answer on database:** Hydrogen and oxygen **Acceptable answers:** Oxygen and hydrogen, hydrogen n oxygen, hydrogen & oxygen


title: Size of database a factor for Hibernate vs JDBC?

text: Do you know if the size of the database (number of tables used) is a factor when choosing between Hibernate and JDBC? Why or why not? In my particular case, I am evaluating Hibernate and JDBC for interacting with Oracle database for a small web app.