Fail-fast design

I recently tend to design my methods in the following way:               if ( 'A' === $a ) {         if ( 'B' === $b ) {             return 'some thing';         } else if ( 'C' === $c ) {             return 'some other things';         }     }          /* If you made it up to here, then something has gone wrong */     return false;      So basically the idea is to check if the first condition is correct, if it is then continue until you reach the first `return` statement to return the expected result, if not, move on to the next condition and so on. The key is that all the method's functionality has already shrunken down and wrapped up in a conditional statement piece by piece, so you should meet at least one condition to take a useful action or if you reach the very last line, then it will `return false`, that means none of the expected conditions were met, that in my design it means the input wasn't in a proper or expected format, data-type, range, etc. so the method were not able to continue processing that. I can achieve the same goal in a couple of different ways, but this one seems to be cleaner as I generally need to write code only for _positive_ conditions (I actually don't know how should I call it) -- unless I need to take a specific action if a certain condition haven't met. And in the end I will get `false` if the method wasn't able to accomplish its job -- with real conditions in place most of the time it's almost like a jump to the end of method when you can't pass through an `if` statement. It's actually designed in a way that you will either pass this `if` and will heading to the either next `if` or a `return` statement or you are very unlikely to match any other `if` statements and will jump directly to the last `return false` statement. Now, my questions are:   1. Is it a (true) fail-fast design, which in this case is only looking for the proper condition to continue and is willing to fail as soon as one fails. Is that correct or am I mixing up things here? If not, is there any specific term for that?   2. Also as I recently generalized this approach for all the new methods I create, I wish to know if there is any drawback or design flaw here that might bite me back later.


Keep indentation level low

I hear a lot that you should not write functions larger than one screen size, that you should extract things into functions if you call things very often and all these coding guidelines. One of them is also keep your indentation level low. Some people told me even I should max indent 4 times. But in every day programming it keeps happening that I need O(n^2) or O(n^3) loops with some flow control, which creates out of nowhere 7 or 8 layers of indentation... Are there any good ways to avoid that? One problem is, if you try to avoid complex if/else statement nesting I tend to do this in one row which can look very terrible and be unreadable and not very easy to maintain.


What is the Best Style for Functions with Multiple Returns and If/Else Statements?

> **Possible Duplicate:**   >  Elegant ways to handle if(if else) else In a function where there are multiple returns, what is the best style to use? This style, where there is no 'else' because it is frivolous and you think it is more concise?               f() {         if (condition) {             return value;         }              return other_value;     }      Or this, if you think that 'else' provides nice syntax sugar to make it more readable?               f() {         if (condition) {             return value;         } else {             return other_value;         }     }      Feel free to share whatever other reasons you may have for preferring one over another. EDIT: The above samples are hypothetical, if they were this simple, as Yannis Rizos noted below, the ternary operator ( condition ? value : other ) would be acceptable. However I'm also interested in cases like this:               f() {         if (condition1) {             return value;         } else if (condition2) {             return value2;         }         ...         else {             return other_value;         }     }


Licensing approach for .NET library that might be used desktop / web-service / cloud environment

I am looking for advice how to _architect_ licensing for a .NET library. I am not asking for tool/service recommendations or something like that. My library can be used in a regular desktop application, in an ASP.NET solution. And now Azure services come into play. Currently, for desktop applications the library checks if the application and company names from the version history are the same as the names the key was generated for. In other cases the library compares hardware IDs. Now there are problems:   * an Azure-enabled web-application can be run on different hardware each time (AFAIK)   * sometimes the hardware ID for the same hardware changes unexpectedly   * checking the hardware ID or version info might not be allowed in some circumstances (shared hosting for example) So, I am thinking about what approach I can take to architect a licensing scheme that:   * is friendly to customers (I do not try to fight piracy, but I do want to warn the customer if he uses the library on more servers than he paid for)   * can be used when there is no internet connection   * can be used on shared hosting What would you recommend?


Not assigning Bugs to a specific user

My question: Is there a benefit to NOT assigning a Bug to a particular developer? Leaving it to the team as-a-whole? Our department has decided to be more Agile by not assigning Bugs/Defects to individuals. Using Team Foundation Server 2012, we'll place all Bugs in a development team's "Area" but leave the "Assigned To" field blank. The idea is that the team will create a Task work item which will be assigned to an individual and the Task will link to the Bug. The Team as a whole will therefore take responsibility for the Bug, not an individual, aligning to Scrum - apparently. I see the down side. The reporting tools built into TFS become less useful when you cannot sort by assigned vs unassigned, let alone sorting by which user Bugs are assigned. Is there a benefit I'm not seeing? Besides encouraging teamwork by putting the responsibility on the team-as-a-whole instead of an individual?


Confusion about inheritance

I know I might get downvoted for this, but I'm really curious. I was taught that inheritance is a very powerful polymorphism tool, but I can't seem to use it well in real cases. So far, I can only use inheritance when the base class is an abstract class. Examples :   1. If we're talking about `Product` and `Inventory`, I quickly assumed that a `Product` **is an** `Inventory` because a `Product` must be inventorized as well. But a problem occured when user wanted to sell their `Inventory` item. It just doesn't seem to be right to change an `Inventory` object to it's subtype (`Product`), it's almost like trying to convert a parent to it's child.   2. Another case is `Customer` and `Member`. It is logical (at least for me) to think that a `Member` **is a** `Customer` with some more privileges. Same problem occurred when user wanted to upgrade an existing `Customer` to become a `Member`.   3. A very trivial case is the `Employee` case. Where `Manager`, `Clerk`, etc can be derived from `Employee`. Still, the same upgrading issue. I tried to use composition instead for some cases, but I really wanted to know if I'm missing something for inheritance solution here. My composition solution for those cases :   1. Create a reference of `Inventory` inside a `Product`. Here I'm making an assumption about that `Product` and `Inventory` is talking in a different context. While `Product` is in the context of sales (price, volume, discount, etc), `Inventory` is in the context of physical management (stock, movement, etc).   2. Make a reference of `Membership` instead inside `Customer` class instead of previous inheritance solution. Therefor upgrading a `Customer` is only about instantiating the `Customer`'s `Membership` property.   3. This example is keep being taught in basic programming classes, but I think it's more proper to have those `Manager`, `Clerk`, etc derived from an abstract `Role` class and make it a property in `Employee`. I found it difficult to find an example of a concrete class deriving from another concrete class. Is there any inheritance solution in which I can solve those cases? Being new in this OOP thing, I really really need a guidance. Thanks!


Writing generic code when your target is a C compiler

I need to write some algorithms for a PIC micro controller. AFAIK, the official tools support either assembler or a subset of C. My goal is to write the algorithms in a generic and reusable way without losing any runtime or memory performance. And if possible, I would like to do this without increasing the development time much and compromising the readability and maintainability much either. What I mean by generic and reusable is that I don't want to commit to types, array sizes, number of bits in a bit field etc. All these specifications, IMHO, point to C++ templates, but there's no compiler for it for my target. C macro metaprogramming is another option, but, again my opinion, that greatly reduces readability and increases development time. I believe what I'm looking for is a decent C++ to C translator, but I'd like to hear anything else that satisfies the above requirements. Maybe a translator from another high-level language to C that produces very efficient code, maybe something else. Please note that I have nothing against C, I just wish templates were available in it.


OOP PHP make separate classes or one

I'm studying OOP PHP and working on a small personal project but I have hard time grasping some concepts. Let's say I have a list of items, each item belongs to subcategory, and each subcategory belongs to category. So should I make separate classes for category (with methods to list all categories, add new category, delete category), class for subcategories and class for items? Or should I make creating, listing and deleting categories as methods for item class? Both category and subcategory are very simple and basically consist of ID, Name and parentID (for subcategory).


Never written much unit tests, how can I practice more of it?

I have an interview coming up soon next week and there's a few things on their list of responsibilties for this software development job (the job position title is vague, it says java developer) that I am worried about:   * Unit test features   * Debug new features   * Provide recommendation on test case design (what is this?) I am worried because in my past software projects, I have not bothered writing unit tests. I know how to use JUnit to write tests in Eclipse and the process but it's just that I have not much experience writing tests. For example, I rely on data from the web, which varies a lot from each other, and process this data. How can I write test cases for every single type of data? Also, if the data is from a local database, how would I write a test case that checks that data from tables are being read properly? I've used the debug feature in Eclipse whenever I could, but sometimes, when I am accessing a library which doesn't come ith source code for (e.g. commercial 3rd party Jars), the step into feature would stop. So for most cases, I just System.out.println to discover where the bug is happening. Is there a better method? How can I practice in the short period of time to be somewhat competent in writing unit test?


Is it common to have stored procedures disabled on MySQL managed hosting plans?

I'm building an app that I think would benefit from the use of MySQL stored procedures. I know stored procedures have a bad reputation, but I think they suit my application well. Using stored procedures would reduce the number of queries per request significantly (mostly inserts), as well as allow me to leverage the procedures across multiple implementations of this software. I think the software will benefit. My concern however, is that pushing functionality into stored procedures may make it harder for users to deploy the software on shared hosting services. Is it common practice to expect users to have stored procedure capability (i.e. allow scripts to create and run stored procedures)? **Edit:** This application is intended for my end user to deploy on her own.


JSP, EL, JSTL: learning from a web designer perpective

I have two books geared toward learning JSP. From what I've read, one motivating feature/benefit is that it is easier for web designers (they apparently don't, as a rule, know Java) to work with dynamic pages via EL/JSTL. From what I've seen so far, learning EL/JSTL requires a basic understanding of Java. I have yet to see an example that doesn't have a Java class to reference. Since that is what I've seen, I wonder if someone can tell me that this is true or not. To make the question clear: Do web designers have to get a grasp, on a very basic level, of how a Java class works (e.g. fields, setters, getters, args, constructors...)? This question is really meant to help me decide whether or not to ask another question; it is a qualifier.


Empirical Evidence of Popularity of Git and Mercurial

It's 2012! Mercurial and Git are both still strong. I understand the trade-offs of both. I also understand everyone has some sort of preference for one or the other. That's fine. I'm looking for some information on level of usage of both. For example, on stackoverflow.com, searching for Git gets you 12000 hits, Mercurial gets you 3000. Google Trends says it's 1.9:1.0 for Git. What other empirical information is available to estimate the relative usage of both tools?


How the Erlang get soft-realtime with GC?

Generally GC is not a good choice to get a soft real-time attribute. But Erlang is GC based language can be soft real-time. Does it mean Erlang have almost no GC latency? How does it work?


Style for creating IEnumerable unions

There isn't any cool LINQ sugar for creating unions. The `Enumerable.Union()` method is usually called like this:               var bigList = list1.Union(list2);      The alternative is to call `Enumerable.Union()` which can be more readable:               var bigList = Enumerable.Union(list1, list2);      However neither of these methods are very stylish (more importantly, readable) when scaling out The following is probably the best method:               var reallyBigList = list1.Union(list2).Union(list3);      Which can result in some messy method chaining. Alternatives need incidental variables:               var list1and2 = list1.Union(list2);     var reallyBigList = list1and2.Union(list3);      or               var list1and2 = Enumerable.Union(list1, list2);     var reallyBigList = Enumerable.Union(list1and2, list2);      Is there a clean way of setting up these more complex unions? Would an extension like `Enumerable.Union(params IEnumerable<T> collections)` (used like `var reallyBigList = Enumerable.Union(list1, list2, list3)`) be better?


Separating the database, API, and the interface

Most of my projects start small. Many times I start with a web page (1 file) that has the code to... select stuff from the database => display it to the user and offer editing => receive the edits (sometimes complex enough that it requires parsing) => update the database all of this in 1 file, of course. As the project grows it always becomes annoying to have so much code in one pile, 50 `if` statements. **Question** : What is a good, proven & intuitive data separation? I guess i'm looking for a diagram that explains which code goes in what file. I would like to keep this language independent, but in case it matters I'm using PHP and MySQL.


What are some math concepts to review for an interview?

What are some good math concepts to review for a software engineering interview? The position is not expected to be particularly math heavy, i.e graphics programming, but I imagine refreshing on some math concepts would help going into an interview for a high caliber company. The more specific the better. Thanks in advance!


Can I redistribute simplified BSD code?

Here is a plugin I wish to redistribute: http://plugins.jquery.com/project/TextAreaResizer I've written a Jquery plugin that needs the text resizer as a prerequisite. The license type says:               License type: Simplified BSD License/FreeBSD License      I did a bit of googling and it said you have to retain all license info, but this plugin doesn't come with any! Can I package a modified version of this (I changed one number in the source) and distribute it with my plugin? Thanks for any insight


How should I plan out my code base?

I'm currently working on a project that's about to reach over 5,000 lines of code, but I never really completely thought out the design. What methods should I use to structure and organize my code? Paper and pen? UML diagrams? Something else?


Reference website for CSS 3 properties (like box-reflect)

Today, I started reading the book _CSS Mastery 2nd edition_. It is really a good book for anyone who is interested in learning some techniques. On page 151, I discovered the `box-reflect` property from CSS3. I tried to find out more information about which browser suports it and the syntax of the property, but I only found a site that didn't explain much. Can anyone please provide me with a link to a website that is up to date regarding the CSS3 elements? The site should also contain information about browser-support for the different elements. I'm primarily interested in the `box-reflect` property and to update my knowledge of CSS3 properties.


Functional programming language for web development

I want to choose to learn a functional programming language, it should fulfill the criteria:   1. Open source, static typed & fully object-oriented too.   2. Must has web framework because it's for web development.   3. I want to avoid oracle jvm altogether, therefore not scala, clojure.   4. Should be rather popular, i.e. has real-world applications in industry. Please recommend which good language I can use? thanks.


Is it possible to combine programming languages?

I've been programming for a while, I've written some rudimentary programs, and I want to keep learning. I've reached that point where you just don't know what to learn next, and I'd like to ask a question for my own curiosity. The question, in a nutshell, is if you can combine multiple programming languages into 1 result? For example, can this code be possible?               <html>     cout << "Hello world!";     </html>      or               import java.util.Scanner;     cout << "Insert a number from 1 to 10";     Scanner n = new Scanner(System.in);     System.out.println("The value you entered was" +n.newLine());      This feels like a silly question but I can't possible know if it's possible or not, so that's why I'm asking it. In this question I notice he is using Python code in html code, if my above example is not possible, what did he do?


What is "short-circuiting" in C?

I have heard of the term "short-circuiting" being used in C. What does this mean and in what scenario would it be used?


How to remove data redundancy in a table?

F1  F2  F3  C1  C2  C3     ------------------------------------------------     A   B   C   1            D   E   F   2            A   B   C       3        D   E   F       4        A   B   C           5     D   E   F           6      i have a table like this. i need my table to be free from Data redundancy like this               F1  F2  F3  C1  C2  C3     -----------------------     A   B   C   1   3   5     D   E   F   2   4   6      i am unable to figure out the optimized logic. can someone help me out.?


data stored in dbase (application result dd.mm.yyyy)

I have a .dbf file (dbase) with data of type "date" to read directly via php. I have the application result (format: dd.mm.yyyy) and the stored hex code. I can't interpret the hex data to get the same results or similar results to the application. Which alogrithm is used to get this results? Examples:               app.result=database.hex;     01.01.1000=17 3C 68;     02.01.1000=17 3C 69;     01.02.1000=17 3D 08;     01.01.2000=2E 7C 50;     01.01.1903=2C 58 6F;      Can anybody help me?


License that grants the initial author all rights of derived/modified work?

_Please note that I do not want to argue about the moral aspect of this question. I know that there are probably many different concerns._ I have been researching for a special license that could be used in a following scenario, but with no success: Let's assume I have a software and want to release its source code, so that others can use it too. Since I don't want others to make changes and keep them closed I could the GPL. But here's the thing: Even if I profit from changes that other people do. I can relicense only my code because I'm not holding the copyrigth any code that not made by me. But I would like to. I want to know if there is a ready-to-use license that will grant me (the initial author) the rigth to relicense any changes or code that was added by others. Or in even shorter terms: A GPL that does not count for me. If you are interessted why I need this: I don't know if I will ever use my software for a commercial product. Probably not, but if I just use the GPL, I migth end up in a situation where I can't remove any other code since there are to many committers.


Are certifications worth it?

I am finishing my college degree in programming soon and I'm exploring the next steps to take to further my career. One option I've been considering is getting a certification or a series of certifications in the area of development I want to work in. Are these certifications worth the time and money? Do employers place a lot of value in them?


Are certification courses worth it?

I'm planning on getting certification in Database Development for SQL Server (MSTC - 70-433). I'm a junior level report writer at a new job and the company is offering to pay the majority, if not all, of training course fees. The course is five days. I noticed that MS has a self-paced training kit (book) that I could use. I'm wondering if this would be a better option because it will allow me to go as quick as possible. I've also heard about video training sessions (Lynda.com) but they seem to go at slow pace. My questions are:   1. What should I expect at a certification course? Is it hands-on training? Small classes with personal feedback or not?   2. Would I be better off learning at my own pace using the training kit? (I'd rather this not turn into a certifications are pointless discussion..)


Would a programming certificate teach me anything?

I'm 16-years old, and due to being placed in accelerated programs during my whole academic career, I just finished high school over the holiday season. For the past year or so I've been teaching myself web development (front-end, more specifically), and want to go into a career in the field. I have a front- end internship all lined up for the summer (some places don't offer them year- round, I guess), but I want to continue learning between these two periods. More specifically, I want to learn some server-side development so I can understand the interconnection between the front-end and back-end better. My question is, would taking on a programming certification program at my local community college teach me anything, or is the information too outdated to be relevant whatsoever? PHP is the server-side language covered in the certificate (it also covers JS and CSS). I feel like in self-teaching myself I may have skipped over some fundamentals of JavaScript, and I'd really like to have a solid understanding of the language from both a syntax and philosophical perspective (i.e. understanding advantages, distadvantages, etc). Edit: I've been building a portfolio, and am considering skipping going for a degree altogether. I just want to do this for self-improvement.


Programming certificates

> **Possible Duplicate:**   >  Are certifications worth it? I'd be glad to hear your opinions on which programming certificates are the most widely recongnized in the industry and how useful are they actually. I've googled a lot this question but I've never asked here and I'd like to gather as many opinions as possible before applying for any. I'm interested mainly in developing business application. I have knowledge in Java, SQL, PHP, some C#. Thank you in advance!


What are other certifications beside cisco and Microsoft , which put some weight in resume

> **Possible Duplicate:**   >  Are certifications worth it? I want to know which are those certifications which can help in increasing job chnaces more. Although experience is more important than certifications but if there is tie on experience then certifications can matter


Do Microsoft Certifications matter?

> **Possible Duplicate:**   >  Are certifications worth it? I'm curious what experience others have had, both from the perspective of an employer and an employee on Microsoft Certifications. I'm kind of sitting on the fence myself on this issue. I tend to have a cynical view of folks with massive amounts of letters following their name, and sometimes think that these certificates are so specialized that they prove a candidate knows "almost everything about almost nothing". Deeply specialized knowledge isn't always needed in the real world, especially if it means total ignorance of related subjects. Nobody needs to here "That's not my specialty - we need to hire another guy on the team" very often. On the other hand, everybody knows how easy it is to BS through an interview, and nobody wants the experience of hiring an employee and finding out two weeks later that they don't really have a good grasp on what you need them to do.


Java Certifications process: Good or Bad idea

> **Possible Duplicate:**   >  Are certifications worth it? I am looking to get into more Java Development after being thrown on a project that required Java development for a month and successfully knocking it out. I still feel as though I could use a little bit more refinement with Java and I thought certifications might be the way to go. I would like to be certified in JPA, Java Web services, and Java Front end development (probably JSF or Spring MVC or something like that). I would like to be an architect at some point as well. I have a couple of questions about what is the best way to go about getting certified. My first question is regarding the Java Certification process itself: 1) Is there a baseline certification that I would need to get before I go out and get certified in JPA , Web Services, Front End development, and Architect certification? 2) Do you think that certification is even a good idea? Do you know of employers that would give someone a leg up if say, he has only worked on one or two Java EE projects but has a certification or two? 3) Is this a good step in terms of career development? Is focusing just on development limiting my self to the basement of some development firms? How can I make myself more valuable as a business asset? Any other thoughts you guys have on certifications and their business worth?


How valuable are master level language certifications like C++ grandmaster?

My understanding of standard programming/computer certifications is that they show you have some core competency about a specific language or technology. There seems to be a little room for variation here, but for the most part I don't feel like I don't see very many "expert" level certifications. How valuable are master level language certifications such as the recent C++ Grandmaster? Do you think they would have a big impact on getting a good job? (I understand that C++ grandmaster is a really extreme, maybe unrealistic, example.) If so, what valuable "master" or "expert" level certifications exist for specific programming languages? Are certifications more valuable for showing core competency or specific specialty knowledge? I am not very knowledgable about this subject so let me know if I made bad assumptions.


Is an SEI certificate worth anything?

I'm talking about SEI Software Architecture Professional Certificate. I've been web developing for 3 years and I'd like to move into Software Architecture. My work will probably pay the fees for this program if I ask nicely enough. But does the SEI have the reputation to make this "certificate" worth having? More importantly, is the training any good? Has anyone done this?


What are the certifications to be need for the Java Architect?

I'm the senior software developer working in a private company. I want to became the Software Architect in the Java side. Could you please tell me the certifications releated to my scenario?


Should I focus on getting certified?

I am a graduate in computing and I am on the job hunt at the moment. So I now have an MSc and a Bsc qualification in applied computing. People have been saying get a professional qualification right away while others have said "not now". I am really unsure what to think of them at the moment, someone said to me they are bad as it makes you look like you are not open to developing in other environments. For example, if I was to get a MS certification employers might think I am useless outside of a Microsoft environment. Are certifications worth the money? Should I really get them now, so soon after I graduate or wait till I have some experience in the working world?


Is the CakePHP certification worth it?

I have over 5 years of experience in web technologies—primarily the LAMP stack—and over 2 years in the CakePHP framework. I am considering the CakePHP certification, is it worth it?


If you're a .NET developer, does getting the Microsoft Certified Master SQL Server 2008 cert make sense?

So I've been working at a job for the past year as a .NET developer/DBA. The job is my first DBA job. Traditionally, I'm a .NET developer and have about 5 years experience in it. Does it make sense for me to continue my certs to get the MCM (assuming I'm eligible)? I'm thinking it doesn't because I've been working with SQL Server for 5 years but only as a DBA for a year. Would it help a developer to have that? Or is it useful only in switching? I became interested in SQL Server because I felt that during the recession, people were looking more and more for developers who could add value across the stack. Now, I'm not so sure...


Is cloudera hadoop certification worth the investment

I am considering investing time to learn Hadoop and it's related technologies. The problem is that my current day job will not be using Hadoop any time soon and even if I learn from books, blogs personal projects I will not have much to backup when I actually need to show that I have Hadoop experience. So while continuing my job I would like to invest into my own training and I am thinking about Hadoop certification from cloudera. What do you think about it? Please answer from your perspective (if you took the certification and training course or are in the market for hiring new hadoop developers and what do you look for) I am sure that there is no shortcut to becoming an expert in Hadoop, but certification and training seems like a jump start.


Thoughts on Agile / Scrum Certifications - Worth it?

For those involved with the Agile community (either as developers or management) you've all probably heard about the Certified ScrumMaster designation as well as Certified Product Owner, and Certified Scrum Developer. You may have also heard about PMI (Project Management Institute) new "Agile Certification." Isn't Agile (as a philosophy) all about opening up to newer and (possibly) more effective methods of developing? Does there need to be a certification to back up the "skills?" What is the best reason to get an Agile certification?


Fundamental Difference between fn() and new fn() in javascript

In what all aspects, calling a function with and without new keyword differ in javascript? I mean what all things are differing between? `testFn()` vs `new testFn()`


Creating a very basic compiler using Java

I want to try and create my own very basic language, with it's very basic compiler. All using Java. For now, it will only need to enable to 'programmer' to print things to the screen. I had an idea for how to do this, and what I wanted to know is: Will this be considered an actual 'compiler', an actual 'language', and an actual 'virtual machine'? (All very, very basic of course). My idea was to create a program which will serve as the 'IDE' (editor and compiler), and another one which will serve as the 'virtual machine'. This means that the IDE will not compile the written code to some existing machine code, like the Java Bytecode, but will actually compile to some kind of compiled code made up by me. This compiled code will only be understandable by my 'virtual machine' program, and will only be able to run inside this program. The 'virtual machine' program, will use high-level Java operations in order to understand and execute the compiled code. The 'virtual machine' program will be a Java program, running on the JVM. My question is: **Conceptually** , is this considered a virtual machine, and 'machine code'? If not, is this still considered a 'programming language', even though it's compiled bytecode can only run inside a specific program?


How to practice programming?

I've been a PHP developer for 5 years now. Before I started working in that field, I've been practicing at home. I've created my own CMS, so I could actually show some of my code to the potential employer. In the final version, it had about 2,000 lines of code, and no one except me was using it. But that was not the case, because I've learned a lot during this project. Lately I've decided to move forward and abandon web developing for sake of C/C++ programming. I've read a few books recommended on stackoverflow, skimmed over a glibc manual, and solved some problems on Project Eurler as adviced. Now it's time to start some project, but I can't come up with anything. What is the next step I should take?


Simulating Agile Software Development

Looking for a guide or example of where a group facilitator walks a group through an agile software development cycle playing the role of both the event facilitator and the key stakeholder or project owner.


what limitation will we face if each user-perceived character is assigned to one codepoint?

Hi all I was wondering what limitations will we have if Unicode had decided to assign one and only one codepoint to every user-perceived character? Currently, Unicode has code-points that correspond to combining characters. Such characters combine with a previous code-point (or sequence thereof) to present to the user what appears to be a single character. From what I can see, the current standard is full of complexities. Even if I try to avoid any kind of complexities by using an encoding like UTF-32, this problem still **persists**. It's not an encoding issue at all. For example, in Unicode when a grapheme cluster is represented internally by a character sequence consisting of base character + accent, then when the user clicks the `>` button to skip to the next user-perceived character, we had to skip from the start of the base character to the end of the last character of the cluster. Why does it need to be so hard? Why can't we assign a single code point to every user perceived character such going to the user-perceived character is simply a matter of reading the next code point? The unicode website seems to acknowledge this complexity, (although I could not understand what exactly is so rare about having to figure out the number of user-perceived character counts in a string): > In those **relatively rare circumstances where programmers need to supply > end users with user-perceived character counts** , the counts should > correspond to the number of segments delimited by grapheme clusters. > Grapheme clusters may also be used in searching and matching Diacritics are also the reason why things don't work as expected. For example, if I throw 2 ピ characters (japanese katakana PI using the unicode representation `U+30d2 U+309a`) into a String builder and reverse it, I would naturally expect the output to be 2 ピ characters (i.e. ピピ), but it gives an invalid output of ゚ピヒ ! **If Unicode had assigned individual code points for each user-perceived character and scrapped the idea of grapheme clusters, this wouldn't have happened at all.** What I would like to know is, what exactly is wrong with representing every user-perceived character as one unicode codepoint? Is it likely that doing so would would exceed U+10FFFF possible code points (if it does exceed U+10FFFF code points I see no reason why they couldn't have set the limit to 2^32 in the first place), Even when there is so much spare space to include the whole family of Elf Languages ? Unicode states: > If you wanted, for example, to give each “instance of a character on paper > throughout history” its own code, you might need trillions or quadrillions > of such codes; But seriously that doesn't make sense at all. Where is the source for making such a claim? A trillion codes is quite an over-statement.


New to iPhone Development - iOS5 Storyboard

I'm new here and pretty new to iOS development. My question is basically, should I learn the old school development methods or just learn how to do things using the latest tools (i.e. Storyboard)? I've had a go with the Storyboard feature of XCode 4.2 and it's very powerful. My only concern is that it requires iOS 5. I don't mind learning the old way of doing things but I've been having trouble finding tutorials/examples for XCode 4.2 that don't use the storyboard. An example would be the with my trouble finding a good tutorial on how to embed a Navigation Controller into a TabBarController. A lot of the material out there seems to be for older version of XCode. Using the storyboard I'm able to set this up with seconds but still haven't managed to get it working without it. So in short :) would you guys suggest I continue my project using the Storyboard or make the extra effort to do things a little more manually?


Certifications for Javascript developers?

I'm looking for a solid and but fast paced entry in field of javascript development. The following topics come to my mind:   * Javascript advanced concepts, OOP   * jQuery, jQuery-UI, jQuery-Mobile   * backbone.js   * node.js   * BDD and/or TDD The courses of http://www.codelesson.com seem promising. What certificates for Javascript developers exist/can be recommended? What other vendors can you recommend?


Custom heap allocators

Most programs can be quite casual about heap allocation, even to the extent that functional programming languages prefer to allocate new objects than modify old ones, and let the garbage collector worry about freeing things. In embedded programming, the silent sector, however, there are many applications where you can't use heap allocation at all, due to memory and hard real-time constraints; the number of objects of each type that will be handled is part of the specification, and everything is statically allocated. Games programming (at least with those games that are ambitious about pushing the hardware) sometimes falls in between: you can use dynamic allocation, but there are enough memory and soft real-time constraints that you can't treat the allocator as a black box, let alone use garbage collection, so you have to use custom allocators. This is one of the reasons C++ is still widely used in the games industry; it lets you do things like http://www.open- std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html What other domains are in that in-between territory? Where, apart from games, are custom allocators heavily used?


Is this kind of Design by Contract useless?

I've just started informatics university and I'm attending a programming course about C(++). The programming professor prefers to connect every topic with a type of programming design that is similar to Design by Contract. Basically, what he asks us to do is to write every exercise with comments that denote the pre-condition, post-condition, and invariants that should prove the correctness of each program we write. But this doesn't make any sense to me. Maybe writing down your thoughts prevent you from making some mistakes, but if this is all an abstract thing, then if your program intuition is wrong, you'll write your program wrong, and then you'll also write pre and post conditions wrong. In the end, you'll be convinced that a wrong program might actually be correct. I had some programming experience before this course and I found myself comfortably with just writing a program and unit testing it. It takes less time to accomplish and is less "abstract" than just thinking about what every single piece of your program should do in every case (which is kinda like mentally testing it). Finally, determining the pre and post conditions takes me about 80% of the total time of the exercises. It's harder to think about putting down this pre and post correct than to write the program itself. Am I right in thinking that working with pre-conditions, post-conditions, and invariants aren't worth anything? Should I convince myself that this method is right?


Architecting a multi-technology solution

I am trying to solve an issue with reusing components. I have some UI components (a mix of JS, CSS, and HTML) that are not specific to any application. These UI components need to be able to be used in multiple applications. One is a RoR application, the other is an ASP.NET MVC application. How can I maintain these components (e.g. with version control, distribution) and still make them accessible to the different platforms that need to consume them? For example, ApplicationA and ApplicationB use UIComponentA, which is not natively a part of their projects or repositories, because UIComponentA lives in its own repository. How can these projects get the dependencies they need while keeping the components reusable and hosted in their own location? Does anyone have experience with a similar situation, and if so, how did you tackle it? If you need further information, don't hesitate to ask, I will update this question.


When and how should I use exceptions (in Python)?

# The Setting I often have trouble determining when and how to use exceptions. Let's consider a simple example: suppose I am scraping a webpage, say "http://www.abevigoda.com/", to determine if Abe Vigoda is still alive. To do this, all we need to do is download the page and look for times that the phrase "Abe Vigoda" appears. We return the first appearance, since that includes Abe's status. Conceptually, it will look like this:               def get_abe_status(url):         # download the page         page = download_page(url)              # get all mentions of Abe Vigoda         hits = page.find_all_mentions("Abe Vigoda")              # parse the first hit for his status         status = parse_abe_status(hits[0])              # he's either alive or dead         return status == "alive"      Where `parse_abe_status(s)` takes a string of the form "Abe Vigoda is _something_ " and returns the " _something_ " part. Before you argue that there are much better and more robust ways of scraping this page for Abe's status, remember that this is just a simple and contrived example used to highlight a common situation I'm in. Now, where can this code encounter problems? Among other errors, some "expected" ones are:   * `download_page` might not be able to download the page, and throws an `IOError`.   * The URL might not point to the right page, or the page is downloaded incorrectly, and so there are no hits. `hits` is the empty list, then.   * The web page has been altered, possibly making our assumptions about the page wrong. Maybe we expect 4 mentions of Abe Vigoda, but now we find 5.   * For some reasons, `hits[0]` might not be a string of the form "Abe Vigoda is _something_ ", and so it cannot be correctly parsed. The first case isn't really a problem for me: an `IOError` is thrown and can be handled by the caller of my function. So let's consider the other cases and how I might handle them. But first, let's assume that we implement `parse_abe_status` in the stupidest way possible:               def parse_abe_status(s):         return s[13:]      Namely, it doesn't do any error checking. Now, on to the options: ## Option 1: Return `None` I can tell the caller that something went wrong by returning `None`:               def get_abe_status(url):         # download the page         page = download_page(url)              # get all mentions of Abe Vigoda         hits = page.find_all_mentions("Abe Vigoda")              if not hits:             return None              # parse the first hit for his status         status = parse_abe_status(hits[0])              # he's either alive or dead         return status == "alive"      If the caller receives `None` from my function, he should assume that there were no mentions of Abe Vigoda, and so _something_ went wrong. But this is pretty vague, right? And it doesn't help the case where `hits[0]` isn't what we thought it was. On the other hand, we can put in some exceptions: ## Option 2: Using Exceptions If `hits` is empty, an `IndexError` will be thrown when we attempt `hits[0]`. But the caller shouldn't be expected to handle an `IndexError` thrown by my function, since he has no idea where that `IndexError` came from; it could have been thrown by `find_all_mentions`, for all he knows. So we'll create a custom exception class to handle this:               class NotFoundError(Exception):         """Throw this when something can't be found on a page."""          def get_abe_status(url):         # download the page         page = download_page(url)              # get all mentions of Abe Vigoda         hits = page.find_all_mentions("Abe Vigoda")              try:             hits[0]         except IndexError:             raise NotFoundError("No mentions found.")              # parse the first hit for his status         status = parse_abe_status(hits[0])              # he's either alive or dead         return status == "alive"      Now what if the page has changed and there are an unexpected number of hits? This isn't catastrophic, as the code may still work, but a caller might want to be _extra_ careful, or he might want to log a warning. So I'll throw a warning:               class NotFoundError(Exception):         """Throw this when something can't be found on a page."""          def get_abe_status(url):         # download the page         page = download_page(url)              # get all mentions of Abe Vigoda         hits = page.find_all_mentions("Abe Vigoda")              try:             hits[0]         except IndexError:             raise NotFoundError("No mentions found.")              # say we expect four hits...         if len(hits) != 4:             raise Warning("An unexpected number of hits.")             logger.warning("An unexpected number of hits.")              # parse the first hit for his status         status = parse_abe_status(hits[0])              # he's either alive or dead         return status == "alive"      Lastly, we might find that `status` isn't either alive or dead. Maybe, for some odd reason, today it turned out to be `comatose`. Then I don't want to return `False`, as that implies that Abe is dead. What should I do here? Throw an exception, probably. But what kind? Should I create a custom exception class?               class NotFoundError(Exception):         """Throw this when something can't be found on a page."""          def get_abe_status(url):         # download the page         page = download_page(url)              # get all mentions of Abe Vigoda         hits = page.find_all_mentions("Abe Vigoda")              try:             hits[0]         except IndexError:             raise NotFoundError("No mentions found.")              # say we expect four hits...         if len(hits) != 4:             raise Warning("An unexpected number of hits.")             logger.warning("An unexpected number of hits.")              # parse the first hit for his status         status = parse_abe_status(hits[0])              if status not in ['alive', 'dead']:             raise SomeTypeOfError("Status is an unexpected value.")              # he's either alive or dead         return status == "alive"      ## Option 3: Somewhere in between I think that the second method, with exceptions, is preferable, but I'm not sure if I'm using exceptions correctly within it. I'm curious to see how more experienced programmers would handle this.


Statistical Software Quality Control References

I'm looking for references about hypothesis testing in software management. For example, we might wonder whether "crunch time" leads to an increase in defect rate - this is a surprisingly difficult thing to do. There are many questions on how to measure quality - this isn't what I'm asking. And there are books like Kan which discuss various quality metrics and their utilities. I'm not asking this either. I want to know how one applies these metrics to make decisions. E.g. suppose we decide to go with critical errors / KLOC. One of the problems we'll have to deal with with that this is not a normally distributed data set (almost all patches have zero critical errors). And further, it's not clear that we really want to examine the difference in means. So what should our alternative hypothesis be? (Note: Based on previous questions, my guess is that I'll get a lot of answers telling me that this is a bad idea. That's fine, but I'd request that it's based on published data, instead of your own experience.)


What does the implementation of .NET string.Split(char[], StringSplitOptions) look like from inside?

That is if we were to see how Microsoft wrote this method what would it look like? I'm mainly interested in the use of the StringSplitOptions enumeration with the other parameter and how they probably structured their code to account for each option.


Has anyone thoroughly compared C# common coding standards?

Most of the C# programmers I know embrace one of the common coding standards. However being aware of the standards is one thing, telling the differences is another. Browsing the common coding standards documents our there on C#, my first reaction was it's more of the same. Admittedly I didn't bother reading everything. Has anyone ever compared them and point out the **major** differences between them?   * **Microsoft's Design Guidelines for Developing Class Libraries**   * **The IDesign C# Coding Standard, development guidelines, and best practices**   * **Lance Hunt's C# Coding Standards**


Good industry qualifications to aim for as a grad?

I am a fairly recent grad and have been working for over a year now in software development. I would like to get a couple of professionally recognised exams on my CV. I am currently looking at Oracle certified java programmer. But are there any others that would look good and people would recommend?


"PHP: Good Parts"-ish book / reference

Before I had my first proper contact with Javascript I read an excellent book "Javascript: The Good Parts" by Douglas Crockford. I was hoping for something similar in case of PHP. My first thought was this book: "PHP: The Good Parts" from O'Reilly However after I read the reviews it seems it totally misses the point. I am looking for a resource that would:   * concentrate on known shortcommings of PHP,   * give concrete examples,   * be as exhaustive as possible I already see that things can go wrong. **Research:** I looked through SO, and Programmers for materials. I obviously found this question: http://stackoverflow.com/questions/90924/what-is-the-best-php-programming-book It's general, mine is specific. Moreover I'm reading the top recommendation "PHP Objects, Patterns, and Practice" right now. I find it insufficient -- it doesn't address the bad practices as much as I would like it to. **Motivation:** I don't _dislike_ PHP. I'm not even competent enough just yet to really state that. In 3 months however, I will start a job that will likely involve a lot of development in that language. I do not really know what quality the code will be. I also don't want to be the guy to introduce all the bad practices and then learn everything the hard way. I try to find out about as many traps that I possibly can. In case of Javascript Crockford's lectures really served as a guiding light. I would never feel confident in Javascript without them.


Hidden web standards behind Google "custom searchEngines"?

Today while playing with Google Chrome Omnibox, I notice a strange behavior. I guess there's some "hidden" web standard behind it, but can't figure it out. Here's how to reproduce:   1. Go to http://edition.cnn.com/   2. Use the search function at the higher right corner, Search a random keyword, for example: "abc"   3. Close the tabs.   4. Open a new tab, type until Chrome reminds you about http://edition.cnn.com/, then press "Tab"   5. The Omnibox now shows "Search CNN.com"! And when you type "abc" and press Enter, it uses the CNN search function to do the job, not Google! I also tried it for several different sites. To some it won't work. But to some sites, like CNN, vnexpress.net, it works after I use the search function of that site once. I also learnt about `chrome://settings/searchEngines` (type it in your chrome box and you will see), and learnt about you can add custom search engine in chrome. But the question is, why Chrome can realize the search URL automatically to some pages, and not others? It's not because some site subscribe to Google service, because I can do the same method for my site (http://ledohoanglong.wordpress.com), and I'm sure that there's no subscription. So I guess there's a method to "expose" the search function of a site, so that Google Chrome can catch it (after I call the search function of that site once, of courses). Does anyone know about how it works behind the scene?


Assembly in a research paper

I am doing a research paper on programming, and I need to somehow explain assembly... I've never learned the language, but I understand what it is used for and kinda what it looks like...               MOV A,47     ADD A,B     HALT      And from what I understand, it is used for writing some compilers, small bits of code that need to be really fast, and other tasks... But this is kind of a question for people who have used/studied assembly and understand it fairly well. And no, I'm not asking for you to type up this segment of the research paper for me. That would be selfish. I just need a brief explanation, clarification on the subject (I'm just unsure if what I know is true or not) and a pointer in the right direction. For a research paper (I need to explain this VERY simply...) what is purpose of using Assembly in today's society? Of course it was important back in the day but now with all the high level languages, when is this low level language used?


Why is the game industry, specifically , so harsh on programmers?

On hackernews and /r/programming I've heard several reports of how the games industry is incredibly harsh on programmers. Someone on this site also linked this blog post in an answer I read recently. According to various reports, programmers in the games industry are severely overworked. Perhaps not when working for small games companies, but definitely when working for places like EA(the place discussed in the blog post). So my question is, why? I'm a developer for a large networking company, I sometimes work more than 8 hours a day, but I wouldn't dream of working 12 hour days 6 days a week like the blog post describes. I'd quit and move on without a second thought. Why does the games industry, specifically, have this problem?


What's the point of camel-case-navigation?

I heavily use CTRL+ to jump between tokens in code (the `_`s are the navigation points):               _fooBar _+ _barFoo_;      Some editors, like the one in the current version of QtCreator, have (by default or optionally) camel case navigation, which goes like this:               _foo_Bar _+ _bar_Foo_;      What is the rationale behind this? I remember some people back in school saying "cool" and "fancy", but is that the whole story? I do not think it is cool, I find it very annoying actually.


Differences between Design by Contract and Defensive Programming

Could Designing by Contract (DbC) be a way to program defensively? Is one way of programming better in some cases than the other?


Do CDNs (such as MSFT and Google) act on the referrer header sent by clients?

Will my site be automatically indexed, or search ranking affected based on my use (or non use) of the Google/MSFT CDN? My clients will be sending them the referrer header which I may or may not want included in search results.


Spring MVC vs raw servlets and template engine?

> **Possible Duplicate:**   >  Why not Spring framework? I've read numerous articles about the Spring MVC framework, and I still can't see the benefits of using it. It looks like writing even a simple application with it requires creating a big hodgepodge of XML files and annotations and other reams of code to conform to what the framework wants, a whole bunch of moving parts to accomplish a simple single task. Any time I look at a Spring example, I can see how I can write something with the same functionality using a simple servlet and template engine (e.g. FreeMarker, StringTemplate), in half the lines of code and little or no XML files and other artifacts. Just grab the data from the session and request, call the application domain objects if necessary, pass the results to the template engine to generate the resulting web page, done. What am I missing? Can you describe even one example of something that is actually made simpler with Spring than using a combination of raw servlets with a template engine? Or is Spring MVC just one of those overly complicated things that people use only because their boss tells them to use it? **EDIT** : A summarized concrete description would be helpful. For example, "I used Spring MVC to build an application that did XYZ, and its feature Q saved me from having to do the extra work of A and B and C which would have been necessary with raw servlets and a template engine." Simply mentioning marketing buzzwords like "dependency injection" doesn't clarify anything.


Best ways to sell management on the benefits of Open Source Software?

I have worked in a few places where the use of Open Source Software in products they produce is strictly forbidden for various reasons, such as:   * no formal support   * lack of trust in something perceived as "just downloaded from the internet"   * How can it be professional if it's not supported, we don't pay for it etc etc I'm looking for the best ways to convince/prove to management that things won't fall apart should we use these tools.


What is the best way to evaluate new programmers?

What is the best way to evaluate the best candidates to get a new job (talking merely in terms of programming skills)? In my company we have had a lot of bad experiences with people who have good grades but do not have real programming skills. Their skills are merely like code monkeys, without the ability to analyze the problems and find solutions. More things that I have to note:   * The education system in my country sucks--really sucks. The people that are good in this kind of job are good because they have talent for it or really try to learn on their own.   * The university / graduate /post-grad degree doesn't mean necessarily that you know exactly how to do the things.   * Certifications also mean nothing here because the people in charge of the certification course also don't have skills (or are in low paying jobs). We need really to get the good candidates that are flexible and don't have mechanical thinking (because this type of people by experience have a low performance). We are in a government institution and the people that are candidates don't necessarily come from outside, but we have the possibility to accept or not any candidates until we find the correct one. I hope I'm not sounding too aggressive in my question; and BTW I'm a programmer myself. _**edit:_** I figured out that asked something really complex here. ~~I will un-toggle "the correct answer" only to let the discussion going fluent, without any bias.~~


About languages strongly typed with late binding, do they make sense?

I never learnt anything about VB6 (and I dont want to) but I wanted to search for bad things in computer software, so my first though was VB6. So for example, VB6 was strongly typed with late binding. Makes some sense to have a language with that combination? (I dont think so). I want to know reasons of why VB6 was like this! or why is good idea for a lenguage to be like this. Bad things that happend with a lengugage like this? good things?


What software is used to write functional and non-functional requirements?

Is there any software which can be used to write functional and non-functional requirements? When writing those, it is essential to:   * Store the document in text format to be able to make diffs and minimize the impact on the version control,   * Apply extensive formatting when creating diagrams would be an overkill,   * Use diagrams, preferably stored in text format as well,   * Cross-link the requirements or the appendixes. Currently, I can only think about three editors which _may_ be used, but which are not truly suitable:   1. **A Markdown editor.** Benefits: text only; easy to add formatting. Disadvantage: not powerful enough: one can add images, but not diagrams; formatting is rather limited; no cross-linking (unless adding much HTML markup).   2. **An HTML editor.** Benefits: text only; ability to add diagrams with HTML 5. Advanced formatting is possible. Disadvantages: markup difficult to change by hand, or if WYSIWYG editor is used, markup is often too verbose and low quality; cross-linking limited to manual only.   3. **A document editor such as OpenOffice or Microsoft Word.** Benefits: ability to apply some advanced formatting; excellent automated cross-linking. Disadvantages: binary format, which means no diff and wasted space in version control. What are my other choices? What is actually used in the industry?


Do you keep your project code names the same in the source tree?

Sometimes when I start working on a project, I just can't think of a good name, or think of a good name that isn't already taken. As a result, I'll end up picking some sort of code name for the project. My question is, how do you handle name changes in your source code once you find a real name for your project? Should you continue to refer to the code name in your source tree, namespaces, binaries, etc?


Ways to ensure unique instances of a class?

I'm looking for different ways to ensure that each instance of a given class is a uniquely identifiable instance. For example, I have a `Name` class with the field `name`. Once I have a `Name` object with `name` initialised to John Smith I don't want to be able to instantiate a different `Name` object also with the name as John Smith, or if instantiation does take place I want a reference to the orginal object to be passed back rather than a new object. I'm aware that one way of doing this is to have a static factory that holds a `Map` of all the current Name objects and the factory checks that an object with John Smith as the name doesn't already exist before passing back a reference to a `Name` object. Another way I could think of off the top of my head is having a static Map in the `Name` class and when the constructor is called throwing an exception if the value passed in for `name` is already in use in another object, however I'm aware throwing exceptions in a constructor is generally a bad idea. Are there other ways of achieving this?


Shell independence in programming groups

Our programming environment is dependent upon certain environment variables being set. For example, to use distcc, one needs to define the `DISTCC_HOSTS` environment variable. The way we handle this is forcing each developer to `source` a global `tcshrc` file upon invoking a new shell. The global `tcshrc` file contains statements to set the environment variables up (among other things). However, this is awfully discriminatory as each developer is forced to use `tcsh` since setting an environment variable is different per shell. The most obvious solution to this problem to have corresponding global `bashrc` and `zshrc` files, but that of course becomes cumbersome since now we have to maintain three different files all containing the same logic. Are there any clean solutions to solve this sort of situation?


Are 3rd-party controls and MVC anathema?

At http://www.codeproject.com/Articles/552846/Why-s-How-s-of-Asp-Net-MVC- Part-1, I read this: "You should not use Asp.Net MVC if you rely on 3rd party vendor controls for of the UI." The author doesn't seem to say why (maybe the explanation is too subtle, or I'm too dense). Thoughts? Is it true? Why would this be?


Why don't public web applications use ini files for configuration

Almost every public CMS out there uses a .php configuration file for the database settings and so on. For example WordPress automatically creates a .php config file when you install it. Why don't they just use a .ini file? PHP already has parse_ini_file() and I'm sure other languages have similar functions.


How to determine the effectiveness of a code review process?

We've introduced a code review process within our organisation and it seems to be working well. However, I would like to be able to measure the effectiveness of the process over time, i.e. are we not finding bugs because the code is clean or are people just not picking up on bugs? Currently, we don't have an effective fully-automated test process. We primarily employ manual testing, so we can't rely on defects found at this stage to ensure that the code review process is working. Has anyone come across this issue before or has any thoughts on what works well in measuring code reviews?


Why should I prefer composition over inheritance?

I always read that composition is to be preferred over inheritance. A blog post on unlike minds, for example, advocates using composition over inheritance, but I can't see how polymorphism is achieved. But I have a feeling that when people say prefer composition, they really mean prefer a combination of composition and interface implementation. How are you going to get polymorphism without inheritance? Here is a concrete example where I use inheritance. How would this be changed to use composition, and what would I gain?               Class Shape     {     string name;     public:     void getName();     virtual void draw()=0;     }          Class Circle: public Shape     {     void draw(/*draw circle*/);     }


Declaring a field name starting with underscore

Before forming a class in Java or other programming languages that support OOP, should I use underscore (_) in each ( **local** or **private** ) field declaration. More precisely: > private String _customername; Is this a correct declaration?


How do I fix an "emergent" bug?

I'm writing a PDE solver, and I have a bug that only shows up in very large test cases. That is, with small grids the program gives correct answers, but there's a large amount of unaccounted-for error (I've accounted for roundoff, discretization, and other standard types of error that unavoidably occur) that creeps in when my test cases get into the days-to-finish range. I can't run this in a debugger, that would take weeks. And printing out intermediate results is not particularly useful given that I can't manually inspect the output to see what's wrong. **How can I find and fix this "emergent" bug?**


Linking to MIT-Licensed dll

I'm currently working on some closed-source proprietary software that makes use of a library ( **SharpAVI** ) distributed with the MIT License. The SharpAVI source _isn't_ being used directly anywhere in my project, only the unchanged .dll provided for download on the codeplex site linked above. The .dll is referenced in one very small distinct project inside a much larger solution (consisting of a single wrapper class around the functionality provided by SharpAVI). I'm particularly concerned about this wording: > The above copyright notice and this permission notice shall be included in > all copies or substantial portions of the Software. Does the license need to be included in a file with _my_ code, which is linked to the licensed code by .dll, and includes none of the original source? Would this make my wrapper code an MIT-licensed product (that would seem to go against the non-viral nature of the license)? If my wrapper needs to become licensed under the MIT License, wouldn't that propagate to any other code that references it as well? **How do I properly attribute the license information for a linked MIT- Licensed .dll without releasing my own code under the MIT License?**


Why can't C arrays have 0 length?

The C11 standard says the arrays, both sized and variable length "shall have a value greater than zero." What is the justification for not allowing a length of 0? Especially for variable length arrays it makes perfect sense to have a size of zero every once and a while. It is also useful for static arrays when their size is from a macro or build configuration option. Interestingly GCC (and clang) provide extensions that allow zero length arrays. Java also allows arrays of length zero.


Good resources and tools for modern, heavy JavaScript development?

I am interested in doing some projects that involve heavy use of JavaScript. Namely HTML5 based canvas games, potentially using node.js as well. I am interested in learning modern best practices, tools and resources for JavaScript. JavaScript is tough to research because you end up wading through a lot of really outdated material, hailing from the times that "JavaScript" was a four letter word. If you are heavily involved in JavaScript programming...   * What text editor or IDE do you use?   * What unit testing framework do you use?   * Do you use Selenium, or something else?   * What other tools do you use?   * What communities exist that discuss recent advents in JavaScript?   * What books do you read/refer to?   * What blogs do you read?


Is there a book for learning Javascript -> DOM -> jQuery?

> **Possible Duplicate:**   >  The importance of javascript and the best way to learn it? I would like to learn Javascript, the DOM model and jQuery. I've found many recommendations for books for each subject, but I wonder if there is a single book which teaches the three subjects in order and how they relate to each other. Thanks for any advice.


Project Suggestion for computer networks using C#

I am looking for suggestion for a project in computer networks using C# as the development tool, as part of a university course I am taking. The project should last about a month, involving two people. I'll be happy to hear any intresting ideas you might have.


Ruby on Rails Development: updating model attribute using f.association collection

Im currently working on a rails program. It contains many different databases but to keep things simple I have a people, student, and faculty table. A person can be a student or faculty member and there all connected by the person_id. A faculty member advises students so the student is connected to the faculty member by the id of the faculty. To create a student you need to select a major and a faculty member(faculty_id). Being that the student and faculty members are all people.. in my dropdown I had to use               <div>       <%= f.input :faculty_id %>       <%= f.association :person, label: "Advisor", label_method: :to_label ,  value_method: :id, include_blank: false, collection:  Person.where("role_id=?", @role.id)%>          </div>      to limit the people in the drop down to only faculty members. But the issue Im running into now is how would I set the faculty_id attribute of the student with the selected value of the association collection?


How can you write tests for Selenium (or similar) which don't fail because of minor or cosmetic changes?

I've been spending the last week or so learning selenium and building a series of web tests for a website we're about to launch. it's been great to learn, and I've picked up some xpath and css location techniques. the problem for me though, is seeing little changes break the tests - any change to a div, an id, or some autoid number that helps identify widgets breaks any number of tests - it just seems to be very brittle. so have you written selenium (or other similar) tests, and how do you deal with the brittle nature of the tests (or how do you stop them being brittle), and what sort of tests do you use selenium for?


Is OO-programming really as important as hiring companies place it?

I am just finishing my masters degree (in computing) and applying for jobs. I've noticed many companies specifically ask for an understanding of object orientation. Popular interview questions are about inheritance, polymorphism, accessors etc. Is OO really that crucial? I even had an interview for a programming job in C and half the interview was OO. In the real world, developing real applications, is object orientation nearly always used? Are key features like polymorphism used A LOT? I think my question comes from one of my weaknesses. Although I know about OO, I don't seem to be able to incorporate it a great deal into my programs.


How to get people involved in your project?

I have many project ideas and unfortunately all require a team of at least 3-5 developers. I've started a project by myself too many times without reaching the end. The point is to involve people in the project with the hope of giving them a share if the project succeeds. I know that the last point however is the hardest and most complicated one. I’m hoping to get some answers that point me in the right direct.   1. Where do I find people that may be interested in the idea?   2. How do I convince people in my network to put time in new ideas? **Update:** Regarding "projects" I'm referring to projects in which I have initiated during my career as developer. Of course it wouldn’t be serious of me to launch several simultaneous projects and complain about not to be able to deliver them to the end.


How can I layout this class to make it easier to use for API developers?

I have an application that allows the user to place a string of text into a PDF document. I have three different ways that they can do this:   1. **Use a Form Field.** Then they have four properties to define:      1. Provide field name     2. provide instance of the field     3. provide an X-axis Offset     4. provide a Y-axis Offset    2. **Search for a string of text.** Then they have four properties to define:      1. Provide string of text to search for     2. provide instance of that string of text     3. provide an X-axis Offset     4. provide a Y-axis Offset    3. **Define Page Coordinates.** Then they have three properties to define:      1. Provide page number      2. provide an X-axis Offset     3. provide a Y-axis Offset In my API, I want the object to be setup intuitively so that it is clear they are choose one of the three different methods and then whichever one they choose, they have the options for each. In my old API, all of those options are grouped together as a list of properties like this:               Placement.FormField_FieldName     Placement.FormField_Instance     Placement.SearchText_Text     Placement.SearchText_Instance     Placement.PageCoordinates_PageNumber     Placement.XOffset     Placement.YOffset      I find this to be a little confusing for the developer using the API because you could never use all of the properties together. You would either use **Form Field** like this:               Placement myPlacement = new Placement();     myPlacement.FormField_FieldName = "MyPdfFormFieldName";     myPlacement.FormField_Instance = ;     myPlacement.XOffset = 0;     myPlacement.YOffset = 0;      Or use **Text Search** like this:               Placement myPlacement = new Placement();     myPlacement.SearchText_Text = "My String Of Text";     myPlacement.FormField_Instance = 1;     myPlacement.XOffset = 0;     myPlacement.YOffset = 0;      Or use **Page Coordinates** like this:               Placement myPlacement = new Placement();     myPlacement.PageCoordinates_PageNumber = 1;     myPlacement.XOffset = 0;     myPlacement.YOffset = 0;      Is there a better way to setup the class (or sub classes) to make it easier for the developer to understand how to use this functionality?


How are mixins or traits better than plain multiple inheritance?

C++ has plain multiple inheritance, many language designs forbid it as dangerous. But some languages like Ruby and PHP use strange syntax to do the same thing and call it mixins or traits. I heard many times that mixins/traits are harder to abuse than plain multiple inheritance. What specifically makes them less dangerous? Is there something that isn't possible with mixins/traits but possible with C++-style multiple inheritance? Is it possible to run into the diamond problem with them? This seems as if we were using multiple inheritance but just making excuses that those are mixins/traits so we can use them.


How to drastically improve code coverage?

I'm tasked with getting a legacy application under unit test. First some background about the application: It's a 600k LOC Java RCP code base with these major problems   * massive code duplication   * no encapsulation, most private data is accessible from outside, some of the business data also made singletons so it's not just changeable from outside but also from everywhere.   * no abstractions (e.g. no business model, business data is stored in Object[] and double[][]), so no OO. There is a good regression test suite and an efficient QA team is testing and finding bugs. I know the techniques how to get it under test from classic books, e.g. Michael Feathers, but that's too slow. As there is a working regression test system I'm not afraid to aggressively refactor the system to allow unit tests to be written. **How should I start to attack the problem to get some coverage quickly** , so I'm able to show progress to management (and in fact to start earning from safety net of JUnit tests)? I do not want to employ tools to generate regression test suites, e.g. AgitarOne, because these tests do not test if something is correct.


What are the key points of Working Effectively with Legacy Code?

I've seen the book Working Effectively with Legacy Code recommended a few times. What are the key points of this book? Is there much more to dealing with legacy code than adding unit/integration tests and then refactoring?


A container only assets in Rails

I have multiple segmented Rails apps that are connected to each other:   * App A   * App B   * App C While I try to keep the design, such as header and footer, to look similar, but each app has its own stylesheet, javascript and images in the asset folder. Some of these assets are duplicate, like CSS for footer. It makes maintenance difficult. I'm wondering if I could do something like having App D, where App A, B, and C will just retrieve the assets from App D. So if I need to change anything, I can just change the assets in App D. How do I achieve this?


Use and manage Front End Assets for Web

I am a beginner and am currently developing a kind of cms using PHP. The number of libraries that we can potentially use in the front end is large. I have a question about properly selecting, managing and using front end asset libraries. I don't think just including a bunch of front end libraries like this is the best approach:               <script src="library1" /></script>     <script src="library2" /></script>     <script src="library3" /></script>     // and soon..      What if we use, let's say 20 ? Is that good practice, declaring the script tags 20 times ? What I do currently is use `Assetic`, a php library for managing assets. I create a dump file (and cache it) for each request to my application before loading a template. My controller (I use MVC) could be something like this:               function indexAction()     {         // some logic              $assetManager = $this->get('assetic'); // get assetic service         $css = $assetManager->createAsset(array(                 '@bootstrap',                 '@jquery_ui'                  // and many other library         ));               $assetContent = $css->dump();               // create asset url, dont mind about this          $data['stylesheet'] = $this->createAssetUrl($assetContent);              return $this->render('index-template', $data);     }      And in the template (index-template), I could put kind of:               <link href="<?php echo $stylesheet ?>" rel="stylesheet" type="text/css">      I do that in almost every controller to include a bunch of assets to view. But I am not sure if this is the best method. Are there any better practical method that I don't know ?


Where and when should I use RESTful

When I should use REST? In what kind of web applications? In terms of java in what situation RESTful would be better than ordinary servlets / JSP ? Imagine that I have a web page where users can upload two kinds of files and create some objects that are later saved in DB(current tasks etc). The only think users can download is this two kinds of files. Will RESTful be a good approach in that kind of service?


What did machine code for 4-bit architecture look like?

I don't know how a 4-bit instruction could be enough to do something so I read about the Intel 4004 and it says that it used 8-bit instructions and then I can understand how opcode and numbers has enough digits. Is it true that there never were any 4-bit instructions and that 4-bit systems use 8-bit instructions?   And that opcode and two numbers in an instruction can be done in 8 bits but not in 4 bits?


Manual dependency injection or abstract factory

We're starting to use dependency injection in a fairly large, interactive program. It's early yet, but I have a feeling that the majority of the objects being injected are going to want runtime data passed in to their constructors. Prior to this, I've only used DI in web applications where building everything at the composition root isn't a problem. When working with runtime data, it sounds like the options are to use manual injection or abstract factories. Is there anything important to consider when deciding between the two or does it mainly come down to personal preference? I'm using Ninject with the factory extension, so going the factory route isn't too onerous. However, if we end up with factories in every class, is that a sign that we're doing something wrong? Should we prefer manual injection when the power of an IoC container isn't needed? Could it simply mean that we're over-using dependency injection?


Should I be using OOCSS in a CSS theme?

I have heard of OOCSS some time ago, but never really looked into it. Today I did so, and I thought of the implications of applying OOCSS to a simple CSS theme. One problem I thought of is that, by its nature, OOCSS encourages DRYness and consequently the use of many concise classes that should be applied to elements by the HTML developer. As a CSS theme, I would assume it isn't something significant enough for a developer would go out of his/her way to add specific classes to their elements when writing HTML:               <button class="blue rounded no-border $etc">Button</button>      as opposed to:               <button>Button</button>      Perhaps the HTML developers would be OK with writing the extra code, although it seems there is just as much repeating code on the HTML side as there would be without OOCSS. So, is OOCSS not a one-size-fits-all methodology for writing CSS code, as in this example? Or am I not understanding things properly?


How to handle fine grained field-based ACL permissions in a RESTful service?

I've been trying to design a RESTful API and have had most of my questions answered, but there is one aspect of permissions that I'm struggling with. Different roles may have different permissions and different representations of a resource. For example, an Admin or the user himself may see more fields in his own User representation vs another less-privileged user. This is achieved simply by changing the representation on the backend, ie: deciding whether or not to include those fields. Additionally, some actions may be taken on a resource by some users and not by others. This is achieved by deciding whether or not to include those action items as links, eg: edit and delete links. A user who does not have edit permissions will not have an edit link. That covers nearly all of my permission use cases, but there is one that I've not quite figured out. There are some scenarios whereby for a given representation of an object, all fields are visible for two or more roles, but only a subset of those roles my edit certain fields. An example:               {         "person": {             "id": 1,             "name": "Bob",             "age": 25,             "occupation": "software developer",             "phone": "555-555-5555",             "description": "Could use some sunlight.."         }     }      Given 3 users: an Admin, a regular User, and Bob himself (also a regular User), I need to be able to convey to the front end that: Admins may edit all fields, Bob himself may edit all fields, but a regular User, while they can view all fields, can only edit the description field. I certainly don't want the client to have to make the determination (or even, for that matter, to have any notion of the roles involved) but I do need a way for the backend to convey to the client which fields are editable. I can't simply use a combination of representation (the fields returned for viewing) and links (whether or not an edit link is availble) in this scenario since it's more finely grained. Has anyone solved this elegantly without adding the logic directly to the client?


How to explain pointers to a Java/VB programmer

I am writing a game and my friend has offered to help me as it is a RPG and will take a long time to do the "scripting" bit of the game. The problem is IMO he's not that good a programmer :( (add flame war here). He has only programmed in Java and VB and keeps saying really stupid things to me like "Why don't you drag and drop an onClick event" to design my UI when I'm using DirectX. I tried explaining pointers to him but his response was, if it's just a variable that holds a memory address, why don't you just use an int? I create an instance of an attack class and give the creature a pointer to it so if several creatures use the same attack there is only one instance of it. He keeps saying why not put if statements in the creature class for every attack class and set true for the ones that are there. He has programmed mainly in VB and a little in Java just to learn OOP. How can I explain advanced C++ concepts like pointers and memory management to him? He just doesn't understand there are no super functions like form.show in C++.


Android: Not able to experiment on own?

I have just started learning Android App Development a few days ago, with prior knowledge of C/C++, HTML and CSS. This is the situation I am facing Repeatedly: I am learning from a Video Tutorial Series, after each video, or each few videos, I say myself: Let's use what I have just learnt in the simple (and also "meaningless") app that I have made so far by watching the tutorials. I start implementing it, but then after a few minutes, I realize that I cannot do it because I do not know a few other syntax related to the particular thing, (or) I do not know whether these things can be combined with these other things by the use of . (dot). Whatever I try, I get either an error in eclipse or "Sorry...the app com.example.simple has stopped unexpectedly...." when the app runs. Then I search StackOverflow, Google and learn that what I want to implement requires learning about a few more classes, syntax and creating a few more java classes. I am not able to experiment on my own. Is it normal? Is it the HARD-WAY in which one is supposed to learn? Should I first learn Java and then come back to Android - would that be helpful?


Ruby workflow in Windows

I've done some searching and quite haven't come across the answer I am looking for. I do not think this is a duplicate of this question. I believe Windows could be a suitable development environment based on the mix of answers in that question. I have been developing in Ruby (mostly Rails but not entirely) for about a year now for personal projects on a Macbook Pro however that machine has faced an untimely death and has been replaced with a nice Windows 7 machine. Ruby development felt almost natural on the Mac after doing some research and setting up the typical stack. My environment then included the standard (Linux like) stuff built into OSX, Text Wrangler, Git, RVM, et al. Not too much of a deviation from what the 'devotees' tend to assume. Now I am setting up my new Windows box for continuing that development. What would my development environment look like? Should I just cave and run Linux in a VM? Ideally I would develop in Windows native. I am aware of the Windows Ruby installer. It seems decent but its not exactly as nice as RVM in the osx/linux world. Mercurial/Git are available so I would assume they play into the stack. Does one develop entirely in Windows? Does one run a webserver in a Linux VM and use it as a test bed while developing in Windows? Do it all in a VM? What does the standard Windows Ruby developer environment look like and what is the workflow? What would a typical step through be for adding a new feature to an ongoing project and what would the technology stack look like?


Why is it often said that the test cases need to be made before we start coding?   What are its pros and what the cons if we don't listen to this advice? Moreover, does that advice refer to black box testing or White Box testing or both?


Why don't many code review tools seem to be syntax aware or provide more in-depth analysis of changes?

Why don't many code review tools seem to be syntax aware or provide more in- depth analysis of changes? Is it simply too hard to do? I find this to be a major hole of most programmer's toolkits. From what I have seen, which admittedly is not much, code review tools just compare code line- by-line with many of them not even being able to do syntax highlighting. Is there a solution out there that is smart enough to offer file-level, method-level code review/comparison? One of the simple problems I have is that methods get re-ordered in code and my code review software breaks down completely, but they should be able to do so much more. I'm interested in others opinions/knowledge on the topic of code review/comparison tools.


What are the pros and cons of having a CaseInsensitiveString type in Java?

I'm tempted to create a `final class CaseInsensitiveString implements CharSequence`. This would allow us to define variables and fields of this type, instead of using a regular `String`. We can also have e.g. a `Map<CaseInsensitiveString, ?>`, a `Set<CaseInsensitiveString>`, etc. What are some of the pros and cons of this approach?


Who should pay for fixes/bugs?

So I just started freelancing both in desktop/web development and this client who already accepted my work, and payed me keeps coming back at me each time he finds a bug etc. And I have found myself spending more time than I thought fixing them for free. Is this alright, or should I start charging a support fee? Which is the best way to deal with fixes on a supposedly accepted and completed work?


Keeping SQL Server DB Up to date in Team environment

We are working in a Visual Studio Environment using TFS. When developers get the latest source code it includes a copy of the 'update' sql scripts for the database of the application. The challenge is keeping our local copies of the DB up to date. When changes are made to the DB by another developer, we are looking for a way to:   1. indicate to other developers that their version of the DB is out of date   2. indicate to other developers the order in which they should run the update scripts We are looking for suggestions. For point number 2, I have used numbers such as 01_DropCreate_TableX, 02_Create_StoreProcedure_X. etc DH


Picking powers of two for sizes/limits

A habit I've observed among programmers, and a habit I sometimes subconsciously exhibit myself, is to pick powers of two (or powers of two minus one) when defining a database schema, a data buffer, etc. Have you made the same observation? If I'm not being blatantly subjective, the follow-up questions are: Are there still valid reasons to use powers of two [minus one] in modern technologies? Assuming these habits are mostly vestiges of old technological limitations, I'm just wondering what different flavors of limitations there once were. Some potential reasons I can think of are data structure optimizations and addressing bits. I'm wondering what else was/is out there...


Multi-module web project with Spring and Maven

Assume we have a few projects, _each_ containing some web resources (e.g., html pages).               parent.pom      +- web           (war)      +- web-plugin-1  (jar)      +- web-plugin-2  (jar)      ...      Let's say `web` is the deployable `war` project which depends on the known, but selectable, set of plugins. What is a good way to setup this using `Spring` and `maven`?   1. Let the plugins be `war` projects and use mavens **poor** support for importing other `war` projects   2. Put all web-resource for all plugins in the `web` project   3. Add all web-resources to the classpath of all `jar` `web-plugin-*` dependencie and let spring read files from respective classpath?   4. Other? I've previously come from using `#1`, but the `copy-paste` semantics of `war` dependencies in maven is horrible.


How can one find software development work that involves directly the final end user?

I've worked in software development for 15 years and, while there have been signficant personal achievements and a lot of experience, I've always felt detached from the man/woman-on-the-street, the every day person, how it affects their lives, in a number of ways:   * the technologies: embedded software, hidden away, stuff not seen by the everyday person. Or process technology supporting manufactured products   * the size of the systems, meaning many jobs, divided up, work is abstract, not one person can see the whole picture   * the organisations: large, with departments dealing with different areas, the software, the hardware, the marketing, the sales, the customer support   * the locations and hours: out-of-town business parks away from the rest of society, fixed locations, inflexible: 9-5 everyday This to me seems typical of the companies I worked for and see elsewhere. Granted, there are positives such as the technology itself and usually being among high calibre co-workers, but the above points frustrate me about the industry because they detach the work from its meaning. How can one:   * change these things in an existing job, or compensate for them?   * find other work that avoids these and connects with the final end user? Job designs tend to focus on the job content and technical requirements rather than how the job aims to fulfil end user needs, is meaningful.


Would this be the equivalent of creating a branch, while working with a detached head in Git?

Let's say I checked out a version different than HEAD. Let's say I made some commits, and so an anonymous branch was created. Afterwards I may have checked out a different branch, so now the only way to get to my commits is via `reflog`. If do this:               >> git reflog | grep -i mycommit     sha1hash     >> git branch reattaching     >> git cherry-pick hash_of_commits     >> git checkout master     >> git merge reattaching      Is it the equivalent of:                  >> git reflog | grep -i mycommit         sha1hash        >> git branch reattaching sha1hash        >> git checkout master        >> git merge reattaching      What happens to the detached head commits, as I think that via cherry-picking, they will exist in 2 places. Will they forever remain in my repository?


Thoughts on Development using Virtual Machines

I'll be working as a development lead for a startup and I've suggested that we use VMs for development. I'm not talking about each developer having a desktop with VMs for testing/development, I mean having a server rack where all VMs are managed and have the developers work from a microPC (ChromeOS anyone?) locally, or even remotely from their home computer. To me, the benefits are the fact that it's extremely scalable, cheaper in the long run, easier to manage and that we utilize the hardware its maximum potential. As for cons, I can't think of any particular showstoppers other than we'll need someone to setup/maintain said setup. I was hoping that some of you might of had a similar setup at your place of employment and be able to weight in with your opinions. Thanks.


Boss wants to convert all developers to virtualized desktops

> **Possible Duplicate:**   >  Thoughts on Development using Virtual Machines My boss has been singing the praises of leveraging virtualized desktops for all our developers in the company - about 100 people. I think this is a horrible idea and can think of no other companies pursuing a similar course of action. He believes that he can run Word and Outlook much faster over his server hosted virtual machine and has somehow come to believe that this will work for software development just as well. I have grave doubts of this. **Can anyone else provide me with some objective technical and/or business data on this scenario which can be used to dissuade him?** I can see desktop virtualization as a viable option for task based workers who sit in front of MS Office or a LOB app all day, but for software development, I see this as a huge potential blunder. I for one, have no interest in returning to dumb terminals and blind faith in operations to keep the servers and network tuned to our needs. If such a system is instituted, I may very well leave the company... as I see the policy betraying a clear lack of understanding and a diminished perception of value in what the devs are doing...