Building a computer system with JS?

I recently finished this book called The Elements of Computing Systems where you build a working computer system from the ground up, starting from basic logic gates, to creating your own machine code and Assembly language, to intermediate code, and finally a simple object-oriented programming language that compiles down to VM code. I enjoyed it a lot and I'd like to create something similar in JavaScript, but with more features. I've already written an emulator for the Hack machine in JS:                 // Creates a new CPU object that is responsible for processing instructions       var CPU = function() {          var D = 0;    // D Register         var A = 0;    // A Register     var PC = 0;   // Program counter               // Returns whether an instruction is valid or not     var isValidInstruction = function(instruction) {         if (instruction.length != 32)             return false;              instruction = instruction.split("");               for (var c = 0; c < instruction.length; c++)         {             if (instruction[c] != "0" && instruction[c] != "1")                 return false;         }              return true;     };                 // Given an X and Y input and 6 control bits, returns the ALU output     var computeALU = function(x, y, c) {              if (c.length != 6)             throw new Error("There may only be 6 ALU control bits");              switch (c.join(""))         {             case "000000": return 0;              case "000001": return 1;              case "000010": return -1;              case "000011": return x;              case "000100": return y;              case "000101": return ~x;             case "000110": return ~y;             case "000111": return -x;              case "001000": return -y;              case "001001": return x+1;              case "001010": return y+1;             case "001011": return x-1;             case "001100": return y-1;             case "001101": return x+y;             case "001110": return x-y;             case "001111": return y-x;             case "010000": return x*y;             case "010001": return x/y;             case "010010": return y/x;             case "010011": return x%y;             case "010100": return y%x;             case "010101": return x&y;             case "010110": return x|y;             case "010111": return x^y;             case "011000": return x>>y;             case "011001": return y>>x;             case "011010": return x<<y;             case "011011": return y<<x;                  default: throw new Error("ALU command " + c.join("") + " not recognized");          }     };                // Given an instruction and value of Memory[A], return the result     var processInstruction = function(instruction, M) {              if (!isValidInstruction(instruction))             throw new Error("Instruction " + instruction + " is not valid");              // If this is an A instruction, set value of A register to last 31 bits         if (instruction[0] == "0")         {             A = parseInt(instruction.substring(1, instruction.length), 2);                  PC++;                   return {                 outM: null,                 addressM: A,                 writeM: false,                 pc: PC             };          }              // Otherwise, this could be a variety of instructions         else         {             var instructionType = instruction.substr(0, 3);             var instructionBody = instruction.substr(3);                  var outputWrite = false;                   // C Instruction - 100 c1, c2, c3, c4, c5, c6 d1, d2, d3 j1, j2, j3 (000..000 x16)             if (instructionType == "100")             {                 var parts = [ "a", "c1", "c2", "c3", "c4", "c5", "c6", "d1", "d2", "d3", "j1", "j2", "j3" ];                 var flags = {};                       for (var c = 0; c < parts.length; c++)                     flags[parts[c]] = instructionBody[c];                       // Compute the ALU output                 var x = D;                 var y = (flags["a"] == "1") ? M : A;                  var output = computeALU(x, y, [flags["c1"], flags["c2"], flags["c3"], flags["c4"], flags["c5"], flags["c6"]]);                       // Store the result                 if (flags["d1"] == "1") A = output;                  if (flags["d2"] == "1") D = output;                 if (flags["d3"] == "1") outputWrite = true;                       // Jump if necessary                 if ((flags["j1"] == "1" && output < 0) || (flags["j2"] == "1" && output == 0) || (flags["j3"] == "1" && output > 0))                      PC = A;                 else                     PC++;                       // Return output                 return {                     outM: output,                     addressM: A,                     writeM: outputWrite,                     pc: PC                 };              }                  else throw new Error("Instruction type signature " + instructionType + " not recognized");         }     };                // Reset the CPU by setting all registers back to zero     this.reset = function() {         D = 0;         A = 0;         PC = 0;     };                // Set the D register to a specified value     this.setD = function(value) {         D = value;     };                // Set the A register to a specified value     this.setA = function(value) {         A = value;     };                // Set PC to a specified value     this.setPC = function(value) {         PC = value;     };               // Processes an instruction and returns the result     this.process = function(instruction, M) {         return processInstruction(instruction, M);      };      };       I was thinking about adding things like a filesystem, sound, Internet connectivity, and an RGBA screen output (currently it's only black and white). But how feasible would this be, really? Because what I'm thinking about doing is starting _completely_ from scratch. And what I mean by that is create my own machine code, then work all the way up towards a C-like language and actually create working programs and stuff.


C++ vs Objective-C design principles of setters and getters

In C++ I was told that my classes shouldn't have getters and setters: Doing it wrong... blog post. On the other hand, in Objective-C, the direct use of ivar is discouraged, because the getters allow to do lazy instantiation, and setters make KVO easy. Why is that difference?


How does one deliver messages to (and query from) sites with possibly bad connectivity, having numerous WCF Soap and Web API services?

My company is investigating using a service bus. Currently we have running prototypes of NServiceBus and Microsoft Service Bus (on premise). I'm quite happy with the pub-sub and topic messaging capabilities the bus provides but I'm getting lost in one of the requirements they are referring to. For example: They want to query the service bus and "GetAccountInformation()" and expect a result back ala WCF service style and expect the bus to answer them sufficiently to display the result in a UI. Now, with the above I mentioned the following :   1. The bus cannot be used for querying as the inherit pattern involves a "high latency" as we cannot be guaranteed that any subscriber would be listening at that point.   2. It sounds like they want to use the bus as a "hub" for all communications. To me that's sounds like they need WCF relays. To complicate matters, the reason why they are looking into it, we need to be able deliver messages to (and query from) geographically dispersed sites some of which has absolute horrible connectivity issues. So, for this case messaging fits. Also, all different sites have numerous WCF Soap and Web API services. How to achieve this?


Is XHTML5 dead or is it just an synonym of HTML5?

So what happened to XHTML5? http://www.w3.org/TR/html5/ That page is a draft for both xhtml5 and html5? So there's no difference between these doctypes?


Just getting started in Spring and my preference is XML config over annotations. Correct or not?

After having read through some of the Spring docs my inclination is towards using a XML config file rather than annotations on the classes themselves. My reasoning is that by doing so you avoid tying your POJOs to a particular framework. Based on your experience with Spring, are there any advantages that XML configuration have over an annotation based configuration, and if not what are the disadvantages?


Going from cutting edge to maintaining legacy projects

I have an Access 03 program with a bunch of VBA code that is in use and the end user wants new functionality. I am finding it very difficult to add new functionality because my brain wants to use the most recent .NET technologies and VBA is not recent at all. How should I go about "rolling back" technologies in my head to keep my frustration levels to a minimum? Also my boss said it wasn't in the budget to rewrite the project from access and vba to some sort of form and SQL combo (which I could probably pound out in a few days, which is the same amount of time that I feel that it will take me to look up and implement in the old system).


What are the tradeoffs for using 'partial view models'?

I've become aware of an itch due to some non-DRY code pertaining to view model classes in an (ASP.NET) MVC web application and I'm thinking of scratching my itch by organizing code in various 'partial view model' classes. By partial-view-model, I'm referring to a class like a view model class in an analogous way to how partial views are like views, i.e. a way to encapsulate common info and behavior. To strengthen the 'analogy', and to aid in visually organizing the code in my IDE, I was thinking of naming the partial-view-model classes with a `_` prefix, e.g. `_ParentItemViewModel`. As a slightly more concrete example of why I'm thinking along these lines, imagine that I have a domain-model-entity class `ParentItem` and the user- friendly descriptive text that identifies these items to users is complex enough that I'd like to encapsulate that code in a method in a `_ParentItemViewModel` class, for which I can then include an object or a collection of objects of that class in all the view model classes for all the views that need to include a reference to a parent item, e.g. `ChildItemViewModel` can have a `ParentItem` property of the `_ParentItemViewModel` class type, so that in my `ChildItemView` view, I can use `@Model.ParentItem.UserFriendlyDescription` as desired, like breadcrumbs, links, etc. * * * As a second example, imagine that I have entity classes `SomeKindOfBatch`, `SomeKindOfBatchDetail`, and `SomeKindOfBatchDetailEvent`, and a view model class and at least one view for each of those entities. Also, the example application covers a lot more than just _some-kind-of-batches_ , so that it wouldn't really be useful or sensible to include info about a specific some- kind-of-batch in _all_ of the project view model classes. But, like the above example, I have some code, say for generating a string for identifying a some- kind-of-batch in a user-friendly way, and I'd like to be able to use that in several views, say as breadcrumb text or text for a link. As a third example, I'll describe another pattern I'm currently using. I have a `Contact` entity class, but it's a _fat_ class, with dozens of properties, and at least a dozen references to other _fat_ classes. However, a _lot_ of view model classes need properties for referencing a specific contact and most of those need other properties for collections of contacts, e.g. possible contacts to be referenced for some kind of relationship. Most of these view model classes only need a _small_ fraction of all of the available contact info, basically just an ID and some kind of user-friendly description (i.e. a friendly name). It seems to be pretty useful to have a 'partial view model' class for contacts that all of these other view model classes can use. Maybe I'm just misunderstanding 'view model class' – I understand a view model class as always corresponding to a view. But maybe I'm assuming too much.


Design of a custom query result array with lazy loading

I have a database that generates a query result array, each position of the array being a hash like object. Since each array item must be mapped into a well defined class, I decided to implement an array-adapter that cast every item into the expected object class. This cast is done only upon request, not in advance. The native query only return **ids**. The adapter uses these to pull the object that must be adapted. This approach introduces a time delay between the query (native query result) and the provided final item. During this time any item could have been modified in the background by other process. There is also an ugly effect where different sections of the array have different eventual consistency. > Does this mean that any database query must be exhaustive (no lazy fetch of > results)? If a query should always be exhaustive, I am considering in making my adapter _smarter_ , capable of performing a limited query for my views. If the view request a point past the initial limit, it will load more results, however this seems to have the same consistency by parts problems as before. > How are the problems for lazy loading of past query results consistency > problems solved?


Senior developer role to architect role

Sometimes I think architect role is just a title that is given for someone that has been a senior developer for a number of years. How do you know when a senior developer is ready to take on an architect role? Is it by market standard common for senior developer to jump to architect role or do they need to be a team lead then architect? I need some enlightment on this topic.


Opensource, noncommercial License?

i want to publish my software under a opensource license with the following conditions: you are allowed to:   * Share — to copy, distribute and transmit the work   * use a modified version of the code in your application you are not allowed to:   * publish modified versions of the code   * use the code in anything commercial Is there a software license out there that fits my needs ? (crosspost: http://stackoverflow.com/questions/4558546/opensource- noncommercial-license)


Know executables files launched/loaded by an executable file

I would like to know any executable files launched or loaded by an executable file (if possible without running it,if it is not possible i don't want any change in the system). For example i have this source code compiled in an executable :               CreateProcess("C:\\Windows\\explorer.exe", NULL, NULL,NULL,FALSE,0,NULL,NULL,&SI,&PI);     hKernel32 = LoadLibrary("kernel32.dll"); // I can know this by looking in the import table     g_LoadLibrary = (pLoadLibrary)GetProcAddress(hKernel32, "LoadLibrary");     g_LoadLibrary("unknow.dll");     ShellExecute(NULL,"open", "script.py", "", "", SW_SHOWDEFAULT );      Here i want to know he spawn explorer.exe, load kernel32.dll ,unknow.dll and start script.py. How i can do that ? Thank you!


Code obfuscator for C++

I suspect that obfuscating C++ code will make reverse engineering harder: without meaningful symbol names there will be no hints about modules functions and interactions. Can anyone recommend good, verified obfuscator for C++? Their prices are about $150, but if I end up purchasing 3 different products, it will be $450.


How to quickly adapt to a project?

Suppose my favourite open source application has a bug. Now I want to contribute to the application by fixing its bug and submit the patch to the development team. What's the most effective way to do this? Do you actually read the whole source code of the project (or most of it) to understand the logic before start fixing it?


Belkin device runs Linux, how can I create my own custom firmware for it?

The Belkin N300 F9K1002 firmware is located here. It does not appear to be encrypted. How can I upload my own custom Linux firmware to this device. How would I go about hacking it?


Should Android development be done on Windows or OSX? Is there any difference?

I have the option to install the Android SDK on Windows or OSX. Which platform provides a better (easier) development experience? To keep this constructive, I'm looking for any difference that eliminates compatibility issues, ease of debugging, or compatibility with 3rd party utilities.


C# Open Source software that is useful for learning Design Patterns

In college I took a class in Expert Systems. The language the book taught (CLIPS) was esoteric - Expert Systems: Principles and Programming, Fourth Edition. I remember having a tough time with it. So, after almost failing the class, I needed to create the most awesome Expert System for my final presentation. I chose to create an expert system that would calculate risk analysis for a person's retirement portfolio. In short, the system would provide the services normally performed by one's financial adviser. In other words, based on personality, age, state of the macro economy, and other factors, should one's portfolio be conservative, moderate, or aggressive? In the appendix of the book (or on the CD-ROM), there was this in-depth example program for something unrelated to my presentation. Over my break, I read and re-read every line of that program until I understood it to the letter. Even though it was unrelated, I learned more than I ever could by reading all of the chapters. My presentation turned out to be pretty damn good and I received praises from my professor and classmates. So, the moral of the story is..., by understanding other people's code, you can gain greater insight into a language/paradigm than by reading canonical examples. Still, to this day, I am having trouble with everyday design patterns such as the Factory Pattern. I would like to know if anyone could recommend open source software that would help me understand the Gang of Four design patterns, at the very least. I have read the books, but I'm having trouble writing code for the concepts in the real world. Perhaps, by studying code used in today's real world applications, it might just "click". I realize a piece of software may only implement one kind of design pattern. But, if the pattern is an implementation you think is good for learning, and you know what pattern to look for within the source, I'm hoping you can tell me about it. For example, the System.Linq.Expressions namespace has a good example of the Visitor Pattern. The client calls Expression.Accept(new ExpressionVisitor()), which calls ExpressionVisitor (VisitExtension), which calls back to Expression (VisitChildren), which then calls Expression (Accept) again - wooah, kinda convoluted. The point to note here is that VisitChildren is a virtual method. Both Expression and those classes derived from Expression can implement the VisitChildren method any way they want. This means that one type of Expression can run code that is completely different from another type of derived Expression, even though the ExpressionVisitor class is the same in the Accept method. (As a side note Expression.Accept is also virtual). In the end, the code provides a real world example that you won't get in any book because it's kinda confusing. To summarize, If you know of any open source software that uses a design pattern implementation you were impressed by, please list it here. I'm sure it will help many others besides just me.               public class VisitorPatternTest     {              public void Main()         {             Expression normalExpr = new Expression();             normalExpr.Accept(new ExpressionVisitor());             Expression binExpr = new BinaryExpression();             binExpr.Accept(new ExpressionVisitor());         }     }          public class Expression     {         protected internal virtual Expression Accept(ExpressionVisitor visitor)         {             return visitor.VisitExtension(this);         }              protected internal virtual Expression VisitChildren(ExpressionVisitor visitor)         {             if (!this.CanReduce)             {                 throw Error.MustBeReducible();             }             return visitor.Visit(this.ReduceAndCheck());         }              public virtual Expression Visit(Expression node)         {             if (node != null)             {                 return node.Accept(this);             }             return null;         }              public Expression ReduceAndCheck()         {             if (!this.CanReduce)             {                 throw Error.MustBeReducible();             }             Expression expression = this.Reduce();             if ((expression == null) || (expression == this))             {                 throw Error.MustReduceToDifferent();             }             if (!TypeUtils.AreReferenceAssignable(this.Type, expression.Type))             {                 throw Error.ReducedNotCompatible();             }             return expression;         }          }          public class BinaryExpression : Expression     {         protected internal override Expression Accept(ExpressionVisitor visitor)         {             return visitor.VisitBinary(this);         }              protected internal override Expression VisitChildren(ExpressionVisitor visitor)         {             return CreateDummyExpression();         }              protected internal Expression CreateDummyExpression()         {             Expression dummy = new Expression();             return dummy;         }     }               public class ExpressionVisitor     {         public virtual Expression Visit(Expression node)         {             if (node != null)             {                 return node.Accept(this);             }             return null;         }              protected internal virtual Expression VisitExtension(Expression node)         {             return node.VisitChildren(this);         }              protected internal virtual Expression VisitBinary(BinaryExpression node)         {             return ValidateBinary(node, node.Update(this.Visit(node.Left), this.VisitAndConvert<LambdaExpression>(node.Conversion, "VisitBinary"), this.Visit(node.Right)));         }     }


Parameterized Django models

In principle, a single Django application can be reused in two or more projects, providing functionality relevent to both. That implies that the same database structure (tables and relations) will be re-created identically in different databases, and most times this is not a problem (assuming the projects/databases are unrelated - for instance when someone downloads a complete app to use in their own projects). Sometimes, however, the models must be "tweaked" a little to better fit the problem needs. This can be accomplished by forking the app, but I wondered if there wouldn't be a better option in cases where the app designer can anticipate the most common customizations. For instance, if I have a model that could relate to another as one-to-one or one-to-many, I could specify the `unique` property as a parameter, that can be specified in the project's settings:               class This(models.Model):         other = models.ForeignKey(Other, unique=settings.OTHER_TO_THIS)      Or if a model can relate to many others, I could create an intermediate table for each of them (thus enforcing referential integrity) instead of using generic fks:               for related in settings.MODELS_RELATED_TO_OTHER:         model_name = '%s_Other' % related         globals()[model_name] = type(model_name, (models.Model,) {             me:models.ForeignKey(find_model_class(related)),             other:models.ForeignKey(Other),             # Some other properties all intersection tables must have         })      Etc. Let me stress out that I'm **not** proposing to change the models at runtime nor anything like that; once the parameters were defined and `syncdb` called for the first time, those parameters are not to be changed again (unless you're doing a schema migration). Is this a good design? Are there better ways to accomplish the same thing, or maybe drawbacks I coulnd't anticipate? This technique is meant to be used sparingly (only on apps meant to be reused in wildly different contexts, and only when a specific need of customization can be detected while the app model is being designed).


How to manage an open source project's documentation?

I am the creator of a growing open source project. Currently, I'm becoming frusterated trying to figure out the best way to manage documentation. Here are the options I have considered:   * HTML Website   * A Github Wiki   * Markdown Files Hosted On Github   * Placing All Docs in Github README.md The documentation is already written in Markdown, I just can't figure out how I want to make it available. I'm really drawn towards Git since I can branch and tag the documentation just like I can branch and tag the source. I could use a Markdown library to translate the Markdown to HTML and display it on a styled website. I would need to upload changes to the website anytime there was a change, and it would be difficult to manage all of the different "tags" of the documentation. Github Wikis (as far as I know) do not change according to the branch you are on. So, I could only have the "master" version of the documentation in Github Wiki form at any given time. Putting it all in the Github README is kinda neat. I get branching and tagging, but it's a little tiring to use and doesn't lend itself well to easy navigation. Am I missing some awesome solution? What other options do I have?


Why is imperative programming preferred over functional programming?

**Background:** I am proponent of functional programming who works at a VB.NET shop where the prevailing mental model is imperative programming. Being that foundation of our system is WinForms I can understand we're not going to get entirely away from imperative programming, but still I try to use FP (primarily via Linq) wherever possible because I believe in its merits. **Arguments & counter-arguments against FP**   1. One might notice that fluent Linq is less efficient than its imperative counterpart in that this style processes a sequence down to another sequence and repeats that. Generally, its going to take a few more passes than the imperative approach which can be better optimized to avoid repeat passes over a sequence. For this reason, the lead couldn't understand why I would choose a functional approach that is clearly "less efficient."     * _Counter-argument_ : I argued that while it is sometimes less efficient in terms of CPU cycles, that I felt it is more humanly intelligible and easy to follow since each line does just one thing on its pass over the sequence. To me this feels like having an assembly line where each person at his station has just one job to do. I feel that the negligible trade off of efficiency is recompensed by code whose concerns are neatly separated.   2. The next argument against FP that I hear in my shop is that it's harder to debug -- which is true. It's not easy to step over Linq code. And I do sometimes have to unravel a method chain in order to better follow and dissect issues that I can't immediately spot.     * _Counter-argument: For the most part though I don't have issue with this because I think the functional style is more declarative in how it reads and when an error is thrown within a functional chain, I can usually spot the issue immediately. **My Question** I've been trying to promote functional style in our shop and I don't feel like I'm making headway. I've done both styles of programming and have only recently dabbled in Haskell. Despite years of imperative experience, now that I'm making routine use of FP in JavaScript, it's grown on me. It rings a note of rightness in my core when I compare it to what I might have done if I stuck to an imperative style. I've retrained my brain toward functional thinking, toward functional composition. _What I can't understand is how hard its been to convince others of FP's merits._ For example, the developers in my shop do use Linq, but I think they generally use it in the context of dealing with domain data. I use it in a more general sense and prefer it anytime I'm dealing with sequences/lists or persistent data structures. I haven't been able to convince my teammates to expand their use of Linq. _What I'm trying to understand is what causes a developer to not like FP._ I would like to see an answer from someone who has a good deal of experience with FP but decided in favor of the imperative style. What drove the decision to stay with imperative instead of using functional? * * * Here's an additional example highlighting the differences between imperative & functional programming. I wrote the `SelectedRows` method of our grid in Linq as such:               Public Property SelectedRows() As DataRow() Implements IDataSourceControl.SelectedRows         Get             Return Me.ugrBase.Selected.Rows.                 OfType(Of Infragistics.Win.UltraWinGrid.UltraGridRow)().                 Select(Function(ugr) ugr.ListObject).                 OfType(Of DataRowView)().                 Select(Function(drv) drv.Row).                 ToArray         End Get      However, this style of code makes some of our developers uncomfortable and so our lead rewrote it to the more familiar:               Public Property SelectedRows() As DataRow() Implements IDataSourceControl.SelectedRows         Get             Dim plstRows As New List(Of DataRow)             For Each bugrLoop As Infragistics.Win.UltraWinGrid.UltraGridRow In Me.ugrBase.Selected.Rows                 If bugrLoop.ListObject IsNot Nothing Then                     plstRows.Add(CType(bugrLoop.ListObject, DataRowView).Row)                 End If             Next             Return plstRows.ToArray()         End Get


Return tasks or expose events?

What is preferable when you program an API? And I have to add that in my case there will be two events exposed in spite of everything.


Best way to deploy database-dependant application

I have always "custom developed" software for clients. This means:   * Develop the software   * Install SQL Express on client site   * Import DB, create DB user, set DB permissions etc.   * Install software on client site (multiple pc's)   * Voila! Now, I am looking at deploying your basic "end user" app, to a mass of unknown audience. I.e. your basic app someone will download. What are the best common methods for deploying an app with a database? I am looking for the classic (one setup app, deploying both app and db) without the user needing to do some technical configs. I would appreciate some ideas...


How to handle business rules with a REST API?

I have a REST API to manage a booking system I'm searching how to manage this situation : A customer can book a time slot : A TimeSlot resource is created and linked to a Person resource. In order to create the link between a time lot and a person, the REST client send a POST request on the TimeSlot resource But if too many people booked the same slot (let's say the limit is 5 links), it must be impossible to create more associations. How can I handle this business restriction ? Can I return a 404 status code with a JSON response detailing the error with a status code ? Is it a RESTFul approach ? **EDIT :** Like suggested below I used status 409 Conflict in addition to a JSON response detailing the error


What options are there if an SVN repository becomes unavailable?

A project I'm working on was hosted on a svn repository at bettercodes.org. This was under another user's name and **that repository is now unavailable**. The person responsible for the project was sent an export from Eclipse and I had a more or less up-to-date project on my machine. I could see no other option than to commit my copy of the project to another repository. **It is now possible that some of the most recent changes by another programmer are missing**. Now, what options do I have to bring this project together? Is some of the necessary metadata saved on Eclipse or are all the changes on the original repository? What tools could I use to check what is missing in terms of classes, config files and code?


Programming without target platform?

I have a idea for a program and have began laying out the software design concept in a traditional SDLC model of charts and instructions for what I want all parts to achieve. A quick explanation of my idea is this, I want to build a IDE for a tablet that is intended to run on mobile platforms but can also be ran on Windows, Macs, etc. This platform will have a couple very unique concepts in it for graphical programming interface and remote application server usage for compiling and project management like a GIT. I would like to achieve this without having to revamp the code for each system and believe C will allow me to stay close to my goal of no specific platform programming. **The Question** I would assume I want to avoid OS specific calls and (or) external libraries (stick to standard library much as possible) to a minimum. What would be the best practice of doing this while still completing a nearly finished program (until I make targeted platform adjustments)? Would C be my best option to achieve this? **Why I ask.** I have been really interested in using C because of its portability, ability to utilize memory, program sizes are smaller and more efficient, and integration in to nearly all mobile platform. I have done a fair amount of homework on C and am halfway through the “C Programming Guide, second edition” by Kernighan and Ritchie. I have even ordered some books on building compilers and OS design to assist in some fundamental concepts that I believe are relevant to my idea.


What is the algorithm to copy a region of one bitmap, into a region in another?

In my project (and I am sure many others), I need to copy a subset (R2) of one bitmap image (R1), into a region (R3) in another, where the destination region can be any size (stretching and scaling where necessary). ![enter image description here](http://i.stack.imgur.com/fuZqL.png) I am sure this is a solved problem but I cannot find any examples; **what is the most straightforward algorithm for performing this operation?** (Linear interpolation would be sufficient for filling in the pixels when the source is scaled upwards, if that is the quickest (computationally) method)


Python 3, replace in strings

I need to transliterate a Hebrew text. So wrote a little Python script, which reads-in the Hebrew text from a text file, globally replaces the Hebrew letters with Latin ones. Now I need to do some fine tuning (replace certain things in some position but not in other, so a global replace won't do). The trouble is the following: The read-in text is a string so I cannot replace individual string elements. So, what would be the best way to do it?


How to handle growth of an open source project?

I've been involved in helping out doing support for an open source project for a year or two now, and the project has gained a lot of popularity since I started. The program sees more than 100,000 downloads per week, and is used by more than 60% of people in its primary field, so we're obviously delighted that people have enjoyed using it so much. However, the problem is that the development and support base has not grown nearly as fast, and we're starting to hit some growing pains. The small handful of developers (the main developer in particular) are getting stretched pretty thin, and the tech support volunteers are starting to get burned out. Thus far, it has pretty much just been a bunch of dudes hanging out on IRC, writing this program and helping users. There's no 501(c)(3) organization or LLC or anything like that. Right now, we don't have a very formal bug tracker or issue database (we do have a forum with a category dedicated to bug reports), which I do admit is something that we could improve to get more developers on board. But I suppose my real question is, how does one make the transition from small personal project to a real... _thing?_ How have the big boys like GIMP, FFmpeg, Blender, etc. handled this transition? And on top of this, is there a way to offer compensation with a FOSS project? I suppose donations help, but that only goes so far...it seems strange to make a living off of free software, but if the program is going to continue to get better, I don't see how we can continue without compensating people for full time work. Basically, we're having some growing pains, and feeling "too big for our britches." What can we do to manage this transition and not get burnt out on doing too many things at once?


Is there any express edition like thing in Delphi?

I visited the site of Embarcadero and read about Delphi. Though the new version is named Delphi XE, but it is not Express Edition. I want to learn programming in Delphi. Is there any Express Edition or a trial version with no time limit?


Best Practice to return responses from service

I am writing a SOAP based ASP.NET Web Service having a number of methods to deal with Client objects. e.g:   * int AddClient(Client c) => returns Client ID when successful   * List GetClients()   * Client GetClientInfo(int clientId) In the above methods, the return value/object for each method corresponds to the "all good" scenario i.e. A client Id will be returned if AddClient was successful or a List<> of Client objects will be returned by GetClients. But what if an error occurs, how do I convey the error message to the caller? I was thinking of having a Response class:               Response { StatusCode, StatusMessage, Details }      where Details will hold the actual response but in that case the caller will have to cast the response every time. What are your views on the above? Is there a better solution? ---------- UPDATED -----------   Is there something new in WCF for the above? What difference will it make If I change the ASP.NET Web Service to a WCF Service?


Should a web designer know server-side coding?

We're implementing an CMS based on ASP.NET MVC. Now, any designer should be able to provide themes for this CMS. But to write a theme, they need to be able to modify the generated HTML, thus the concept of View. In other words, they should be capable to either modify current views, or create new views from scratch, to fit their requirements. However, now we're not sure that we're taking the right path. Should a web designer (HTML, CSS, JavaScript + Photoshop) really know about server-side platforms like Razor or PHP, or classic ASP, or anything else?


How do you assess your Agile compatibility?

After adopting Agile for a while now, we started to think that we can improve how we do Agile. But for starter, we need to know how well are we doing now and to identify the problems in our current processes before we can improve it. One thing we notice is that every team do Agile a little different from another. A ritual might works well for one team but not for another team. So we want to identify these incompatibilities in our team. What are the common tools/methods that your organization uses to identify these problems?


Is there such thing as a "theory of system integration"?

There is a plethora of different programs, servers, and in general technologies in use in organizations today. We, programmers, have lots of different tools at our disposal to help solve various different data, and communication challenges in an organization. Does anyone know if anyone has done an serious thinking about how systems are integrated? Let me give an example: Hypothetically, let's say I own a company that makes specialized suits a'la Iron Man. In the area of production, I have CAD tools, machining tools, payroll, project management, and asset management tools to name a few. I also have nice design space, where designers show off their designs on big displays, some touch, some traditional. Oh, and I also have one of these new fangled LEED Platinum buildings and it has number of different computer controlled systems, like smart window shutters that close when people are in the room, a HVAC system that adjusts depending on the number of people in the building, etc. What I want to know is if anyone has done any scientific work on trying to figure out how to hook all these pieces together, so that say my access control system is hooked to my payroll system, and my phone system allowing my never to swipe a time card, and to have my phone follow me throughout the building. This problem is also more than a technology challenge. Every technology implementation enables certain human behaviours, so the human must also be considered as a part of the system. Has anyone done any work in how effectively weave these components together? FYI: I am not trying to build a system. I want to know if anyone has thoroughly studied the process of doing a large integration project, how they develop their requirements, how they studied the human behaviors, etc.


What HTTP status codes need to be checked for this network task to perform smoothly?

My office department logs in to the ISP Server through a keep-alive-browser login page. This, for better performance, is encapsulated in to a small python script. This is what it does (Pseudo code)               1.CheckForActiveInternet     2.if not active          Login          KeepAlive     3.else          report      In step 1, a host like "www.google.com" is checked for active connection. A status code is returned and this is exactly what my doubt is; what would this code be? **200** or **202**? Incase google redirects to .co.** urls the status code would be **302** which even complicates it further since our ISP redirects too, when there is no active internet connection.   You could see that if we check **302** for deciding on weather or not we'd be needing a login, it could be either the google redirecting or our ISP itself. So what could be done here? The current script checks:               if status in (200, 202, ""):         Connection is Active      This is quite vague isn't it? When is an empty string returned as status code? A non-redirecting site like wikipedia.org might do the trick I thought, but I don't know how feasible this method would be.


Best resource for developing JavaScript curriculum?

At the risk of being downvoted, I really need the community's input - I am helping put together a post-secondary quality curriculum (vocational school, not university) around open-source languages, specifically JavaScript and maybe some Ruby or PHP. There are some great trade books out there, but things get a little more limited when you need a text book with quizzes and an answer key, for example. I believe this material exists somewhere - is there an online resource or any sort of accreditation body around JavaScript? I realize this may be considered too 'subjective', but I am having a hard time sifting through the mountains of online JavaScript tutorials and trade books.


How do you handle constantly changing database dimensions?

For the last two months or so I have been looking for solutions or practices to handle release management within databases. I'm looking for what people view as the best process for handling this. We have 3 environments for our databases:   * Development   * User Acceptance Testing (UAT)   * Production The problem is sometimes we are making changes to several things within our development database and come time to deploy, some of the features may not be ready to be released to UAT. Recently we have started using Red Gate SQL Source control for storing all of our entities (with regular commits). I was thinking of going based off of changesets (i.e. say everything from changeset X and back is now being pushed to UAT) however, this means that people are only checking their code into source control just before we do a deploy which can get confusing (especially since people are forgetful). Another issue with going with the changeset approach is if there is a bug in a stored procedure that needs to be fixed, the changeset number would end up being out of scope of our max changeset for the revision therefore making it so that if we need to recreate the database off of a maximum changeset, we would be pushing the bug out again. Any suggestions on a process? Thanks


What can I use to keep track of the status of 60 software projects, some of which are obsolete?

I've taken a software development role in an engineering company(all software developed is for internal use only). The company has about 60 individual projects from past developers. The problem is that all past developers are gone and no one knows why about half of the software was built, who uses it, or even what some of it does. We use SVN, but no past developers wrote comments or did any sort of documentation. Assuming I figure all of this out, is there some program/system/method that could be used to keep track of all this information? The company is leaning toward Excel, I'm assuming there's something better. Would it just be better to write up documentation in a Word Doc and commit it to svn so it's right next to the code?


Why should I use Iesi.Collections instead of the traditional System.Collection?

Was research on how (for convetion) define a Many Many where table where both fields are primary key and found this post. So decide to install the Iesi.Collections in my library domain. But there came a doubt. In the "Iesi.Collections" outperforms "System.Collections" Iesi.Collections? Why should I use? It is better in performance?


Minimax in a bayesian game with multiple players who do not play in order

Premise: I know that such a game would be better solved by MCTS, however, from a theoretical point of view, would it be possible to apply minimax to a bayesian multiplayer game where the order of playing is determined by result of the previous turn? Game description:   * Players: {A,B,C,D} (A and C are the maximizing team while B and D are the minimizing team)   * Bayesian to set for example players' cards.   * Turn 1: A->B->C->D   * Turn 2(the order depends of the actual epilogue of Turn 1): C->D->A->B   * Turn 3: B->C->D->A   * ...   * Turn N: game ends. My feeling is that wouldn't be possible because after Turn 1 finished, in minimax standard definition, I must be able to start the next turn from a known player, while chance should be only applied to game's payoffs. Any opinion would be helpful.


What kind of user authentication do I need in for a restful web api

I am doing a restful web api with asp.net Web API 2 I do not want to use any form of cookies or basic authentication (send user/pass in cleartext thus SSL needed) I do not use/need claims stuff. I have not decided yet about asp.net self hosting or IIS. I just want to send an encrypted token between client server via SSL. I am using Entity framework 6, .NET 4.5.1 and I just want to do CRUD-actions on my user table. Not more. What is the project template/library/approach I should start with to do the above?


How to avoid being forked into oblivion by a more powerful contributor?

As recently reported here: > Xamarin has forked Cocos2D-XNA, a 2D/3D game development framework, creating > a cross-platform library that can be included in PCL projects. However the founder of the project that was forked says: > The purpose of the MIT license is to unencumber your fair use. Not to > encourage you to take software, rebrand it as your own, and then "take it in > a new direction" as you say. > > While not illegal, it is unethical. It seems that the GitHub page of the new project doesn't even indicate that it's a fork in a typical GitHub manner, opting for an easily-removable History section instead (see bottom). So my questions are:   1. Was Xamarin's action and the way the action was done ethical or not?   2. Is it possible to avoid such a situation if you are a single developer or a small unfunded group of developers? I am hoping this could be either a wiki question or there will be some objective answers grounded on modern OSS ethics/philosophy.


How do I start my career on a 3-year-old degree

I received my bachelor's degree in Com S (second major in math) in December 2011. I didn't have the best GPA (I was excellent at programming projects and had a deep understanding of CS concepts, but school is generally not the best format for displaying my strengths), and my only internship was with a now- defunct startup. After graduation I applied for several jobs, had a fair number of interviews, but never got hired. After a while, I got somewhat discouraged, and though I still said I was looking, and occasionally applied for something, my pace slowed down considerably. I remain convinced that software development is the right path for me, and that I could make a real contribution to someones work force, but I'm at a loss as to how I can convince anyone of this. My major problems are as follows.   1. Lack of professional experience-- a problem for every entry-level programmer, I suppose, but everyone seems to want someone with a couple of years under their belt.   2. Rustiness-- I've not really done any programming in about a year, and since school all I've really done is various programming competitions and puzzles. (codechef, hackerrank, etc.) I need a way to sharpen my skills.   3. Long term unemployment-- while I had a basic fast-food job after I graduated, I've been truly unemployed for about a year now. Furthermore, no one has ever hired me as a programmer, and any potential employer is liable to wonder why.   4. Old References-- my references are all college professors and one supervisor from my internship, none of whom I've had any contact with since I graduated.   5. Confidence-- I have no doubt that I could be a good professional programmer, and make just about any employer glad that they hired me, but I'm aware of my red flags as a candidate, and have a hard time heading confidently into an interview. How can I overcome these problems and keep my career from being over before it starts?


Hardware-control on one computer. But how about several?

For a while I have been pondering the question of, given a standard interface specification, whether there is a way to allow multiple programs to control multiple hardware devices across the network. The program I am working with is the standard implementation of the ASCOM standard. In short, the principle is that any program can call another known program or driver and expect it (computer-wise) to implement certain standard interfaces, allowing the calling program to control hardware. Currently we only use COM and .NET to do this. This allows many different hardware and software manufacturers to all build software and drivers that all work together. By now it is becoming quite standard, including standard telescope companies providing drivers. Within the ASCOM group, we _have_ discussed how to do this across the network, but since we are more of a user group with a couple core devs, we have never been able to really decide what's a good way to do this. In order to understand the situation better, since I have already made a proof of concept system that works, here are several questions.   1. What transports/pipes/interops are available that most or all languages support across OSs? Or is the transport OS specific? I mean, for instance, the COM interop is on windows. Is there an equivalent on Linux, for instance, that would work the same and the language could use interchangeably? Most languages support network IO. Do we have to use that for interprocess communication or are there other options?   2. To make something truly platform and language agnostic, it would almost need to be dealing with text strings, not binary objects. What standard formats are there, and what are the pros and cons of each.   3. What are your thoughts on getting multiple languages to work together on one computer? Can it work well? Inter-process or intra-process as well?    4. Is something like ASCOM done in any other field of computing? Or are astronomers the only people who connect various software programs and hardware devices together to get one working system? If you need more information, feel free to ask. The ASCOM standards home page is short and hopefully might help illustrate things a bit, but I don't expect you to crawl all over the site before you can answer. :D


What's the term for re-implementing an old API in terms of a newer API

The reason for doing it is to solve the case when a newer API is no longer backwards compatible with an older API. To explain, just say that there is an old API v1.0. The maker of this API decides it is broken and works on a new API v1.1 that intentionally breaks compatibility with the old API v1.0. Now, any programs written against the old API cannot be recompiled as-is with the new API. Then lets say there is a large app written against the old API and the developer doesn't have access to the source code. A solution would be to re- implement a "custom" old API v1.0 in terms of the new API v1.1 calls. So the "custom" v1.0 API is actually keeping the same interface/methods as the v1.0 API but inside its implementation it is actually making calls to the new API v1.1 methods. So the large app can be then compiled and linked against the "custom" v1.0 API and the new v1.1 API without any major source code changes. Is there a term for this practice? _There's a recent example of this happening inJamie Zawinski's port of XScreenSaver to the iPhone - he re-implemented the OpenGL 1.3 API in terms of the OpenGL ES 1.1 API. In this case, OpenGL 1.3 represents the "old" API and OpenGL ES 1.1 represents the "new" API._


Is placing self taught programming experience in a (computer science) university CV a good idea?

I wish to know if putting my attempts at programming in my university CV is a good idea. On the one hand it could show I'm willing and eager to learn, but on the other it could make it appear tacky and a little overqualified. Also, can I say I have experience in X programming language without being fully confident in it?


What topics/abilities are critical to learning a programming language?

What topics/abilities are generally accepted as vital-to-know of any programming language? (Can be answered through either language-specific or non-specific suggestions, however) For example, I wager "Data Structures" would be one. Or if this was for learning a foreign (non-programming) language, "Verb conjugation" might be one. I've found this, which is a helpful start: http://www.indiangeek.net/wp- content/uploads/Programmer%20competency%20matrix.htm


Java Design Question

I am considering the options for designing a system in java which accepts data files from different systems applies some transformations to the data, concats data from multiple files to produce some output data files for the downstream systems. The data transformations are not per record transformation, e.g. I need to read a record , then search the file for another record matching the pattern of a given field from the first record I was thinking of spring batch,but have been asked to consider other options also. Kindly help with any pointers, things to consider while designing and evaluating options.


Are there any statistics on how often code is read?

I have often come across claims that source code is read much more than it is written and just wanted to do a little calculation like: > If you write a line that takes me 5 minutes longer to read because you were > to lazy to write a comment for 5 minutes it will cost us n*X if 5 minutes of > programmer time cost X. Then I realized that I not only lack n to do the calculation but also have never seen any evidence for the claim that code is read much more than it is written. Is that just a fishy "well it is only written once so it has to be read a lot more" argument or are there any studies on the subject that you know of?


Evaluating the complete revision of other's software

I'm having some difficulty to evaluate the revision of a software: the software was paid by customer years ago, never used, and now the customer have noticed that it doesn't work as expected. Now this customer asked me to evaluate the project (I have the sources), and I should give an estimation of the time to fix it and probably a maintenance contract. However, after having analysed the code all the day, I notice that the source code base is very bad. Here is the crucial characteristics:   * A lot of source lines (140K+)   * C++ without classes, all statically allocated, all externs, all public   * Poor comments, poor documentation   * A bunch of warnings, counted more than 7K+ times. Warnings spreads from _unsigned/signed mismatch_ to _aliased variables_ , till _uninitialized variables_.   * Static analysis tools have signaled buffer overflows, unassigned variables, suspect string operations.   * Lot of multithreading and no critical section at all. The code will compile, but only the "debug" version is able to run for a short time. I suspect that buffer overflows are working enough. I've already encountered code like this, I'm not surprised that it is not working as expected. Now I'm thinking how to face this task in the most convenient way, and this is what I thought:   * Fix all compiler warnings.   * Fix all static analysis warnings   * Ensure exclusive access to data shared across multiple threads   * Enable `_HAS_ITERATOR_DEBUGGING` for debugging `std::vector` accesses (vector is used a lot). This imply an upgrade to VS 2005, at least.   * Uses CRT heap debugging as much as possible, even if this imply to move most of the global variables to be allocated on the heap.   * Extensive use of assertions (along with minidump creationg for post-mortem analysis)   * Exhaustive test cases to prove/test software robustness. I would like to prepare unit testing, but I should refactor methods with 2500+ lines, and it would add enough pain to give up. I think I have a good plan, or maybe I'm only in the right direction. I think I'm missing a measurement to actually evaluate the work I could face. Any thoughts?


The rationale behind Falsy values

I'm wondering what the arguments for/against Falsy values are. On what principles would you decide to add or exclude them from a language? Are there any problems you could see them causing off-hand? For users of languages that support Falsy values:   * Where specifically have you used them to your advantage?   * Where have you had unpleasant run-ins with them?   * Are there any rules or finer points in your language/project/team about where it's appropriate or inappropriate to use them? For users of other languages:   * Have you ever seen a situation where you've thought "I wish I could use a Falsy value here"? I'm tagging the question `haskell` and `python` because AFAIK those two represent opposite ends of the spectrum (Haskell demanding `Bool`s when you use `if`, and Python treating `None` and some "empty" values as Falsy), but feel free to talk about your experience from other languages. Just mention where on the spectrum they stand.


Is the Javascript bet a loser or a winner one?

Recently I had the the sensation that the world is trying to port _every_ existing application in HTML5. The proliferation of Javascript API meant to cover almost every programmer's need is the tangible proof. There's an API for every taste: graphics (2D/3D), audio, video, realtime communication, filesystem access, permanent storage, database, connectivity and many more. Everythings seems really nice, but the shame is that at the basis we have Javascript. Now, I cannot say that I'm a real every-day Javascript programmer, and I don't know anyone like that, that's why my experience is not so meaningful, but in the last time I found myself writing some prototypes to see which can be the limit of HTML5. The outcome for me has been discouraging. I find that the language itself, when writing something more complicated than dealing whith some DOM manipulation and event-handling, is not _handy_ (read: maintainable, readable, sharable, ..). But the real problem is not the sytax which may be a matter of taste, but the fact that I see there is a stubborness of people trying to make a _universal_ language out of Javascript, with the browser acting as a sort of a Virtual Machine, which, as a matter of fact, is not and never(?) will be. The availability of new APIs certainly creates many possibilities, and developers are trying to take advantage of them, but at the end they may eventually fight against the inevitable and intrinsic slowness of the language. A slow language, even with every possible shiny feature, remains a slow language, and in some cases this is a true limit. In the past 5/6 years we have seen really huge improvements in Javascript enginges, but today Javascript is still a slow language, and I have the feeling that there is no more room for great improvement in this. So, what now? With GWT (that I think has already reached its top), Google wanted to simplify the developers' life, taking Javascript away from them, and offering every kind of optimization to squeeze Javascript at its limit. Then Google created a new language, dart, with its own Virtual Machine running on a browser ([Dartium]), and which aspires to completly replace Javascript from every browser; in the meanwhile you can always compile it into Javascript (as GWT does). Mozilla has created asm.js where (if I get it right), one can write applications in C/C++, compile the code with clang obtaining LLVM bitcode, which can be compiled again in (a small subset) of Javascript, which, if executed in a special version of Firefox, it can reach great performance. Now, as a programmer, I find myself writing a real HTML5 program, where I have to fight against the Javascript poor performance, and I see that the world is puzzling trying to find exotic ways to overcome the problem, and I ask myself: would it be such a bad thing to keep Flash (or equivalent technologies) alive? Isn't this Javascript _hype_ (I'm exaggerating here..) just trying to make it behave different from what it actually is? Am I the only one seeing this trend?


Mixing Fowlers Transaction Script and Domain Model

I am developing a large application where the previous developer used Martin Fowlers Transaction Script pattern. The requirements are becoming more complex and it is becoming a bit of a maintenance nightmare. Therefore I have started to use Fowlers Domain Model and Table Data Gateway in an attempt to separate concerns and reuse code. It is becoming a refactoring process. My question is: is it bad practice to mix and match patterns? e.g. using Transaction Script and Domain Model in the same application or is this relatively common practice?


The Proper UML Model of a System for Non-Technical Boss

I've taken on some side work for this non-profit and last week was my first week on the job. They have two SQL Server Databases each with many tables in them that represent over 20 different applications such as   * **Course signup** - Trainers can signup to teach different available classes   * **Course Approval form** - trainers complete this form to get new courses approved to be added to the list of available classes.   * **Schedule** - schedule of important dates for a term (holidays, start date for classes, etc.)   * **Trainer** - list of all trainers and other information about a trainer (contact info, education, etc.)   * **Training Calendar** - List that students can look at to see what's available for the current term   * **Training plan** - a report that is printed for student with all of the classes they've signed up for   * **Certificate** - Print a certificate for a student once the training course has been completed There are about 15 other applications but it's all related to trainers, training, courses, students, etc. This data is all over the place as there are no relationships between tables and very tedious processes have to be done to complete simple task. For example, for every new term you have to copy the data in the "old" table, create a new table, paste the old data into the new table and append the new data for the current term to the new table. So there's a table for every term (3 terms per year) for the past 10 years and that's only the beginning. There's a lot of copying and pasting from Excel to SQL Server to get the data into the database and their front-end to manipulate the data isMS Access which I'd like to replace with ASP.NET (they have IIS 7). To properly architect this and have good documentation, I've installed Visio 2013 and I'm learning about UML. So that boss can know exactly how this system will be re-architected, and how all the pieces will fit together what UML diagram should I create for him? Would that be a component diagram? I need to give him the 10,000 foot view so something like use-case, sequence, or database diagrams is way to low-level for him.


C++ why & how are virtual functions slower?

Can anyone explain in detail, how exactly the virtual table works & what pointers are associated when virtual functions are called. If they are actually slower, can you show the time that the virtual function takes to execute is more than normal class methods? It is easy to lose track of how/what is happening without seeing some code.


Is there a design pattern for managing dependencies?

I'm building a component that manages available resources (JavaScript and CSS files) for a web page. As controls are added to the page, they register and un-register their requirements with this manager. Then at render time the manager only renders `<script>` and `<link>` tags for the required resources. A basic implementation would be to have a dictionary with the resource URL as the key and a list of dependent controls as the value. Then at render time, if the list is empty, don't render the resource. I'm wondering if there is an established pattern for this? I'm using ASP.NET and C# if that bares any significance. **UPDATE** I was thinking about it and while the manager is controlling the dependencies of the controls of the page, the fact that they are dependencies is almost superfluous to my question. I think what I'm looking for is something like the Observer Pattern but the observers don't require being notified, the manager simply needs to maintain a list of subscribers.


Silverlight 5 and MVVM. Do I really need other frameworks? What is the best way for rapid development?

I've been reading and watching videos on MVVM and Silverlight.. I'm pretty new to Silverlight but not new to .NET. Interesting that I used MVVM in my WPF apps without knowing that it's MVVM. I was creating easily-bindable classes to serve as a layer between data and XAML :) Project that we start will be done with Silverlight 5 and WCF on a back end. Project will be rather large with several modules 50 or screens each, ideally I would like to load them on demand. MOST(not all) UI will be straight-forward data entry stuff. I'm trying to see what should be our architecture and how will it benefit us in future. I think I GOT IT as far as what MVVM and WHY. I also checked Caliburn Micro (and understood what it does). I see ReactiveUI and MVVMLight. To be honest I don't like external libraries/dependencies. Also, I don't really care about using naming conventions to satisfly external framework and perfectly OK with binding in XAML. Since we have good commands support and XAML debugging in SL5 - I don't think I need external framework. So, I think having ViewModels and binding via XAML with minimal view-related code in code-behind will be perfectly fine with me. Here is my dilemma:   1. If I use RIA services. 80% of my UI will bind perfectly to RIA generated stuff with some converters of course. Will it be bad architecture to have everything bind directly and just some more complex views to use ModelView?    2. Should I use RIA services?! I think YES. I'm all for generated code especially when it's plain data-entry stuff. Will it keep client code synced with server-side?   3. From what I see - ModelView have to be manually coded. Am I correct? Again, for 80% of project that's probably going to be waste of effort.   4. If I want to have multiple xap files that load on demand, should I use some kind of framework? I think keeping it in one file may get too big. Thanks!


Smallest set of objects that add up to a certain value

I’m trying to write an algorithm that, given a number of credits and a set of objects that have different values, calculates: 1) The smallest set of objects which values add up to the number of credits. 2) if 1 is impossible (no combination adds up to the number of credits) finds the set of objects that comes closest to the amount of credits (the sum must be strictly less than the amount of credits). If more than one set adds up to the same number of credits the smallest set should be returned. By smallest set I mean the set with the least objects. In english: I'm trying to pay a price with the smallest amount of objects possible. If that cant be achieved I want to pay the closest to such amount possible (less than) with the smallest amount of objects. simple examples: credits: 6 objects: 10 5 2 2 2 Result: 2 2 2 credits: 10 objects: 5 2 11 2 1 5 Result: 5 5 credits: 9 objects: 5 2 10 Result: 5 2 I was wondering if there is any algorithm already developed to do such a search.


How can we reduce downtime at the end of an iteration?

Where I work we practice scrum-driven agile with 3-week iterations. Yes, it'd be nice if the iterations were shorter, but changing that isn't an option at the moment. At the end of the iteration, I usually find that the last day goes very slowly. The actual work has already been completed and accepted. There are a couple meetings (the retrospective and the next iteration planning), but other than that not much is going on. What sort of techniques can we as a team use to maintain momentum through the last day? Should we address defects? Get an early start on the next iteration's work anyway? Something else?


Do some languages make it easier to build graphically-intensive GUIs?

I made an algorithm that has a good potential use for a commercial application. I'm thinking of making a GUI, and since it's computationally expensive, I'm thinking of putting it "on the cloud" to offer the numerical part as a service. What I'm thinking is making a GUI, and then the users submit the work to the server. This GUI could be made open software (in fact, very probably will be). The GUI has a lot of graphics. Imagine something like making picks on surfaces plots, taking a look at those picks with different tools, and using numerical mathematics on those picks. Are there languages that make this work easier? What, specifically, about them aide in creating GUIs like this?


How do I teach to my brother how to program?

My brother is 12, and he's asked me several times to teach him how to program. I'm confident that I'm not a terrible programmer, but I don't see myself as an effective teacher. I taught myself most of what I know, using books and the web.   I've loaned him the "Head First iPhone Development" book, which was quite obviously way above him, since he—like I was at that age—loves to read fiction, but hates technical books, and has no prior experience. I also asked him for an app idea, and he came up with something that involved 3D modeling and such. It's great that he's aspiring high, but I doubt he has the patience to learn enough to gain patience to learn the rest. He's definitely bright, and I was able to explain the concept of variables to him. I'm taking a C++ course in college and I can probably pass that on to him. Is that a dumb idea? What do you suggest? Should I continue to encourage him? If so, what materials should I suggest?


TTS on App Engine

I have written a small front-end to the Festival TTS system using Python/Django. I wish to deploy it on the Google App Engine cloud. A few questions:   1. My application uses the Festival app 'text2wave'. Will is work on the cloud?   2. I have used Python primitives like subprocess.call() to invoke the aforementioned program. Will that work?   3. If your answer to any or both of (1) and (2) is no, is there a free api on the web that I can use (from the appengine)? I read somewhere about placing calls from Phono to a Voxeo backend, but I'm not sure what that means. I am aware of the Google Translate extension that allows translation using an HTTP GET (REST) request, but here the text is limited to 100 chars. Bad. Plus, they may take it down any point of time.


can we do scaling by throwing ruby stone

1. I heard developers at my office discussing Ruby language can be used for following purposes: Desktop apps,Web Apps,and may be handheld devices. Actually,we are in phase of selecting technology to have scalability of the following:   2. I have - Ruby made Desktop apps on each inventory unit of the big firm. And wish to synchronize all relevant data from those desktop apps to a web app DWarehouse like Dropbox for some ontology and mining work. And wish to have some wireless chat app also on handsets like whatsapp to assist in faster communication between inventory unit managers.   3. So,can we get a faster good build of Desktop apps,web apps and handset chat apps using ruby technology.   4. And I know ruby can't be scaled up for large workload,then what we can do later,should we get some java or php support to scale the application base or there is some cloud option present for ruby.


What Features of an IDE Would Make It More Useful Than A General Purpose Editor

I am authoring a IDE for the Lua language. I find that many programmers do not like to use IDE and prefer VIM (which is in vogue at the moment), SCiTE, or . In trying to win some mind-share I am interested in what features an IDE could provide that would make it a compelling alternative to a general purpose editor. Is there a "killer-app" so to speak for an IDE that would make it a "must- have"? This could be thought of as the reverse of Most useful features of VIM that aren't standard in a IDE I won't link to my IDE unless someone asks - but you can pretty much just Google my name and find it. EDIT: My IDE is actually a language plugin for an existing IDE, so I do inherit many features from the host IDE - at some level though my language support is an IDE in and of itself - at least as far as the language specific aspects are concerned.


I am in a rather difficult work situation. Should I stay or should I go?

After reading a lot on this forums, it seems that my current employer isn't a really great place to work and I'm wondering if I should move on, or stay a bit longer and then leave so it looks better on my resume (Only been here 3 months). Things that I'm worried about with this company   * A completely non technical manager with little management experience leading this team. Fine in a bigger company but we're a small team (< 10 employees)   * Alright hardware but no choice of OS and we can't get any decent software bought for us   * Terrible salary and no overtime pay, not great benefits   * Mandatory overtime. If I didn't work tons of overtime nothing would be done in time and I'd get in trouble   * Stuck fixing old code which is terribly written, unstable, undocumented and full of bugs. We don't use it anymore but lots of clients to maintain   * We must track ALL of our time, billable, non-billable and internal   * No bug database (I'm trying to implement one, hard since I have no time since I'm working crazy overtime and I want some time to myself when I get it   * I'm the only programmer So I work for a web development company that works with Joomla quite a bit, and I'm a PHP/Python guy with Java/C++ experience and a willingness to learn many other languages. I've also got experience in technical but non programming related fields such as System Administration. I'm wondering, should I call it quits, wait a while longer so I can use the job on my resume, or try and fix the problems we have?


Can someone explain how to do the Fast fourier transform based multiplication algorithm in very large numbers more clearly? I've been searching for this a lot and I'm having a very hard time because all explanations I get have mathematical notation represented in figures or images and my screen reader can't read it. Can someone explain this clearer? And with examples if possible. Preferable in java.


Implementation of deque in C++ with an array

How is the `end()` function implemented in deque-STL of C++ with array? As per my knowledge it returns past-the-end element. But when a loop is run like, `for(i=deq.begin();i!=deq.end();i++)` and the whole array is full (suppose size=4), then I think `end()` will point to the position where `begin()` is pointing, in this way it won't go in the for loop. How to resolve this problem?


Help with inheritance hierarchy design

I'm having trouble designing an inheritance hierarchy. In the figure: **Base class:**   * This uses the Template Method.    * Contains core logic/algorithm that calls virtual/abstract methods **Derived types:**   * These classes provides concrete implementation of the virtual/abstract methods expected by the Base. **Conditions:**   1. I have a virtual method (Run).    2. The default Run method uses another virtual method (Proc).   3. If a derived class uses the default Run behaviour, they must implement Proc.   4. If a derived class overrides the Run behaviour, then it shouldn't have to care about the existence of Proc, let alone overriding it. ![enter image description here](http://i.stack.imgur.com/fPlc6.png) I've considered making Run() abstract and let each derived class handle their own. But then I'll end up with duplicate code. ![enter image description here](http://i.stack.imgur.com/kJ5Gp.png) I'm using a simplified example here. In my actual project, I have several "Run"-typed virtual methods, each calling several "Proc"-typed methods. Because of that, I have a whole bunch of virtual "Proc" methods with "throw new NotImplementedException()" Creating a new derived type is also confusing, because the coder may not know which virtual methods must be implemented/can be ignored/etc. I've considered using a strategy pattern, but since I have several "Run" methods, each one of those would have to be a strategy, which seems like overkill/overengineering. ![enter image description here](http://i.stack.imgur.com/IWsqE.png) Is there any way to simplify this? * * * **[Update 1]** Here's an example that's closer to the kind of methods I'm working with ![enter image description here](http://i.stack.imgur.com/rsuoV.png) And imagine yet another method: ![enter image description here](http://i.stack.imgur.com/QXu3b.png)


What is the use of the prefix "for(;;);" in an Ajax response

After using the chrome debugger to inspect the ajax requests of Facebook (for curiosity), I noticed that the response is in JSON, however it is always prefixed with               for(;;);      In example, if the JSON were `{hello:"world"}`, then Facebook would respond               for(;;); {hello:"world"}      Does this have any use? I imagine it must have a purpose...


In C++, is it a reflection of poor software design if objects are deleted manually?

With the advent of smart pointers, is it a sign of poor design if I see objects are deleted? I'm seeing some software components in our product that people are still doing this. This practice strikes me as un-idiomatic, but I need to be sure this is the industry consensus. I'm not starting a crusade but it'd be nice to be prepared theory wise. **Edit** : legit uses of delete, Klaim mentioned the object pool use case. I agree. Bad examples of using delete, I am seeing many new's in constructor or start() and corresponding delete's in the destructor or stop(), why not use scoped_ptr? It makes the code cleaner.


Can I get sued over duplicating another program's UI?

If I see something I like in another application, and create something similar from the ground up in a commercial product, could I get sued over it? Of course it would be styled to look differently, however most of the functionality would be the same since the functionality is what I liked about it. It also would not be the entire system, just a part of one. I live in the US.


Resource/Thread Allocation and Deadlock

Here is the question I'm having trouble with: > Give the resource graph and determine whether a deadlock state results. > Assume that when a thread requests an available or unallocated resource, the > OS immediately allocates that resource to the thread.   * There are three threads: T1, T2, T3   * There are three resources: R1, R2, R3 Here is the sequence of events:   1. T1 requests R1   2. T1 requests R3   3. T2 requests R2   4. T2 requests R3   5. T3 requests R1" Now, I have written out the graph for the problem.   ![Allocation Question](http://i.stack.imgur.com/DeSE0.jpg) Have I drawn the graph appropriately? Based off of this graph, I assume there is no deadlock because there are no cycles. I am unsure if my solution is correct. Can anyone help clarify this? Thank you!


Writing a killer use case for a cron job

I'm a beginner when it comes to writing use cases, but I searched a lot and most of the materials I found mentioned that I should concentrate on the business value to the customer when writing a use case. example: Use case for a search page               1- User opens search page       2- User provides the search word     3- The system presents the search results      Of course it was easy to write the use case as the system had some kind of UI that that user interacted with. However, what if I'm writing a use case for a cron job? I was developing a module that basically connects to a number of ftp servers to download some files then the downloaded files are parsed to generate some reports and finally these reports are uploaded to my company's ftp server. The problem is the only business value for the whole module is the generation of the reports (i.e. The team who requested that module only cares about the reports not anything else). This is the use case I came up with:               1- The system downloads the files from the ftp servers.     2- The system generates the reports from the files.     3- The system uploads the reports to the company's ftp server.      However as I was reading Applying UML and Patterns, 3rd released edition the author introduced a monopoly game use case as follows: ![use case](http://i.stack.imgur.com/Ey1NZ.png) A whole game in just 3 steps!!! I thought since the whole purpose of the game is just the simulation then maybe that's why he didn't mention any details, and maybe I should do the same too. * * * So now I have exactly 3 mixed questions: 1- Should use cases focus entirely on the business value for the customer and ignore internal operations? 2- In case a cron job is invoked how to determine the business value if the customer has no interaction what so ever with the system? 3- A colleague of mine actually contradicted with my approach entirely and he insisted that I should write as much details as possible in a use case (as instead of `The system downloads the files from the ftp servers` it should be decomposed to the smaller functions that make this feature such as `get list of servers from DB`,`connect to ftp server`, `check if there are any files`, `download file`,`delete file from ftp server`,`close connection`). Is this correct or better?


Communication between resource and authorization server/identity manager?

## Short Doing the design / for an api we're building we noticed there is little to nothing to be found on how your resource server can validate a token given by a client with the authorizationserver/identity manager. ## Longer So in our system the resource server and identity manager are seperate systems (we call it the identity manager because we also implement an authentication layer there). I believe we have a pretty good grasp of what oAuth is/defines but in a lot of examples and essentially how we always implemented it in the past (mainly just experimenting) the authorization server and the resource server were the same. But in this setup we want to split that up. This to seperate the authentication/authorization from the actual API. That creates a problem, since there's little to nothing said in oAuth 2.0 about how to then validate a token with the authization server as far as we know. I made a diagram to illustrate the situation. ![oAuth seperate systems/communications, it's simplified, a lot is missing](http://i.stack.imgur.com/UbqRs.png) I am talking about the communication between **Identity Manager** and **Resource server** to validate the token. We have 2 proposed solutions to the problem, but are not sure what is acceptable.   1. We can make a call (https) over to the Identity Manager from the Resource Server to validate the token, and get authorization scope, cache that for the given lifetime.   2. We could also make a shared (Redis?) cache (only for the tokens) to which the Resource Server gets read only access. This would reduce overhead and we would be able to invalidate tokens from the Identity Manager by simply removing it it from the cache without having to notify the Resource server. We would limit access to this cache to only be able to get using a client/token combination, so no 'get all', if it's not set we assume the client is not authorized. The reason we want to do it this way is to seperate the responsibilities and over time be able to add different Resource Servers (APIs) while still keeping user management central to our organisation, tho currently it would only be a single api. **What would be a good way to tackle this problem?** One of our suggestions or something completely different? Does oAuth 2.0 say anything about this that I missed? **P.S.** I did find this post about the same problem, but that doesn't answer what might be a proper solution to this problem given the situation. I will keep looking until I find something I am not too unsure about and post the direction we take if this doesn't get answers :)


Descriptive naming vs. 80 character lines

I frequently hear these two valuable programming practices: (1) lines of code should be 80 characters or less and (2) use descriptive names for variables, methods, classes, etc. I understand the reasoning for both of these words of advice, however, they seem to often be tradeoffs of each other. If I keep my code below 80 chars/line I end up using less descriptive names (esp. in Python in which each indentation counts as 4 characters) but if I use more descriptive names, I end up with lines over 80 characters. So, my question is which of these two pieces of advice is more important to abide by if the choice must be made? I am wondering this as an independent (hobbyist) programmer, but more importantly from the perspective of a software engineer working for a larger company.


Should I release source code to fix bug

I have a bug in my application that I'm building. I asked a question on S.O. and one of the users asked me to post or send all the code to him so he could look at it. I totally understand the request. It is valid and understandable. However, I'm having doubts on if I should. Obviously, I give him/her the keys to the kingdom and I will not have any recourse if he/she would do something malicious. **I also want to add that I mean no-disrespect to the user on SO that offered their help. I'm just airing a concern.** I do want to have my bug fixed but there is no guarantee that this person would be able to fix it. Should I release the entire source code and hope for the best? Or keep it and try to figure it out on my own? What would you do?


Why are header files bad design?

this says header files are bad design, but I don't know why. The answers specified there are about the inefficiency of header file when building. Why it is _bad design_ is not really touched upon. As far as I know:   - headers lets you break the source file up so you can compile smaller things faster   - headers lets you separate the interface from the implementation   - headers lets you specify functionality in only one place. ie. no repeating Yet using includes, include guards, headers, etc. are considered bad design. How so? What are the alternatives? -- EDIT: re. DRY issues A common argument is that it violates DRY in that you repeat changes in signatures in both the .cpp and .h files. However, if the code is designed to reuse functionality specified in outside files, is it not unavoidable that header files must be used? The question asks why header files are bad design, yet without the headers, is modularity not lost? If modularity is lost, is that not itself a design issue? Thus using header files averts a separate design issue. Repeating in general is a bad idea, I get that, but it seems unavoidable if you require common functionality. In which case headers are bad, in terms of signature repetition. In terms of how you design your software, I'm inclined to say that splitting code up/modularizing, and reusing code means your code is designed well.


Starting Java Web Services and feeling lost

After building mainly Java desktop apps and some small GWT services, I'm trying to learn how to build Web Services in Java but I feel overwhelmed by the sheer amount of buzzwords, terms, specifications and technologies. Besides, I'm not able to find a comprehensive, yet correct source to learn. Is this normal when starting WS, and what are good books/resources?


Optimization algorithm, how to develop this problem

I have a situation where I would like your input and think over / solve algorithm. The specs > There are inventories with a specified amount of capacity.   >  'X (width) and Y (time)' creates together a total space. '60 * 100 = 6000'. > In reality "width" are a business value unit, but we can talk width here. > > Now there also are boxes, which take a part of the space.   >  Each box take width (X) and time (Y). Two boxes with 80 * 20 each, will > fill a inventory with 1600+1600. It will result a fill factor, 2800 space > left in the inventory, after the boxes are added. Each box always belong to > it's inventory. > > There exist unlimited, serial dependent, inventories with boxes added > individually. The former inventory have to be performed before next are > performed. > > Boxes themself have a attribute, like a color, which make a ownership in > higher context. Like a "give me all boxes of color -yellow-" context. I.e. > to find out which inventories contain that color. A box with same color can > exist several times, even in same inventory. But if in same inventory, they > have unique box-id's. The problem > There have to be added optimization strategy which make width (X) > adjustable. Time (Y) is still fixed and can't change. The optimization rule > is that available space in former inventory should be filled with a > part/slice from second inventory. > > Time must fit. I.e. 2x15 or 1x25 can fit to 1x30. 1x35 can't fit. Also the > width added to former, must be reduced from second. Remember that a box > isn't allowed to be removed from it's inventory (but width can be 1 as > minimum). Though, on adjustment, new boxes have to be created in the former > inventory.   > It's a mathematical theory but i mainly want to transform a algorithm of this kind, into code. Or give the question a glance of what kind of theories to look for. Perhaps this is a common problem? or too complex considered as "re- invent the wheel" and recommend to buy a third party module. [Edit] 'length' changed to 'width'   Added a graphic to better illustrate how the optimization rule will apply. ![enter image description here](http://i.stack.imgur.com/QMmSL.gif) There are a little green piece remaind at right, after optimization, because of the "at least 1 width must remain"-rule. The red and blue did not fit fully.


Difference between Software Engineering and IT?

I see mostly everyone distinguishes between being a Software Engineer and being in IT on the jobs sections of their site. What is the distinction?


What am I supposed to take away from the term Routed Events?

I use events all the time, I cheat and use autocomplete in Visual Studio. Object.closing += [tab] button. Put something in the autogenerated function. Some people like to emphasize the "routed" nature of it, and that leads me to believe I'm missing something. Is there more to it? What am I supposed to know about routed events?


Difference Between Software Development and Production?

**In a typical SDLC** there isn't much mention of the word production or development or the distinction between the two.These seem more of a real time , industrial driven concepts . I have come across these terms in regards describing companies. ![enter image description here](http://i.stack.imgur.com/BCwJy.jpg) As i understand Production in Software does not necessarily mean product development.Inspired from the question Why do we call it “production”? I came to question the basic distinction between the two i.e **development and production in regards to software**. I used to be under the impression it was just a way of describing the development process in a product development company.   * **Question 1: What is the distinction between the two?**   * **Question 2: How widely are these terms used? and are they properly understood and distinguished ?**


Collecting and sweeping of session-dependent uploads

I develop a Java web application with an upload-feature. The upload is devided into two parts:   * During a user-session the user can upload files at any time while navigating through the whole site.   * All uploads of a single user during a session will be collected on the server. Moreover the files of each user are stored into different directories, that is each named with the session-id of user.   * Only when the user commits this uploads explicitly all uploaded files of his directory will be transfered to a target. (The explicit commit is needed because it is a long running threaded action on a legacy-system).   * If the user doesn't commit the uploaded files, the temporary-directory of the user will be deleted at logout. Now the essential part of my question: If the user closes his browser the files won't be deleted, because I don’t get an event. To workaround this situation I clean up all temporary directories by a scheduled task in this way:   * Get all directorynames (the session-id)   * Lookup each directoryname respectively session-id in a collection of active sessions.   * If the session is found, keep the directory, otherwise delete the directory. Now I'm in doubt if it is a security risk to use the session-id for naming the directory. Sure it's easy to lookup and cleanup, but I haven't found another way to link a directory to a concrete session. Do you have a clever and easy solution to handle upload into a user specific directory and especially deleting directories of lost users? Or is there another way to tell the cleanup task which directories are obsolete?


What's a technical way to describe removed functionality in a software application or framework?

I'm not trained programmer, so be gentle with my ignorance. I'm trying to search changelog files for where an open source project dropped a feature I need. I was just wondering if there may be a good set of terms to describe this. Bugzilla has detailed bug reporting forms. Are design changes also logged using rigorous language? Its something I can see myself advocating as my own small contribution. (^_^)


How to generate nonce for Ajax web requests

As many of you know WordPress uses "secret key" like thing for every AJAX request. Making each request unique and also 'somewhat' secure (just a step ahead than nothing). How would I implement the same using PageMethods (webservice methods inside aspx page) in asp.net application. Some things I have already taken care of are authentication and authorization to access the page. I would like to know How to generate the same nonce/secret key whatever in C# for asp.net application? Also doesn't this affect the performance of the application like 100 thousand users use it and each time the method has to go through encryption, random number generation etc..? Is there any way I can check if posted data is what was actually posted. Checking the integrity of posted data? Do you need to follow design patterns to secure application logic? Does one exist to make your application at the least somewhat secure?


I made an HTML5/Javascript game. Do I have to license it?

So I created an HTML5/Javascript online game. I host it on my website for anyone to play for free. I am still currently working on it. Do I need to license my game? And if so, what license do you recommend? I was looking at some open source licenses like GPLv3, but i'm not sure if I even need a license? **If I need a license** , I need one that allows:   * my game to be totally free **to play**   * my game to be embedded on other websites   * no one else can re-distribute my game, unless it is under my name and not theirs Also, if I need a license, where do I include it? Do I just have to state somewhere that the game is licensed under "xxxxx license"? Or do I have to include a link to the license file hosted on my server? OR even include the license file in my game (i.e. in the games javascript file, or under a game menu, etc.)?


should I throw exception from constructor?

I know I can throw exception from constructor in PHP but should I do it? For example, if a parameter's value is not as I expected it. Or should I defer throwing an exception till a method is invoked. What are advantages and disadvantages in both cases?


Web Routing Standards

We are putting together an API to provide our vendors some simplistic direct access. I've built APIs before, and have always routed them as such:               {controller}/{action}/{id}      My boss, however doesn't think that's intuitive. He thinks we should route our API like this:               {controller}/{id}/{action}      His reasoning is this: "For object number 7, get it" or "For object number 15, save it." He thinks it makes more sense that way and that out vendors will understand it better that way. For me, it's about starting with the most detail then drilling down: "I'm dealing with an object, I need to save it, save it with id 15" I'm trying to build an argument for keeping it standard, and the "Everyone else does it this way and we are just going to confuse people" argument doesn't seem to be effective. His response is, "We've never had an API before, so it will be OK for our customers to use it this way." I would like to find some stronger arguments, backed up by white papers if I can find them, but I am coming up blank. What arguments would you use, and are there any whitepapers you could point me towards?


Drawback of implementing DDD service as static class?

Can Services in a domain-driven design be implemented as C# static class? What are the drawbacks of this choice? Can it be implemented as a non-singleton non-static class?