var args constructors/methods vs lists

In the long debate of using arrays vs lists in the public API of Java classes, I tend to prefer lists in most situations. However, I also found convenient to use var arguments in many constructors and methods, which require declaring an argument of the method (the last one) as an array (implicitly adding "..." before the parameter name). Since in many of these methods I do want to provide a programmer the possibility to _either_ explicitly list the arguments (with var args) or use a pre-defined collection when invoking the method, I often end up defining a constructor or method with var arguments, and an overloaded version that accepts a list instead of the var args array. For example:               public void myMethod(X ...items) {           myMethod(Arrays.asList(items));     }            private void myMethod(List<X> items) {           ...       }        I know that in theory I do not need to overload the method replacing the var args array with a list if I want the programmer to send a collection of objects. He could just send an array. The reason I often do this is because most (if not all) of the methods in my API use lists instead of arrays, and it is a bit weird that for one or two methods requirying collection of objects, the programmer needs to work with arrays (in cases when the var args are not convenient). So I provide an overloaded version working with list for consistency. However, since this is a recurrent problem, I have the uncomfortable feeling of being writing boilerplate code too often. I would like to receive feedback if my motivation of keeping my interface consistent (accepting var arrays or lists, but not forcing the programmer to work with arrays if not really required) is valid enough to keep writing overloaded versions using lists for most of my methods requirying var arguments. I would like to highlight that I know that for certain methods arrays could be more convenient than lists. My question concerns situations where the only motivation for declaring the last argument of the method as an array is because in certain scenarios using var arguments can be convinient. **UPDATE** Thanks for your feedback. My conclusions at the moment are the following:   * Reduce the usage of var args as much as possible.   * Continue adding an overloaded version of the method with var args, such as the array argument is replaced by a list (or an `Iterable`, as @Kevin pointed out), in cases where it can be useful to have the choice to invoke the method with either var args or with a collection.   * Stop using Java as soon as possible :) (I already knew that one)


Shouldn't storage classes be taught early in a C class or book? I notice that a lot of books, even some of the better ones, covert it toward and end of the book and some books just add it as an appendix. I would teach it together with variables. This is so foundational and I think unfortunately many do not make it that far in a book. Now that auto has a different meaning (vs being optional) it may confuse people that didn't realize it has always been there. for example: C Programming: A Modern Approach 18.2 Storage Classes 401 Properties of Variables 401 The auto Storage Class 402 The static Storage Class 403 The extern Storage Class 404 The register Storage Class 405 The Storage Class of a Function 406 Summary 407 @DeadMG, I fear I didn't state my question properly. Everyone always uses storage classes. Every single variable in a C program has a storage class. The thing is that some of the keywords were made optional because, for example, `int i; = auto int i;` The reason I ask is because I've seen code so bad where variables are declared at the top of a program to be made available to a function and not lose its value when it goes out of scope but only one function needed it. Then, by default the variable's storage class is "extern" int i; but they may not know since extern is assumed by the compiler. What they should have done is to declare it in the function that needed it as static, static int varToKeepValue; that way you achieve the desired goal of preserving the variable's value when the function goes out of scope throughout the execution of the program, while also making the code more readable. btw: I'm interested in this, please email me your thoughts if this question gets closed. On another note: you have a very odd approach... keep learners ignorant? I think is because they don't have that information that the language is not used properly. It's not like not letting kids run with knives. My approach is, learn the language inside and out that will let you use it properly.


What capabilities of Adobe Flash are not present in the WinRT API?

As from March 2013, Microsoft allows Adobe Flash content to play by default on its immersive Internet Explorer 10: http://redmondmag.com/articles/2013/03/11/new-ie-10-flash-policy.aspx When asked about Silverlight, Microsoft says > Silverlight will not be supported in immersive Internet Explorer 10 since > these capabilities are superseded by the new WinRT API. Does this mean that there are capabilities of Adobe Flash not present in the WinRT API that forced Microsoft to allow Flash? What are these capabilities?


How does Github calculate language percentage in a repo?

I have a repo with Ruby and PHP code in it. Github says my repo is 74.8% PHP and 25.2% Ruby I do not understand how this can be. When I compare the 2 languages in my project:               # Count how many files:          # Ruby     ls | grep ".*\.rb" | wc -l     # returns 10          #PHP     ls | grep ".*\.php" | wc -l     # returns 1               # Count how many lines, words, chars:          # Ruby     cat *.rb | wc     # returns 229, 812, 5303          # PHP     cat *.php | wc     # returns 102, 473, 2760      Ruby always seems to have more. Am I missing something?


Environment Variables and Visual Studio 2012

I have a problem with Visual Studio 2012 and Environment Variables under Windows 7. I added a variable called `{LIBS}` with the value `C:/libs/`. In `C:/libs/` are folders containing C++ libraries. So far, so good. I added the paths to the project's settings (linker etc.), like `{$LIBS}boost` to include the boost libraries. I expected that I would now be able to use something like this               #include "boost/someboostfile"      but this does not work, I have to use the absolute path               #include "../../boost/someboostfile      but this is what I do not want to do. Is there anything I'm doing wrong?


How to avoid binary dependency on size change

class A { public: int i; }; // A.h and defined in project libA.vcxproj (libA.dll)      I'm using class A in multiple places at various projects as below. Apporoximately 100 projects.               include "A.h"     class UseA { public: A *a; UseA(){ a = new A(); } ~UseA() {delete a;} }      My problem is whenever I add a member variable to class A I will have to build all the projects (~100) as the size of the class A has been changed and building 100 project is time consuming. How to avoid building so many projects on size change of a single class? Also I have many classes like class A defined in libA.vcxproj.


When is it appropriate to use colour in a command-line application?

Currently I have a command-line application in C called `btcwatch`. It has a `-C` option that it can receive as an argument that compares the current price of Bitcoin with a price that was stored beforehand with `-S`. Example output with this option is:               $ btcwatch -vC  # -v = verbose     buy: UP $ 32.000000 USD (100.000000 -> 132.000000)     sell: UP $ 16.000000 USD (100.000000 -> 116.000000)      The dilemma is whether to use colour for the `UP` or `DOWN` string (green and red, respectively). Most command-line applications I know of (apart from git) stay away from colour in their output. In my desire for `btcwatch` to look and be quite "standard" (use of `getopt`, Makefiles, etc), I'm not sure if colour would look out of place in this situation.


is it possible to use shopify for just their shopping cart component or should I just roll my own

I'm working on an e-commerce site and am a rails developer; due to the nature of the items, I am managing them in their own database so I'm really looking for something that is only for the shopping cart aspect (there are things like heavy nesting and integration with other pieces of the app that would be very difficult to reproduce). It seems like there are two ways that I can go. (1) One way is rolling my own shopping cart and using something like Stripe (which I have been evaluating and am working fine with it). This literally could be as easy as creating an orders table and a line items table and a lot of front-end. (2) Or I could try to integrate into a third-party shopping cart like Shopify. I am not really sure if I can just use the shopify shopping cart or whether there is any advantage to this. If I already have most of my app done, would shopify (or another shopping cart app) provide any significant benefit (it clearly could)? Or would the integration be too much of a headache? Like for example, when a user 'adds to order' on my site, can I post to shopify and associate it with that user? thx


The Programmers Bill of Responsibilities

So, we've all heard of The Programmers Bill of Rights and XP has a similar concept. It's a common complaint these days that we hear a lot about people's rights but not so much about their responsibilities, so what should be on the programmers bill of responsibilities. That is things that they should do, which they may find unpalatable, but that which separate programmers acting professionally and responsibly, from those who do not. I'm primarily interested in the unpalatable ones and the ones which tend not to happen. That is the ones that programmers tend to shirk and avoid, rather than the ones which 90% of programmers actually want to do (such as always refactor and use source control). So, **what should be on the Programmers Bill of Responsibilities?**


Do you actually write 'clean code'?

I have seen some programmers tweaking their code over and over again not only to make it 'work good', but also to make it 'look good'. IMO, 'clean code' is actually a compliment indicating your code is elegant, perfectly understandable and maintainable. And the difference comes out when you have to choose between an aesthetically appealing code vs. code that's stressful to look at. So, how many of you actually write 'clean code'? Is it a good practice? What are the other benefits or drawbacks of this?


Find all lines segments intersections

I have a collection of lines segments, represented by an array. Ex: [3,7,13,6,9] is 4 line segments: [(3,7)(7,13)] , [(7,13)(13,6)] , [(13,6)(6,9)] , ([6,9)(9,3)] ![enter image description here](http://i.stack.imgur.com/vv0FK.png) I want to find all the lines segments intersections(not including the common point), is there any better way of doing it rather than brute force(Checking all the options with O(N^2))?


What is the best way to lead a team of 4-5 students for a summer project?

We're a bunch(4-5) of 3nd year college students about to begin our 3 months summer vacation and we would like to get going on a project. We want to make a game with XNA, it doesn't have to be big or something but we have 3 months so I'm not sure how big it can get. I plan on being the "team leader" because I have the most experience with C#/XNA and I'd like to learn how to be a team leader, this could be good training. So how should I proceed with this ? Whats the best way of leading a small team when you've never done it before ?


What is Pseudocode?

I've seen a lot of mentions of Pseudocode lately, on this site and others. But I don't get it:   * **What is Pseudocode?** For example, the Wikipedia article below says _"It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading."_ Does this mean that it **_isn't_** actually used to make programs?   * **Why is it used?**   * **How is it used?**   * **Is it considered a Programming Language?** See the above Wikipedia quote.   * **Is it commonly known/used?**   * **Anything else...** I honestly don't know where to start with this. I have Googled it and I've seen the Wikipedia article on the topic, but I still don't fully understand what it is.


Object model design: collections on classes

Consider Train.Passengers, what type would you use for Passengers where passengers are not supposed to be added or removed by the consuming code? I'm using .NET Framework, so this discussion would suit .NET, but it could apply to a number of modern languages/frameworks. In the .NET Framework, the `List<Person>` is not supposed to be publicly exposed. There's `Collection<Person>` and `ICollection<Person>` and guidance, which I tend to agree with, is to return the closest concrete type down the inheritance tree, so that'd be `Collection<Person>` since it is already an `ICollection<Person>`. But Collection has read/write semantics and so possibly it should be a `ReadOnlyCollection<Person>`, but its arguably common sense not to alter the contents of a collection that you don't have intimate knowledge about so is it necessary? And it requires extra work internally and can be a pain with (de)serialization. At the extreme ends I could just return `Person[]` (since LINQ now provides much of the benefits that previously would have been afforded by a more specified collection) or even build a strongly-typed PersonCollection or ReadOnlyPersonCollection! What do you do?


I just started a job with Scrum and something seems to be missing. I am new to Scrum

The code is a complete mess of a combination of classic ASP/ASP.NET. The scrum consist of us patching up the big mess or making additions to it. We are all too busy doing that to start a rewrite so I am wondering.. Where is the part in Scrum where the developers can have the power to say that enough is enough and demand that they are given time to start the big rewrite? We seem in an endless loop of just patching old code with 'Stories'. So things are being run by the non-technical people who seem to have no desire to push for a rewrite because they don't understand how bad the codebase has gotten.. So who is in charge of making this big rewrite change happen? The developers? The Scrum Master? The current strategy is just to find time and do it ourselves without the higher-ups involved since they are mostly to blame for the current mess we are in.. `<-` insert rant about non-technical people telling technical people what to do here `->`.


How to pass around a debug flag variable?

I need to generate debug output in a java appliation that cannot be debugged by placing break points and traces. I've thus far been placing the debug flag as a static variable in one of the classes and then accessing it from all other classes. But this I suspect will eventually cause massive issues later on. What's the best way to do this?


Univeristy Projects and Uniqueness

I am in the process of trying to identify a suitable project for my final year at university. How important is it that the project be unique? I really want to do a project with the Kinect and am eagerly awaiting the official SDK. As yet I am struggling for an idea. However, I have looked at kinecthacks.com to see what other people have been working on, and a few of these ideas interest me. Would you think it is ethical to take one of these ideas and implement yourself? Obviously one would try to implement additional functionality on top of what is already there? Thanks.


Is it good to publish the software and development technologies?

I did some research on developers in my area. I was mainly interested in their products and the kind of tools they used in building them. I want to make this information public, but I was just wondering if it is a good idea. What I mean is, if the developer used Apache, MySQL and PHP and I made this public, does it make it easier for people to hack their product?


Different callbacks for error or error as first argument?

We (and the JS SO chat room) had a talk with @rlemon some days ago about his Little-XHR library about error handling. Basically, we wanted to decide which error handling pattern should be used:               xhr.get({         // Some parameters, and then         success: function(data) {},         failure: function(data) {}     })      Or:               xhr.get({         // Some parameters, and then         callback: function(err, data) {}     })      One is more jQuery-like, while the other is more Node-like. Some say that the first pattern makes you think more about handling error. I think the opposite, since you may forget the other callback function, while the argument is always there on the second pattern. Any opinion/advantage/drawback about both these patterns?


How do you change how intellij auto formats code?

IntelliJ does some odd formatting with Javascript code and I am trying to figure out how to get it to stop formatting this way. Whenever I chain jQuery functions together, it over indents the auto created code such as this:               $('#something').focus(function() {         /* Do some stuff */     }).blur(function() {             /* this is where the cursor and closing braces end up */             })      I want it to look like this:               $('#something').focus(function() {         /* Do some stuff */     }).blur(function() {         /* cursor and closing braces indented normally */     });      How do I change this?


How to implement session state in a backend web application?

When using a non-MVC service-oriented/Interactor pattern approach to decoupled system architecture, how is session state implemented? I've been thinking of building the frontend of an application using MVC (PHP/Ruby etc.), and send messages to a command-line backend which is the actual application. Since I want the offline application to be completely in control of functionality I would imagine using an offline session management system to work best, which at login issues an ID that is thereafter sent to the application on every request. The ID would be stored in a cookie on the client-side, just like a regular session cookie. Since the frontend works through HTTP requests anyway it makes little sense to do it any other way to me. Are there any better alternatives to this method that I should consider? I would prefer to keep the actual system completely decoupled from the web UI and also plan on implementing a desktop UI aswell, so the Interactor pattern seems to be the best way to achieve this to me. What I'm explicitly trying to avoid is the "do everything in our MVC framework! (and be stuck forever)" that seems to be popular nowadays.


Algorithm to optimize grouping

I would like to know if there's a known algorithm or best practice way to do the following: I have a collection with a subcollection, for example:               R1 R2 R3     -- -- --     M  M  M     N  N     L  L        A      What i need is an algorithm to get the following result:               R1, R2: M N L     R2: A     R3: M      This is -not- what i want, it has more repeating values for R than the above:               R1, R2, R3: M     R1, R2: N L     R2: A      I need to group in way that i get the most optimized groups of R. The least amount of groups of R the better so i get the largest sub collections. Another example (with the most obvious result):               R1 R2 R3     -- -- --     M  M  A     V  V  B     L  L  C      Should result in:               R1, R2: M V L     R3: A B C      I need to do this in LINQ/C#. Any solutions? Tips? Links?


Why can't we use unique identifier as combination of email and password?

For prevent email conflicts for authentication system we can surely choose email and password combination as unique identifier. What can prevent me to built authentication system by treating unique identifier as combination of email and password ? What is wrong with this design ?


What data structure could a word processor use to map the user's caret position/text selection to its internal representation of the document?

Word processors (e.g. Microsoft Word) display documents to the user as styled text. The user can select a part of this text and apply styles to it, and edit the text. The word processor must (I guess) have an internal representation of the document that indicates which bits of the text displayed to the user should be styled differently. But the user doesn't interact with this internal representation. They interact with the text, by using the caret and selecting portions of it. What data structure might the word processor use to efficiently map the text with which the user interacts to its internal model of the document?


Motivation and pitfalls (?) of the auto keyword in C++11

I was recently wondering why the keyword `auto` was chosen in C++11 to mark a variable whose type must be inferred by the compiler, like in               auto x = 1;      Since   1. `var` seems more common in other programming languages (e.g. C#, Scala, JavaScript), and   2. As far as I understand the new semantics of `auto` breaks backward compatibility (it was rarely used but had a different meaning in previous revisions of C++, see e.g. here) I wanted to ask if there was a special reason for choosing `auto` (in favour of `var` or any other keyword). Was there any specific discussion about this issue before the C++11 standard was released? Also, are there any possible incompatibilities we should watch out for when recompiling legacy C++ code with a C++11 compiler?


Using my own code in freelance projects

I have been into freelance business for more than 2 years. While doing projects for other people, I've build a compilation of common tasks that I implement in projects and put them into code. It's kind of a library with some functions that I can reuse without having to rewrite the same thing dozen times. I'm talking about accessing Access databases, downloading information from FTP and similar stuff. Is this acceptable from a legal point of view? What's the difference in reusing the old code and rewriting it from the scratch (using you own brain again, therefore the exact same logic)? I do not hold any copyright to it, of course, and provide the source code for these classes to my clients.


Windows Hibernate API

Is it possible to programmatically trigger the Windows's Hibernate without actually Hibernating, just to take snapshot of the OS at regular intervals? So that the system can return to the previously saved state in case of any failure. This is much like System Restore, which backups system files; but the idea is to backup the complete OS's active state.


Pushing for greater automated testing on a QA team

I'm a junior developer joining a QA team at my company. The QA team I had been interacting with while working as a developer was very solid and the business had been very good about encouraging and funding good, solid automated testing techniques and hiring people who were good at it. However, this new team I am joining looks like it might be a little more reactive in nature, blending some of the testing responsibilities (as I understand them) with ops work and not doing a lot of proactive regression testing. I'm hoping dearly that I am wrong, but the fact is I could be right as well. Does anyone have any good advice for promoting automated testing? Bear in mind that I'm not a manager or lead, and also not even an experienced tester. But on some level, it feels like some of these principles should fall into common sense. Am I wrong for thinking that? If not, what should I do?


Getting overwhelmed after starting a new project

I started a project (a Windows based timetable program that helps you stay organised with your subjects and assignments). The problem is that I'm not sure how I should manage this project and what order to build things. I.e. Should I build all the different interface elements then write the code or should I make an interface, code it, make another interface then code that? So my question is; how do I split up this longish project into small, ordered pieces to complete; and how should I order this?


Designing an API on top with Java RMI and Rest APIs

I'm working on the backend of a java web application. We have a document repository (Fedora Commons specifically) where we house xml files. I want to abstract the API of the repository internally so that we aren't tightly coupled to one product. I'd also like to give the flexibility of connecting to to a repository via Java RMI or REST APIs. I was hoping to get advice or resources on how to implement something like this. My thought it that I'd have some abstract repository class that had methods like getRecord, updateRecord, and deleteRecord. In the constructor I would pass the URI for the repository and the API method and port. This would allow some flexibility in the future so that if the REST api became more practical, but allow the flexibility or using RMI which could (should?) have better performance. Am I over thinking this or am I on the right path?


Mixing Angular and ASP.NET MVC/Web api?

I come from using ASP.NET MVC/Web API and now I am starting to use Angular but I am not clear on the proper way to mix them. Once I am using Angular does the MVC sever side concepts still provide any value ? Or should I strictly be using Web API purely to get data for the angular HTTP calls ? Is there maybe a more stripped down starting point I should use if the VS template is adding a lot of stuff I don't need ? I like the idea of a strict divide of server side = pure data and client side = pure HTML processing Any tips you have for a ASP.NET MVC guy transitioning to Angular would be helpful


Working with Multiple XML Schema Classes in C#

I'm working with a data import process in C#, which takes a zip file filled with XML files and saves specific data points into a database. This is accomplished by loading the XML data into classes compiled from the schema. The import logic retrieves the data by digging down into the right classes and fields. The XML schema is defined by a different company, and the schema changes every one to years when an updated version of their software is released. What my company would like to do is be able to import different versions of the schema so that we could support older files. There is also debate on whether this change is worth the effort. My plan to accomplish this would be to determine which schema to use at the beginning of an import, and then use different interfacing classes to get the data from the XML and pass it back to the import classes, which would then save the values to the database. There are over 200 classes generated based on the schema, but we only need to access data in about half of them. Are there other ways to approach supporting multiple XML schemas that may be easier?


Standard/Proper way of counting lines of code?

How should I count the lines of code in a project? In C++ for example, should I count the lines of the header files with my class definition? Should I count the header of a (non standard) library I am linking against? In Qt (or any other GUI framework), should I count the lines of the form's design? Should I count the Makefile too? I ask because it is a simple way to measure the size of the project and/or effort involved. Even though a GUI file is not code _per se_ the programmer might have spent hours doing it. **EDIT** Most of you did not understand the question and/or are assuming that I want to use the magical number of LOC as the ONE AND ONLY metric to rate a project or even a day of work. I consider a negative LOC day a very nice day. It means I've somehow managed to understand and model the problem better and more efficiently. Comments like "Why do you need this" are not interesting. Like it or not, the number is out there, Wikipedia says Windows XP is rated at 45M LOC, Linux 2.6.35 at 13.5M, I could go on. Maybe I could have asked better. Anyway, my original intent was to know how those numbers in Wikipedia were calculated and not the subjective nature of them. I found this in a MSDN blog, very useful as it shows how VS2008 does it: ![enter image description here](http://i.stack.imgur.com/KKXGQ.png)


Build times for small incremental changes to C# Web Applications

I have recently been moving away from ASP.NET Websites in favor of Web Applications. More specifically I have recently been picking up MVC as an alternative to developing ASP.NET Forms websites. Something that I find highly frustrating is the constant build->change->re- build process when testing small changes to compiled code. I find myself 'bundling' several changes between builds just to avoid waiting 20-25 seconds for Visual Studio to crunch it's way through the compilation process. I created a clean MVC 4 project from the VS template and timed the build after making a single line code change, it took 19 seconds. When making a change in the code-behind in an ASP.NET website I've always found that the page is seemingly re-compiled on the fly when you next hit the page. This would seem to me to be a better environment for web development rather than VS forcing an entire rebuild after every small code change. In the past I have enjoyed the luxury of making a change, hitting refresh in the browser, and waiting 1-2 seconds for my result. Is this achievable with web applications built using Visual Studio?


HTTP PHP Authentication and Android

I am working on a website for which I hope to have an application for as well. Because of this, I am creating PHP API's which will go into my Database and serve specific data based on the method/function called. I want to protect these API's from misuse however, and I plan on implementing Authentication Digest to do so. However one of the OS's I want to support is Android. And I know that a malicious user would be able to reverse engineer the Android app and figure out my authentication scheme. I am left wondering:   1. Is there a better way to protect these API's from misuse?   2. Is there a way to prevent a malicious user from reverse engineering the app and potentially seeing the source code for it, enabling them to see my authentication scheme?   3. If none of these are preventable, then is my only option to have a Username/Password cred specifically for the Android app, and when eventually hacked, change the creds and issue an update for the app?


Diving into microcontroller programming

I just got a batch of LED matrix modules from Sure Electronics (http://www.sureelectronics.net/goods.php?id=1120) and a driver board (http://www.sureelectronics.net/goods.php?id=972). I've got it wired up, and connected to my Mac. I found the right drivers, and I'm now able to send text to the displays using the virtual COM port, as per the documentation from Sure Electronic's website:               start with "0xFE,0x47 (G) 0x01,0x01" followed by 16 characters - display the 16 characters in the first row     start with "0xFE,0x47 (G) 0x01,0x02" followed by 16 characters - display the 16 characters in the second row      The plan is to hook it all up to a Raspberry Pi (when I eventually get one) and use it all to display information from a web service. However, this setup is not optimal. The driver board requires some initialization each time it is powered up, in order to be available via USB. Also, I'd like more control over the display of characters (this setup, for instance, does not support non-ASCII characters, or text scrolling). Heavy googling has led me to believe that I need to go deeper into the HT1632 chip on the driver board. The documentation from Sure Electronics is sparse. The goal would be to be able to address each LED pixel individually from my code running on my computer (as in a 2D array of booleans, for example). I'm totally new to micro programming, so I have no idea where to start. What do I need to do in order to program it? Can I even modify the code of the driver board, or do I need another kind of driver board? And how do I automate the boot up sequence, so that the board is automatically USB enabled? Also, I'm mostly a Java/Web developer guy, so I would like to avoid as much C programming as possible. If anyone with experience with this kind of programming could point me in the right direction to start, I would be grateful.


Does the lack of states on HTTP make the protocol unfit for modern applications?

I changed from PHP to ASP.NET, now I’m working with webforms in a somewhat large company. I given some though and research to back my impressions on ASP.NET webforms and I came to the conclusion that Webforms is an attempt to make web applications easier to write for those who came from the "desktop programming" world. But before shunning WebForms I decided to analyze the needs of the software we write and bumped on the issue of maintaining application states on the Web. I understand that HTTP is a stateless protocol, and ASP.NET tries to simulate states with session variables , hiddenfields and viewstates, it is in my understanding also that all of the above cited have flaws and are not perfect ways to keep the state in my application, But I also understand the need to keep a state on my app. Which raises the questions, is the HTTP really fit for this type of job (making applications that require state)? Are the tools currently available to webdevelopers enough? Are the new tools available with HTML5 effective at the job or are they just workarounds for the limitations to HTTP. I love developing for the web, and I’m much more familiar with the web than with the desktop, I just been wondering about this HTTP statelessness thing for some time and i want to understand if I’m missing some point or if I’m right on my notions.


is it possible for the author to trademark the name of an open-source application?

I would like to know if the name of an open-source application can be trademarked by the original author and what it means when it comes to distributing it through major linux distros, that is, will they accept this kind of software?


How to efficiently store IP addresses?

**Background**   I have a requirement where I need to remove a few nodes in a network based upon a command given by the user. To keep the nodes from transmitting or receiving data I thought of changing its IP address to some other address. Before I change the address I want to save the node's IP so that I can re- assign the original IP back to the node after the simulated network outage is over. My problem is how to efficiently save the nodes' IP addresses. Should I use a linked list or a hash table?


What programs emit C++ code and pass it to mainstream compilers?

I suspect there're programs that instead of emitting machine code instead emit C++ code and then start a mainstream C++ compiler to compile it to machine code. I can't find any notable examples except MIDL which emits some rather primitive code. What are notable examples of such systems?


Storing Dynamic SQL in text files vs inline code

Our Architecture team is proposing a framework that would see our SQL queries moved from coded strings within our applications, into a file based system where we would invoke them with function calls. Our application makes heavy use of SQL queries ranging from the mundane, to very complex. This is a .NET solution. The idea is that each query would be written to text files, and we would be able to tag fields, joins, and conditions with attributes. When calling our SQL functions, we could pass arguments to toggle these attributes on/off based on our business logic, allowing for only the portions of the SQL we need to be executed. Although I like the idea of abstracting away our SQL, I am skeptical that this system will result in any tangible benefits. The major driver of this is our past experience where many coders created some massively bungled dynamic SQL functions which were impossible to understand. The idea is that this will make it easier to define your queries, will make all queries more easily testable, and clearly define the business logic involved. I am unsure if this will survive the test of reality. I’d like to get some feedback on the pros/cons of this approach. Also, before anyone suggests it, the Entity Framework was rejected due to questionable support from our database provider (Teradata).


Calculating local results from global values using SQL and PHP

I have an interesting problem for you all. I have a partial solution but I feel you guys can come up with an efficient solution. What I have a SQL table with following structure: StockId <\- a unique ID for the share StockHolderId <\- a unique ID for the share holder StockPrice <\- The price of the stock - if this is a request to purchase this is kept -1 BuyingorSelling <\- value of 1 means the holder wants to buy, value 2 means he is selling StockQuality <\- a special record that stores a value calculated based on some complex computation. The values are 1, 2, or 3 based on let us say bad, neutral, good. What I want to do is to find out who all can give me the stock I want to buy and who can purchase the ones I got. I want the person who gives a good quality stock (local value) at cheapest price (global value) to be my best selling match and the person who can buy most (semi global) of my stocks to be my best buying match. The formula to rank the seller is 0.5 * price + 0.3 * availability + 0.2 * quality. How would you go about it? Any ideas? I have created a table that joins with itself to get info of every match and then grouping but how can I acquire the price value to be cheapest?


Objective-C Categories and Sprawling Classes

The generally accepted programming practices I've come across tend to advise against big, sprawling classes. Does using Objective-C categories change the conventional wisdom somehow? Is it more acceptable to have bigger classes if each "subclass" or set of tasks is in its own category? In my own experience, I've found that where I might've in the past tried to split classes, I now sometimes find it easier and rather maintainable to just split categories, but am I setting myself up for future maintenance hell (or other kinds of hell) by doing this?


Licence all code?

Should every piece of code put online have a licence with it, or should it explicitly mentioned that it is in the public domain? I'm writing a simple python script that will take a project euler problem number and save a file with the question text as comment. As I was creating the directory and initializing git I added a licence file, which got me thinking is it even necessary to put a licence for something so simple. So, should every project no matter how trivial have it's licence explicitly mentioned or is it just overkill to put a licence with such small scripts? What is the recommended practice here?


Data Structures usage and motivational aspects

For long student life I was always wondering why there are so many of them yet there seems to be lack of usage at all in many of them. The opinion didn't really change when I got a job. We have brilliant books on what they are and their complexities, but I never encounter resources which would actually give a good hint of practical usage. I perfectly understand that I have to look at problem , analyse required operations, look for data structure that does them efficiently. However in practice I never do that, not because of human laziness syndrome, but because when it comes to work I acknowledge time priority over self-development. Over time I thought that when I would be better developer I will automatically use more of them - that didn't happen at all or maybe I just didn't. Then I found that the colleagues usually in the same plate as me - knowing more or less some three of data structures and being totally happy about it and refusing to discuss this matter further with me, coming back to conversations about 'cool new languages' 'libraries that do jobs for you' and the joy to work under scrumban etc. I am stuck with ArrayLists, Arrays and SortedMap , which no matter what I do always suffice or either I tweak them to be capable of fulfilling my task. Yes, it might be inefficient but do we really have to care if Intel increases performance over years no matter if we improve our skills? Does new Xeon or IBM machines really care what we use? What if I like build things, but I am not particularly excited whether it is n log(n) or just n? Over twenty years the processing power increased enormously, which gives us freedom of not being critical about which one to use? On top of that new more optimized languages appear which support multiple cores more efficiently. To be more specific: I would like to find motivational material on complex real areas/cases of possible effective usages of data structures. I would be really grateful if you would provide relevant resources. There is similar question ,but in the end the links again mostly describe or do dumb example(vehicles, students or holy grail quest - yes, very relevant) them and people keep referring to the "scenario decides the data structure to use". I want to know these complex scenarios to be able to identify similarities to my scenario and then use them. The complex scenarios where it really matters and not necessarily of quantitive nature. It seems that data structures only concern is efficiency and nothing else? There seems to be no particular convenience for developer in use one over another. (only when I found scientific resources on why exactly simple carbohydrates are evil I stopped eating sugar and candies completely replacing it with less harmful fruits - I hope you can see the analogy)


Implementing the command pattern in a RESTful API

I'm in the process of designing an HTTP API, hopefully making it as RESTful as possible. There are some actions which functionality spreads over a few resources, and sometime needs to be undone. I thought to myself, this sounds like a command pattern, but how can I model it into a resource? I will introduce a new resource named XXAction, like DepositAction, which will be created through something like this               POST /card/{card-id}/account/{account-id}/Deposit     AmountToDeposit=100, different parameters...      this will actually create a new DepositAction and activate it's Do/Execute method. In this case, returning a 201 Created HTTP status means the action has been executed successfully. Later if a client wishes to look at the action details he can               GET /action/{action-id}      Update/PUT should be blocked I guess, because it is not relevant here. And in order to Undo the action, I thought of using               DELETE /action/{action-id}      which will actually call the Undo method of the relevant object, and change it's status. Let's say I'm happy with only one Do-Undo, I don't need to Redo. **Is this approach ok?** **Are there any pitfalls, reasons not to use it?** **Is this understood from the POV of the clients?**


How to speak to a computer

I am a self-taught, novice programmer. The language I chose was Objective-C, so that I can write Apple applications and software. I have learned the hard way that Objective-C has a steep learning curve, but I have forced myself to look at it over and over until I get it right. I feel I am completing one major step, and that is becoming very comfortable with the syntax. Now as I enter the next big step - finding out what is possible with a computer programming language - I am thinking that all software is just developed within the confines of:   * classes   * loops   * booleans   * IF/OR statements   * variables   * etc.  Is that a true assessment? When thinking of software in my head do I just need to learn to convert it all to the above? Right? Sorry if this question sounds funny, but I am just learning how to take the language in and talk (what I think is) the language of a computer. Is there a good book or tutorial that helps illustrate how to "speak as a computer would"?


Should I Do Calculations in T-SQL or Program?

I am creating a stored procedure that is logging some data. The data ultimately needs to end up in 2 tables. The incoming data is coming from a JSON string containing 15 parameters, and the data is then logged to the database using the stored procedure I'm writing. I would like to send the data into 1 stored procedure and INSERT it into both tables. The first table is a raw data logging table. It will be used for debug and troubleshooting. The second table will be used for report generation. This table requires some simple mathematical calculations to be done on incoming data. For example: `DECLARE @Table2Fld3 DECIMAL = @IncomingFld9 - @IncomingFld4;` I'll have about 8 of these calculations to do to compute the values for table 2, then I'll do an INSERT to save the data. So my question is, is it a good practice to do these calculations in the T-SQL? Or would it be better for me to create 2 separate stored procedures and do the calculations in my code? One trade-off I see is that if I do it all in the code then I have to create 2 database connections. **EDIT** I should elaborate on the "2 database connections" comment. The application in question is a windows service that establishes multi-threaded server/client communication. The logging system is asynchronous to the server/client communication. Using that existing system, in order for me to target multiple stored procedures, it would require 2 calls to the logger which would spin up 2 connections to the database.


Why are inheritance and interfaces restricted to instance members?

Disclaimer: I think the rules are almost the same in most OO languages, but since I'm most familiar with C# I'll be relating to this specific language. I think that the use of attributes and reflection could be largely reduced if static members would apply the same principles as OO instances. Static properties and methods can be "overridden" by decedents by using the new keyword, but they cannot be forced to implement one via an interface, neither can the 'base' keyword be used (only explicitly naming the base type is supported). To make things worse, the members cannot be referenced via an instance, but have to always be specifically qualified with the exact type. Constructors also have limited "inheritance" support, one can choose which base constructor is called, but you cannot force an object to support a constructor that takes certain parameters by defining it in an interface. The best hint I could find to answer this question so far is this one on stack overflow (answering a different question). In his answer Jörg points out three principals that apply to Object Orientation:   * messaging,   * local retention and protection and hiding of state-process, and   * extreme late-binding of all things. Now I fully understand that if you want to pass on a state-full class from one method to another as an object, these principles make sense. However in my opinion the principle of inheritance, overriding base methods with alternative or additional functionality, could also be beneficial to stateless business logic. One example where forcing an object to implement a certain constructor would be helpful is with de-serialization. For example where the constructor should accept an XML node. In C# it is dynamically implementable using reflection, but having compile-time errors and avoiding the reflection boilerplate would add lots of value! Static method/member interfaces would be helpful in situations where some aspects of a value are type specific, without any relation to the instance. For example a class could have a DisplayName, Unit, Weight, Factor or other aspects that are the same across all instances of the specific type, regardless of the instance value. Attributes (or Annotation) can be used to exploit these without the need to create an instance, however, there again it's extra boilerplate code and no way to enforce their implementation with compile-time errors. I admit there are many simple ways to work around these points, I'm not looking for workarounds. Returning a static value in an instance-property is quite common, and it is not that much overhead to create an instance of an object just to read out the type-specific aspects, but I'd like to know the rationale background on why static things have been systematically excluded. I have heard about "the virtual stack" before, but don't really know how it works technically (and cannot find any simple explanation on the net). Are the reasons of technical or philosophical nature? * * * Edit: elaborating on static interfaces: An example of how I think a static interface could provide a strongly typed, compiletime checked, alternative to reflection:               public staticInterface MyStaticInterface     {         constructor(XmlNode node);         string DisplayName { get; }         int Weight { get; }     }      The usage:               public void FillNodesToolBox()      {         MyStaticInterface[] nodes =              assembly.GetTypes().Where(t => t.Implements<MyStaticInterface>());              for (int i = nodes.Length - 1; i >= 0 ; i--)         {             Console.WriteLine(string.Concat(                 nodes[i].DisplayName, " (", nodes[i].Weight.ToString(), ")"));         }     }      Looking back, this actually looks like making my Type object inherit from System.Type, adding some properties to it, which is different than a static member... `string.Empty != typeof(string).Emty` (the latter will not compile). Maybe I'm starting to find the answer, but it feels like I'm walking in a paradoxical circle, it doesn't quite 'snap' yet....


Teaching `class`es and objects in C++ to university students

To learn `class`es and objects at my university, students are required to develop a simple game (nine-mens morris or something similar) using Java. Java is used because of its libraries and tool support. What is the counterpart for C++. * * * _Background_ : I am a researcher at a university working with drones. The programming language for the research group is naturally C++. However, like most universities the introductory language of choice where I work is Java. The problem is when the students join the research group, it is hard work to "unlearn" Java for C++. IMHO, it hurts more than it helps. I want to propose teaching C++ instead; but I need to offer an alternative for learning `class`es and objects.


Simple, permanent queue system with pub/sub for Node.js?

> Highly related Nodejs: many clients requests through one socket I'm investigating a robust message passing system for this application of mine. The easyest solution would be Redis pub/sub (it's simple, effective and I'd also use Redis for caching) but as I understand it, publishing is a "one shot" operation only to actually subscribed clients. Whoever subscribes after the publishing, does not get the message. I'd like to be able to "stash" unreceived messages for a while, so if I reconnect to the channel I'd get back the messages I've not received. I know that systems like ActiveMQ with the ack and permament queue mechanism would solve this issue easily, but I'm wondering if there could be a simpler solution/approach. What do you think?


Webservice Return Generic Result Type or Purposed Result Type

I'm building a webservice which returns JSON / XML / SOAP at the moment.. and I'm not entirely sure which approach for returning results is best. The Client Consuming the Services will generally be Web Applications / Mobile Web Applications. But could be from various WordPress and other social media Plugin type systems. Which would be a better return value? A generic "transfer" type structure, which carries Generic properties or a purposed type with distinct properties:               class GenericTransferObject{         public string returnVal;         public string returnType;     }      VS               class PurposedTransferObject_1{       public string Property1;     }          //and then building additional "types" for additional values     class PurposedTransferObject_2 {       public string PropertyA;       public string PropertyB;     }      Now, this would be the serialized and returned from a web service call via some client technology, JQuery in this example. SO if I called: /GetDaysInWeek/ I would either get back: {"returnType": "DaysInWeek", "returnVal": "365" } OR {"DaysInWeek": "365"} And then it would go from there. On the one hand there's flexibilty with the 1st example. I can add "returnTypes" without needing to adjust the client other than referencing an additional "index".. but if I had to add a property, now i'm changing a structure definition.. Is there an obvious choice in this situation?


Code formatting SQL queries

Should I break SQL queries in different lines? For example in the project I am working on, we have a query that is taking 1600 columns! 1600 + tab chars. I wrote queries like this:                  "SELECT bla , bla2 , bla FROM bla " .           "WHERE bla=333 AND bla=2" .            "ORDER BY nfdfsd ...";      But they demanded me to put them in one line and said that my style is bad formatting. Why it is bad practice?


Formatting SQL statements

In recent years I've developed a habit of formatting SQL `SELECT` queries like so:               SELECT         fieldNames     FROM         sources         JOIN tableSource ON col1 = col2         JOIN (             SELECT                 fieldNames             FROM                 otherSources          ) AS subQuery ON subQuery.foo = col2     WHERE         someField = somePredicate      So you see my pattern: each keyword is on its own line and that keyword's fields are indented by 1 tab-stop and the pattern is used recursively for sub- queries. This works well for all of my `SELECT` queries, as it maximizes readability though at the cost of vertical space; but it doesn't work for things like `INSERT` and `UPDATE` which have radically different syntax.               INSERT INTO tableName            (  col1,   col2,   col3,   col4,   col5,   col6,   col7,   col8  )     VALUES ( 'col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8' ),     VALUES ( 'col1', 'col2', 'col3', 'col4', 'col5', 'col6', 'col7', 'col8' )          UPDATE tableName     SET         col1 = 'col1',         col2 = 'col2',         col3 = 'col3',         // etc     WHERE         someField = somePredicate      As you can see, they aren't as pretty, and when you're dealing with tables with a lot of columns they quickly become unweildly. Is there a better way to format `INSERT` and `UPDATE`? And what about `CREATE` statements and other operations?


How to integrate technical line/functional manager into Scrum team?

We have recently had a new line manager start to manage our Scrum team. He is immensely experienced in our field but is relatively inexperienced at Agile/Scrum. He has extensive technical expertise in embedded software (the team's domain) that would go to waste if not utilised properly. However, the team is wary of making a line manager part of the Scrum team. The general consensus is that the line manager should not be part of the Scrum team at all. There are a number of issues that may crop up, e.g. the team may start "reporting" to the manager (i.e. a daily status update!), the manager may start to micro-manage team members etc etc. As it currently stands, he has already said that he feels like an outsider within the team. We really want to make use of his technical skills, we'd be foolish if we didn't because we are a relatively inexperienced and young team of twenty somethings. What would be the best approach to integrate a senior "technical" line manager in a Scrum team and make him feel like he _is_ part of the team?


Equivalent of SOLID principles for functional programming

I've found the SOLID principles quite useful when thinking about object- oriented design. Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?


Test Driven Development Code Order

I am developing my first project using test driven development. I am using Zend Framework and PHPUnit. Currently my project is at 100% code coverage but I am not sure I understand in what order I am supposed to write my code. Am I supposed to write my test FIRST with what my objects are expected to do, or write my objects and then test them? I've been working on completing a controller/model and then writing a test for it but I am not sure if this is what TDD is about. Any advice? For example, I wrote my Auth plugin and my Auth controller and tested that they work properly in my browser; then I sat down to write the tests for them which proved that there were some logical errors in the code that did work in the browser.


Rendering trillions of "atoms" instead of polygons?

I just saw a video about what the publishers call the "next major step after the invention of 3D". According to the person speaking in it, they use a huge amount of _atoms_ grouped into _clouds_ instead of polygons, to reach a level of _unlimited detail_. They tried their best to make the video understandable for persons with no knowledge of any rendering techniques, and therefore or for other purposes **left out all details of how their engine works.** The level of detail in their video does look quite impressive to me.   * How is it possible to render scenes using custom atoms instead of polygons on current hardware? (Speed, memory-wise)   * If this is real, why has nobody else even thought about it so far? I'm, as an OpenGL developer, really baffled by this and would really like to hear what experts have to say. Therefore I also don't want this to look like a cheap advert and will include the link to the video only if requested, in the comments section.


How do I demonstrate my web development experience?

Web designers generally need to have a decent portfolio of websites to demonstrate their ability. It seems web developers should have a similar portfolio, but any portfolio website a web developer might put together might never be as flashy as a web designer's, whose main goal is to show off good design. Is it necessary to have a list of websites I can point to when talking about my experience? Or are there other ways to demonstrate my experience, like perhaps a blog that talks about the concepts I'm interested in?


Mixed licencing for an application

I'm currently writing an application which I am thinking of open sourcing once I'm out of beta. However, I would like to maintain ownership of the icons and other graphics (they're actually the work of someone else that I'm paying to do). Does the GPL allow this kind of mixed licencing? Or is it all or nothing? Are there alternative licences which allow the source code to be released while not allowing images to be modified or reused?


Should we mock entities and value objects when doing DDD?

After reading a few articles about **Newable** vs **Injectable** objects and how these concepts relate to DDD's services, entities and value objects, I was left with some doubts about using newables in my code especially in my unit tests. Main candidates for newables were Entities and Value objects meaning that instead of injecting these dependencies into other objects one should just `new` an instance of these objects and use them directly in the code. However, good DDD practices advocate assigning responsibilities to entities and value objects if they were deemed appropriate. So the entities and value objects will end having some serious business logic in them. Now if a service operates on an entity or a value object should I mock the entity or value object and pass the mock to the service (mocking will require an `interface` for the value objects or entities which seems to be advocated against) ? Or should I just `new` an entity/value object and pass a concrete implementation to the service and thus violating the unit testing principle of testing only one unit?


Looking to create a custom, graphical editor for a data model using HTML5 and SVG

I need to create a graphical editor for our data model that works in an HTML5 compliant browser. I am looking for a proper library/framework to build on. The model is stored as xml, but that should be largely irrelevant for the front-end technology. To be more concrete, I am looking to build a kind of diagram editor to create boxes and lines. Each box will have a set of editable properties and a set of relationships to other boxes represented as lines of various kinds (think UML class diagram, but a bit more complex). It must be possible to edit each box's properties through the editor. I require a kind of toolbar from which users can select new boxes to create. Lastly, I would like an automated layout engine, but the user should be able to override through drag and drop. Eclipse GEF is a good example of the kind of framework that I am looking for. It provides a tool palette, layout managers, drag and drop support, and an MVC architecture. However, I need this to work in a browser, not as a Java-based RCP app. There are plenty of excellent JS libraries out there for displaying data (like d3 and jqplot). And I have started prototyping in d3. It is a powerful and flexible library, but also low-level. It seems to me that I would need to implement my own toolbar and drag-and-drop capabilities for example. This is something that Eclipse GEF provides out of the box. Do I need to implement all this functionality myself or does there exist a library or framework that is more appropriate for my goal?


How to manage a copyright notice in an open source project?

I'm working on, and adding to, a GitHub-hosted project that includes this LICENCE.md (apparently the MIT licence verbatim):               Copyright (c) 2012 [Acme Corp]          Permission is hereby granted, free of charge, to any person obtaining a copy     of this software and associated documentation files (the "Software"), to deal     in the Software without restriction, including without limitation the rights     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell     copies of the Software, and to permit persons to whom the Software is     furnished to do so, subject to the following conditions:          The above copyright notice and this permission notice shall be included in     all copies or substantial portions of the Software.      I've made changes, improvements etc (say 10% of the code, in ballpark figures) and publish the code to my own GitHub fork. What should I do with this copyright notice? I'd like to update it (eg, just to add the name of my own organisation), but it says not to. How are these things normally managed? Add a separate copyright file?


Does hybrid hard drive improve programming experience?

I'm tired of how luggish my developments PC is. It's Core2 Duo, 2GB RAM, Seagate ST3500320AS HDD - not the top model, but quite a decent one. Typically I open several copies of Visual Studio 2008, lots of tabs in Firefox, Outlook, MSDN, plus the programs I debug are quite huge, plus whatever Windows thinks it can't live without so I end up with Task Manager showing something like 2,5 GB pagefile usage. All the software above becomes luggish to such extent that it's really annoying. Something like I click on a menubar in Visual Studio - and instead of just opening the menu it works the harddisk for say 10 seconds. I'd like to have some magic "don't make me think" solution - so that it is installed once and then the lugs disappear or at least decrease significantly. It should not be very expensive - something like the current price of a hybrid drive. Will a hybrid drive magically help overcome my problem once and for all? Do you have experience using hybrid drives for similar purposes?


What's the Best Way to Release a Small Open Source JavaScript Library?

I wrote a nice little open source CoffeeScript color library called color. I think it's handy, and I believe other people would find it useful. What's the best approach for letting the world know about it?


Converting ANTLR AST to Java bytecode using ASM

I am currently trying to write my own compiler, targeting the JVM. I have completed the parsing step using Java classes generated by ANTLR, and have an AST of the source code to work from (An ANTLR "CommonTree", specifically). I am using ASM to simplify the generating of the bytecode. **Could anyone give a broad overview of how to convert this AST to bytecode?** My current strategy is to explore down the tree, generating different code depending on the current node (using "Tree.getType()"). The problem is that I can only recognise tokens from my lexer this way, rather than more complex patterns from the parser. **Is there something I am missing, or am I simply approaching this wrong?**


Software development project inception phase

Currently our team develops Web Applications and now we are going to Windows Forms applications. I have created the inception phase for our Windows Forms project structure. eg:               ApplicationSolution          --> Security Project(Login Authentication)                    a. Users will be registered with different applications in our application database.                eg: ProjectApplicationId|ProjectName        | UserId                    1                   |ProjectApplication1| user                    2                   |ProjectApplication2| user                    b. Execute Application (Start)               c. On Security dialog, application automatically get the userid of the user and see all the application it is registered using System.Security.Principal.WindowsIdentity.GetCurrent()                eg: Prototype                   Welcome User! Please Choose Appliations you are registered on below:                                      ProjectApplication1 <--this will be a dropdown                                      ProjectApplication2                   Password: [*********************]                   [Access Application Button]               d. User selects the application with its password              e. If the password is incorrect (application.exit()) else execute Selected Application                   eg: ProjectApplication1 is selected then execute ProjectApplication1          --> ProjectApplication1          --> ProjectApplication2          --> Many to come ++                  if ProjectApplications has been closed then restart security Application.      My questions on this use case:   1. Is my use case possible?   2. Can you give me any recommendations ?  Currently we use setup and deployment to create installer in each Windows Forms application.


Polymorphism confusion

I have read once in a book about exception where "an object of type Exception can be an instance of any subclassof Exception". I kinda get it, but there's still confusion can anyone clarify me the meaning of this?


What should I learn, practice to grasp or follow the fashion of the Web UI development?

I am not totally a Web UI developer, indeed I am doing some work about deployment. But I have interests in the fantastic effects of some great website. I know a little about javascript, jquery, extJS, Ajax or Flex are doing this kind of fantastic work. What bothers me:   1. Is there other techniques doing this kind of work?    2. Which should I dig deep in?    3. How can I effectively improve the techniques in that?


Arguments for and against backwards compatibility for new iOS projects

At the time of writing, iOS 6 has been available for about 3 months. In the proposal-phase of a new iOS project, the client asks for backwards compatibility of the app involved, all the way back to iOS 4.0. With the current timeline this app is scheduled to be launched in september 2013, close to the probable release of the next iOS version (most likely 7.0). My gut tells me it's ridiculous to support iOS 4.0, and senseless to support iOS 5.0 for this project. By september 2013 the majority of all app-savvy iOS users will either own an iOS-6-only device (like iPhone 5, iPad 4/mini) or will have upgraded to the latest iOS version. In addition to the statistics, I have the feeling that the people left on prior iOS versions will probably not be on the prowl for the latest and greatest apps anyway, therefore not of interest to the client. However, these are guesses at best, and _I'm having difficulty backing up my guesses with solid references by authoritative sources_. Do you know of authoritative sources (like Apple or major app studios) voicing their opinion on backwards compatibility **for iOS** and could you provide one or more links? I'll award the most authoritative question with the 'correct answer' check mark.


Considerations on which Java version to run in Production

Some people run the bleeding edge of technologies - updating the day that something is updated. In production, this isn't as appropriate. Researching about if the current (Java 7) version is ready for production produces a significant amount of old material that might not be correct anymore (at the time of this writing Java 7 has been out for a year and a half which seems plenty long). What considerations do I need to make to determine if it is appropriate to upgrade the production environment to a later version of Java?


Service method, bean as an argument and mandatory attributes

There is a service:               createUser(User user)      where you can create a new user, with so many attributes (`name`, `address` lines...). Now, some user attributes are mandatory. Other attributes are not mandatory (like `nickname` or `image`). The problem is that, from the outside, you can't tell the difference (in compile time). You can't force yourself to set only mandatory fields; moreover, the list of mandatory fields can change in the future and your code will stop working (while still compiling). So we can   * `createUser(int userId, String username...)` \- explode the bean properties and don't use bean as an argument. Now every change will be reflected in the API, but method signatures may become huge. Also, when overloading methods for various combinations of mandatory fields with non-mandatory - that can be a mess, too.   * use multiple beans, and have methods like (given names are just illustrative) `createUser(UserCoreData user)`, `createUser(UserFull user)` but that still would not help much.   * or have service for storing mandatory User data and then having additional services for storing additional, non-mandatory data.   * (EDITED) or to split `User` into logical components (ie smaller beans) `Address`, `DateFrom`... and use those in service methods. Is there a pragmatical way to describe service method and its arguments in case like this? (in Java).


What did your college do right and what could they improve upon?

Whether you learned from a University, or mentor, or what have you (I'm mainly more concerned with University/Equivalent), what did the institution do right? And what do you think they could've improved upon when learning your programming skills? I'm curious how everyone felt their institution did as far as teaching them how to become a good programmer.


What is the real responsibility of a class?

I keep wondering if it is legitimate to use verbs that are based on nouns in OOP.   I came across this brilliant article, though I still disagree with the point it makes. To explain the problem a bit more, the article states that there shouldn't be, for instance, a `FileWriter` class, but since writing is an **action** it should be a **method** of the class `File`. You'll get to realize that it's often language dependent since a Ruby programmer would likely be against the use of a `FileWriter` class (Ruby uses method `File.open` to access a file), whereas a Java programmer wouldn't. My personal (and yes, very humble) point of view is that doing so would break the Single Responsibility principle. When I programmed in PHP (because PHP is obviously the best language for OOP, right?), I would often use this kind of framework:               <?php          // This is just an example that I just made on the fly, may contain errors          class User extends Record {              protected $name;              public function __construct($name) {             $this->name = $name;         }          }          class UserDataHandler extends DataHandler /* knows the pdo object */ {              public function find($id) {              $query = $this->db->prepare('SELECT ' . $this->getFields . ' FROM users WHERE id = :id');              $query->bindParam(':id', $id, PDO::PARAM_INT);              $query->setFetchMode( PDO::FETCH_CLASS, 'user');              $query->execute();              return $query->fetch( PDO::FETCH_CLASS );         }               }          ?>      It is my understanding that the suffix DataHandler doesn't add anything relevant; but the point is that the single responsibility principle dictates us that an object used as a model containing data (may it be called a Record) shouldn't also have the responsibility of doing SQL queries and DataBase access. This somehow invalidates the ActionRecord pattern used for instance by Ruby on Rails. I came across this C# code (yay, fourth object language used in this post) just the other day:               byte[] bytes = Encoding.Default.GetBytes(myString);     myString = Encoding.UTF8.GetString(bytes);      And I gotta say that it doesn't make much sense to me that an `Encoding` or `Charset` class actually _encodes_ strings. It should merely be a representation of what an encoding really is. Thus, I would tend to think that:   * It is not a `File` class responsibility to open, read or save files.   * It is not a `Xml` class responsibility to serialize itself.   * It is not a `User` class responsibility to query a database.   * etc. However, if we extrapolate these ideas, why would `Object` have a `toString` class? It's not a Car's or a Dog's responsibility to convert itself to a string, now is it? I understand that from a pragmatic point of view, getting rid of the `toString` method for the beauty of following a strict SOLID form, that makes code more maintainable by making it useless, is not an acceptable option. I also understand that there may not be an exact answer (which would more be an _essay_ than a serious answer) to this, or that it may be opinion-based. Nevertheless I would still like to know if my approach actually follows what the single-responsibility principle really is. What's a class's responsibility?


When to Stop Debug

I've read the article about fixing bug in this post What process do you normally use when attempting to debug a problem/issue/bug with your software?. One of the answer which I noted is "take a rest" when you have spent too long to try to fix the bug. I believe it is a good idea too. But sometime I am in a tight deadline when some mysterious bug appears. When this is happened I tend to think to rewrite the code rather than spending more time to fix the bug. My question is, when will you think it is better to rewrite the code rather than fix it? Or what criteria can we use to determine whether to keep fix the bug or rewrite the code?


Is Prolog professionally useful?

I learned Prolog many years ago in University. During my professional life, I have never needed to use Prolog. Have I missed something special? As far as I remember Prolog requires completely different mindset comparing to prominent programming languages. **Is Prolog really ever used to implement something professionally useful?**


Single Line Statements & Good Practices

I have recently acquired a habit which I know many of you may frown upon, but which, in the end, helps me keeping an eye on global code structure rather than on the structure of a single, (sometimes) repetitive method: grouping a number of statements in a single line, like this:               textBox1.Text = "Something!"; textBox2.Text = "Another thing!"; textBox3.Text = "Yet another thing!";      as opposed to               textBox1.Text = "Something!";     textBox2.Text = "Another thing!";     textBox3.Text = "Yet another thing!";      I use to do that for repetitive tasks to maintain overall code "beauty" and to help me tracking program structure easily, but I admit it may not be a good practice. I actually use it a lot, so I would like to know what are your thoughts on this. Also, do you think that anyone which would ever have to maintain my code have problems with this approach?


TAOCP online resource

I am a CS student, and am really astonished that I didn't know about Donald Knuth and his TAoCP. Now that I do, I really look forward to diving into it. Would going for the entire volume 4 be a good idea? Also, is there a place online where I can read up (especially, the algorithms and DS part) ? thanks, Yati


Building an application around a theoretical currency

I'm currently doing an application design that involves sale of service. The application will ultimately be used internationally and will need to adjust prices based on user location. Is it a good idea to store / work with all prices in an absolute unit? For example - credits. And I can specify conversion rules like 1 credit = 1 USD. What scenarios would I need to be careful about if I do this (and should I be doing this)? One thing I can think of is problems during auditing if I change my conversion rules periodically. In which case I'll need to start storing conversion rules by date and the conversion process will also require the time of transaction to give the correct amount in any currency for that time. Am I complicating this too much?


generating a class dynamically from types that are fetched at runtime

is doing the following possible in C# (or in any other language) **1.** I am fetching data from a database. At run time i can compute the no. of columns and data types of the columns fetched. **2.** Next i want to "generate" a class with these data types as fields. I also want to store all the records that i fetch in a collection.               The problem is that i wanna do both step **1** and **2** at runt ime      is this possible ? I am using C# currently but i can shift to something else if i need to.


Connection Pooling

As an example, I am using PostgreSQL with an application-layer connection pool, such a a JDBC connection pool. The specific JDBC connection pool is not important. My question is more about the actual caching of the database connection. Connections to the database are created by supplying a data source (with credentials) to a JDBC driver, which presumably acts as bridge to a ODBC- compliant driver, which takes the standard set of commands and translates them to database specific formats. On top of a JDBC driver, an application can use a connection pool, which alleviates overhead/latency in creating and closing database connections. These connections are stored in a pool in an "array" if you will. Each connection is set to "not in use". When the connection is needed, the connect pool marks the connection as "in use" and gives it to the thread in an application which requested a connection. When the thread is finished with it, it then return the connection to the pool where another thread in a multi-threaded program can use it. After being idle for n amount of time, the connection is removed from the pool to free resources. Now while the connection is in the pool, does the tcp connection itself to the database remain live? In other words, when a thread retrieves a connection from the pool, the configuration of the PostgreSQL JDBC driver (authentication credentials) is cached and the bridge to the ODBC driver is cached, so a lot of work is already done in terms of taking the standard sql command and translating it to the specific database command. But does the database connection pool also cache the TCP connection, that is, keep the TCP connection alive and open to the database while the connection is still in the pool?


Tools to ensure clients expectations are met

I was in an interview recently and was asked if I use any tools to ensure a clients expectations for a project are met. I couldn't really think of any actual tools apart from stuff like JIRA to ensure bugs/feature requests are kept track off. Has anyone else been asked this? What would have been a good answer to give? Thanks!


Do you rotate agile team members?

I've got long standing developers in my sprint team. They know the domain, they've been with the company 5+ years and as a team we have a pretty good burn down rate. There are other sprint teams, some with equally knowledgeable developers and others with newer developers who are trying to get up to speed. My manager is worried that all our eggs are in one basket and wants to rotate out one or two knowledgeable developers in exchange for the some new guys. I can see their point but can also see the problems that go with that - I'm sure there are others but these are just a few off the top of my head.   1. New developer will have a much lower work rate   2. New developer will bring down the work rate of at least one experienced person as they constantly ask questions.   3. New developer leaves the team at the end to join another team - hopefully he'll remember what he did with us.   4. New developer leaves the company - wow we wasted a whole bunch of time. I might like to add that the organisation is struggling with agile. It was a traditional waterfall development company and still thinks in big releases and items that are "expected" to be in the release. If you've been in a similar situation to this I'd love to know you experiences - does rotating out the team members work? Would pair programming or other methods be a better route to take?


Handing Off A Unity Project

I have someone who wants me to develop a game for them. I do not intend to continue developing the game after its first release (he wants me to develop it for commercial use). To make the project easy, I was thinking of using the Unity game engine. I am going to say right now, I am a kid heading into college, he wants to pay me, but I don't want to be paid, and this is for his own personal business endeavor, I am afraid if I hand off this project to a more established professional, even if I use source control, he will disregard it, throw it away, and the part I am most afraid of tell him I did a cruddy or lazy job (because I used Unity). What are your opinions on this situation, and the use of Unity in this way?


SVN command line client: checkout refused when LDAP password changed “svn: OPTIONS of” (repo) “authorization failed” (but works in TortoiseSVN)

When using the command line/terminal svn client, a colleague is getting "svn: OPTIONS of " [repo] "...authorization failed" error message when they attempt to checkout the repo to be their local working copy. They used to be able to do this but have recently had to change their password (periodic routine security policy). And it stopped working. NOTE: The svn check command does ask for a password everytime (which they supply - i.e. their new one.) BUT strangely they have no problem with Tortoise SVN, it works on that. They supply their usual login and new password and it works. Our setup is a virtualised CentOS Linux machine with several Linux user accounts where development takes place and the SVN central repo is on a separate server, authentication is using our LDAP login (i.e. the same corporate login used to login to our Windows machines). We login as Linux users to our development server from our Windows machines, using standard terminal SSH tools, e.g. PuTTY or MobaXTerm or CygWin. When I change my password I don't get the same problem, I am able to checkout. I have seen many questions about this error message from searching various forums on google but none have provided me with a solution as yet. One of the solutions I found suggests to clear or remove a local cache containing authentication, in a .subversion folder, we tried this but still the same problem. Also tried checking out to another folder. So it seems we have clean out any trace of cached passwords but yet it still rejects. Could there be another place on our CentOS Linux machine that caches the login What is meant by OPTIONS (could it be a setting somewhere on our development machine or on the SVN repo server?) Could it be a HTTP Proxy cache of my colleague's credentials stored somewhere - so we need to clear that when a password is changed? (Mistakenly posted on superuser.com (which is about users), so closed it there and moved it here)


Should certain math classes be required for a Computer Science degree?

For a Computer Science (CS) degree at many colleges and universities, certain math courses are **required** : Calculus, Linear Algebra, and Discrete Mathematics are few examples. However, since I've started working in the real world as a software developer, I have yet to truly use _some_ the knowledge I had at once acquired from taking those classes. _Discrete Math might be the only exception_. My questions: **Should these math classes be required to obtain a computer science degree? Or would they be better served as electives?** I'm challenging even that the certain math classes even help with required CS classes. For example, I never used linear algebra outside of the math class itself. I hear it's used in Computer Graphics, but I never took those classes-- yet linear algebra was _required_ for a CS degree. I personally think it could be better served as an elective rather than requirement because it's more specific to a branch of CS rather than general CS. From a Slashdot post CS Profs Debate Role of Math In CS Education: > _'For too long, we have taught computer science as an academic discipline > (as though all of our students will go on to get PhDs and then become CS > faculty members) even though for most of us, our students are overwhelmingly > seeking careers in which they apply computer science.'_


Business trying to make technical decisions

We've often run across scenarios where the business will promise a client a new feature. The business will promise that the feature be implemented in a specific way. These technical details promised by the business are usually poor. Unfortunately, client is now set and want this feature to be implemented in the way described by the business. In the end, the business just wants this feature to be completed without regard to quality and maintainability. Is there a good way to push back? How can we explain to the business that providing technical details before the requirements have been gathered is a bad idea?


Introducing functional programming into your development environment

This is a long story but I will try to summarize it as best I can. We are a .NET shop that writes software for a variety of different types of funds. For example, we write health claims management software, pension management software, 401(k) software and some other financial-type things. Now we are entering a new realm: derivatives and quantitative analytics type of work, which seems very exciting. This is something that is coming down in the next 8-12 months I've been told. Now, I have learned some functional programming on my own, mainly just superficial glances at various languages via this book but never really dug deep into it. Now, since we are a .NET shop I was thinking F# might be a good choice, because we could potentially leverage some .NET libraries and existing knowledge possibly. My question is, where to start? I am having an exceedingly difficult time trying to figure out if I should go with Haskell, Erlang, Scala, F#, etc. They all seem very interesting and capable and quite frankly this might be a good chance to break out being so Microsoft dependent. Has anyone had a similar situation? If so, what was your experience making the jump to functional and what did you choose and why? I know this is kind of a big question but I don't know any developers that are using functional methods right now so I have nowhere else to turn other than Googling incessantly and finding flame wars everywhere on the best functional language.


How to justify framework upgrades

I am looking at how to justify changes to those who control budgets. For example if we have Enterprise Library 4 on some systems and the latest version is 5, is it worth upgrading? How do you justify it? Is it best to continually try to keep frameworks that systems use up to date. Or is it better to do a major lift every x years?


Start reading Ruby (on Rails) code

I'm an experienced developer which quite some experience in meta programming. I just found my way to Ruby and want to understand more of Rails (and related) project internals. Even if I understand the high level concepts, it's hard to get an overview of those projects. I wonder how other people approach that problem? How would you for example approach the Mongoid source code to get a good understanding of it's internals?


Software Requirement Specification documentation by professionals

I just wanted to know what is the significance of SRS(Software Requirement Specification) in programming? and what are the techniques used in preparation of an SRS .. also who writes the SRS.. is it the programmers?


Is the average number of bugs per loc the same for different programming languages?

I have been told that the average number of bugs/defects per line of code is "constant" for different programming languages. 10 KLOC of Ruby would have the same number of bugs as 10 KLOC of c++. The argument is usually used to promote the use of expressive languages (think python/ruby over c++/assembly) since the number of lines to describe the same functionality would be smaller. Does anybody know where this claim comes from? Does higher-level languages lead to fewer bugs?


What is the advantage of implementing a composite design pattern?

Apparently, a composite design pattern represents individual entities and collective entities in the same manner. What is the advantage to this? For instance, if I subclass a class, why would I want to treat objects of both classes in the same way? For instance, if 'tuna' is a subclass of 'fish', why would I want to have the same implementations for methods of objects in both classes?


Application of Implementing 3 Stacks in single array [Need]

Well there is lot of discussion about implementing 3 [ or 2 stacks ] in a single array. [Interview question] but whats the **real need or application** for implementing stacks like that? can't we allot memory as 3 separate stacks [array] itself?. anyway we are alloting array[size * 3] in that single array. some links that discuss some: use-an-array-to-implement-three-stack how-to-implement-3-stack-in-a-single-array-efficiently


How to deal with database connections in a Python library module

I have created a library in Python that contains functions for accessing a database. This is a wrapper library around a third party application database, written due to the fact that the third party application does not offer a decent API. Now I originally let each function open a database connection for the duration of the function call which was OK, until my program logic used nested calls to the functions where I would then be calling a particular function a few thousand times. This wasn't very performant. Profiling this showed that the overhead was in the database connection setup - once per function call. So I moved the open connection from within the function(s) to the module itself, so that the database connection would be opened when the library module was imported. This gave me an acceptable performance. Now I have two questions regarding this. Firstly, do I need to be concerned that I am no longer explicitly closing the database connection and how could I do it explicitly with this set-up? Secondly, does what I have done fall anywhere close to the realm of good practice and how might I otherwise approach this?


How far to go with typedef'ing primitive types like int

Do you bother typedef'ing most of your number types like this? Or do you just use "int" in most places? It might be more important in my current project with is client / server based and the types have to match when transmitted through the wire as binary data - but I just wondered how far people go with this generally:               types.h:          typedef int16_t Version;     typedef int32_t PacketLength;     typedef int32_t Identity;     typedef int32_t CabinetNumber;     typedef int64_t Time64;     typedef int64_t RFID;     typedef int64_t NetworkAddress;     typedef int64_t PathfinderAddress;     typedef int16_t PathfinderPan;     typedef int16_t PathfinderChannel;     typedef int64_t HandsetSerialNumber;     typedef int16_t PinNumber;     typedef int16_t LoggingInterval;     typedef int16_t DelayMinutes;     typedef int16_t ReminderDelayMinutes;     typedef int16_t EscalationDelayMinutes;     typedef float CalibrationOffset;     typedef float AnalogValue;     typedef int8_t PathfinderEtrx;     typedef int8_t DampingFactor;     typedef int8_t RankNumber;     typedef int8_t SlavePort;     typedef int8_t EventLevel;     typedef int8_t Percent;     typedef int8_t SensorNumber;     typedef int8_t RoleCode;     typedef int8_t Hour;     typedef int8_t Minute;     typedef int8_t Second;     typedef int8_t Day;     typedef int8_t Month;     typedef int16_t Year;     typedef int8_t EscalationLevel;      It seems logical to try and make sure the same type is always used for a particular thing to avoid overflows, but I do often see code where "int" has just been used pretty much everywhere instead. The typedef'ing often does lead to code that looks a bit like this though:               DoSomething(EscalationLevel escalationLevel)     {         ...     }      Which then makes me think which bit is actually describing the parameter - the parameters type or the parameters name?! Thanks.


Will it cost me a lot if I chose ASP.NET and IIS?

I intend to build a type of online social network in ASP.NET. I am going to host it under IIS server. The database that I am going to use is SQL Server. The site will accept a maximum 500,000 users. It will be in one language and it's targeted to people who live in countries which its main language is the language that this site will be built in. I expect the number of users who will use the application every day will be between 30,000 and 34,000. so in average it may be 2000 online users per hour. I can afford to buy Visual Studio Professional but I do not know If I will be able to afford the cost of IIS/ SQL server, etc (any other MS fees). I do not know how to calculate the cost and, with these estimates, determine how many servers I need. Waiting help from experts.


Why do Java's Iterator and ListIterator point between elements?

The Javadoc for ListIterator says: > A `ListIterator` has no current element; its cursor position always lies > between the element that would be returned by a call to `previous()` and the > element that would be returned by a call to `next()`. Why was Java's `ListIterator` implemented to point between elements rather than at a current element? It seems that this makes client code less readable when it has to repeatedly call `getNext()`, `getPrevious()`, so I assume there must be a good reason for the choice. As a side note, I just wrote a little library called peekable-arraylist that extends `ArrayList`, `Iterator`, and `ListIterator` that provides a `peekAtNext()` and `peekAtPrevious()` methods implemented like:                 @Override public synchronized T peekAtNext() {          T t = next();          previous();          return t;       }


Hardware that accelerates pointer dereferencing?

Most modern languages make a heavy use of pointers / references: a typical OOP language uses VMT lookups, a typical functional language builds key data structures out of pointers, etc. Even typical C code often sports things like `foo->bar->baz`. It is well-known that dereferencing a pointer is cache-unfriendly, unless the pointer happens to point very near some just-accessed location and hits the same cache line. Is there, or has there been, hardware that tries to address this problem? It's not currently widely deployed; why? Hitting L1 or even L2 cache is so much faster than hitting RAM on current hardware that the goal of making pointer dereferencing reap some of the caching benefits seems worthy.


Levels of user permissions in a RESTful API

Let's say I have a company that ranks the cutest cats on the internet. **I offer a resource at`/cats/`** which provides users with the latest, cutest adorable cats. Users can either get just the top 3 cats if they haven't paid at all or registered. The top 10 cats if they paid 337 dollars and are logged in, and the top 100 cats if they paid 1337 dollars and are logged in. I have a 'user identifier' when making the request. In short, **consumers of`/cats/` get a different number of cats based on their 'user ranking'**. I do have a user identifier on the consuming end, but I have no explicit representation of the user level on the consuming end. **I'd like to inform users they can upgrade their subscription** when making the request. That is, I need to distinguish between _3 cats since I only offer 3 cats_ and _3 cats because that's what the user level allowed_. What is the best practice for distinguishing limiting the resource because the consumer does not have sufficient priviledges and limiting it because that's what the consumer has? **How does the client know if they can upgrade their ranking?** That is, they only got a limited resource because _they_ don't have permissions. What is the best practice here? Note, this is a gross simplification of the actual case. Also, just to clarify - reading is appreciated. * * * Update: ### Here are options we've considered:   * Storing the user permissions objects once on the client, querying for it only when account login or upgrade is performed.   * Passing `null` values in JSON indicating it exists, but an actual _nothing_ was transfered. So 10 cats for a user with 3 cats could be `["Garfield","Sylvester","Puss in Boots",null*7]`   * Passing a resource permission pair `{cats:["Whiskers","Fluffy","Socks"],authCount:3}` I'd like to do this right the first time to deliver the cutest cats in the best way possible and we'd and we'd like