Common mistakes which lead to corrupted invariants

My main source of income is web development and through this I have come to enjoy the wonders of programming as my knowledge of different languages has increased over the years through work and personal play. At some point I reached a decision that my college education was not enough and that I wanted to go back to school to get a university degree in either computer science or software engineering. I have tried a number of things in my life and it took me a while before I found something that I feel is a passion and this is it. There is one aspect of this area of study that I find throws me off though. I find the formal methods of proving program correctness a challenge. It is not that I have trouble writing code correctly, I can look at an algorithm and see how it is correct or flawed but I struggle sometimes to translate this into formal definitions. I have gotten perfect or near perfect marks on every programming assignment I have done at the college level but I recently got a swath of textbooks from a guy from univeristy of waterloo and found that I have had trouble when it comes to a few of the formalisms. Well at this point its really just one thing specifically, It would really help me if some of you could provide to me some good examples of common mistakes which lead to corrupted invariants, especially in loops. I have a few software engineering and computer science textbooks but they only show how things should be. I would like to know how things go wrong so that it is easier to recognize when it happens. Its almost embarrassing to broach this subject because formalisms are really basic foundations upon which matters of substance are built. I want to overcome this now so that it does not hinder me later.


How to organize large Rails application?

I am working on a large(ERP level) Rails project. We have 150 tables and more than 150 models. It takes minutes to find a model. Should we add all models under the models folder or should we put them in different subfolders? Same thing goes for controllers and views.


Role of Microsoft certifications ADO.Net, ASP.Net, WPF, WCF and Career?

**I am a Microsoft fan and .Net enthusiast.** I want to align my career in the lines of current and future .Net technologies. I have an MCTS in ASP.Net 3.5. The question is about the continuation of certifications and my career growth and maybe a different job! **I want to keep pace with future Microsoft .Net technologies.** My current job however doesn't allow so.So i bid to do .Net based certifications to stay abreast with latest .Net technologies. My questions:   1. What certifications should i follow next? I have MCTS .Net 3.5 WPF(Exam 70-502) and MCTS .Net 3.5 WCF(Exam 70-504) in my mind so that i can go for Silverlight development and seek jobs related to Silverlight development.   2. What other steps i need to take in order to develop professional expertise in technologies such as WPF, WCF and Silverlight when my current employer is reluctant to shift to latest .Net technologies? I am sure that there are a lot of people of around here who are working with .Net technologies and they have industrial experience. I being a new comer and starter in my career need to take right decision and so i am seeking help from this community in guiding me to the right path.


Spoiled by Python convenience- and productivity-wise, spoiled by C++ speed-wise. Now unhappy with both

I'm currenetly struggling with choosing how to proceed as a programmer. I mainly programmed games and would like to continue. And for about 5 years or so I just used C++ and OpenGL, so I spent a lot of time on infrastructure, strange bugs, and mostly getting basic things to work. A friend of mine then recommended python and after initially being aversed by it being not as explicit and formal as I was used to I was shocked by how much more productive I could be and how much progress I could actually make in a very small amount of time. So currently I'm working on a multiplayer-shooter and repeatedly I find myself struggling with python being not as fast I might want it to be. I know that that I have to approach writing efficient code in python very differently now, but even with a little help from friends that are more experienced with python there is just too much going on sometimes (and extrapolating this, I know that I will end up stuck). There are a lot of things I really like about my "home-language" C++, but after knowing how many hours I could be wasting I don't really want to go back. What language can you recommend which offers high-productivy, is memory-safe (I really hated this) and as high-performance as I can get, but is still mature enough to be used for kind of serious projects (games-related) and maybe even mature enough to have people already having spent some time on OpenGL-Bindings or various libraries for Sound and similar (alternatively easy access to shared libraries written in C). Easy cross-plattform is a big plus! So no .NET please. Is this even possible?


Code cleanup methods and/or code coverage tools

I have an application at work, which I started work on about 7 years ago. This was my first engagement in ASP.NET web applications, and coming from a Win32 background I had a hard time adjusting. All this time, both the project and myself have "matured" and now most parts of it are well defined, properly structured and readable. However, there is a significant piece of it, that is "old junk". By that I mean old obsolete code, that was not working well, or was not properly structured, which has been replaced, but left in the source files instead of being removed. I must note here, that I was not the sole developer, but did most of the coding throughout. What I want to do, is whenever I have free time at work, to remove the old obsolete and unused code. Are there any techniques/methodologies that I can use/follow in order to do this more efficiently? Any tools perhaps? **EDIT: (clarification based on feedback)** The code I am talking about is not used anywhere, and is not called from anywhere in the project. What I need is way to find out where the code resides, since we are talking about a large codebase. So something in terms of code coverage tools would help. Any suggestions for asp.net projects? (the particular case is in Web Site project form)


What data structure is suitable for implementing dynamic huffman encoding and decoding on a piece of text?

Some pseudo code or resources will be appreciated.I was thinking if implementing it in form of a BST stored in an array. However,not all operations can be performed easily using this approach. I am open to using STL's for this purpose as well.My main purpose is to implement it in the simplest manner possible.


How to use unit tests as a source of information?

A colleague of mine was once at a seminar about agile development, where he heard it is possible to use unit tests as technical documentation. Something like using unit tests as an example of how to use the class. A quick Google search provided _TDD and Documentation_ , which proves it should be possible. But looking at our code, I see that we obviously failed to implement unit tests in such a way. In my opinion unit tests are there to test code as a minimal unit, even with help of mock and fake classes and functions. So, the questions are:   * Isn't it the task of functional tests to show how a class (or set of classes) should be used?   * If it is possible to use unit tests as technical documentation, are there some guidelines on how to implement such unit tests?


A Web Service to collect data from local servers every hour

I'm trying to find a way to collect data from different servers around the world. Here are the details: There is only one single PowerShell script on servers that encrypts data (simple csv file) and sends with preferred method (HTTP/HTTPS Post could be) There is no more control on that servers. Can't install any service, process etc. Just I can configure script to execute every hour. This script also will have encrypted username/password/license key for every server. Script will compress data and send to me with these information. So I need a service (I'm not sure if Web Service is the rigth solution) on the cloud that will help me to: Will get data that is sent from servers using a method. Will authenticate request to recognize sender using license key/username/password and most importantly, Will redirect/send this filecab to my SQL Server on the cloud (Azure). Also it should seperate data according to customer information in license key. So every data for every customer will be stored in dedicated DB/Tables on my SQL All the processes above should be completed automatically. No way for manual steps. Question: A Web Service (SOAP or Restful) is the rigth solution for that?


What is the accepted practice for string resource management in java?

In Android, final strings are stored in a `strings.xml` file, which makes it easy to update text, reuse strings and to translate an app to a different locale -- because everything is in one place. However, in all the examples that I have seen of desktop applications all the strings have been hardcoded into each class. Is hardcoding strings into files standard practice for desktop applications? Or is there a better way to do this?


Recommended architecture for an interactive table widget with multiple behaviors in Javascript / jQuery

Use case:   For an administration UI, I want an interactive table widget with a number of behaviors:   * Collapse / expand (yes, this means the rows are a hierarchy)   * Update of data in a child cell based on a parent cell.   * Hiding or revealing of a row or an entire sub-tree based on a value update.   * Two or more form elements in each row, that may depend on each other. E.g. a checkbox that will mess with the value of a text field in the same row.   * DOM manipulation on newly created rows. E.g. the checkbox might be turned into a more visual kind of widget. Or  In another use case, I have the following additional behaviors:   * Adding and removing rows, manually or automatically.   * Drag and drop of rows. (probably not in combination with the collapse/expand, but who knows) The problem:   * Ideally, we want each of these behaviors to be implemented as a separate and independent module / plugin. BUT   * If one behavior changes the DOM, then other behaviors need to know about it. E.g. if you insert a row, then the collapse/expand needs to know, to decide whether the new row should be shown or hidden. And the newly added row needs new event listeners from various other behaviors.   * There might be behaviors that are triggered by the state of other behaviors. E.g. each row might contain a text field, and depending on the value, the row must be moved up or down (drag/drop). The question: I had to deal with this kind of problem a few times and I generally managed to get it work. However, I always hated the architecture that came out of it. What I'd like is an approach that allows to create the different behaviors as independent modules, and then somehow plug them together. Some more specific questions:   * Where should each of the behaviors keep its state information   * What about state information for a specific table row? Should it be stored as a variable on the DOM element? (e.g. `$('tr')[5].isExpanded = true`) or rather in a data container in the module itself?   * How can modules know about DOM updates?   * How should modules talk to each other?   * How should the code of each module be structured? What kind of API should it expose?   * How to handle multiple instances of this kind of widget on one page? (In this case, global instances don't work) Example: https://drupal.org/project/multicrud (sorry, all I have atm is Drupal modules)


Win loss code that does not make 1-0 record better than someone like 20-3

ok, am just looking for a win loss code example. This can be for any language, just wanting the outline. Fairly new to programming, so dummy it up for me :) I can do (win-loss/total of win loss). Guessing that is a good standard win loss ratio, but I don't want a new person that has 1-0 to be ranked higher than someone that has 20-3. Any help is appreciated and thank you. EDIT: The chess styles are a little more than needed. Just want a ranking system with win/loss. so lest say 20-3 is top in league right now. he is, say 23 weeks in so far. if one guy comes in and wins first match against anyone, I don't want him to take #1 spot over people thats been there longer and have a great winning record. To respond to ampt... maybe he will be best in league, but I don't want him instantly there cause he had one good match. Not sure if that clarify any more. Didn't really follow Doc all the way. Looks as if he is hindered in list up to his 11th game. Not sure if thats what you ment there. Thanks again for all reasponses.


Creating fast, realtime dialogue search for television scripts

We have a database of television scripts and we'd like to search it, getting results as we type. We often remember words or snippets of dialogue but can't remember exactly what was said or what episode it was said in: "What was the episode where George goes against his instincts and walks up to the girl at the diner and tells her he's unemployed?" With this tool you'd type "George unemployed" and the result with context (and possibly other hits) would pop up:               EPISODE: "The Opposite"          George : Excuse me, I couldn't help but notice that you were looking in my direction.     Victoria : Oh, yes I was, you just ordered the same exact lunch as me.     ( G takes a deep breath )     George : My name is George. I'm unemployed and I live with my parents.     Victoria : I'm Victoria. Hi.      My question is about the best way to design a data structure to implement this kind of search?   My idea so far is store a lookup table in an in-memory data store such as redis. To create the table, first I'd give each script (episode) an id, and then i'd parse the script into lines based on the person speaking. So a particular piece of dialogue could be located with an episode id paired with a line id. Next I would process each line, creating a data structure indexed by all words appearing in any script, and storing the episode/line location of every instance the word was used.               apple -> [                 { scriptid: 9, lines: [11,99] },                { scriptid: 21, lines: [103,211,214] }              ]     orange -> [                  { scriptid: 2, lines: [101] }               ]      We could pair this data structure with a simple scoring algorithm, so that when a user searched for multiple words, we'd only show matches where both words occured in the same script, and give higher rank to locations where the words appear closer to one another. There are other details that, ideally, would be accounted for, such as matching plurals and mispelled words. Is this a reasonable approach? How could it be improved? What other details should I consider?


Is having decrypted compressed files in iPhone is a problem on submission?

I am about to submit an iPhone application. I do download Encrypted Zip files from a remote server and of course I do decrypt the files to view them to the user. Does that mean I need to answer YES for               Does your application have encryption?      when I upload my Binary?


How do you make decorators as powerful as macros?

Quick background: I am designing a Pythonic language that I want to be as powerful as Lisp while remaining easy to use. And by "powerful", I mean "flexible and expressive". I've just been introduced to Python function decorators, and I like them. I found this question that suggests decorators are _not_ as powerful as Lisp macros. The third answer to this question says that the reason they're not is because they can only operate on functions. But what if you could use decorators on arbitrary expressions? (In my language, expressions are first-class, just like functions and everything else, so doing that would be fairly natural.) Would that make decorators as powerful as Lisp macros? Or would I have to use syntax rules, like Racket and Honu, or some other technique? **EDIT** I was asked to provide an example of the syntactic construct. For an "expression decorator", it would simply be a decorator on an expression (where "$(...)" creates an expression object):               @Decorator("Params")     $(if (true):         printf("Was true")     else:         printf("Wasn't true"))      Also, if I _do_ need to use syntax rules, as mentioned above, it would use a pattern matching syntax:               # Match a bool expression, a comma, and a string.     macro assert(expr:bool lit string) { e , s }:         if (!e):             error s         else:             printf("All good")      The above would match this:               assert i == 0, "i should have been 0"      That's a rough sketch, but it should give you an idea.


Lazy-initialization vs preprocessing in image-based iOS app

I am making an iOS app which contains museum gallery: user can look through exhibits and then select info about it, etc.   On the exhibit screen I have two ScrollViews that are different, but are being fed by common data source. Each view is a set of images. Two top grey squares are the previews and the bottom one (where you can see the picture) is the main view. All scrollviews are lazy-loaded.   The question is, do I need to transform preview images to proper size on-the- go, or somehow pre-process them to make loading faster and use that pre- processed and resized images in previews? The benefit of lazy-initialisation here is lower waste of resources, but slower loading, compared to ready images. On the other side, preprocessed images will waste storage and network (images will be loaded only once and then will be stored locally). What would be better from performance point of view, taking in account that app has to run smoothly down to iPhone 4 (oldest with iOS 7)? Is it good idea to combine two methods and cache lazy-loaded images?


what data storage method should I use?

I am currently writing a program and among other things need to store data. The program listens to two computers talking to each other in a known protocol (the program know what protocol it is,the user give the program the protocol structure ), if the packet that arrived to the program has unseen value in one or more of the fields it add it to the database. I am not sure what data storage method(such as sql server,xml etc.) to choose since I don't know whether the data stored in the database would be large or not, it depends on the computer's conversation Also I will need to be able to get all the data from the database with no trouble and might need to extract some data and not the other (for example all the packets with the value 24 in field x) By protocol I can't just give you one because the user of the program defines which protocol the conversation is in. By conversation I mean that two computers talk to each other it doesn't matter if a user operate the computers or not. The maximum number of entries in the database would be the number of variations that the packet in the certain protocol can be. I mean if the protocol is 8 bytes long the maximum number of entries would be 2^64 but if the header is longer the number goes up, but the number of entries could be less depending on the conversation and it is out of my control. The program will only store unique headers, I mean that the same combinations of values in the header won't be in the DB twice, the program store the header if it is unique and it isn't stored in the DB I thought of using a sql server such as mysql but I am not sure what data storage method would suit this situation the most?


Find common ancestor

![enter image description here](http://i.stack.imgur.com/GtimL.jpg) Given X number of leaves (the ringed leaves in the picture) in an unbalanced tree with depth aroun 100-1000 and total number of nodes around 15 000 000. I'm looking for the first common ancestor for those leaves. What is the most efficient way to achieve this?


How comes the C++ standards committee introduces a keyword like nullptr and gets away with it?

That must have broken a lot of peoples code bases right? Everyone who had a variable named "nullptr" (which I think would have been fairly common) has to find "nullptr" and replace with "something_else" before being able to compile with c++11. Does the standards committee assume that people will do that much "adjusting"?


Can Hadoop be made production-stable on a Windows platform?

Is anybody using **Hadoop** on **Windows** (Win32 or Win64) in **production** for serious work?   * If you've tried it and rejected this combination can you give your (top) reasons?   * If you managed to make it stable can you give an impression of how much work it took? * * * **Background:** My company is 100% Windows. There's not much I can do about this other than use the tools I'm given. According to the Hadoop documentation **only** UNIX-like platforms are recommended for production environments. Windows environments are currently considered to be experimental. I've tried some of the basic Hadoop Set-up on win32, and there seem to be a lot of gotchas, and I'm starting to suspect that this might be a foolish line of research. I understand that Hadoop scripts depend to some extent on UNIX features such as Bash, Rsync, SSH which could be provided by Cygwin - however I'm not planning on becoming a pioneer. I'd like to run something which is somewhat standard. I want a decent chance of being able to get some community support if there's something I cannot solve all by myself. I'm willing to invest some time to get this working on the company systems, but I'd like some reassurance from more pioneering types who have been there before. Alternatively I'd like some good advice from somebody who knows it's not worth bothering with!


When and how to use the advanced features of git?

I'm not exactly a new git user but I have never used any of its advanced features such as tags, branches, merging and others. I haven't even used anything equivalent features from other VCS software. My projects have been so simple that I have only needed commits and sometimes diffs. Now I'm planning to open-source a server project of mine which probably will get a lot bigger and it probably needs to be organized better. Git can probably help me with that but how? The development methods are scrum and TDD if that matters.


Design question: Is this good case for proxy pattern, or "over done"?

Working on a major enhancement for legacy code, I have been wrestling with myself over whether this is a good case to use the Proxy pattern, and more specifically whether a good case to use the Java Dynamic Proxy API. **BACKGROUND** We have a "FIXConnection" class used to send orders to a destination. The application maintains 1 to n FIXConnections for sending (a specific object is selected based on what the user specified on the order). Normally, the order would be sent straight out to the market. The enhancement is to see whether order could be filled by other orders already sent to market before sending, and if it can be filled, execute totally different logic (i.e. not send). If not, it delegates to current logic. This feature will only be used by one client, so it is turned on/off dynamically (or by configuration setting). It feels like this is a good use for the Proxy pattern/Dynamic Proxy, because it would allow designing a block of code to intercept requests to the existing FIXConnection.send method (and also its processResponse method), only in the case whether the feature is enabled. The Proxy could either execute the new logic (if warranted), or dispatch to existing logic. **PROS AND CONS**   _PRO_   * Using Proxy avoids any issues with Class hierarchy (we occasionally subclass this FIXConnection class). If we handled this by subclass, then other children might need to be moved to this under this as a parent.   * We don't need to update the existing top level class with any flag to check if this feature is enabled, and to conditionally execute code. (i.e. not create code for one special case, which would now be hit by all cases).   * Single point of control  _CON_   * Existing class exposes public variables, all would need to be refactored into getter/setter methods, and need to extract an interface (so that Dynamic Proxy could be used). i.e. a ripple throughout other classes.   * Binding between the proxy and legacy method could be a little cheesy (e.g. method.getName().equals("send"). There are ways of more tightly binding, but ... (yuck?)   * Is this making things unnecessarily complicated? In general I try to subscribe to doing "the simplest thing that could work". This doesn't quite feel like it. Would love to hear anyone's thoughts about how they might handle this design question.


What is really happening when we change encoding in a string?

http://php.net/manual/en/function.mb-convert-encoding.php Say I do:               $encoded = mb_convert_encoding ($original);      That looks like simple enough. WHat I am imagining is the following `$original` has a pointer to the way the string is actually encoded. Something like `char *` kind of thing. And then there are things like what the character actually encoded. It's probably somewhere along UTF-64 kind of thing where each glyph is indeed a character. Now when we do               $encoded = mb_convert_encoding ($original);       several thing can happen:   * the original internal representation doesn't change however it is REINTERPRETED so that the code that show up differs   * the original string that it represent doesn't change however the ENCODING change. Which one is right?


Will TSQL become useless because of new ORMs?

By introducing LINQ to SQL, I found myself and my .NET developer colleagues gradually moving from TSQL to C# to create queries on the database. Entity Framework made that shift almost permanent. Now it's nearly 2 years that I use LINQ to SQL and LINQ to Entities and haven't used TSQL that much. Yesterday, a colleague encountered a problem (he had to create a SP) and we went to help him. But we all found that our TSQL knowledge was diminished for sure, and a simple SP that seemed trivial to us 2 or 3 years ago, was a challenge to be solved yesterday. Thus it came to my mind that while TSQL's life is attached to SQL Server, and logically as long as SQL Server lives and doesn't change it's SQL language, TSQL would also live, practically it might die, and soon very few people might know it. Am I right? Do existence of ORMs like Entity Framework threaten TSQL's life and usability?


How do you convince management to "invest" in unit tests?

How did you convince your manager to let you unit test? By "use", I mean being allowed to develop, check-in to source control and maintain the unit tests over time, etc. Typical management objections are:   1. The customer didn't pay for unit tests   2. The project does not allow time for unit testing   3. Technical debt? What technical debt? Do you know other objections? What were your answers? Thanks in advance!


How do I stress the importance of unit tests to my manager

I've recently started a new job, & I've been tasked with completing a feature that another developer didn't finish before he left the company. The existing tests are out of date (i.e useless)...technical debt everywhere. I think it would be a very bad idea to implement features without tests, I've put this across to him a few times and he keeps saying that we'll complete this feature and then I can do tests. But the previous developer didn't get around to updating the tests, so it seems that my manager just says that, but doesn't mean it and keeps pushing for more features. This latest feature is a big one, and I think it would be a really bad idea to finish it without writing tests for the whole application first. I understand that my manager has his own deadlines/pressures etc, but this feature needs to be done right, or it could come back to haunt both of us. So how can i put this across to him in a way that will sink in how important this issue is? I should also mention that I'm the sole developer, and the manager is non- technical.


Layers and layers of SOAP

I am designing the back-end to a SOAP web-service and have a question about how I am thinking of doing it. I am going to go with a simple layered design which consists of 3 separate layers.               Layer 1 -> Layer 2 -> Layer 3      **Layer 1 :** Will implement the SOAP skeleton interface, so this will be the main entry point of my application. This layer will pull data from the SOAP request and pass it to the business logic layer as a business object. It will get back business objects from the business logic layer with which it will populate a SOAP response. **Layer 2 :** Business logic layer that implements the business logic behind the web-service. It will be passed data from Layer 1 and interact with Layer 3, the DAO layer. **Layer 3 :** DAO layer which will preform CRUD operations on my DB. With populating SOAP response objects in my code, the implementation might be a bit messy in Layer 1, so I came up with the following 3 options. Option 1 - Three layers is enough, any more layers would be overkill. SOAP objects are always going to be messy looking, just get over it. Option 2 - Create an extra layer between Layers 1 and 2. This layer would take data from the SOAP request, populate a business object which it would then pass to the business logic layer. This would keep the methods in Layer 1 neat and tidy. It would look something like this :               Layer 1  ->  SOAP Request   ->  Layer 1.A  ->  Business Object  ->  Layer 2     Layer 1  <-  SOAP Response  <-  Layer 1.A  <-  Business Object  <-  Layer 2         Option 3 - Do not create any more layers. Simply create a utility object with a method that takes a SOAP request and returns a business object. I could then pass the business object to Layer 2. The same utility object could then be used in Layer 2 to pass a SOAP response back to Layer 1. Or does this approach kind of blur the lines and make my design less modular?


project with 2 types of interfaces performing different jobs, should they use the same BLL and DAL?

i am working on a project that has two interface (web and desktop), they are not performing the same tasks but they use the same BLL and DAL, the web part using 100% of the BLL and DAL, while the desktop only needs to know about 20% of the BLL and DAL. do you think it is a good idea to let the desktop use the same BLL and DAL as the web, which consequently will lead to ditributing thos BLL and DAL with the desktop application? or you think i'd better create new BLL and DAL projects just to serve the desktop app? but in this case i will fall in the trap of maintaining two copies of the same code!


Is it wise for a programmer to move into management?

Many times, a developer has suggested that I become a team leader because I'm motivated, but during my career in the IT industry, I've seen so many people who are great at programming, move into management and they are miserable. I've also seen many managers return to programming stating "I'm a technical person, I like technical problems". If this is such a common thing, why do developers feel compelled to leave the technical domain and move into management? Sure you'll have more money and more control, but if you don't enjoy your work and take your problems out on your team, that's hardly economic of your time. Secondly, I've been asked in developer interviews, "Would you consider leading a team?" and I'm always tempted to cite the Peter Principle based on what I've seen. I am interested in furthering myself, but not in the way the company may want i.e "Vice President of department blah". To be honest, I've seen this more often in the corporate world than in small development houses and it's always put me off ever going back to a corporate environment. I just feel that this is becoming more and more the norm and it's impacting team morale and degrading the quality of the work. Question: Based on what I've said, Is it a smart move for a technical person to move into management?


How do you think about using `//` for JSON comment?

I'm considering extending JSON by adding comment. For just my own project, internally. If JSON got a comment, I think its syntax should be `//`~`\n` style, JavaScript syntax. How do you think?


How to explain that writing universally cross-platform C++ code and shipping products for all OSes is not that easy?

Our company ships a range of desktop products for Windows and lots of Linux users complain on forums that we should have been written versions of our products for Linux years ago and the reason why we don't do that is   * we're a greedy corporation   * all our technical specialists are underqualified idiots Our average product is something like 3 million lines of C++ code. My and my colleagues analysis is the following:   * writing cross-platform C++ code is not that easy   * preparing a lot of distribution packages and maintaining them for all widespread versions of Linux takes time   * our estimate is that Linux market is something like 5-15% of all users and those users will likely not want to pay for our effort when this is brought up the response is again that we're greedy underqualified idiots and that when everything is done right all this is easy and painless. How reasonable are our evaluations of the fact that writing cross-platform code and maintaining numerous ditribution packages takes lots of effort? Where can we find some easy yet detailed analysis with real life stories that show beyond the shadow of a doubt what amount of effort exactly it takes?


Sucking Less Every Year?

Sucking Less Every Year -Jeff Atwood I had come across this insightful article.Quoting directly from the post > I've often thought that sucking less every year is how humble programmers > improve. You should be unhappy with code you wrote a year ago. If you > aren't, that means either A) you haven't learned anything in a year, B) your > code can't be improved, or C) you never revisit old code. All of these are > the kiss of death for software developers.   1. How often does this happen or not happen to you?    2. How long before you see an actual improvement in your coding ? month, year?   3. Do you ever revisit **Your** old code?   4. How often does your old code plague you? or how often do you have to deal with your technical debt. It is definitely very painful to fix old bugs n dirty code that we may have done to quickly meet a deadline and those quick fixes ,some cases we may have to rewrite most of the application/code. No arguments about that. Some of the developers i had come across argued that they were already at the _evolved_ stage where their coding doesn't need improvement or cant get improved anymore.   * Does this happen?    * If so how many years into coding on a particular language does one expect this to happen? Related: Ever look back at some of your old code and grimace in pain? Star Wars Moment in Code **"Luke! I am your code!" "No! Impossible! It can't be!"**


How should I manage my time?

There are times when just one bug that keeps eating away your time like hell ... for example this one. I generally end up wasting hours and realize I've gone terribly behind my schedule and not completed other tasks. With n number of tabs open in the browser, I end up posting the question in stackoverflow as a last resort. What are some time management techniques that lets you stop, rewind and get back in action when faced with a road block?


Object-Oriented Design: What to do when responsibility of the class is big

I applied principles of the GRASP and ended up having a class called Environment. This class's responsibilities are to:   * Keep information about services in the environment,i.e. environment definition (Service is another class)   * Start/stop services meeting some criteria   * Apply configuration changes to different service and keep list of updated services   * Restart services with configuration change   * Revert configuration changes at the end of session   * Search/Give Service class based on criteria (name etc.) According to OOD, this is not a problem: _very cohesive responsibility is assigned to this class_.   But on the other hand it's a problem since the _class is too big_ , even though all responsibility assigned to it makes sense. If I want to divide this responsibility to between separate classes, then all these classes need to know about "environment definition", which makes coupling worse and those classes will have _"feature envy"_. What design patterns are applicable for such situation? Or what other principals can be applied to have cohesive, less coupled classes? Thanks in advance.


What uses IronPython has?

I've been wondering to myself, what uses does IronPython have in a .NET environment? what can it do that can't be done with VB, C# or F#? It seems kind of strange to go through all the trouble of making the DLR and enabling dynamic languages on the clr just to add another language.   What do people use IronPython for?


What are the best things to put in my portfoilo to demonstrate my Java skills and make me more marketable?

I have studied Java for quite a while and written a lot of small SE programs. I have a good grasp on the language at this stage but unfortunately I do not work in the area of Java programming (as of yet). I would like to develop a portfolio of Java programs for the purposes of moving into this area. This is also vital in most interviews. I also would like to develop this portfolio to further my learning (maybe in the area of Java EE). Can anybody recommend a starting point? GF


What is the difference between Static code analysis and code review?

I just wanted to know what the difference is between static code analysis and code review. How are each of these two done? More specifically, what are the tools available today for code review/static analysis of PHP? I would also like to know about good tools for code review for any language.


Why is my page load time so closely correlated with number of database queries?

Whenever I'm doing web development, and a page takes longer than half a second to be generated, I know that somewhere my code is hitting the DB too many times. The normal way to fix this situation is to ask the DB for all the information all at once instead, by doing JOINs and the like. My question is: Why do many database queries make a page slow? There must be considerable overhead to each query, but what is it? **EDIT** : Alright, let's take an example (it's a bit silly and small, but it'll do) `people` table:               | name | football_team_id |      +------+------------------+     | jim  | 1                |     | mike | 3                |     | carl | 2                |      `football_team` table:               | id | color |     +----+-------+     | 1  | red   |     | 2  | blue  |     | 3  | green |      We all know that this is slow:               SELECT name,football_team_id FROM people;     # start rendering the page, realise we need colors     SELECT color FROM football_team WHERE id=1     # oops, need mike's color     SELECT color FROM football_team WHERE id=3     # oh, and carl's     SELECT color FROM football_team WHERE id=2      This is a bit better:               SELECT name,football_team_id FROM people;     SELECT id,color FROM football_team WHERE id IN (1,3,2)      This is best:               SELECT name,football_team_id,color FROM people JOIN football_team ON people.football_team_id=football_team.id      In each example we're getting the same amount of data, but the latter is easily the fastest. You wouldn't expect the same behaviour if you were reading from a file descriptor, for example.


The definition of C-based language

What is the definition of C-based language?   Is C# considered to be C-based?   Is Java considered to be C-based? Furthermore, what does it mean for a language to be based on another language anyway?


What's the correct approach for passing data from several models into a service?

I have an `AccountModel` and a page where the user can upload a file. What I would like to have happen is when the user uploads the file. The `PageController` does something like the following. this is a quick attempt just written in the question to illustrate my question.               public class PageController : Controller {       private Service service;           public ActionResult Upload(HttpPostedFileBase f){              service.savefile(f,_AccountModel_whatever.currentlyloggedinuser.taxid)          }     }               public class Service     {     // abunch of validation and error checking to make sure the file is good to store     }      Wouldn't this approach be in bad practice? Since I'm making my controller dependent on the existence of th AccountModel? This will become a **HUGE** program over the next few years, and I really want to maximize the quality of the framework now.


Capturing mobile device system (output) audio

I'm trying to figure out a way to capture the system audio of an Android and/or Windows Phone. The idea is to provide a stream based on the music I'm currently playing on my phone. What I'm not sure about is what the best approach would be for sending the audio. Preferably I'd like to capture all the device audio (same as when connected to a bluetooth device). But I'm not sure whether this is possible with Android or Windows Phone. For Android I found this article http://xzpeter.org/?p=254, he states this is'nt possible without making your own Android build. Which isn't an option for me. For Windows Phone I can only find ways to capture audio from the mic. Not directly from the system. The only alternative I can come up with is to let the app provide all the audio, meaning I would have to build all the basic mediaplayer functionality into the app. But this would mean I have to put much more work into the app, and I wouldn't be able to use other apps like Winamp and YouTube to provide audio. Did I maybe overlook a way to capture all the audio of the device? Or maybe there's a way to capture audio from specific applications? **Edit** After doing some more research, I really doubt I can capture all system audio. Or maybe it's possible to simulate an bluetooth audio device? For the Windows Phone I was going for the alternative solution: selecting songs which would then be streamed to the server. But it seems that for Windows Phone it's not even possible to get physical access to the songs: http://stackoverflow.com/questions/16251400/stream-a-xna-framework-media-song- to-a-server


Is an event loop just a for/while loop with optimized polling?

I'm trying to understand what an event loop is. Often the explanation is that in the event loop, you do something until you're notified that an event occurred. You than handle the event and continue doing what you did before. To map the above definition with an example. I have a server which 'listens' in a event loop, and when a socket connection is detected, the data from it gets read and displayed, after which the server goes to the listening it did before. * * * However, this event happening and us getting notified 'just like that' are to much for me to handle. You can say: "It's not 'just like that' you have to register an event listener". But what's an event listener but a function which for some reason isn't returning. Is it in it's own loop, waiting to be notified when an event happens? Should the event listener also register an event listener? Where does it end? * * * Events are a nice abstraction to work with, however just an abstraction. I believe that in the end, polling is unavoidable. Perhaps we are not doing it in our code, but the lower levels (the programming language implementation or the OS) are doing it for us. It basically comes down to the following pseudo code which is running somewhere low enough so it doesn't result in busy waiting:               while(True):         do stuff         check if event has happened (poll)         do other stuff      * * * This is my understanding of the whole idea, and i would like to hear if this is correct. I am open in accepting that the whole idea is fundamentally wrong, in which case I would like the correct explanation. Best regards


Write a directory structure (pseudo code)

I am writing a wiki article and wondering what is the proper way to write a directory scheme? I am doing something like               main folder     - sub folder     - sub folder     ...      But I'm stuck after that. Any help?


Got made redundant after three months - should I include this in my resume?

In my last job, I was hired for a specific project which the company lost before I even got a chance to start work on it: four people were made redundant on the same day. I spent three months there and while I did learn new dev skills (I worked on a minor project while waiting to start on the main one), I cannot consider myself an expert in the speciality of this company (barely passing familiar). As a developer, should I maintain this on my resume? Do I even say that I was made redundant or is it best to leave it out entirely? Rob :)


Calculating WPM given a variable stream of input

I'm creating an application that sits in the background and records all key presses (currently this is done and working; an event is fired every keydown/keyup). I want to offer a feature for the user that will show them their WPM over the entire session the program has been running for. This would be easy if I added a "Start" and "End" button to activate a timer, but I need to detect only when the user is typing continuously - ignoring all one-time keyboard shortcuts and breaks the user takes from typing. How in the world do I approach this? Is this even realistically & accurately possible?


How to deal with data on the model specific to the technology being used?

There are some cases where some of the data on a class of the domain model of an application seems to be dependent on the technology being used. One example of this is the following: suppose we are building one application in .NET such that there's the need of an Employee class. Suppose further that we are going to implement relational database, then the Employee has a primary key right? So that the classe would be something like               public class Employee      {          public int EmployeeID { get; set; }          public string Name { get; set; }          ...      }      Now, that EmployeeID is dependent on the technology right? That's something that has to do with the way we've choose to persist our data. Should we write down a class independent of such things? If we do it this way, how should we work? I think I would need to map all the time between domain model and persistence specific types, but I'm not sure.


How to implement multi-theme PHP application

I am developing an application which will handle many virtual stores and I would like to have many themes that the user could choose anytime. I would to know what's the main ideia to implement it. I will be developing it using Symfony 2. I was thinking about implementing own views and assets for each theme   * Resources      * views        * theme 1          * Product            * List.html           * Detail.html           * ...       * theme 2          * Product            * List.html           * Detail.html           * ...       * theme 3          * Product            * List.html           * Detail.html           * ...     * public        * theme 1 assets          * js         * css         * images         * ...       * theme 2 assets          * js         * css         * images         * ...       * theme 3 assets          * js         * css         * images         * ... And in the database each user would have own preferences(theme name, color, etc...). I am looking for an implementation which will allow me to add any kind of theme. For exemple, one theme, in main page the cart icon will go cart page and another theme, cart icon will pop up a window showing products. What's the best approach to implement multi theme web application? What I am missing?


REST Service Authentication/Authorization

I have a WCF rest service that will be consumed by multiple clients. The information returned by the client requires me to know who they are, so that I can return information specific to them. Is the best way to approach this type of design to authenticate them and return a token for their session, then pass this token along with every request? Thanks.


When should you use bools in C++?

We had an assignment for our class where we had to create a _Tic-tac-toe_ game. People like to complicate themselves, so they wrote complex games which included menus. At the end of the game, you had to have the option to play again or quit the program. I used an `int` variable for that, but I noticed some classmates using BOOLs. Is it more efficient? What's the difference, between storing an answer that should only store two values in an `int` rather than storing it in a bool? What is the exact purpose of these variables?


Multistream Project v/s Single Stream project

If we want to have code reviews before a developer delivers his work, then can you suggest whether multi stream project { i.e., each developer create his own stream and view and later deliver to single stream.} or single stream { i.e., all developers work on same stream } which is advisable.


Combining multiple events into one action/ Defer refreshing

So in a GUI program I have multiple events that trigger a update of a workspace. This update call is costly so I would want it to not happen very often. A user might pick something from a dropdown ( triggers a refresh ) and then put a check in a checkbox (also triggers a refresh ). If he does this in a short time interval this might result in the first refresh to be irrelevant. One way to handle this would be to have a refresh button for the user to press, or a toggle to set whether to automatically refresh. But I wouldn't want to put this in the hands of the user. Is there any other strategy to do this that is proven to be effective and error free? PS. I'm specifically using .Net 4.0 -> C# -> WPF -> Caliburn.Micro but would like to hear of any method that could be reproduced using .net 4


Questions about what professional C++ programming is like

I currently program professionally in C#, and since I started in 2008 I've been curious about what unmanaged, C++ programming is like. I've looked at the obvious answer -to look at the job descriptions online - but they're high- level descriptions and job requirements that don't really go into the details of what professional programming in C++ is like. If you're a Windows programmer, does this usually involve working with CLI, MFC, or ATL? How many jobs are about maintaining legacy code vs. innovating something new? Is the extra attention to memory management an interesting challenge or a tedious task? Are the standard and Windows/UNIX libraries enjoyable to work with? How often do you see a programmer go from a more "high-level" language background like C# or Java to C++, and how often do you see programmers move in the other direction? What do you think will drive demand for future generations of C++ programmers (e.g. game development or maintaining legacy systems)?


How to manage document format changes with local storage?

I'm programming a Javascript application which saves "documents" in localStorage. As the app evolves, naturally there are changes in the document format. I've tried searching but not found anything – probably (at least partly) because of search term ambiguities. What is a good practice in managing document format versions/upgrades with local storage implementation approach?


Programming language and database concurrent locking primitives

I am writing an article about both programming language locking primitives (which are really wrappers for OS primitives) and database locking primitives. Are there any short wide-spread titles for these two types of locking? For example, "code locking" and "database locking"?


What defines a standard?

What defines a standard like HTML5, C++0x, etc.? Is it just that you hand something in to W3C/ANSI/ISO/..., they produce a couple hundred pages long document and suddenly it's a standard? Can't I, as an individual, create something and standardize it by myself? I surely could produce a couple hundred pages long document which describes my creation in every detail. So what is the benefit of               publisher: W3C          Stand...      ?


Is it true that first versions of C compilers ran for dozens of minutes and required swapping floppy disks between stages?

Inspired by this question. I heard that some very very early versions of C compilers for personal computers (I guess it's around 1980) resided on two or three floppy disks and so in order to compile a program one had to first insert the disk with "first pass", run the "first pass", then change to the disk with "second pass", run that, then do the same for the "third pass". Each pass ran for dozens of minutes so the developer lost lots of time in case of even a typo. How realistic is that claim? What were actual figures and details?


How to get better at testing your own code

I am a relatively new software developer, and one of the things I think I should improve is my ability to test my own code. Whenever I develop a new functionality, I find it really difficult to follow all the possible paths so I can find bugs. I tend to follow the path where everything works. I know this is a well known issue that programmers have, but we don't have testers at my current employer and my colleagues seem to be pretty good at this. At my organization, we do neither test-driven development nor unit testing. It would help me a lot but it's not likely that this will change. What do you guys think I could do in order to overcome this? What approach do you use when testing your own code?


Why do XSLT editors insert tab or space characters into XSLT to format it?

All XSLT editors I've tried till now add tab or space characters to the XSLT to indent it for formatting. This is done even in places within the XSLT where these characters are significant to the XSLT processor. XSLT modified for formatting in this way can produce output very different to that of the original XSLT if it had no formatting. To prevent this, _xsl:text_ elements or other XSLT must be added to a sequence constructor to help separate formatting from content, this additional XSLT impacts on maintainability. Formatting characters also adversely impact on general usability of the tool in a number of ways (this is why word-processors don't use them I guess) and add to the size of the file. As part of a larger project I've had to develop a light-weight XSLT editor, it's designed to format XSLT properly, but without tab or space characters, just a dynamic left-margin for each new line. The XSLT therefore doesn't need additional elements to separate formatting tab or space characters from content. The problem with this is that if XSLT from this editor is opened in other XSLT editors, characters will be added for formatting reasons and the XSLT may therefore no longer behave as intended. Why then do existing XSLT editors use tabs or spaces for formatting in the first place? I feel there must be valid reasons, perhaps historical, perhaps practical. An answer will help me understand whether I need to put compatibility options in place in my XSLT editor somehow, whether I should simply revert to using tabs or spaces for both XSLT content and formatting (though this seems like a backwards step to me), or even whether enough XSLT users might be able to persuade their tools vendors to include alternative formatting methods to tabs or spaces. **Note:** I provided an XSLT sample demonstrating formatting differences in this answer to the question: _Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever?_


What do you think of opening brace comments in source code?

I have developed a habit of writing comments in my code by putting the comments on the same line as the opening brace, after the brace. I've found that this saves vertical space. It also leaves a hint why something was done, but I'm wondering if it's readable for others. Example:               void DoSomeInterestingImageManipulation(char *pImage)     {//This will convert the image to formatABC which allows x% space savings for storage         if(pImage && pImage[0] == 0xFF)         {//Process the extra case where image internal format needs decompression             ++pImage;             //...             //...             //...         }              //Proceed normally         *pResult = Foo(pImage);     }      Do you consider it easier to read or harder to read?


Managing SQL Stored Procedures' Version

I am working with a team of 5 persons. We are using SQL Server as our database. Since long time I want to store the Stored Procedures in SVN so that the versions can be maintained. Is there any tool which can be used as a plugin with SQL Server Management Studio and allows checkin from there.


Software Optimization vs. Hardware Optimization - what has the bigger impact?

I was wondering how software optimization and hardware optimization compare when it comes to the impact they have on speed and performance gains of computers. I have heard that improving software efficiency and algorithms over the years has made huge performance gains. Obviously both are extremely important, but what has made the bigger impact in the last 10, 20 or 30 years? And how do hardware changes affect the software changes? How much of software optimization is a direct result of hardware improvements and how much is independent of the hardware? To be clear, I am asking about software optimizations at the level of compilers and operating systems. Obviously using better high level-algorithms will result in the largest speed ups (think: quick-sort vs. bubble-sort), but this question is about the underlying reason why computers are faster today, in general.


How to remove the boundary effects arising due to zero padding in scipy/numpy fft?

I have made a python code to smoothen a given signal using the Weierstrass transform, which is basically the convolution of a normalised gaussian with a signal. The code is as follows:               #Importing relevant libraries       from __future__ import division       from scipy.signal import fftconvolve        import numpy as np           def smooth_func(sig, x, t= 0.002):            N = len(x)            x1 = x[-1]            x0 = x[0]                   # defining a new array y which is symmetric around zero, to make the gaussian symmetric.           y = np.linspace(-(x1-x0)/2, (x1-x0)/2, N)            #gaussian centered around zero.           gaus = np.exp(-y**(2)/t)               #using fftconvolve to speed up the convolution; gaus.sum() is the normalization constant.           return fftconvolve(sig, gaus/gaus.sum(), mode='same')      If I run this code for say a step function, it smoothens the corner, but at the boundary it interprets another corner and smoothens that too, as a result giving unnecessary behaviour at the boundary. I explain this with a figure shown in this image This problem does not arise if we directly integrate to find convolution. Hence the problem is not in Weierstrass transform, and hence the problem is in the fftconvolve function of scipy. To understand why this problem arises we first need to understand the working of fftconvolve in scipy.   The fftconvolve function basically uses the convolution theorem to speed up the computation. In short it says:               convolution(int1,int2)=ifft(fft(int1)*fft(int2))        If we directly apply this theorem we dont get the desired result. To get the desired result we need to take the fft on a array double the size of max(int1,int2). But this leads to the undesired boundary effects. This is because in the fft code, if size(int) is greater than the size(over which to take fft) it zero pads the input and then takes the fft. This zero padding is exactly what is responsible for the undesired boundary effects. _**Can you suggest a way to remove this boundary effects?_** I have tried to remove it by a simple trick. After smoothening the function I am compairing the value of the smoothened signal with the original signal near the boundaries and if they dont match I replace the value of the smoothened func with the input signal at that point.   It is as follows:               i = 0      eps=1e-3     while abs(smooth[i]-sig[i])> eps: #compairing the signals on the left boundary         smooth[i] = sig[i]         i = i + 1     j = -1          while abs(smooth[j]-sig[j])> eps: # compairing on the right boundary.         smooth[j] = sig[j]         j = j - 1      There is a problem with this method, because of using an epsilon there are small jumps in the smoothened function. _**Can there be any changes made in the above method to solve this boundary problem?_**


What is the point of using the private access modifier for C# class members?

From MSDN... > The access level for class members and struct members, including nested > classes and structs, is private by default. If class members are private by default then why use the private access modifier for them? I see it all the time in code examples and open source projects including the ASP.NET MVC source. I even use it in my own projects but I'm left wondering why.


Multiple projects - similar platforms or as different as possible?

When working on multiple projects simultaneously (for the sake of simplicity let's say half time each on two projects), which is better? Should the two projects   * Use the same language? Same/similar frameworks?   * Use entirely different languages? Additionally, is it best if they are target for similar platforms, or different (web v. desktop v. mobile v. utility library for internal use)? The first responses that come to mind are   * They should be similar, and play to the strengths of the developer to help him handle managing both of them   * They should be as different as possible to help the developer keep organized Since I've never done this in a professional setting, I was hoping more experience programmers could shed some light on the best way to go about doing this. **EDIT** :   This question is assuming the existence of multiple other projects, each of which is underway (I think some underway and some brand new with no design decisions yet made would be too broad for one question). When choosing between existing projects for a second project, should a developer consider how similar his new project is to his current project, and how should that affect the decision?


Learning to program in C (coming from Python)

If this is the wrong place to ask this question, please let me know. I'm a Python programmer by occupation. I would love to learn C. Indeed, I have tried many times, but I always get discouraged. In Python, you write a few lines and the program does wonders. In C, I can't seem to be able to do anything useful. It seems to be very complicated to even connect to the Internet. Do you have any suggestions on what I can do to learn C? Are there are any good websites? Any cool projects? Thanks


Extending user registration in Django site that uses both site admin tables and my own module?

I'm writing a Django site that registers a particular type of user and this is done by the resources that come with the framework, the site administration. The issue: I'd like to create a new model with a foreign key to an admin site table and loaded from a excel cvs that augments the data from the user registration form. I'd like to do this in a database agnostic way without sql. Just using models, urls, forms, template language etc. I do not know how to check the contents of the user registration form against the new table? **forms.py**               from django import forms     from django.contrib.auth.models import User     from django.contrib.auth.forms import UserCreationForm     from django.core.mail import send_mail     #     # Called by register_user view.     #     class MyRegistrationForm(UserCreationForm):         email = forms.EmailField(required=True)              class Meta:             model = User             fields = ('username',                        'password1', 'password2',                        'email', 'first_name', 'last_name',)              def save(self, commit=True):                  # create and load user object             user = super(MyRegistrationForm, self).save(commit=False)             user.email = self.cleaned_data['email']             user.first_name = self.cleaned_data['first_name']             user.last_name = self.cleaned_data['last_name']                         if commit:                 user.save()                 send_mail('Your Provider Enrollment Registration',                           'You are now an authenticated provider!',                            'donfox1@mac.com',                           [user.email], fail_silently=False)                              return user      **models.py**               class NPIdata(models.Model):         '''          NPI data is associated with admin site User accounts.         '''         NPI = models.IntegerField(max_length=10)         lastname = models.CharField(max_length = 20)         firstname = models.CharField(max_length = 20)         Credential = models.CharField(max_length = 15)         user = models.ForeignKey(User)


Can I use silverlight for building SocialNetworking applicaiton?

I am wondering: how feasible it would be to start developing a social networking website entirely based on silverlight; This has been fairly discussed over the years in favor of HTML. Has something changed with silverlight improvements over the years? What about:               * Performance       -- active users       -- technology used, MVVM + MEF (possibility of lags, server memory overflow...)     * Security       --- WCF Ria Services & EF      What are your thoughts on this subject?


How to comment on a PEP?

Proposals for new Python features are collected in documents called PEPs (Python Enhancement Proposals). There's a master list at http://www.python.org/dev/peps/ which links to (for example):   * Labeled break and continue http://www.python.org/dev/peps/pep-3136/   * Asynchronous IO support http://www.python.org/dev/peps/pep-3153/   * Remove Backslash Continuation http://www.python.org/dev/peps/pep-3125/ It's great that proposals are published publicly for the community to read. However, how is the community supposed to participate? The pages don't allow comments. It strikes me as weird the Python developers would make proposals public then deliberately exclude the community from discussion. Have I missed something? In particular, I'd like to read other people's comments on http://www.python.org/dev/peps/pep-0453/ and add my own. * * * For comparison, Ruby feature proposals are made as posts to its bug tracker. You can read everyone's comments below, and add your own (after making an account)   * Refinements and nested methods https://bugs.ruby-lang.org/issues/4085   * Frozen string syntax https://bugs.ruby-lang.org/issues/8579   * Exception#cause to carry originating exception along with new one https://bugs.ruby-lang.org/issues/8257 Nodejs feature requests are plain GitHub issues, which is probably the most inclusive. It's very easy to join GitHub and post a comment.   * https://github.com/joyent/node/issues?labels=feature-request


Interaction between programs

I am writing an interactive program in which it takes speech input from the user for a specific list of commands. The list of commands will be stored locally in a graph and based on the usage their weight will be modified. The speech input is taken and processed into text and then it's executed by bash scripts. I am thinking what I should use to interact (synchronize) between the speech recognition engine and then the list and the bash program. I am using C++ and Bash on a Unix system. I thought of `mutex` but the problem is what if the user gives multiple inputs then I'll have to buffer it and then process it sequentially and that will make the system slower. The bash script is used to call the system utility commands as requested by the user. Should I only use C++ or Bash too? I am thinking of storing the graph in a binary format. Is this the best way to store the graph? Please suggest alternatives.


How to convince my company (operating in the financial sector) to switch from PHP to Java

My company is in the financial sector and it is using PHP as programming language. I am a PHP developer myself. I am leading a big project started from almost scratch. I can see how PHP is not the best candidate for building robust platforms. I want to convince my company to _gradually_ switch to Java (which I have experience with). I was trying to find as many supporting arguments as possible. Can you help with this? So far I have found these:   * Most of the competitors are using Java (anyway not PHP)   * Most financial companies use Java rather than PHP   * On average, Java developers are better prepared (on average!)   * The compilation process catches a lot of problems before the software runs in production   * Strong typing makes everything more robust as contracts between interfaces is well defined Any other points I am missing? Thanks!


Best Practice Method for Including Images in a DataGrid using MVVM

All, I have a WPF `DataGrid`. This `DataGrid` shows files ready for compilation and should also show the progress of my compiler as it compiles the files. The format of the `DataGrid` is               Image|File Path|State     -----|---------|-----        *    |C:\AA\BB |Compiled     &    |F:PP\QQ  |Failed     >    |G:HH\LL  |Processing     ....      The problem is the image column (the *, &, and > are for representation only). I have a `ResourceDictionary` that contains hundreds of vector images as `Canvas` objects:               <ResourceDictionary xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"                           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">     <Canvas x:Key="appbar_acorn" Width="48" Height="48" Clip="F1 M 0,0L 48,0L 48,48L 0,48L 0,0">         <Path Width="22.3248" Height="25.8518" Canvas.Left="13.6757" Canvas.Top="11.4012" Stretch="Fill" Fill="{DynamicResource BlackBrush}" Data="F1 M 16.6309,18.6563C 17.1309,8.15625 29.8809,14.1563 29.8809,14.1563C 30.8809,11.1563 34.1308,11.4063 34.1308,11.4063C 33.5,12 34.6309,13.1563 34.6309,13.1563C 32.1309,13.1562 31.1309,14.9062 31.1309,14.9062C 41.1309,23.9062 32.6309,27.9063 32.6309,27.9062C 24.6309,24.9063 21.1309,22.1562 16.6309,18.6563 Z M 16.6309,19.9063C 21.6309,24.1563 25.1309,26.1562 31.6309,28.6562C 31.6309,28.6562 26.3809,39.1562 18.3809,36.1563C 18.3809,36.1563 18,38 16.3809,36.9063C 15,36 16.3809,34.9063 16.3809,34.9063C 16.3809,34.9063 10.1309,30.9062 16.6309,19.9063 Z "/>     </Canvas>     </ResourceDictionary>      Now, I want to be able to include these in my image column and change them at run-time. I was going to attempt to do this by setting up a property in my View Model that was of type `Image` and binding this to my View via:               <DataGrid.Columns>         <DataGridTemplateColumn Header=""                                  Width="SizeToCells"                                  IsReadOnly="True">             <DataGridTemplateColumn.CellTemplate>                 <DataTemplate>                     <Image Source="{Binding Canvas}"/>                 </DataTemplate>             </DataGridTemplateColumn.CellTemplate>         </DataGridTemplateColumn>     </DataGrid.Columns>      Where in the View Model I have the appropriate property. Now, I was told this is not 'pure' MVVM. I don't fully accept this, but I want to know if there is a better way of doing this. Say, binding to an enum and using a converter to get the image? Any advice would be appreciated.


Reasoning behind the syntax of octal notation in Java?

Java has the following syntax for different bases:               int x1 = 0b0101; //binary     int x2 = 06;     //octal     int x3 = 0xff;   //hexadecimal      Is there any reasoning on why it is `0` instead of something like `0o` like what they do for binary and hexadecimal? Is there any documentation on why they went this route?


For in-house programmers (non-project managers), do you normally receive project instructions written out in advance?

I'm fairly new to working as a programmer, at least working as a regular employee in-house for a company. I often become frustrated with my company's management style as they basically just pick out whatever random tasks catches the lead developer's fancy that day, or the day before, and give me the task (with tasks usually lasting less than 1 day). A lot of the tasks I have now are fairly small and are for adding enhancements to a web application, fixing bugs, etc. I am bothered, however, by the fact that they don't plan ahead so as to give me an written outline of projects a few days in advance so that if, for example, I am rusty on something I can at least familiarize myself with it on my own time or at least have a more relaxed approach to the job so that everything doesn't have to be so reactionary on my part (where I can mull things during off-time over before starting work on them, etc) I guess I'm just curious if this is the norm or if most development jobs value clearly laid out specifications for tasks and are able to prepare them somewhat in advance. I would be interested to hear anyone's experience / opinions, etc. Thanks


Where to find open source volunteers?

We have an open source Java project (REMPL) and actively looking for volunteers. What is the best way to find them? Junior programmers are OK for us.


A good tool set for ASP.NET development

What are some good (or must have) ASP.NET development/debugging tools in addition to Visual Studio IDE? So far the only trick in my pocket is .NET Reflector, that has come in handy before. (I would limit browsers add-ons to IE if possible, since I'm working on a corporate intranet and using FF is not always an option).


Is it good practice to use NoStackTrace in scala?

I came across the `NoStackTrace` mixin for Exceptions in scala. Is it good practice to use it, or should it be considered "internal" to scala and left alone?


Is a 'God' ViewModel desired in WPF

My application has user controls within user controls. Please see a screen shot of one of the most beautiful applications of all time (UC = user control): ![enter image description here](http://i.stack.imgur.com/EEvpd.png) All the properties live in the MainWindow code behind, there are none in my UserControls. To bind to my properties I use               DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1,AncestorType=Window}}"      This works fine but, it does mean all binding properties are in my MainWindow code behind (or the MainWindow ViewModel). Is this desired in a MVVM (or should I say WPF) approach, in that all the children share the same ViewModel?


Should one check for null if he does not expect null?

Last week, we had a heated argument about handling nulls in our application's service layer. The question is in the .NET context, but it will be the same in Java and many other technologies. The question was: should you always check for nulls and make your code work no matter what, or let an exception bubble up when a null is received unexpectedly? On one side, checking for null where you are not expecting it (i.e. have no user interface to handle it) is, in my opinion, the same as writing a try block with empty catch. You are just hiding an error. The error might be that something has changed in the code and null is now an expected value, or there is some other error and the wrong ID is passed to the method. On the other hand, checking for nulls may be a good habit in general. Moreover, if there is a check the application may go on working, with just a small part of the functionality not having any effect. Then the customer might report a small bug like "cannot delete comment" instead of much more severe bug like "cannot open page X". What practice do you follow and what are your arguments for or against either approach? Update: I want to add some detail about our particular case. We were retrieving some objects from the database and did some processing on them (let's say, build a collection). The developer who wrote the code did not anticipate that the object could be null so he did not include any checks, and when the page was loaded there was an error and the whole page did not load. Obviously, in this case there should have been a check. Then we got into an argument over whether every object that is processed should be checked, even if it is not expected to be missing, and whether the eventual processing should be aborted silently. The hypothetical benefit would be that the page will continue working. Think of a search results on Stack Exchange in different groups (users, comments, questions). The method could check for null and abort the processing of users (which due to a bug is null) but return the "comments" and "questions" sections. The page would continue working except that the "users" section will be missing (which is a bug). Should we fail early and break the whole page or continue to work and wait for someone to notice that the "users" section is missing?


Should a method validate its parameters?

Say you are designing a Square root method sqrt. Do you prefer to validate the parameter passed is not a negative number or do you leave it up to the caller to make sure the param passed is valid. How does your answer vary if the method/API is for 3rd party consumption or if it is only going to be used for the particular application you are working on I have been of the opinion that a method should validate its parameter, however, Pragmatic Programmer in its Design by Contract section (chapter 4) says it's the caller responsibility to pass good data (pg 111 and 115) and suggests using Assertions in the method to verify the same. I want to know what others feel about this.


Does (should?) changing the URI scheme name change the semantics?

If we take:               http://example.com/foo      is it fair to say that:               ftp://example.com/foo      .. points to the _same_ resource, just using a different mechanism for resolving it (and of course possibly a different representation, but perhaps not)? This came to light in a discussion we were having surrounding some internal tooling with Git. We have to process some Git repositories, and they come to use as "git@{authority}/{path}" , however the library we're using to interface with them doesn't support the `git` protocol. I suggested that we should make the service robust in of that it tries to use HTTP or SSH, in essence, discovering what protocols/schemes are supported for resolving the repository at {path} under each {authority}. This was met with some criticism: "We don't know if that's the same repository". My response was: "It had better be!" Looking at RFC 3986, I see this excerpt: > URI "resolution" is the process of determining an access mechanism and the > appropriate parameters necessary to dereference a URI; this resolution may > require several iterations. To use that access mechanism to perform an > action on the URI's resource is to "dereference" the URI. Which makes me think that the resolution process is permitted to try different protocols, because: > Although many URI schemes are named after protocols, this does not imply > that use of these URIs will result in access to the resource via the named > protocol. The only concern I have, I guess, is that I only see reference to the notion of changing protocols when it comes to traversing relationships: > it is possible for a single set of hypertext documents to be simultaneously > accessible and traversable via each of the "file", "http", and "ftp" schemes > if the documents refer to each other with relative references. I'm inclined to think I'm wrong in my initial beliefs, because the `Normalization and Comparison` section of said RFC doesn't mention any way of treating two URIs as equivalent if they use different schemes. It seems like schemes named/based on IP protocols ought to have this notion, at least?


suggesting large changes/a rewrite as an intern

**The context:**   * it's an internal project (that I don't think a lot of people use)   * it's old   * we're updating it **The issues:**   1. it abuses the mvc framework (no use of models, business logic in views, etc)   2. what we're being asked to do is small, but because of the low cohesion we have two options:      1. continue to botch things     2. move large chunks of code around or rewrite the thing **The solutions (I see):**   1. continue working with it, ignore best practices in favor of being done soon and not introducing new bugs by refactoring/rewriting   2. refactor/rewrite I guess my question is really: if I want to make large changes to this project, how do I do propose that without insulting anyone? Or would it be better for me to simply go with the flow even if that means (metaphorical) duct-tape sometimes?


How significant is the impact of the type system (static/dynamic) on the overall design of programs?

Coming from Java, I've never used a language with dynamic typing. I'm very used to the static-typing way of thinking. My question is, how much does the use of dynamic typing as opposed to static typing influence the overall design of programs written using languages with that kind of typing? **Does the kind of typing (static/dynamic) influence the design of programs significantly?** Working with a dynamically-typed language, would you structure your application differently than working with a statically-typed language? **Or is it merely a language characteristic that affects mainly local implementation details, but doesn't affect overall designs?**


C API in C++ with RAII, two alternatives to implement error handling (Exceptions)

I have an API written in C, which produces a result by returning a pointer to allocated memory.   For using it with C++ (C++11) I've wrapped the function calls in objects, which keep the result in a `std::shared_ptr`. So far so good. However, the C library features _two_ functions for every operation. One produces possibly an error, the other never. Let's call them   `some_pod * do_it_with_error(Parameter ..., Error **)`   and   `some_pod * do_it_without_error(Parameter ...)` I can pass in the address of an `Error *` pointer to the first function and if there's an error it won't be `NULL` afterwards. For solving this I thought of two different implementations.   First, I could SFINAE for choosing between the `with_error` and `without_error` functions, like so:               template<typename NoThrow = void>     struct do_it {       public:         void operator()(...)         {           Error * error = NULL;           m_result = std::shared_ptr<some_pod>(do_it_with_error(..., &error));           if (error) {             throw(MyExceptionWithError(error));           }         }       private:         std::shared_ptr<some_pod> m_result;     };          template<>     class do_it<std::nothrow_t> {       public:         void operator()(...) noexcept         {           if (! m_result) {             m_result = std::shared_ptr<some_pod>(do_it_without_error(...));           }         }       private:         std::shared_ptr<some_pod> m_result;     };      Usage:               do_it<> di_error;     try {       di_error(...); // might throw     } catch (...) {}          do_it<std::nothrow_t> di_no_error;     di_no_error(...); // won't throw for sure      However, since the result is wrapped in a `std::shared_ptr` there will also be a `get()` method:               const std::shared_ptr<some_pod> & get(void) { return m_result; }      For error checking I could just implement a another method `check`.   The default implementation would now look like this:               struct do_it {       public:         // will never throw         const std::shared_ptr<some_pod> &         get(void) noexcept         {           if (! m_result) {             m_result = std::shared_ptr<some_pod>(do_it_without_error(...));           }           return m_result;         }              // might throw         do_it &         check(void)         {           if (! m_result) {             Error * error = NULL;             m_result = std::shared_ptr<some_pod>(do_it_with_error(..., &error));             if (error) {               throw ...;             }           }           return *this;         }            private:         std::shared_ptr<some_pod> m_result;     };      Usage:               do_it di_error;     try {       auto result = di_error.check().get();     } catch (...) {}     do_it di_no_error;     di_no_error.get();      So, both implementations seem to be equally good (or bad) to me.   How could I decide which one to use.   What are the Pros and Cons?


Find common functionalities or functions between 2 programs

I've been facing a problem recently, in which I want to optimize two programs. For that, I wanted to create some kind of "Common Interface" which I could reuse between my two programs. However, the code of these are approximately 1000 lines, and I don't want to spend a big amount of time checking if this or that function is the same as this one and whatsoever. So I used BOUML to check the similarities between class diagrams. But I wonder if there is a global way to do such a study ?


how to express alternative flows in activity diagram

I want to express the below events in an activity diagram:   * An alternative flow, such as "at step x of basic flow, user clicks cancel instead of ok".   * An alternative entry to the use case, such as "instead of click the bold button, use can press Ctrl-B".   * An error, such as "when user clicks save, the system is unable to save the file to disk." How can I do these? Thank you.


Under which circumstances (if any) does it make sense to work for a startup, for free?

I've been bumping around the startup world for a while, and most startups I've seen seem to have (amongst other things) two things in common:   1. A lack of money   2. An inability to, reliably, hire good quality developers This means that, for startups, the ideal hire is someone who is free - where they can wait until they've both raised money and found out that the hire is worth his price tag. When (if ever) is this a win win situation? For you, as a programmer or software developer, when would this make sense?


How would you teach C# delegate to a newbie?

I was reviewing Andrew Troelsen book on C# 4.0. The part that explains delegates starts as smooth as:               public class SimpleMath     {         //declare delegate         public delegate int BinaryOp(int x, int y);              public static int Add(int x, int y)         {         return x + y;         }     }          class Program     {         static void Main(string[] args)         {         //create delegate which points to Add method         BinaryOp b = new BinaryOp(SimpleMath.Add);              //Invoke Add method using delegate         Console.WriteLine("10 + 10 is {0}", b(10,10));         Console.ReadLine();         }     }      than gets as complicated as               public class Car     {         public int CurrentSpeed {get;set;}         public int MaxSpeed {get;set;}         private bool carIsDead {get;set;}         public Car() {MaxSpeed=10;}         public Car(int maxSpeed, int currentSpeed)         {             MaxSpeed = maxSpeed;             CurrentSpeed = currentSpeed;         }         //declare delegate         public delegate void CarEngineHandler(string msgForCaller);         //define member of this delegate         private CarEngineHandler listOfHandlers;         //add registration function for the caller         public void RegisterWithCarEngine(CarEngineHandler methodToCall)         {             listOfHandlers = methodToCall;         }              public void Accelerate(int delta)         {                 if (carIsDead)                 {                         if (listOfHandlers!=null)                                 listOfHandlers("Sorry, the car is dead");                 }                 else {                         CurrentSpeed+=delta;                         if (10== (MaxSpeed - CurrentSpeed) && listOfHandlers!=null)                         {                                 listOfHandlers("Gonna blow!");                         }                         if (CurrentSpeed >= MaxSpeed)                                 carIsDead = true;                         else                                 Console.WriteLine("Current Speed = {0}", CurrentSpeed);                 }         }     }      If we try to pick that content and teach somebody else, we are going to find a hard time, since it becomes tricky. How would you teach C# delegates in a way he/she is able to understand clearly when to use them?


Debugging, performance tracing, profiling, tools, etc. - suite?

My client is looking to standardize on its "helper" tools suite of applications to aid developers of a very large .NET project in debugging, profiling, finding memory leaks and performance bottlenecks, etc. kinds of issues All developers use VS2010, target .NET 4.0, and support a large distributed system: Winform UI client (CAB framework), SQL2008 Backened, CSLA app-tier with Dataportal & remoting, and there is a large job-processing layer with Compute cluster pack (CCP) as well as a few dozen other peripheral technologies. To give you an idea of the size, the system is probably north of 5M lines of code, has about 100 developers around the world and has been in development & production support for the last 5 years with this same team size. Over the years, client did not have a single strategy that revolved around profiling tools of kinds. Client bought the tools when programmers said: "oh, this looks nice to trouble-shoot this particular problem I'm having".. So, now the client wants to standardize on a suite of tools. What has worked so far: Ants for memory profiling. dotTrace for performance profiling. There is currently a serious consideration being given to CA Wiley for production monitoring. VS2010 profiling has been deemed not good enough and not working well enough within the current system. Can anyone recommend a single suite of tools that would be a good substitute for ALL the tools mentioned above? Integration with VS2010 is a must. All sorts of bells & whistles and ease-of-use and ability to drill-down into deepest levels to find the weirdest problems is required. Thank you for your suggestions


When there is no API

When it is necessary to integrate with a web application, and an API is unavailable, is it a viable solution to simulate a web browser interacting with the web application as a real user would interact with it? UPDATE Some context. Web App belongs to a vendor/partner. Their timeline for building a proper API will not meet our needs. Scraping for data is the least used part. Full CRUD for interacting with the app is required. As a developer, I can see that it will work, but I want to be able to address concerns that others may raise about this approach. Would you base a mission critical business application on this approach? Why or why not?


What's the difference between college-level and corporate programming?

I have just completed my Bachelors degree in IT field. I have deep interest in coding and really want to be a professional in it. Now, apart from college courses, I have been learning programming(C#) on my own (college level programming is too basic). Now I feel I need a little more time to be close to professional programmer. But some of my seniors say that corporate world programming is too different from bookish programming, hence there is no point in wasting time. (They are not programmers themselves, this may be probably what they heard). Would I benefit by reaching an advance level of C#? or as mediocre level is sufficient to break interviews, higher levels do not matter to firms because they rely on their training purely to teach how things work in corporate world and learning more won't help me much? Please if there are some professional programmers who can help, I promise this is something which about every student interested in programming want to ask at my stage. "How do you actually change from learner to professional in field of programming?" - keep learning until you are perfect or joining a firm is must once basics are covered?


Unique Value Object vs Entity

Trying to convert some entities into value objects I am stuck in a case where what seems a value object must be unique within an aggregate. Suppose we have a **Movie** entity which makes the root of an aggregate. This **Movie** entity is related with some set of **AdvertisementEvent** objects with the role of displaying an advertisement at certain timestamp. The **AdvertisementEvent** contains a link to some **Banner** that must be displayed, the coordinates and some effect filters. Since **AdvertisementEvent** is just a _collection of configuration parameters_ I am not sure if I should care about its identity and treat it like just a large value object. However I do care that within a **Movie** there must be only one **AdvertisementEvent** at a certain timestamp, probably even _around_ the timestamps. I find hard to split my doubts in multiple independent questions, so there they go:   1. Does a _collection of configuration parameters_ sounds like a value object?   2. Am I mixing the concept of uniqueness of **AdvertisementEvent** within **Movie** and transactional integrity rule?   3. Does _any_ of the choices in point (2) implies that **AdvertisementEvent** must be a member of the aggregate made by **Movie**?   4. Is my **AdvertisementEvent** object an Entity, a Value Object or an Event Object? (I used the _Event_ suffix in the name to highlight my confusion)   5. Are large value objects like this a design smell? I guess that I am not dealing with an Event in the sense of DDD because it is not something that just _happens_. The real DDD event should be something more like _AdvertisementEventReached_


Internship along with Google Summer of Code?

I am wondering about how much time Google Summer of Code typically takes. I do have an internship lined up for this summer, but GSoC seems like quite an awesome experience. I also really want to get into Open Source development. It states in the FAQ that it's not a good idea to attempt both, but it doesn't give any specifics. I'm wondering if it's feasible to do both. Or would I be better off by trying to work on open source in my spare time? Thanks for all your help!


What are benefit/drawbacks of classifying defects during a peer code review

About 3 months ago, our engineering group rolled out Review Board to be used for all peer code reviews. Today, I had a discussion with one of the people involved in that process and found out that we are already looking for a replacement (possibly something commercial) because of several missing features. One of the features that is apparently asked by many people is the ability to classify/categorize each code review comment (i.e. is it a style issue, coding convention, resource leak, logic error, crash... whatever). For those teams that regularly practice code review, is this categorization a common practice? Do you do it? have you done it in the past? Is it good/bad? On one hand, it gives the team some more metrics and possibly will indicate more specific areas where developers may potentially need to be trained in (at least that seems to be the argument). Are there other benefits? And on the other hand, and this is my concern, is that it will slow down code review process that much more. As a team lead, I've done a fairly large share of reviews, and I've always liked the ability, to highlight a chunk of code, hammer off a comment and move on as fast as possible. Although I haven't tried it personally, I have a feeling that expanding that combo box every time and scrolling/searching for the right category would feel like something is tripping you. Also if we start keeping metrics on this stuff, my other concern is that valuable code review meeting time will be spent on arguing whether something is a logic error or if it should be classified as a crash.


How can I help myself focus on a project when there is a more fun one I can work on?

I suffer from adult ADHD. Sometimes I get bored with projects or work items assigned to me at work because they aren't particularly interesting. I end up inventing more interesting work and working on that instead, not getting my assignments done on time. I do end up making useful software, but not what I committed to making. I know that I need to "suck it up" and "just do it", however the ADHD makes it difficult for me to choose what to think about. As a result, I get distracted often and don't deliver on time. Are there any techniques I should try to help stay on task, especially when there is more fun work I could be doing?


What is the (craziest, stupidest, silliest) thing a client/boss asked you to do?

See title, but I am asking from a technical perspective, not > Take my 40 year old virgin niece on a date or you're fired.