title: What features should be tested via automated UI testing?

text: We recently had a consultant tell us that if a feature can only be tested via automated UI tests (e.g. Selenium, Coded UI), then there is an underlying architectural issue. While this statement might be a bit extreme, it is along the same lines of the testing pyramid in that UI tests should make up a small portion of your overall automated test suite. So, what kinds of features _should_ have automated UI testing? Will a system with a cogent architecture still have features that can only be verified through UI tests, or should these tests just serve as "back-up" for a suite of unit and service tests?


title: Machine Learning With Categorical and Continuous Data

text: This question could go here or on S.O. perhaps... Suppose that your training dataset contains both categorical and continuous data such as this setup:                Animal, breed,  sex, age, weight, blood_pressure, annual_cost      cat,    calico, M,   10,  15    ,   100         , 100       cat,    tabby,  F,   5,   10    ,   80          , 200      dog,    beagle, M,   3,   30    ,   90          , 200      dog,    lab,    F,   8,   75    ,   80          , 100      And the dependent variable to be predicted is the annual vet cost. I'm a bit confused as to the specific techniques available to deal with such a dataset. What are the methods commonly used to deal with datasets that are a mixture of both continuous and categorical data?


title: Convert grammar into an LL(1) grammar which recognises the same language

text: I have the following sample question for a compilers exam and wanted to check my solution.               Convert the following grammar into an LL(1) grammar which recognises the same      language:          E -> E + T       E -> T       T -> id      T -> id()      T -> id(L)      L -> E;L      L -> E      For my answer I have               E  -> T E'       E' -> + T | ε       T  -> id      T  -> id()      T  -> id(L)      L  -> E L'      L' -> ;E | ε      Can anybody verify the answer? **Edit** Ok so would it be similar to...               E  -> T E'       E' -> + E | ε       T  -> id      T  -> id()      T  -> id(L)      L  -> E L'      L' -> ;E | ε


title: Keep user and user profile in different tables?

text: I have seen in a couple of projects that developers prefer to keep essential user info in one table (email/login, password hash, screen name) and rest of the non essential user profile in another (creation date, country, etc). By non-essential I mean that this data is needed only occasionally. Obvious benefit is that if you are using ORM querying less fields is obviously good. But then you can have two entities mapped to same table and this will save you from querying stuff you don't need (while being more convenient). Does anybody know any other advantage of keeping these things in two tables?


title: In C++ what is the commonly accepted method for making a program platform-agnostic?

text: The way I usually do it is I make some namespace Platform in Platform.h and every OS call is encapsulated by a static function in this namespace. So the only place in the entire code base that knows what OS is being used is Platform.cpp. Is this a good way of making things easier? For instance when I call Platform::MessageBox(...), what actually happens is:               void Platform::MessageBox(...)     {     #ifdef(_WINDOWS)     ....     #elif(_LINUX)     ....     #elif(_MAC)     ....     #endif     }


title: Interesting Topics in Comp. Sci. for New Students?

text: I hope this is the right forum to ask this question. Last friday I was in a discussion with my professors about the students' lack of motivation and interest in the field of Computer Science. All of the students are enrolled, but through questionnaires and other questions that my professor posed it was revealed that over 90% of all enrolled students are just in it for the reward of getting a job sometime in the future (since it's a growing field with high job potential) I asked my professor for the permission to take over the first couple of lectures and try and motivate, interest and inspire students for the field of Computer Science and programming in particular (this is the Intro to Programming course). This request was granted and I now have a week to come up with a lecture topic for my professor's five groups. My main goal isn't to teach, I just want to get students to be as interested in the field as I am. I want to show them what's possible, what awesome magical things have been done in the field, the future we are heading towards using programming and Comp. Sci. Therefore, I would like to pose this question: I have a few topics, materials and sample projects that I would like to talk about:   * Grace Hopper (It is my hope to interest the female programmers in the class. There are never more than two or three per group and they, more than males, are prone to jumping ship and abandoning Comp. Sci.)   * The Singularity Institute   * Alan Turing   * Robotics   * Programming not as a chore or a must, but the idea that we are, at our core, the nexus to which anything anybody does in the digital world is connected to. We are the problem solvers; we assemble all the parts together and we are the ones that, essentially, make the vision a reality.   * Give them an idea for a programming project which, through the help of the professor, could be significant to every student (I want students to not only feel interested in the topic, but they should feel important, that what they do here makes a difference) Do you have interesting topics worthy of discussion, something I can tell the students which they can get interested about? How would you approach the lecture? If you had 90 minutes worth of time to try and get students interested in the project, what would you do?


title: Emphasize negation

text: I was just writing an if statement with fairly long property names and came occross this problem. Let say we have an if statement like this:               if(_someViewModelNameThatIsLong.AnotherPropertyINeedToCheck == someValue &&        !_someViewModelNameThatIsLong.ThisIsABooleanPropertyThatIsImportant)     {         //Do something     }      The second property is of a boolean type and it makes no sense to have the stetement like               if(boleanValue == true)      Is there a better way to emphasize the negation then to put the `!` in front. To me it seems like this can easily be overseen when reading the code and may potentialy cause problems with debuging


title: Parsing a Log File - Java

text: Im reading a log file in Java on a Linux box on a continual schedule of 2 minutes looking for certain messages. I store the last offset (RandomAccessFile getFilePointer) and read from it onwards when I detect LastModified has changed; is this best practice or even right?


title: Data sharing across processes

text: I have a C# .NET app that downloads a users Tweets using LinqToTwitter. This is for TV broadcast - the client wants to show Tweets on air. We have two other apps that need to access these tweets. One is a C++ app and one will use MS Script Host. These two apps don't run at the same time - it's one or the other. My question is, of the many ways to share this data, which would you choose? **DataBase** \- Like MySql. This was my first choice. But then it seemed like overkill for the 10-20 tweets they would get per day. **Streaming** \- Like TCP or named pipes. This would involve some type of protocol. Like "Give me the last 10 tweets..." **Xml** \- Store the data in a file all programs can access. Simplest, but just doesn't feel right for some reason. **Memory Mapped IO** \- I think this would require a COM library for the scripts to be able to use it There are others. Just curious what you would use. I am the only programmer in a small company and don't have others to bounce ideas off of. Thanks.


title: Using database Indexes

text: This might sound like a naive question but when are database table indexes in mysql required? How do such indexes affect performance and why?


title: Is there a way to display the stack during recursion method?

text: I'm trying to learn recursion. I copied this bit of code from my book and added the displays to help me trace what the method is doing and when.               public static void main(String[] args) {                   System.out.println(sum(4));          }//main          public static int sum(int n) {         int sum;         System.out.println("n = " + n + "\n");         if (n == 1)             sum = 1;         else             sum = sum(n - 1) + n;            System.out.println("n after function = " + n + "\n");         System.out.println("sum after function = " + sum + "\n");         return sum;     }          Here's the results: > n = 4 > > n = 3 > > n = 2 > > n = 1 > > n after function = 1 > > sum after function = 1 > > n after function = 2 > > sum after function = 3 > > n after function = 3 > > sum after function = 6 > > n after function = 4 > > sum after function = 10 > > 10 I'm getting hung up on what's being stored in the stack, or perhaps how it's being stored. Is there a way to display what's in the stack while n is counting down to 1? This is an odd concept - it's like an invisible loop storing values in a way I don't understand.


title: Are there any good, open-source change request systems?

text: I have a need to make a somewhat custom change request system (very high auditing requirements). Instead of completely reinventing the wheel I was wondering if there's an open-source change request system, considered decent that I could write a custom module for? I've done some searching but the ones I have found don't seem to encapsulate what a change request system should be (no way of recording test plans or work streams). In my experience a change request system has (does) store test plans / technical specs and a log of work.


title: How important are the people I work with?

text: I'm a very lucky individual who's managed to push a job I enjoy as a junior developer (I say push as I was hired as a Business Analyst but moved into development by proving I could do the work). I'm happy with my salary and working conditions. BUT (Seriously, why wouldn't there be a but?) the people I work with are... in a word... up themselves. I have two senior developers - brilliant minds, great work but complete knowledge horders. I feel like there's a lot I _could_ learn from them but very little they're going to _let_ me learn. As I'm early in my career and really want to become as great at this as I can - how important is learning from others (outside of the Internet) at this point in my career? Am I doing myself a disservice that I'm going to live to regret later in my career by staying here and not seeking out a workplace that has people willing to teach me and help me to further my skills?


title: Asynchronous Java

text: I'm wondering if I wanted to implement a web service based on java that does web analytics, what sort of architecture should I use. The actualy processing of the Big Data would be done by Hadoop. However I am not sure what I would need to do to make it asynchronous, or is Hadoop already asynchronous by nature? Could I do something with JMS? If so, how would that fit into the whole thing? Would it be something along the lines that upon receiving the web service request, I use JMS to send a message to Hadoop to handle a particular data, and then wait for it to come back to me? I am not too familiar with asynchronous java so I'm not sure where to start.


title: What does "testing surface" mean in the context of programming?

text: I encountered the following text in an article on the ModelViewPresenter pattern and my brain blue-screened: > Passive View usually provides a **larger testing surface** than Supervising > Controller because all the view update logic is placed in the presenter. I haven't come across this particular jargon before and I'm rather puzzled about what exactly constitutes the "testing surface" of a design pattern. Would someone please enlighten me regarding what the term means and also what it means for one design pattern to have a larger (or smaller) "testing surface" than another?


title: Dota 2 running on Linux, Mac and Windows - How do they do it?

text: How do Valve create games that run on Linux, Mac and Windows? I imagine they dont really write one version for each platform bec that would just be a nightmare.. or do they? I imagine it is written in a portable C++ code (or C#?) but I wanted to know more details about this. I've developed an app on Adobe AIR and considering on porting it to a diff language as Adobe abandoned linux support.


I have been browsing some OpenJDK code recently and have found some **intriguing** pieces of code there that has to do with **bit-wise operations**. I even asked a question about it on StackOverflow. Another example that illustrates the point:                1141       public static int bitCount(int i) {      1142           // HD, Figure 5-2      1143           i = i - ((i >>> 1) & 0x55555555);      1144           i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);      1145           i = (i + (i >>> 4)) & 0x0f0f0f0f;      1146           i = i + (i >>> 8);      1147           i = i + (i >>> 16);      1148           return i & 0x3f;      1149       }      This code can be found in the Integer class. **I cannot help but feel stupid when I look at this.** Did I miss a class or two in college or is this not something I am supposed to just _get_? I can do simple bit-wise operations (like ANDing, ORing, XORing, shifting), but come on, how does someone come up with a code like that above? **How good does a well-rounded programmer need to be with bit-wise operations?** **On a side note...** _What worries me is that the person who answered my question on StackOverflow answered it in a matter of minutes. If he could do that, why did I just stare like deer in the headlights?_


title: PHP framework plunge

text: I am about to take plunge into PHP frameworks and my weapon of choice is kohona. I have a reasonable amount of OO experince with java. And my javaScript, jQuery, PhP and html/CSS skills are passable. Now to the question. Is this a reasonable choice? As ZEND looks like a steeper learning curve and CakePHP commandline configuration does not immediately strikes me as good way to produce code.


I was thinking about this for quite some time. Is function memoization really only for primitives? I currently have this piece of code:               Public Shared Function Mize(Of TArg1 As Structure, TResult)(ByVal input_f As System.Func(Of TArg1, TResult)) As System.Func(Of TArg1, TResult)         Dim map = New System.Collections.Generic.Dictionary(Of TArg1, TResult)         Return Function(arg1 As TArg1)                    If map.ContainsKey(arg1) Then Return map.Item(arg1)                    Dim result = input_f(arg1)                    map.Add(arg1, result)                    Return result                End Function     End Function      And I'm wondering should i upgrade TArg1 such that it could accept any arbitrary class?


title: How to handle flag in multiple if-else's

text: I seem to see this often enough in my code and others. There's nothing about it that seems horribly wrong, but it annoys me as it looks like it can be done better. I suppose a case statement, might make a little more sense, but often variable is a type that does not work well or at all with case statements (depending on language)               If variable == A         if (Flag == true)             doFooA()         else             doFooA2          else if variable == B         if (Flag == true)             doFooB()         else             doFooB2     else if variable == C         if (Flag == true)             doFooC()         else             doFooC2      It seems there's multiple ways to "factor" this, such as 2 sets of if-elses, where one set handles when Flag == true. Is there a "good way" to factor this, or perhaps when this if-else algorithm happens it usually means you are doing something wrong?


title: Scalable spring core with AMQP?

text: I use 3 standard Spring MVC war, which share a common core (Services, DAO, and Models). The main problem is when I plan to deploy all the 3 wars on a same server. I have the Core Application Context instantiated 3 times. I know it's possible to share a common context using an EAR, but for scalability purposes I have to keep all 3 wars, as 3 distinct units, which could deploy in a different count each. My question is about an architectural choice: Is it a good idea to split the Service layer used by my Controllers in a facade + commands (pattern) which can be distributed to the core (backend) via an AMQP? So that I could share requests across multiple cores.


title: I believe I have mixed C and C++ code when I shouldn't have; Is this a problem and how to rectify?

text: **Background/Scenario** I started writing a CLI application purely in C (my first proper C or C++ program that wasn't "Hello World" or a variation thereof). Around midway through I was working with "strings" of user input (char arrays) and I discovered the C++ string streamer object. I saw that I could save code using these, so I used them through the application. This means that I have changed the file extension to .cpp and now compile the app with `g++` instead of `gcc`. So based on this, I would say the application is now technically a C++ application (although 90%+ of the code is written in what I would call C, as there is lots of cross-over between the two language given my limited experience of the two). It is a single .cpp file around 900 lines long. **Important Factors** I want the program to be free (as in money) and freely distributable and usable for all to have. My concern is that someone will look at the code and think something to the effect of: > Oh look at the coding, it's awful, this program can't help me When potentially it could! Another matter is the code being efficient (it is a program for testing Ethernet connectivity). There should be no parts of the code that are so inefficient that they can severely hinder the performance of the application or its output. However, I think that is a question for Stack Overflow when asking for help with specific functions, methods, object calls, etc. **My question** Having (in my opinion) mixed C and C++ where perhaps I shouldn't. Should I look to rewrite it all in C++ (by this, I mean implement more C++ objects and methods where perhaps I have coded something in a C style that can be condensed using newer C++ techniques), or remove the use of string streamer objects and bring it all "back" to C code? Is there a correct approach here? I am lost and need some guidance on how to keep this application "Good" in the eyes of the masses, so they will use it and benefit from it. **The Code - Update** Here is a link to the code. It is circa 40% comments, I comment nearly every line until I feel more fluent. In the copy I have linked to though, I have removed pretty much all the comments. I hope this doesn't make it too hard to read. I am hoping though that no one should need to fully understand it. If I have made fatal design flaws though, I am hoping they should be identifiable easily. I should also mention, I am writing a couple of Ubuntu desktops and laptops. I'm not intending to port the code to other operating systems.


title: Debugging checklists: How much it's necessary to have?

text: Should making _debug-checklists_ be an essential part of development process? How it can be integrated with _unit-tests_? **Update** Debugging checklist: Think about it as your troubleshooting checklist -- like what you do for your network connection, this time for your developers and your source code. For example if you're trying to access web via your web browser and you can't, then you'd probably go and check if you can load other websites or not, if not, then you'd check your internet/network connection, and so on. Here if you have a team of multiple developers and you ran into a bug, you wouldn't just jump into the source code and try to debug it there, because someone else might changed the code and that might cause the problem. To spot the actual bug without a checklist, everybody needs to spend a lot of time looking at different things, probably in an unorganized way also. For example we have a Map module in our software. If you're trying to use that module somewhere in the application and that doesn't work, then there is a small checklist to help you debug it faster:   1. Check if the license exists in Dashboard/Settings/Map or in the database. Is that a valid license?   2. What is the MapCenter? Is that a valid LatLng?   3. What is the MapProjection?   4. Can you reach the MapServer? So, specially if you're new to the team/code, you can catch up with others much faster without spending hours trying to spot the cause of errors. There are ways to do a better error handling -- like throw an _exception_ for example if the MapServer is unreachable, however there are also situations that you still need to check different elements to make sure what exactly causing the error. The question is: If I'm writing a _sort_ function, and I know that you need to specify the correct _encoding_ in order to get the correct result, should I write a checklist simply like this:   1. Make sure you have set the proper _encoding_ in configuration file. If the above example could save myself or another developer 10-15 minutes of looking around to find the problem, should we make it mandatory for every developer to write this kind of checklists when they spot something that's potential to be source of a problem on a specific part of application later?


title: Does putting types/functions inside namespace make compiler's parsing work easy?

text: Retaining the names inside `namespace` will make compiler work less stressful!? For example:               // test.cpp     #include</*iostream,vector,string,map*/>     class vec { /* ... */ };      Take 2 scenarios of `main()`:               // scenario-1     using namespace std;  // comment this line for scenario-2     int main ()     {       vec obj;     }      For scenario-1 where `using namespace std;`, several type names from `namespace std` will come into global scope. Thus compiler will have to check against `vec` if any of the type is colliding with it. If it does then generate error. In scenario-2 where there is no `using namespace`, compiler just have to check `vec` with `std`, because that's the only symbol in global scope. I am interested to know that, shouldn't it make the compiler little faster ?


title: Refactoring and Open / Closed principle

text: I have recently being reading a web site about clean code development (I do not put a link here because it is not in English). One of the principles advertised by this site is the **Open Closed Principle** : each software component should be open for extension and closed for modification. E.g., when we have implemented and tested a class, we should only modify it to fix bugs or to add new functionality (e.g. new methods that **do not** influence the existing ones). The existing functionality and implementation should not be changed. I normally apply this principle by defining an interface `I` and a corresponding implementation class `A`. When class `A` has become stable (implemented and tested), I normally do not modify it too much (possibly, not at all), i.e.   1. If new requirements arrive (e.g. performance, or a totally new implementation of the interface) that require big changes to the code, I write a new implementation `B`, and keep using `A` as long as `B` is not mature. When `B` is mature, all that is needed is to change how `I` is instantiated.   2. If the new requirements suggest a change to the interface as well, I define a new interface `I'` and a new implementation `A'`. So `I`, `A` are frozen and remain **the implementation** for the production system as long as `I'` and `A'` are not stable enough to replace them. So, in view of these observation, I was a bit surprised that the web page then suggested the use of **complex refactorings** , "... because it is not possible to write code directly in its final form." Isn't there a contradiction / conflict between enforcing the Open / Closed Principle and suggesting the use of complex refactorings as a best practice? Or the idea here is that one can use complex refactorings during the development of a class `A`, but when that class has been tested successfully it should be frozen?


title: What does Microsoft Public License (Ms-PL) clause 3 section (A) actually limit?

text: I've been looking at the Ms-PL license that ASP.NET MVC and DotNetOpenAuth are published under and 3A says this:               3 Conditions and Limitations          (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.      Does this mean that I cannot name my project ASP.NET MVC DotNetOpenAuth Sample Project and publish it if I use these two technologies or does it just mean that I cannot use the author's name to promote this project?


title: Client/Server App – Best online data storage/administration/communication library?

text: I work on some iphone/android apps and the “data stored on a centralized server” pattern seem fairly common. So far, I have done one app like this, doing everything myself at a low level without using many libraries:   1. MySQL database   2. PHP/HTML web forms allowing the app manager to enter/update content with some validation   3. PHP scripts turning the SQL data into downloadable XML files   4. App code (java/objective-c) to download the XML files, parse them and turn them in some proper objects then displayed in the app UI As you can imagine, that is very tedious and boring and there is lots of duplicated stuff. Also, it was interesting to do it once that way to understand how it works but I’m sure some libraries do it much better that my own php/java/obj-c code. Now, I will have to work on something similar and I’m looking for some sort of API/service that will do most of this work for me but still allow me to alter/customize what I need to (e.g.: web form validation so that the app manager doesn’t break the integrity of the database, e.g.: plugging with my own classes). So I’m looking for the best generic solution that cover all the steps above plus the case when the app can insert/update data as well (download and upload). (Note the library shouldn’t have a licence that prevents me from selling the app) Let’s say I have to build an app about cars, I want to store the car data in an online SQL database with some HTML forms allowing the app manager to add more cars (but only allowing him to enter validated data). I want the app user to be able to download the cars and insert new one in the online SQL database from his phone. What library/API would you recommend? What service would save me the most time while still allowing flexibility?


title: Version control: Dealing with incomplete/broken code

text: It seems to be a generally accepted good practice not to push invalid, broken, or incomplete code. But one of the huge advantages of version control systems is that it gives you a remote place for your code, so you can work on the same codebase from more than one place. Suppose you are working on a feature with a couple other developers, and a bad winter storm is announced; everybody agrees to go home and keep working rather than get caught in the storm, but nobody is at an ideal _stopping place_. What do you do?   1. Create different branches for each developer and commit your changes to that, push those branches to remote and hope you can clean it up later on remote without making life difficult?   2. Create a different `remote` just for incomplete code?   3. Copy your code to your personal flash drive and hope you don't lose it later, or get caught violating company policy?   4. Something else? (We use `git`, but I would hope the answer could be general to any version control system.)


title: Using a stream manipulator (endl) or a newline escape character (\n)?

text: I don't have a specific context in which I'm asking the question, but while I was reading a beginner book on C++ I noticed the use of both an endl stream manipulator and a newline escape character when dealing with a stream object. The exmaple is as follows:               cout << "Hello World" << endl;     cout << "Hello World\n";      My questions are:   1. Is it more appropriate to use the stream manipulator (endl) in a certain situation and an escape character in a different one?   2. Are there drawbacks efficiency wise to using one of the two?   3. Are they completely interchangeable?   4. I read that an escape sequence is stored in memory as a single character. Does that mean it is more appropriate to use endl if you're going for low memory consumption?    5. Does the stream manipulator endl use up memory in any way, if so is it more than the escape sequence? Thanks, StackExchange Apologies if I posted this in the wrong section, I thought it counted as data structures.


title: In git, is it a bad idea to create a tag with the same name as a deleted branch?

text: I have a project with a git branching model that roughly follows that of nvie's git-flow. Our release branches are named in a SemVer format, e.g. `v1.5.2` Once a release branch is given the green light for production, we close the branch, by merging it into master, applying a tag, and then deleting the branch. As we immediately delete the release branch, we've been using the same identifier for tagging the branch, e.g. `v1.5.2` Here's the commands we'd use to close a release branch:               $ git checkout master     $ git merge v1.5.2     $ git tag -a v1.5.2 -m "Version 1.5.2 - foo bar, baz, etc"     $ git branch -d v1.5.2     $ git branch -dr origin/v1.5.2     $ git push origin :v1.5.2     $ git push     $ git push --tags      This seems to work in the majority of cases, however it's causing an issue in the scenario where another instance of the git repo (e.g. another dev machine, or staging environment) has a local checkout of the v1.5.2 branch. The `git push origin :v1.5.2` command will delete the branch in the remote, but does not delete the local version of the branch (if it exists) in all repos. This leads to an ambiguous reference, when trying checkout `v1.5.2` in those repos:               $ git checkout v1.5.2     warning: refname 'v1.5.2' is ambiguous.      Can this be avoided without using a different syntax for the branches, e.g. `release-v1.5.2`, or `v1.5.2-rc`? Or is it unavoidable, and therefore a fundamentally bad idea to create a tag with the same name as a deleted branch?


title: Should I store test files in source control?

text: I have a number of (large) test files that need to be maintained. This means access to their history is a requirement. **Benefits**   * Any new developers get the entire test suite with just a `git pull`.   * The history of the files is backed up.   * The files themselves are backed up. **Drawbacks**   * Huge increase in size of repository.   * Huge increase in download size of new developers copying the repository. What are the best practices for maintaining test files? Do I store these files in source control? Are there any alternatives?


title: Sprint Planning Meetings - determine if a work item is "planned"?

text: We've been working with Scrum for a while now, generally successfully. However of late, as the pressure has started to mount up we've encountered several situations where items came through planning meetings but when it actually came time to code, it became apparent they were woefully under-specified. This is an annoying and awkward waste of time. So I'm wondering, is there anything we can do to make sure that a work item is properly understood and planned before it's included in a sprint? We don't use TDD, but my experiences with it suggest that it's a good way of ensuring a programmer understands a task before beginning work. So I did consider trying to work out some automated testing as a possible approach to this. But not all work items are amenable to automated tests, and it's likely to be difficult/boring for non-programmers in the meeting. As an aside, out of curiosity, is when one has decided on acceptance criteria, should they go on a work item, or a user story, or both?


title: Wrapper around C++ STL

text: Where I work we have our own system library, which pretty much is only wrappers around the STL, such as:               template <typename T>     class HVector {     protected:         std::vector<T> data;     public:         int size () const; //Only returns data.size()         int custom(); //Some generic custom function that uses the data vector     }      Most of the class members are just re-declarations of the STL container members, but we also have a few customized functions that do some generic tasks with the container. Is this a good design? If not, what would be the best way to implement the customized functions around the containers?


title: Mobile number validation

text: I am trying to find best way to validate a mobile number with in a country. Currently my understanding is: User can enter whatever format they want in mobile numbers and its a waste of time and energy to validate it against a set of regular expressions. My application is not a critical one like banking application and if the user is entering an invalid mobile number, it is at his own risk to get updates (like activate account/ do something with the application) So I think the best way is to check for mobile number length and whether all are digits. I want to know the best way forward and is there any good resource (non- scattered) to get all mobile number length validations based on a country code?


title: Pictures from iPhone to clients FTP server - Directly (iPhone->FTP) or Cloud (iPhone->Amazon->FTP)

text: My clients wants to take pictures with their iPhone's and place them collectible on their server, suggested by FTP. I can see there is two solutions:   1. Directly upload from the iPhone to the FTP server. My colleague can make so the get the ActiveDirectery username and password, so they do not use the same password all of them.   2. Upload them directly to Amazon S3, where I then have a worker which takes the image and puts it on the ftp server. I can do this easily with Python. I will use Kinvey to manage users. Is nr. 2 overkill on short terms? Or is the downsides with creating a FTP connection on a iPhone? My boss thinks it makes it unnecessary more complicated with that extra link. I can easily see what my boss mean, and think he is right. The problem is that I have not tried FTP'ing in Obj-C and do not know how hard or difficult it can might be. I know phonegap, which could easily upload to Amazon.


title: Should I reference a CopyOnWriteArraySet from the Set interface?

text: There are two ways to use a CopyOnWriteArraySet:               // A     Set<Object> set = new CopyOnWriteArraySet<>();      and               // B     CopyOnWriteArraySet<Object> set = new CopyOnWriteArraySet<>();      With 'normal' sets like HashSet and TreeSet, case A is preferred, because it allows easy switching of the Set implementation. However, in this case a conscious choice is made for a specific thread-safe Set implementation. Should I use case B to signify this intent?


title: Is a coder that 'quality checks' bug fixes and bugs raised by testers a recognised role?

text: I've recently found myself frequently in the position where I'm checking both bug fixes by other programmers, and bugs raised by the QA team. Any bug fixes frequently end up having 'collateral damage', and I've found it invaluable to go through any recent fixes, and analyze what other parts of the system could potentially have been impacted by the changes. It's been instrumental in maintaining the reliability of the system. Without this process, the testers generally find new bugs raised, and rarely recognize the cause as the recent bug fix. I'm also quite often going through new bugs raised by the testers, analyzing possible causes to determine if there's a root cause that may impact on other parts of the system, quite frequently merging two or more bugs into one case. It's essentially doing the 'investigation' part of the bug fixing process, so that another programmer can focus on just the coding. The question is, is this a recognised role? It doesn't seem to fit into the 'Programmer' or 'QA' job title neatly, it's kind of in-between. Or is the need for this role more a consequence of bad process or bad design?


title: Modern approaches to retrieve useful content from a web page?

text: What are the modern ways to (effectively) determine which part of page contains useful text, data tables, etc. and which are not (e.g. ads, navigation, etc.)? What were the last valuable researches/result/papers in this field in latest years? Thank you in advance!


title: Keep permuting a vector until it is ordered

text: I have this problem: Imagine you have a vector V, integers from 0 to 70000 -- sorted in ascending order Now you have a permutation P of that vector. Then you do V[P] "shuffling" the vector. If you keep doing V[P] (P never changes), V will eventually be sorted again in ascending order? Is there a way you may know, a priori, how may shuffles you need?


title: Do backend developers care what their code looks like in the frontend?

text: As a backend and a frontend developer I see the process from start to finish, first by creating the logic, displaying the correct data on a web page and then using frontend skills to make this look awesome. My question is, do pure backend developers care what their code ends up looking like in the frontend? As far as the user is concerned, they will ONLY see design/frontend. They don't actually care that your code is clean, DRY and maintainable. As long as it doesn't disrupt their payment process or flight booking they do not care. Does this affect the average backend developer?


title: Asynchronous Programming in Functional Languages

text: I'm mostly a C/C++ programmer, which means that the majority of my experience is with procedural and object-oriented paradigms. However, as many C++ programmers are aware, C++ has shifted in emphasis over the years to a functional-esque style, culminating finally in the addition of lambdas and closures in C++0x. Regardless, while I have considerable experience coding in a functional _style_ using C++, I have very little experience with actual functional languages such as Lisp, Haskell, etc. I've recently began studying these languages, because the idea of "no side- effects" in purely functional languages has always intrigued me, especially with regards to its applications to concurrency and distributed computing. However, coming from a C++ background I'm confused as to how this "no side- effects" philsophy works with asynchronous programming. By asynchronous programming I mean any framework/API/coding style which dispatches user- provided event handlers to handle events which occur asynchronously (outside the flow of the program.) This includes asynchronous libraries such as Boost.ASIO, or even just plain old C signal handlers or Java GUI event handlers. The one thing all of these have in common is that the nature of asynchronous programming seems to _require_ the creation of side-effects (state), in order for the main flow of the program to become aware that an asynchronous event handler has been invoked. Typically, in a framework like Boost.ASIO, an event handler _changes_ the state of an object, so that the effect of the event is propagated beyond the life-time of the event handler function. Really, what else can an event handler do? It can't "return" a value to the call point, because there is no call point. The event handler is not part of the main flow of the program, so the only way it can have any effect on the actual program is to change some state (or else `longjmp` to another execution point). So it seems that asynchronous programming is all about asynchronously producing side-effects. This seems completely at odds with the goals of functional programming. How are these two paradigms reconciled (in practice) in functional languages?


title: Are there any design patterns that are unnecessary in dynamic languages like Python?

text: I've started reading the design pattern book by the GoF. Some patterns seem very similar with only minor conceptual differences. Do you think out of the many patterns some are unnecessary in a dynamic language like Python (e.g. because they are substituted by a dynamic feature)?


title: Why do we need private variables?

text: Why do we need private variables in classes? Every book on programming I've read says this is a private variable, this is how you define it but stops there. The wording of these explanations always seemed to me like we really have a crisis of trust in our profession. The explanations always sounded like other programmers are out to mess up our code. Yet, there are many programming languages that do not have private variables.   1. What do private variables help prevent?    2. How do you decide if a particular property should be private or not? If by default every field SHOULD be private then why are there public data members in a class?    3. Under what circumstances should a variable be made public?


title: Why shouldn't I be using public variables in my Java class?

text: In school, I've been told many times to stop using `public` for my variables. I haven't asked why yet. This question: Are Java's public fields just a tragic historical design flaw at this point? seems kinda related to this. However, they don't seem to discuss _why_ is it "wrong", but instead focus on _how_ can they use them instead. Look at this (unfinished) class:               public class Reporte {              public String rutaOriginal;         public String rutaNueva;         public int bytesOriginales;         public int bytesFinales;         public float ganancia;              /**          * Constructor para objetos de la clase Reporte          */         public Reporte() {              }     }      No need to understand Spanish. All this class does is hold some statistics (those public fields) and then do some operations with them (later). I will also need to be modifying those variables often. But well, since I've been told not to use `public`, this is what I ended up doing:               public class Reporte {              private String rutaOriginal;         private String rutaNueva;         private int bytesOriginales;         private int bytesFinales;         private float ganancia;              /**          * Constructor para objetos de la clase Reporte          */         public Reporte() {              }              public String getRutaOriginal() {             return rutaOriginal;         }              public String getRutaNueva() {             return rutaNueva;         }              public int getBytesOriginales() {             return bytesOriginales;         }              public int getBytesFinales() {             return bytesFinales;         }              public float getGanancia() {             return ganancia;         }              public void setRutaOriginal(String rutaOriginal) {             this.rutaOriginal = rutaOriginal;         }              public void setRutaNueva(String rutaNueva) {             this.rutaNueva = rutaNueva;         }              public void setBytesOriginales(int bytesOriginales) {             this.bytesOriginales = bytesOriginales;         }              public void setBytesFinales(int bytesFinales) {             this.bytesFinales = bytesFinales;         }              public void setGanancia(float ganancia) {             this.ganancia = ganancia;         }     }      Looks kinda pretty. But seems like a waste of time. Google searches about "When to use public in Java" and "Why shouldn't I use public in Java" seem to discuss about a concept of **mutability** , although I'm not really sure how to interpret such discussions. I do want my class to be mutable - all the time.


title: Why shouldn't I make variables public, but should use public getters/setters?

text: I'm watching a C++ tutorial video. It is talking about variables inside classes and assert that variables should be marked private. It explains that if I want to use them publicly, I should do it indirectly through functions. Why? What's the difference? It looks like the result is the same, except that instead of having one line of code, I now have like 9 or 10 more LOC to do the same thing. Can someone explain why converting a private variable in a class to public within the class rather than just making it public right out the simple way is any different and more efficient?


title: Do ALL your variables need to be declared private?

text: > **Possible Duplicate:**   >  Why do we need private variables? I know that it's best practice to stay safe, and that we should always prevent _others_ from directly accessing a class' properties. I hear this all the time from university professors, and I also see this all the time in a lot of source code released on the App Hub. In fact, professors say that they will actually take marks off for every variable that gets declared public. Now, this leaves me _always_ declaring variables as private. No matter what. Even if each of these variables were to have both a getter and a setter. But here's the problem: it's tedious work. I tend to quickly lose interest in a project every time I need to have a variable in a class that could have simply been declared public instead of private with a getter and a setter. So my question is, do I really need to declare _all_ my variables private? Or could I declare _some_ variables public whenever they require both a getter and a setter?


title: How do you handle the need to have multiple development environments?

text: How do you deal with different project environments? Every project might require a different database (oracle, IBM db2, mysql & etc), a different server (tomcat, IBM WAS, weblogic & etc) or some other new technologies. Every time a new database or new server comes in, I install them on to my workstation for my convenience. Right now I have more than one database and server on my workstation and it has caused my workstation take some time at startup. I have to wait a period of time for my workstation to be ready for me to start working. Sometimes when I install database A, it causes my previous database B to have issues. I found that this will take a lot of my cpu usage although I'm not using them at the moment. In this case, I can think of only one method, I can install the databases on to one virtual machine and the servers on to another virtual machine. Or one project environment one virtual machine. Then I can start just the one that I need it. What do you think?


title: What are the differences between abstract classes, interfaces, and when to use them

text: Recently I have started to wrap my head around OOP, and I am now to the point where the more I read about the differences between abstract classes and interfaces the more confused I become. So far, neither can be instantiated. interfaces are more or less structural blueprints that determine the skeleton and abstracts are different by being able to partially develop code. I would like to learn more about these through my specific situation. Here is a link to my first question if you would like a little more background information: What is a good design model for my new class? Here are two classes I created:               class Ad {         $title;         $description         $price;              function get_data($website){  }              function validate_price(){  }      }               class calendar_event {         $title;         $description              $start_date;              function get_data($website){ //guts }              function validate_dates(){ //guts }      }      So, as you can see these classes are almost identical. Not shown here, but there are other functions, `like get_zip()`, `save_to_database()` that are common across my classes. I have also added other classes Cars and Pets which have all the common methods and of course properties specific to those objects (mileage, weight, for example). Now I have violated the **DRY** principle and I am managing and changing the same code across multiple files. I intend on having more classes like boats, horses, or whatever. So is this where I would use an interface or abstract class? From what I understand about abstract classes I would use a super class as a template with all of the common elements built into the abstract class, and then add only the items specifically needed in future classes. For example:               abstract class content {         $title;         $description                   function get_data($website){  }              function common_function2() { }         function common_function3() { }      }               class calendar_event extends content {              $start_date;              function validate_dates(){  }      }      Or would I use an interface and, because these are so similar, create a structure that each of the subclasses are forced to use for integrity reasons, and leave it up to the end developer who fleshes out that class to be responsible for each of the details of even the common functions. my thinking there is that some 'common' functions may need to be tweaked in the future for the needs of their specific class. Despite all that above, if you believe I am misunderstanding the what and why of abstracts and interfaces altogether, by all means let a valid answer to be stop thinking in this direction and suggest the proper way to move forward! Thanks!


title: Interfaces vs Base class

text: I'm strugging to know when to use a base class with Polymorphism or an interface. Providing my object exposes DoThis() then I can't see why it matters if it's an interface of a base class. Please consider the following               public void MyMethod()     {         var myObject = new MyObject();         myObject.DoThis();     }      In regards to MyObject, I could have created it in 2 ways Approach 1               public class MyObject : IMyInterface     {         public void DoThis()         {             //logic         }      }      Approach 2               public class MyObject : MyBaseObject     {         public override void DoThis()         {             //logic         }      }      From what I can see, both of these implementations achieve the same thing. The issue could be my example is too simple/contrived but, is there a way to know when to use one approach over the other? In my example above, I would _guess_ the answer is preference? I've not done any big projects before and so I'm guessing that one isn't as extendible but I don't know why I think that!


title: How long should I provide free updates for my shareware - per version, per year, or forever?

text: I will release my first shareware soon and I'm wondering for how long should a paying user be entitled to free updates. I can think of three options:   * You buy a version then all the updates are free for one year (eg. SmartFTP)   * You buy a version then all the minor updates (mostly includes bug fixes) are free (eg. UltraEdit)   * You buy a version and all the minor and major updates are free forever (eg. Total Commander) It seems that different applications use different ways. What would you recommend?


title: UPOS RFIDScanner data format

text: A lot of work that I do currently is based in the OPOS/UPOS world. My company has a device that can read 13.56Mhz tags (RFID), Smart Cards, and Mag Stripe cards. Up until somewhat recently I have only been working with RFID for a very specific scenario. That was to read UltraLight C and Desfire cards. These cards were all setup very specifically so that I could take the data read from those cards and force it into a MSR track2 format. The past couple of weeks, however, I have been working on reading RFID credit cards (since I have a Visa card I've been using mine), and Smart Card credit cards. (The visa card I have has both) In learning how to communicate with SmartCard and reading ISO7816 and EMVCO documents I became a little more familiar with how info is stored. But now I have a question regarding UPOS. The RFID data on my Visa is stored (and read) very similar to how the data is stored and read from the Smart Card on my Visa. Cool. Well in the UPOS spec for SmartCardRW the ReadData method returns a byte array. That's cool, I can just return all that data and then parse it as my heart desires. The RFID though has a LinkedList of Tags. Well this makes sense in terms of my Visa card (reminds me of a question I have in regards to SmartCard, but that is for another question) but what about ULC and Desfire, or for that matter any Mifare card. Pages, Files, Purses don't exactly fit the Tag profile. For instance lets just say I read pages 4-12 on my ULC card. Each page I read is 4 bytes long. Does this mean I have 9 tags in my LinkedList? Is my Tag id the page number? Or then how does that translate to Desfire? I open application 123456 and read file 1 and file 2, Do I have 2 tags? and if so what is my tag id? At least with my Visa I _think_ that I have to use the Tag id (ex 5F24 for my expiration date) and value of {0x15, 0x10, 0x31} Part of me says yes..that makes sense. Another part of me says, "well if that is the case then why doesn't SmartCardRW have Tags?" So that is my question. How do I format my data from those different types of media? or is that the job of my Control Object (the application)? Is so how does it know? The only protocols I have are:               // Summary:     //     Enumerates the available predefined RFID tag protocols the device supports.     [Flags]     public enum RFIDProtocols     {         EpcClass0 = 1,         RFIDSdt0Plus = 2,         EpcClass1 = 4,         EpcClass1Gen2 = 8,         EpcClass2 = 16,         Iso14443A = 4096,         Iso14443B = 8192,         Iso15693 = 12288,         Iso180006B = 16384,         Other = 16777216,         All = 1073741824,     }      If I use that well all of my cards that I have are all Iso14443A. I use the ATQA and the SAK to know what type of card I really have. There is no RFID property that lets me specify that. So I'm lost.


title: Flowchart for solving programming problems

text: I noticed that every developer implements a somewhat different flowchart for solving programming problems. By flowchart I mean a defined system of techniques that the developer goes through in a certain sequence, trying to solve the problem at hand. Some examples for techniques:   * Google "how to..." or "... tutorial".   * Search the java/msdn/apple/etc API doc for the specific class or method.   * Search in stack overflow the exact problem with some tags like [iphone]/[java] etc.   * Take a nap and let the subconscious work.   * Debug.   * Draw the algorithm or system.   * Google the logged error message.   * Ask a colleague or manager.   * Ask a new question in stack overflow. From your experience, what is the best flowchart for solving a programming problem?


title: Does Java development typically involve more subclassing than C#/.NET?

text: I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly as much as (I think) I do now. Having mainly used C# in my career, I'm noticing a startling difference in how inheritance is used Java and C#. In C# it seemed like inheritance could be avoided in most situations. The task at hand could usually be accomplished by using concrete classes of the .NET framework. In Java, from what I'm gathering from code samples, it seems like the Java framework supplies many interfaces or abstract classes that are then meant to be implemented/extended by the developer. This seems to be too big a difference to just boil down to style. What is the reasoning behind this? I feel like I won't be writing clean Java code until I understand this. Also, is this limited to just the Android SDK or is this a Java-wide approach to OOP? Or put in another way, What is it about the design of these two languages that (seems to encourage) more or less inheritance use than the other? If the languages treat inheritance identically, and assuming my observation is valid, then it means this is related to the design of the frameworks/libraries and not the languages. What would the motivation be for this kind of design?


title: How to popularize Nemerle (or another programming language)?

text: Any .NET developer who is interested in different programming languages knows that F# is the most popular functional language for the .NET platform nowadays. The only fact describing the popularity of F# is the great support of Microsoft. But we are not limited with F# at all. There are some other functional languages on the .NET platform. I'm very disappointed with the fact that Nemerle isn't well-known. It's an awesome language which supports three paradigms: object-oriented, functional and meta- programming. I won't try to explain why I like it so much. The problem is that I can't use it at work. I think that only really brave companies can rely on Nemerle. It's almost unknown, that's why it's hard to find new developers for the project. Noone wants to make a first step with Nemerle if it can influence the budget what is reasonable. So, here is a question: **what can I do to make Nemerle more popular?** Here are my first ideas:   * implement open-source projects using Nemerle;   * make presentations on different conferences;   * write articles.


title: How soon existing projects should be upgraded to newer version of the technologies powering it?

text: In large scale applications (e.g. Banking Domain), what is the criteria of upgrading an existing project to a newer version of the technology on which it is built? For instance, a .NET application built on .NET Framework 3.5 and using Oracle 9i back-end. There are not any specific urgent requirements, but should I think of upgrading to .NET 4.5 and Oracle 11g in the near future? Is it advantageous to keep pace with the technology version?


title: What is the difference from the push and pull development models?

text: I was reading Extreme Programming Explained, Second Edition and in the chapter 11 "The Theory of Constraints" the authors talk about the old and obsolete **"push" development model** and the XP way, the **"pull" development model**. It looks like a quite important concept, but it takes only a very small paragraph and two images that are mere illustrations of the "waterfall" and iterative process, nothing specific about these models except by the image caption. I searched and it doesn't go any further about it in the rest of the book. I couldn't find any further explanations or discussions about it in the Internet either. If the only difference about those is that one is **"waterfall"** and the other is **iterative** , them why push and why pull? Does anyone understand what is really the difference between those two and give some good examples?


title: How can I prototype a very abstract theoretical framework?

text: I've had an idea for a semantic model of computing that's theoretically sound but is also quite unusual. I'd like to quickly prototype a system to prove that it can work in practice. Most of my work is in programming languages, so I'm comfortable putting together a small language for the purposes of testing, but I wonder if this is the best approach, as it necessitates a certain amount of advance work on the linguistic side that's not directly related to the computational model. So what is the best prototyping strategy for a very high-level theoretical framework such as this? Should I go with a new language, or an embedded DSL, or some other approach? I can provide a bit more background if necessary, but this doesn't need to turn into a discussion of the specifics of the model.


title: Releasing software/Using Continuous Integration - What do most companies seem to use?

text: I've set up our continuous integration system, and it has been working for about a year now. We have finally reached a point where we want to do releases using the same. Before our CI system, the process(es) that was used was:               (Develop) -> Ready for release -> Create a branch -> (Build -> Fix bugs as QA finds them) Loop -> Final build -> Tag          (Develop) -> Ready for release -> (build -> fix bugs) Loop -> Tag                    Our CI setup:     1 server for development (DEV)     1 server for qa/release (QA)      The second one has integrated into CI perfectly. I create a branch when the software is ready for release, and the branch never changes thereafter, which means the build is reproduceable without having to change the CI job. Any future development takes place on HEAD, and even maintainence releases get a completely new branch and a completely new job, which remains on the CI system forever, and then some. The first method is harder to adapt. If the branch changes, the build is not reproduceable unless I use the tag to build [jobs on the CI server uses the branch for QA/RELEASE, and HEAD for development builds]. However, if I use the tag to build, I have to create a new CI job to build from the tag (lose changelog on server), or change the existing job (lose original job configuration). I know this sounds complicated, and if required, I will rewrite/edit to explain the situation better. However, my question: [If at all] what process does your company use to release software using continuous integration systems. Is it even done using the CI system, or manually?


title: Buffer-overflow vulnerabilities that a static code analyser won't pick up

text: I'll use FlawFinder in this example. FlawFinder is a static code "analyser" tool that examines C/C++ source files and outputs warnings/hits if a vulnerability was identified. The way it does this is by using text pattern matching for function names and their parameters. It then matches these against a pre-defined database of commonly known issues/vulnerabilities associated with different standard library functions. E.g.               #include <stdio.h>          int main()     {        char str[50];             printf("Enter a string : ");        gets(str);             printf("You entered: %s", str);             return(0);     }      This will cause FlawFinder to generate a hit at the line calling the `gets(str)` function. It will warn against a potential buffer overflow and advises the developer to use fgets() instead. I'm suspecting that this may cause some false positive results in some cases, as it doesn't actually "analyse" the code and the context but just matches function names against a set of predefined warnings. But I was wondering if there's a situation where you could have an obvious buffer overflow vulnerability that wouldn't be identified by a tool like FlawFinder or in general most static code analysis tools? Specifically in a C/C++ environment.


title: What do you think of this Exception handling practice

text: I'm working on a project that includes a lot of creating/manipulating and reading JSONObjects and arrays but not in a systematic way. So there is JSON code everywhere.   It is ok for me except that every time I work on a JSONObject I got to handle JSONException.   So I created a class that extends JSONObject and Override the put/get methods in it and handled JSONExceptions inside this class.   It made my code way much clearer and I believe it is more than enough for my case. What do you think?


title: The purpose of using a constants pool for immutable constants

text: _Originally posted atstackoverflow.com/q/23961260_ * * * I come across the following code with a lot of frequency:               if (myArray.length == Constants.ZERO_INT)       or               if (myString != null && !myString.equals(Constants.EMPTY_STRING))       Neither of these makes much sense to me. Isn't the point of having a constant pool for ease of code appearance and to allow for modularity? In both of the above cases, it just looks like needless noise that accomplishes neither objective. My question: what is the purpose of using a constants pool for variables like this which will never change? Or is this just cargo cult programming? If so, then why does it seem to be prevalent in the industry? (I've noticed it with at least two different employers I've worked with).


title: When inheriting from a base class, should you retest constructor arguments?

text: Say I have something like this:               public class BaseClass     {         public BaseClass(string someString)         {             if(someString == null)                 throw new ArgumentException();         }     }          public class ChildClass : BaseClass     {         public ChildClass(string someString)             : base(someString)         {             // Should I do this??             if(someString == null)                 throw new ArgumentException();         }     }      Also, what if I'm inheriting a class that I do not have the source for. Should I recheck constructor arguments?


title: Where to store web application custom configuration settings

text: I'm currently working on an internal web application for my company in node.js We want to have certain configuration settings be changeable by management. For example, we pre-print some labels automatically during receiving if the quantity is less than 5 so the user doesn't have to stop to confirm a print dialog. What if we wanted to shift this to any quantities less than 10 because it is found to be more efficient? My question is this: What's the best approach to save custom configuration settings if I was to create an area for changing these params on their dashboard? Would saving this information in a json formatted text file on the server and then just parsing it using fs every time be the best way? or is there something I'm not thinking of? Thank you in advance.


title: Could JQuery and similar tools be built into the browser install?

text: After reading another question about JQuery and CDN's, is it feasible for tools like JQuery to "come with" the browser, thus reducing/eliminating the need for the first download from a CDN, or from your own host server. JQuery files specifically are pretty small, so you could easily have a number (all?) of the different versions as part of a browser install. Now fair enough, this would increase install footprint, download time for the browser itself. Then sites could check "local" first, before CDN (which then caches), before finally defaulting to downloading from the website server itself. If this is feasible, has it been done, and if not, why hasn't it be done?


title: Teaching version control (git, mercurial) to undergraduates?

text: I'm teaching a scientific programming course to undergraduates, targeted at freshmen/sophomores who are seeing the command line for the first time but are likely to need version control in future classes and careers. Are there resource for teaching version control (to those who have never seen it) available? What aspects should be taught first / emphasized most?


title: How do you decide what code to put into a function?

text: I started out with a script that was a few hundred lines. Later, I realized I wanted another script that would require much of the same code. I decided to wrap certain areas of the original script that would be shared, into definitions. When I was deciding exactly what should be in a function, I came across various things to consider:   1. What should I set as its input parameters? If anything was needed in the function, I should probably require it as a parameter, right? Or should I declare it within the function itself?    2. If function x always requires the output of function y, but function y sometimes is needed alone, should function X include the code of function y or simply call function y?    3. Imagine a case where I have 5 functions that all call a function 'sub' (sub is essential for these 5 functions to complete their work). If 'sub' always is supposed to return the same result, then wouldn't multiple calls from these parent functions duplicate the same work? If I move the call to 'sub' outside of the 5 functions, how can I be sure that 'sub' is called before the first call to any of the 5 functions?   4. If I have a segment of code that always produces the same result, and isn't required more than once in the same application, I normally wouldn't put it in a function. However, if it is not a function, but is later required in another application, then should it become a function?  Sorry if these questions are too vague, but I feel there should be some general guidelines. I haven't programmed for very long, and bounced around between OOP and functional, but I've never remembered reading anything that explained this. Could it simply be a matter of personal preference?


title: Python methods vs builtin functions

text: Python widely uses built-ins (or module function) and not class methods. So   * `len([])` instead of `[].length()`   * `filter(f, [])` instead of `[].filter(f)`   * `str(2)` instead of `2.to_str`   * same for `map`, `foreach` etc These prevent you from doing nice chaining which is possible in other languages like Ruby or Scala: (sorry very artificial example)               my_list.map(f).filter(g).length()      In Python you would need to either split into several lines:               list_of_something_else = map(f, my_list)     list_of_something_else_without_blah = filter(g, list_of_something_else)     length = len(list_of_something_else_without_blah)      In a single expression it doesn't look readable:               len(filter(g, map(f, my_list))      Is it considered to be not-Pythonic to chain methods? Or do people usually extend classes with a dozen of helper functions to make it easier?


title: What is the rule on passing around collections? List vs. Ienumerable vs. IQueryable

text: I do Entity Framework stuff using repository patterns that are passed to the controller to than be called by the client using jquery AJAX.. Is there any basic rules on in what format I should be passing around these lists? Within the server code I suppose I could just pass around an Iqueryable? yes? And to the client I could pass around a list version ? That is my first guess.. any ideas ?


title: When/Where to create/assign event handlers to its elements

text: Lets say I have the following code               // JS          $(function(){             $('[data-mc=logout]').click(function(){                     if (!confirm(myconfig.msg['asklogout'])) {                         return false;                     }             });                  $('[data-mc=ajax]').click(function(){                     var target=$(this).data('target'); //retrieve data-target of the clicked tag                     return false;             });     });      which target some HTML elements               //  HTML          Logout     Start page        1. Am I right when I say that this code needs to be called on every full page load?   2. a: If so, what if one of the elements doesn't exists on the chosen page?   b: To avoid errors an "if exist" check is necessary, right?   c: jQuery will do that prior adding the handler?   3. What if some content gets requested using Ajax and inserted into the DOM. Then this code needs to be called again, right?   4. Is this best practice or should the code be split and called per page load, where only existing element's event handlers gets attached?


title: Are gimmicks ever a good idea?

text: Are adding gimmicks to a website ever a good idea? What I mean by gimmick is adding "cool" features that solve no real problem. We are currently considering adding a "Magazine style" product viewing application to the site. You know like a flash based app that shows magazine pages that you can click and flip the pages with your mouse. I personally think this is terrible idea. We already have a category page where you click on a category and it lists products. So this catalog view is not solving any problems that are not already solved. They want to use it because of its "cool" factor. I personally don't think its cool, I think its cumbersome, but thats besides the point. I am all for adding complex features, but only when those complex features are solving real problems. I think this worst part of all is there are now 2 paths for the user to take, a category route and a magazine route. I think the shopping route should be linear and I believe too many options like this is distracting and confusing. InDesign has a plugin that can make something like this very easily. So not much time will be wasted on it, but I still think it is a very bad idea. Am I right, or being too opinionated? Can anyone give me any good arguments for either side?


title: What should I expect as a C++ software engineer in a company that develops python web applications?

text: A company is hiring C++ software engineers. When I go to the company's website, they provide a web applications written in python. (At least that's what I see from the outside.) What kind of responsibilities can I expect? Does this sound like server and back end coding? What else? At which point would a python web application most likely switch to C++?


title: Recommendations on running Visual Studio inside a VMWare VDI environment?

text: Does anyone have experience running Visual Studio inside a VDI environment?   * Would you recommend it?   * Would you advise against it? * * * **Our Background** Our department is one of the few in the company that doesn't use thin clients. The head of the department is getting pressure that we too should be using thin clients, in a hope that the help desk and server admins will be more responsive to other departments complaints and issues. I agree with the idea behind it, but I'm very leery of running a program like Visual Studio inside a virtual machine.


title: Returning from a long function on the first false condition

text: I have a long(ish) function of the following pattern:               bool func(some_type_t *p1, another_t *p2)     {       bool a = false, b = false, c = false, etc = false;            a = (some_long && expression && \            (that_deserves | its_own_line));            b = (another || long_expression && \            (that_deserves | its_own_line));            c = and_so && on;            return a && b && c && etc;     }      As you can see, the return value is `true` if and only if all flags are true. Hence I can return as soon as one of them turns out to be `false`. It may or may not be more optimal than the current version, but I want to do it to satisfy my OCPD. I thought of putting everything in a `do{}while(0);` and breaking out on `false`, but that looks odd (and I remember seeing something like that in tdwtf). I do not want multiple return statements or deeply nested if blocks, and I certainly don't want to compromise on readability with a huge if that relies on short circuiting. I can live with `goto` in this case, but I want to know if there are any other patterns/constructs used in similar scenarios.


title: Understanding how memory contents map into a struct

text: I am not able to understand how bytes in memory are being mapped into a struct. My machine is a little-endian x86_64. The code was compiled with gcc 4.7.0 from the Win64 mingw32-64 distribution for Win64. These are contents of the relevant memory fragment: ...450002cf9fe5000040115a9fc0a8fe... And this is the struct definition:               typedef struct ip4 {         unsigned int ihl :4;         unsigned int version :4;         uint8_t tos;         uint16_t tot_len;         uint16_t id;         uint16_t frag_off; // flags=3 bits, offset=13 bits         uint8_t ttl;         uint8_t protocol;         uint16_t check;         uint32_t saddr;         uint32_t daddr;         /*The options start here. */     } ip4_t;      When a pointer to such an structure (let it be `*ip4`) is initialized to the starting address of the above pasted memory region, this is what the debugger shows for the struct's fields:               ip4:          address=0x8da36ce     ip4->ihl:     address=0x8da36ce, value=0x5     ip4->version: address=0x8da36ce, value=0x4     ip4->tos:     address=0x8da36d2, value=0x9f     ip4->tot_len: address=0x8da36d4, value=0x0     ...      I see how `ihl` and version are mapped: 4 bytes for a long integer, little- endian. But I don't understand how `tos` and `tot_len` are mapped; which bytes in memory correspond to each one of them. Thank you in advance.


title: Why is it so hard to make a great app?

text: Maybe a better way to ask the question would be: why is the Facebook app so bad? This is not so much a question specific to the Facebook iOS app, it just uses that as an example. What I want to know is how is it possible that a company like Facebook that has all the resources it needs can make such a bad app. Facebook is famous and "cool" so a lot of devs, designers and architects want to work for them, and it has the money to pay for the best of those. And it's not like it doesn't care about the app. It's not some small internal unimportant project, it's one of the most downloaded apps on the app store. But also one of the most complained about. This brings me to my question, how is it possible that an entity with such resources and desire can end up making such a bad product? To put it another way, what are the main complexities involved in such a big project that can ultimately lead a collection of perfectly skilled individuals to collectively create something that is not so perfect? Put in a more positive way, what is required (other than skilled people) to make a great product?


title: Why can we delete some built-in properties of global object?

text: I'm reading es5 these days and find that [[configurable]] attribute in some built-in properties of global object is set to true which means we can delete these properties. For example: the join method of Array.prototype object have attributes               {[[Writable]]:true, [[Enumerable]]: false, [[Configurable]]: true}      So we can easily delete the join method for Array like:               delete Array.prototype.join;     alert([1,2,3].join);      The alert will display `undefined` in my chromium 17,firefox 9 ,ie 10,even ie6; In Chrome 15 & safari 5.1.1 the [[configurable]] attribute is set to true and delete result is also true but the final result is still `function(){[native code]}`. Seems like this is a bug and chromium fix it. I haven't notice that before. In my opinion, delete built-in functions in user's code is dangerous, and will bring out so many bugs when working with others.So why ECMAScript make this decision?


title: Exercise 3.6: Skiena Algorithm Design Manual

text: I am preparing for interview and try to solve the exercise problems of the book. > 3-6. [5] Describe how to modify any balanced tree data structure such that > search, insert, delete, minimum, and maximum still take O(log n) time each, > but successor and predecessor now take O(1) time each. Which operations have > to be modified to support this? Solution: Maintain extra pointers to the successor and predecessor. Update the pointers on insert and delete. Nothing else right? Or is there some other trick involved. Thanks


title: Javascript heavy page/application - best practice for handling errors

text: Consider an application that contains a number of pages with a relatively large amount of javascript present, or a predominantly JS powered application. The script handles a number things, such as:   * Client side validation   * Showing/hiding entry sections when appropriate   * Autocomplete when filling text fields   * Date pickers etc. If we consider the case that javascript is a requirement to use the site (e.g. not public internet site), I am wondering what the best practice would be for handling an unexpected error that occurs at runtime that causes some of the functionality to no longer be present (e.g. sections remain hidden, calendar controls become empty textboxes etc). The options that I can think of would be:   1. Try to fail gracefully and have a page that will respond with no script present (gets trickier the more complex a page/app becomes). or   1. Try..Catch round all the critical code, and on error, display a message, or redirect to an error page. I am curious if anyone has 'best practice' suggestions for this? * * * My motivation for looking into this comes after an obscure bug with an earlier version of jQuery for a user in IE10 running in compatibility mode. This question is not about that, but the knock on affect was that a lot of the code in a document ready handler in jQuery was not loaded, resulting in significant degredation in usability.


title: Strategies to find memory leak in AIR app with native extension

text: **Background:** I'm working on an Adobe AIR app that has many facets. I'm looking for strategies to find memory leaks. Broadly speaking, the EXE contains an embedded JVM, and an AIR Native Extension for Windows (using C). So there are many moving parts. As one example, I'm using MonsterDebugger which traces either the AIR runtime (or the Flash Player... I'm not sure which). We've used it to find one leak (regarding listeners in ActionScript). I'm also monitoring the EXE via PowerShell and trying to match memory jumps with log files. **Questions:**   * How can I monitor an embedded JVM, that is launched via C in an AIR ANE?   * Any other strategies? I'm treating this as a "whiteboard" question; this is why it's not on Stack Overflow.


title: Way for java program to read file from when it was stopped

text: I am working on an application that reads a log file, looks for a specific string, sends alert emails and saves data from the file into a database. The reading functionality is working well, but I am coming across an issue when I stop and restart my program. Basically, it always starts from the beginning of the log file, so I am rereading information I have already read. Please reference the example below. Consider I have the log file with the following lines               1 0708 1200 Error in log     2 0708 1230 Received invoice 00001     3 0708 1231 Received invoice 00002     4 0708 0130 Error in log      5 0708 0135 Received invoice 00003     6 0708 0200 Received invoice 00004     7 0708 0230 Received invoice 00005     8 0708 0235 Error in log      In this example, say I ran the application. The application would start reading at line 1 and continue until I stop the application (picking up any lines that are added to the file as well). Let's say I stop the application when I get to line 5. If this were the case, I would have received an alert e-mail from line 1 and line 4. I would have also saved lines 2 and 3 in the database. My problem/question comes from when I want to restart the application again. Currently, the application will start reading at line 1 again. This is not an issue when it comes to saving data because I have placed a clause to not save if the line has already been added. However, when it comes to sending e-mails I will receive an e-mail for lines 1 and 4 again. After all of the that rambling, I will present my actual question / inquery. Is there a way to stop a program (it completely stops the process) and begin reading from the spot in which I stopped reading from? I cannot think of a way to save the place holder for the file and use it once I start the program again. I have considered saving the file pointer value to a text file and reading from there at every start up, but I was wondering if there was another way or any suggestions to improve this process. I know this question is abstract, but I am reaching out for extra brains on this issue. Little information:   * This is a java program   * This is a web app running on a tomcat server   * The server that tomcat is running on is a unix server   * This is a constantly running application that should only be shut off during an issue or change   * The logs being scanned are very large with 500,000+ lines   * The logs turn around (get replaced with empty log) once they reach a certain size. This means that when I save the file pointer, I have to make sure I am in the same file before I start reading again, otherwise I want to start from the beginning Any help / suggestions would be very helpful. Sorry for the wordy question, please let me know if anything is unclear. Thanks!


title: Examples of Liskov Substitution

text: I'm facilitating a session next week on the Liskov Substitution Principle and I was wondering if anyone had any examples of violations 'from the trenches'? I'm looking for something other than uncle Bob's rectangle - square problem and the persistent set problem he talks about in A-PPP (although that is a great example). So far I'm using the example of a (very simple) List and an IndexedList as the 'correct' use of inheritance. And the addition of a Set to this hierarchy as a violation (as a Set is distinct; strengthening the pre condition of the Add method). I've also taken this great example and it's solution from this question Both those examples are great but I'm looking for something more subtle and harder to spot. So far I've come up with nothing so if you've got a great, subtle example post it up. Also, any metaphors you've come across that helped you understand LSP would be really useful too.


title: Quality Assurance=inspections, reviews..?

text: Studying this subject extensively, the most books state the following:   * **Quality Assurance: prevention activity. Act of inspection, reviewing..**   * **Quality Control: testing** While there are some exceptions that mention that QA deals with just processes (planning, strategy, standard application etc.) which is IMHO much closer to real QA, yet I cannot find any good reference in Google Books. I believe that inspections, reviews, testing is all **quality control** as it is about checking products, no matter if it is the final one or work products. The problem is that so many authors do not agree. I would be grateful for detailed explanation, ideally with a reference.


title: How bad is using underscore in names?

text: I am mainly a C programmer. In my world, writing `likeThis` or `like_this` is just a matter of style. In Haskell however, it seems that camelCase is the definite choice. Personally, I find the later much more readable. Think `pthread_mutexattr_init` vs `PthreadMutexAttrInit`. What's more, I have configured vim to swap the numbers and their alternate symbols (in C), since numbers happen to be written much less frequently than symbols such as parentheses, star, ampersand etc, which makes life easier on my wrist. As a bonus, this lets me write `this_sort_of_thing` without using the shift key. My question is, from the Haskell programmers, whether using underscore in names is acceptable to the Haskell community or not. Is camelCase an unwritten rule or common convention? Would it be ok to make the public functions `likeThis` but internally write `like_this`?


title: Does ES6 help grow the Ecmascript standard library?

text: With all the noise about EC6, one thing that I realized I haven't heard about is expanding Javascript's standard library. Javascript has a fairly sparse standard library. You need a 3rd party library to do many basic things like date manipulation. I'd rather have more built into the browser via a standard library then have to download Javascript to do basic things. Is this a focus of the standards body? Is it contingent on ES6 modules? Is it even correct to discuss an "Ecmascript standard library" (does the standard specify a std lib like say C++'s spec does) or is it something specific to the Javascript implementation of the Ecmascript standard?


title: MVC and the business rule

text: I need to know where in the MVC should I apply the business rule. Imagine the situation: I have a school and I need to generate a calendar of classes for teachers. Each teacher has a school subject and is only available certain times. I need to generate this calendar in such a way that teachers can performing without timing conflicts. **Here are my questions:**   1. What part of MVC the teacher should be part of? Taking into mind that your timings data are stored externally (such as a SQL database or an XML), it should be a Model, correct?   2. Now, where in the MVC the business rule that will compile the calendar should be developed? Like Controller or a Library?   3. These data could be worked directly into the Model, or perhaps a specific Model to work with other Models? **Now a bit of my vision:** (please, correct me if I'm wrong)   1. The data from the teachers should be handled by a Model. So that I could, for example, get the timing available to him and his school subject. So, Teacher is Model.   2. The compilation of the calendar could be done in a controller or library. Question: but, controllers should be related to routes, and libraries to an API?


title: What are the benefits of closing every if-statement with an else in Python?

text: I am reading Learn Python the Hard Way by Zed Shaw. In this lesson he writes: "Every `if-statement` must have an `else`." What are the benefits of ending every `if-statement` with an `else`? Are there any legitimate reasons not to end an `if-statement` with an `else`?


title: In memory collection vs database vs individual classes for infrequently changed objects

text: I have a ASP.NET application which puts the users through a series of forms in a wizard like fashion and has them fill out fields on the form. In code, these forms and fields are represented as "Step" objects, with a collection of "Field" objects as properties. Currently I have only one Step class, and each individual step is an instantiation of this class with various identifying properties set on it, including the collection of fields. The step objects are persisted in a database and loaded using an ORM. Note these "Step" objects aren't actually responsible for tracking progress of a specific user, they're really just templates that describe step properties like name, display name, step order, etc. Progress is tracked through a series of "ItemStep" objects which basically link one of these "Step" templates to a specific "Project". "ItemSteps" store information about which steps are completed, locked, skipped, etc. However, these step objects and the associated field objects are not designed to be configured by end users. Most changes to the objects would likely break the application without corresponding changes to the code. Given all of this, I see 3 possible things I can do.   1. Moving the steps and fields out of the database and into some sort of in memory collection. My basic thought process is to have a static collection that holds all the steps, which will be hidden behind my existing data access logic.   2. Create a new class for each step, and appropriately define equality methods so that two step objects of the same class are considered equal. Then instead of querying either my in memory repository, or my ORM, all I need to do is new up an instance of the appropriate step class. The only downside is I have to find some way to persist the relationship between an "ItemStep" in the database and the "Step" class it should be instantiated with.   3. Do nothing and keep everything as it is. I figure 1 or 2 will result in a performance improvement since they'll be fewer trips to the database, and will streamline the process of application changes, since I won't have to worry about updating the database. And either 1 or 2 could also make it easier to build out a rich inheritance model around the steps, and move some logic onto the step class itself, instead of where it currently sits, inside my Presenters. Of these three possible solutions, what would you reccommend?


title: Help understanding server-side scripting

text: As far as I understand, there are basically 3 options for doing server-side scripting these days:   1. Using scripting languages that can be directly interpreted/executed by the web server (e.g., PHP and ASP), where the scripts are interpreted/executed on the fly (i.e., as HTTP requests come), the output is embed into HTML pages is then sent back to the client.   2. Using any language (e.g., C, C++, PERL, Python) the operating system of the server is capable of executing (either using an interpreter or using the executable file already compiled) and then using CGI to communicate between the web server and the OS. Output of the scripts comes via CGI to the server in the form of complete HTML pages, and is then sent back to the client.    3. Using Java on a server that can handle servlets/JSPs, which is pretty much the same idea as option 1 above, except using Java instead of PHP/ASP. **Questions** :   1. Is my understanding so far on track, or did I get something wrong?   2. Are ASP and PHP the only languages that can be interpreted and executed directly by a web server?   3. Where does Ruby fall in the classification above? Can it be interpreted/executed by servers like PHP? Or does it communicate via CGI?   4. Is server-side scripting via CGI becoming obsolete or not at all?


title: Where to put sample data in project structure

text: I am working on a Scala project and I want to include some sample data somewhere in the project. Specifically, my Scala project includes code that performs various natural language processing tasks on text data. I want to include a sample set of text files that the user can use to test out the program somewhere in the project structure. Right now I am putting this sample data in the resources folder (mostly because it is the only location within the project that I know how to read from). But I was wondering if this is the best location? In general what is the best practice regarding where to put sample data within the project? Alternatively, would it be a better idea to simply provide this data separately (i.e external to the project)?


title: Architecture Decoupling

text: I have set up my ASP.NET MVC project as follows: Presentation Layer : ViewModels, Views, Certain logic to handle service responses Business Logic / Service Layer : Services that work with data from either database or presentation layer. (Domain models is EF entities) Database Access Layer : Entity Framework. according to http://www.asp.net/mvc/tutorials/getting-started-with-ef-using- mvc/advanced-entity-framework-scenarios-for-an-mvc-web-application#repo a repository/unit of work pattern is no longer needed with EF6. And working with ASP.NET Identity creating a interface for DbContext is hard, making all services have a tight coupling to the ApplicationDbContext. Is this okay? in the scenario you have to change database to NoSQL, you would have to change all the Services code instead of just the "middleware". Any comments to architecture is welcome aswell. I am trying to find a good stand point for creating an application.


title: When should user stories be combined and separated?

text: As a school project, we are rolling out our initial set of user stories. Should a user story record the original idea from a user, without combining them or separate them? For example, John added that "I want to post multiple choice questions.", and Mike added that "Except multiple questions, I want to post true/false questions." David added that "I want a confirmation box before I add questions" Do you leave those 3 user stories as it is, or you want to combine John's and Mike's as "I want to post multiple choice and true/false questions." and within this new user story a detail like "show a conformation box before clicking the add buttion"? What do you choose?


title: How to convert this recursive problem to iterative? Line Simplification algorithm fails to run due to Maximum Recursion Depth being hit

text: I am implementing the Douglas, Peucker's Line Simplification algorithm in Python. I started with this implementation. However, it fails to run in Python due to Maximum Recursion Depth being hit. How can I convert this algorithm to a iterative one? I am not able to imagine this problem in an iterative view. My expectation is to get approach/hint which can be used rather than actual code. Is it possible to use some internal stack to resolve the stack overflow (or avoid the maximum recursion depth)? **Update:** Found the iterative implementation of the algorithm here.


title: How to get up to speed on latest technologies?

text: I am working as Software Developer for Financial Company and we are using standard Java/Java EE stack with Oracle db as backend and using Spring/Hibernate framework with JBOSS Application Server. So this is pretty much standard stack and it's an legacy application. Now, I read blogs on Infoq.com and corporate engineering blogs and see people are trying out new technologies like NoSQL(Mongodb, Cassandra), Cloud Computing(AWS), Big Data(Hadoop and it's related eco system) and distributed computing frameworks(Zookeeper, cluster based cassandra...mongodb...hadoop configuration !!!) but I cannot use those technologies in my current project as it's an legacy application and there is no scope and messing around with core components. So my question is,   1. How can I learn and come to speed on all this new technologies?   2. What approach should I take? (I do lot of reading from Infoq and HighScalability about different architectures but never get an experience where i am migration my complete application to ec2 instance and analyze what are benefits of doing that or what all scenarios should we consider with that kind of project) Any thoughts?