Does designing a method that changes the argument's (if was object) values a good practice?

The premise is using a language (e.g. C#, javascript) which passes an object by reference into a method. Assume there is an object "Player" which has a property "Level" and there is a method takes Player as parameter and its function is to increase the player's level by 1. The method can be designed something like (c# syntax):               void AddLevelBy1(Player player)     {      player.Level +=1;     }      The concern was this method changed the value of the argument and I could not find a generic way to indicate (or may prevent?) this. One might get some hints from the method name "AddLevelBy1". But such a way is not reliable and if the method was name "foo" then it becomes even more ambiguous. So is there a solution / convention for this case (indicate whether arguments get changed)? Or such method design was considered a bad practice? **Added:** Try to describe my case more clearly:   1. I have an object "Player" which was not defined by myself (cannot change).   2. I wrote a method (AddLevelBy1() in this example) which takes "Player" as parameter (I know what happened).   3. I also pass this "Player" to some other methods (e.g. foo()) which were not written by me (so this is no way to know whether the "Player" got changed). Thanks for some answers below but what if the codes were designed in the manner I described above. I have added a demo of the case I described: http://jsfiddle.net/54sun/srhHt/9/


can a software be an ERP and CMS simultaneously

I was reading about CMS and ERP. And got confused at this point that whether a system can both be an ERP and a CMS? is it possible?


How do programmers deal with low level software development in high level languages?

I am somewhat new to programming and the best way I can ask this question is with an example. I know how to do basic things in Java and C#. Things like a small windows forms application or make a generic class. I've basically been learning and haven't tried to do anything big yet. Anyways, I've always been curious about how things are done "under the hood" I guess you could say. I know it all gets boiled down to 1s and 0s and that assembly languages basically give commands to patterns of 1s and 0s, but its seems like there's this jump from there to: use a library for this a library for that. It seems to me like all C# can do without a library is arithmetic and binary logic. To get input or output, you use libraries, etc... I know this question probably seems obvious to some and I know that I have a lot to learn but I don't even know where to begin with a question like this. Thank you. So my question is this: > If someone were going to make a virtual machine or a Playstation emulator, > or an operation system, or a driver, or add mp3 support to a media player, > or make your own file type, etc... How? I can't see the way that would be > done with C# or Java. In other words, if I read a book like Professional C# by WROX or Programming C# by OReilly, would I know how to do these things? Or do you have to learn assembly language or something more low level like C++?


Is there a web-specific reason for the design choices behind the JavaScript language?

With the advent of "the web is the platform", JavaScript is fast becoming the most widely used programming language in the world. However, many tasks that are easy to accomplish in other modern languages are difficult or puzzling in JavaScript, because the language design is so "unique":   * JavaScript has a **prototype-based OOP system** ; most other modern languages have an inheritance-based one   * JavaScript has such a **weird typing system** that it doesn't fall into any of the standard categories (plenty of examples on WTFJS)   * JavaScript is **extremely lenient in how it parses the syntax** (semicolons are optional etc.) From a developer's point of view, most of these design decisions make developing in JavaScript harder. Conceptually, the JavaScript language seems one step behind Java, and two steps behind Python and Ruby. But since I don't believe that the people behind JavaScript are striving to create a language that is difficult to use, I can only reason that those design points must have something to do with the intended use of JavaScript as a scripting language for web sites, deeply connected to the DOM. **How (if at all) do these design points cater to the intended use cases of JavaScript? What reasoning is behind those seemingly random design decisions?**


How to link the data of MongoDB and Neo4j?

I want to implement a system which store the profiles of employee and the resources that they have. There are many types of resources, such as the documents they produced, the techniques they have...etc. I store the properties of nodes and relationships on MongoDB, and only store the relationship on Neo4j. But I face a problem, how could I link these two database? For example, when I want to find A's friends who get JAVA license in 2012, I have to find the id of people on MongoDB, and use this id the find the friends on Neo4j, and then I have to check who have JAVA license in 2012 on MongoDB... I think it is very complex and have some performance issue, how could I solve it? The probable solution I think is storing data both on MongoDB and Neo4j. When I want to do complex search, I can only use Neo4j. The point of having properties in Mongo is that it has better performance on search by properties, and I think it is better to manage data on MongoDB.


Methods for structuring JavaScript SDKs

I've built a REST API and have been using Backbone models throughout a couple different applications to communicate to it. I would really like to build a single JS SDK that can be used in any application that contains that reusable code. I have started by creating an npm, bower, and component.json so that it can be easily installed. From what I can gather the goal is to create a single object attached to the `window` for access within other applications. At which point everything in is encapsulated. I have a couple questions and concerns:   1. Is there anything I need to avoid to prevent conflicts with other libraries?   2. How do I handle dependencies? Should I encapsulate them or let the user know they have to add it?   3. Are there any methods of structuring SDKs that provide similar benefits to, say, MVC within a web app? **NOTE:** If this is question doesn't follow the guidelines for programmers.stackexchange.com please provide guidance on how to change it rather than just closing it. Thanks much.


Are all race conditions worth fixing?

I just wrote the following piece of code (in delphi):               procedure Update(Value: Integer);     begin       // If the last update was yesterday, replace yesterday value       if CompareDate(FLastUpdate,Now) <> 0 then       begin         FYesterdayValue := FTodayValue;       end;       FTodayValue := Value;       FLastUpdate := Now;     end;      And I realized that it contains a small, but real race condition. Imagine that the first time the "Now" function is called it's one millisecond before midnight, the if-statement is skipped and the timestamp is updated with another call to "Now" which is now one millisecond AFTER midnight. Now the timestamp has the wrong value and the FYesterdayValue will not get the correct value. In practise, I think the chances of this ever happening is almost non existent because a) the code is typically called ~1 / minute and b) the cpu time between the two call will be EXTREMELY small. However it's a bug and I'm curious if you would fix it if you stumbled upon it in a project.


Are there any contracting agreement templates online?

Contracting is fairly common, so I imagine that there's some pre-fab templates for software contracting agreements out there. I'm looking for one that I modify for my needs, pass through my lawyer and supply to clients. Does anyone know of any resources available?


Is it a good idea to use Twitter Bootstrap 3 for production?

So in the past few weeks I was introduced to Bootstrap 3-RC1. I made some web sites using it, and I actually enjoyed it. Then, recently, I discovered Twitter Bootstrap has already released version 3-RC2. It makes me wonder if it's okay for me to use Bootstrap RC2 for production now? Is it wise if I used it considering it still in RC phase or should I just wait for the official, completed version 3?


Contractor vs Consultant

For a programmer, two of the most common terms that seem to be overloaded are contractor and consultant?   Is there a difference between the two?


Methods to identify and resolve memory leaks in the JVM

As the data is migrated via the object level, there has been a slow upwards trend in memory usage. I can see the periodic gc activity, but the memory trend is still going up slowly. I have currently for my application set the starting and max heap at 14GB in production, however if we might need a large data set, my concern is the we will eventually hit the limit and then the application will slow down (which was what happened). What are some effective ways and proving strategies to help identify and remedy a potential memory leak in a running Java process?


Twitter Bootstap: Backwards compatibility?

I work for a university Digital Services team. Our university's main website uses the Ektron CMS (I have my own thoughts about this, but that's irrelevant). Because we maintain a university website, we need to make sure our website is extremely backwards compatible. We are trying to make a decision as to whether Twitter Bootstrap is conducive to what we're trying to do. Upon review, I've found that Bootstrap uses the CSS preprocessor "*Less Css*". We're currently using *SASS*, which we compile via terminal using Ruby Compass. The downside I'm wondering about while using *Less Css* would be that it compiles using Rhino and Node.js. Would this create issues because   1. Less CSS uses Node.js to compile; if someone does not have js enabled in their browser, will it not display the CSS?    2. the CSS has to compile each time a page is rendered, will it slow down a pages load time? What is most appealing to use is the grid system/glyphs/ and js plugins that comes with Bootstrap, which is good because we often have to create new content for events and other things happening in the university. However, it's extremely hard for us to give up cross compatibility. What are benefits of Bootstrap?   What are draw backs of Bootstrap?


Beginning Data Mining

For simplicity, my database has entities and transactions. Each transaction has a DateCreated and a foreign key to the entity. I'd like to have the ability to find entities that have had a recurring number of transactions within a close time proximity of other entities. Simply, if entity A has had a transaction within 10 minutes of entity B, 5 different times. The more I research on this topic, the more confused I'm becoming. I ran through the Data Mining Algorithms and their AdventureWorks data mining tutorial. I _think_ I need a clustering approach. Mostly I'm looking for guidance on how this type of problem is typically approached. In the end, my goal is to allow the user to select X minutes and Y occurrences, and display the result data back to them. If I can offer any more information please let me know.


What is the best way to manage Hibernate sessions in a Struts-1 application?

I am now the owner of a Struts-1 application, and the Hibernate session management is all over the place. I have searched online documentation but have not found a clear explanation of the best way to manage Hibernate sessions in a Struts application. Presumably a Hibernate Session should be created (or fetched) at the start of each action, and a transaction opened, and then the transaction committed or rolled back at the end of the action. Is that correct? How can this be managed for all actions without duplicating code in each action? Should each Action fetch objects from the DB, call model functions, and then save the objects, ala Ruby on Rails?


C++ GUI Design & Programming

I am familiar with the basics and fundamentals of C++ and now I would like to move on to designing and coding GUI features of it, interactive dialogues, etc... like VB or Delphi Where do I start (self teaching text book, online tutorial)? Thanks


Web-Development preparation and entire project workflow

I work as a lone programmer on web-development projects(front and back-end) - I have completed a couple of projects, so I'm fairly new at this, I have read and tried a few approaches and reached a way of going about them. The question and my description is fairly long so please be patient. What I am looking for, is :   **1.** Preparation/Planning that would be typically done before you start development, once you know exactly what needs to be built.   **2.** From your experience please give me feedback/suggestions on the process I follow currently.   The clients I work with are generally startups and have limited budgets so I can't charge them on a per/hour basis(I think that is how large companies usually bill their clients[on man/hours] for development projects) and have to work with a fixed budget. **This is the process I currently follow :**   **1.** Gauge the scope of the project and try to understand what they are trying to accomplish in a couple of meetings.   **2.** Give them a rough ball-park figure with a quotation that describes in general what they expect to get from the project, I try to be specific about features, but, I'm not putting too much time into this because I know the client may just be asking around for quotes, and not actually convert.   **3.** I follow Jeff Atwood's suggestion for payment & work :   **15%** payment - Upfront before starting any work   During this phase HTML mockup of the end website is made, a flowchart(with yEd) describing the website in as much detail as possible and a document that mentions other features that are not there in the flowchart. This is done by going into all the details of the project and finalizing the bits that will fit in and stuff that is too much work to implement for the agreed price. Because specifics are not discussed earlier, portions of these are also more or less a negotiation on what they will actually get. Because this is a fixed budget project, there needs to be fixed requirements, else, my price keeps going down as more features are added.   A color scheme, design wireframe and design PSD is also finalized.   **35% payment** \- Start Development   The project is fixed, begin development. I Host the site on my server, where the client can access the front-end, but, doesn't have access to any code.   **30% payment** \- Shift code to client's server/give client the server access details   Make the site live.   **20% payment** \- Couple of weeks after the site goes live, once all the bugs have been fixed.   * * * **Questions :**   **1.** Once you know exactly what you are going to build, what sort of planning would you do before you begin coding?      **2.** From your experience, what parts of the whole process would you do differently?


Where to publish articles about open source?

I've been developing a free, open source Java database abstraction project (jOOQ) and I have released first stable releases from November 2010 onwards. Feedback has been quite good and constructive, and I am very motivated to continue my work. In the mean time, to get more attention and feedback, I have published articles on   * http://java.dzone.com/   * http://www.theserverside.com/   * http://www.infoq.com/ (they didn't publish my article, though) These are some sample articles so you know the type of article I want to publish:   * http://java.dzone.com/announcements/simple-and-intuitive-approach   * http://java.dzone.com/articles/2011-great-year-stored What other resources would you recommend? Where else should I publish, knowing that   * I want to reach Java/SQL developers and architects / technology decision makers   * I can publish in English, German, French   * I think that my project is suitable for both beginners and pro's (in Java and SQL, or programming in general)


JAAS - What is the required control flag used for?

The Java Authentication and Authorization Service (JAAS) defines that if a login module has the flag "REQUIRED", the authentication should proceed down the login module list on success or failure, and that the module is required to succeed for the overall authentication process to succeed. The question is: What could this flag be used for? Since the login module is required to succeed, why does the authentication process need to continue down the login module list when a REQUIRED module fails to authenticate a Subject?


2D movement of an object based on speed and new vector

I am writing a small game where a sea vessel (like a battleship) can be moved in a 2D place based on orders that it receives. I wanted to know if someone can help direct me to a post or example code that will help me move a ship from one location to another based on the speed and new vector. So, if I had a ship that is moving in a south westerly direction (say 120 degrees) and it receives new orders to turn to a new vector of 020 degrees, how can I calculate the turn. I don't want it to just turn on a dime and head in the new direction. I want it to make the wide turn (as if it were in water) and then when it reaches the new vector, start heading in that direction. Any help would be appreciated.


Jira Agile how to specify what branch or version a improvment or story goes in

First off this is a copy of my post on pm exchange PM Post. I believe that board is very new and I would also like input from my fellow developers that may not be watching the PM boards. Pasting the other message below. Thanks guys! ..... How do you handle telling your developers where to put the change wether it be a bug or new feature using JIRA? Here is why I ask... For Issues/Bugs I think the use of the Affects and Fix version fields are a no brainier if fix version is 2.5 I know the code needs to go into the 2.5 branch. However to me the wording at least doesn't fit these fields for stories and improvements. An improvement could affect a future version but it doesn't "Fix" something. Using the fields differently between bugs and improvements seems like a bad idea too? I think this would be confusing to the users? Here is an example of what I mean Bug/Issue: set Fix version to the versions you want this bug to fix. Story/Improvement: set the Affects version to where you would like this new feature to go. For both of these scenarios you are saying where to put the code. Using different fields... and if you want to start spelling out WHERE the bug exists (version 1 and 2 but not 1.5) you then use BOTH fields for a bug and one differently for an improvement.


In-process SOA?

Can DI/IoC be used for a simplified, local SOA? I have been reading up on SOA (examples: here, here and here) and it seems that at first a lot of the attention was at interoperability and enabeling distribution of tasks by using standard message-formats and transfer-protocols (web- _services_ ). Later the crux has been to achieve loose coupling: To find principles for partitioning business-logic, manage dependencies and how and when to share data between parts. Is this a correct description? How is this related to DI/IoC? For a system with low performance requirements would it be a simplification to use DI as a "message broker", and asynchronous events to do "pub/sub" and only break out a service and go across an ESB or such as required by integrations?


Creation of an Assembler

I've always been interested in how programming languages are created, so for the past 8 months I've been researching, practicing and more about the creation of compilers. I've been able to quite easily write front ends for languages and withing the past couple months have been reading more about the back end pieces of a compiler. On top of this I've been reading about and practicing things with the x86 instruction set. It has been my dream to write a compiler and I would like to make my first big step of understanding back ends, this being attempting a simple x86 assembler. My goal for this is to learn more about code generation, x86 instruction set, executables and figure out the best algorithms and techniques (don't answer anything about the front end, I have this down lol). Eventually to be satisfied in my progression I would like it to output an executable for my platform (Ubuntu Linux amd64, ELF executable) written in the assembly language. This is a daunting task, though I feel I'm ready with some blood, sweat, and tears. So, my question is: what and in what way does my assembler need to do things? I know it needs to process the actual source, the what? From all I've gathered after processing the source I need to, write out a ELF header and then output the generated x86 code after this correct? I can't find much in depth information on how the x86 code is stored in the executable or even relocatable object files. I know there's sections of some sort but I can't find out how these are expressed, and what they're for. Anyone willing to answer any of these questions or point me in the right direction is awesome, I've been working on this a long time.


Moving from VS 2005 to VS 2010 what to learn for web apps?

Just moving from Visual Studio 2005 webforms to 2010. Bit confused of lately about what to learn on the new version. I will just be doing web applications only   1. Should I learn entity framework or MVC framework for my new applications moving from simple webforms?   2. What would you guys advice to learn as top priority moving to Visual Studio 2010 which will benefit me the most?


How to see what parts of your java code are run most often?

I would like to be able to see what code in thousands of lines of source code is run most often and takes the longest. The purpose of this would be for optimization. Being able to see what parts of the code are run most often is important for optimization, because those parts are where I should focus to speed up. At the same time of course, some code is run very often but takes virtually no time, so its also important to be able to see what code takes the longest. I guess the best of both worlds would be a program that adds up the amount of time a piece of code takes, including ALL of the times it was run (therefor figuring out what slows down your code most overall). Is there a kind of tools for this?


Design pattern for a multi-threaded URL fetcher in java

I'm looking for hints and suggestions on a design for a multi-threaded URL fetcher in java. Specific requirements are:   * To fetch each one of around 1,000 URLs periodically   * The interval between each fetch will be URL specific   * Intervals are likely to be 2 mins to 1 hour I'm imagining I will need a bunch of fetchers each running in their own thread that get pushed the next URL to fetch when in a "ready" state. I will need to handle errors, e.g quit querying a specific URL if it repeatedly times out or 404s. Any ideas much appreciated. Thanks


What is dependency Analysis and how is it done?

I saw this in a job posting for an ASP.net developer. "An understanding of basic software development practices such as ...and Dependency Analysis." I read the wikipedia entry for Dependency Analysis and understand that it basically means one thing depends on the other so you can't reorder or parallelize them. What does this mean in practice? Is there a tool that is used to do a Dependency Analysis? What should I know about it for an interview and in practice if I get the job?


Are there any scientifically rigorous studies of coding style principles?

Is a coding style principle - e.g. the single-exit principle - really a good thing? Always, or just sometimes? How much difference does it really make? Whatever your opinions, these are obviously subjective questions. Or are they? Has anyone attempted to make an objective, scientifically rigorous study of coding style principles? I can't imagine how anyone would do a double-blind study of readability, but maybe double-ignorant might be possible - use students who don't know about the principle being studied as subjects, and non-programmers to administer the study.


How does css3 hardware acceleration work?

Can anyone tell me how some css3 code (transitions/transformations) get hardware accelerated? In other words, what actually happens when the browser sees css3, what is the pipeline/process involved?


Backend programming portfolio

For most of my development years I have been a _Java backend developer_ , mostly for web applications. Usually for regular jobs I have described my duties in previous ones during the interview, expanding what's on my resumé. Now for a possible freelance job I was asked for a portfolio, and then we'd have the interview. Never done it before, I'm in doubt of how to do it, as putting in written form requires quite a lot more of thought:   * Should I use **UML diagrams** to describe what parts of the project I've worked on? Besides having to learn UML, I have two issues here: having to remember the exact work from several years ago, and wondering if I can get into trouble for displaying internal parts of systems not owned by me. Those UML diagrams should be, low level (sequence diagrams) to high level (application architecture, or class diagrams). The frameworks I used on those jobs is already on my resumé.   * Should I link to the resulting web sites? Like, _go to that site, create a user and then do the following actions_ , and you'll see what parts I've worked on.   * How do I show the parts of my job that don't involve coding? Like leading other people, managing a project, testing, running scripts, checking the database that everything is ok, etc.   * Also, sometimes I had to do frontend development, using Javascript. I've read other questions regarding portfolios here, from which I got that I have to avoid putting my open-sourced pet projects on my resumé, unless they are popular and widely used (which they are not).


How do you demonstrate performance in paired-programming environments?

Performance reviews have come up recently at my work, and I was put in an interesting position. Our team does a lot of pair programming, which has a tendency of averaging out the skill differences between team members (especially considering we rotate pairs). Generally, when doing performance reviews, you look back at the work you've done, and demonstrate what you've accomplished, and how you've exceeded expectations to try to negotiate a raise or other benefits. How do you demonstrate (or even measure) individual performance in an environment like this?


How do I subcontract with another programmer?

Another programmer wants to subcontract me to write, test, and document code. If anyone has nuggets of wisdom they could share regarding the business arrangement, I sure would appreciate the advice. My present plan is to go through specification and break it down into fixed-price deliverables, with the definition of "done" being passing the pre-specified test.


Why do people think SOAP is deprecated?

While browsing SO today I found this question here and it starts with this: > Sure, you're gonna tell me that SOAP is depracated and all, well i'm forced > to use it Found lots of statement like this one on SO up till now, this one just triggered me to ask this question. REST has its uses, SOAP has its uses, in some places they intersect as functionality but they are not replaceable to one another. So I wonder, why do people think SOAP is "deprecated"? Is it ignorance? Complexity of SOAP and WS-* specs? REST hype? What? If you think SOAP is deprecated please tell me why. I'm curious!


Is constantly looking for code examples a sign of a bad developer?

I am a CS student with several years of experience in C and C++, and for the last few years I've been constantly working with Java/Objective C doing app development and now I have switched to web development and am mainly focused on ruby on rails and I came to the realization that (as with app development , really) I reference other code way too much. I constantly Google functionality for lots of things I imagine I should be able to do from scratch and it's really cracked my confidence a bit. Basic fundamentals are not an issue, I hate to use this as an example but I can run through javabat in both java/python at a sprint - obviously not an accomplishment and but what I mean to say is I have a strong base for the fundamentals I think? I know what I need to use typically but reference syntax constantly. Would love some advice and input on this, as it has been holding me back pretty solidly in terms of looking for work in this field even though I'm finishing my degree. My main reason for asking is not really about employment, but more that I don't want to be the only guy at a hackathon not hammering out nonstop code and sitting there with 20 Google/github tabs open, and I have refrained from attending any due to a slight lack of confidence... Is a person a bad developer by constantly looking to code examples for moderate to complex tasks?


Is reading+modifying existing code better than making your own?

I'm an inexperienced programmer. I have been assigned to develop a Firefox plugin with no prior experience. So I followed the tutorial at MDN. I learned so many things, it's exciting and overwhelming at the same time. When I finally started programming, I ended up using extension the tutorial gave me, and modify it. And after realizing there are tons of code out there which pretty much does everything my extension has to do, I ended up analyzing these codes and implant them to mine with some modifications to suit my own needs.... So yeah, basically what I'm asking is: Will spending a lot of your time observing people's code and modifying them instead making my own improve my skill as a programmer in general?


Does searching documentation and samples look bad?

I am starting a new job in a company with many developers and media people, the layout of the place is open with computers around a skinny oval, I have worked in small teams and programming embedded C, the jobis for objective C I'm still in a medium stage, so I know what I don't know (haha), that means I have to google it and then implement it, So the question is how bad does it look if the guy next to you does lot of searching for coding I mean, at the end of the day I will get the job done, but want to look professional too!


Am I copy/paste programmer?

When ever I am stuck with a particular problem, I search for a solution in Google. And then I try to understand the code and tweak it according to my requirement. For example recently I had asked a question Reading xml document in firefox in stack overflow. Soufiane Hassou gave me a link to w3schools, where I found a example on parsing xml document, I understood how the example works, but I copied the code and tweaked it according to my requirement, since I don't like typing much. So does this make me a copy/paste programmer? How do you say if a person is a copy/paste programmer ? Thanks.


Is Googling every code a bad practice?

I just came from an interview in which they asked me several questions about programming and problem solving. Regarding the programming questions, I asked them to let me Google so I can see the code (I quoted that logic is the thing to learn, not the language). At the end of the interview they told me that my skills very good but what would I do if Google has been blocked around our country(It can happen in Pakistan, Youtube is yet blocked). Is it really that a programmer should know the code too?


Am I required to memorize coding in a work space or can I fall onto references to provide me edge to finishing my development?

I would like to know if I am expected to memorize coding in a workspace or am I allow to fall into references whenever I am unsure. In a week of non-stop self learning, I feel I can understand the basics html and CSS, but am I required to memorize every single code once I get a position in this field or is it fair to use references to provide you the edge to finish your development. I was always under the impression you had to hand- code everything but I am wondering if I'll be looked as less of a developer if I fall to references. Understanding that if I do memorize most things, it will save me the time it will take me to code something but I don't want to feel penalized if I need to refer back to a code because I need refresh myself. This Programmers question held a lot of good answers, but they don't quite fit for me. My role is as a graphic designer/illustrator not a developer, and I am still relative new with how the process works. I'll definitely like a strong input to make sure I go along the right path in my learnings Because HTML and CSS are just a starting point, I want to excel in other areas as well. Thanks for taking the time to read my post. P.S (if you have any other additional references or advice, I'll gladly appreciate it)


Programmer performance

I am a PHP programmer with 1 year of experience. As I am just starting my career, I am learning a lot of things now. I can say I am a little bit of a perfectionist. When I am assigned a problem I start off by Googling. Then, even when I find a solution, I keep trying for a better one until I find 2-3 options. Then I start learning it and choose the best performing solution. Even though I am learning a lot, this process gets me labeled as a low performer. My questions:   1. As a novice, should I continue to use this learning process and not worry about my performance?    2. Should I focus more on my performance and less on how the code performs?


What has been your experience with commercial third-party libraries?

I am thinking of purchasing an Infragistics library for a project I'm working on, but I've never used a third-party library in my code before. Is it something you would recommend? Have you ever had any problems with them? What should I watch out for?


Is there a kind of programs to illustrate most features and usages of different programming language?

We all know “The quick brown fox jumps over the lazy dog” used as benchmark for printing and fonts. I wonder if there is a similar “Lazy Dog” for Programming Languages. There are so many different programming languages, with all kinds of features and syntaxs, similar or different. The problem is: the user will be confused when using different languages at the same time. Although plenty of differences between different languages, there must be something in common, i.e. a task or routine. If we implement the same task in different languages, and try to cover most frequently used features, then the language learning or comparison will become much more easy. This kind of programme doesn't need to be very long, just like a tutorial but be common and abstract enough. Does it exist?


@staticmethod vs module-level function

This is not about `@staticmethod` and `@classmethod`! I know how `staticmethod` works. What I want to know is the proper use cases for `@staticmethod` vs. a module-level function. I've googled this question, and it seems there's some general agreement that module-level functions are preferred over static methods because it's more pythonic. Static methods have the advantage of being bound to its class, which may make sense if only that class uses it. However, in Python functionality is usually organized by module not class, so usually making it a module function makes sense too. Static methods can also be overridden by subclasses, which is an advantage or disadvantage depending on how you look at it. Although, static methods are usually "functionally pure" so overriding it may not be smart, but it may be convenient sometimes (though this may be one of those "convenient, but NEVER DO IT" kind of things only experience can teach you). Are there any general rule-of-thumbs for using either staticmethod or module- level functions? What concrete advantages or disadvantages do they have (e.g. future extension, external extension, readability)? If possible, also provide a case example.


Storing data in 2 different systems/database structures

My company is an online retailer, and we use an homebrew ecommerce platform. In the last year or so, we've partnered with a accounting software vendor, as our homebrew solution was unable to produce reports as needed, or otherwise satisfy the requests of banks and investors. We're off to a rocky start with the software, but I'm wondering if it's our approach. Currently, we store a complete set of data in the database connected to our ecommerce platform. Nightly, we send the necessary API calls to sync our entities in the accounting software (orders, POs, invoices, etc), and each morning, I've created scripts that validate that the data is correct between the two systems. This collective system has been a nightmare, as any minor chages to the ecommerce platform cascade in violent and horrible ways to system B. It's resulting in a TON of work on my part to make corrections on a daily basis. Is there a correct way to approach this problem? Or does the problem really lie upstream, in our decision to duplicate the data between the two systems. Has anybody successfully done something similar? It has been a non-stop fire drill for 3 months now, and any advice would be greatly appreciated.


Use Dependency Injection For Data Objects?

I'm just learning about dependency injection, and am stuck on something. Dependency Injection recommends sending dependent classes through the constructor, but I'm wondering if this is necessary for data objects. Since the Unit-Testability is one of the main benefits of DI, would a data object, that only stores data, and not any procedures ever be unit tested, making DI an unnecessary layer of complexity, or does it still help in showing dependencies even with data objects?               Class DO{         DO(){             DataObject2List = new List<DO2>();         }              public string Field1;         public string Field2;         public List<DO2> DataObject2List;     }          Class DO2{         public DateTime Date;         public double Value;     }


Would it be realistic for an amateur programmer to obtain a CS degree in 2~2.5 years at a state university?

Would it be realistic for an amature programmer to obtain a CS degree in 2~2.5 years at a state university assuming time and money is available?


J2EE - Field level Role-based security for a complete web application

I have a complex website designed using Spring MVC and MyBatis. User Interface is very complex and we have lot of custom made widgets - calenders, lists, graphs etc. If we were to implement field level role-based security what are the options available both from front-end and back-end perspective?


License: free to use but not free to modify or redistribute

I am releasing an application at no cost, but I am not granting users the right to modify or redistribute the code. How should I call this? I initially used the term "free license", but on second thoughts I find this confusing because free can have several meanings, and in people's mind it is often associated with open source. Is there a better terminology for my case?


How do you handle minor change in source code causing discontinuity in version tree?

For instance, I have a file with poor indentation (at least incoherant with the rest of the project). If I correct the indentation and commit, there will be a serious change in the file at a certain point in time, causing the diffs between versions before and after that serious change to be hard to read. How do you handle that king of minor logical modification causing major diffs ?


How do I refer to the smallest possible non-zero value?

Back in my C programming days I thought there was a constant or function (I can't remember what it was called, let's call it `SMALL`) whose value was the smallest possible positive value. (Imagine the LSB=1 and all other bits = 0.) It was used to avoid a divide by zero error. For example, let's say you want to compute `z = x/y`. Then you could calculate   `z = x / (y + SMALL);` Is there a built-in function in MS EXCEL that implements `SMALL`? For that matter, does it exist in C/C++ or am I going crazy?


Young career with job offer - keep current job or leave for new one

I recently interviewed for a position at a large Fortune 500 company at the recommendation of a friend. Yesterday, they made me an offer for 55k. I currently work at a small, 35 person company making 50k. I interned there for six months, and was converted officially to a full time employee a year and two months ago (I worked full time as an intern but had no benefits). Pros about the company I'm currently with:   * Small, I can talk to the boss directly or pull him aside whenever   * Wide array of responsibilities - I can go from doing .Net development to working on a database at any given time. May program one minute and talk to our customer for clarification the next.    * Very comfortable. I love the people I work with. We get a lot of awesome small benefits that would come with a small company. Family atmosphere - very close to who I work with.    * Excel at the job. I do what I do very well. There's a future in terms of job security.    * Passionate. I love what I work on - aeronautics. I find it fascinating. The big company works with trading stocks, and I have no care for that field at all - I fear I'll get bored because of that.   * Vacation hours. 24 vs. 12 at new company. Pros of big company:   * Work alongside two great friends. They have personally attested to really enjoying the job.    * Better pay, better benefits.    * Much more accelerated skill set development. Where the small company lets me flex a wide array of skills, this company will ultimately make me a better programmer, as I feel that I'm not quite learning as much as I should - they aren't entirely up to date on some higher level programming concepts.    * Recognizable name may get foot in the door later for better jobs elsewhere. The decision has me wrecked. I'm not quite sure what to do. Advice? I don't plan on staying at the small company forever, as I'd like to go somewhere that pushes me harder and allows me to learn a lot, but I'm just not sure if this is the place I want to jump to. Should I, or should I keep looking?


What do you put in the "Computer Skills" section of your resume?

> **Possible Duplicate:**   >  At which point do you "know" a technology enough to list it on a resume I'm having trouble selecting exactly what to put in the computer skills section of my resume. I feel the need to list a lot of languages and the IDEs I work with, and perhaps mention that I use Mercurial too. But this seems, well, kinda fake; after all, where do I draw the line in the list of languages? Sure, I learned a little C in a class, I can conquer some simple printf and getchar projects, but I don't really think that counts as being able to list it on my resume. I seem to recall Joel or Jeff addressing this but I can't find it now. But I'm pretty sure they said something along the lines of don't put it on your resume if you don't want to be drilled on it. Well, I sure wouldn't want to be drilled on C... But is there no justification in my listing languages like C# that I don't work with daily but could pick back up after a short refresher? I mean, I wouldn't want to be drilled on the internals of .NET either, but I think I am justified in listing it in a list of languages I have used... How do you decide? What do you have in your 'Computer Skills' section of your resume? (and can you please find the Joel/Jeff posts I'm thinking of, if they exist?)


How much should I know about Hibernate before I add it to my CV/Resume?

> **Possible Duplicate:**   >  At which point do you "know" a technology enough to list it on a resume I have been holding off adding Hibernate to my CV (resume, for American readers),but we are just coming to the end of a project where we have used it successfully and it might be time to add it. I don't know if we covered all the usual parts of this product, because it was my first such project. Could someone come up with a list of the major features, without knowledge of such, I would come to grief in a hypothetical job interview?


Metrics: Comments vs Documented API

I've been asked to run some code metrics in order to assess the quality of the code. One of the metrics was vaguely specified as "comments". I ran Sonar on my code, and while I got 10% on the "comments/loc ratio metric", I got 50% on the "documented API" metric (which gives you the number of methods/classes/instance variables with javadoc comments). I will try to convince the manager and the client that the "documented API" metric is more relevant than the first in estimating the quality of the code, especially that the metrics' goal is to assess the maintanability of the project in case another team took it. Do you have studies/opinions about which of these two metrics is more relevant to assess the quality and maintanability of the code? I could use them as persuation tools. Thank you


How to improve myself as a web developer?

What technologies, techniques and mindsets would be most beneficial to web developers? I'm a relatively new developer with only 3 months working for an actual web development company. Since I've started, I've learned the wonderful world of version control using Git and how useful the command line can be. I've also learned the world of good a decent editor such as Eclipse can do with it's RegEx Search and Find and few other features I actually use. What I'm wondering is what are some other things you've learned over the years that have been been really helpful and might apply to a web developer? I work primarily in PHP and front end languages (HTML/CSS/JS).


Why does pkg_resources not find bloom in my virtualenv?

I'm trying to hack on the ROS bloom build system (https://github.com/ros- infrastructure/bloom). After I've made some edits, I build it and install it to a virtualenv to test using               python setup.py build     python setup.py install --root /path/to/my/virtualenv      However, once in my virtualenv, it doesn't work since pkg_resources fails to find the module. What am I doing wrong here?               (virtual-bloom)[asinha@localhost  virtual-bloom]$ yolk -l     Python          - 2.7.5        - active development (/usr/lib64/python2.7/lib-dynload)     bloom           - 0.4.4        - active     pip             - 1.3.1        - active     setuptools      - 0.6c11       - active     wsgiref         - 0.1.2        - active development (/usr/lib64/python2.7)     yolk            - 0.4.3        - active     (virtual-bloom)[asinha@localhost  virtual-bloom]$ ./bin/bloom-generate     Traceback (most recent call last):       File "./bin/bloom-generate", line 5, in <module>         from pkg_resources import load_entry_point       File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2805, in <module>         working_set.require(__requires__)       File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 696, in require         needed = self.resolve(parse_requirements(requirements))       File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 594, in resolve         raise DistributionNotFound(req)     pkg_resources.DistributionNotFound: bloom==0.4.4     (virtual-bloom)[asinha@localhost  virtual-bloom]$ ls     bin  include  lib  lib64  usr     (virtual-bloom)[asinha@localhost  virtual-bloom]$      I'm guessing it's still looking at the system site-packages for some reason. I did use the `--no-site-packages` flag while creating the virtualenv:               virtualenv virtual-bloom --no-site-packages --verbose


How do I design a card game?

I can not come up with a good architecture for my card game. I need help to understand how games usually are designed. First, I will describe game rules. ### Game Rules Setup   * There are four players, each two player form a team.   * Each player gets 12 shuffled cards   * There are 4 blinded cards on table(river)   * Players order are like this  ![enter image description here](http://i.stack.imgur.com/F0Av1.png) Betting   * Each player can pass or select a number greater than current bet between 100 to 160   * Betting starts from first player and circles until a team pass   * Once a player pass they can't bet anymore   * The team that wins the betting round should at least collect points equal to their bet in order to win the game   * The team that lost the betting round should not allow the their team achieve their goal   * If the team that won betting round gets all the points the other team will get negative points equal to their bet   * if the team that lost the betting round collects all the points the other team will get double negative points ### Game flow and collecting points   * Player that won betting round ( **the king** ) gets four remaining cards on the table.    * Then she/he can save a set of four cards in their team cards bank without even playing them.   * The king will pick a suit as the **ruler suit** and let others know that   * King starts the game by putting a card from his/her hand on table. Each other player should play in this order      * if they have the same suit of that card in their hand, they have to play one of those cards     * if they don't have it, they can play any other suit   * After all other players played their hands, winner of the round will be:      * The one who has highest card if all cards are the same     * The one who has highest "ruler" card if there is any   * Winner of the round will collect cards and put it in their bank   * Player who won previous round will start the next round   * This will continue until everybody's hand is empty ### Counting points   * Winning each round has 5 points. This means every 4 cards has at least 5 points.   * Having Ace, 10 or 5 in bank each adds 5 points # My Design ## Classes               class Card {        string suit;        string rank     }     class Deck {       List cards = [];       List suits = ['S', 'H', 'D', 'C'];       List ranks = ['1', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A'];       private void init(){..}       void shuffle(){...}     }          class Game{       Deck deck = new Deck();       Player player1;       Player player2;       Player player3;       Player player4;       int _isOn = 0;            Game(this.player1, this.player2, this.player3, this.player4){         deck.makeCards();         deck.shuffle();         start();       }            void start(){         player1.cards.addAll( deck.cards.getRange(0, 12) );         player2.cards.addAll( deck.cards.getRange(12, 24) );         player3.cards.addAll( deck.cards.getRange(24, 36) );         player4.cards.addAll( deck.cards.getRange(36, 48) );         deck.cards.removeRange(0, 48);       }            String toJson(){       }            String toString(){       }     }     class Player{       String name;       int points;       List cards = [];            Player(this.name, {this.points});            String toJson(){}            String toString(){}     }      ### My Problem Now that I've defined all these classes I don't know how to bind this definitions to a database (like Mongo) and control the game flow.   * Where should all that logic go?   * How should I keep state in a server/client scenario? Note: I'm using Dart to program this but I don't necessary want answers be written in Dart.


Garbage collectors and pointers/ reference

I am a little confused on both pointers and reference. From my understanding pointers are addresses in memory. If I pass a variable using pointers and reference to a function, any manipulations of the variable in the function will change the original variable. I read online that passing by reference is not encouraged because it can get messy code easily. I also read here (http://stackoverflow.com/questions/7058339/c-when-to-use-references-vs- pointers), that we should avoid pointers if we can. My question is when should pointers and reference be used? I know pointers are used in Xcode for strong references and reference counting. Since, higher level languages like c# have garbage collector, does that mean we shouldn't ever use pointers and reference in them?


Is a PHP file secure enough on a GoDaddy Server to hard code an AES salt into the file?

So I am creating a web api for an app I am making. The data is sanitized before it is sent to my web api and then encrypted before it is stored in my MySql server. The phone app sanitizes then behind the scenes calls -> web php api which encrypts aes style with a hard coded salt then calls -> server My question is if I hard code a salt value into the php page is it at risk on a go daddy server? I mean I know NOTHING is truly secure however what are the odds that someone would be able to hack a go daddy server and see my php source code. Assuming they disassemble my app and see the URL call to the api. Since php code executes on the server I am assuming that there is no way to extract it?


Pure C Vector Implementation

I am implementing a vector in C. I am doing this for the fun of programming, for the fun of learning, and for the use of the data structure in later projects. This is not homework. My question is regarding methodology, not necessarily implementation, therefore I am not really looking for a code review. Now, I have read over many implementation examples and most of them take the size of an individual element as an argument to the `Vector_create()` function, and use this for later `memmove()`/`memcpy()` calls and what not and more or less keep (for instance) the vector's elements in contiguous memory. In other words, the underlying array is essentially a single `void*`. In the implementation I wrote before doing a lot of looking at how other people have done it, I allow(force) the client code to allocate an "object" and pass that as a pointer to the `Vector_append()` function. So my underlying array is a `void**`. _So I guess the real question I am asking is if this is wrong._ Wrong as in best practices wrong. I see that the "normal" way of doing this doesn't use an array of pointers and instead just copies the memory of a struct (for example) into the underlying `void*` array and thereby keeping the actual data of the elements contiguous, as mentioned earlier. My way avoids a crap load of `memmove()`/`memcpy()` because I just copy pointer values, however, I am forcing the client to `malloc()` everything that is sent to the vector, and thereby do a bunch of screwing around on the heap. Along those lines, I do call `free()` on the underlying data item when the item is removed, so the vector library does a `free()` that the vector library never did the original `malloc()` on. _Is this bad practice too?_ The only trouble I seem to get into is if there was a member variable (for lack of a better term) that points to dynamic memory within the struct. It then becomes the client responsibility to `free()` that data, but again, the struct itself is freed from within the vector library call `Vector_remove()`.


High traffic chat - how to check if there is new message and show it for all users

I already had question about this but obviously it was not accepted very well, apparently too long when it's actually more information so you could have given me better answer. Ok, I will be much clearer now. Best possible logic to develop scalable chat in terms of stability, storing/reading messages on chat, updating chat on new message for all users etc.? I have most of this developed, the logic I think I miss is --> check if there is new message and show it for all users. I have this implemented but it crashes the site due to its traffic of 300k-400k people, so that's my main question. The chat is PHP based and uses Pusher (www.pusher.com) for instant messaging but it lacks what I need because it's more like a websocket. * * * I'm using hardcoded files to keep messages (want to avoid database as much as possible). It's a no extension type of file, I'm sure you know. I'm getting crash with               $fp = fopen(..., "w"); // pretend ... is the path and filename     fwrite($fp, $msg); //hardcode the message     fclose($fp);      where `$msg` is the message itself. I'm having 1 file per message. I show last 150 messages = 150 file accesses and reads, yeah it's too much I guess. I have better logic now which I'm pursuing and that is 1 file with last 50-100 messages at all time. Sure it should be much better. How does it crash, that's the trickiest part because everything seems ordinary, believe me it is difficult to determine what exactly crashes the site, but in like 5 minutes when I try to open the site it's gone, then I put the old content without chat and is back online again. I'm having jquery post every 1 second to check if there is new message. I'm using timestamp in a special file where I keep the time last message was sent and `if ((time() - time in file) <= 2)` = reload last 150 messages including the last one. Too much input/output, write/read or however to say it I think is what crashes the site.


scipy.stats.percentileofscore() wrong?

i'm a data scientist and python noob, but I seem to have found a bug with scipy.stats.percentileofscore. it may be "by design" but please bear with me. if you have an array, you will get an upper bound of 100, but never a lower bound of 0. The lowest percentile you will get is 100/len so if I have an array of 30 items the lowest percentile I'll get is 100/30 ==> (3) so I have a workaround to allow a zero percentile result. is my workaround valid? is there something I"m doing wrong? please suggest. also note the following i put the numbers in the 0.0 to 1.0 range (I don't like using 0 to 100 for percentages)               stochState.kSlopePercentile = scipy.stats.percentileofscore([stochHist.kSlope for stochHist in stochState.history],stochState.kSlope)  / 100.0     invHistLen= 1.0/len(stochState.history)     if(stochState.kSlopePercentile < 1.0):         stochState.kSlopePercentile -= invHistLen * (1-stochState.kSlopePercentile+invHistLen)      the above code subtracts up to 1/len from the percentile (more the closer the percentile is to zero)


Coping with an unfixable endless project

We have a large (1200+ hours) website that has **a lot** of technical debt. This is mainly caused by the following (usual) reasons.   1. Multiple programmers who come and go during development.   2. Change of specifications during development.   3. Numerous added functionalities added (in a short time). The customer wants alot of new functionalities, and that basically comes down to working on this project **weekly** for 10+ hours. Due to the technical debt, we spend **A LOT** of hours fixing or investigating problems, that usually find their origin in one of the following:   1. A shameless, silly bug that makes people cry.   2. A new feature results in the above because we hadn't foreseen all the places the new feature would have an influence.   3. Some other problems we have faced (f.e. server migration, upgrades) We have issues **daily** and we have tried to following things to put this to an halt:   1. Created technical documentation regarding the import, payment and general working of the website.   2. Have meeting at the start of the week - discussing the current issues or improvements and how they should be tackled.   3. Have a test-plan. Programmer A test B, B tests C and C tests A. Then our Project Manager will throw in some tests. Regarding the impact of the feature we throw it on a staging environment and let the customer check for itself. The problem is that the problems keep happening...and somehow we can't get a grip on it. New features still cause bugs, and old bugs keep saying hello. Somehow - perhaps due the size of the project - we can't seem to get a grip on this project. I assume there are alot of programmers working on larger projects then this. That is why I come to my question: What can we do, or what do **you** do to avoid these problems on large projects? Minor edit, extra info:   1. We use version control (SVN).   2. We have DTAP development process.


What is the meaning of MODULE_LICENSE_BSD_LIKE in Android source code?

In Android source code, we see files like MODULE_LICENSE_APACHE2, MODULE_LICENSE_BSD_LIKE, MODULE_LICENSE_W3C. An outside observer would think that these specify the intended license that applies to the source code tree where this file resides. Take the JSON module, for instance. It has an empty file MODULE_LICENSE_BSD_LIKE, which might indicate that the JSON module is licensed under one of BSD licenses. However, sources themselves say that they are licensed under Apache License 2.0, as seen in JSON.java. Packagers of this library for Fedora, as well as other operating systems like Debian, consider the library to be licensed as Apache License 2.0. This seems reasonable, as an empty file bears no legal weight. However, MODULE_LICENSE_BSD_LIKE is apparently there for a purpose. What is that purpose?


Unit testing behaviours without coupling to implementation details

In his talk TDD, where did it all go wrong, Ian Cooper pushes Kent Beck's original intention behind unit testing in TDD (to test behaviours, not methods of classes specifically) and argues for avoiding coupling the tests to the implementation. In the case of behaviour like `save X to some data source` in a system with a typical set of services and repositories, how can we unit test the saving of some data at the service level, through the repository, without coupling the test to implementation details (like calling a specific method)? Is avoiding this kind of coupling actually not worth the effort/bad in some way?


Forking GPL project: Do I have full rights on the new fork or still dependencies with the original owner(s)

I am considering the creation of a fork to a small project licensed under GPLv2, and I have some very specific questions I did not manage to answer in my research on various sites and foras. When I fork the code, I am forced to release the new project under the same license (GPL) as I will do, but could I also decide to release it under a dual license, one of them commercial? When forking the project, do I automatically own the copyright of the whole thing? This is relevant when, for example, deciding a future change in the license, or to be able to enforce the GPL license to a 3rd party Thanks!


Loose Coupling in Object Oriented Design

I am trying to learn GRASP and I found this explained (here on page 3) about Low Coupling and I was very surprised when I found this: > Consider the method `addTrack` for an `Album` class, two possible methods > are: > > `addTrack( Track t )` > > and > > `addTrack( int no, String title, double duration )` > > Which method reduces coupling? The second one does, since the class using > the Album class does not have to know a Track class. In general, parameters > to methods should use base types (int, char ...) and classes from the java.* > packages. I tend to diasgree with this; I believe `addTrack(Track t)` is better than `addTrack(int no, String title, double duration)` due to various reasons:   1. It is always better for a method to as fewer parameters as possible (according to Uncle Bob's Clean Code none or one preferably, 2 in some cases and 3 in special cases; more than 3 needs refactoring - these are of course recommendations not holly rules).    2. If `addTrack` is a method of an interface, and the requirements need that a `Track` should have more information (say year or genre) then the interface needs to be changed and so that the method should supports another parameter.    3. Encapsulation is broke; if `addTrack` is in an interface, then it should not know the internals of the `Track`.   4. It is actually more coupled in the second way, with many parameters. Suppose the `no` parameter needs to be changed from `int` to `long` because there are more than `MAX_INT` tracks (or for whatever reason); then both the `Track` and the method need to be changed while if the method would be `addTrack(Track track)` only the `Track` would be changed. All the 4 arguments are actually connected with each other, and some of them are consequences from others. Which approach is better?


Is using dirname(__FILE__) a good practice?

Looking at the code of Joomla I see that in the first line of the index, it defines the base path of installation with `dirname(__FILE__)`. Is this a possible risk for the site? If a non controlled error message show the internal path of the Joomla directory, because of, for example a failed include, can it be used to perform some kind of attack to the site? If yes, is it convenient to use this function?


How best to implement HTML5 support for my validation library

I have created an annotation-based validation library called regula. There seems to be some amount of interest around the framework and the next thing I'd like to do is to support HTML5 validation. Originally I figured that I would check to see if the browser supported the HTML5 validation that has been specified and to either emulate or delegate to built-in regula equivalents. This is trivial for things like `required`, but once you start getting into the date-validation, it gets tricky (date widgets, localization, etc.). So I have a few options in front of me:   * Full HTML5 Shim along with widgets (for date stuff etc.): I feel like this is overkill and essentially reinventing the wheel since this is already covered by things like modernizr.    * Use HTML5 validation if available (either native, or provided by shim; otherwise ignore): What this means is that if HTML5 validation is available (natively or through a shim) I will use it, otherwise I will ignore it. I'm leaning towards the latter since currently if someone wants to use HTML5 validation, they will most probably require a shim since not all browsers support HTML5. Which option do you think is better?


How to implement string matching based on a pattern

I was asked to build a tool that can identify if a string match a pattern. Example: > {1:20} stuff t(x) {a,b,c} would match:   * `1 stuff tx a`   * `20 stuff t c` It is a sort of regex but with a different syntax   * Parentheses indicate an optional value   * {1:20} is a interval; I will have to check if the token is a number and if it is between 1 and 20   * {a,b,c} is just an enumeration; it can be either a or b or c Right now I implemented this with a regex, and the interval stuff was a pain to do. On my own time I tried implementing some kind of matcher by hand, but it turns out it's not that easy to do. By experimenting I ended up with a function that generates a state table from the pattern and a state machine. It worked well until I tried to implement the optional value, and I got stuck and how to generate the state table. After that I searched how I could do this, and that led me to stuff like LL parser, LALR parser, recursive-descent parser, context-free grammars, etc. I never studied any of this so it's hard to know what is relevant here, but I think this is what I need:   * A grammar   * A parser which generates states from the grammar and a pattern   * A state machine to see if a string match the states So my first question is: Is this right ? And second question, what do you recommend I read/study to be able to implement this ?


Is it correct to add booleans in order to count the number of true values in a vector?

Is it conceptually correct to sum a vector of booleans? From a mathematical point of view, I would argue it's not: `True + True != 2`. But it's quite practical to do so still! Example using the vectorised `Python` library `numpy`:               In [1]: X = rand(10)          In [2]: large = X>0.6          In [3]: large.dtype     Out[3]: dtype('bool')          In [4]: large.sum()     Out[4]: 7      I don't like it, but it's very practical. Is this a good practice? **Update** : the aim is to count the number of true values in a vector.\ **Update 2013-02-18** : I just discovered the numpy function `count_nonzero` does _exactly_ what I need in a proper way. That means that as far as `Python` is concerned, there is no need to use the "dirty" way.


Slow developer machines - approach with vmware good?

we are using slow developer notebooks. They come equipped with vista and 2 gb rams, which slows down everything. Someone decided a good resolution would be to use vmware clients instead of faster pc hardware. VMWare clients would run on dual core xeon cpu's. What do you think of that and what backdraws will probably result out of it?


How would you use Redis for Exception Handling?

I was reading this transcript of an interview with a GitHub developer and he was describing how they use Redis: > Q: You mentioned using Redis. How do you use that?   >  A: **We use Redis for exception handling** and for our queue. We tried a > lot of Ruby-based queuing mechanisms. Chris wrote an abstraction to the > queuing mechanism. We used to use BJ and DJ and in the super early days we > tried out Amazon SQS and a lot of queuing mechanisms and they all fell over > at one point or another with the amount of traffic that we were doing on > them and the types of queries that we were trying to get from them. > Eventually we moved to a Redis space that Chris also wrote, called Resque. Can anyone guess to what that means to use Redis for exception handling? Does it mean the logging of exceptions or something else? You can see the video of him saying it here.


What monad is the opposite of the error monad in haskell

In the error monad, the first failure halts any execution further just carrying the fault through any following binds. What monad halts on success only carrying forward successes, and basically swallowing any faults and trying the next bind disregarding the failure of the previous one? The error monad could maybe be used for this treating failure like success, but I'm curious if the default libraries have a monad for this specific purpose, almost like an Or monad in my mind "Do this, or that" Edit: Behaviour would be:               Left "fail" >>= (\x -> Right "win") >>= (\x -> Left "ahh neener") >>= (\x -> Right (x + " yay"))      In the error monad the first left value is just carried forward, so the result of that is `Left "fail"`. The behaviour I want is where the above returns `Right "win yay"` it's a trivial monad to implement I could write myself, but figured something existed to do such (maybe not using Either, but that's the first thing that comes to mind for such behaviour).


What are the external dependencies of a Python executable?

I guess there is a tool called Py2Exe to convert a Python application into an executable file. Since I am also using PyQt4 for GUI apps., what are the external dependencies for such an executable? What type of files I need to bundle along with my Setup? Is there any Python Setup Builder tool?


What does GWT not provide that straight AJAX coding gives?

For an experience core Java programmer with no AJAX and very little Javascript experience, the GWT is attractive. But, what will I be missing if I just use GWT?


How to deal with TODO List Overflowing?

Seriously... I need more time, and I can't find it. I've got my **main project** and I spent most of my time on it. I'm trying to, BUT I got a **lot of** minor projects, old projects support. I'm **very interested** in self-improvement because I'm still being sort of a young programmer and I spend lot of time discovering new technologies. Also, I'm part of some of linux distribution core teams (after all I'm a linux newcomer) and I'm spending time for it too (my main project is win-only though). I'm getting better in all directions. But slowly, because I'm doing everything at the same time ... Many times, I feel like this : ![enter image description here](http://i.stack.imgur.com/KrhC6.gif) And I don't want to leave the stuff I'm interesting in, I just need more time... But there is no more time. I also have my private life, working at home and working at work isn't so easy. Living at work is also not the solution. So finally I'm searching for a way to optimize (Hard optimize) my TODO list because the time is not a thing you can increase.


What is negative code?

I was reading the Wikipedia article on Douglas McIlroy and found a quote that mentions > "The real hero of programming is the one who writes negative code." What does that mean?


How do I handle this job situation?

I am a recent college graduate. I recently interviewed for a Software Developer position. I really like the environment. I got offers from other places but this place just feels really comfortable for me, I am familiar with the frameworks that they are using. Recently, recruiter told me that the team might think that I am a little under qualified. They want someone with a 1-2 year experience now. They are interviewing others with that experience. But I really want this job. I emailed the recruiter that I am willing to do what ever it takes to get this job. I don't mind spending lots of extra time to increase the pace of my learning. I really like that environment and that position. But I think he is out of town. Is it Ok email the manager and tell them about how I feel. I will be willing to do what ever it takes to make this work. I.E take couple of thousand less, or spend extra time. Like I said, I got offers from other places but this place jut feels right and comfortable for me. They got everything I need.


TFS - Explaining the difference between Product Backlog Item and a Task

I've run into this challenge a couple of times and I'm hoping someone can provide some references, training or advice on how to explain the difference between a Product Backlog Item and a Task in TFS. I understand and have explained that a Product Backlog Item is the "What" and the Task is the "How". I have also explained that the PBI is the requirement and the Task is how the requirement is met. I'm repeatedly met with blank stares and head scratching when I explain this. It seems that the Software Engineers I explain this to can not make the distinction. It is all the same to them. I believe my other challenge is that I am not able to effectively illustrate why it is important to make the distinction.


How to approach design to minimize conflicts when distributing individual locations to merchants

One of my potential customers is operating an open market in their town. From what I'm told, they make a decent profit by renting out the individual locations on that market to small merchants who come there every day to sell produce and other goods you normally find in such places. Each merchant needs to pay some fixed amount up front to receive a seasonal contract that grants them the right to sell their goods on the market during given season. The contract does not, however, specify at which micro-location the merchant will be stationed, or indeed, on which days they will be present. The only thing the contract grants them, is the right to sell certain types of goods and during which season. For each day that they are actually present on the market, a cashier comes to their spot and collects the daily rent for that spot. Now, certain micro-locations have more traffic than others, so there is bound to be some competition. Which is good, normally. Established merchants wish to retain their spot so their loyal customers can find them. The problem is that the existing "mechanism" of reservation is basically first-come, first-(re)served. In reality, this means at around 02:00 AM, merchants start appearing and placing all their stuff on their sweet spots in order to prevent others from doing the same. At times, competition can be quite literal. Things escalated into a physical altercation a couple of times in the past, so an overseer is now required to be present during the night before busiest days of the season. The customer has now asked me to come up with a software-based solution for this problem. An idea for a web and/or mobile app has been tossed around, but whatever the form, it would have to support the following features:   * merchant authentication,   * selection of a preferred micro-location for the next day,   * advance payment of the daily rent via some online method. While I was reading through the requirements, one thing immediately jumped out at me: **I cannot possibly do this in an app form**! Here's what I think it will happen, if I do anyway: In the first days and weeks, merchants that know about and use the app, will have an unfair advantage over merchants that don't. It would be easy to assume this problem will self-correct quickly enough, but it would be a wrong assumption, IMHO. Many of the small merchants are in reality older, computer- illiterate people. Imagine a kind, old lady selling flowers, for example. She will never use the app, because it's space technology to her. But she _will_ continue to show up at 02:00 AM and happily place her flowers on the same spot as the day before. Only to learn 4 hours later that _someone else_ had already reserved and payed for that spot yesterday, from their home, using a computer! How is she to compete with that? But things don't end here... Let's assume that, somehow, she does learn to use the app (or gets someone else do do it for her, which is more likely). Now, everyone is using the app to reserve their spot. Fast forward a couple of weeks, and this is what we get: Joe S. Merchant logs into the app at 05:10 PM, 10 minutes after the reservations for the next day have opened. To his surprise, almost all the spots have already been taken, including his usual one. Now he can either hope someone will not show up so he can take their spot at the last minute, or he can accept he's been too late and he lost a whole business day because of this confounded computer thing! Naturally, I've explained my views to the customer... And they agree it's a problem. They wouldn't want to make a bad situation worse just to have a more convenient way of collecting daily rent. We both believe the present system could stand improvement. The basis of present system is competition and that is probably here to stay. The problem is that currently the competition is directly based on physical effort (i.e. how early a person is willing to wake up and travel to the market place to get the spot). This effort is in turn a natural limiting factor on the (un)fairness of the whole competition. By introducing **ANY** software substitute, this key factor is effectively gone! It reduces the problem to who is faster in the first minutes when reservations start. There's no real effort involved anymore which automatically appears unfair! So we feel like the rules have to be adjusted somehow. We've tossed around some ideas that could make the online competition more fair. Ideas like: **1\. Building a reputation based system** This one brings in a lot of extra complexity, not to mention responsibility of tracking and assessing the various factors that contribute to reputation score. Most of these cannot be automated which means they would incur extra cost to the customer. **2\. Randomizing the start of each day's reservation window** This one has the potential of lessening the competition pressure in the first minutes of the reservation window, giving it an _appearance_ of being more fair. Yet, I fear it would only annoy the merchants. What both me and my customer agree about, is that we absolutely **CANNOT** implement a reservation mechanism based on bidding. That would be in violation of financial laws the customer's company must abide by which call for a fixed rent in this situation. I refuse to believe that the best solution is the one that presently exists, even if merchants are used to coming in at 02:00 AM and waiting 4 hours for the market to actually open. **I turn to this community to ask: How can I earnestly better the present system with a software component? What options am I missing?**


Reasons NOT to open source not-for-profit code?

I am a big fan of open source code. I think I understand most of the advantages of going open source. I'm a science student researcher, and I have to work with quite a surprising amount of software and code that is not open source (either it's proprietary, or it's not public). I can't really see a good reason for this, and I can see that the code, and people using it, would definitely benefit from being more public (if nothing else, in science it's vital that your results can be replicated if necessary, and that's much harder if others don't have access to your code). Before I go out and start proselytising, I want to know: **are there any good arguments for _not_ releasing not-for-profit code publicly, and with an OSI- compliant license?** _(I realise there are a fewsimilar questions on SE, but most focus on situations where the code is primarily used for making money, and I couldn't much relevant in the answers.)_ **Clarification:** By "not-for-profit", I am including downstream profit motives, such as parent-company brand-recognition and investor profit expectations. In other words, the question relates only to software for which there is NO profit motive tied to the software what so ever.


To Open Source or Not to Open Source, that is the question

So, I have a couple of projects that I have been working on and I am trying to decide if I want to open source them or provide them for free as closed source. I have never "owned" an open source project before and I would love to hear thoughts on the pros and cons of both options. Any horror stories of deciding on either approach are acceptable too.


Who owns the code, who owns the algorithm, who owns the idea?

This question got me thinking what products of the programming effort belong to the employer, and what don't. The two extremes are (0) the code - it apparently belongs to the employer and (1) the learned personal and technical skills. But what is in between? Who owns the pseudocode/algorithm? Who owns the general idea of the algorithm? Who owns the know-how that such an algorithm may serve some useful purpose (e.g. on this site questions are values, as well as answers)? Also: Who owns an idea on the web?


How to practice typing of programmer keys such as tilde, pipe and programmer quote?

It is nice that there are services such as TypeRacer where you can practice casual writing but I want to practice programmer keys, covers more numbers and keys not used by regular typist. There was some tutor with which I practiced some programmer keys and noticed that my speed dropped dramatically from 70-80 wpm to even about 15-30 wpm, it also trains different muscles. So how can I practice just programming keys with programming texts or just random code pieces?


How do I tell the cases when it's worth to use LINQ?

Many things in LINQ can be accomplished without the library. But for some scenarios, LINQ is most appropriate. Examples are:   1. `SELECT` \- http://stackoverflow.com/questions/11883262/wrapping-list-items-inside-div-in-a-repeater   2. `SelectMany`, `Contains` \- http://stackoverflow.com/questions/11778979/better-code-pattern-for-checking-existence-of-value   3. `Enumerable.Range` \- http://stackoverflow.com/questions/11780128/scalable-c-sharp-code-for-creating-array-from-config-file   4. `WHERE` http://stackoverflow.com/questions/13171850/trim-string-if-a-string-ends-with-a-specific-word What factors to take into account when deciding between LINQ and regular .Net language elements?


Storing a value vs calling reference for repeated use in Java

I have an old habit of avoiding calling references multiple times, both for easier to read/maintain code, and for possible efficiency. But I'm wondering which is more efficient (memory, performance, both?). For example when working with XML using a VTD parser               if( vn.toString( vn.getCurrentIndex() ).equalsIgnoreCase( "broken-label" ) == false )             {                 do                 {                        if( parentNode != null )                     {                         currentNode = parentNode.addChildNode( vn.toString( vn.getCurrentIndex() ) );                     }                     else                     {                         currentNode = new xmlNode( vn.toString(vn.getCurrentIndex()), null );                         treeNodes.add( 0, currentNode );                     }      Does not store the value, perhaps saving some overhead for creating space to save a local variable and also lowering the burden on the garbage collector (assuming this section of code is repeated thousands of times in quick succession. My habit of cleaner/efficient code would be to replace the above with the simple change of               String label = vn.toString( vn.getCurrentIndex();          if( label ).equalsIgnoreCase( "vsled-image" ) == false )             {                 do                 {                        if( parentNode != null )                     {                         currentNode = parentNode.addChildNode( label ) );                     }                     else                     {                         currentNode = new xmlNode( label, null );                         treeNodes.add( 0, currentNode );                     }      While this is obviously easier to read and maintain. Are there any non-human benefits?


Best way to share (make accessible) to the world a maybe useful self-written utility script/program?

Throughout my life I've accumulated a fair share of scripts that have proven to be useful to me in many cases and might be useful to many others. I look at things like todo.txt (which probably started off as just someone's personal text file manager) and even simpler ones online and sometimes I feel like I want to put my stuff out there for people who are looking for it to be able to use, open source. What's the best way to just put things out there where people who might want to find it would find it? Should I start a well-read blog? post in forums? I don't want to advertise or spam it, just have it in some kind of way where anyone who would might be looking for something of similar functionality would find it through google or something.


Any tips in tackling extremely complex problems like the Hanoi Tower problem?

People often give me the "divide and conquer" tip, but I think for some problems it's not nearly enough. The problem with such a complex problem as the Hanoi Tower problem is that you can't even simulate or abstract parts of the problems even if you divide it into parts if you know what I mean. So, can anyone give me a step-by-step approach in tackling such a complex and difficult problem?


How come javascript, being a prototype based language, doesn't have an easy way to access the prototype?

May be this is a stupid question, but I'm kind of intrigued. Being JavaScript a prototype based language, with its pseudo-class function constructors sort of half baked (remember JavaScript: The Good Parts ...) I wonder how is it possible that it didn't have, right from the start, some easy way to access the prototype of each object. By easy way I mean something like object.prototype, or object._prototype (and not the dirty proto) For what I know, the Object.getPrototypeOf(obj) was just added in late 2008, almost 13 years after JavaScript was launched. I'm asking this because I always wondered if JavaScript was ever meant to be used as a pure prototype based language, I mean, without using any function to construct objects (in other words, never using the new operator).


Build website using a known language or a new one?

So there is a website that I want to build. It will be a review aggregator and probably a bit more. I want to build this website for three reasons:   1. I really think this website will be used by a reasonable amount of people    2. I want to practice my programming skills since currently at my job I am doing mostly scripting    3. Maybe learn a new language. I am currently torn though since my immediate reaction is that I want to use Java since I know it relatively well, like it, and feel it will allow me to put something up as quickly as possible. I would also like to use an existing Web Application Framework. If I don't end up going with Java I would probably go with one of the following:   * C#/.NET - I prefer static languages, and this is similar to Java.   * Python - I use this at my job superficially and it seems that a lot of people are using it.   * Ruby - Seems to have a very well established framework   * Scala - Has some similarities to Java but from what I read it's a different paradigm So I guess my question is under these circumstances do you think that I should build a website using a known language or a new one?


What can I do to prevent taking on an unethical development project?

Back in my self-employment days, I've once taken on a small and rather well- paid project: "A newsletter system", the spec stated. Everything was fine, invoices were paid with each milestone reached, me was a happy developer … Until Mr. Client started demanding mail header spoofing and a bunch of other functionality eventually leading me to the conclusion that I was building quite the sophisticated spam mailer. To make a long story short: Financial considerations made me finish what I had started. I resent having taken on the job in the first place to this day – if I had bothered to google my client's name, I would've been warned. What strategies can I use to avoid ending up coding stuff I'd rather not see in someone's hands?


Is it good practice to keep 2 related tables (using auto_increment PK) to have the same Max of auto_increment ID when table1 got modified?

This question is about good design practice in programming. Let see this example, we have 2 interrelated tables:               Table1     textID - text     1      - love..     2      - men...     ...          Table2     rID - textID     1   - 1     2   - 2     ...      Note: In Table1:   * `textID` is auto_increment primary key  In Table2:   * `rID` is auto_increment primary key & `textID` is foreign key   * The relationship is that 1 `rID` will have 1 and only 1 `textID` but 1 `textID` can have a few `rID`. So, when table1 got modification then table2 should be updated accordingly. Ok, here is a fictitious example. You build a very complicated system. When you modify 1 record in table1, you need to keep track of the related record in table2. To keep track, you can do like this: **Option 1** : When you modify a record in table1, you will try to modify a related record in table 2. This could be quite hard in term of programming expecially for a very very complicated system. **Option 2** : instead of modifying a related record in table2, you decided to delete old record in table 2 & insert new one. This is easier for you to program. For example, suppose you are using option2, then when you modify `record 1,2,3,....,100` in table1, the table2 will look like this:               Table2     rID   - textID     101   - 1     102   - 2     ...     200   - 100      This means the **Max** of auto_increment IDs in table1 is still the same (100) but the **Max** of auto_increment IDs in table2 already reached 200. what if the user modify many times? if they do then the table2 may run out of records? we can use `BigInt` but that make the app run slower? Note: If you spend time to program to modify records in table2 when table1 got modified then it will be very hard & thus it will be error prone. But if you just clear the old record & insert new records into table2 then it is much easy to program & thus your program is simpler & less error prone. **So, is it good practice to keep 2 related tables (using auto_increment PK) to have the same Max of auto_increment ID when table1 got modified?**


Is it RESTful to resume terminated POST operation on a GET request?

I have a RESTful API, one of the resource has a state that is determined collectively by multiple servers, not all of them belong to us. One of the operation on this resource will have to modify the state of multiple servers. The client sends a POST request to do this operation to our API server and our API server sends requests to the other servers to fulfil the request. Due to the nature of the whole operations, not all of the operation can be done in a single transaction. The APIs for the participating servers mostly do not support 2-phase commit, but most do have some idempotence guarantee, although not all of them are RPCish rather than RESTful. If any error happens during this operation, the resource is left on an intermediate state, but the server should be able to repeat the operations from the point it has left off to fix the resource's state. Would it be a bad idea or would it conflict with REST principles if the server transparently resumes unfinished operations the next time the client reloads the state of the request (with a GET) rather than requiring the client to discover the resource is in an intermediate state and send another request to fix the situation before continuing anything else. One one hand, GET is supposed to be a safe operation, but on the other hand, letting GET resolve the situation simplifies the client as it doesn't have to deal with this situation. Note that the users also interacts with the other participating servers directly (i.e. not just through our client) so they may see some of the effects of the operations if a resource is left in an intermediate state.


Is it possible to use C++ with the .NET framework?

I've read many comments about GUI programming, in both, C# and C++. And I noticed that Microsoft's .NET framework is powerful for GUI programming. So is it possible to use C++ and .NET framework? I think it will be a great combination since C++ is powerful language, and .NET framework is preferred for GUI programming on Windows, as I've read. Is it possible to write the GUI in C# and the functionality in C++?


In which format should I sent the values in database in PHP?

I am developing an application which is based on the quiz contest for competetive exams. The user can give different categories of tests, which will contain different types of questions of following types:   1. Single select,   2. Multiple select,   3. Match making,   4. Comprehension (the quetion will be a paragraph and on the basis of that there will be questions),   5. Free text (the user will have to type the answer),   6. Range (the user have to select a number from 1 to 10). My concern is that while creating questions from admin site, how can I manage the database for above type of questions? I have one answer column in the question table but there are six type of questions so what should be the convenient way for saving answers in the databse so that when user will give answer, I can easily check if the answer matches? I am thinking of saving the answer in the form of XML tags. Will this be a good approach?


What should be the sense to use strict comparison to this specific string: 'final'

In a code review that I was doing to a coworker, I said that here:               if (someValue === 'final'){      There is no sense to use strict comparison because the only way to pass it as true is with other string value equals to final. I think that it is enough:               if (someValue == 'final'){      His argument is that an object could have a toString method that returns that string but strictly it does not have the same datatype. While that is true, as a computer(that are not intelligent as human), in the other hand, there is not sense, as at the end of the way the only way to pass this as true is with a string equals to final. This was his sample code:               Test = function(){}     Test.prototype.toString = function () { return 'final'; }     var disagreeDaniel = new Test();     document.getElementById('foo').innerHTML = (disagreeDaniel == 'final');      So my point here guys, is that I need you get better explanation to him why there is not sense of the strict comparison on a fixed strict like 'final' because there is no way to pass it as positive with a value different than 'final'.(his example at the end return the string) For me strict comparison is useful for booleans, nulls, undefined, zero, where those could pass all as false in some cases. I want to hear your opinions. **====== Update ==========** It is easy to identify that people does not read. My question was the sense of use === to compare to 'final'. I got a lot of explanations of things nothing to do. For compare to null, false, zero etc, I said that I used === for THOSE cases but not for long strings. but people tried to explained me about null, false, zero, etc. The verdict until now is that there is not a SOLID argument(there are some good ones but not solid) that demonstrate why using === for compare to 'final' should be better than use ==(read again, is just this use case, I'm talking about one specific use case). I also spoke with my coworker, I gave him the +1 to the code. I do not have problems with ===, my problem never had to use it, my point always was and is, and will be, what should be the **sense** , and looks like it would be a question with nevertheless answer. ps. other thing that I learned time ago, is to never be aggressive with other opinions; "technical topics" for several programmers, are like religion for religious(and some guys here just remembered me it). ps2. I marked as solved to be democratic, I do not want to demonstrate anything, just thought this site is for good discussions, and I got that. :D


foreach in list or foreach in list.where

I don't know what to call this question. This is my example:               foreach (var item in lstItem.Where(item => stock.ItemCode == item.ItemCode))     {          stock.ItemName = item.ItemName;          stock.ItemUnitName = item.ItemUnitName;          stock.BrandName = item.BrandName;          stock.FamilyName = item.FamilyName;     }      or               // Assume list has items     var list = lstItem.Where(item => stock.ItemCode == item.ItemCode);     foreach (var item in list)     {          stock.ItemName = item.ItemName;          stock.ItemUnitName = item.ItemUnitName;          stock.BrandName = item.BrandName;          stock.FamilyName = item.FamilyName;     }      Which one is better?