instruction
stringlengths
34
19.9k
I'm having a hard time understanding the difference between an emulation virtual machine and a language vm. I started with the research and implementation of an emulation virtual machine. Primarily emulating quite old 16-bit architectures. I want to get the basics down for a language virtual machine. Are both systems ...
I'm a bit confused about the difference between nominal and structural type systems. Can someone please explain how they differ? From what I understand: Nominal: Type compatibility is based on type name. Structural: Type compatibility is based on the type structure, e.g. in C if 2 variables are struct types with diffe...
I would like to experiment with threads on a multi-core processor, e.g. to create a program that uses two different threads that are executed by two different processor cores. However, it is not clear to me at which level the threads get allocated to the different cores. I can imagine the following scenarios (depending...
Should every piece of code put online have a licence with it, or should it explicitly mentioned that it is in the public domain? I'm writing a simple python script that will take a project euler problem number and save a file with the question text as comment. As I was creating the directory and initializing git I adde...
I've read a couple of articles (example) that consider the classic for (int ...... size() .... i++) loop bad practice when iterating through for example vectors in stl. Instead the recommended why is to use vector iterators, i.e. begin, end, etc. Why is that?
After watching this talk on REST, Reuse and Serendipity by Steve Vinoski, I wonder if there are business cases in greenfield projects for (XML-)RPC-ish setups, that REST could not solve in a better way. A few RPC-Problems he mentions: Focus on language (fit the distributed system to the language, not the other way aro...
Despite increases in screen size and resolution, many sources still suggest that code be limited to 80 characters per line. I realize than there are many different opinions on this subject, but I wonder whether there are any standards bodies or influential firms that use other limits (120 characters is a common alterna...
I have a couple of exam questions for my compilers class and wanted to check if my solutions are correct. The first question is: Consider a language in which numbers start with an optional minus sign, followed by one or more decimal digits, followed by an optional decimal point. If the number contains a decimal po...
I have the following question taken from a compilers course exam: Show that the following grammar is ambiguous. S = XcY X = a Y = b | Z Z = bW W = d | ϵ I drew the following tree: Am I correct in thinking it is ambiguous because acY can end up at acb (one of which is followed by an epslion) following different paths...
I've just had to switch out an ORM and it was a relatively daunting task, because the query logic was leaking everywhere. If i'd ever had to develop a new application, my personal preference would be to encapsulate all query logic (using an ORM) to futureproof it for change. Repository pattern is quite troublesome to c...
How do you evaluate arbitrary math expressions using temporary variables instead of a stack? What I'm talking about is translating an expression into an array of simple operations- each that change one variable based on the second argument. An example list of operations might be: = += -= *= /= Notice how each operati...
Consider an existing project that is dual-licensed GPL + either MIT or BSD. Since it's dual-licensed, when I fork, can I pick one license in the fork? Or do my forked files need to continue to be dual-licensed? It sure would be simpler to track only one license.
I read the hardware requirements of WCF in a book and two of them are the following ones: A DVD-ROM drive A 1024 × 768 or higher resolution display with 256 colors or more Why is there a requirement for the screen resolution, or to have a DVD drive? Perhaps, this requirement is necessary for Visual Studio to work. A...
I find that the encapsulation required by OO has me frequently passing paramenters down the line from parent to child to great grandchild to second grand nephew once removed (not actually that bad). But inevitably in the process, and especially if graphics are involved there will be garbling the by the third iteration ...
I've read about Template Method Pattern but I'm not sure about one thing. The steps (methods) of an algorithm are supposed to be in the template method. In the case my template method's algorithm is about 2 completely different tasks that I would like all my objects to perform, let's say the one is drawing and the othe...
Why does the compiler store constant values in the assembly metadata? Are they directly embedded to Intermediate Language code from the assembly metadata?
I need something that represents a queue in F#. The queue will be filled with items once, and (as the application progresses) items will be taken from this queue and moved to other lists. Should I use the Queue class in .NET, or should I avoid it, and use the native lists in F# instead? Is there a better solution? Why ...
In my team we have been working on a firmware for a product. The product was released some years ago but we still implement new features in the firmware and regularly provide a new firmware for our customers. Recently we have developed a new product which use the same firmware as the first one. Of course, we had to cha...
Imagine a scenario as follows: Lets say you have a central computer which generates a lot of data. This data must go through some processing, which unfortunately takes longer than to generate. In order for the processing to catch up with real time, we plug in more slave computers. Further, we must take into account the...
CodeIgniter has a very nice feature called a Profiler, which displays information at the foot of a page, information such as GET, Memory, POST data. It also shows database queries and how long they took to run which I find very useful. I have recently taken over a legacy PHP application and it would help a lot to see w...
I had recently read a paper 'Aspect-Oriented Programming' by Gregor Kiczales and others, and found there the loop fusion example. Here is a definition of the loop fusion from the paper …the loop fusion composes by fusing the loops of those primitive filters that have the same loop structure and that are direct neighbo...
The problem occurs while doing TDD. After a couple of test pass, the return types of some class/module change. In a statically typed programming language, if a previous mocked object was used in the tests of some other class and was not modified to reflect the type change, then compilation errors will occur. For dynami...
I have a product with two separate applications. The core of the product lives in the database (oracle) and runs according to a schedule. The other is a client application (currently ASP.NET MVC3) used to manage the database application. There are three levels of validation going on; client, server-side, and database...
I have an MIT-licensed project that used to include a GPL JavaScript library which has since been removed. Is there any legal necessity to rewrite the revision history to completely remove this code?
I need to find the time complexity in terms of Big Oh notation for the following program which computes the factorial of a given number: The program goes like this: public int fact(int n){ if (n <=1) return 1; else return n * fact (n-1); } I know that the above program uses recursion but how to derive the t...
In designing an API that provides an event listening interface, it seems there are two conflicting ways of treating calls to add/remove listeners: Multiple calls to addListener will only add a single listener (like adding it to a set); can be removed with a single call to removeListener. Multiple calls to addListene...
I am working on debugging my mobile application. There is a specific requirement/issue that I am having related to a drag and drop touch interface on an iPad. I am at the trial and error phase of trying to figure out how to fix this (meaning I have no idea how to fix the issue I'm seeing). The only way I have been ...
I am building a tutoring application that can be used to draw objects and then one is able to drag them around. I would like to know what is the best thing to do when someone clicks on an object and starts to drag it. I was told I should "lock" it - prevent it from being grabbed by someone else at the same time and bei...
So I have a javascript program that currently gets random points, it generates a random x,y,z value around the center point, within the radius r var maxArms = 3; var i = 0; var color = []; for(var arm = 0; arm <= maxArms; arm++) { var perArm = (numStars/maxArms); var perPoint = Math.ceil((r/10)/5); ...
I am eager to know what information is checked by the online companies to confirm that the card is yours? If a programmer has to implement this functionality, how can he access information like address of the client which is not written on the debit card? Thanks
I've recently been hired for a project that involves working with and around several third-party "enterprise" systems. Due to what I imagine would be the astronomical cost and effort required to build a sufficiently faithful replica of the production environment, the prospect of having a real development environment se...
Recently I've found myself chafing at the limitations of document indexing engines. I was developing a small website that needed some fairly robust searching capabilities but due to their hardware constraints I couldn't deploy a Lucene-ish solution (such as Solr or ElasticSearch, like I normally would) to handle this n...
This subject is long time in the making for me and it particularly took off when I was researching bootloaders for computers and consumer electronics, which, I will note, differ drastically. I've learned how ancient and inflexible x86 hardware is and just how much the structure of software is constrained by it. Example...
If an OSS project is not backed (for example, by the Apache Foundation), how is the OSS license upheld? My specific scenario is this: if I create an GPLd mobile application with a non-commercial transformations clause, what's to actually stop someone from re-releasing it as "Pro" and charging for it? I assume the owner...
So my question is this: Is there any easy way for a single developer to release an app on iOS and Android? I am a web developer that primarily plays in PHP, Node, Ruby, AS, and JS. I have dabbled a tiny, tiny bit in Objective-C and Java. Basically I am looking for a good way to release a fairly simple app on both Andro...
Is there a more common name for a "Blittable" data type? In my software there is a distinction between a variable sized structure and a fixed size structure that has a similar behavior to "blittable" but I have only seen the name used in Microsoft software.
I'm trying to lead a charge for re factoring our rather bloated controllers. We currently have a BaseModel from which all our other models inherit. The BaseModel contains things common to all pages, such as the page title, css files needed, current user. Each constructor has a private method to construct a particular V...
I have been programming for about a year and I am really interested in data analysis and machine learning. I am taking part in a couple of online courses and am reading a couple of books. Everything I am doing uses either R or Python and I am looking for suggestions on whether or not I should concentrate on one langua...
I've been reading about Developer (or Programmer) Anarchy, which seems to be billed as a post-Agile development methodology. I found a few resources on it (1, 2) but it doesn't seem to be a lot out there. I was wondering if anyone had any good resources where I could find out more about it _ how to implement it, pros...
A colleague and I have run a Kanban board at 2 places of work now, introducing a kind of scrum-ban agile/lean process into the team. Helping us move towards more flow orientated work and continuous releases. I just wanted to ask your advice, that when a task is peer tested or tested by the test team further down the bo...
Assume we have a method that validates an object before saving it to a DB. It returns back KVP something like: public KeyValuePair<bool, List<FooErrorReason>> ValidateABar(Bar b) { var reasons = new List<FooErrorReason>(); if (string.IsNullOrEmpty(bar.Name)) { reasons.Add(new FooErrorReason { PropN...
I have an exam question that I am unsure of the answer. The question is: In organisation X valid user names have the following structure. The user name can be either the employee’s name followed by a colon and then the department name or a string of one or more alphanumeric letters consisting of lower case, uppe...
I'm very new to python and (coming from Java) am trying to think in a "pythonic" way. I'm having trouble understanding how Django turns a function (or variable) name given in string to the actual function. Example from Django tutorial: If we give: list_display = ('question', 'pub_date', 'was_published_recently') Dja...
I am currently designing a web/mobile application the bulk of whose users will be distributed across the different U.S. time zones with a potential of scaling up to other countries and time zones as well I have worked with several other globally used apps and noticed they all used datetime to record timestamps with the...
Assume there is an HTTP server which accepts connections and then it has somehow wait for headers to be fully sent in. I wonder what is the most common way of implementing it and what are the rest pros and cons. I can only think of these: Many blocking workers are good because: It is more responsive. Easier to introdu...
In .NET Framework, localized strings are located in an XML file (or multiple files). Those files are part of the project and are committed to the source control as any other source code file. Usually, Visual Studio is used to display those files as a table and edit the localized strings. I work in a small team on a pro...
I have a simple C++ RPC that lets you have remote class instances that support live members (data structures) update as well as method calls. For example I had a class declared like this (pseudocode): class Sum{ public: RPC_FIELD(int lastSum); RPC_METHOD(int summ(int a, int b)) { lastSum = a + b; ...
My company uses a mix of onsite and increasingly offsite contractors for development of websites and online applications. Our platform uses a mix of open source software and libraries that we've made a number of modifications to over the years. Some of the modified software is licensed GPLv2 without the linking except...
I've seen it stated several times that AOT can run some more expensive optimizations that take too long to be used by a JIT. But I've never seen it stated what exactly these optimizations are. So I'm wondering, what are these optimizations?
The General Question What are the differences between algorithms using data structures and algorithms using databases? Some Context This is a question that has been bugging me for some time, and I have not been able to come up with a convincing answer for it. Currently, I am working on strengthening my understanding ...
Why is it that when I try to make an array of ArrayLists: ArrayList<Integer>[] arr=new ArrayList<Integer>[40]; there is an error and java does not allow this? Is there a reason related to java's implementation of generics, generics in any language, or something arbitrary?
The wikipedia articles are too advanced for me to understand, could someone give me a simple explanation please?
Background I have a business question regarding web-based software licensing. A number of web sites offer software as a service for various APIs. A good example is Google's Custom Search API. The process to use web services typically resembles: Account. User creates an account. Server. User defines the IP address(es) ...
I gave up on programming a little over a year ago when I kept hitting this wall. I am revisiting the subject because I want to create basic Android application. But I feel that my limited knowledge will not suffice. Here is my problem. I have read a few books and watched video tutorials on C#/Java, followed examples, ...
ROM - Read Only Memory Does this term mean the memory which should only be read and not written to , or the memory which can only be read ? "ROM in PC's and laptops are usually seperate chips in the motherboard where BIOS is present (Please correct me if I am wrong) . Can they be overwritten (I guess we can) ? When we ...
During a recent code review I was asked to put default cases in all the files wherever switch block is used, even if there is nothing to do in default. That means I have to put the default case and write nothing in it. Is this the right thing to do? What purpose would it serve?
I've basically stared to do the following when creating a REST service: HTML is requested service returns the desired web page but without the requested "resource", eg. data web page contains JavaScript that issues AJAX request to the same service (different content-type) service then returns the actual data (JSON) an...
Could Ruby on Rails have been created in another language like PHP, or are there some functions in the Ruby language that make the difference?
We're trying to move our project documentation process from Google Documents to a set of self-hosted Git repositories. Text documents are Git-friendly enough, since we usually do not need any fancy formatting, we'll just convert everything to, say, multimarkdown with an option to embed LaTeX for complex cases. But spre...
I'm to write an event correlator module for the device we produce. When a fault occurs the resulting avalanche of logs about derivative conditions from various modules is readable only to a person skilled in the task - a layman will be utterly lost. The event correlator is supposed to solve this problem - find root cau...
Lately there have been some kind of revolution against singletons, but is there something wrong with them if they are stateless? I know the overuse talk and all... this applies to everything not just singletons.
I want to apologize in advance if my headline is not specific enough, but I think this is a general question, although I have a very concrete example: In my team we maintain a test specification which we use every time we release software. The specification is written in Word and, as a consequence, we occasionally have...
I presume it's that way so it could be extended with custom algorithms, but wouldn't it be more convenient to apply, let's say, factory method pattern here and avoid the whole NoSuchAlgorithmException thing? Something like: MessageDigest.getMD5Algorithm(); or MessageDigest.getInstance(DigestAlgorithmFactory.getMD5Al...
I have just started reading C++, and I came across a term "Null Terminated String", I read about it but couldn't understand what it actually stands for. I also want to know what is the difference between a c-string(also referred as "Null terminated String") and a c++ string.
Let's say I have a product that has different features, or different feature access depending on things (i.e Premium User, Beta, Demo, Logged-in User, etc..). What's the best way to organize a system to where it's not a set of static checks (i.e a bunch of if statements, for example)? The platform isn't important, I'm ...
How to represent rules for a rule engine as objects? A rule would be if (booleanExpression(input)) then a chain of generic actions" else next rule ...where the generic actions might be e.g. passing the input to a different chain of rules, returning a conclusion (terminating analysis with result), or gathering additi...
gdb implemented support for reverse debugging in 2009 (with gdb 7.0). I never heard about it until 2012. Now I find it extremely useful for certain types of debugging problems. I wished that I heard of it before. Correct me if I'm wrong but my impression is that the technique is still rarely used and most people don't ...
I'm trying to do research on these css preprocessors. Are there any advantages of using sass over less as a css preprocessor? Factors that i'm looking for include community size, software project maturity, etc. I know there was another question related to this, but it was not constructively written and closed. Update L...
I have a print operation to perform for my customer documents. I need the other standard operations to be performed as well, like add,update, delete. so, I have following: For creating new customer:URI = /customer/{id}, type = POST, Methodname = CreateCustomer() For updating:URI: /customer/{id}, type = PUT, method = ...
Edit *We have a heart monitor hooked up to to an msp430 with a roving networks wifi module. I would like to connect send some type of a datastream to a webserver so that someone could watch it offsite. I would like to have a datastreaming connection or something to the webserver because I was thinking it is more natura...
In some javascript code I'm working on refactoring I've handled cases where I wanted to default an object property to true without having to go through the code-base and add the property to every instance of the object by doing something like this: if(typeof(thisBool) === 'undefined' || thisBool) { //do cool stuff ...
This question branches out of this question, What are the differences between algorithms using data structures and algorithms using databases?. The General Question Should a database table(s) structure match its intended data structure(s) in the logic? Some Context The simplest example (and it may be oversimplified) of...
The Two Projects I work at a pretty small software company, and I'm currently in a situation where I'm at the end of development for "Project A", about to start development for "Project B". Project B is supposed to be an "extension" of Project A (both are primarily web apps). In Project B, the plan is to not only add b...
I often hear people say that C++ programmers should expose their library's/product's public API as a C API. What does that mean and what are the advantages of that?
Where I work I see lots of classes that do things like this: public class ClassThatCallsItsOwnGettersAndSetters { private String field; public String getField() { return field; } public void setField(String field) { this.field = field; } public void methodWithLogic() { ...
Theoretically, if I were to build a program that allocated all the unused memory on a system, and continued to request more and more memory as other applications released memory that they no longer need, would it be possible to read recently released memory from another applications? Or is this somehow protected by mod...
I am interviewing for a PL/SQL position with a large corporation. I will have to write a multiple choice exam. I am wondering whether the exam will likely use old-style joins (joining happens in the 'WHERE' clause) or ANSI ones. My apologies if this is not the correct forum for this question.
I'm trying to really master Haskell error handling, and I've gotten to the point where I don't understand why I would use Control.Exception instead of Control.Monad.Error. The way I can see it, I can catch Control.Monad.Error exceptions in both pure and impure contexts. By contrast, exceptions defined in Control.Excep...
I have written an extensible c++ wrapper around a very hard to use but also very useful c library. The goal is to have the convience of c++ for allocating the object, exposing its properties, deallocating the object, copy semantics etc... The problem is this: sometimes the c library wants the underlying object (a point...
Consider someone is writing a message (or a question at StackOverflow). The context is following: In my code, I have the following line: int foo = Bar(); However, the compiler returns an error: line 42: Bar() is unknown function I'm puzzled to choose a proper verb instead of "returns". I've seen people using various ...
I need to write a web application that acts as a configuration interface for some system services. Meaning it will probably change some kind of configuration file and has to restart (linux) system services. I was wondering how to design such a thing in a secure way. It is very similar to router web interfaces and such,...
I am building a tutoring application that multiple students can sign into the same session with a tutor. My question is, for example, if I sent out a command to draw a line, do I need to wait to see that all connected students propagated the command. Now, it relies that requests will be processed in order. But consid...
When I read about frontends, it always mentiones webpages. Can it be used in different contexts, e.g. desktop applications?
I'm a bit surprised by a sentence found in the book "Clojure Programming" (1st [and only as I write this!?] edition), page 78: It should be obvious that it's impossible to deterministically test a function that depends upon a random number generator Well, to me it's not obvious at all. First in the context the book...
I am frequently tempted to wrap integers, etc, solely for the purpose of writing methods that can return null. Negative 1 can work in many cases, but too often (especially in sound) it's a valid return value. Often, to get around this, I am returning a reference to a larger object that contains the primitive in questio...
I would like the answer to explain what impact, if any, does the type of company/industry have on the rigor, depth and breadth with which software engineering is practiced. The best would be some links to support the answer with references. As a control point, let's declare an assumption that a company which follows t...
I've been learning SQL recently and practicing with MySQL/Postgres and soon Oracle DB. I've also search the web for a 'road map' study of databases but couldn't find one, unfortunately. I want to understand where and why particular database concepts fall on the scale from beginner to intermediate and advanced. I'm thi...
Our team is going to adopt scrum and agile technics. We've got a product, which we develop for multiple customers. This customers supplied us with necessary requirements, so everithing is fine to adopt agile techinics. But at some moment (for example during sprint), new customer apears, and he wants to get a demo of pr...
I have a method which has external dependencies within the method. Please help me in writing a junit test case for the below program. @Override public void methodToTest(String user){ //fetch the values from the properties file. Config class has a static method called //getProperty which reads the v...
If 2 classes have the following in common: part of how their state is represented (both have a linear container) multiple identical methods (identical code, not just signature) But are not substitutable, ie: they play different roles. Then how do I avoid repeating those methods? The obvious solution would be inherita...
In JSF if I have a component that conditionally renders based on a number of variables what is the optimal way to handle the render statement... should the logic live in the component declaration or in some form of helper class? The text woof is only displayed when an animal is an elephant or dog and the animal is not ...
Can python be efficiently implemented in big data field? To be precise I am building an web app that analyses really big data in medical health care field consisting of medical history and huge personal information. I need some advice on how to handle very big data in python efficiently and with high performance. Also ...
How does the Law of Demeter applied to object-oriented systems with coupling and cohesion? I was reading a book "Software development and professional practice" and came across the chapter about LoD, and was curious about how that principle is applied into object oriented systems.
I have some confusion regarding the use of static variables/references in a class. It feels like I may not have entirely figured out the implications of keeping something static. When I say a variable is public static, is it one instance of the variable per class or one instance per assembly? For example, I have a user...
Context: Finding company to do the job The use case of an application I want to write is that a user will describe a task to be performed by some company, e.g., I want to move 10 boxes (30x40x50cm) of books and clothes from London to Bristol next week. How much would that cost? and the application will find candida...
I'm building a little framework, currently it is just for fun. I'm wondering how should I implement classes that should be instantiated by the framework and be passed to the controller to use? For instance: I have an "input" class that houses functions which take POST and GET data and filter it. The class is also used...
After you have done a good normalization, do you still need to index the table? How is this going to affect the performance? Will it even affect the performance in some way after a good normalization? Which columns are usually indexed if you already have the primary key and the foreign key? It's seems like it's alread...
I want to implement a security system into my web-based Intranet application which allows security administrators to 'fine-tune' exactly what type of access a user/role has to an object. For example, an ACL-based solution might allow a receptionist access to Create, Read and Update an appointment but not Delete it, sim...
I think this article, A Successful Git Branching Model, is very well known among experienced DVCS users. I use hg mostly, but I would argue this discussion is fine for any DVCS. Our current workflow is each developer clones the master repo. We write code on our own local repo, runs tests, and if all goes well pushes t...
I am trying to find best way to validate a mobile number with in a country. Currently my understanding is: User can enter whatever format they want in mobile numbers and its a waste of time and energy to validate it against a set of regular expressions. My application is not a critical one like banking application and ...