Avoiding new operator in JavaScript -- the better way

_Warning: This is a long post._ Let's keep it simple. I want to avoid having to prefix the new operator every time I call a constructor in JavaScript. This is because I tend to forget it, and my code screws up badly. The simple way around this is this...               function Make(x) {       if ( !(this instanceof arguments.callee) )       return new arguments.callee(x);            // do your stuff...     }      But, I need this to accept variable no. of arguments, like this...               m1 = Make();     m2 = Make(1,2,3);     m3 = Make('apple', 'banana');      The first immediate solution seems to be the 'apply' method like this...               function Make() {       if ( !(this instanceof arguments.callee) )         return new arguments.callee.apply(null, arguments);            // do your stuff     }      This is WRONG however -- the new object is passed to the `apply` method and NOT to our constructor `arguments.callee`. Now, I've come up with three solutions. My simple question is: which one seems best. Or, if you have a better method, tell it. **First** - use `eval()` to dynamically create JavaScript code that calls the constructor.               function Make(/* ... */) {       if ( !(this instanceof arguments.callee) ) {         // collect all the arguments         var arr = [];         for ( var i = 0; arguments[i]; i++ )           arr.push( 'arguments[' + i + ']' );              // create code         var code = 'new arguments.callee(' + arr.join(',') + ');';              // call it         return eval( code );       }            // do your stuff with variable arguments...     }      **Second** - Every object has `__proto__` property which is a 'secret' link to its prototype object. Fortunately this property is writable.               function Make(/* ... */) {       var obj = {};            // do your stuff on 'obj' just like you'd do on 'this'       // use the variable arguments here            // now do the __proto__ magic       // by 'mutating' obj to make it a different object            obj.__proto__ = arguments.callee.prototype;            // must return obj       return obj;     }      **Third** - This is something similar to second solution.               function Make(/* ... */) {       // we'll set '_construct' outside       var obj = new arguments.callee._construct();            // now do your stuff on 'obj' just like you'd do on 'this'       // use the variable arguments here            // you have to return obj       return obj;     }          // now first set the _construct property to an empty function     Make._construct = function() {};          // and then mutate the prototype of _construct     Make._construct.prototype = Make.prototype;      * * *   * `eval` solution seems clumsy and comes with all the problems of "evil eval".   * `__proto__` solution is non-standard and the "Great Browser of mIsERY" doesn't honor it.   * The third solution seems overly complicated.  But with all the above three solutions, we can do something like this, that we can't otherwise...               m1 = Make();     m2 = Make(1,2,3);     m3 = Make('apple', 'banana');          m1 instanceof Make; // true     m2 instanceof Make; // true     m3 instanceof Make; // true          Make.prototype.fire = function() {       // ...     };          m1.fire();     m2.fire();     m3.fire();      So effectively the above solutions give us "true" constructors that accept variable no. of arguments and don't require `new`. What's your take on this. **\-- UPDATE --** Some have said "just throw an error". My response is: we are doing a heavy app with 10+ constructors and I think it'd be far more wieldy if every constructor could "smartly" handle that mistake without throwing error messages on the console.


Should a RESTful API provide data for an entire form?

Let's say I have a JavaScript web application which entirely uses a RESTful API for data. Let's say this application has a data form, and let's say I'm editing a record at /product/12345. When building the form, I make a RESTful request to /product/12345 and get JSON data:               {       "id": 12345,       "name": "Some Product",       "active": true,       "sales_user_id": 27     }      _So, my form obviously may have a dropdown list for selecting a sales person. I need to populate this list._ **Where should the data come from?** What's the most common approach? Would it make sense to make it part of the /product/12345 request response?               {       "id": 12345,       "name": "Some Product",       "active": true,       "sales_user_id": 27,       "sales_users": [         {"id": 1, "name": "Anna Graham"},         {"id": 2, "name": "Dick Mussell"},         {"id": 3, "name": "Ford Parker"},         {"id": 4, "name": "Ferris Wheeler"},         {"id": 5, "name": "Jo King"}       ]     }      What about when creating a new record? Should my API also respond to GET /product/new, with the following?               {       "sales_users": [         {"id": 1, "name": "Anna Graham"},         {"id": 2, "name": "Dick Mussell"},         {"id": 3, "name": "Ford Parker"},         {"id": 4, "name": "Ferris Wheeler"},         {"id": 5, "name": "Jo King"}       ],       "categories": [         {"id": 1, "name": "Category 1"},         {"id": 2, "name": "Category 2"},         {"id": 3, "name": "Category 3"},         {"id": 4, "name": "Category 4"},         {"id": 5, "name": "Category 5"}       ],       "etc": [ ... ]     }


Right multi object dependance design

I need some help with a correct design. I have a class called `BufferManager`. The `push()` method of this class reads data from a source and pushes it to a buffer repeatedly until there is no more data left in the source. There are also consumer threads that read data from this buffer, as soon as new data arrives. There is an option to sort the data before it comes to buffer. What I do right now is that `BufferManager`, instead of pushing data to the buffer, pushes it to another "sorting" buffer and starts a sorting thread. `SorterManager` class reads the data, sorts it in files and `push()`es the sorted data into the buffer. There will be a bottleneck (I use merge sort with files) but this is something I can't avoid. This is a bad design, because both `BufferManager` and `SorterManager` push data to a buffer (that consumers read from). I think only `BufferManager` should do it. How can I design it?


Choosing language to write general library in

I'm about to start writing a library to support machine learning algorithms (decision trees, ANNs, Bayes nets, etc.), and I'm planning on making this a very general library. By this, I mean I want to be able to plug this module into as many languages as possible. To clarify, here's why I've started writing it in C++ (Windows headers):   * I know I can import C++ libraries into C#, and I've heard you can import C++ into Python. So, obviously, the library can be used in 3 languages, possibly 4 if I don't use system-specific headers.   * Is there a language where I can cover a wider spread, weighted by popularity of languages? (For example, C# and C++ have pretty high weight to me because I use both frequently, Python less so.)


Which one is the fastest Message Broker in case of a single machine?

I would like to know, which Message Broker I should choose in case of communication among apps within a single PC, considering speed. Among Apache ActiveMQ , MSMQ , RabbitMQ , OpenAMQ which one is the fastest in case of communication among multiple apps on a single PC?


Constructor should generally not call methods

I described to a colleague why a constructor calling a method can be an antipattern. example (in my rusty C++)               class C {     public :         C(int foo);         void setFoo(int foo);     private:         int foo;     }          C::C(int foo) {         setFoo(foo);     }          void C::setFoo(int foo) {         this->foo = foo     }      I would like to motivate better this fact through your additional contribute. If you have examples, book references, blog pages, or names of principles, they would be very welcome. Edit: I'm talking in general, but we are coding in python.


HTML5 PhoneGap Mobile development?

I want some suggestions about the project concepts/ideas on HTML5 PhoneGap mobile app development. I want to develop some app that can be a learning curve to get to know about these technologies. Any specific app concepts wherein I can get myself accustomed with using features like camera, geolocation, accelerometer, etc and implement those as a coherent part of the project work? Apologies if this might not be appropriate forum to ask such question. But I could not find any relevant stackexchange site for this.


Why do we need "callback functions"?

I am reading the book `programming in Lua`. It said that > Closures provide a valuable tool in many contexts. As we have seen, they are > useful as arguments to higher-order functions such as sort. Closures are > valuable for functions that build other functions too, like our newCounter > example; this mechanism allows Lua programs to incorporate sophisticated > programming techniques from the functional world. Closures are useful for > callback functions, too. A typical example here occurs when you create > buttons in a conventional GUI toolkit. Each button has a callback function > to be called when the user presses the button; you want different buttons to > do slightly different things when pressed. For instance, a digital > calculator needs ten similar buttons, one for each digit. Y ou can create > each of them with a function like this:               function digitButton (digit)       return Button{label = tostring(digit),                     action = function ()                       add_to_display(digit)                       end}     end      It seems that if I call the `digitButton`, it will return the `action` (this will create a closure), so, I can access the `digit` passed to `digitButton`. My question is that:               Why we need call back functions? what situations can I apply this to?      * * * The author said: > In this example, we assume that Button is a toolkit function that creates > new buttons; label is the button label; and action is the callback closure > to be called when the button is pressed. The callback can be called a long > time after digitButton did its task and after the local variable digit went > out of scope, but it can still access this variable. according to the author, I think a similar example is like this:               function Button(t)       -- maybe you should set the button here       return t.action -- so that you can call this later     end          function add_to_display(digit)       print ("Display the button label: " .. tostring(digit))     end          function digitButton(digit)       return Button{label = tostring(digit),                     action = function ()                                add_to_display(digit)                                end}     end          click_action = digitButton(10)     click_action()      thus, `the callback can be called a long time after digitButton did its task and after the local variable digit went out of scope.`


What is a single word I can use to describe a non-query SQL statement?

I'm trying to come up with a good name for a data access object that executes non-query SQL statements. I know DML is a valid term, but I wanted to make sure it is the best. Right now we have OracleNonQuery, but I'm hoping to find something better. **UPDATE:** OracleDML or OracleDMLStatement are good suggestions. I'll probably go with one of those unless someone has a better term.


Find all points within a certain distance of each other?

Let's say, we have... 50k points randomly allocated in 3D space, according to some volumetric function, so that in some parts of the space, points are closer together, but in other parts, they are further away. Every point has a random color (represented by an integer, for example) I would like to find all points that:   * Are within a certain (general) distance of each other, and   * are of different color. What is the fastest way to compute this? Further, non-mandatory details: My end goal, is to remove all points with the same color, until there are no more collisions. I would like to remove as few colors as possible, however, this is not _mandatory_ I could simply remove all colors that are involved in any collisions AT ALL, though, it could result in a lower quality result. The distance does not need to be exact. For instance, if an exact "collision radius" represents a perfect sphere, then I would be fine with the collision radius being the shape of, say, a cube. I am also fine with a trigger-happy solution. That is, I am fine if points get "detected" even if they are not too close. I just don't want this to happen very often, and I _cannot_ accept points that are to close _not_ being detected. Also, I'm sure there is a family of algorithms devoted to this, but I can't for the life of me come up with any names... Knowing the name of an algorithm of this type would be immensely helpful.


Is there a difference between merges in svn compared to git or mercurial?

From my understanding SVN is 'Easy to branch. Difficult to merge'. Why is that? Is there a difference how they merge?


Complexity of ArrayList of LinkedHashSet

I get input strings from the console like this:               while ((currentLine = bufferedReader.readLine()) != null ) {         StringTokenizer string = new StringTokenizer(currentLine, " ");         while (string.hasMoreTokens()) {             // Create a new LinkedHashSet for every token and then add it to the ArrayList.             LinkedHashSet<String> linkedHashSet = new LinkedHashSet<String>();             linkedHashSet.add(string.nextToken());             setOfStrings.add(linkedHashSet);         }     }      I'm always getting different strings from input, never the same. After finishing filling in the data structures I have this situation:   * An `ArrayList<LinkedHashSet<String>>` which contains one LinkedHashSet for each string split.   * Inside each `LinkedHashSet` I have a string that is different from any other string present in the other LinkedHashSets - in other words, its unique. For example, I can't have this inside the ArrayList:              Set x : [foo]     ...     Set y : [foo]       **After doing that, I call the function below many times to make different merges.**               public void mergeSets(ArrayList<String> operations, ArrayList<LinkedHashSet<String>> setOfStrings) {         String toMerge = operations.get(1);         String fromMerge = operations.get(2);         boolean enteredFirstToMerge = false;         boolean enteredFirstFromMerge = false;         // Temporary LinkedHashSet reference used to merge two sets.         LinkedHashSet<String> subSetToMerge = null;         LinkedHashSet<String> subSetFromMerge = null;         for (Iterator<LinkedHashSet<String>> iterator = setOfStrings.iterator();                 iterator.hasNext(); ) {             LinkedHashSet<String> subSet = iterator.next();             if (subSet.contains(toMerge) && subSet.contains(fromMerge))                 break;             else {                 if (subSet.contains(toMerge) && !enteredFirstToMerge) {                     enteredFirstToMerge = true;                     subSetToMerge = subSet;                     iterator.remove();                 } else if (subSet.contains(fromMerge) && !enteredFirstFromMerge) {                     enteredFirstFromMerge = true;                     subSetFromMerge = subSet;                 }             }             if (enteredFirstFromMerge && enteredFirstToMerge)                 break;             }             if (enteredFirstFromMerge && enteredFirstToMerge) {                 subSetFromMerge.addAll(subSetToMerge);             }         }      Explanation: For example, if I have as operation `merge foo bar`, I have to do these steps:   * First of all, I have to find where `foo` and `bar` are located:     * Inside `setOfStrings`, I can have this situation:                              position x : [bar, tree, hotel]             ...             position y : [foo, lemon, coffee]           When I find them, I have to **_`combine the set which contains foo with the set that contains bar`_** this way:                           position x : {bar tree hotel foo lemon coffee}                 ...                 position y : {} -> deleted from the arrayList      This function takes as parameters an `arrayList` of operations and an `arrayList<LinkedHashSet<String>>`: For the `ArrayList` of `operations`, I always get a specific position:   * `operations.get(1)` refers to the set to merge (foo in this example)   * `operations.get(2)` refers to the set where to add the foo set (bar in this example) With this for loop, I iterate the ArrayList to search the to sets,`for (Iterator<LinkedHashSet<String>> iterator = setOfStrings.iterator(); iterator.hasNext(); )` This `if` statement checks if the iterator is in the specific set:               if (subSet.contains(toMerge) && !enteredFirstToMerge) {         enteredFirstToMerge = true;         subSetToMerge = subSet;         iterator.remove();     } else if (subSet.contains(fromMerge) && !enteredFirstFromMerge) {         enteredFirstFromMerge = true;         subSetFromMerge = subSet;     }      **_My question is: Could I have collisions with this type of algorithm that I implemented?_** If not the time complexity is only O(n) -> the size of the arrayList.


php and mysql hosting service that fulfills my registeration system

Kindly tell that how to make a registration system that work with php and MySql . I tried the demo that is here but how it works with the online web hosting . I have registered the free hosting at here   I have also created the database at here but cannot know how to use php files and upload at and use the mysql database that I created here . I want online registration system that uses php and mysql with the free hosting that serves my purpose. The registration system creates the user and sends confirmation email to user’s email address and after confirmation user can log inn to the web application and further work will be done here after registration. Kindly guide me in the above scenario or tell another free hosting service that fulfills my purpose.


One-use variables - has any language ever had them?

A principle that I follow is that, when an identifier is established, it should be a signal to the reader that the value referred to is indeed an abstraction which will be used more than once. That is, the identifier is defined or assigned once, and the value is read more than once. However, a common idiom exists whereby, in order to increase readability, parts of a complex expression are factored out into variables. These variables will only be used once, violating the principle. Thus, a special separate class of identifier should be used to indicate a one- use variable. This principle applies to any identifier. So you might have one-use functions, one-use methods, one-use variables, etc. Has there ever been a programming language which supported one-use variables?


Is it beneficial to study past the basics of a core language when the primary goal is to rely on its framework?

Please keep in mind this is not another 'How much [ _insert programming language here_ ] should I know before moving onto [ _insert framework here_ ]?' What I'd like to know is how beneficial is it to learn the those advanced concepts of a programming language when your intention is to heavily rely on its framework the majority of the time. So for example I've began to use jQuery and first took the time out to really grasp the core concepts of Javascript. Additionally I have a few _beyond the basics_ books (Secrets of a Javascript Ninja for instance) on the shelf that really delve into the language. As I skim through the pages though I find that a fair bit of it doesn't carry over to jQuery being that my main intention is DOM manipulation. The same can be said for Ruby and RoR. Will these books make me a better programmer overall? Probably. Can these topics help me become that much better with its framework? That's what I'm having a hard time understanding.


How would you rank these programming skills in order of learning them?

As a **general purpose** programmer, what should you learn first and what should you learn later on? Here are some skills I wonder about...   * SQL    * Regular Expressions    * Multi-threading / Concurrency    * Functional Programming    * Graphics    * The mastery of your mother programming language's syntax/semantics/featureset    * The mastery of your base class framework libraries    * Version Control System    * Unit Testing    * XML    * Do you know other important ones? Please specify them... On which skills should I focus first?


Storing Attendance Data in database

So i have to store daily attendance of employees of my organisation from my application . The part where I need some help is, the efficient way to store attendance data. After some research and brain storming I came up with some approaches . Could you point me out which one is the best and any unobvious ill effects of the mentioned approaches. The approaches are as follows   1. Create a single table for whole organisation and store empid,date,presentstatus as a row for every employee everyday.   2. Create a single table for whole organisation and store a single row for each day with a comma delimited string of empids which are absent. I will generate the string on my application.   3. Create different tables for each department and follow the 1 method. Please share your views and do mention any other good methods


Benefits of setting PHP memory_limit to lower value for specific PHP script?

I need to execute just few lines of PHP code on every single page of my website. This PHP code does not require more than 4MB memory. That is why i want to allocate just 4MB memory to all pages by using following code :               ini_set('memory_limit','4M');      Does it give any benfits in any of the following areas :   1\. Website speed   2\. Bandwidth optimization   3\. Optimizing server memory usage


Where to find a good mobile robot simulator?

I would like to learn more about robotic mobile, could anyone recommend some easy and stable one? **EDIT** If possible in C, C++ or Java as programming languages. It could run in linux or windows.


How does a movie theater seat booking system prevent multiple users from reserving the same seats?

In the movie theatre I go to they have ticket kiosks that allow you to select the seats you want; they also have a website that does the same (the website also has a countdown timer of like 30 secs in which you must choose a seat). While I understand things such as database transactions and other techniques for handling multiple simultaneous users, I just can't get my head around how multiple people can be allowed to select a seat at the same time; is it as simple as the first one to press BUY gets the seats and the other person will get an error message, or am I missing something?


Why do we write our specs in different files from our source?

The D Programming Language supports writing unit tests inline with source. There's a Ruby gem called test_inline that lets you write specs in the same file as your code. Why is it generally conventional to keep source code in a completely separate directory from test code?


How to create a common interface for classes with different subsets of members

Don't know how to put it, But I'll try to be as clear as possible I have a project in which I am creating lots of classes and those classes have some common properties and methods but those methods could have different code in them, So I decided to make an interface so that I could inherit that in all classes and all classes would have same methods in them like `insert, update, delete` with different code inside those those methods but this trick flopped when I discovered that not all classes have same structure like some have insert method but not update and if I inherit interface I have to provide a public declaration for all members of that interface which I don't want. Trick two I thought about abstract classes created one too but same problem all the abstract members has to be implemented with public. So long story short **I want to create a common inheritable structure which would work as a non instance-able blue print for classes and could be inherited into lots of classes but in many classes I don't want to implement all of the members of that structure** NOTE : I can do no-op(empty methods that do nothing, or return a null, for example) as some guys suggested me but that ain't the solution I am looking for because those unnecessary members will be visible during intellisence and that's what i want to avoid. How can I do that ?


Handling a request to override browser behaviors (Back and Refresh)

I'm a new guy in this company and I've been tasked to research on possible workarounds with the browser behaviors to cater to the demands of our client. A little background; what they want is to display a 'custom' dialog whenever a user would like to navigate away from a page (not the browser default) that has a form, just as how facebook does it. I've found a workaround with the `Back` button in the form of browser states and have it integrated in my local build of the web app. Works like a charm, though I'm not convinced this is good practice. (more of a trick if you ask me) The problem is the `Refresh` event. All my research (here's one) tells me I should give up. Sigh... So I'm looking for a way to convince my superiors that this it's a bad practice to override browser behaviors or how it's virtually impossible to override the refresh behavior; diplomatically as much as possible. (if I could do citations on articles that would further prove my point, that would be great) Or do I continue looking for possible workarounds in the internet? (too much research effort but not much accomplishment if you ask me, but hey, what do I know?)


Is there a downside to installing Visual Studio Ultimate if I don't need all the features?

Microsoft released today the final builds of Visual Studio 2012 on MSDN. I'm trying to decide from this version comparison page which edition to install (I can install any edition I want for free). I'm a solo developer who develops mostly web apps and console apps in C# and Python. Some of the features in Ultimate/Premium look potentially cool (like UML and "historical debugging"), but most of the features I will not need, or have never heard of. On the one hand, it would be nice to have the features in case I want them someday. On the other hand, for some software products, the extra features cause the higher end editions to (1) be slower and use more memory, and (2) have a more cluttered UI. Is this the case with Visual Studio?


Team switching from TFS Source Control to TFS with Git, not sure how to handle complex project structure

I've used git for my personal projects for years, but that's always working alone, not needing to branch much, etc.   Our development team at work has decided we are definitely switching to git, and as one of the most experienced git user on the team I have the task of figuring out our project structure. Our current structure has a single Source Control, with many Projects. Those source control "projects" may contain multiple folders which contain multiple Visual Studio Solutions which can contain multiple Visual Studio Projects, some of which are shared.   An example:   * Main Directory      * Folder 1        * Solution 1          * Project 1         * Shared Project 1     * Folder 2        * Solution 2          * Project 2         * Project 3       * Solution 3          * Project 4         * Shared Project 1         * Shared Project 2     * Folder 3        * Solution 4          * Shared Project 1         * Shared Project 2 I am not sure at all how to translate this to git properly. The main concern that has been mentioned to me is that if we use git submodules, when checking in changes it has to be applied to multiple repositories. Is there a way around this? Does TFS in Visual Studio handle this in an easy to manage way?   Anyone have any good information about this kind of thing?


Full signed part of two complement long

I am reverse engineering a data file (from a synthesizer). It seems that e.g. -1 is written as FF FF FF FF, so in four bytes. while +1 is written as 00 00 01 (--), so only three bytes. Is something like this common? I only heard about either a 3 or 4 byte format, but not 3 OR 4 depending on the sign. And is there some way to handle this in C#? BitConverter class is a bit too limited for this.


What is the legal status of old reference material?

I am in the very, very early stages of writing an Amiga 500 emulator, and would like to include the hardware documentation either alongside my source code or in a separate `doc` package. As one example, here is the copyright notice from the Commodore Amiga A500/A200 Technical Reference Manual: ![enter image description here](http://i.stack.imgur.com/4nOx4.png) That doesn't sound promising. Other documents I'd like to include are the Motorola 68000 Programmer's Reference Manual, the AmigaDOS Technical Reference Manual, and perhaps others in the future. Do I need to tackle these documents one-by-one, or is there a "Yes you can" or "No you can't" umbrella that covers all of them? If there is a broad-brush answer, it does not need to be specific to my documents in particular. Thanks in advance!


Testing minor browser version compatibility

I develop a web application and we test it on browsers like Firefox and Internet Explorer. During our development we test the application on Firefox 3.5. **2** and our testing team tests the same on 3.5. **6** and found the UI looks good. But all of the sudden the client complains that it doesn't look good in 3.5. **8**. How do we handle these minor version issues? How can we check the browser compatibility during development and during testing? Is there any tool to test the application on 3.5. **X** , X being all the minor versions?


Aspect oriented programming and implicitness

Lets suppose that I have a class which represent an image and has a number of methods.               class Image     {         circle(x,y,radius,color);         square(x,y,w,h,color);         floodfill(x,y,color)         clear();     }      Furthermore, I want to have undo functionality. A simple way of implementing this is to keep a list of all the actions that have been performed. When I undo, I just rerun all of the actions. One solution would be to implement an aspect, something like this:               aspect ImageUndo     {         on Image::circle, Image::square, Image::floodfill         precall(object, args)         {              object.actions_list.add(args)         }     }      Essentially, this aspect has now modified the behavior of Image. That gives me concern. In particular, another programming unfamiliar with the existence of ImageUndo aspect may run into the following problems:   1. He adds a method, and it does not work with the undo functionality.   2. Attempting to debug the undo mechanism, it is not clear where the actions_list get added to. On the other hand we could have               class Image     {         @undoable_action         circle(x,y,radius,color);              @undoable_action         square(x,y,w,h,color);              @undoable_action         floodfill(x,y,color)              @undoable_action         clear();     }      Which does not bother me as much because it gives an idea of where to look for the undo code and makes is so that the new coder will probably notice it an automatically add it to a new method. To summarize: aspects (at least those like the one I showed) seems to bring "implicit magic" into what code does. It seems to me that the implicitness is dangerous and we should really make it explicit. Are there good reasons for the implicitness? Do people who actually use AOP write code that does this sort of modification? Note: this is a reworking of Is Aspect-Oriented Programming a good idea? which was closed because my previous version came across, unintentionally, as ranting.


Effective ways to make your OSS project popular?

After writing a few (relatively obscure) OSS frameworks, I've learned the hard way that writing a good framework isn't enough--there has to be some time spent marketing your framework as much as the time you spend coding it. So here's my question: What are some effective ways for making your OSS project become well-known? Aside from blogging, how do I gain the most market attention for my code with the least amount of effort as humanly possible? (EDIT: I'm a lazy programmer and I hate documentation, but I'm biting the bullet. I want to be famous)


What makes C developers so curious if "i++ == ++i"?

Just a random observation, it seems that on StackOverflow.com, there are questions about if "++i == i++". That question gets asked all the time though, I think I saw it asked about 6 or 7 times in the past 2 months. I just wonder why C developers are so interested in it? The same concept/question exists for C# and Java devs as well, but I think I saw only one C# related question. Is it because so many examples use ++i? Is it because there is some popular book or tutorial? Is it because C developers just love to cram as much as possible into a single line for 'efficiency'/'performance' and therefore encounter 'weird' constructs using the ++ operator more often?


Should the Presenter depend on the View or the vice versa?

So far, I have used the **MVP** architecture pattern a few times. Every now and then, I wonder whether my `Presenter` should depend on my `View` or vice versa, that is the `View` depends on my `Presenter`. **NOTE** > Though the sample code provided is in C#, I don't mind about the language. > My question targets more precisely the **MVP** pattern. Additionally, it was > provided off the top of my head solely to help illustrate my concern. It may > not compile. Here's a short sample of what I'm used to do:               public interface IHasUiHandler<H> where H : IUiHandler {         H Handler { set; }     }          public interface IView {         void Close();         void Hide();         void Show();     }          public abstract class Presenter<V> where V : IView {         protected Presenter(V view) { this.view = view; }              public void CloseView() { view.Close(); }         public void HideView() { view.Hide(); }         public void ShowView() { view.Show(); }              private readonly V view;     }      And let's say I'm creating a Customer Management feature.               public interface ICustomerManagementUiHandler : IUiHandler {         Customer CreateNewCustomer();         IList<Customer> ListCustomers();         void RemoveCustomer(Customer customer);         Customer UpdateCustomer(Customer customer);     }              public class CustomerManagementPresenter : Presenter<ICustomerManagementView>                                              , ICustomerManagementUiHandler {         public CustomerManagementPresenter(ICustomerManagementView view             , CustomerManagementService service)              : base(view) {             view.Handler = this;             customers = service;         }              public Customer ChangeExistingCustomer(Customer customer) { return customers.Update(customer); }         public Customer CreateNewCustomer(Customer customer) { return customers.Add(customer); }         public IList<Customer> ListCustomers() { return customers.List(); }         public void RemoveCustomer(Customer customer) { customers.Remove(customer); }              private readonly CustomerManagementService customers;     }          public interface ICustomerManagementView : IHasUiHandler<ICustomerManagementUiHandler> {             }          public class CustomerManagementForm : Form, ICustomerManagementView {         public CustomerManagementForm() { }              public ICustomerManagementUiHandler Handler {              private get { return handler; }              set { if (handler == null) handler = value; }          }              private void changeCustomerButton_Click(object sender, EventArgs e) {             if (Handler == null)                  throw new InvalidOperationException("Can't change customer. No handler specified.");             Handler.ChangeExistingCustomer(current);         }              private void createCustomerButton_Click(object sender, EventArgs e) {                                     if (Handler == null)                  throw new InvalidOperationException("Can't add new customer. No handler specified.");             Handler.CreateNewCustomer(); // No parameters for sample simplicity sake.         }              private void deleteCustomerButton_Click(object sender, EventArgs e) {             if (Handler == null)                  throw new InvalidOperationException("Can't add new customer. No handler specified.");             Handler.RemoveCustomer(current);          }              private readonly ICustomerManager manager;         private ICustomerManagementUiHandler handler;     }      I feel like the `View` should depend on the presenter, so that there would be no need for a `Handler` property in the `View` itself. Then the `Presenter` could depend on the data access service or the like to handle the business entities and the like. This would wave away the **Method Injection**, which is a benefit, IMHO. Plus it seems to reduce complexity for waving away both the `IHasUiHandler` and `IUiHandler` interfaces. This makes it a easily testable code because the `Presenter` is an easily-tested class. However, this way I'm afraid that the `Presenter` has no real handle over the view which it should be able to either show or hide. So this is where I'm growing confused about which shall depend on which.


How to format Android view IDs

I struggle with this every time I work on a project. I am not entirely sure what the standard conventions are for creating view ids. I usually use something like               view_more_button      but then if we have, let's say, multiple dialogs with a view more button then I'll start doing               view_more_button_dialog1      and from there it just spirals downward. Any suggestions?


.Net build and deploy solutions for desktop and Web applications

My employer is still in the dark ages when it comes to software development, test, build and deploy. Our development to deployment application lifecycle is:   1. Once development/changes are done we build an msi package using a visual studio setup and deployment project.   2. Msi is placed in a network folder   3. instructions are given to relevant team to deploy package.  A deploy for a windows application can consist of an msi, Sql scripts and application configuration changes, and the deployment of these is all manual. We are now looking to automate the build and deployment process for our Windows and Web applications. Most of our apps don't have unit tests which can be run automatically but going forward we will. What is the best way to do this?


Where could Distributed Version Control Systems currently be in Gartner's hype cycle?

**Edit** : Given the recent downvoting (+8/-6 at this point) it was made clear to me that Gartner's lifecycle is a biased metric from a programmer's perspective. This is something that is part of a paper I'm going to present to **management** , and management types are part of Gartner's audience. Giving DVCS exposure & enthusiasm (that "could" be deemed as hype, **or at least attacked as such** ), think about the following question when reading this one: **"how could I use Gartner's hype cycle to convince management that DVCSs are ready (or ready-enough) for us, and that it is not just hype"** Just asking if DVCSs is hype wouldn't be constructive, Gartner's hype cycle is a more objective instrument than just asking that (even if this instrument is regarded as biased). If you know any other instrument please, by all means, mention it. **Edit #2** : I agree that Gartner's Life Cycle is not for every technology, but I consider it may have generated enough buzz to be considered hype by some, so it maybe deserves to be at least evaluated/pondered as such by using this instrument in order to prove/disprove it to whatever degree. I'm an advocate of DVCS, BTW. **Edit #3** : Thanks for your answers. Bounty goes to Caleb for answering my question with detail and practical advise. Accepted answer goes to philosodad for providing another useful instrument and answering beyond my question. * * * I'm doing research for a whitepaper I'm writing in favor of DVCS adoption at company and I stumbled upon the concept of social proof. I want to prove that the social proof of DVCS adoption is not necessarily cargo cult and doing further research I now stumbled upon Gartner's hype cycle which describes technology maturity in 5 phases. ![enter image description here](http://i.stack.imgur.com/CnhKu.gif) My question is: what could be an indicator of the current location of Distributed Version Control Systems (I mean git, mercurial, bazaar, etc. in general) at a particular phase in the hype cycle?... in other (less convoluted) words, **would you say that currently expectations of DVCSs are a) starting, b)inflated, c)decreasing (disillusionment), d)increasing (enlightenment) or e)stabilizing (mature) and (more importantly) _why_?** I know it is a hard question and there is subjectivity involved, but I'll grant the answer (and the traditional cookie) to the clearest argument/evidence for a particular phase.


What should I expect from a developers guide?

I'm willing, with some friends, to make a developers guide for an open source point of sale written in Java. The thing is I have never written anyone and so I don't know exactly what to put in there to meet standards. I'm thinking about putting UML, and using Java doc but still I don't know what are the expectations of developers towards a developers guide. How can we say a developer's guide is truly worth?


Why C++ to write a compiler?

I was wondering why C++ is a good choice to write a compiler. Of course C is good for this purpose too, because many compilers are written either in C or C++ but I am more interested in C++ this time. Any good reasons ? I was looking for that in the Internet, but I cannot find any good reasons.


Implementing a "state-machine" logic for methods required by an object in C++

What I have: 1 hypothetical object/class + other classes and related methods that gives me functionality. What I want:   1. linking this object to 0 to N methods in realtime on request when an event is triggered   2. Each event is related to a single method or a class, so a single event does not necessarily mean "connect this 1 method only" but can also mean "connect all the methods from that class or a group of methods"   3. Avoiding linked lists because I have to browse the entire list to know what methods are linked, because this does not ensure me that the linked methods are kept in a particular order (let's say an alphabetic order by their names or classes), and also because this involve a massive amount of pointers usage. Example: I have an object `Employee Jon`, Jon acquires knowledge and forgets things pretty easily, so his skills may vary during a period of time, I'm responsible for what Jon can add or remove from his CV, how can I implement this logic?


Difference between REST and CRUD

I learned REST and it feels a lot like CRUD (from what I have read about CRUD). I know they are different, and I wonder if thinking they are similar means I don't understand them. Is it that REST is a "superset" of CRUD? Does everything CRUD does and more?


Do job postings exaggerate their requirements?

I feel like a reasonably qualified programmer, but a lot of job postings I run into make me feel otherwise. Almost all of them separate qualifications into requirements and desirables, but even the requirements part can be daunting. I've seen a lot of postings that say they require several years (2 or more) experience in a relatively small technology or library, something specific to their company. Other times I see 5 or even 7+ years experience required for a language. On their own some of these would be ok, but it gets ridiculous when a small town company says you need 3 years in 2 languages, proficiency in network programming, scripting, databases, and stuff like "experience with large highly redundant business critical systems" all at the same time. Do they really expect to find someone who has extensive experience working with exactly the same technology set they use? I have a hard time finding a single posting where I don't have at least 1 or 2 holes in my skill set. I've heard over and over that most places value your ability to learn quickly and will teach you on the job, but then why say it's required? Are they just trying to discourage the bottom of the barrel (FizzBuzz failures) from applying?


Non-zero exit status for clean exit

Is it acceptable to return a non-zero exit code if the program in question ran properly? For example, say I have a simple program that (only) does the following: Program takes N arguments. It returns an exit code of min(N, 255). Note that any N is valid for the program. A more realistic program might return different codes for successfully ran programs that signify different things. Should these programs instead write this information to a stream instead, such as to stdout?


What is meant by "Now you have two problems"?

There is a popular quote by _Jamie Zawinski_: > Some people, when confronted with a problem, think "I know, I'll use regular > expressions." Now they have two problems. How is this quote supposed to be understood?


How to charge in agile iterative approach?

I have a doubt about budgeting when working with agile iterative approach. If I understood well, in agile at the end of each iteration we have usable product, so we have some of the requirements met and then some part of the software will be already working. How do we charge for our work in this methodology? Do we charge per iteration, i.e. charge per major requirements being met, or just charge the customer when the software is indeed finished and then receive for everything at once?


Does the method of adjustment matter, or just the final calibration?

A company produces software (and hardware) that is used to both perform automatic _adjustments_ on electronic test equipment as well as perform _calibrations_ of the same equipment. The results of the calibrations are put onto a certificate of calibration that is sent to the customer along with the equipment. This calibration certificate states various conditions of the calibration, such as what hardware (models/serial numbers) and software (version) was used to perform the calibration, as well as things like environmental conditions, etc. Making the assumption that the software used to produce the data (and listed on the calibration certificate) used on the certificate of calibration must have gone through a "test/release" process and must be considered "released" software - does this also mean that the software used for adjustment must also be released? I believe that the method (software/environmental conditions/etc) used or present during adjustment doesn't matter, all that really matters is the end result of the calibration, the conditions _present during the calibration_ , and whether or not the equipment was within the specifications. The real question I'm hoping to get answered: _Is there a reputable source (e.g. NIST or somewhere similar) that addresses this question?_ (I have searched...) The thinking is that during high volume production runs, the "unreleased" system can be used to perform adjustments, as long as a released system is used to perform the calibrations, since the time required to perform the adjustments is much longer than the calibration. This unreleased system will eventually become released for use, but currently is not. Also, please not that there is a distinction between "adjustment" and "calibration". The definition from BIPM International vocabulary of metrology, 2.39: > Operation that, under specified conditions, in a first step, establishes a > relation between the quantity values with measurement uncertainties provided > by measurement standards and corresponding indications with associated > measurement uncertainties (of the calibrated instrument or secondary > standard) and, in a second step, uses this information to establish a > relation for obtaining a measurement result from an indication. Followed by NOTE 2 (emphasis in original text): > Calibration should not be confused with **adjustment of a measuring system** > , often mistakenly called "self-calibration", nor with **verification** of > calibration As a side note, I'm not sure why this got down voted. It's regarding software and it's use before and after release for use. I believe there is a best practice that can be applied and this is (hopefully) not primarily opinion based.


Am I deluding myself? Business analyst transition to programmer

Current job: Working as the lead business analyst for a Big 4 firm, leading a team of developers and testers working on a large scale re-platforming project (4 onshore dev, 4 offshore devs, several onshore/offshore testers). Also work in a similar capacity on other smaller scale projects. Extent of my role: Gathering/writing out requirements, creating functional specifications, designing the UI (basically mapping out all front-end aspects of the system), working closely with devs to communicate/clarify requirements and come up with solutions when we hit roadblocks, writing test cases (and doing much of the testing), working with senior management and key stakeholders, managing beta testers, creating user guides and leading training sessions, providing key technical support. I also write quite a few macros in Excel using VBA (several of my macros are now used across the entire firm, so there are maybe around 1000 people using them) and use SQL on a daily basis, both on the SQL compact files the program relies on, our SQL Server data and any Access databases I create. The developers feel that I am quite good in this role because I understand a lot about programming, inherent system limitations, structure of the databases, etc so it's easier for me to communicate ideas and come up with suggestions when we face problems. What really interests me is developing software. I do a fair amount of programming in VBA and have been wanting to learn C# for awhile (the dev team uses C# - I review code occasionally for my own sake but have not had any practical experience using it). I'm interested in not just the business process but also the technical side of things, so the traditional BA role doesn't really whet my appetite for the kind of stuff I want to do. Right now I have a few small projects that managers have given me and I'm finding new ways to do them (like building custom Access applications), so there's a bit here and there to keep me interested. My question is this: what I would like to do is create custom Excel or Access applications for small businesses as a freelance business (working as a one- man shop; maybe having an occasional contractor depending on a project's complexity). This would obviously start out as a part-time venture while I have a day job, but eventually become a full-time job. Am I deluding myself to thinking I can go from BA/part-time VBA programmer to making a full-time go of a freelance business (where I would be starting out just writing custom Excel/Access apps in VBA)? Or is this type of thing not usually attempted until someone gains years of full-time programming experience? And is there even a market for these types of applications amongst small businesses (and maybe medium-sized) businesses?


In what order are rows fetched absent ORDER BY clause?

One programmer is testing and comparing the same application which uses the same database structure, and the same data, only in two separate databases, one with Oracle 8 and one with Oracle 9. The app runs a query with **no** `ORDER BY` clause. **He pretends the ORDER-BY-less query should return the rows in the same order in both databases.** I tell him there's no warranty of the same row order **unless you explicity provide an ORDER BY clase.** The database has the same indexes and keys. But the explain plan shows that in one of the databases the engine is using the key or one of the joined tables whereas in the other database it's using another's. He insinuates that the two DB environtments are not equal, which is so because they have different statistics, different rdbms engines, etc., but not because I failed to replicate every index the original database has. I tell him he must explicity provide an `ORDER BY` clause if the order is really that important. ## The question So I can explain him better: **In what order does a query fetch rows when you don't explicity write an ORDER BY clause, and why doesn't that query return the rows in the same order ?**


Debugger for file I/O development?

Okay, the question title may be a bit cryptic. But it aptly describes what I'm looking for: I think every experienced coder went through this numerous times: You get a binary file format specification, you implement the reader for it, and… nothing works like expected. So you run your code in the debugger, go execute through the code line by line, every header field is read in seemingly correct, but when it comes to the bulk data, offset and indices no longer match up. What would really help in this situation was a binary file viewer, that shows you the progress of your file pointer, as you step through the code, and ideally would also highlight all memory maps. Then you could see the context of the current I/O operations, most notably those darn "off-by-one" mistakes, which are even more annoying when reading a file. Implementing such a debugger should not be too hard. traces on the process' file descriptors/handles and triggers on the I/O functions, to update the display. Only: I don't know of such a kind of debugger to exist. Do I just lack knowledge about the existance of such a tool, or is there really no such thing?


How to verify that all files are intact prior to install?

I'm working on my CMS (in PHP platform) for a long time now. The main program is done and I'm currently developing the Installer part. Installation itself will be fairly simple:   1. Upload all files   2. Verify that the "content/" dir has correct permissions   3. Check if ALL files are intact and not modified [This is the subject of this question]   4. Insert the config data and first settings   5. Run install (Generate all DB tables and insert sample data etc.) Now the question-mark is at step 3. How do I verify ALL files? Verification itself should compare all CMS root-directories files against a list from remote location. List should contain filename, filesize and filetype. This way the user can check, that there are no unnecessary or corrupted files, that could indicated a breach in the software. I have seen some software installers do that, but I cannot find any right now and there for I'm clueless on the most optimal method for this. Of course there always is a simple `array` trick, but there surely must be a better and faster method?!


Using Dynamic LINQ to get a filter for my Web API

We are considering using the Dynamic.CS linq-sample included in the "Samples" directory of visual studio 2008 for our WebAPI project to allow clients to query our data. The interface would be something like this (In addition to the normal GET- methods):               public HttpResponseMessage List(string filter = null);      The plan is to use the dynamic library to parse the "filter"-variable and then execute the query agains the DB. Any thoughts if this is a good idea? Is it a security problem?


Why would one prefer C# (ASP.NET MVC) or Java (JSP) instead of PHP for web applications/projects

I'm wondering, why would one (consider it not just a single developer, but a company) prefer C# or Java for web applications? What's their considerations regarding the question. I mean, a company, has an assignment to make a web- site for customer, or online game, or web-portal, how does the project management or/and the software architect (and the core team) came to the conclusion - "we will do it in ASP.NET MVC" for example? I know it's specific, but what are the common reasons? Especially, why instead of PHP? As PHP is purely designed for web. Maybe if it is for a single web-site, there are much CMS's where the customer is familiar with, but let's say PHP also has a lot of CMS's, and most of the ASP.NET ones are as spaghetti as wordpress is. Also, as I'm aware, the common webserver is a windows webserver, back in the days I started with computers, everyone was saying the administration in windows is worse than in unix-based platforms. I really don't see the point. For me is just like waste of resources, I think you will need twice better machine running on Windows for the same achievements. C# for desktop - thumbs up, but for web - why? Same for JSP. Its common server is cross platform, so no need of Windows, but still isn't it also waste of resources? And the question is the same as the paragraph - how a company would decide to use JSP. The question was raised, because of lots of the sites rising in ASP.NET nowadays. To be honest, I have seen too few sites in JSP. P.S.: Sorry, I didn't find the relevant tag for this, so I tagged the languages and the involved stuff


How to avoid errors and not miss anything

I have a problem that is more serious than it might seem. I've been programming for about three years , and I have learned and improved a lot , I read the code easily to others, understand the problems and transform them into code, I easily adapt to new technology and I love to learn how it all works . That's all fine . The problem I have is that I often forget small details , which then turn out to be critical . For instance , yesterday, after changing a database query to retrieve some data filtering by twenty fields , forgot to load all the data ( the query returned only the data of the primary key of the whole object ) . Other times are smaller things that do not make the whole process fails, but still I am afraid to fail at something serious , that my superiors grow weary of my mistakes , etc. . I would like to know how I can schedule the job to not forget anything or at least soon realize that I have forgotten something or have missed something ...


Why is Feature Driven Development considered an Agile methodology?

In several places Feature Driven Development (FDD) is called an Agile methodogoly - e.g. the Wikipedia entry on FDD. Yet in general, to be considered FDD it seems the following requirements have to be satisfied:   * Coloured UML **has to be used** (but documentation isn't necessary);   * Instead of pair programming the team is divided by software features;   * **refactoring is discouraged** or, at least, isn't a task with explicit scope;   * **unit testing is discretionary** , the team leaders can decide;   * the work flow has to pass through the five FDD phases; On the flip side it seems to me that Agile is   * UML is an **optional** tool   * Tests are documentation   * Tests are **obligatory**   * **refactoring** is a consequence of the change requests of the customer and it **isn't discouraged**. Am I wrong with my understanding of either concept?


Practice examples

I hold a bachelors in CS, but generaly, i call myself a beginner in programming. With an emphasis in focusing on learning to code and make Android Apps. I have gone through this common (http://developer.android.com/training) tutorial. Read through, and close to the end so as to get a general understanding. Done their example of Hello world. The next i want is a set of codes that i can go through, practice with them so as to build my skill to a harder level. I really want this so bad, and i want to do App development as a carrier. I appreciate any advice given.


Converting an empty string to a number

If you are designing a function which should conver a string to an integer, how would you convert an empty string? The question is only about this one particular input value (empty string). Between throwing an `ExcStringIsEmpty` exception and converting to `0` options I prefer the first. It seems more logical to me. Because when you perform an opposite conversion from integer `0` you will hardly convert it to an empty sting but to a string `0` instead.


What is a good way to share internal helpers?

All my projects share the same base library that I have build up over quite some time. It contains utilities and static helper classes to assist them where .NET doesn't exactly offer what I want. Originally all the helpers were written mainly to serve an internal purpose and it has to stay that way, but sometimes they prove very useful to other assemblies. Now making them public in a reliable way is more complicated than most would think, for example all methods that assume nullable types must now contain argument checking while not charging internal utilities with the price of doing so. The price might be negligible, but it is far from right. While refactoring, I have revised this case multiple times and I've come up with the following solutions so far:   1. **Have an internal and public class for each helper**   The internal class contains the actual code while the public class serves as an access point which does argument checking.   Cons:     * The internal class requires a prefix to avoid ambiguity (the best presentation should be reserved for public types)     * It isn't possible to discriminate methods that don't need argument checking     2. **Have one class that contains both internal and public members (as conventionally implemented in .NET framework).**   At first, this might sound like the best possible solution, but it has the same first unpleasant con as solution 1.   Cons:     * Internal methods require a prefix to avoid ambiguity     3. **Have an internal class which is implemented by the public class that overrides any members that require argument checking.**   Cons:     * Is non-static, atleast one instantiation is required. This doesn't really fit into the helper class idea, since it generally consists of independent fragments of code, it should not require instantiation.     * Non-static methods are also slower by a negligible degree, which doesn't really justify this option either.  There is one general and unavoidable consequence, alot of maintenance is necessary because every internal member will require a public counterpart. A note on solution 1: The first consequence can be avoided by putting both classes in different namespaces, for example you can have the real helper in the root namespace and the public helper in a namespace called "Helpers".


Programming Challenges for a beginner

> **Possible Duplicate:**   >  How can I teach a bright person, with no programming experience, how to > program? I'm in an unusual situation. A colleague of mine wants to "learn programming" and, being a developer I have been tasked with teaching him "programming". Personally, I am self taught, and have never taught any sort of skill to anybody else before so I am not quite sure where to start. Also, I still have a heck of a lot to learn myself (although don't we all)! I write in C# but is C# a good language for a beginner? I was thinking that Visual Basic .Net would be a better starting point, so was considering getting him setup with Visual Studio Express 2010, teaching him a few basics (variables, functions, classes etc) then finding some programming challenges and asking him to work through these. Does anybody have a good source of these sorts of challenges? Also is this a good strategy? Finally, what are your experiences of teaching programming to somebody else and what advice would you give?


What is the best way to teach beginners?

> **Possible Duplicate:**   >  How can I teach a bright person, with no programming experience, how to > program? I was recently asked by an older friend working on the city council if I would be willing to teach a summer programming course, targeting middle school to high school aged students with either minimal or no prior programming experience. I'm a senior in high school, but I've been programming since a young age, and I've worked locally with my city on various projects requiring programming. The first thing is, I don't want to teach something that can easily be learned anywhere online. If I spent all day over two weeks teaching only basic HTML with bits of CSS, I'd feel like I'm ripping them off (since the class is planned to be $30.00 per person, although I won't receive any of the money). Furthermore, there's actually already a web design class being taught, and I got the impression that I wasn't meant to focus on web development. If it was all up to me (which it's not, I have to create a plan and present it in front of the summer programs board for approval), I would spend the first week teaching Haskell, and the second week using it to solve math problems (like those seen on Project Euler). Unfortunately, I'm probably the only one who would be interested in taking such a class, and I should probably focus more on programming rather than mathematics. I've seen in this thread that Java was not well liked, and I've seen in virtually any other thread that people loved Lisp dialects (especially Scheme, and I suspect this is somewhat related to the love of books like SICP). I have the problem of trying to make the course interesting and engaging, while educational. I don't necessarily need to "sell" programming to them, since they should be somewhat self-motivated applicants, but I also don't want to bore them and "ruin" programming for them. What should I do? What should I teach?


How do I know how much to ask for in salary?

I'm heading into my first job (i.e. they're bringing me on for a full position) in Software Development and am quite nervous about how the whole salary negotiation thing goes. Glassdoor.com says that my position for my (lack of) experience offers something ridiculously high like 85k. Salary.com says that Software Developers with no experience in my location get about 65k. From some research, I know I shouldn't say a number before they do. But let's say they offer me _Xk_. What should I counter with? Do I say things like "My research shows that people around my experience level for this position at this company earn much more...", etc?


Recompiling a java project while it is running

I have a Java program that takes about an hour to run. While it is running, if I change the source code and recompile it, will this affect the above run?


Where do I start to build this?

I'm a real estate professional and part of my job is to scan a database day in and day out searching for properties for a prospective investor buyer to purchase. I am pretty sure a program can be made that will scan this database for me, and alert me when one pops up that I should look at. I make the decision on what they buy based on a few pieces of data. Things like square footage, beds baths etc. Basically what I do is compare a prospective distressed property to properties that match criteria to determine how close they are, and then come up with a likely after repair value based on the other sold nearby houses. I theorize that my program should be able to scan the DB, gather all new properties added. Take each property. determine which other sold properties are most comparable and come up with a likely after ARV. Then compare that ARV to the list price, if it is within a certain range, alert me. So far I've gone and confirmed that I can get a feed for this data. I think it will be in xml but won't know the structure of the data until i apply for a feed license. My problem is I have no idea where to start on this. I've been tinkering around with little website building and very basic html and php for about 10 years but never really became a master of it. Is this too much for a newb to build? should I pay? or suck it up and learn?


How can I improve my productivity in Linux?

I have been mostly using Windows but I know my way around a Linux system but I am not as productive as in Windows. I am looking for some "survival" guidelines on what should I focus to be able to improve my productivity in Linux (mainly, being more efficient with the command line interface).


How many `malloc` calls is too many? If any?

I'm implementing a system in C, implemented partially as a library. The library does most of the memory management itself, with the application layer just having to call `*_destroy` functions on the top-level objects. While checking for memory leaks, I noticed that the number of calls to `malloc` seemed quite high, relative to the size of the application code. The performance of the code seems fine, but I've been bitten by "fast enough" code before when trying to scale. The number of allocations roughly matches the number of objects created, including child objects of the top-level ones. So creating a single top-level object might trigger 7 malloc calls, since it needs one for itself and then a couple for it's children that may also need a few children. Unfortunately, I'm relatively new to C programming, though generally experienced as a programmer, and have no idea whether or these numbers are normal or not. So what would a good rule-of-thumb be for number of allocations? I know that less would generally be better, but changing the code to allow it would introduce complexity that I'm not willing to add without a significant increase in performance. Also, should I worry about the performance of `malloc/free` or is that the realm of real-time performance (games etc.)?


A good C Variable Length Array example

This question got rather a freezing reception at SO, so I decided to delete it there and try here instead. If you think it does not fit here either, please at least leave a comment on suggestion how to find an example I'm after... **Can you give an _example_ , where using C99 VLAs offers a real advantage over something like current standard heap-using C++ RAII mechanisms?** The example I am after should:   1. Achieve an easily measurable (10% maybe) performance advantage over using heap.   2. Not have a good workaround, which would not need the whole array at all.   3. Actually benefit from using dynamic size, instead of fixed maximum size.   4. Be unlikely to cause stack overflow in normal use scenario.   5. Be strong enough to tempt a developer needing the performance to include a C99 source file in a C++ project. * * * Adding some clarification on the context: I mean VLA as meant by C99 and not included in standard C++: `int array[n]` where `n` is a variable. And I am after an example of use case where it trumps the alternatives offered by other standards (C90, C++11):               int array[MAXSIZE]; // C stack array with compile time constant size     int *array = calloc(n, sizeof int); // C heap array with manual free     int *array = new int[n]; // C++ heap array with manual delete     std::unique_ptr<int[]> array(new int[n]); // C++ heap array with RAII     std::vector<int> array(n); // STL container with preallocated size      * * * Some ideas:   * Functions taking varargs, which naturally limits item count to something reasonable, yet is without any useful API-level upper limit.   * Recursive functions, where wasted stack is undesirable   * Many small allocations and releases, where heap overhead would be bad.   * Handling multi-dimensional arrays (like arbitrarily sized matrices), where performance is critical, and small functions are expected to get inlined a lot.   * From comment: concurrent algorithm, where heap allocation has synchronization overhead. Wikipedia has an an example which does not fulfill my criteria, because the practical difference to using heap seems irrelevant at least without context. It is also non-ideal, because without more context, it seems item count could very well cause stack overflow. Note: I'm specifically after an example code, or suggestion of an algorithm which would benefit from this, for me to implement the example myself.


Preparing to release code as open-source

I have developed a fully functional tool which I would like not only to share with anyone interested but also get support from the community. This tool is cross-platform, written in C++ with Qt, the code is well commented but I still lack any documentation. There are also some small issues and improvements to be made before I can call it a stable, final version. What are the first steps that I have to take to release code as open-source and attracting people interested in contributing? This is my first serious attempt to release open-source code and I really don't know where to start. Should I just push it to Github put together a small wiki and pray for the best?


How to deal with pointers from child to parent?

I have a class that represents a file in specific binary format on disk (the parent in the title) and another class that represents an object inside that file (child). When the object changes, it sometimes needs to relocate to a new position in the file and the file class has to be notified about this new position. To do this, I have added a `weak_ptr` field to object, which points to the file. Except that means there has to be a `shared_ptr` for file, so I'm using a `static` factory method instead of public constructor for it. And object now can't be initialized in the constructor, so I'm using `unique_ptr` for it. In code, it looks something like this:               class File;          class Object     {     private:         std::weak_ptr<File> file;          public:         Object(std::weak_ptr<File> file)             : file(file)         {}              void modify();     };          class File     {     private:         std::unique_ptr<Object> object;         std::shared_ptr<File> self;              File()         {}          public:         void setObjectPosition(std::uint64_t newPosition);              static std::shared_ptr<File> create();     };          void Object::modify()     {         std::uint64_t newPosition = …;              file.lock()->setObjectPosition(newPosition);     }          void File::setObjectPosition(std::uint64_t objectPosition)     {         // store objectPosition     }          std::shared_ptr<File> File::create()     {         auto file = std::shared_ptr<File>(new File());              file->self = file;         file->object = std::unique_ptr<Object>(new Object(file));              return file;     }      Is this this the right approach to do this? Or is there a better/more idiomatic solution? I feel like I'm using `*_ptr` too much, but I can't think of anything better.


How can web development bootcamps deliver on their promise?

I came across the concept of web development bootcamps, these 9-10 week intensive crash courses claim to teach beginners web development and help them get 80k starting salary jobs. Many of you might have heard of these. Is what the bootcamps promise feasible? Is it possible for web technologies like Ruby on Rails, HTML5, CSS, and Javascript to be taught from scratch in such a short period? And to people without a technical background?


Python -- when should a class have-a rather than be-a?

This is related to "Extends is evil" vs. OCP? but separate because the idea of "implement the interface" doesn't exist in Python. I'm writing a class to pull some data off a webpage. It's going to need to hold on to a cookie for authentication, so I'm going to use a `requests.Session` object in some form. I'm never sure how to approach this -- what's the appropriate choice here?               class FooFetcher(requests.Session):         def __init__(self):             super.__init__()      or               class FooFetcher(object):         def __init__(self):             self.session = requests.Session()      ? The former seems to end up with `FooFetcher` having way more public methods than it needs to. The latter looks like it might be unnecessarily convoluted, since pretty much every method of `FooFetcher` is going to involve a call to a method of that `Session` object, plus maybe some parsing of JSON that it finds.


Should a repository be passed in to the User Interface

In Mark Seeman's Dependency Injection in .NET he injects a repository into his UI layer. I believe that he is doing this so that he can store everything in the UI configuration, however this just strikes me as bad design. Wouldn't it be better to pass the service reference into the UI? What is to stop a future developer from using the repository directly? Also, he says that he is building this as an n-tier architecture. But, he has now coupled the data layer to the UI layer (no matter if DI is used or not). What if he wants to host all three layers on different self-contained servers. While his approach COULD work, it just seems wrong to me. So, I wanted to see what the general community has to say. Am I right in my thoughts, or am I missing something? Simplified version of the code:               public class UI     {       IRepository _repo;       public UI(IRepository repo)        {         _repo = repo;       }            public stuff UIMethod()       {         var svc = new Service(_repo);         return svc.GetStuff();       }     }          public class Service     {       IRepository _repo;       public Service(IRepository repo)       {         _repo = repo;       }            public stuff GetStuff()       {         var persistenceStuff = _repo.GetStuff();         //Do some business logic here         return persistenceStuff.ToServiceStuff();       }     }


Differences between TypeScript and Dart

Microsoft recently unveiled Typescript, a new JavaScript-like programming language. Some time ago, I heard about Dart, a new programming language created by Google to solve problems related to Javascript like performance, scalability, etc.. The purpose of both new languages seem the same to me.. What do you think? Are the purposes of the languages the same? What are the real differences about them?


What is beautiful code in C++, and why do most programmers care that much?

As most projects use a C++ API, they deal with constraints of the API and constraints of the project itself. I'm a beginner at programming, I don't like to use OOP at all because nobody clearly managed to explain to me WHY it's is so important to restricting yourself with private scope to prevent others programmers to break data organisation consistency of some kind. I still can be ok with OOP, since it still allows to make some great things like Qt and Ogre3D, but those are only APIs, not applications, and those codes need to be perfect so nobody can criticize the work. I don't understand why do most programmers, since they make apps and not APIs, want to do perfect code like they design some genius piece of code, and waste time on this.


Great companies using FPA as cost estimation

Anyone know if great enterprises (Google, Oracle, SAP) uses Functional Point Analysis to estimate software building effort?


How to write a very basic compiler

Advanced compilers like `gcc` compile codes into machine readable files according to the language in which the code has been written (e.g. C, C++, etc). In fact, they interpret the meaning of each codes according to library and functions of the corresponding languages. Correct me if I'm wrong. I wish to better understand compilers by writing a very basic compiler (probably in C) to compile a static file (e.g. Hello World in a text file). I tried some tutorials and books, but all of them are for practical cases. They deal with compiling dynamic codes with meanings connected with the corresponding language. How can I write a basic compiler to convert a static text into a machine readable file? The next step will be introducing variables into the compiler; imagine that we want to write a compiler which compile only some functions of a language. Introducing practical tutorials and resources is highly appreciated :-)


What would be the best way to learn about compilers, and executable formats?

I want to write my own compiler for my own language. Yes, it's going to be hard, and it will take long, but I think it will be worth it. I have looked into OSDev.org, and read about executable formats there, but they aren't much help. I am looking for information beyond what they have there. So, anything will help. Books, websites, PDFs, anything. I am looking into 32-bit, not 64- or 16-bit.


Implementing a first basic interpreter: what should I learn first?

I'm about to implement my own very simple programming language, and an interpreter to execute code in that language. The language will be very basic. Example code:               var x = 3     if x > 2 print x     if x < 2 print "hello"      The language wouldn't feature anything more complex than single-line `if` statements. This is because it's the first time I'm attempting something like this, so I'm starting small. The interpreter will be written in Java, and thus execute the code with Java operations. My question is this: I know that the topic of creating compilers and interpreters is very complex. But since I'm new to this, I believe I should start with basic techniques and approaches. **What should I learn before starting to work on this project? Especially what kind of knowledge regarding parsing and interpreting should I learn before starting?** Is it enough to just 'break down the text into substrings, and then more substrings', or should I learn more advanced techniques and apply them? **The knowledge and experience I acquire are meant to allow me to later build more knowledge on top of it when I continue learning and implementing interpreters. But shouldn't be 'too much' for a first attempt.**


What is "the refactoring method" for understanding code wrote by someone else?

I wrote code, but I myself many times don't even understand the code i wrote. I heard people using "refactoring method" to help them to understand others' code. I just knew a very little about refactoring. That is using the combined key **Alt Shift R** in eClipse, but it will automatically change all the related code & thus does not make any benefit for understand code. So, what is "the refactoring method" (for understanding code wrote by someone else) that people talk about?


In Git, is the use of a 'PRODUCTION' branch necessary and/or would it be feasible to have more than one of them?

**A short summary of how we do branch managing** : From the MASTER branch one or many feature branches can be made (for mid to long term development), when deploy-able changes have been merged to MASTER then release branches are made. Release branches are kept for maintaining deployed version until the next release occurs and they are merged to PRODUCTION in order to build TAGS which are deployed to Live Environments. **First verse of the question** : Is it actually necessary to have the PRODUCTION branch step? Surely TAGS can reliably be created off a Release Branch at the same point that it would have been merged to the PRODUCTION branch? If they are worth having then the **second verse of the question** : Would it be a suitable source control to have more than one PRODUCTION branch while having just one MASTER? **The motivation** : We will soon have an internal project starting that will (hopefully) be a "white-label" product we can use to replace three separate internal applications we use currently (as well as for any future applications). It would be one back-end, one library, one API but three teams using it and managing their own User Interfaces and adding reusable functionality to the back-end. A thought was the project could be one repo with one MASTER, various feature branches for any of the teams as they need to develop things (mid- to long term). But should we then have a PRODUCTION branch for each of the three 'versions' of the product or just TAG off from the respective Release branches? So that they could deploy independently from each others' sprints and requirements (as long as they do not break the shared infrastructure). PS: Each of the three applications deploy to independent Live environments and used by different departments in the company. PPS: If you know of any other versioning-flows which would be better suited please tell me! [EDIT - After reading jhr's answer] Think of this as one BIG project/application. But instead of having one BIG team working on the sections used by 3 departments (each with their own required UI flows and features etc) we may be split into three teams, each working on a department's features, on the same code base (repo). This is not a technical spec question per-say but rather one for opinion, experience or preference etc.


Boss is afraid to use a version control system for new project, should I anyway?

See Superior refusing to use subversion My question is similar, but here are the main differences in my scenario:   * We are starting a new project from scratch, using PHP and web tech. There would be no down time in development as we would be adopting it from the beginning, if I have my way.   * My dev team consists of me, and my boss. We are the "IT" Department of a relatively small firm. There is another IT worker who does desktop support but no development.   * My job title is Programmer; my boss's is IT Manager. The upper echelon of management likes my boss. They like me too, but probably not enough to give me the authority to override him. The web app will replace a legacy FoxPro application with absolutely no source control. In fact, due to legal requirements, the decision was made (before I was hired) to fork the app into 7 completely separate programs - not just the files that calculate things which can vary by state - but I mean the entire directory was copied, 7 times, and different states were given to different developers. Things diverged from there. My boss's idea of version control is to copy and paste entire source files from the state he's working in, into all the other states, thus overwriting those files. Small tweaks are recorded in text files manually, and must be copied and pasted by the developer for the target state. This doesn't always work so nicely. I get blamed for changing things and causing it to break when these files are pasted over. My boss's proposal, directly pasted from an email:   * Updates should be submitted as packages in the SUBMISSIONS folder. The package should contain all relevant files as well as an ‘UPDATE.NFO’ file that contains a description of the update, a list of all new files included (with descriptions), and a list of all modified files with modification details.   * Update packages should focus on an individual element and not stray from its intended purpose. Code should be designed to be modular and reusable whenever possible.   * All submitted packages should be installed in each developer’s test environment soon after submission. Each developer is to review the new addition and voice any concerns over its installation to the production environment. A standard package update should be held for a minimum of 3 business days for this review process before being loaded into the production environment. High priority updates/fixes can skip this requirement. (end email) The reason source control was invented is to make all that automatic, right? I suggested subversion, because that's what I used in college. Boss doesn't like subversion because "It makes a mess of the code" and people on the internet told him it was bad. (Where is he looking???) I don't know whether he dislikes only subversion, or all source control products (he hasn't replied to that question yet). I am not asking for a compare/contrast of different systems like svn vs git, I can do that myself. I am looking for a third party who can present a logical argument for the use of SOME form of version control. Please, fellow coders, help me. If something you can say, addressed to my boss, would have an affect on my plight, I beg you to come forth. My boss can be reasoned with if a logical argument is presented. I am putting forth my own effort on the side to convince him, through research and demonstration, but if people from the development community are overwhelmingly on my side, I think he might reconsider. To be fair, I must also ask those opposed to version control to speak up. RSVP. Or am I wrong altogether? Is source control really necessary in my situation? This is our main business-critical software we're talking about, so it will end up huge no doubt. But there's only 2 developers (now). MY ACTUAL QUESTION: If I can't convince him, would there be any point to me using it only for myself? I am speaking as someone with very limited experience actually using svn; all I really know is checkout and commit. What are the features of source control (may include other products than svn) that would aid in my individual development effort? And please no "Get another job" comments. I know, people, believe me I know. Before it even comes up, you may assume that I am insane. Maybe I'm just a sucker for challenge or a plain old masochist. But just consider it not an option.


How does an online game continue after the host leaves?

**Note:** This is a question about networking, not gaming. I'm using StarCraft merely as an example. The game _StarCraft_ (not StarCraft 2) supports online play. One person hosts, and other people join. If the host leaves during the game, the game can continue indefinitely without the host. How does that work? Consider the following scenario:   * I host a 3 versus 3. Note that, for people to be able to join, my router has to be configured to port forward 6112, TCP and UDP (see Blizzard Support).   * Five people join. Everyone (myself included) is behind a router. I start the game.   * Three minutes into the game, about twenty zealots pour into my base. Nobody helps me.   * My base is eliminated, so I leave (the game doesn't give you a choice).   * The game continues without the host (the home team has two players left). How do the remaining five clients (who didn't need 6112 forwarded) remain connected? If I understand correctly: if two programs want to talk to each other, one of them has to be a "server" and listen for connections on a port, while the other has to be a "client" and initiate a connection request on that port. They can't simply start sending packets to each other (and I don't even know how they would, if both are behind routers). Someone hosting a game is a server, while those joining it are clients. It's easy to see how the clients can start communicating with the server. What I don't get is: how do the clients start communicating with each other without going through the server? Does the Internet Protocol allow a server to initiate connections between clients? It's entirely possible that, in the case of StarCraft, game traffic goes through Battle.net servers. StarCraft does maintain a connection to Battle.net during games (for messages from friends, etc.). However, I doubt game traffic goes through it, because if it did, why would hosts need to port forward 6112? My question is: can a server, with multiple clients connected to it, initiate connections between them?


Organisation GitHub account. Secure to use for personal projects?

So a large client of mine gave me access to their Organisation GitHub account.   With it came a login for myself (on github.companyname.com) and of course access to certain repos on their company account (by switching the user to the company via the button in the top left). Now I was wondering, since I can create private repos for myself, is it safe for me to use these for non-related projects or can the company administrators access my user's repos despite being private? My understanding of Github is limited as it is, so this extra layer of complexity from the organisation account isn't helping too much. Thanks,   Mike **UPDATE:** Thanks to all of you who posted answers and wrote comments, all were really helpful. I have decided to no host any personal projects on their enterprise account as suggested, and again, as recommended I now host my repos on a private provider like bitbucket. Mike


For asp.net mvc is this a three tiered solution?

I am a asp.net mvc programmer and if I want to start a project I do this:   1. I make a class library named `Model` for my models.   2. I make a class library named `Infrastructure.Repository` for database processes   3. I make a class library named `Application` for business logic layer   4. And finally I make a MVC project for the UI. But now some things are confusing me. Am I using 3-tier programming? If yes so what is n-tier programming and which one is better? If no so what is 3-tier programming? Some where I see that the tiers namings are DAL and BIZ. Which one is correct according to the naming convention?


Is there much difference between X86 Assembly language on Windows and Linux?

I'm a complete beginner at Assembly, and my aim is to learn as much as I can to do with Assembly to one day I can reach expert level (I know I'm way off right now, but you never know). My only problem is this: I've got two books which both teach assembly, one on a Linux and the other on Windows. They are Jeff Duntemann's Assembly Language Step By Step (the linux one) and Introduction to 80x86 Assembly Language and Computer Architecture (the windows version). If I want to get the best out of assembly, should I do this on linux and windows? Also, is the syntax the same on Windows and Linux or will I have teach my self again when learning on the other OS( which is my main concern, I want to be able to use assembly on windows and linux).


Are companies in certain locations (big city vs small town, etc) more likely to offer telecommute contract programming work?

I'm interested in taking on more contract projects for programming and, although it'd be nice to find clients just in my area, I want to expand my search a bit to other areas where a company may allow me to telecommute. I'm wondering if anyone who has experience with this has noticed that whether a company would be more likely to be open to this based on if they are in a bigger city vs a smaller town. I would think that companies in smaller areas may have trouble finding programmers for some things and therefore would be more willing to outsource but maybe I am wrong. Any info is appreciated, I'm just trying to get an idea as to how to concentrate my efforts with networking with people form different areas, etc.


Industry has no place for passionate programmers?

I've been interning at a place where my manager believes that if you are in a,   * _product company_ , then you generally spend time tweaking the product and sometimes adding some features, or   * _service company_ , then you keep doing repetitive things which makes me feel industry is no place for someone who likes to do create news things and solve difficult problems. So is the industry not a place for a passionate programmer? Does this change from country to country? * * * **Update to clear some things that can be understood differently than what they were meant.** Tweaking here is making sure your product has tables with the number of rows and columns the client wants, etc. Customize it for the customer. New "feature" isn't new functionality here. Just aesthetic-level changes. And it's sometimes. I'm not sure what he meant by repetitive though. He was like, you have to make the UI again and again every time. (I see no repetition there though. If a different UI is needed then a _different_ UI needs to be designed. If you can use the old one then you don't need to do much anyway.)


Is it a bad idea to use mutable for pre-allocated temporaries?

Let us assume I have the following C++ class:               class MyFastMessageEncoder     {     public:         MyFastMessageEncoder() :             m_fieldEncoder(ENCODING_STYLE_DEFAULT)         {         }              void set_encoding_style(const EncodingStyle encodingStyle)         {             m_fieldEncoder.set_encoding_style(encodingStyle);         }              EncodingStyle get_encoding_style() const         {             return m_fieldEncoder.get_encoding_style();         }              void encode(const UnencodedFieldList &unencodedFieldList, Message &message         {             for (UnencodedFieldList::const_iterator it = unencodedFieldList.begin(), end = unencodedFieldList.end(); it != end; ++it)             {                 m_fieldEncoder.set_raw_data(*it);                 message.add_field(m_fieldEncoder.encode());             }         }          private:         FieldEncoder    m_fieldEncoder;     };      The `MyFastMessageEncoder` class is required to be extremely efficient (encoding will be performed on tens of thousands of messages per second), the time required to instantiate the `FieldEncoder` object is a non-negligible cost, so to solve the issue, I have defined the `FieldEncoder` object as a class member, and initialized it inside the constructor just once. My issue is that `FieldEncoder::SetRawData()` is a non-const method, which means that the `MyFastMessageEncoder::encode` method must also be non-const. _However_ , if I were to make the FieldEncoder object a temporary inside the method, `MyFastMessageEncoder::encode` could be flagged as const. This means that every object that calls `MyFastMessageEncoder::encode` is also non-const, which (to me) just starts ruining the program's const-correctness. Now I understand how the `mutable` keyword works works, and how I could use it to solve this problem, but my question is: **Would doing so be considered bad form, since the internals of the object are technically being modified?** Other considerations:   * Thread-safety is not a concern, this is guaranteed to only run in a single thread (although the `MyFastMessageEncoder` may be created on multiple threads)   * The `set_raw_data` method does not impact the `FieldEncoder` class outside the `MyFastMessageEncoder::encode` method. Any data that is set is cleared or overwritten the next time the `set_raw_data` method is called.


How much can I charge for this a little job?

I started doing freelancing. I got my first job to create a set of reports. The business team has provided me with the sample reports and also some sample codes. My job is to query the database and generate output as pdf using iText. There are around 25 such reports with different complexities. I am not sure how much to charge them. Can some one please help me in this?