Unit testing best practices for a unit testing newbie

In recent years, I have only written small components for people in larger projects or small tools. I have never written a unit test and it always seems like learning how to write them and actually making one takes a lot longer than simply firing up the program and testing for real. I am just about to start a fairly large scale project that could take a few months to complete and whilst I will try to test elements as I write them (like always), I am wondering if unit testing could save me time. I was just wondering if anyone could give good advice:   1. Should I be looking at unit testing at the start of the project and possibly adopt a TDD approach.   2. Should I just write tests as I go along, after each section is complete.   3. Should I complete the project and then write unit tests at the end.


Algorithm Correctness and Complexity Analysis

If given an algorithm to traverse a graph (say with a breadth first traversal algorithm). And say you code it in the same manner described in this video tutorial shows (starting at 04:30 for breadth first). Then you were asked to do an Analysis of the correctness and complexity of the code. What things will you set your mind to think about in analysing the algorithm? I mean let us start with Correctness Analysis .. is it simply a matter of setting my algorithm to work on 100s and 1000s of different graphs and if the traversal of all of them is a success I say "Yep, I have analysed this and it is correct!" Or is there more to it? **How would you analyse the correctness of a piece of code?** Also complexity .. there are so many parameters to complexity, but I'm guessing with it being an Algorithm, it'll be useful to talk about that n metrics stuff, n to the power of 2 and so on .. that is complexity is it not? The higher the power of n, the more complex the algorithm. How can I figure out the power of n for some code? **How do you determine the complexity of an algorithm?**


Looking for good practices on managing branches and developers in Git

I a little while ago I joined a new development team and recently we had our first major release. We've used Git since the beginning of the project and by now are somewhat comfortable with it. However, now that the product is in the field, we are discovering new issues/processes that need to be established. Up to this point, everything we've done was by referencing the very popular successful branching model post, which indeed has been very helpful Currently we have the following branches, all live and all being updated:   * master - only released, stable code (tagged every time release is cut)   * develop - wide open. used for long term development   * hotfix-1.0.1 - branched off master's 1.0.0 tag for small, very targetted fixes which are already lining up   * release-1.1 - This is a small incremental release that we want to push relatively soon so we wanted to manage it separately from develop and to limit scope of changes. These are the merging rules we are establishing:   1. If a code change is made in release-1.1, it must be merged up to develop.   2. If a code change is made in hotfix-1.0.1, it must be merged up to release-1.1.    3. Nobody except for one team member should merge anything into master and that merge only happens when a product version is about to be shipped. My questions are:   1. When should the merges take place? As soon as the fix is applied in lower-level branch? Or periodically in chunks of changes? If periodically, how do you typically determine merge period?   2. Who should do the merges? Person making the original code change? Or one individual who would be designated as "Director of Git Services"? Reason I'm asking all this is because it seems that while Git is very flexible (and I do love that part about it), it also allows you to easily shoot yourself in the foot. With just few commands, someone could easily, and hopefully not on purpose, merge new development right into hotfix that should ship out in 2 days. Many of us are new to Git and we are still feeling our way around the tool. I was thinking how my other companies/teams handled such concepts in the past and I think the biggest difference is that most other source control products that I've used, work with individual commits, so each developer could be responsible for making sure his fixes are applied to the correct places. But with Git, when one developer runs:               git checkout release-1.1     git merge hotfix-1.0.1      ... after his commit, those commands will end up merging an entire branch including code that he has never seen before and may not be the best person to resolve, if there are any conflicts.


Shared context: good or bad?

RSpec allows users to share context across tests / examples, which would reduce the number of code lines in my app by a significant amount. On the other hand, somehow related to the question of sharing codebase between tests, one of the reasons why I'm using Factories and not Fixtures is because I don't want tests to be dependent on code stored outside the tests. Ryan Bates explains it better: > There’s a heavy dependency between the tests and the fixtures and we can > cause the tests to fail just by changing the fixtures. External dependencies > that are this strong aren’t a good idea and make the tests brittle. What's best practice here, to share context across tests or to have an independent context for each test?


Using node.js, how to serve content without using a framework like express?

I'm trying to learn node.js and create a web application, and although I'm doing my best to just use only node.js to create it, I'm having a very difficult time finding resources and examples that describe the process without using other frameworks or libraries. Specifically, how can I serve HTML and CSS content without using hard-coded string variables, but serving up HTML and CSS files dynamically using just node.js?


Are `break` and `continue` bad programming practices?

My boss keeps mentioning nonchalantly that bad programmers use `break` and `continue` in loops. I use them all the time because they make sense; let me show you the inspiration:               function verify(object) {         if (object->value < 0) return false;         if (object->value > object->max_value) return false;         if (object->name == "") return false;         ...     }      The point here is that first the function checks that the conditions are correct, then executes the actual functionality. IMO same applies with loops:               while (primary_condition) {         if (loop_count > 1000) break;         if (time_exect > 3600) break;         if (this->data == "undefined") continue;         if (this->skip == true) continue;         ...     }      I think this makes it easier to read & debug; but I also don't see a downside. Please comment.


Is "continue" and "break" in loops antipattern/bad practice in Java?

I see the main purpose of `continue` in programming, it can get you out from the rest of loop steps like:               while(condition1){       ... code ...       if(!condition2){         continue;       }       ... code ...       if(condition3){         break;       }       ... code ...     }      I understand that condition2 and condition3 might depend on the inner code so it makes handy to make a separate escape route from loop step. But does it mean the code should be refactored instead building escape routes, like rethinking the original condition1? I would say if I need several `continue` and `break` parts, I feel bad about my code, usually I am working without `continue` and I don't really miss it. An another use of `continue` and `break` which I can accept is optimalization, but I still have the same feeling about it like I told above. For some reasons I have feeling "using GOTO". **Am I right, if I am not, why?**


what are the advantages and disadvantages of putting code for an unfinished project on github

I'm stating to work on a project that I intend to release as open source via the githubs. What are the advantages of putting the code on github from the outset, as opposed to waiting until the project is in a working state before publishing. If it matters, this particular project is a C# app/service, and I have only a free github account (so I can't make it private and then pull back the covers later)


Better OOP in Javascript - multiple methods or methods with options?

Let's say I have an object like this:               function Foo() {       this.parser = new DataParser();     };      Within Foo I have a method that does something like this:               Foo.prototype.getResponse = function(message, callback) {       var payload = {data: message, type: 'normal'};       var response = this.parser.parse(payload, function(data){         callback(data);       });     }      Now, let's say that somewhere else I need to call `foo.getResponse()`. Most of the time I want it to run just like this, but on occasion I need the format of the `payload` to be slightly different - let's say I need to specify a different type. Would it be better to make a different method for this slightly different kind of request, like so...               Foo.prototype.getSimilarResponse = function(message, callback) {       var payload = {data: message, type: 'other'};       var response = this.parser.parse(payload, function(data){         callback(data);       });     }      ... or to take an option on `getReponse`, like so...               Foo.prototype.getSimilarResponse = function(message, type, callback) {       var payload = {data: message, type: type};       var response = this.parser.parse(payload, function(data){         callback(data);       });     }      ... or to do something else entirely? Using a `type` option in the example above is a lot more DRY, but I don't like the way it requires the caller to know about payload type, which is really the concern of `Foo` and doesn't need to be exposed anywhere else. How would you recommend approaching a situation like the above?


Training materials - books vs webcasts

I'm in process of selecting some training materials for our team. We mainly focus on C# (Silverlight and ASP.NET) I thought it would be a good idea to get some books (to keep us up to date) but also I ran into some websites that offer webcasts/workshops with annual subscriptions fees. I much prefer following some video and actually trying out some code rather than reading C# bible, hence I liked the idea. **Has anyone had any experience with those video/webcasts/workshop learning? Are there any good ones out there?**


How do you assign error codes?

How, when developing a medium sized project, do you identify, create and maintain error codes? I for the life of me can't think of a simple and clean method of doing so. Some of my ideas convert class names and method name into an integer string, but that is way to long to display to the user on top of the fact that method names and class names may change (hopefully not!). Others are just using an incrementing log system (ie. when ever I create a new error message, just add 1 to the last error message id). But that is just completely unorganized. **Edit 1:** To be more specific I am talking about error code such as: `Error 401 Unauthorized.`


How to get to level where one can charge $300/hr?

I've been a developer for financials/hedgefunds in the Northeast for about 9 years now. I'm a consultant and would like to stay that way. What do I need to do to get to around $300/hr? I've been a pure dev my entire career so it seems like doing more management would be required. Is this goal even possible?


What is the size of a reference variable in java. Can it be calculated?

As pointers in C require 2 bytes of memory size irrespective of the size of the data type they are pointing. So does the same thing applies to java references also ?


Wrapping constructor arguments

Given a base class with around 25 or so subclasses, I have found that adding an argument to the base constructor is painful.               protected AbstractController(Service1 s1, Service2 s2, Service3 s3){ ... }     public Concrete1Controller(Service1 s1, Service2 s2, Service3 s3) : base(s1, s2, s3)     public Concrete2Controller(Service1 s1, Service2 s2, Service3 s3) : base(s1, s2, s3)      Now that I need yet another object passed to my base controller, I am debating introducing a wrapper class and refactoring so that only a single parameter is required in the constructors of (most) concrete instances.               public class ServiceLayer     {         public Service1 S1 {get; private set; }         public Service2 S2 {get; private set; }         public Service3 S3 {get; private set; }              public ScheduledReportServices(Service1 s1, Service2 s2, Service3 s3)         {             S1 = s1;             S2 = s2;             S3 = s3;         }     }      Which will allow me to clean up quite a bit.               protected AbstractController(ServiceLayer sl){ ... }     public Concrete1Controller(ServiceLayer sl) : base(sl)     public Concrete2Controller(ServiceLayer sl) : base(sl)      Given the amount that this reduces clutter, I'm either a dope for not doing this to begin with or there's a valid argument against this kind of approach. I'd be interested in a) knowing what this "pattern" is called and b) if I'm going to regret it and if so, why?


The most important advice to a non-professional programmer

As an adjunct to my regular job (teaching) I have taken on the task of developing an appointment booking system to be deployed on the school's server (SQL Server 2008 R2 / IIS 7.5). I have been writing and programming web pages since the very beginning, so I have a good knowledge of the client-side (including jQuery). I also have some knowledge and experience in database programming (Access and mySQL). For the last several months I have been been teaching myself server-side programming (mainly via the Apress books on MVC3, ASP.Net and C#, as well as through the tutorials on Pluralsight.) I shall be developing the system in Visual Studio 2010, and have written one or two basic practice solutions in MVC3 that work fine on my local development system. My question: What is the single most important thing I should know or do as I embark on this project? (PS. I am committed to using MVC3, Entity Framework 4.1, C# and Visual Studio.)


How are the forwarding of requests normally managed in the Chain of Responsibilty pattern?

I was just experimenting with the **Chain of responsibility** pattern, implementing my own version. I'm currently reading Design Patterns, but I'm not really sure whether DP tells to stop your forwarding of requests when a single action is accomplished, or just continuing to the end of the chain. What I'm interested in is how this feature of the COR pattern is managed in most of cases. In my example below, I let the forwarding continuing to the end of my chain. I don't think you need any source, but you can anyway find it here. If **I missed some DP paragraphs** telling about this, please provide its location!


Has Little Endian won?

When teaching recently about the Big vs. Little Endian battle, a student asked whether it had been settled, and I realized I didn't know. Looking at the Wikipedia article, it seems that the most popular current OS/architecture pairs use Little Endian but that Internet Protocol specifies Big Endian for transferring numeric values in packet headers. Would that be a good summary of the current status? Do current network cards or CPUs provide hardware support for switching byte order?


What qualities does an "average" programmer have?

There's a lot of talk around this site and elsewhere about comparing the productivity of excellent programmers to "average" programmers. Likewise, there's talk of how to become a great programmer instead of an "average" one. Everyone can agree there are definitely some amazing coders out there, and lots more (very) subpar programmers. These are easy to define (designed and wrote a text editor in Assembly on a Nintendo DS over a weekend vs checks in copy-and-paste code that doesn't compile on a daily basis). But what qualities does an average coder have? This I think is important beyond just an academic discussion, such as making hiring decisions and sizing up where you are on the crappy-amazing scale. So what qualities does an "average" programmer have or should have?


What is the benefit of multiple return values

I feel as if a return statement should only return one value. When it returns multiple, things get confusing. I know since the return type in Java has to be declared, this is difficult to do, but in languages like Python it is a snap. Are multiple return values a sign of bad design or coding style? Python example                    def get_name():        # you code        return first_name, last_name


Should I structure my DBs based on the data's true form, or how I plan to use that data?

This is mostly a hypothetical question, but it's something I've been tossing around and I wondered what other people though. Here's a contrived example to illustrate: Let's say I'm building an app that lets users pick a few keywords and then shows them photos that are tagged with those keywords. On one hand, I could create `user`, `keyword` and `photo` tables which store the data entities as they exist. This would let allow me to easily change the function of the app without needing to change the underlying data structures, but it also requires several queries to fetch the data I need for the app. Or, I could just have a single `user-photos` table, and somehow stuff all the data in there. This would make it easier to pull the data I need for the app, but it would be harder to perform any other type of querying on that data. After all, a `user-photo` isn't really a _thing_ \-- it's just a convenient data structure for this one purpose. This might be a bad example, but the main thrust of my question is: should your database structure be based on the actual underlying entities they're storing, or can you use shortcuts to make it easier to use the data for your purposes?


Time complexity implications when designing shell scripts for large data/high number of files?

There are many questions about the performance of commands or scripts on the _U+L_ SE asset. As time is of the essence, this is often evaluated using the `bash` time _reserved word_ or the external `time` command and a subset of the target data, under average or no load. Yet there are scenarios which are either about a large number of files or just operations on very big files. In some instances a careful examination of what happens in the shell, intricate knowledge of command behavior, even hardware considerations, provide insight into efficiency. But benchmarking remains no simple affair. In one instance recently a community member made a comment about the _time complexity_ of a command, implying that since there was no _sorting operation_ \- and not merely no `sort` command - it would ultimately scale better with more data. The solution involved `awk`, whereas another solution involved for instance a combination of the `grep`, `sort` and `head` commands.   * Is this just an instance of "the simpler the better" - what are main implications of _time complexity_ when designing shell scripts which operate on huge data sets(number or size)?    * Beyond common sense and _sorting_ (an operation for which there is a seemingly high level of intuition about performance costs, even for a non expert), is there a well known _common time complexity_ example which would showcase how the concepts apply in practice to shell scripting?


Is Java instanceof operator considered reflection, and what defines reflection?

I had a discussion with a coworker today, whether usage of using the Java operator `instanceof` is a kind of reflection. And the discussion quickly evolved into what actually defines reflection. **So, what is the definition of reflection?** **And is the usage of`instanceof` considered "using reflection" ?** And in addition, if `instanceof` is considered reflection, then is polymorphism not also "using reflection"? If not, what is the difference?


How do you write unit test cases?

Sometimes I end up writing unit test cases for the code other developers have written .There are occasions when I really didn't know what the developer was trying to do (the business part) and just manipulated the test case to get the green line . Are these things normal in the industry ? What is the normal trend ? Are the developers who wrote the code supposed to write the unit test cases ?


Is there a name for a testing method where you compare a set of very different designs?

"A/B testing" is defined as "a method of marketing testing by which a baseline control sample is compared to a variety of single-variable test samples in order to improve response rates". The point here, of course, is to know which small single-variable changes are more optimal, with the goal of finding the local optimum. However, one can also envision a somewhat related but different scenario for testing the response rate of major re-designs: take a baseline control design, take one or more completely different designs, and run test samples on those redesigns to compare response rates. As a practical but contrived example, imagine testing a set of designs for the same website, one being minimalist "googly" design, one being cluttered "Amazony" design, and one being an artsy "designy" design (e.g. maximum use of design elements unlike Google but minimal simultaneously presented information, like Google but unlike Amazon) **Is there an official name for such testing?** It's definitely not A/B testing, since the main component of it (finding local optimum by testing single-variable small changes that can be attributed to response shift) is not present. This is more about trying to compare a set of local optimums, and compare to see which one works better as a global optimum. It's not a multivriable, A/B/N or any other such testing since you don't really have specific variables that can be attributed, just different designs.


vim (or other text editor) ability as a metric for potential tech job candidates

Not sure if this is a "subjective" question or not. I'm thinking about hiring a mid level java programmer and came to the realisation that all the competent programmers that I've worked with had a very strong knowledge of their chosen editor. My chosen editor is vim (sometimes I use it as a plugin in IntelliJ IDEA). So in the case that someone puts that they use vim to program with I was considering giving them a couple of quick tasks to see how they go about it. Something that you could do in varying different ways. For example today I had a xml file with placeholder strings of the form               <?xml version="1.0"?>     <root-element>        ....xml....        ${placeholder.here} some text ${placeholder.there}         and some more text ${placeholder.everywhere}        ....xml....     </root-element>      and wanted to convert it into a string that I could then paste as a java string array literal, sorted alphabetically. e.g.               ["placeholder.everywhere", "placeholder.here", "placeholder.there"]      Has anyone used this kind or metric in their interview process and if so what were the results? If you did use editor ability as a metric, what editing tasks did you set? Any problems with using this as a indicator (obviously amongst other criteria) of ability?


Why has the rate of programming language popularization slowed down in recent decades?

If I understand correctly, there was a huge birth of programming languages during the early decades of computing, but then things have stabilized. Basically, why are many universities and industries still using languages such as C and C++ (which were created decades ago), when there have been plenty of decades since then to improve upon and create more effective (and human- friendly) languages?


Restrictive routing best practices for Google App Engine with python?

Say I have a simple structure:               app = webapp2.WSGIApplication([         (r'/', 'pages.login'),         (r'/profile', 'pages.profile'),         (r'/dashboard', 'pages.dash'),     ], debug=True)      Basically all pages require authentication except for the login. If visitor tries to reach a restrictive page and he isn't authorized (or lacks privileges) then he gets redirected to the login view. The question is about the routing design. Should I check the auth and ACL privs in each of the modules (`pages.profile` and `pages.dash` from example above), or just pass all requests through the single routing mechanism:               app = webapp2.WSGIApplication([         (r'/', 'pages.login'),         (r'/.+', 'router')     ], debug=True)      I'm still quite new to the GAE, but my app requires authentication as well as ACL. I'm aware that there's `login` directive on the server config level, but I don't know how it works and how I can tight it with my ACL logic and what's worse I cannot estimate time needed to get it running. Besides, it looks only to provide only 2 user groups: `admin` and `user`. In any case, that's the configuration I use:               handlers:     - url: /favicon.ico       static_files: static/favicon.ico       upload: static/favicon.ico     - url: /static/*       static_dir: static     - url: .*       script: main.app       secure: always      Or I miss something here and ACL can be set in the config file? Thanks.


Useful versioning scheme for a git project?

I have a small github project, which I need to add an option to to output some version number on the commandline. The problem is I have no idea how to "compute" the version number. Is this some random process? Should I just start at 1.0 (probably creating a tag or something), and put a number after `.` for fixes? I know this question is a bit vague... I just had never to deal with this, and want to use some sane versioning scheme. **EDIT** Im also interested into how to update this version number automatically, maybe using something like a git hook.


Best advice for game programmer who wants to go indie?

So. I'm working right now as an intern in a mobile game development company. I've used Unity quite a lot for 1 year now but, that's about all the experience I have with game design/development. Here's the things. I wanna go indie, the main reason is for fun, I really enjoy games and by making indie games I believe I can let my imagination fly and make personal personal stuff. Unfortunately I...I just don't know where to start! I'm interestes in making mobile and web games so what...should I download Stencyl? Construct 2?...XCODE for iOS, maybe a great plugin for Unity would be fine? What whould be your single best advice for someone like me? (programmer and interestes in design) :)


Efficient Data Structure for holding a graph

Problem Link - http://opc.iarcs.org.in/index.php/problems/NUMTRIPLE In my opinion, the problem can be solved by a data structure, that shows how each number is connected to another, and via recursion find the smallest possible value. But my question is, what data structure (most efficient) can hold/represent such data? Also, is there a better (faster) way of solving this problem. Thanks


What makes for "good style" in Java?

I had asked this question on Stackoverflow, and before it got booed off, I received the helpful suggestion from Péter Török that this might be a better place to post it. I've been programming in Java for a few years. I've often discussed design decisions with colleagues on the basis of what constitutes 'good style'. Indeed, there are a number of StackOverflow questions/answers that discuss a design on the basis of whether something is 'good style'. But what makes 'good style'? Like many things, I know it when I see it... but I wanted to have better idea than just my conscience saying that this design doesn't feel right. What are the things you think about in order to produce good, well designed code? (I acknowledge that this is somewhat subjective, as what is 'good style' will depend on the task at hand). (Also, I should add that I'm not interested in team styles - e.g. "we use indents of 2 spaces rather than 4"..., and I'm not interested in the Java code conventions.) Edit: thanks for all the good answers/comments so far. I'm especially keen for answers that would help codify those things that make a programmer's conscience (and possibly stomach) wrench?


Is there a GPL-compatible software license for libraries which allows static linking, but requires redistribution of library source code?

I'm looking for an existing library license which satisfies the following conditions:   * GPL-compatible   * Can be statically linked with closed-source programs   * Binary modifications of the library, including cases where the library is statically linked with another project, must be accompanied by the library source code Licenses which are close but not quite what I need:   * LPGL \- does not allow static linking with non-free software*   * Eclipse Public License \- not GPL-compatible due to a patent clause   * GPL linking exception \- does not require source code redistribution *: The LGPL allows static linking with some specific technical conditions - specifically, it must be possible to make modifications or use newer versions of the library, and to do that one would need to make available the object files and build scripts for the non-free components. Generally speaking, this is technically difficult and sometimes impossible (in the case of e.g. templates or inlined functions), and very often (as is my case) the underlying reasons for which static linking is required conflict with these LGPL requirements. For this reason, LGPL is unsuitable for my use case, and frankly I've yet to see a project which used static linking with an LGPL library in this manner, considering all the associated technical and legal (templates/macros/inlining) problems.


How to get started in coding for JBoss

I have an idea on how to revamp our internal application, after having accessed the needs of the users, addressing thier current issues, and the like. But I am not a coder. My last application I wrote was in college, in C, (java wasn't invented-ish!) and it was a booking system, with the option to add on other modules, blah blah. I got an A, but I became a system administrator instead, more intrested in designing and maintainend networks and infrastructure, but with the advent of virtualisation, and linux management tools such as puppet I can now manage infrastructure in my sleep! Now I want to write code - to put on my infastructure, and I want to build .... a booking system! This is just to get experience, but I am at a loss as to where to start. Setting up the environment, will take me about a day. Writing the spec, even how I want it to work, I already know, but as for actually coding in a decent manner, I can only guess. If anyone can recommend a book, website, blog, twitter person to follow, or just advice on how to build a kick butt basic jboss app, then please, "I AM READY TO LEARN" :)


How to avoid being sued for your software?

I have a written a small app as a research project that uses open source libraries. It can do packet sniffing, network scanning and man in the middle attacks on wifi and lan. This software is intended to be used for security auditing. But users can also use it to circumvent the MAC filtering of their ISP and get free internet. The case seems similar to that of uTorrent. uTorrent can be used legally, but almost everyone uses it for illegal downloading. If users download my software and use it like that, can the ISP sue me as the author of the software? What should I put into the Terms and Conditions to avoid being sued for misuse of my software? **EDIT**   I'm from Eastern Europe, but live in the UK. In which country should I ask a lawyer? People can download my software globally.


What are the most important points of interface between a web developer and IT?

Some background: My current job has be as the sole web developer for our company. I have been given responsibility for a number of external websites, as well as our internal intranet site. The external sites are currently hosted externally, and either created/maintained with a CMS, or custom designed by the external host. I will be migrating the websites to our own internal server, and redesigning them using whatever tools I deem necessary (php, jquery, MySQL, etc.). The intranet is hosted internally, but also needs a complete redesign. Our IT is currently going through some reorganization, and historically has little experience with web technology. I want to plan coordination with them, help develop proper infrastructure, and identify the primary channels of communication between us. My question is: what are the main points of coordination that normally exist between development and IT, focusing on web-based development? Given a (relatively) blank slate, what would be the ideal division of responsibilities, and primary points of direct collaboration? I know some aspects of my particular situation may be atypical (i.e. I'll be responsible for setting up the PHP environments, source control repositories, database administration, etc.), but I'd like answers to focus more on the typical configurations, as that will be more useful to others.


What are good approaches to cleaning up old projects?

I've got some software that I wrote around 2 years ago and needs some features added to it. I've realised that it's in an awful mess, and I have the urge to move everything around, tidy up, etc. I've read the Joel on Software article about not starting again, so whats the best way forward?


C++ Without Source Files

Bjarne Stroustrup mentions in his book "The C++ Programming Language, 4th Edition" that not all C++ implementations use files to store and compile code: > There are systems that do not store, compile, and present C++ programs to > the programmer as sets of files. (Chapter 15, page 419) Later in the chapter, he reiterates that certain implementations do not use files but he does not give any examples. How would such an environment function compared to a more common file-based environment?


Why do we need a format for binary executable files

When binary files (i.e. executables) are saved they usually have a format (e.g. ELF or .out) where we have a header containing pointers to where data or code is stored inside the file. But why don't we store the binary files directly in the form of sequence of machine instructions.   Why do we need to store data separately from the code?   Secondly when the assembler creates a binary file is the file is among the above formats?


Right design pattern to use StopWatch class

I have to measure execution time for a blocks of code. I had implemented simple `StopWatch` class like http://www.goldb.org/stopwatchjava.html. If I will invoke methods of `StopWatch` class directly between business logic then my source code became unreadable and unclean. What design pattern can be useful in my situation to keep code readable and clean?


Why should I use JAX-RS REST instead of normal servlets?

I'm teaching myself J2EE technologies using Glassfish as my webserver and EJB container. I'm very interested in learning REST as well, and developing an application that is adherent to the rules of REST. My first project is to write a chat client. The user will go to a webpage, download a webpage with the javascript to run the chat client (which posts the data to the server and fetches it as well). The calls to post data, and to fetch data, from the webserver will be through a RESTful interface. Right now I've done this through servlets that listen on the /chatroom/getMessages and /chatroom/postMessage URI's. The wrinkle that I run into when I try to convert this to a RESTful service using JAX-RS that doesn't use servlets is that I feel like I'm reinventing the wheel. With the servlet specification I had this HTTPSession object that made it very easy to keep track of where someone is in the chat buffer (and therefore which messages should be sent to them when they visit /chatroom/getMessages). But now when I make it completely RESTful, and just use POJOs with JAX-RS (which I actually like better from a style standpoint) I now have to reinvent session state if I want it by handing the person a token, and having them hand it back to me every time we talk just like the automagically generated session cookie would have done for me if I was using servlets. WHY should I implement this with JAX-RS and abandon the servlets? I haven't seen any JAX-RS tutorials that mix servlets and JAX-RS (probably for good reason), so this doesn't seem to be an option. What I really want to know is what compelling reasons there are for going with REST. What does it buy me to not just use the servlets in a RESTful way?


In an MVC system, where should the database persistence code sit?

I've seen multiple configurations for persisting information to the database. Generally, three types of designs seem common in my corner of the world:   * Controller manages the persistence    * Model manages the persistence   * Third party library manages the persistence, usually requiring some sort of annotations on the model. I'm wondering which configuration (if any) is, conceptually, the easiest to use/most compatible with an MVC architecture? (If it's not one I listed, please give a quick outline/overview as part of the answer)


Find feature in NetBeans (or even Eclipse, or others) excluding comments

Is it possible to use the find feauture in NetBeans or other Java IDE excluding commented code from the results? How?? Given a project I'd like to find all the occurrences of a word without getting back possible matches that come from code that is commented. Am I the only one that needs something like this?


Should MVVM ViewModel inject an HTML template for default view?

I'm working on web application design that includes Knockout.js and have an overall MVVM question: Does it make sense for the ViewModel to automatically inject a default HTML template (pulled from separate file)? More detail: suppose I have a site like this...               header...         widget 1         widget 2         widget 3     footer      ...and widgets 1/2/3 are going to be Knockout.js ViewModels **determined at runtime** from an overall list of available widgets, each with associated HTML template file. I understand that in MVVM you want the view (HTML template in this case) to be separate from the ViewModel (Javascript file in this case) so that people can edit it separately and possibly provide multiple templates for different "skins". However, it seems like it would also make sense for the ViewModel to point to a **default** html template that gets automatically used unless the controlling code provides a different one. Am I looking at this correctly? As an example, see this answer on StackOverflow where he recommends injecting the HTML and then the ViewModel. Seems like a one-liner would make more sense in that case, with the possibility of overriding a default template value.


Is CType() ever the preferred option?

Is there any time `CType()` is the proper option over other methods? I did plenty of thinking on this myself, but wanted to put the question in hopes there would be answer to my question so I can put the question to rest in my workplace. My idea is that `CType()` should never be used. But others seem to think it's still around for something other than backward-compatibility. So is there still a use for it? A big problem is that many people don't seem to understand the difference between Casting and Converting. ## Converting Vs Casting This was one such line of code:               With objZipFile.GetEnumerator()         While .MoveNext             objZipEntry = CType(.Current, ZipEntry)             … all this work is done with the objZipEntry         End While     End With      If my buddy ever reads this, he'll be like, "MY CODE!!!!" lol. Yes, this is your code. And as I discussed with him, .Current is an enumeration of objZipFile, but its type is ZipEntry. So why is he "Converting" with `CType()`, when what he's really doing here is Casting. He should be using `DirectCast(.Current, ZipEntry)`. So the proper way to Cast something is to use `DirectCast()`. But this isn't a discussion about `DirectCast()`. The point here is that `CType()` Should certainly not be used to Cast, it's a Conversion tool, so let's talk more about Converting. ## To CType() or Not To CType(), I don't think so In the simplistic example, I have a string `"123"`, and I want the string to be converted to an Integer. So many times, you see something like this:               Dim result as Integer = 0     result = CType("123", Integer)      Great! It Works! Then what is the difference between that and this:               Dim result as Integer = 0     result = Integer.Parse("123")      Well, with that exact example, the difference is that `CType()` took more resources to run. If I gave you two clear drinks and told you one had a health rating of 10, and the other of 9. You don't choose the 9 on principle that it isn't that much less healthy, you choose the dam 10. Also, the `Integer.Parse` line is a couple characters of less typing. Okay, but what if your input isn't "123"? What if the input is "UrMom"? I hear `CType()` won't break... but as far as I know, that isn't true. `CType()` breaks just as much as `Type.Parse()`. I'd like some arguments on that. Though an argument supporting `CType()`'s resilience alone isn't reason enough to use `CType()`. On the other hand, we have this option in the `Type`-Class:               Dim MyInt As Integer = 0     Dim TryInt As Integer = 0     If Integer.TryParse("54", TryInt) Then         MyInt = TryInt      Else         'Handle it appropriately      End If      Not only are we parsing the data, but if it doesn't parse, we are handling it correctly. Which is a much better option that throwing a `Try/Catch` around bad code and letting it break before handling its failure in the `Catch/Finally`. Keep in mind, there may be multiple different ways to cast and convert, but the main purpose of this question is to prove or disprove that `CType()` simply shouldn't be used. My main argument is this... The only arguments I've seen that support the use of `CType()` are those that say `CType()` won't break if passed bad data, or that `CType()` is better if you are unsure of the data going in. In response to that I say Pish-Posh. Rethink your code, place conditionals, and know what you're wanting to use the item for. If something happens that you weren't expecting, handle it correctly. So is there any time `CType()` is the proper option over other methods? Please provide examples.


Partial GPL 2 legacy code into a GPL 3 project

I plan to import works from a Java GPL2 project into a GPL3 one.   1. How must I "head" all my project derivating sources files : must I put the GPL2 license of the original project (saying that "This file is part of PROJECT_NAME ...") above my project one ?   2. How should be the LICENSING file of the whole projet : must I put both licenses in it ?   3. I don't know yet if I will import nearly complete classes or just some pieces of codes from the original project. Anyway, how should I inform the user (saying, in a about dialog) : is saying "Work derivated from PROJECT_NAME project" enough ? Thanks in advance.


Fun resources for learning Java

Is there a fun way to learn Java? Instead of what's the "best" way to learn it, I'm wondering the funnest way to learn it. I'm taking an introductory course on programming right now to see what it's all about, but quite frankly it's not very enjoyable. I certainly love programming in an applicable sense (for accomplishing layout and analytics tasks), I find that it takes a while to get to the point (it took me a year with JavaScript) to feel like you can just dream things up and try them out. I realize the subjectivity of the questions avails it to flames, etc., so I'll restate the spirity of the question. I want to know what resources/methods people have employed to make learning a programming language more enjoyable.


Entity Framework designer not effective anymore

At my current workplace, **Entity Framework 5** is used for all data access/manipulation. It is a database-first approach using the model designer to add/edit/delete/update entities. **Problem** We now have tons of tables and this is becoming a nightmare to update. The model is very convoluted and it can sometimes crash the IDE. I'm not super clued up on the Entity Framework side of things, but surely this isn't the recommended approach. I have never liked the designer from the beginning. WYSIWYG-like designers spell trouble in my eyes. **Solution?** Structural changes to the database are essentially done by DBAdmins so we can't do code-first (anyway, I prefer not to have database tables generated). Is there a better approach to this? Shouldn't we be using an XML-based mapper instead of using the designer. What about code-first to the existing database?


Is there a de facto standard documentor for Javascript?

I'm trying to document my code using JSDOC3, that has a similar syntax to PHPDocumentator / Apigen. But is there a de-facto standard for Javascript inline documentation? I think Google Closure is the most complete (or so it seems), but what is widely adopted by IDEs and what most people expect to the docs to be?


Passing configuration to a handler

I'm building my own JET Parser and one of the things I am trying to do as per the JET specifications is to allow changing of the start and end tags from the default `<%` and `%>`. Right now I have a parser handler modeled after `javax.xml.parsers.SAXParser` and `org.xml.sax.ext.DefaultHandler2`. The handler can take handle a directive that will change the parser configuration. So I am thinking of the following options:   * have a `setParser(Parser)` method that gets called by the handler and have that as part of the interface. The method is called by the Parser when starting the parse process.   * have a `directive(..., Parser )` method that gets called by the handler and have that as part of the interface. This limits the parser updates to directives only.   * store the startTag and endTag in the handler and have the get methods.   * have a new configuration class that gets passed around using the set or directive method. My current thinking is to have a `directive(..., ParserConfiguration )` method that gets called by the handler and have that as part of the interface. This limits the parser updates to directives only and only let it deal with configuration. Is the approach I have chosen is a good option for an API, or is there a better alternative that I didn't think of yet?


Is the "Objects First" approach a good idea?

Do you think programming novices should learn objects from day 1, as seen in the book "Objects First With Java: A Practical Introduction Using BlueJ" by David Barnes? Or do you think this is a bad idea? For those unfamiliar with the book, here is a list of the topics discussed in the chapters: > Chapter 1 deals with the most fundamental concepts of object-orientation: > objects, classes and methods. It gives a solid, hands-on introduction to > these concepts without going into the details of Java syntax. It also gives > a first look at some source code. We do this by using an example of > graphical shapes which can be interactively drawn, and a second example of a > simple laboratory class enrolment system. > > Chapter 2 opens up class definitions and investigates how Java source code > is written to create behavior of objects. We discuss how to define fields > and implement methods. Here, we also introduce the first types of > statements. The main example is an implementation of a ticket machine. We > also look back to the laboratory class example from chapter 1 to investigate > that a bit further. > > Chapter 3 then enlarges the picture to discuss interaction of multiple > objects. We see how objects can collaborate by invoking each other's methods > to perform a common task. We also discuss how one object can create other > objects. A digital alarm clock display is discussed that uses two number > display objects to show hours and minutes. As a second major example, we > examine a simulation of an email system in which messages can be sent > between mail clients. > > In Chapter 4, we continue by building more extensive structures of objects. > Most importantly, we start using collections of objects. We implement an > electronic notebook and an auction system to introduce collections. At the > same time, we discuss iterations over collection and have a first look at > loops. The first collection being used is an ArrayList. In the second half > of the chapter we introduce arrays as a special form of a collection, and > the for loop as another form of a loop. We discuss an implementation of a > web log analyzer as an example for array use. > > Chapter 5 deals with libraries and interfaces. We introduce the Java > standard library and discuss some important library classes. More > importantly, we explain how to read and understand the library > documentation. The importance of writing documentation in software > development projects is discussed, and we end by practicing how to write > suitable documentation for our own classes. Random, Set and Map are examples > of classes that we encounter in this chapter. We implement an Eliza-like > dialogue system and a graphical simulation of a bouncing ball to apply these > classes. > > Chapter 6, titled Well-behaved objects, deals with a whole group of issues > connected to producing correct, understandable, and maintainable classes. It > covers issues ranging from writing clear, understandable code - including > style and commenting - to testing and debugging. Test strategies are > introduced and a number of debugging methods are discussed in detail. We use > an example of a diary for appointment scheduling and an implementation of an > electronic calculator to discuss these topics. > > In Chapter 7, we discuss more formally the issues of dividing a problem > domain into classes for implementation. We introduce issues of designing > classes well, including concepts such as responsibility-driven design, > coupling, cohesion, and refactoring. An interactive, text-based, adventure > game (World of Zuul) is used for this discussion. We go through several > iterations of improving the internal class structure of the game and > extending its functionality, and end with a long list of proposals for > extensions that may be done as student projects. > > Chapters 8 and 9 introduce inheritance and polymorphism with many of the > related detailed issues. We discuss a simple database of CDs and videos to > illustrate the concepts. Issues of code inheritance, subtyping, polymorphic > method calls and overriding are discussed in detail. > > In Chapter 10 we implement a predator/prey simulation. This serves to > discuss additional abstraction mechanisms based on inheritance, namely > interfaces and abstract classes. > > Chapter 11 introduces two new examples: an image viewer and a sound player. > Both examples serve to discuss how to build graphical user interfaces > (GUIs). > > Chapter 12 then picks up the difficult issue of how to deal with errors. > Several possible problems and solutions are discussed, and Java's exception > handling mechanism is discussed in detail. We extend and improve an address > book application to illustrate the concepts. > > Chapter 13 steps back to discuss in more detail the next level of > abstraction: how to structure a vaguely described problem into classes and > methods. In previous chapters we have assumed that large parts of the > application structure already exist, and we have made improvements. Now it > is time to discuss how we can get started from a clean slate. This involves > detailed discussion of what the classes should be that implement our > application, how they interact, and how responsibilities should be > distributed. We use class-responsibilities-collaborators (CRC) cards to > approach this problem, while designing a cinema booking system. > > In Chapter 14, we try to bring everything together and integrate many topics > from the previous chapters of the book. It is a complete case study, > starting with the application design, through design of the class > interfaces, down to discussing many important functional and non-functional > characteristics and implementation details. Topics discussed in earlier > chapters (such as reliability, data structures, class design, testing, > extendibility, etc.) are applied again in a new context.


File shredder algorithm

As a part of learning system programming, I am looking to implement a file shredder. The simplest way (and probably seen as naive) would be to replace the data bytes with zeroes (I know OS splits the files and I'll replace bytes in all those chunks). But when I google on this topic, I am surprised to find multiple pass algorithms, some going as high as 35! Could someone elucidate the benefit of multiple pass please? I couldn't find any explanation. Thanks


Is there an equivalent of mod_rewrite for Twisted web?

I've been programming in PHP for a long time, and I've just recently decided to make the switch to Python. Of all the Python web frameworks, I settled on Twisted Web to build the framework of my startup. However (and I know it sounds nitpicky), mod_rewrite was something that I really appreciated about Apache. I want the entire system written in Python, and not just bits and pieces written in PHP and Python: while a PHP frontend could work, I'd avoid it if it was at all possible. Is it possible to build such an application without resorting to ugly urls? Note: I am aware of the fact that Django allows URL rewriting, but it kinda defeats the purpose of using Twisted by itself.


Any recommendations for setup/teardown of browser automation testing?

I have been doing some browser automation testing recently using Selenium (and Watin a bit too) and have reached a point where I am looking for recommendations on controlling the environment I'm testing. For example, if I have a test that registers a new user on site (or similar database dependent task); how do people ensure that the test does not persist or at least is able to be repeated without always changing the test itself? I'm seeking recommendations for ensuring my integration/acceptance tests using Selenium can be ran without having to worry about changing them or the environment manually.


Am I using Factory and Impl classes properly?

In my 2d destruction derby simulator I have a CargoTruck class and CargoTruckImpl that implement an interface called Truck. CargoTruck has a reference to CargoTruckImpl which is returned through the CargoTruckImplFactory. But then I decided to add to this chain by having CargoTruckImpl and CargoTruckMovementImpl use the interface called Movement. CargoTruckImpl has a reference to CargoTruckMovementImpl which is returned back to CargoTruck through the MovementImplFactory. CargoTruck->CargoTruckImpl->CargoTruckMovmentImpl FuelTruck->FuelTruckImpl->FuelTruckMovmentImpl Is adding to the chain like this bad? Am I violating the Separation Principle or the Open-Closed Principle by using Factory classes this way? Is there a better way of doing this?


What kind of users stories should be written in the initial stages of a project?

When just starting a project, you have nothing---no UI, no data layer, nothing in between. Thus, a single story like "users should be able to view their foos" will entail a lot of work. Once you have that story, one like "users should be able to edit their foos" is more realistic, but that first story will involve setting up a UI layer, a presentation logic layer, a domain logic layer, and a data access layer. This doesn't fit with my concept of "tasks": to me, I'd rather have something like the following "tasks":   * Show dummy data for a user's foos in HTML, derived from JavaScript objects.   * Set up a presentation logic layer, and connect the JavaScript objects to it.   * Set up a domain logic layer, and connect the presentation logic layer to it.   * Set up a data access layer, and connection the domain logic layer to it. Do all of these fall under the single "story" above? If so, I feel like stories are not a terribly useful framework in the early stages of a project. If so, that's fine---I just want to make sure I'm not missing something, since I'm really trying to learn this agile methodology as best I can.


Switch form paragraph mode to line break mode in WYSIWYG editor because of client request?

I'm building a website fro a client which uses TinyMCE as the main WYSIWYG editor. Now my client asked if it is possible to write a line and make a line break and then continue without leaving a space between the text before and after the line break (e.g. just like in word). I told him that the web uses paragraph for formatting and not line breaks. Still he'd like to use line breaks for formatting. Should I convince him not to use line breaks for formatting or should I just switch TinyMCE to line break mode (which the is not recommended in the TinyMCE documentation).


Is OpenGL after C++ job oriented?

First, my regards to all programmers out there who have put their endless efforts in learning and becoming expert, wise, efficient and best. Let me describe my situation. I have just graduated from Electronics and Communication Stream. Though I have more interest in software development and hence I have opted to become a software developer rather than Electronics engg.   1. I have learned C++ and wish to wish to go more deep.   2. I have started to learn OpenGL. Guide me in the following:   1. Is OpenGL good to learn and is it job oriented?   2. Should I learn some other language rather then OpenGL after C++?


How to ask the boss to pay for qualifications?

I'm working as a junior developer for a startup company, and have been working here around 7 months now. After 4 months, we had a late quarterly review, and just before the boss mentioned there was a training budget, and we should let them know what training we needed and they'd get it for us. I asked for some training at the time, but 3 months have passed without mention of it, and I have since learnt what I needed in my own time (I just can't stop learning new things!) I took on a new role recently, so have been given some cheap ($60) training for that however. Now the next review is approaching, and I would like to get Adobe Qualified Expert qualifications for ActionScript 3 / Flex. I was told by a contracted co-worker who had left that I should try to get the company to pay for this, as it's something they can tell potential investors as a selling point. My question is though; how do I approach this with my boss? I don't want it to sound like I'm looking for another job and want the qualifications to look elsewhere! Edit: I should mention the company I work for is very qualification-light at the moment, and all the flex developers are junior level at the moment. I'm looking to progress which is why I want the qualifications. Even if I can't get them through the company then I'll be learning it myself, but would rather not stump my own cash when it's to help the company in the long run!


Looking for jobs after a project ending badly

My company just canceled the project I was working on because they were dissatisfied with how it was going. I was quite disappointed with it because I thought the project was going well and I had already explained the limitations that the software would have due to the time constraints. I have decided that I will now look for a new job, but I am worried the project ending badly may give me some difficulties. Any advice on how I can minimise the difficulties this causes me without being dishonest?


Is it fair to ask a team to start using CoffeeScript?

I started my new job as a JS developer in November and starting implementing Backbone pretty soon after. This was a big enough learning curve for the team (me included), however I'm thinking about looking at CoffeeScript, which I'm guessing would require everyone on the team to know it? Is that too big of an ask, just to make me slightly more productive?


Is this Observer variant an improvement?

In a C++ code base I've been working on, they have a bunch of instances of the observer pattern, but it's a little different from the classical pattern. In the classic, the Observer is a specific interface with specific method(s) that are called when the Observable changes or has new data.               Observable                       Observer     register( Observer* )            update( data1, data2 ... )      In our code base, we use a template class that takes the number and type of arguments to the update() method as parameters, and allows you to specify any pointer-to-method as the recipient of the data.               Observable                               register( Functor<data1, data2> )         Is this an improvement over the original pattern? Here's what I think are the pros of each approach: Classic:   * clarity - the interface marks which classes are recipients of observable data    * less code - the boiler plate and ugly template syntax to create the functor are somewhat onerous Variant:   * flexibility - I can make any object in my system receive the update (if it has the right method signature) without having to change the original object As a another option, do I have it all wrong that this is the Observer pattern in practice?


Should a developer argue against unnecessary or harmful features?

What is a good attitude from developers when discussing new features, and namely, non critical/questionable features? Say you are developing some sort of Java like language, and the boss says: "We need pointers so that developers could fiddle with object memory directly!" Should the developer shoot down the idea because it adds unimaginable complexity and security vulnerabilities, or should he do what's asked? This may not be a good example, but what about things that are more in a gray area, like adding buttons that break workflow, or goes against internal structure of the program, etc.? What is the optimal "can do" vs. "can't do" distribution for a regular programmer? EDIT: The question is not about a bad boss :D I was more interested how do people approach new problems that add a noticeable amount of problems while maybe being marginally useful. Should the general attitude be:   1. yes we'll do it, screw the complexity   2. maybe   3. no, the general rework, and implications don't justify the change What should be the reaction of a good developer?


How should we implement Scrum with two projects for one team?

I'm starting at this new company as a scrum master, and they want to dive into Scrum, which is nice and all, but they only have enough people (4) for one team. The road map includes delivering a new product and maintaining the old one, so what should we do?   * 2 products backlogs for 1 team? How should we do planning in this case?   * 1 product backlog for 2 products? How will sprint review work in this case?


Is there any merit to using `union` to create an alias?

I've inherited a bit of code and saw something new. They have a data structure definition out in a .h file, and in various local files they'll declare:               union globalStructOstuff localVar;      **Is there any merit to this?** I could see some if the global was some placeholder and the local versions were going to be different eventually. But that's not the case here. So I think all it's doing is causing new guys a couple of extra minutes searching for definitions. I'd axe it once I got the chance, but I wanted to see if I'm missing some greater purpose. **Edit, resolution**   With your fine help, I managed to open my eyes and realize globalStructOstuff isn't a struct at all, it's a union which holds the struct of a similar name. And they didn't use typedef. So all that's happening here is declaring a local variable. It has a type of union. No alias to anything global. Sorry for the confusion, thanks for all your help.


How do you determine a 'release' date when a team uses Scrum

I'm new to scrum and using it on a project. We do 3 week iterations, estimate at the beginning and then collect the points at the end. We have a product back log (probably not complete). If you do estimates of the entire back log at the beginning aren't those estimate just 'wild ass guesses' So when do you estimate the back log and how do you determine a release date? ep


Why aren't postfix and primary expressions symmetrical?

Every primary expression is a postfix expression but a postfix expression is not primary expression. But in mathematics, equality seems to be symmetrical. That is: > If _A_ is _B_ , then _B_ is _A_ Why isn't this the case for postfix and primary expressions?


Is my concept in open source license correct?

I would like to justify whether my concept in the open source license is correct, as you know that, misunderstanding the terms may lead to a serious law sue. > The main difference among the open source license is whether the license is > copyleft. Copyleft license means allow the others to reproduce, modify and > distribute the products but the released product is bound by the same > licensing restriction. That means they have to use the same license for the > modified version. Also, the copyleft license require all the released > modified version to be free software. > > On the other hand, if any others create derived work incorporating non- > copyleft licensed code, they can choose any license for the code. The several kinds of license and comparison > GPL is a restrictive license. Software requires to released as GPL license > if that integrate or is modified from the other GPL license software . The > library used in developing GPL license software are also restricted to GPL > and LGPL , proprietary software are not allowed to employ (or complied with) > in any part of the GPL application. > > LGPL is similar to GPL , but was more permissive with regarding allow the > using of other non-GPL software. > > BSD is relatively simple license, it allow developer to do anything on the > original source code . The license holder do not hold any legal > responsibilities for their released product. > > Apache license is evolved from the BSD license. The legal terms are improved > and are written by legal professionals in a more modern way. It covers > comprehensive intellectual property ownership and liability issues. Also, are there any popular license beside these?


choosing Database and Its Design for Rails

I am having a difficulty in deciding the database & its structure. Let us say the problem is like this. For my product I have various customers( each is an educational institute) Each customer have their own sub-clients ( Institution have students) Each student record will have some basic information like "name" & "Number" . There are also additional information that a customer(institution) might want to ask sub-client(student) like "email" or "semester" I have come up with two solutions : 1\. Mysql _**__insititution_ ___** id-|- Description| * * * _**___Student__** id-|-instituition_id-|-Name-|-Number| * * * _ **_student_additional_details_ ___** student_id -|- field_name -|- Value * * * Student_additional_details will have multiple records for each student depending upon number of questions asked from institution. 2.MongoDb _**__insititution___** id-|- Description| * * * _**__Student_ ___** id-|-instituition_id-|-Name-|-Number|-otherfield1 -|- otherfield2 * * * with mongo the structure itself can be dynamic so student table seems really good in mongo . But the problem comes when I have to relate student with institution . So which one is a better design ? Or some other idea ?


What is the best method for releasing free "extension" or example code based on a closed source proprietary project?

I have a proprietary project. It's a simple authentication library. I want to write open source(BSD) extension/examples for it. These examples interface code, connecting my authentication library to a database containing users. I'm providing examples which people hardly ever use out of the box, but are excellent starting points for tying it into their own database. I want to be able to release these extensions separately from the library. What is the best way of to this? My idea is to use a free github project and put the extensions there as well as the demo version of my authentication library(ie, just the assembly). How would I manage different versions of the authentication library though? At the moment, I use SVN for managing the source code of the authentication library, though I like git as well, so would switch if that'd be better. Does anyone know of a good way of managing this kind of thing?


Variables initialization and for loops in a flowchart

I have to create a flowchart to a C# programm and I am not very familiar with it. My problem is that I do not know if one should represent variables initialization in a flowchart and if so how should I do it. Second problem is that I am not sure about the correctness of my for loop. Here is the flowchart I created tot a part of the programm. It would be very nice if you can tell me if that is correct and if not what should I correct. Thank you! ![enter image description here](http://i.stack.imgur.com/Hey0G.png)


Do I have to remove my app from app store? (Copyright infringement)

I just got an copyright infringement notice that says my app infringes on the usage policies of the services my app uses. However, this mail does not come directly from the company that runs the website I pull information from. The mail comes from a company that has some paid apps in the same category on the app store (mine is free), so they obviously want me gone. My question is, can I just ignore this mail until I hear directly from the company that runs the website? Judging from their (the company that contacted me) website, they have no connection what so ever to the company that I fetch information from.


Java API Deprecations

Who decides the API deprecations the JEE specification or the vendor of JDK like Sun, IBM?


Should I put utility methods inside a class?

I have been working on a library which contains a large set of functions. For the sake of simplicity, I am going to use just one set as an example. I am not sure which is the better way, in terms of ease of use and performance, whether I should put those methods provided as individual methods, prepended with the function category, or whether it is better to create a Class containing all the method as static methods. For Example: Individual methods: (p.s. this could also be writen without `request_` in the function name and using Namespaces instead)               function request_method() { ... }     function request_url() { ... }     function request_useragent() { ... }     ....      Classed method:               class Request {         public static function method() { ... }         public static function url() { ... }         public static function useragent() { ... }         ...     }


Implementing Scheduling Within an Application

I'm building an app and the end user will be using an Admin screen to schedule content on the front page. They will be choosing two dates, a start date and an end date. Obviously I don't want to cycle through the entire collection to see if todays date is between any of the start or end dates every time the front page loads. Also, don't want the user to be able to schedule two things that overlap each other. There should be a better way than checking for conflicts with each record before saving. Using Node/Socketio/Express/Mongoose I could index the collection in Mongo then sort accordingly to test for today's date and make sure there aren't conflicting schedules. Also, I could have a flag that is set once the day changes that signifies current content. I thought there might be a better way. Does anyone have any thoughts?


Frustration with Java Swing layout managers

I have been trying for years to master Swing layout managers with no success. Every time I need to do something with Swing, it is like pulling nails to get the visual components to line up the way I want them to. I am familiar with frameworks like Matisse but that's not the point. My question is: Why does Swing even need layout managers? It seems like an overcomlicated paradigm. What I would like to be able to do is jave a simple JFrame and then for each component (like JLabel) simply specify X and Y coordinates where I want it to be situated -- done deal. Can anybody explain what is wrong with this simple approach that would work predictably 100% of times? Or is there an actual layout manager that does things exactly like this?


In JSF where do objects like PhaseListeners fit in the MVC pattern?

When it comes to JSF, I've had trouble distinguishing where certain objects I create fit into the overall MVC pattern. The View is simple enough since that's handled by the .xhtml template but when it comes to objects like:   * Action/Change Listeners   * PhaseListeners   * Validators   * Navigation Beans   * Converters   * Filters At first I'd assume some of these belong to the Controller but I've seen a number of statements here and elsewhere on the web stating that for most developers using an MVC framework, specifically JSF, the majority/entirety of the Controller is already implemented by the framework. The following Q&A: Understanding JSF as a MVC framework , while very informative still leaves me feeling pretty vague on the matter. The accepted answer states that consumers of JSF do not implement Controllers while the thesis linked to at the bottom of the answer clearly states that Listeners are a part of the Controller pattern.


Should I use Legitimate Email spoofing?

Recently I receive a request: users' emails are stored in the database, and as request of a user, the system will send an email on their behalves. To add more context, it's like sending an email from the vendor, to their customers' email addresses. But it's not a fixed email (it depends on which vendor ask the system). Using JavaMail, I can simply set the `from` field. But something doesn't seem right. When searching for this kind of work, I come across "Email spoofing" - which looks like what I'm going to do. There are some drawbacks for this approach, such as it may make the emails attractive to the spam filters, and so on... Ofcourse I can just do as the client want, but I just wonder, is there any better alternative?


Sequence diagrams and the Implementation

In the design phase we create UML Sequence diagrams (in OOD). My understanding is that after creating an Use Case diagram if we need to show further information in terms of time sequence of events of that Use Case, we can go for sequence diagrams. My question is, should a sequence diagram represent exact implementation details? If I ask in another way, should all method calls and object interactions in the implementation be shown in the Sequence Diagram? Or else it should present a high level picture of the implementation? Normally in the implementation, things could be implemented with slight differences than specified in design diagrams. So that if a sequence diagram should show exact implementation details, we might have to revise them after the implementation. Another related question would be, who are the audiences of these sequence diagrams other than the author? An answer for this question might answer the original question as well.


What's the best way for me to get started using version control in an opensource project?

It was suggested that I take my project open source due to its size and my lack of skills, so I checked out Google Code, and started making a project and now it's asking me if I want the project to have Git, Mercurial, or Subversion code hosting. I don't even know what code hosting is, and a search just confused me more with the debates between all these things, and this is made even worse as Google Code is asking me which type of license I want. I think I'm not quite understanding what open source really means, can someone pretty much make a quick layman's cheat sheet on what all this is? Much appreciated. **Edit** There have been a lot of great responses on these three versions of code hosting, but I think I failed to communicate the real question: Basically I've no idea how this open source stuff works, why would I host the code somewhere like this? And would that mean I have to take the site off of my current hosting, or is this an entirely different type of hosting? What happens when I make my site open source, what rights do I have, what rights do I give away. How does it work, do people just come and throw code at me for free? Perhaps these are stupid questions, and if that's the case then I guess I need stupid answers, I seriously have no idea what open source is, except for the concept of sharing code...


Is short-circuit evaluation a consequence of call-by-name?

If the boolean operators &&, || are implemented as infix methods, then isn't short-circuit evaluation just a consequence of being implemented using call- by-name semantics, since, for example, the && method wouldn't then evaluate the second arg in any case if the first is false. I'm just wondering because they are generally treated as separate topics (e.g in the Scala intro course I'm taking - https://class.coursera.org/progfun-003/lecture/5 ) but short-circuit evaluation seems to just be a consequence of call-by-name.


Use MAC address for license

One of my company product need to implement a license mechanism. I'm planing to generate a key base on users PC MAC address. But I'm bit scared is this method confuse with some advance hardware. configurations such as.   * Multiple network cards.   * Virtualization.   * Mac address change possibilities(?)   * Working with VPNs. Is it a good idea to generate license key with MAC address? Some ideas?


Unit (regression) testing scientific algorithms given floating point behavior

I have been working on a project and running into a very difficult problem. The problem can be stated simply as how to unit-test numerical algorithms. However if you just took this simple statement you would get the standard set of answer isolation of input, random processes, mocking, tolerancing, etc.   The answer (if there is one) does not reside with these. Also, as a note, I am not concerned with testing the correctness of the algorithm. That is done with very different methods and it is assumed that the algorithm is correct. What I am using unit-testing for is to make sure that changes in other parts of the system/support algorithms do not change the output of the algorithm under test. So, for a description of the problem: We have an algorithm which takes Gigabits of data, processing it, and generates an image with a corresponding map of which pixels are good and which ones are not. It is this map which I need to verify does not change and pixels which are not valid are not to be used in any way other than the fact that they invalid. If this was all that was given I would have many possible solutions and in fact the method have been using for years is to look at the number of valid pixels, the average, standard deviation, peak and valley of the image. This has proven very sensitive detector for changes. But, this year has added complications which is causing issues with this approach.   * The number of threads being used has increased causing changes in the floating point behavior. In the past the smaller number of thread was accounted for in the tolerances used.   * We have been using floating point (as compared to double) to increase throughput. This has caused the rounding behavior to change even more and combined with the number of threads makes it worse. This has also been made worse as we move to using SIMD processing like GPU and/or AVX instructions sets.   * We have been enhancing the algorithms used to recover more of the pixels which would have been marked as invalid in the past are not valid. This combined with 1 and 2 above is resulting in some pixels being included on some machine and not on others. Since these are on the edge of useability these difference are handled by the algorithms with use this image and are not of concern for the system as a whole, but are causing problems with unit testing the algorithms.   * We have also recently ran into the problem that two numbers (internal to the calculation) are the same and because of the rounding behavior one or the other is picked resulting in different outputs. . Again this is not a problem of the system as a whole, only with unit testing to flag for differences.   * As a minor side example, we also have other non-linear algorithms with due to rounding behavior can give different outputs. Since these algorithms are self correcting the final solution is good, but has a higher variability than easily accounted for unless the tolerances are opened larger than desired. So, my questions is how to account for these issue in unit testing.   I strongly need unit testing because we have a team of programmers working on the system and we need the ability to detect when someone makes a change which unknowingly impacts other algorithms. Yes this has happened in the past and the method being used at the time caught the change before it reached the final product. As the primary algorithm developer I can use your help. I have had many ideas, but they don’t work for all cases and it’s not clear when to use one of the different methods. **Edit:** I now that this is frequently called regression testing but I also know that many time it is also generically called unit testing by many people, even if it's not completely correct. I am not necessarily looking for a magic bullet (that would be nice) but I do need a way of handling these issues in a way which can be handled by others in the group which may not be as knowledgeable on the details. If that is a “pick” one of these methods that is fine if it the rule are clear. We do adjust the parameters when we change the algorithms, but once it is fixed the floating point behavior is still causing differences. When we see differences we always investigate why and in general we try to adjust the algorithm to reduce the difference, but there are times where these is not possible because of the additional computation time. If we stayed away from the limits this would not be an issue (as in the past) but to advance the technology we need to push the limits giving rise to the issues described. You can see this in a simple example. Calculating an average of many numbers. If you stay with number which are close to each other, there are simple methods to make sure the results are accurate. Now when you allow for numbers which have large (orders of mag) difference, with threading, float compared to double, etc you can get very different results. Yes I know there are algorithms which can be used to fix these issue but they can be very computation expensive. While averaging is not my problem you could imagine that the difference don’t impact downstream processing but you still want to write a test to monitor the calculation.


What is the best and most cost affordable solution for storing user uploaded videos and pictures?

I'm in the process of building an iOS application that will allow users to upload short videos (low res. and < 5 seconds) as well as full-size images as taken by their iOS device. Not being certain of how successful this endeavor will be I'm looking for something solid, cost affordable and can scale as (if) needed. Here are my requirements in a nutshell:   1. Users will be able to upload low res. vides < 5 sec. in length or full-sized images captured from their iOS device.   2. I need the ability to monitor the amount of storage used on a user-by-user basis for billing and even restricting further uploads if, for example, they have reached a certain threshold   3. I need something robust but cost effective (I'm a one man operation at this point). Something that can grow and scale with me would be ideal. Any help in reaching this goal is definitely appreciated. Thanks -wg


Need some advice on CLI design, I need to provide simple but powerful command line options

I am writing a utility that runs on RHEL5 command line. I need my command line options to be simple but powerful. I looked at the various UNIX utilities to get an idea of how simple command line utilities have to be. Do you guys suggest any documents/links that talk about command line etiquette? I am modelling my utility on top of LVM (that's all the info I can give for now). I know it's a software engineering question, but I thought it would be appropriate to post here. Please advise.... PS: I am not asking for details about getopt or command line utility parsers.....


Backing up messages in S3 within a Storm topology

In my project we are trying to build up a KIND-of-a-lambda storm based architecture. The component would be responsible for indexing the site usage events so we expect a quite massive random load. The solution for real-time processing of the messages seems fine, but in parallel to the "speed layer" we want to back up the messages in a raw form (just as they are coming down from the queue) in Amazon S3. Since writing a file per message is obviously out of the question, we need to somehow buffer/aggregate the messages before posting to S3 - and here is where the problems begin. We have two concurrent approaches and none seems perfect:   1. We used Redis as a buffer. Basically messages coming down from a queue (RabbitMQ) are buffered in Redis and once some preconfigured batch size (say 1000) is reached the buffer is flushed and stored to S3. The whole message proccesing cycle is not transactional. Once message is stored to Redis it is acknowledged in the queue. This means that if Redis dies the whole batch gets lost and this is not acceptable. We can think of Redis cluster to make the thing more bullet proof but... doesn't it seem like going in a wrong direction?   2. The second approach would be to use Trident Topology. Changing the input queue to Kafka makes things looking more or less straightforward. The message processing cycle can be transactional. HOWEVER, there is this one annoying keyword that keeps beeing repeated in the Trident documentation - **small batches** \- that Trident assumes small batches. For example the TransactionalTridentKafkaSpout batches the messages into 2 seconds chunks. This is much too little for us. I'm not sure why the batches should be small, but if it's really required maybe the first approach is better? Which one from above is better? Maybe somoeone would come up with a "third" idea?


How would I develop an avatar based 3D conference environment?

I want to develop a 3d environment to be used for meetings and other such functions. Each attendee could log in with a customized avatar and could collaborate and discuss via voice and text chat. I would like to add in multimedia content features as well into the environment. I need help regarding platform selection preferably I want to implement it as a web application with no local installation. I'd like to avoid a browser plug-in unless absolutely necessary. I don't know graphics programming so I'd prefer an approach that uses existing platforms and off the shelf software. I have considered the following options thus far:   * WebGL   * Google O3d   * web 3d's X3D    * VRML   * X3doom   * Sirikata Platform    * yogurt3d   * Unity3d   * Jibe   * OpenSim   * Papervision3d   * Flash   * 3dmlw   * Java3d   * Infinity3d   * Cube3   * CloudMach Are there other possibilities?


Programming concepts taken from the arts and humanities

After reading Paul Graham's essay Hackers and Painters and Joel Spolsky's Advice for Computer Science College Students, I think I've finally gotten it through my thick skull that I should not be loath to work hard in academic courses that aren't "programming" or "computer science" courses. To quote the former: > I've found that the best sources of ideas are not the other fields that have > the word "computer" in their names, but the other fields inhabited by > makers. Painting has been a much richer source of ideas than the theory of > computation. > > -- Paul Graham, "Hackers and Painters" There are certainly other, much stronger reasons to work hard in the "boring" classes. However, it'd also be neat to know that these classes may someday inspire me in programming. My question is: what are some specific examples where ideas from literature, art, humanities, philosophy, and other fields made their way into programming? In particular, ideas that weren't obviously applied the way they were meant to (like most math and domain-specific knowledge), but instead gave utterance or inspiration to a program's design and choice of names. **Good examples:**   * The term **endian** comes from _Gulliver's  Travels_ by Jonathan Swift (see here), where it refers to the trivial matter of which side people crack open their eggs.   * The terms **journal** and **transaction** refer to nearly identical concepts in both filesystem design and double-entry bookkeeping (financial accounting). `mkfs.ext2` even says:              Writing superblocks and filesystem accounting information: done      **Off-topic:**   * Learning to write English well is important, as it enables a programmer to document and evangelize his/her software, as well as appear competent to other programmers online.   * Trigonometry is used in 2D and 3D games to implement rotation and direction aspects.   * Knowing finance will come in handy if you want to write an accounting package.   * Knowing XYZ will come in handy if you want to write an XYZ package. **Arguably on-topic:**   * The Monad class in Haskell is based on a concept by the same name from category theory. Actually, Monads in Haskell are monads in the category of Haskell types and functions. Whatever that means...


How do I optimize a web application for high-latency users?

Basically, I have an application that does searches and requests results from a backend via long polling. It connects to the backend which collects results for 500 ms then sends them back to the client (I'm simplifying things here a bit of course). As we've optimized this, we've noticed a growing divide between users who search at night vs users that search during the day. Namely, users who search at night are _much_ slower than users that search during the day due to the fact that these users are mostly international and have higher latency. What are good high-level approaches to speeding things up for these users?


Hate repetition to the extreme

I program in a style that everything it's expensive or I really do hate repeating anything, mostly because I develop for embedded systems. So I get very annoyed when I **have** to do something that causes repetition. An example would be that in my current project, I am creating a Layout Manager. I had this huge function that did all the work of placing everything, which I don't mind as long as I comment well. Some point down the line I realise that something I do in that long function I need to do again somewhere else, like adjusting for something that is bigger than the current. But what got me really annoyed ( and why I'm posting ) is that the needed function requires three variables. To me those three variables are expensive and should only be computed once per call. But to refactor the code the way I need to I have to put the variables in the needed function. Now the variables gets evaluated three times. This is just an example, and things like this crop up a lot else where, so besides telling me those evaluations aren't expensive, at which point I'll say, "I'm still repeating it though", what can be done about this sort of thing, or, to my huge annoyance, is it unavoidable? _**Update:_** One of the main suggestions given is store the value. Using the example above again, storing the value does not seem viable. Mostly because the needed function takes two needed values which are used to compute the three variables. It would mean I would have to create an object, and feel free to correct me if I'm wrong, store the values and variables into the object and then test them if they had changed. In short, unless there are other ideas out there, it looks to be unavoidable. The only real thing you can do is minimise up to a limit. How deep do I create objects at the cost of property look ups? How many times to I repeatedly have to create those three variables? I hope you get the idea. There is also the fact maybe I could better refactor my code. I tend to write in huge functions and only pull out what I need, which is probably KISS's fault. I think need another acronym to balance things out :P .


Why isn't the arrow operator in C++ just an alias of *.?

In c++, the * operator can be overloaded, such as with an iterator, but the arrow (->) (.*) operator does not work with classes that overload the * operator. I imagine that the preprocessor could easily replace all instances of -> with (*left).right, and that would make iterators nicer to implement. is there a practical reason for -> to be different, or is that just a peculiarity of the language/designers?


Constraints in a relational databases - Why not remove them completely?

Is there any reason to build constraints between tables (inside SQLserver) nowadays? If so, when? Most applications in my area are built on object principles and tables are joined on demand. Demand are based on the need from the application. I won't load a bunch of constrained tables for a simple look- up, which in turn (after action) require one another simple lookup. ORM tools such EntityContext, Linq2Data, NHibernate are also handle the constraints by themselves, at least you know what tables that need each other. Doing constraints inside the server is just about making (forcing) same changes twice? This is usually not a question up for decision, but this database is designed quite different. The design looks regular good, mostly mirrored the objects used by the applications. What disturbing me is all constraints configured inside SQLserver with "not cascade". Which means that you have to play "seek and find" when coding new database queries. Some cases requires up to 10 levels of an exact order to make a single delete. This surprises me and I'm not sure how to handle it. In my simple world, that setting makes the constraints losing most of the purpose. OK if the database were accessed from hosts without knowledge of the design. How would you act in this scenario?   Why not just remove all constrains from db and keep them at application level?


What top companies look for in an Interview?

1. Basically I am looking for what is it that you goof up and you are out from the remaining process ?   2. Are elimination rounds a fair way to judge a person ? Anyone can have a bad hour :-(    3. Should you code the best possible or should you get the Algorithm right ? I generally first code a workable solution and then work on it till a level I think it looks beautiful to me. Is this a wrong approach ? Recently I had a telephonic interview in which I was asked to write a variation of Level Order traversal in 20 minutes. I could get the Algorithm and working code in 20 minutes but couldn't get the Exception handling and the coding convention right, after which I didn't hear back from them :-( All the other questions in the interview went very well this was the only thing which was 'not upto the mark'. Needless to say I like the company and will apply again but want to get it right the next time :-) Please share your experiences and valuable suggestions.


What open source POSIX compliance test suites are available?

I'm working on a small open source project, ELLCC, that uses clang/LLVM as a cross compiler for various target processors. For the runtime environment, I'm using the NetBSD libraries and porting them to target Linux and standalone systems. I want to run a POSIX compliance test suite on the code. I've found the Open POSIX Test Suite, which looks like a good start, but it hasn't been updated since 2005. I've done some preliminary testing (with gcc and ecc under Linux), and it looks like it needs a few updates for modern compilers. My questions are:   1. Does the Open POSIX Test Suite live on somewhere in a more up to date form?   2. Are there other open source alternatives?


Examples of composition in software engineering?

In programming, various terms like abstraction are mentioned quite heavily. What, however, is composition? What is a basic but effective example of composition at play to result in good quality code (good quality meaning easy to understand, short and concise, etc).


How do I grok NHibernate's QueryOver API?

I've run into the limits of what NHibernate 3.0's LINQ provider is capable of and decided it's time to learn about one of the more powerful (or at least feature-complete) options: the `QueryOver` API. The problem is, I have zero experience with `ICriteria`, and all of the tutorials I've been able to find online either:   1. Assume I'm an `ICriteria` expert and simply show me how to convert ICriteria code to the new fluent interface, or   2. Are trivial "here's how you do an inner join" examples that don't really help me _understand_ more complex concepts like projections, subqueries, requirements, or whatever other magic the API is capable of. What should I read to really **learn** about QueryOver, and how to make full use of it?