instruction
stringlengths
34
19.9k
I'm writing an optimizer for a language similar to JavaScript, and need to choose an intermediate code representation. The obvious/typical choice these days is Static Single Assignment (SSA). However, Modern Compiler Implementation in C also discusses functional intermediate form, which basically means going pure funct...
The C standard states that if an attempt is made to change a const type,the result is implementation defined.This gives error on my system,but what does it depend on(compiler,os)? What are the possible results(implementation defined) on various machines?
Currently, I am using Android/Java. I am looking for the most efficient means to determine the average of the highest 100 pixel values taken from a greyscale preview. The preview part I am more or less okay with; however, it determining which sorting methodology is the most efficient. The other option is to apply a t...
Well, actually it's a assignment project and I've already implemented a simple yet functional forum with NodeJS. But now we've been required to use ORM frameworks to refactor part of your code worth refactoring. As I use Node.JS, there's no such type-safe benefits from ORM I could get. Besides, the code is already func...
The C Programming Language by Ritchie says that: The library routine sqrt expects a double type and will produce nonsense if inadvertently handled something else. So if n is an integer, we can use sqrt((double) n) to convert the value of n to double. But the following code works fine on my system: printf("%f",sqrt(9)...
I'm creating the design for a browser bookmark merging program and I've ran into a design problem that I've seen before yet I've never come up with a good solution for it. So lets say I have a Browser class: Browser: String bookmarkFilePath String type Bool bookmarkFileExists() When my program runs I will want ...
I'm adding copyright notices to all my source code files: Copyright (C) 2013 My-First-Name My-Surname But what if someone else is also named My-First-Name My-Surname? What does courts think about that? How would they know who is the real author? Is there something I can/should do about this situation? (So they'd know...
To be specific, I want to know which function/types in libpri and being used in the Asterisk project. I'm not traditionally a C programmer, but I know some basic stuff because I took a class in college.
Can anyone give an example of instances in which the AF_UNIX i.e unix domain sockets are used for process communication in a unix-based system
I need a little help understanding the implementation of radix exchange sort algorithm. Radix exchange (I don't know if it's the exact name in english based literature) is a lot similar to quicksort, but uses binary representation of numbers. Firts we look the highest digit in binary representation, and then using two ...
I'm writing a lexer in JavaScript. It's pretty typical - rules are specified with regular expressions and produce a token. I am unsure of the best way to handle when multiple rules are matched. The existing lexers I've looked at handle this by picking the rule with the longest match. It also seems like a viable strateg...
Say I have a model written in php whose properties are the columns of a table in a db and each instance of the model represents a row in the table. I also have a page ('view') where I display the contents of each column one row at a time, starting with the first row (id=1). Above this display are two buttons, one which...
Reading the Go language specs, I read in the intro: "The grammar is compact and regular, allowing for easy analysis by automatic tools such as integrated development environments." Is the word "regular" here a technical term, or should it be interpreted just as a vague English word?
I'm reading the Go language specification. The section on comments states: Line comments start with the character sequence // and stop at the end of the line. A line comment acts like a newline. What is the point of specifying that a line comment acts like a newline? Couldn't line comments simply act like empty strin...
For some time now our Scrum teams have experienced recurring impediments caused by external factors to the team. The teams have discussed the impediments in their retrospectives and also brought it up on "Scrum of Scrums". It seems that the impediments may require involvement by management as it requires some rather si...
I have searched around for a way to run a program meant for ARM processors on an Intel computer, but I can only find ways to do the reverse, to compile Intel programs for ARM. Are there any open-source cross-compilers that will allow me to do so? Thanks for your help.
Lest's say I have user stories about using product catalog in shop: As an administrator I can add/modify/delete catalog items (one or more user story, doesn't matter here) As a customer I can search product catalog As a customer I can view product details Each of this stories rely on predecessor: design and create d...
The source code I'm working on at the moment performs numeric calculations between a bunch of different properties belonging to different data models. All the calculations are coded in a big method with a lot of If statements than make it very complex, difficult to change and it contains some bugs. I have not found a ...
My program should perform following task: It listen on http port after getting request it does following things. Connect to gearman Parse gearman payload to JSON (Upto 100 bytes) Connect to Redis Parse redis payload to JSON (256 bytes to 10KB. 80% cases it will ~256 bytes) Put some data in MySQL Put data in Redis...
Similar question here (but not the same) because I am interested in which specific algorithms work particularly well in Lisp. Lisp tutorials always give the example of finding factorials, but wanting to find factorials is not a good enough motivation to use Lisp. I've heard that Quicksort has a particularly elegant imp...
I am completely new to designing algorithms with graphs. I am following CLRS and other video lectures in Youtube, notably from IIT/MIT. They are pretty good, and I currently have decent idea about graph data structures, search, spanning-tree, etc. However, I am completely clueless as to how to identify a coding problem...
I've got an existing SQL table structure that looks like this: Orders - order_id - organisation_id - [all the rest of the order data] Organisations - organisation_id - [all the rest of the organisation data] Users - user ID - [all the rest of the user data] I'm trying to change the Orders table so that an Order can ...
I have been trying to understand the DOM, and although I have a fair idea of what it is, there are certain ideas I just cannot pin down. I will list down what I think the DOM is and my questions will be inline. The DOM is a fully object-oriented representation of the web page. The W3C DOM standard forms the basis of ...
As I have been taught - one controller = one use case. But I have: OutsiderController SupplierController (which extends OutsiderController) SubContractorController (which also extentds OutsiderController) And I want to do the SSD for SupplierController and SubContractorController. What do I do? Do I write in both SSD...
Initial situation: We are developing a software platform where products can be generated by configuring different components and adding additional ones. The platform is developed several years by a little developer team. Now the platform is more and more used, we get new developers as well as testers. We are currently ...
I work for a company that has bought a licence for a windows client software that allows only 20 running clients per company. I am trying to find a way around this 20 user restriction by programming a PHP web front end that connects to the existing database. This will allow unlimited users to access the database. The ...
The development team I'm in has been working on a VERY large project for months now and we recently started to implement a kanban board with agile practices into our process. We have seen MASSIVE improvement in our throughput! Its so exciting! But we have one struggle right now. We have a total ticket count for the pro...
When rolling out a new feature, sometimes it makes sense to notify the end user what it is, and give them an opportunity to provide feedback whether the software should get them to 'try something new' or 'put it off'. In a cloud software, how should user preference data such as this be managed? A small piece of inform...
I am more of a high-level wheel reinventor. I definitely prefer to make use of existing API features built into a language and popular third-party frameworks that I know can solve the problem, however when I have a particular problem that I feel capable of solving within a reasonable time I am very reluctant to find s...
Is there a best practice for calling language-native functions when writing testable code? I have experimented a little with php code and have come up with two methodologies: create a wrapper class for all native functions and mocking this wrapper when writing tests using "namespace magic": calling all native function...
I ask because so many of the questions I see in SQL amount to: "This is slow. How do I speed it up"? Or are tutorials stating "Do this this way and not that way as it's faster". It seems to me that a large part of SQL is knowing just how an expression would be performed and from that knowledge chosing expression styles...
I work as a solo developer in a small company. There's more than enough work, but the same does not apply for money. Thus, I won't be seeing any new colleagues in the near future. I am responsible for absolutely everything that has do to with IT operations. This involves development and maintenance of software used in-...
How can I convert this requirement into one requirement: For columns where there are just numbers, numeric sorting will be used. For columns that have numbers and letters, alpha-numeric sorting will be used. For Date columns, time sorting will be used. All sorting will have ascending and descending properties.
We are doing agile software development, basically following Scrum. We are trying to do sprint reviews but finding it difficult. Our software is doing a lot of data processing and the stories often are about changing various rules around this. What are some options for demoing the changes that occurred in the sprint...
I have the following (in C#, but the question could also apply to Java): public interface ILibraryAdapter { string Property1 { get; } string Method1(string param1); ... } public class ThirdPartyLibrary : ILibraryAdapter { private readonly ThirdPartyClass thirdPartyClass; private readonly ILog log; ...
I have a very very limited understanding of SQL and PHP. I have a few projects I want to try and work on, which will require doing some web scraping for data collection and then storing, sorting through, and analyzing the data. I would like to also have this data available on my website so others can sort through it as...
Starting with #Delphi #XE2 many of the new RTL units related to Vcl styles, OSX and so on, uses inc files to declare types, classes and implement code (just like the FPC does), what is the justification to do that? you can see what i mean if you inspect one of these folders (source\rtl\posix, source\rtl\posix\osx, sour...
I am torn between object oriented and vector based design. I love the abilities, structure and safety that objects give to the whole architecture. But at the same time, speed is very important to me, and having simple float variables in an array really helps in vector based languages/ libraries like Matlab or numpy in ...
I am trying to write a Java application that works similar to MapReduce. There is a server and several workers. Workers may come and go as they please and the membership to the group has a soft-state. To become a part of the group, the worker must send a UDP datagram to the server, but to continue to be part of the gro...
I'm building an Online Food Ordering System with PHP and MYSQL, One of the feature of the application is to allow users to search for the restaurants by typing the area name. I would like to know using PHP for search will be more efficient or using Stored Procedure or using any third party tool. Efficient in the sense ...
I am using an Export Module, now I want to extend it for different connections. I have a database which contains products Its Description, Review, Images etc. I use the serialize function to save it as XML file. After saving it as XML, in admin pannel I have possibility to select how this XML file will be exported. for...
Given a maximum integer value M, I want to generate N integer values that are distributed with a lower frequency when approaching M (preferably M should still have a non-zero probability). I don't really care much about the probability function, let's assume (half of) a normal distribution. How would I do that if I don...
The majority of my work over the last three years has largely been around maintaining legacy systems that needed patching up or the occasional revamp before being sold again. I understand the critical role dedicated maintenance programmers have to play in companies with a large number of projects and limited developers...
I have a script I want to sell. It's written in PHP, but that's not relevant here I guess. I want to secure my script with a license, so the buyer is forbidden from redistributing it. This is the first time I am selling my own script, so I have no idea how to start with this. Please let me know how I can protect my sc...
In many interviews I've been asked this question. What is a Package Diagram? and What is a Sequence Diagram? and difference between Package Diagram and Sequence Diagram. Thanks in Advance. Edit Sorry, google give me lot of answer, but i want to practical answer with example.
I was thinking about experimenting a bit with using mapreduce and such on a dataset we have to see if we can benefit from it in any way. What route should I go if I want to be able to instantly, without any major modification, deploy my findings to some kind of grid/cloud-system to see if there is any extra benefit to ...
I'm trying to understand constructor chaining better. I understand that this technique can be used to reduce code duplication for initialization of a class object and I also understand the order in which they're executed. I found the following example and I cannot see clearly what the benefits are in the code? And whe...
Preamble If I say "BSD" I mean the 3-Clause BSD license If I say "GPL" I mean the GPLv3 license I am not the author of the GPL project I am the author of the BSD project Simple Task I want to use a 3rd party software (GPL) in (or better 'with') my open source project (BSD). Situation I won't change any of the GPL pr...
currently I'm working on a project with the following setting: There is a proprietary application which performs transactions on a Microsoft Access database (which is actually stored as an .mdb file) The API of the application doesn't have enough functionality for the requirements we're facing Our application has dire...
I understand all the advantages of Daily Scrum and my team does it when we are working on stories. But sometimes we just have bugs to fix for days, while we're waiting for new stories, and when this happen we put daily scrum aside. Some of developers says that "There's no need to do a Daily Scrum when we have nothing t...
I've had a chance to try it out and I like it very much. I'm thinking of using it in all of my future projects. I'd like to hear some critique and opinions about it. I've done a little research on the subject and I'm not sure I've seen this approach around, but I'm pretty sure that it must have been tried by some more ...
I am developing mobile based social network with backend and I cache some data from facebook. I asssume I should include a kind of Terms of use and privacy policy statement in the application? is it really neccessary? where can I find proper templates for this?
The problem is the UserTypes property (used to populate a drop down list in the AddUser view) is not being retained after POSTback of the form. Here is my AddUserModel: (which inherits from EditUserModel which doesn't have properties for UserTypes/UserTypesSelectList - probably part of the problem?) public class AddU...
I am trying to do something somewhat unique, and the best path I can find at the moment is to use List joins, but I'm not sure this is possible. I'm hoping someone can suggest a best course of action. The issue at the moment is that I have several lists (i.e. Employees) that all have a lookup to the Assets list. I al...
Since Javascript is an interpreted language, entire functions can be changed during runtime. I have recently been contemplating a framework that would allow for dynamic code changes (such as UI plugins) to take effect without having to reload the page, while still providing enough information to undo the change if desi...
Let's say we're making a parser. One implementation could be: public sealed class Parser1 { public string Parse(string text) { ... } } Or we could pass the text to the constructor instead: public sealed class Parser2 { public Parser2(string text) { this.text = text; } public ...
I've seen plenty of questions asking if listening to music boosts productivity, etc. but I haven't been able to find one about performing music. Learning to play the piano has been on my to-do list for a while, partly because I have a sneaky suspicion that learning to deal with the relationships, recursions, etc. inher...
I know Aggregation is a has-a relationship, but I encountered a question in a test which did not make sense (and had grammatical mistakes as well) Which of the following statements correctly describe the concept of aggregation in OOP? A Splitting a class into a several sub classes B Creating one piece of code that wor...
I have been given a spec to create a new MVC4 website, it will not be too large a project at first but I suspect it will grow as the business gets new ideas for it. Using .NET 4.5 ASP.NET MVC4 and EF I have to choose between code-first with migrations or Sql Server Data Tools (SSDT) for handling my database. With the S...
I used the Process Editor (from TFS Power Tools) to update the Workflow diagram of a particular Work Item Type (viz., the "Issue" type). There are a dozen other projects on our server that share the Issue type, and I would like to port my changes to all of them. But unfortunately, while the Process Editor allows you to...
Just like NVR (Network Video Recorder) and DVR (Digital Video Recorder), I was wondering if there's a term / acronym for Desktop Monitoring Recorder? Perhaps DMR? I can't find any standard terms for this type of system. I'm writing a system which is just like an NVR but records / monitors computer desktops instead. It'...
I wish to acquire a new computer that is specially designed for programming. I would like to build it myself for the learning experience, but am willing to purchase it made as well. Basically I have downloaded so many files dedicated to programming that are so large that a) my computer is near capacity and b) my 4 yea...
I have been reading a lot lately and I have come across articles in which people make the 'grand' assertions that there are no bugs in the Tex program by donald knuth. Is this in any way possible and if so how is this possible?
The C Programming Language by K & R states that C, like most languages, does not specify the order in which operands of an operator are evaluated. (The exceptions are &&,||,?: and ','). According to the book, the result of the statement : printf("%d %d\n",++x,power(2,x)); depends on the compiler. But it itself says in...
I've read many, many, many posts on how "you're probably storing passwords wrong". They are always referring to storing passwords on a server into which a user is logging; they basically rehash (pun intended) ubiquitous advice like make sure to salt the passwords, etc. etc. However, I've never seen an article on best p...
I have an MVC 4 based web app. Where I provide 2 login types, 1. Employee and 2. Customer. With Customer login, I present a dashboard and other stuff, about his orders, etc. With Employee login, I allow the employee to search for his customers and provide the ability to carry out certain customer specific tasks. It is ...
We are working on a integration between two large systems. System A is a database with employee data, and System B is an external system that is used for the daily contact with the customers (i.e meetings, locationdata,work order,work status, and so on). We will deploy a ESB in the middle. There are 3 instances of Syst...
I have created a library in Python that contains functions for accessing a database. This is a wrapper library around a third party application database, written due to the fact that the third party application does not offer a decent API. Now I originally let each function open a database connection for the duration o...
Well, there is lot of discussion about implementing 3 (or 2 stacks) in a single array. But whats the real need or application for implementing stacks like that? Can't we allot memory as 3 separate stacks [array] itself? Anyway we are alloting array[size * 3] in that single array. some links that discuss some: Use an a...
If a dynamic library exports the address to a global variable defined within the library, how are accesses to that variable translated during dynamic linking so that a running application can interact with it?
Many people consider exceptions to be a problem because they create invisible paths through your code. For example in this snippet: function writeToFile(text, filename): filehandle = open(filename) foreach line in text: filehandle.write(line) filehandle.close() The write method could throw an Exception. In t...
I've been working as an app developer for a year and a half now (not long I know), and I've just been given my first big project. Needless to say it didn't go very smoothly, so I sought advice from a senior programmer involved in the project about how to approach it. He said that I had drastically been over thinking t...
I have seen the words Fetch and Select used seemingly interchangeably when naming data access layer methods (ex. Person.Select or Person.Fetch). Which one is correct? My instinct is that the point of the data access layer is to abstract data access and thus the term Fetch would be more of an abstraction perhaps tha...
Im building small web-service which will provide my users with data through API. Also, some data will be available right on my website. The question is about how to use my own API? Should my website make a query to, for example, http://website.com/api/users/?format=json and then render data? Because I can use standard ...
I'm setting up some requirements for a software extension and try to use user stories to describe what I want to achieve. As a creator I want to add a new entry, to let users access it through the main page. I have the idea of adding an entry via Drag&Drop. My company has some guidelines, to have every command always...
I have a class (Timer) with an array list of Timable objects. Timeable is an interface. There is some specific functionality that I need for the Trigger class (implements Timable), which has a reference called target. A lot of methods need to search through the Timer array for Trigger objects with a certain target. Wh...
A common problem in my very small team workflow is handling merges from trunk/stable repositories up to feature branches which are ahead of the trunk or stable versions, but which need to track the changes in the trunk and stable versions. We are using mercurial, but any DVCS would perhaps have a similar workflow, incl...
I know that there are some other questions about C++ refactoring, but none satisfies my needs. I have a background in Java and Python programming, but now I'm approaching C++. I've read (and absolutely love) books about agile coding, test-driven development (TDD), refactoring, etc. The first that comes in my mind is "C...
I am learning Android programming and right now and i'm reading about fragments. I understand what fragments are, but either the tutorial is missing some steps or i'm missing something. So my question is when developing an Android UI, what are the benefits, if any, to using fragments as apposed to single page layouts? ...
Occasionally, I'm confronted with the problem that I have to provide some constructors in order to initialize objects with different sets of data. These sets can be mathematically transformed into each other, for example: public Element(int x, int y, int width, int height) { setValues(width,...
I have around 200 million new objects coming in, and a 90 day retention policy, so that leaves me with 18 billion records to be stored in the form of key-value pairs. Key and value both will be a string. It is basically a mapping between a unique identifier for the object in the application to the unique identifier for...
I am about to embark on a redesign of an application, one where querying the database is particularly annoying. I intend to redesign the database as much as possible but the data shape cannot change too much. The database has a main table and 10 other tables each representing a record type. The main table has all of t...
I'm looking for patterns or architectural guidance for an upcoming feature I'm designing. Basically, it's an export feature with multiple export targets, and I'm looking to find a way to make it generic enough where plugging in new export targets don't require a lot of core changes. By export targets, I'm simply referr...
It seems there is a lot of discussion on the web about the differences between these two paradigms, and how OOP is somewhat better than structured programming. But aren't they complementary? From my point of view one could organize his application following OOP principles and implement its logic using structured progra...
A group of us were wondering whether or not to go with CC0 or WTFPL because the CC0 explicitly states lack of liability. Does the WTFPL, if used properly, also free the author(s) from liability of usage?
In Mercurial you can close a branch like this: hg commit --close-branch, this means the the branch will not be listed anymore but will still exist, and can still be listed if you use hg branches --closed I have learned that in Git generally branches are not kept, they disappear, specially when doing fast-forward merges...
Let me explain our situation. We are small company with about 20+ staff and all the while we have been practicing the standard waterfall model with not much success (due to frequent changes of requirements and lack of direction). So one day our CTO came in and he briefed us about SCRUM and all of us were convinced that...
From the "Gang of Four" design patterns, there's the Factory method: class Factory(product) case product when a new A when b new B when c new C end new Factory(a) Why is this more useful than having three classes, a, b, and c and calling them individually?
This question is about the persistance of variables across different modules in nodejs when they don't directly "require" each other, but do "require" a common ancestor. It is also the generalised version of this stackoverflow question. Whilst I received an answer there that helped me solve my specific case, I'm still ...
I'm working on an assembly project and I need to write code to switch from text to VGA mode. This is fairly complex and requires setting up a lot of data, so I'd rather not write it myself. Fortunately I found a snippet of code on the internet that does exactly what I want. Unfortunately it does have a copyright notice...
I noticed that a lot of GitHub accounts only have repositories which are forked from other accounts. In addition the people who do this usually don't make any contributions to the forked repositories. I've heard of people collecting stamps and seashells, but why would anybody want to collect repositories? Personally I ...
I have a question regarding generalization. I know when it is needed to be done, but is it worth having an extra class for 1 field? e.g.: StatisticsCustomer has fields: Customer customer and int projectCount StatisticsCountry has fields: Country country and int projectCount What is best in this situation? Creating an e...
There was an application for PalmPilots that I liked back when PalmPilots were a thing. I want to recreate it (or at least what I remember of it) for modern mobile devices. The problem is, after scouring the internet for any information on the application or the original author, I am unable to find anything. I can't ev...
I have an opensource project currently under MIT license. I have received a request from a company to use my code for their commercial project without having to give any attribution or credit. To be honest, when I released the code, my sole intention was only to help a fellow programmer, and I didn't really think about...
In the same way that a publication table might relate to a person table via subscriptions, or a company table might relate to a person table via employee, I'm wondering if there is a descriptive way to relate a company table to a company_type table. Here are some rough (and simplified) examples of the relevant tables. ...
There are many comparative studies and available online when it comes to the runtime performance of applications built using one language or another. Some driven by corporations, some academic, some just personal experiment reports. We also get a decent share of comparative studies on side-effects of a programming lang...
I'm working on a Java Project, and I wrote a small plug-in to the existing project. I wrote it on my Mac(dev), QA is on Windows and Prod is on Unix. In the code I make specific API calls to a different program. On my mac though I'm just reading in a file. In Dev it is using windows file path to execute an external prog...
I have a peculiar problem. My application has different levels of authentication. One specific level of user (super user) needs to be able to use the application as another user (subordinate user) that has lower privileges. We decided that when the super user selects to be a subordinate user then another tab in the bro...
I have a javascript project which uses Grunt and several plug-ins such as: jshint qunit requirejs optimizer Not all of the developers run the grunt tasks locally (e.g. jshint, qunit), so they might not know if code they committed has issues. It's easy enough to set up a grunt watch task, but emailing the team upon er...
There are some (quite rare) cases where there is a risk of: reusing a variable which is not intended to be reused (see example 1), or using a variable instead of another, semantically close (see example 2). Example 1: var data = this.InitializeData(); if (this.IsConsistent(data, this.state)) { this.ETL.Process(da...