Passing an object between different handlers or a Superclass that contains most of the logic

I'm going to try to make this as concise and concrete as possible, but apologies since I can think of multiple ways to make it work. This question might also relate to handling production workflows or manufacturing, but I have no experience in these areas. I have a problem where I need to move an Object, O, from different states to other states (like a Nondeterministic finite automata). The problem is the Object can be in different states at the same time, and the interaction sometimes matters. For example say there are 10 states, O can be in up to 3 of those states at the same time. I'm a bit lost as to what type of code design I should use to model this. The two ideas I am thinking about are   1. Pass O from handler to handler, and manage the transitions between states, and keep some sort of info in O saying which states they are in, so that each state can figure out what to do based on what other states O is in.   2. Have a larger Superclass that handles which states O is in, and handles the interactions. I'd normally say 1. but handling all the interactions between handlers in each handler sounds messy. What would be the better option between these 2? Or is there another method that is preferred? ** Update and Clarification ** As a concrete example. The Object can be in one of many physical locations, while it can also be in one of several stages of processing (The object might move back and forth between locations, or back and forth between the stages of processing). As additional complexity each physical location might have sublocations, but I think I can ignore that for now. So if it's clearer, it can be considered to be two independent automata, but choosing the edge to move to the next state in either automata depends on it's state from both automata.


Can I minify Javascript that requires copyright notice?

I guess this is actually a legal question, but it relates to software. I'm about to include a JS plugin in a project. The comments include: >   * Redistributions of source code must retain the above copyright notice, > this list of conditions and the following disclaimer. * Redistributions in > binary form must reproduce the above copyright notice, this list of > conditions and the following disclaimer in the documentation and/or other > materials provided with the distribution. >   1. Is using this in my web site "redistribution?"   2. If I minify this to conserve bandwidth, I assume it will strip all comments. **If the answer to #1 is yes, doesn't that imply I'm legally not allowed to minify it?** (That would stink, since I was planning to auto-minify all JS as part of the deploy process.)


how to prove the complexity of an algorithm mathematically

I know the fundamental algorithms and it's complexities. for e.g if Binary Search has Complexity O(log n), then how I can mathematically prove this?


Which of these 3 languages is easiest to convert to Delphi?

I am intending to purchase some source code for my Delphi program. It is not too big an algorithm, but it is not available in Delphi and I'll have to translate it to Delphi. However, I have not worked in any of the languages it is offered in and I don't know which I should buy. I want the one that will translate to Delphi most easily and accurately. The three languages are: C++, Java, and C#. Which one would be easiest to convert?


In a functional requirements document, is the Assumptions section dangerous?

I am currently a reviewer on a Best Practices document for Developers or Business Analysts in writing a Functional Requirements document. This document is not necessarily a template for functional requirements documents, but a guide to what elements are necessary, optional, and dangerous to include a Functional Requirements document. The author of the document states that: > Functional Requirements documents should NEVER have an Assumptions secion! > Do not assume anything about what people know about this application or any > external issues surrounding it. I am not sure that I agree with this sentiment but don't really have the words to refute it either. In a perfect world the analyst will have time to properly analyze every stakeholder input and every possible external issue but inevitably due to time constraints and other issues some assumptions need to be made. Is this a bad idea because it is too easy for the intellectually lazy to declare assumptions rather than requirements? If not then why do you think Assumptions are a good idea? **EDIT:** To clarify, I am not asking about the Assumptions section of technical documentation but of an Assumptions section in a requirements document written by a non-technical business analyst.


How are we supposed to deal with Customers who don't give a damn?

I have some customers who expect everything for next to nothing. They also want things to behave a certain way, or look a certain way, but when explaining to them why it's not a good idea to implement a certain feature and offering suggestions, they don't listen. When things go wrong, they get moody, and demand I change/recode the entire feature to their liking, but when told that it's because they wanted it that way, they don't listen. I've found that after years of being around these types of people, it's had a major impact on the way I deal with people I can't stand, and I've seriously run out of ideas. How do you deal with people who never listen, never learn, and want everything for free?


How to depict Import a file action in the Sequence diagram

Everyone says sequence diagrams are so easy but I just cannot figure this out. Basically user clicks on an 'Import from temp folder' button, the program opens a window with a list populated with filenames, user clicks on a filename, clicks on OK and the document is imported. I know the order of the actions but how to depict e.g. populating a list, or selecting an item from a list? So I assume the objects would be like:               [USER]  [ImportDialogWindow]    [ListOfFiles:STRING]   [?where to go with selected file]


Packaging PHP/Python files inside android .apk files?

I am developing an android app using HTML5. I want to make it work completely offline. I know that it is possible to package the .html, .css and .js files inside the .apk file itself in the "resources" but is it possible to also package PHP or Python files inside the .apk file itself? So that no internet connection would be required to run the app?


unit testing on ARM

We are developing application level code that runs on an ARM processor. The BSP (low level code) is being delivered by a 3d party so our code sits just on top of this abstraction layer (code is written in c++). To do unit testing, I assume we will have to mock/stub out the BSP library(essentially abstracting out the HW), but what I'm not sure of is if I write/run the unit test on my pc, do I compile it with for example GCC? Normally we use Realview compiler to compile our code for the ARM. Can I assume that if I compile and run the code with x86 compiler and the unit tests pass that it will also pass when compiled with RealView compiler? I'm not sure how much difference the compiler makes and if you can trust that if the x86 compiled code pass the unit tests that you can also be confident that the Realview compiled code is ok.


Why are HDL IDEs so user-unfriendly when compared to generic-purpose language (like Java/C) IDEs?

I've been programming for a while now, and I've covered a lot of languages. And this trend that I noticed is that all HDL languages have so painful IDEs! In general, any development environment having some Hardware related development has very crappy UI. I'm talking about uVision, ModelSim, VHDL Simili, Xilinx etc, compared with Netbeans, Eclipse, Visual Studio etc. Why do hardware-guys hate their developers? NOTE: There are exceptions (LABView is awsome!). Can you think of any more?


Why a static main method in Java and C#, rather than a constructor?

I’m Looking for a definitive answer from a primary or secondary source for why (notably) Java and C# decided to have a static method as their entry point, rather than representing an application instance by an instance of an `Application` class (with the entry point being an appropriate constructor). * * * ### Background and details of my prior research This has been asked before. Unfortunately, the existing answers are merely begging the question. In particular, the following answers don’t satisfy me, as I deem them incorrect:   * _There would be ambiguity if the constructor were overloaded._ – In fact, C# (as well as C and C++) allows different signatures for `Main` so the same potential ambiguity exists, and is dealt with.   * _A`static` method means no objects can be instantiated before so order of initialisation is clear._ – This is just factually wrong, some objects _are_ instantiated before (e.g. in a static constructor).   * _So they can be invoked by the runtime without having to instantiate a parent object._ – This is no answer at all. Just to justify further why I think this is a valid and interesting question:   * Many frameworks _do_ use classes to represent applications, and constructors as entry points. For instance, the VB.NET application framework uses a dedicated main dialog (and its constructor) as the entry point1.   * Neither Java nor C# technically _need_ a main method. Well, C# needs one to compile, but Java not even that. And in neither case is it needed for execution. So this doesn’t appear to be a technical restriction. And, as I mentioned in the first paragraph, for a mere convention it seems oddly unfitting with the general design principle of Java and C#. To be clear, there isn’t a specific _disadvantage_ to having a static `main` method, it’s just distinctly _odd_ , which made me wonder if there was some technical rationale behind it. I’m interested in a definitive answer from a primary or secondary source, not mere speculations. * * * 1 Although there is a callback (`Startup`) which may intercept this.


Good technologies for developing a modular server component in .net?

I am using WPF, Prism and Unity to develop the user interface for a .net application. The UI will run from a PC, but I also need to develop a separate complex server component that will provide services to the PC component via WCF. Prism and Unity have proved to be of great value in creating a modular application, at least as far as the user interface is concerned. I would also like to make the server component modular, but I cannot find anywhere what techniques, patterns and technologies are suitable. I have considered:   * Unity or one of the other DI containers    * Selected parts of Prism, such as modules and events Are these suitable for developing a modular server component? Or are these UI technologies only and should I be looking at something completely different?


Do you check in bin or debug folders (and dlls) into your TFS?

Quick question about TFS - Do you guys check-in bin/debug folders into TFS? (if so, why?) Since the content of those folders are dynamically generated is it better to leave them out so that the programmer will not run into read-only issues?


When does 'optimizing code' == 'structuring data'?

A recent article by ycombinator lists a comment with principles of a great programmer. > `#`7\. Good programmer: I optimize code. Better programmer: I structure > data. Best programmer: What's the difference? Acknowledging subjective and contentious concepts - does anyone have a position on what this means? I do, but I'd like to edit this question later with my thoughts so-as not to predispose the answers.


How are software licenses applied?

I have created a small and helpful project that I'd like to upload to a public repository and share under the FreeBSD license. What are the common steps I should make to apply the license to my code? I mean, what are the technical actions that should be done to apply the chosen license. More specifically:   1. Should I put the licensing information in the header of every file?   2. If yes, should I put the whole license text or there is an acceptable short version?   3. Should I have a specific file (e.g. in the root directory) that deals with the licensing? Is putting the license text in it enough?   4. If a project is a cooperative effort by various people on-line, that are not part of any organization, what should be written in the copyright clause? Are there any other technical issues I should know?


Should I work for free while applying for a job?

An employer usually asks a candidate to do a small project at home ("homework") as a part of applying for a job. Last time I applied for a job (as a web developer), there were aproximately 10 applicants who were all given different tasks. Despite the fact that there was only one vacancy, the company used the work of all of the candidates in one of its projects. Actually, it is quite plausible for a company to create these "vacancies" just to make people work for free - I estimate, that aproximately 2 weeks of programmer's work was saved with all of the job applications that company had on one vacancy. Is this a common practice and how can you protect yourself from working for free in the future?   Have you seen this during your career?


How to create distinct set from other sets?

While solving the problems on Techgig.com, I got struck with one of the problems. The problem is like this: > A company organizes two trips for their employees in a year. They want to > know whether all the employees can be sent on the trip or not. The condition > is that no employee can go on both the trips. Also to determine which > employees can go together the constraint is that the employees who have > worked together in past won't be in the same group. Examples of the problem: > >   1. Suppose the work history is given as follows: {(1,2),(2,3),(3,4)}; then > it is possible to accommodate all the four employees in two trips (one trip > consisting of employees 1& 3 and the other having employees 2 & 4). Neither > of the two employees in the same trip have worked together in past. >   2. Suppose the work history is given as {(1,2),(1,3),(2,3)} then there is > no possible way to have two trips satisfying the company rule and > accommodating all the employees. > Can anyone tell me how to proceed on this problem?


At what point is it good to try to reinvent a standard?

Take a look at this picture from XKCD.com ![Hey, some mouse-hover text. Wonder if it says something about USB devices?](http://imgs.xkcd.com/comics/standards.png) Browsers are a good example of this. While I develop websites for them, I have to search through the unique 'standards' for each to make sure my sites are fully compatible. When developing a new program (to compete with existing products), I can see people thinking that their idea is worth putting there in a final product that other products will see the advantages and include it as well. Obviously this isn't always the case (browsers, are once again a good example). Some features are ignored by Webkit browsers and some by Gecko browsers and yet IE tends to just ignore everything quite frankly. In truth, these new 'ideas' or implantation tend to just cause problems for the end-user. Now, sometimes these ideas are important to include. Without ideas, there would be no change and without change, no advancement or positive improvements. At what point is an idea/feature worth implementing. What decides if a feature is worthy of becoming 'standard'?


Modern languages and the JVM

Many modern programming languages (Scala, Erlang, Clojure, etc.) are targeting the JVM. What are the main reasons behind that decision?   * JVM's maturity?   * Portability?   * Because JVM simply exists, and the language designers were not willing to write a new VM/interpreter?


How can I secure a short-term programming job or internship abroad?

I am planning to go to the UK or Ireland (but it could be any location, generally speaking) for 3-6 months in about a year or so and would like to be part of a software development team there. I am not necessarily looking for a full-time job, but given that several areas around there are known to be "programmer paradises", I'd rather benefit from it to broaden my horizons and also share what knowledge I have. What I would like to do is:   * to spectate and take part in the knowledge exchange and decision making strategies. To see how people think of different problems, how they tackle them, how they subdivide and distribute the work etc.    * to experience best practices in action, rather than trying to make them work for me as a lone developer or work for yet another company, that wants me to just get it done.   * to get in touch with technologies and languages that are new to me, although this is really optional, because it's something I can do myself (although I rarely seem to find the time).  I like to think, that I have a lot of things to bring to the table, but I would also like to learn, or better yet to experience, a lot. So what I am looking for an internship for a developer with work experience. Basically something like as a journeyman's stay: to work with somebody, who I can turn to, when in obvious need of wisdom. How can I go about doing this?


Commitment level to the project?

You've quoted your time that it will take certain time to produce a piece of software. When you have started the project, is it better to go hard at the beginning and cruise later? or to try to maintain a consistent effort throughout the project?


Git & project backups

I've been using SVN for sometime and have been making an awkward, but soon to be rewarding transition over to git. Theres quite a few side / small projects that I'm working on which 90% will never see the light of day. As well - I also have my weekly school assignments / projects, and finally client projects that I have on the go. I've been rolling the idea or question of how or what the best way would be to back up my projects. The solutions I've sought out so far: **github** which offers an outstanding service - I'm ok with my work being open source, however It's the school work and client work I might not want the public to be open to. github, of course has a payment plan - but let's face it, im a poor colleage student doing what I can to at least put KD on the table! Theres the **USB thumbstick** that I can take around with me, work off of or back up, but that requires it to be around constently. Theres **Dropbox** , but thats a little overkill since it already is a form of a version control system, as well - I have quite a few things on the go - putting everything within dropbox would eat a lot of space Finally, theres a **private server**. I have a mac mini setup as a media server and I was thinking that I could backup to that. Anyways - what are your guys thoughts, how do you handle backing up projects, not only for version control but for the everyday backups.


Tried teaching myself to program before college, accidently overwhelmed myself, tips?

I'm sixteen, I'm overly interested in programming, and I'm currently taking IT classes during my mornings in high school. Last year, I tried teaching myself to code. It was quite exciting, but all I did was watch TheNewBoston's videos on YouTube for Python. After his tutorials, I just did research, made some CMD programs, and that's it. After that, I got cocky and got my feet wet in many other languages. Java, C++, C#, Perl, Ruby... and it overwhelmed me. Which made it less fun to code. I want to go to college for a 2 year programming course. And I want to make writing code my profession. But how do you recommend I attack re-learning it all again? Start with Python? Don't even try? Also, I'm not 100% in math, but I'm good friends with a lot of programmers, who say they suck at math, but manage to code just fine. I'm not looking for negative feedback. I just want the proper head-start on things before college.


Why do we use to talk about addresses and memory of variable in C?

Why do we use to talk about addresses and memory of variable in C, where in other languages (like in Java, .Net etc) we do not talk about variable address and memory in a program, we will directly use the variables. But in C Language we are listening the word address and memory. How to explain this? I hope C is high level language designed over the assembly language. So C is a thin layer over assembly language (in assembly language we will use memory locations to store a variable and track a variable). But in other languages these addresses and memory related things are wrapped in that specific language, so that we will not listen these words.


Should adapters or wrappers be unit tested?

Suppose that I have a class that implements some logic:               public MyLogicImpl implements MyLogic {         public void myLogicMethod() {             //my logic here         }     }      and somewhere else a test class:               public MyLogicImplTest {         @Test         public void testMyLogicMethod() {             /test my logic         }     }      I also have:               @WebService     public MyWebServices class {         @Inject         private MyLogic myLogic;              @WebMethod         public void myLogicWebMethod() {             myLogic.myLogicMethod();         }     }      Should there be a test unit for `myLogicWebMethod` or should the testing for it be handled in integration testing.


How to deal with transactions when creating a database connection for each query

In line with this post here I am going to change my website to create a connection per query to take advantage of .NET's connection pooling. With this in mind, I don't know how I should deal with transactions. At the moment I do something like (psuedo code):               GlobalTransaction = GlobalDBConnection.BeginTransaction();     try     {         ExecSQL("insert into table ..")         ExecSQL("update some_table ..")         ....         GlobalTransaction.Commit();     }catch{         GlobalTransaction.Rollback();         throw;     }      ExecSQL would be like this:               using (SqlCommand Command = GlobalDBConnection.CreateCommand())     {         Command.Connection = GlobalDBConnection;         Command.Transaction = GlobalTransaction;         Command.CommandText = SQLStr;         Command.ExecuteNonQuery();     }      I'm not quite sure how to change this concept to deal with transactions if the connection is created within `ExecSQL` because I would want the transaction to be shared between both the insert and update routines.


What is the technical reason that so many social media sites don't allow you to edit your text?

A common complaint I hear about Facebook, Twitter, Ning and other social sites is that once a comment or post is made, it can't be edited. I think this goes against one of the key goals of user experience: giving the user **agency** , or the ability to control what he does in the software. Even on Stackexchange sites, you can only edit the comments for a certain amount of time. **Is the inability for so many web apps to not allow users to edit their writing a technical shortcoming or a "feature by design"?**


App in Mac app Store free for those who already have downloaded the iphone version?

I want the people who are using my iphone app to be able to download the Mac version(From the Mac app store) for free? and others pay for it! possible? any Ideas how to implement this?


Testing in procedural programming code

I have designed and implemented, for my final year in college, an autonomous robot with Arduino board microcontroller. The robot wanders around an area, avoids obstacles and tries to detect intruders. I have to do some testing for this project . Could anyone help me by telling what test procedures I can perform in procedural code? Observation of the behavior of robot could be one of them?               Servo servoLeft;          // Define left servo     Servo servoRight;         // Define right servo     const int trigPin = 5;     const int echoPin = 2;     int buzzerPin = 6;               // choose the pin for the LED //buzzer     int inputPin = 9;              // choose the input pin (for PIR sensor)          int val = 0;       Timer t;     boolean pirSense = false;     long xronos=0;          void setup() {      Serial.begin(9600);      servoLeft.attach(4);      // Set left servo to digital pin 10      servoRight.attach(3);     // Set right servo to digital pin 9           pinMode(buzzerPin, OUTPUT);      // declare LED as output      pinMode(inputPin, INPUT);     // declare sensor as input           pinMode(trigPin, OUTPUT);      pinMode(echoPin, INPUT);      t.every(30000,monitoring);       }             void loop() {         long duration, distance;       digitalWrite(trigPin, LOW);       delayMicroseconds(2);       digitalWrite(trigPin, HIGH);       delayMicroseconds(10);       digitalWrite(trigPin, LOW);       pinMode(echoPin, INPUT);       duration = pulseIn(echoPin, HIGH);       distance = microsecondsToCentimeters(duration);        delay(100);        Serial.println(distance);        if (distance >= 40){            moveForward();          }           else {              stopMove();         int x = random(0,2);           if(x == 0 ){          turnRight();              delay(500);        }        else{          turnLeft();                delay(500);        }       }      t.update();      }                void monitoring(){       xronos = now();      while( xronos+5 >now() ){       stopMove();      delay(1000);      pirSensor();      }          }                 // Motion routines for forward, reverse, turns, and stop       void reverse() {       servoLeft.write(0);      servoRight.write(180);       }           void moveForward() {      servoLeft.write(180);      servoRight.write(0);      }            void turnRight() {      servoLeft.write(180);      servoRight.write(180);       }      void turnLeft() {       servoLeft.write(0);       servoRight.write(0);       }           void stopMove() {      servoLeft.write(90);      servoRight.write(90);       }           long microsecondsToCentimeters(long microseconds)      {      // The speed of sound is 340 m/s or 29 microseconds per centimeter.      // The ping travels out and back, so to find the distance of the      // object we take half of the distance travelled.      return microseconds / 29 / 2;      }


Why do we need to write a header file?

Before you whip out your snarky comments, I know -- this is a nooby question. This is my first time using a C based language. I'm an undergrad student learning Objective C for a computer science course on mobile development. I know that, in an academic setting, a lot of real-world considerations aren't necessary since you're building smaller projects, work in smaller teams, etc. But our professor demands -- and XCode supports -- .h header files for every .m implementation file. To me, it kind of seems like busy work. I have to make sure I copy every method signature and instance variable over to the other file. If I change one file, I have to make sure it's consistent with the other file. It seems like just a bunch of small annoyances like that. But I know there has to be _some_ real-world use for header files. A great answer would address both:   1. What is a header file useful for that an implementation file isn't suited for? What is its purpose?   2. Why do we as programmers have to manually write our header files? It seems like they could easily be generated automatically. Thanks in advance!


How to test a localized WPF application in visual studio 2012

I am trying to create a localized application in C# / WPF in Visual Studio 2012. For that I created two resource files and changed one string in a (XAML) window to use the resource files (instead of a hardcoded string). I see the English text from the resource file, which is correct. However, I want to check if the other resource file (fr-FR) also works but I cannot find a setting or procedure how to change my 'project' to run in French. Thanks in advance.


Command Line Tool to generate a method usage report

Is there a command line tool (preferred) that'll generate a report of Java methods within a class and where they are used within a few project folders. Kind of how Netbeans does a "Find Usage" on open projects but as an automated approach. I have a utility class that contains lots of static methods, but I have no idea which ones are dead code [ignoring test case usages]


Integration of routes that are not resources in an MVC REST style application

I would like to keep my application relatively REST-pure for the sake of consistency, but I'm struggling philosophically with the relatively few views (maybe just one) that I'll need to build that don't relate to resources directly, and therefore do not fit into a REST style. As an example, take the home page. Ruby on rails seems to bail on their otherwise RESTful approach for this very basic need of all web sites. The home page appears special:   * You can get it, but a get at the resource level is supposed to give you a collection of elements. I can imagine this being the list of routes maybe, but that seems a stretch, and doesn't address anything else.   * Getting the home page by id doesn't seem to make a whole lot of sense - what's the element of a home collection? Again, maybe routes, but a get on a route would do what? Redirect? This feels odd.   * You can't delete it (arguably you could allow this for administrators)   * Adding a second one doesn't make sense except possibly if the elements were routes   * Updating it might make sense for administrators, but AFAIK REST doesn't describe updates on the resource directly, only elements of the resource (this article explicitly says "UNUSED" for PUTS on the resource) Is the "right" thing to do just to special case these types of things? At the end of the day, I can wrap my head around most of applications being gathered around resources...I can't think of another good example other than a home page, but since that's the start of an application, I think it warrants some thought.


What principles does your software engineering or development organization follow? I am very interested in seeing a list of principles from someone who works at a company where these principles are discussed, published, followed, etc. The closest I have seen to a principles-based engineering organization are companies which are agile and follow the agile principles. Here is a list of Marick's values/challenges: http://www.agilejourneyman.com/2010/02/4-challenges-and-5-guiding-values- of.html I am looking for pointers to more stuff like this. Ideally, I'd like to hear from people who have actually implemented a principles-based approach in their organization.


Using scoped enums for bit flags in C++

An `enum X : int` (C#) or `enum class X : int` (C++11) is a type that has a hidden inner field of `int` that can hold any value. In addition, a number of predefined constants of `X` are defined on the enum. It is possible to cast the enum to its integer value and vice versa. This is all true in both C# and C++11. In C# enums are not only used to hold individual values, but also to hold bitwise combinations of flags, as per Microsoft's recommendation. Such enums are (usually, but not necessarily) decorated with the `[Flags]` attribute. To make the lives of developers easier, the bitwise operators (OR, AND, etc...) are overloaded so that you can easily do something like this (C#):               void M(NumericType flags);          M(NumericType.Sign | NumericType.ZeroPadding);      I am an experienced C# developer, but have been programming C++ only for a couple of days now, and I am not known with the C++ conventions. I intend to use a C++11 enum in the exact same way as I was used to do in C#. In C++11 the bitwise operators on scoped enums are not overloaded, so I wanted to overload them. This solicited a debate, and opinions seem to vary between three options:   1. A variable of the enum type is used to hold the bit field, similar to C#:              void M(NumericType flags);          // With operator overloading:     M(NumericType::Sign | NumericType::ZeroPadding);          // Without operator overloading:     M(static_cast<NumericType>(static_cast<int>(NumericType::Sign) | static_cast<int>(NumericType::ZeroPadding)));      But this would counter the strongly typed enum philosophy of C++11's scoped enums.   2. Use a plain integer if you want to store a bitwise combination of enums:              void M(int flags);          M(static_cast<int>(NumericType::Sign) | static_cast<int>(NumericType::ZeroPadding));      But this would reduce everything to an `int`, leaving you with no clue as to which type you're supposed to put in the method.   3. Write a separate class that will overload operators and hold the bitwise flags in a hidden integer field:              class NumericTypeFlags {         unsigned flags_;     public:         NumericTypeFlags () : flags_(0) {}         NumericTypeFlags (NumericType t) : flags_(static_cast<unsigned>(t)) {}         //...define BITWISE test/set operations     };          void M(NumericTypeFlags flags);          M(NumericType::Sign | NumericType::ZeroPadding);      (full code by user315052) But then you have no IntelliSense or whatever support to hint you at the possible values. I know this is a subjective question, but: **What approach should I use? What approach, if any, is the most widely recognized in C++? What approach do you use when dealing with bit fields and _why_?** Of course since all three approaches work, I'm looking for factual and technical reasons, generally accepted conventions, and not simply personal preference. For example, because of my C# background I tend to go with approach 1 in C++. This has the added benefit that my development environment can hint me on the possible values, and with overloaded enum operators this is easy to write and understand, and quite clean. And the method signature shows clearly what kind of value it expects. But most people here disagree with me, probably for good reason.


Understanding the meaning of "multiple lifecycles application development"?

Some Agile job posts have a requirement "strong understanding of multiple lifecycles application development", what does it means ? So my question would be: what's that field for, and what would I need to learn, knowing that I got Java EE experience and Agile more than 2 years. Sorry if my question isn't constructed well, nor I putted some time searching the meaning :) my self, but all my research yielded job posts :D.


C# Multithreading Interview questions for a senior developer/designer position

I wonder what sort of interview questions were asked to a senior developer or technical consultant on multithreading. Kindly provide me some of the interview questions which were asked in the interview on multithreading if possible kindly put the scenario based questions with some theoretical questions. As I came to know after disscusion with some of the people that some time interviewer might give you a scenario and ask you to implement it? @ Kindly add the specific questions which you have ever faced or asked to the other person in the interview other than only mentioning the concepts because people go through the concepts and still find it difficult to handle the interview questions.so any effort to add the specific question could actually help person to get a head start for the d-day


Is unit testing procedural code effective?

On a current project, the powers that be want to have unit testing incorporated into our development cycle to avoid the constant amount of bugs that seem to seep into our code. The problem is that the spaghetti code is 95% percent procedural, which I've never done unit testing with (all my experience with unit testing has been with OOP code) So my question in a nutshell is would it be wise to proceed with unit testing with our current codebase, or suggest that it be postponed until the application has been migrated to a proper OOP framework? PS: While I tried to style this question as language agnostic, I feel that stating the application in question uses PHP and javascript will help provide more specific answers that could answer this question since from experience this occurrence occurs most with such applications.


Should I continue stressing development standards?

I've been with my software team for about three years now, and just recently I brought up the concept of variable naming conventions (across all languages, but C#/VB.Net specifically). We really don't have any solid naming conventions. I was met with serious resistance - so what?, does it really matter?, blank stares, etc. I was able to get the others to agree to at least be consistent on a given code file (not ideal, but with this group, any standards that is based around anything other than SQL is a step forward). My question is this - I've always received resistance to developing standards.   * Should I just stop pushing standards and accept the fact that everyone seems to be doing their own thing when they code?


Large Scale Application Development in Android

Since, I am fairly new to large scale app development in Android and Java, I though I would ask for your advice guys. My team was faced with developing a prototype of a fairly complex medical software. Although it is only a prototype, I think it might be a good opportunity to learn new platform and get into some good habits. Our design requirements are fairly simple: a set of common files: themes, styles, objects, static methods for database etc. and then a set of smaller "apps" like a: digital tests, games etc. Each one is fairly unique. Our initial thought was to create a set of smaller applications that will be lunched from "the main screen". Each application would be a separate project in Eclipse and then we would modify the build path to include the "common files". This way: each developer could work on their own projects without bothering others. The problems that I find with this approach:   1. Deploying the application (having a bunch of applications instead of one big one)   2. Testing the application    3. Use of strings to lunch another application i.e. worrying whether the application has been installed   4. Silly human errors e.g. modifying common files and forgetting to commit changes Another solution would be to create one big application/project with each developer working on a separate package which would represent each app. However, this introduces common resources (e.g. unique string names) etc. What's your advice? How to tackle this problem? Which one is better in the long run? Are there any other approaches that are more sensible?


How do developers deal with "where to start" problem in a context of overwhelming difficulties caused by too much heterogeneous information?

A friend of mine, a beginner PHP programmer, needs to link the product his company develops with a third-party product (a set of web services). He received the "relevant" documentation (a few hundred of pages of unreadable stuff) from this third-party, have read the PHP documentation related to SOAP client, have read about SOAP and WSDL, but **doesn't have a slightest idea where to start**. Instead of a step-by-step tutorial, he has lots of overly verbose documentation. I suggested him to use prototyping:   1. Imagine the most basic scenario where the third-party web services can be used,   2. Select the relevant documentation,   3. Build (from scratch) the simplest PHP script which will play this scenario,   4. Once the prototype works, integrate the functionality into the existing product,   5. Refactor,   6. Expand the existing product with additional features. While this may help pushing this person to the right direction, I feel that my suggestion is only partially helpful. I imagine myself six years ago knowing nothing about WSDL and SOAP and having to search inside hundreds of pages of documentation: I would be already discouraged at steps 2 and 3. Experienced developers have a bunch of patterns, practices and processes which help solving basic problems frequently encountered in software development:   * The technical aspects of a feature are uncertain? Use prototyping.   * The application "feels unresponsive"? Use profiling to find bottlenecks.   * The requirements are subject to frequent change? Use Agile.   * Programmers need to be sure their code doesn't contain omissions? Use code reviews.   * The successive versions of a product are not deployed fast enough? Use DevOps. While those patterns and practices help developers solving purely technical/organizational issues (such as "I know how to implement Web Sockets in Java, Python and Node.js, but now I need to do it in Haskell."), the same patterns and practices are not helpful for less experienced programmers who need to solve more substantial and less technical problems (such as "I believe Web Sockets are a sort of HTTP but it happens the other way, something like that; now lead developer asked me to implement that in my app, but I'm not sure why do we need it.") Inviting the programmer to spend three years in college or twelve months reading programming-related books is not always an option: some people need to work to pay their bills, need to finish the project for the next deadline, and are not paid to read books. So what are other options?


Is there a better way to update NoSQL records in bulk?

When we started our application we had the choice of going with the traditional MS-SQL normalized database or with a NoSQL database (RavenDB is what we tried out). Here is a simplified version of our schema:               <Order OrderNumber="1000" OrderVersion="1" ...>       <Products>         <Product Code="X58" Price="$5.50" Quantity="3" ... />         <Product Code="X70" Price="$9.99" Quantity="1" ... />       </Products>       <Contacts>         <Contact ... />         <Contact ... />       </Contacts>     </Order>      While we could have went with a MS-SQL database, we didn't because we wanted all of our data for an order to be kept historically; we did not want to FK the contact even if they had the same name and address because while it might change, the order should have the contact info at the **time of purchase**. Also, yes, we could have FK our Products instead of using the **Code** to reference the product, but Products never get deleted, and again... if they are updated we want to capture their information at the **time of purchase**. Basically, every Order seems to be a self-contained document that should never rely on FKs. OrderVersion is just to keep track of our process version when the order was created, we could easily just have used OrderDate to track versioning. * * * Anyways, so our decision was to go with RavenDB. We built out our application and website, and internally we are testing it out. The one scenario we are running into problems is: _"How do you do a bulk update on records as good as SQL does it?"_ For example, if we had just pushed our code to production during offline maintenance and somehow all records from MA with ZipCodes that have a leading zero (0) had the zero trimmed off (i.e. the zip code now read 1234 instead of 01234)? Normally, we would patch things immediately on one fail-over server at a time, and updating records would be easy:               UPDATE c     SET c.ZipCode = ...     FROM Contact c         INNER JOIN Order o ON c.OrderId = o.OrderId     WHERE o.Version = 1       AND ...      But, it seems that the best solution we could come up with if we use RavenDB is to get all documents, then programmatically update the records through a custom C# console app. It seems that TSQL is much easier/faster. I'm not sure if there is a better way that we are unaware of, or is this a common shortcoming of using RavenDB (or any NoSQL document store)? My biggest worry is, while our console app seemed to run just fine enough with a sample of 100K orders, what happens if we get to the point of 50M+ orders!? Or, is that also an issue with T-SQL that we would eventually run into with the example I gave?


Scheduling Thousands of *Recurring* Jobs

I'm looking for general approaches and ideally libraries/tools for scheduling many thousands of recurring jobs. A simple example is a feed aggregator, where I'd want to repeatedly poll thousands of feeds. I would never want to poll a website more than once an hour (overuses everyone's resources), but I could deal with polling websites less than once an hour if there isn't time to finish everything in an hour (and worry later about sharding the process or whatever to make it faster, if this keeps happening). So I'd basically want a framework where I can say "run this task as often as possible, but no more than once an hour". An additionally nice feature would be for such a framework to exponentially decay unsuccessful tasks, i.e. if a feed URL was broken, it would be scheduled for 2 hours, then 4 hours, etc. I've heard of an approach involving a binary tree which acts as a kind of giant cronjob-like data structure. The system would constantly trawl through this tree to see if any tasks are overdue. I don't have much more information than this. I've looked at tools like Resque, but they don't really seem to cover this use case.


Non-trivial functions that operate on any monad

I'm looking for examples of interesting methods that take an arbitrary monad and do something useful with it. Monads are extremely general, so methods that operate on monads are widely applicable. On the other hand, methods I know of that can apply to any monad tend to be... really, really trivial. Barely worth extracting into a function. Here's a really boring example: `joinTwice`. It just flattens an `m m m t` into an `m t`:               join n = n >>= id     joinTwice n = (join . join) n          main = print (joinTwice [[[1],[2, 3]], [[4]]])     -- prints [1,2,3,4]      The only non-trivial method for monads that I know of is `bindFold` (see my answer below). Are there more?


How to overcome network latency when using data as a service like Cloudant?

I just can't understand, no matter how good and scalable of Cloudant (data as a service), how one can overcome network latency issue? Even the data center is located within the same country, 100ms is way too slow compare to a local network. Any thoughts?


How can I create a software patcher for OS X?

I'm building some software for OS X that isn't distributed through the Mac App Store. My software allows users to download different modules uploaded by various people too. How can I create a software patcher to patch my software, as well as update modules that users might be uploading when necessary? I've looked a bit into diff and patch, which come with OS X but they seem to be largely for plaintext. Any ideas? I've been googling but I'm a bit stumped which is surprising since software patching seems to be in most applications.


CI tests to enforce specific development rules - good practice?

The following is all purely hypothetical and any particular portion of it may or may not accurately describe real persons or situations, whether living, dead or just pretending. Let's say I'm a senior dev or architect in charge of a dev team working on a project. This project includes a security library for user authentication/authorization of the application under development. The library must be available for developers to edit; however, I wish to "trust but verify" that coders are not doing things that could compromise the security of the finished system, and because this isn't my only responsibility I want it to be done in an automated way. As one example, let's say I have an interface that represents a user which has been authenticated by the system's security library. The interface exposes basic user info and a list of things the user is authorized to do (so that the client app doesn't have to keep asking the server "can I do this?"), all in an immutable fashion of course. There is only one implementation of this interface in production code, and for the purposes of this post we can say that all appropriate measures have been taken to ensure that this implementation can only be used by the one part of our code that needs to be able to create concretions of the interface. The coders have been instructed that this interface and its implementation are sacrosanct and any changes must go through me. However, those are just words; the security library's source is open for editing by necessity. Any of my devs could decide that this secured, private, hash-checked implementation needs to be public so that they could do X, or alternately they could create their own implementation of this public interface in a different library, exposing the hashing algorithm that provides the secure checksum, in order to do Y. I may not be made aware of these changes so that I can beat the developer over the head for it. An attacker could then find these little nuggets in an unobfuscated library of the compiled product, and exploit it to provide fake users and/or falsely-elevated administrative permissions, bypassing the entire security system. This possibility keeps me awake for a couple of nights, and then I create an automated test that reflectively checks the codebase for types deriving from the interface, and fails if it finds any that are not exactly what and where I expect them to be. I compile this test into a project under a separate folder of the VCS that only I have rights to commit to, have CI compile it as an external library of the main project, and set it up to run as part of the CI test suite for user commits. Now, I have an automated test under my complete control that will tell me (and everyone else) if the number of implementations increases without my involvement, or an implementation that I did know about has anything new added or has its modifiers or those of its members changed. I can then investigate further, and regain the opportunity to beat developers over the head as necessary. Is this considered "reasonable" to want to do in situations like this? Am I going to be seen in a negative light for going behind my devs' backs to ensure they aren't doing something they shouldn't?


As a tooling/automation developer, can I be making better use of OOP?

My time as a developer (~8 yrs) has been spent creating tooling/automation of one sort or another. The tools I develop usually interface with one or more API's. These API's could be win32, WMI, VMWare, a help-desk application, LDAP, you get the picture. The apps I develop could be just to pull back data and store/report. It could be to provision groups of VM's to create live like mock environments, update a trouble ticket etc. I've been developing in .Net and I'm currently reading into design patterns and trying to think about how I can improve my skills to make better use of and increase my understanding of OOP. For example, I've never used an interface of my own making in anger (which is probably not a good thing), because I honestly cannot identify where using one would benefit later on when modifying my code. My classes are usually very specific and I don't create similar classes with similar properties/methods which could use a common interface (like perhaps a car dealership or shop application might). I generally use an n-tier approach to my apps, having a presentation layer, a business logic/manager layer which interfaces with layer(s) that make calls to the API's I'm working with. My business entities are always just method-less container objects, which I populate with data and pass back and forth between my API interfacing layer using static methods to proxy/validate between the front and the back end. My code by nature of my work, has few common components, at least from what I can see. So I'm struggling to see how I can better make use of OOP design and perhaps reusable patterns. Am I right to be concerned that I could be being smarter about how I work, or is what I'm doing now right for my line of work? Or, am I missing something fundamental in OOP? **EDIT:** Here is some basic code to show how my mgr and api facing layers work. I use static classes as they do not persist any data, only facilitate moving it between layers.               public static class MgrClass     {         public static bool PowerOnVM(string VMName)         {             // Perform logic to validate or apply biz logic             // call APIClass to do the work             return APIClass.PowerOnVM(VMName);         }     }          public static class APIClass     {         public static bool PowerOnVM(string VMName)         {             // Calls to 3rd party API to power on a virtual machine             // returns true or false if was successful for example         }     }


Variable names: underscores, no underscores, or camel case?

Variable names can be written in many ways, but the most common that I'm familiar with are:   * thisisavariable,   * this_is_a_variable, and   * thisIsAVariable. Which of these are preferred, and why?


C# dynamics and Expando object

Under which application development scenarios C# dynamics and ExpandoObject can be used or when to consider using c# dynamics and ExpandoObject


CMS updates into subversion -> review process

We manage a range of client sites built in Wordpress and Joomla and these require regular updates to the core CMS and extensions. We keep these sites in subversion and place updates in subversion. We try to use a single revision for this. We face some difficulties in making this process efficient, over time we would like to automate it, so we can offer the process on a fixed price basis The process is currently as follows   1. make copy of whole folder   2. svn status |grep '^!' |sed 's/^!\s*/svn delete "/g' |sed 's/$/"/g' |sh   3. svn update   4. svn status |grep '^?' |sed 's/^?\s*/svn add "/g' |sed 's/$/"/g' |sh   5. svn ci -m "Commit message"   6. svn remove -m"temporarily remove" http://subversion.repository.com/svn/automatem/projects/client/trunk/project/foldername Steps 5-6 are usually repeated multiple times. What I'm looking for help with   * we are using subversion version 1.6 and 1.7, because there are no .svn folders in 1.7 in subdirectories, I wonder if the process is much easier on 1.7?   * we've added step 3 because it reduces the number of repeats in steps 5-6. However this was just trial and error and I can't quite get my head around why this is   * As I understand it, the issue in step 5-6 is that when the an extension is updated, it may delete a whole folder and then re-insert that folder with changed files. In subversion 1.6, this would remove the .svn folder, which causes a 405 Access denied error (the folder gets added, but already exists in svn). What I would need is something that inserts all .svn folders back into my working copy if the folder already exists in svn. Is there a way to accomplish this?   * Any other improvements of course appreciated.


What is the most cross-browser/system compatible option for 3d graphics on a web page?

I would like to develop a bit of functionality for a web site that involves a bit of 3D - the user can move around objects, rotate them and texture them. So far I've looked into:   * WebGL (in particular three.js) and it looks great, but it's not supported in IE nor IOS.   * IOS supports the `<canvas>` tag, but only 2d. It looks like three.js has an unsupported hack to make a 3d thing use the 2d canvas instead without textures, but this looks like a hack.   * I also considered resorting to Flash which works on most browsers, but that won't work on IOS.  What's my best option for doing 3d web graphics on the vast array of browsers and interfaces? At the moment I'm thinking WebGL for web (and ask people to use chrome or firefox, and take the hit on IE) and then maybe write a native app for IOS, but I am not sure if there are better alternatives available that I don't know of.


How does if/else work internally in all programming languages?

if(true/false){          //if condition is true      }else {          // if condition is false     }      Everyone knows about the structure of `if-else`. But what is `if` actually? Is it a class method, static method or keyword? I'm little confused about this.


Any good resource on running a service software company?

A service software company is like an outsource company. You give us the requirements, we band the result for you. This is a unique situation where each project is short lived and vastly different from one to another. I'm interested to learn if anybody is successful in running this kind of company and any good resource of setups like this. Thank you!


WHat are the benefits of placing the concatenation character at the end or beginning of a line

Considering multiple lines of say SQL query strings:               $sql = "select * from table ".     "where a=5";      What do you think are the benefits and downsides of putting the concatenation character at the end or beginning of the line? This is to revise a coding guidelines document, we have 2 people here that "feel" it should be either way


What makes a good developer / system documentation?

Much time is wasted to get new developers started with existing software systems, because there is no good documenation. But what makes a system documentation good? One thing is a good API documentation like the Java API doc, but how to transfer the "bigger picture" and other things that cannot be placed in the API doc? One constraint is that it should not be to hard and time consuming to write the docs, because that is one reason why it is omitted so often. So, what makes documentation good?


Debugging: understanding details on why certain fixes worked?

When debugging, I sometimes find that I make some changes and I am not 100% sure why those changes correct some bug in the program. Is it essential to understand every single detail about why some bugs were occurring and why certain changes eliminated those bugs? Or is it common among developers to sometimes get the program working without really knowing the details about why the fix worked?


Why would it take hours to decode transmissions from Curiosity rover via MRO?

This video clip by NASA says that data from Curiosity relayed by the Mars Reconnaissance Orbiter (MRO) would be stored for a few hours, then transmitted to Earth (apparently taking about 14 minutes), after which it would take _hours_ for engineers to decode the data. From what I've read, it seems that the MRO can be used as a backup communication device for Curiosity if needed. In the case of Curiosity's landing, I figure the MRO would have store the data until it orbited around the red planet and had a direct line of sight with Earth before transmitting it (then again, I'm only speculating here), which I can understand. But then why would it take NASA engineers hours to decode the signal relayed by MRO after it is received here on Earth? ( _Bonus point: Does it normally take hours to decode MRO signals?_ )


Guiding Non-Programmers in Hiring of a Programmer

A friend of mine has a developer (possibly the "mad genius" type) that has built a substantial system on which their small business is critically dependent. They'd like to get away from their current guy and replace him with someone more reliable, but the question comes up of how to know that the person they replace him with is a competent developer himself. As a developer, I know what questions _I_ would ask and how to interpret the responses, but how would you advise a company void of development background to go about identifying the ones who know their stuff?


can a regex search engine for the web be done and if so, how?

I think it would be a great idea if we had a regular expression search engine, but can it be done? It seems impossible since there's no feasible way of indexing such a huge amount of data properly and displaying results in the order of relevance from what I can think of. I'm curious what the answer to this one would be.


Confusion with Factory pattern regarding Liskov's Substitution Principle, code maintainability and Unit Testing?

I have a confusion regarding Factory Pattern there are basically two ways You can implement that. Approach 1:               public interface IProductFactory     {         IProduct GetProductA();         IProduct GetProductB();         IProduct GetProductC();     }          public class ProductFactory : IProductFactory     {         public IProduct GetProductA()         {             //some implementation goes here         }         public IProduct GetProductB()         {             //some implementation goes here         }         public IProduct GetProductC()         {             //some implementation goes here         }     }      Approach 2:               public enum ProductType     {         ProductA = 1,         ProductB = 2,         ProductC = 3     }          public interface IProductFactory     {         IProduct GetProduct(ProductType productType);     }          public class ProductFactory : IProductFactory     {         public IProduct GetProduct(ProductType productType)         {             switch (productType)             {                 case ProductType.ProductA:                     //return IProduct with specific implementation                     break;                 case ProductType.ProductB:                     //return IProduct with specific implementation                     break;                 case ProductType.ProductC:                     //return IProduct with specific implementation                     break;                 default:                 //return null             }         }     }      **Pros of both approaches** Approach 1:   1. benefit of compile time checks that the implementation class will be forced to provide the corresponding methods. Approach 2:   1. Implementation will have a benefit of shorter no. of lines of code.   2. Interface does not become fragile, it won't change as the new products keep on adding. **Cons of both approaches** Approach 1:   1. Lines of code becomes large.   2. As more number of Products are implemented, the interface changes and hence it is hard to follow Liskov's Substitution Principle. Approach 2:   1. Since it is hiding internal details of GetProduct, it is hard to tell what the Factory will return when a specific type of enum is passed.    2. You might get into run time exceptions **I am still struggling to decide on which approach to use?** * * * **Note:** I am only aware of these two approaches, there might be different approaches also.


Cogent arguments for 'semantic css' over 'object oriented css'

[Context - I'm a Java developer, having a discussion with a designer who works in the html/css space] I was having a discussion with a co-worker today about the merits of 'semantic css'. His response was, "Oh we're not interested in semantic css, we use object oriented css" I understand what he means, ie that they're using the 'inheritance' properties of css and SASS mixins to describe styles. But I feel like he has not tried to understand 'semantic css'. I'm trying to construct a cogent argument about why 'object oriented css over semantic css' is flawed. This is my reasoning so far:   * “css isn’t object oriented” http://stackoverflow.com/a/7431746/15441   * Write html code with semantic components http://css.dzone.com/articles/object-oriented-css-crap-long   * Examples of layout out your page with semantic components http://woork.blogspot.com.au/2008/11/css-coding-semantic-approach-in-naming.html   * Examples of non-semantic naming http://css-tricks.com/semantic-class-names/ My question is "what are some cogent arguments explain semantic css to someone who thinks that 'inheritance', 'classes' and 'mixins' make something object oriented and that he doesn't need to worry about good naming?"


In a declarative language, specifically in the context of modelling, can we make a clear distinction between code and data?

For declarative languages, specifically (but not limited to) in the field of modelling, it's not obvious to me whether code can be considered to be separate from data. This line of reasoning may only apply to non-turing complete languages such as NeuroML. Say for instance I had a very domain specific declarative language which I used to described the positions of planets and their velocities, and I described a system of three orbiting bodies:               satellite planet_earth,moon,sun {          planet_earth.position = [6,0,0]          planet_earth.velocity = [0,23,-32]          planet_earth.mass = 1e3          moon.position = [6,0,0.0001]          moon.velocity = [0,0,3]          moon.mass = 1e2          sun.position = [0,0,0]          sun.velocity = [0,0,0]          sun.mass = 1e12 }      This language could be passed to a simulator which then simulated the motion of the planets. From one perspective this is code - It is describing initial conditions and consequently within the constraints of the language a sequence of steps for a computer to run. From another perspective it is 'data' - it is a description of a physical system. Is this concept (is something code or data) something which has been studied much? I've looked into it


What determines when an application requires mvvm?

I'm developing mobile applications for Windows Phone 7. This application calls some web services and occasionally sends responses out via web services. I recently started looking into MVVM and noticed that, although it is suggested when developing applications in WP7, alot of developers say only to use it if its necessary. Along with that they said that if the application is "small" enough or "simple" enough then it probably isn't worth the time. Hence my question. When should we use MVVM? Is it possible to build larger scale applications without it?


Distributed system command and control

I have an application that consists of a set of Java and C++ of processes running on one or more systems and need to ability to monitor and control the components as if they were one complete system. My requirements:   1. runtime statistics (messages per second etc..)   2. log of events   3. control: "service X set rate to 1000 mps" or "all services stop"   4. ambient configuration so all services can start up and discover the working mode (etc..) Since data plane messaging is 0MQ based, I am currently doing this with 0MQ based messaging and a message distributor to fan out the control messages. However, I am interested in how others have tackled the problem. Thanks.


Priority queue for Kruskal's algorithm with running time O(E lg V)

I'm reviewing my notes on Kruskal's algorithm and have a question about getting the runtime down to O(E lg V). By using a PQ with _edges_ and a boolean array of which vertices we have added to our tree _T_ , the running time is O(E lg E), but in my notes there is also a variant with running time O(E lg V), by using a PQ with vertices instead of edges. However, this requires the PQ to support updating weights (important part highlighted): > Maintain a PQ of vertices connected by an edge to T, togethether with the > edge that connects it to T. The priority of this tuple is the weight of the > min-weight edge connecting it to T. When adding a new vertex to the tree, we > add all vertices adjacent to this new vertex to the PQ unless it's already > in the PQ. **If it is in the PQ and the new edge connecting it to T is of > lower weight, we update its weight and the edge associated with it** , if > not, we do nothing. When thinking about how to actually implement this, I realized that all priority queues I have seen have O(n) updates, since the ordering is too weak for us to be able to find an element faster. I tried searching a bit but couldn't find any PQs that support updating in O(lg n) time, except some references to fibonacci heaps that can do it in O(1) time, but looks like a much more complex data structure. Is there a simple way to get O(lg n) updates of a priority queue? I could insert keys and references to elements in a hash table and use that to quickly find and update elements, is this a viable solution? (I realize that this will require O(n) extra space.)


FreeType font patent issue and Apple platform

As I know, FreeType restrict some features by patented font technology from Apple. So, if I develop a program for Apple platform _only_ , can I enable and use the features?


Who should be responsible to write test cases?

Should tests in some project be written by the actual person that does the coding (usually senior in our team) or it can be done by junior coders with less experience?


What programming skills have provided you the best return on investment?

What are the things that took you only a little time to learn, but had a big payoff? And how long did it take to learn enough before the they began to pay off? For instance, I’m not a master of regular expressions, but it probably took a couple of hours to understand the basics enough for to start using them and they come in handy on a regular basis.


Distributed transactions and queues, ruby, erlang

I have a problem that involves several machines, message queues, and transactions. So for example a user clicks on a web page, the click sends a message to another machine which adds a payment to the user's account. There may be many thousands of clicks per second. All aspects of the transaction should be fault tolerant. I've never had to deal with anything like this before, but a bit of reading suggests this is a well known problem. So to my questions. Am I correct in assuming that secure way of doing this is with a two phase commit, but the protocol is blocking and so I won't get the required performance? It appears that DBs like redis and message queuing system like Rescue, RabbitMQ etc don't really help me a lot - even if I implement some sort of two phase commit, the data will be lost if redis crashes because it is essentially memory-only. All of this has led me to look at erlang - but before I wade in and start learning a new language, I would really like to understand better if this is worth the effort. Specifically, am I right in thinking that because of its parallel processing capabilities, erlang is a better choice for implementing a blocking protocol like two phase commit, or am I confused?


Correct echoing of html in js?

A colleague and I were discussing how to echo HTML inside of javascript code. Specifically, in a situation similar to this:               new Element('div', {         html: '{long string of HTML goes here!}'     }.inject($('content'));      Short snippets seem to work well in this situation, but what if we were echoing a large set of data? The line would then become very long, and hard to debug (because who horizontally scrolls?!) A problem also lies in the fact that besides its length, all quotes used need to be escaped, especially if the javascript code is being echo'd from the server side, in which case one of the quote marks would be "used up", per se. One solution would be to break up the long line of HTML code:               new Element('div', {         html:   '{long string of HTML goes here!}' +                 '{some more HTML goes here}' +                 '{and even more...}'     }.inject($('content'));      Another solution provided involved including an addslashes()'d server-side include, which involves a second file. Although I suppose it is also possible to define all of the to-be-included HTML in a php variable, and echo it when it is needed:               <?php         $html = addslashes('{html content}');     ?>          new Element('div', {         html: '<?=$html?>'     }.inject($('content'));      Which method is best in terms of code readability, efficiency, and security?


Keep it simple now, or program with the future in mind?

I'm currently coding a new application for my company that is rather involved. To meet the deadline, the functionality has been toned down quite a bit so that we can have something ready to go for launch. I've been given the task of getting version 1 up and running by the end of the month. I'm about halfway through development and I've come to the point now that there is an end in sight. Yesterday, I spent some time coming up with a very nice easy solution for one of the requirements and am quite proud of how it turned out. This morning the version 2 document was sent out, and there is a requirement in there that will require the code I wrote yesterday to be either gutted, or severely changed. It would require a lot of work in the future if I leave it the way it is. I can take an extra day now to make my current solution more robust so that the v2 feature will be able to be added with a lot less effort, but that will put me a bit behind for the extra coding it would require. I don't know if I'll be doing v2. It might be me or it might be a co-worker, or even an intern. If you were in my shoes, would you spend the time now to make it easier in the future, or would you leave your solution and deal with it when the time comes?


In PHP, how do you code with scalability in mind?

I know this may be a general question, but what exactly goes into scaling for all the users you will encounter, even if not in the next few months? I did some research and most of what is done is server side, with caches and other similar stuff. Any points in the right direction would be helpful.


What programming languages should every computer science student be taught?

What languages (or classes (as in paradigms) of programming languages, plus a recommended language of that class) should every computer science student be taught in college according to you? Motivate your answers; why that language? What use will one have from it? What concepts does it teach (better than language X does)? **Note/clarification** : This question is about computer science with heavy focus on software engineering, not pure computer science. It is still computer science education and not software engineering education which is the focus.


How we call an RPC that not only calls external functions but also updates data structures?

I have a simple C++ RPC that lets you have remote class instances that support live members (data structures) update as well as method calls. For example I had a class declared like this (pseudocode):               class Sum{     public:         RPC_FIELD(int lastSum);         RPC_METHOD(int summ(int a, int b))         {          lastSum = a + b;          return lastSum;         }     };      On machine `A` I had its instance. On machines `B` and `C` I had created its instances and connected them to machine `A`. So now they actually do all processing on machine `A` but machines `B`, `C` get `lastSum` class field updates automatically (and can subscribe to update event). How to call (`Nice Name`) such a functionality when we have binding over network done automatically by RPC library? How RPC library creator can announce such feature?


What can a company do to restrict offsite contract developers from redistributing GPLv2-licensed code modifications?

My company uses a mix of onsite and increasingly offsite contractors for development of websites and online applications. Our platform uses a mix of open source software and libraries that we've made a number of modifications to over the years. Some of the modified software is licensed GPLv2 without the linking exception. For various reasons, we do not want the source to be made public. The concern is that if we supply the binaries to our platform for our offsite developers, we are obligated to supply the source code upon request. Additionally, there will be times when we need to distribute the source of our modified libraries. From there, nothing would seem to preclude the contractor from redistributing the work. The GPL FAQ states: > . . . when the organization transfers copies to other organizations or > individuals, that is distribution. In particular, providing copies to > contractors for use off-site is distribution. Furthermore, the GPL states: > You may not impose any further restrictions on the recipients' exercise of > the rights granted herein. The question is: **what can be done to restrict offsite contractors from redistributing our modified code?** A note, that I think the GPLv3 addresses this concern with the following clause. So my question is specifically about GPLv2-licensed modified code: > You may convey covered works to others for the sole purpose of having them > make modifications exclusively for you, or provide you with facilities for > running those works, provided that you comply with the terms of this License > in conveying all material for which you do not control copyright.


Abstraction: The War between solving the problem and a general solution

As a programmer, I find myself in the dilemma where I want make my program as abstract and as general as possible. Doing so usually would allow me to reuse my code and have a more general solution for a problem that might (or might not) come up again. Then this voice in my head says, just solve the problem dummy its that easy! Why spend more time than you have to? We all have indeed faced this question where Abstraction is on your right shoulder and Solve-it-stupid sits on the left. Which to listen to and how often? What is your strategy for this? Should you abstract everything?


Difference between class clusters and abstract factory in cocoa

I have read that Obj-C class clusters are an implementation of the abstract factory. Can anyone explain if there are any differences between the 2 as design patterns. I read somewhere that there are certain restrictions on class clusters that don't apply to traditional abstract factory but it did not give more details.


What is the role of an Information Architect?

I've heard this term bandied about, especially in reference to web development, but I'm having trouble getting a clear understanding of what an Information Architect actually does. Any ideas what their role or deliverables would be?


Using an Apt Repository for Paid Software Updates

I'm trying to determine a way to distribute software updates for a hosted/on- site web application that may have weekly and/or monthly updates. I don't want the customers who use the on-site product to have to worry about updating it manually I just want it to download and install automatically ala Google Chrome. I'm planning on providing an OVF file with Ubuntu and the software installed and configured. My first thought on how to distributed software is to create six Apt repositories/channels (not sure which would be better at this point) that will be accessed through SSH using keys so if a customer doesn't renew their subscription we can disable their account:   1. Beta - Used internally on test data to check the package for major defects.   2. Internal - Used internally on live data to check the package for defects (dog fooding stage).   3. External 1 - Deployed to 1% of our user base (randomly selected) to check for defects.   4. External 9 - Deployed to 9% of our user base (randomly selected) to check for defects.   5. External 90 - Deployed to the remaining 90% of users.   6. Hosted - Deployed to the hosted environment. It will take a sign off at each stage to move into the next repository in case problems are reported. My questions to the community are:   1. Has anyone tried something like this before?   2. Can anyone see a downside to this type of a procedure?   3. Is there a better way?


Risks of maintaining codebase C++ Builder 6?

My company has a large software application written in C++ Builder 6. I am a junior developer only one year out of college. My question is:   1. How much technical debt are they in? What are the hazards of working in such an IDE that is no longer supported?


software design interview questions

I am preparing for an interview at google, and it will involve programming questions as well as design questions. I have done interviews with facebook and amazon, and I didn't do well in the design part of the interview for both companies. I was asked to design a restaurant reservation system, an array of caches, and the facebook friends list. The questions vary in very different ways. Can anyone give me suggestions on how to prepare for this kind of interviews and how to get better at this in general? I wonder if there are places like careercup.com which is very helpful preparing for algorithm interviews, it has some design problems as well, but not nearly enough.


Efficient solution for dictionary updates

Let's start with the problem: There is a large dictionary X that contains {key, value} pairs, i.e.:               X = [{100, 10}, {101, 0}, {103, 0}, {106, 2}, {110, 1}]      Every t seconds, X has to be updated with values from sub dictionary U and 0 set to each value for a key that is not present in new updated U, but was in the previous update. The most important requirements is, that an update has to be performed in such a way, that the minimum number of update operations of each {key, value} pair in dictionary X have been performed, ie. X updated by U where               U = [{100, 10}, {102, 5}, {103, 0}, {105, 1}, {110, 0}]      would become:               X = [{100, 10}, {101, 0}, {102, 5}, {103, 0}, {105, 1}, {106, 2}, {110, 0}]       but only following pairs have been updated/added in X:               {102, 5}     {105, 1}     {110, 0}      To make things a bit more interesting, there are few constraints:   * it is very costly to iterate over dictionary X. Assume X is very large.   * it is very costly to make an update to {key, value} pair so the task is to minimize this cost. So that was the problem stated. Here is my solution: First idea I had was to save the dictionary U after updating X. On the next update I take each key from Uprev and set it to 0 in X.               foreach (var pair in Uprev)     {         X[pair.Key] = 0;     }      After this has been done, I would do a loop to set new values for keys present in new dictionary U:               foreach (var pair in U)     {         if (X.ContainsKey(pair.Key))            X[pair.Key] = pair.Value;         else            X.Add(pair.Key, pair.Value);     }      So ... the question: is there a better solution for the problem I described above? Is it possible to better manage the updates? Any ideas are welcome, so feel free to post anything that comes to mind. Thank you for contribution


Is Java Bytecode interpreted?

The definition of interpretation (correct me if I'm wrong) is parsing code like so: **1-** Translate currently parsed line to some intermediate language. **2-** Run the translated line. **3-** Move to the next line. **4-** Translate it. **5-** Run it. And so on. If so, why do people say that the JVM **interprets** the Java Bytecode? What it does is **execute** it. The Bytecode is already translated Java source code, so there's no need to translate further. Than why is the term **interpretation** involved? If this term is used because the JVM **executes** the Bytecode **line by line** , well I'd say that any execution does that. Executes the runnable code from top to bottom. Than why use the term **interpretation**? _**Interpretation** as opposed to what?_


How to apply OOP, SOLID principles and Design Patterns in a library which does parallel processing without the caller's knowledge?

I want to explore the contentions between the two hot topics: Clean code vs. Good performance. (In progress ... please post comments to help me flush out the details of this question. Thanks.) Examples which may help me define the question:   * Windows GDI+ is known to perform work on separate threads, which would have happened in parallel to user's code if run on a multi-processor machine.   * Component Object Model (COM) is a framework which gives class developers the choice to provide parallelizable implementations of interfaces, however bugs which arise from that is not unheard of.   * One way of providing parallelized safety is to ensure that the parallelized work only happen within a single call to the object's method at the outermost API level; the method shouldn't return to the caller until the parallelized work is finished. (Objects and methods which aren't visible to the outside can be parallelized.) Does this make it necessary to build an entire set of flyweight objects just to separate the "Public Objects" from the "Private Objects"?   * SOLID principles encourage extensibility by allowing library users to provide their own implementations of interfaces (through Dependency Injection). How does the library ensure that the user's implementation satisfies the thread-safety requirements?      * Component Object Model uses "thread models" which was an attempt on this issue, however most of the time it only results in deadlocks or failed function calls for the reason that "you are calling from the wrong thread apartment".


how often do we need to do appraisal for a developer?

I have this question since my friend told me that if we have frequent appraisal such as 4 months or 6 months once, people will be turned to a money minded. But I am thinking this in another aspect like, people will be getting feedback and boost quickly than one year appraisal. We do not need to increase the salary much. But the token advancement would help them to get some refreshment.


UML sequence diagrams - include

I'm currently doing my OCPJEA assignment. I have to draw several sequence diagrams for the use cases presented in the documentation. One of the use cases (A) state that after some interaction, the system executes another use case (B). I've already drawn the diagram for B, is there any way in UML2 to show inclusion, or do I have to duplicate all those interactions into A?


Anyone code at a treadmill desk?

have been thinking about getting a treadmill desk for awhile now but I just don't know if it is possible to code at one. I can see doing a normal computer job while walking very slow but I just don't know if you can write code do it. Like a lot of people I could stand to lose weight and I am just not in shape anymore. I sit at my computer for at least 12 hours a day and then I am on my laptop for a few more hours. I need to do something to help my health. I also have been seeing a lot of reports about the long term health issues related to desk jobs. Like this. Before I drop a few hundred dollars on a new desk I am wondering if anyone has tried a treadmill desk and if so which one?


Project Management Software / 1 maybe 2 developers

I am looking for software that I can use to "manage" multiple projects (5 - 10). Here are the features I would like but any recommendation is welcome.   1. Bug/Feature tracking on a per project basis.   2. Some way to keep all documents, diagrams, specs, requirements, in one place with the project. Better yet a tool where all these things or most of them could be authored.   3. Task management during the development phase with milestones and estimates/actuals.   4. Git integration I have been doing contract work and i have been doing really well for myself as far as getting projects but its becoming VERY hard to manage everything in an efficient manner. I am trying to learn about best practices when it comes to software programming methodologies and the more I read the more i realize that I am just managing these projects poorly. I am getting things done but the more I take on the less "solid" everything is. I am afraid if I don't get some good solid tools/practices in place I am going to do my customers and myself a disservice. The problem is that there are SO many options that its hard to weed through them all. I was at a point today where I had decided that I would just code my own (there is some irony here)! Obviously everyone has their likes dislikes I would love to hear from some of you lone programmers and how you manage everything since our needs aren't exactly the same thing that a large team might need. I also want a solution that can scale to 2 maybe 3 developers if I end up hiring some people to help with my work load. Thanks again for your usual insights!


When developing a MVC web application should views or models be created first?

I have to build a new application from scratch, so I want to implement it using MVC3 and try to follow general best practices as closely as possible. However, I'm developing it as a one man army. Does it make more to create the views first so I have some "Mockup screens" then build the Models and controllers? or the other way around?


Is job hopping the best way to keep moving and learning at work?

Leaving aside anything you could do outside of work like OSS or self study, do you think job hopping is a good way of continuously learning new skills. In this context, my definition of job hopping is every 2-3 years, move companies, possibly even domains. By changing to the right jobs you could in theory learn a new language/framework and get exposure to other domains of knowledge. A quick update: This is not my current situation, nor is it an approach I have followed. The thought just struck me and I thought it was a good question.


How do I decide to which class a method should belong

I have `TopicBusiness.class` and `PostBusiness.class`. I have no problem with deciding into which class methods such as `addPostToDatabase()` or `getAllPostsFromDatabase()` should go. But what about `getAllPostsFromTopic(TopicEntity topic)` or `getNumberOfPostsInTopic(TopicEntity topic)`? Should the parameter be the deciding factor? So when the method takes TopicEntity as parameter it should belong to `TopicBusiness.class`? I am quite puzzled by this. EDIT: Some more info as requested. `TopicBusiness.class` and `PostBusiness.class` are classes holding all the business logic of the application concerning topics and posts respectively - that is fetching the data from database and/or performing some operations on them. `TopicEntity` is data (in this case representing single topic) fetched from database. `getAllPostFromTopic(TopicEntity topic)` gets all posts from database that belong to particular topic, while `getNumberOfPostsInTopic(TopicEntity topic)` performs database query and returns the number of posts that topic passed as parameter consists of.


Would a model like this translate well to a document or graph database?

I'm trying to understand what types of models that I have traditionally persisted relationally would translate well to some kind of NoSQL database. Suppose I have a model with the following relationships:               Product  1-----0..N  Order     Customer 1-----0..N  Order      And suppose I need to frequently query things like All Orders, All Products, All Customers, All Orders for Given Customer, All Orders for Given Product. My feeling is that this kind of model would not denormalize cleanly - If I had `Product` and `Customer` documents with embedded `Orders`, both documents would have duplicate orders. So I think I'd need separate documents for all three entities. Does a characteristic like this typically indicate that a document database is not well suited for a given model? Generally speaking, would a document database perform as well as a relational database in this kind of situation? I know very little about graph databases, but I understand that a graph database handles relationships more performantly than a document database - would a graph database be suited for this kind of model?


Ruby - when to use instance variables vs parameters between methods?

I'm writing several methods that call other methods. To pass the information I have a couple of choices:   1. Pass the information as parameters   2. Set instance variables so that other methods can access them When should I choose one option over the other? It seems that the first option is good as it is very specific about what is being passed. the downside seems to be that a lot of values are being passed around. The second method doesn't require passing all the values around but seems to lead to a lot of magic where methods set instance variables 'somewhere' Should I always be very explicit about gets passed to other methods in the class? Are there exceptions so this?


Strategies for browser compatibility on web applications in a corporate environment

With the new CSS 3 and HTML 5 technology, web applications have gained a lot of new tools for a better UI (user interface) interaction, beautiful templates and even responsive layout to fit into tablets and smartphones. Within a corporate environment, those new technologies are required so the company can "follow" the IT evolution and their concurrent, but they also want that those new web applications supports old browsers. How should I deal with this situation? By one side we are asked to follow the the evolution of technology, create responsive layouts and use a lot of cool jQuery plugins. On the other hand, we are asked to support old browsers that do not support those new responsive features, plugins or components.   * I would like advice and strategies on how to create "modern" web applications that are also supported on old browsers.   * How does your company deal with this situation?   * Is it possible to have the same web application run well and beautifully on old browsers, and be responsive and interactive on newer browsers?


Subset whose sum gets closest to saturating some bound

I have a problem that boils to down having a set of integers and wanting the subset of those integers whose sum is closest to some target without going over. What's a good algorithm for doing this? Maybe it's even a well known problem whose name I don't know?


I feel sleepy and tired when I encounter problems during a working day, is that normal?

I think it is kinda strange but I just noticed that I have this odd habit of feeling tired, sleepy and dizzy when I encounter a (programming) problem that I can't solve after a while of trying. It generally shows up when I'm dealing with svn, reading someone else's code or resolving regression issues (old bug reappearing again). To my understanding, this has nothing to do with being exhausted or tired because I just felt brilliant like 30 minutes ago and now, after 30 minutes of wrestling with a problem that I can't (apparently) solve, I suddenly feel an urge to go to sleep. And I really can go to sleep when I feel like that. If I shift my focus to something else or just leave it, then after like 10 minutes or so I feel normal again and am ready to continue. I finally managed to talk about it to a colleague who sits just next to me and he sometimes feels the same way in some extreme cases of constant failures and he also finds it strange and new but there is another person who sits a little farther but he isn't feeling anything like this when he encounters difficulty :-? Ideas? EIDT: I realized the fear of failing the whole project seems to play an important role. Since I'm the agile manager in the team, when I face a problem I can't immediately solve, subconsciously I start to tell myself : this is gonna make the whole thing fail. Specially when regressions happen.


BDD to replace the test teams work - how best to do it?

The system we are developing, using .NET, is extremely large, complex, and some modules are poorly written. We have a large user acceptance test team that is aiming for 100% business scenario coverage, which takes about 6 weeks. Can we use behavior driven development to replace some of the manual tests being done by the test team? How would that information be readable to the test teams so they can be sure it's working? Does BDD replace our integration tests?


What qualifications are most important for an outsourcing manager?

I am considering hiring someone exclusively to manage outsourcing of relatively small projects on Guru.com or VWorker.com. The person should be located close to me so I can have face-to-face communication and also that he/she gets domain knowledge. The projects will be in a wide variety of technologies and ranging from mission-critical to completely experimental projects. Sometimes deadlines will also be extremely tight. My question is what kind of candidates would be the best at undertaking such a job? Are recently graduates the best? Expert technicians who can recognize and communicate with other experts? Experienced project leaders? An aspect of this is that I want the best cost/benefit ratio, given that experienced project leaders are likely to be much more expensive than recently graduates. I also believe that one aspect of this is that this is quite an unusual organizational structure, so I am not sure that people who are used to the bureaucracy project management in big companies would be able to adapt to such a working environment.


Triggering Data Changes in N-Tier

I've been studying n-tier architectures as of late, particularly in VB.NET with Entity Framework and/or LINQ to SQL. I understand the basic concepts, but have been wondering about best practices in regard to triggering CRUD-type operations from user input/action. So, the arcitecture looks something like the following: [presentation layer] -> [business layer] -> [data layer] -> (database) Getting information from the database into the presentation layer is simple and abstracted. It's just a matter of instantiating a new object from the business layer, which in turn uses the data layer to get at the correct information. However, saving (updating and inserting), and deleting seem to require particular APIs on the relevant business objects. I have to assume this is standard practice, unless a business object will save itself on various operations (which seems inefficient), or on disposal (which seems like it just wouldn't work, or may be unwieldy and unreliable). Should my "savable" business objects all implement a particular "ISavable" or "IDatabaseObject" interface? Is this a recognized (anti-)pattern? Are there other, better patterns I should be using that I'm just unaware of? The TLDR question, I suppose, is **How does the presentation layer trigger database changes?**


Starting software projects

Always, when I try to start new project, with what I think new ideas, first of all I search the web to try to find some thing same, most of the time (if not all) I find that my ideas of new project have been implemented hundred of times. I think everyone in software industry feel this every day. The question is:   * when should I approve an idea and start building it, although it's implemented hundred of times around the world?    * how I can make my way in trying of build something new?