instruction
stringlengths
34
19.9k
It struck me recently that a virtual machine for a high level programming language is very much like an OS. It manages resources, e.g. stack, heap, etc. similar to how an operating system manages resources and if the programming language supports threads then the virtual machine also does time-sharing and context switc...
My professor made a comment today - "...They've been having trouble with filesystem performance, and since they're more graphics guys, they asked us systems guys to help out...". What exactly is "computer systems"? What does it mean to be a "systems guy"? And, what is a "systems guy" passionate about? For contrast, wha...
We currently have an interface for an asynchronous video decoder that runs on its own thread. Basically you feed it some data and it'll eventually call you back on its thread through some events, like so (not real code): interface IDecoder { void Decode(parameters); event FrameReady; event FrameDropped; ...
I am writing a full fledged p2p networking library on top of Indy's UDP server with an intention of publishing it online. The design I have implemented has a P2P manager ( TIdUDPServer ) which can act as a server or a peer. Each connected peer is represented by a separate object which contains additional features and i...
I create a lot of views in my work as part of the common MVC pattern applied in web frameworks like Code Igniter and Cake. I also adhere to the following maxim as best I can: fat models and library objects doing the logic; skinny controllers responding to user actions server side; and views presenting request results a...
I am developing an application containing a class which loads application settings from a configuration file. Settings class: public sealed class MyAppSettings : IMyAppSettings { private IMyAppSettings DefaultSettingsInstance; public MyAppSettings() { DefaultLanguage = "en"; var config = C...
The definition of interpretation (correct me if I'm wrong) is parsing code like so: 1- Translate currently parsed line to some intermediate language. 2- Run the translated line. 3- Move to the next line. 4- Translate it. 5- Run it. And so on. If so, why do people say that the JVM interprets the Java Bytecode? What it d...
In method call syntax in many object-oriented languages, the receiver object goes to the left of the method name, e.g. someObject.someMethod(). This comes in handy when using an IDE with code completion/code assist/Intellisense; when the user types a method call expression, the receiver has already been typed, so the I...
My question is related to C++ but it comes from Java actually. When I was programming Java I had multiple classes, which were derived from a base "Test" class. Their purpose was to test things - run tests (unit tests/not unit tests). In order to run a test, I had a public static void main in every class. So the matte...
Today I stumbled upon the python package called PyContracts. However, python has the assert statement which seems to allow you to do exactly those things. What advantages do contracts have over assert statements?
(I reworded my question to make it more specific). Consider a programming language, that it's programs may only be run inside a specific program that serves as an interpreter. The interpreter scans each line of the source code and executes it as it is. Would the interpreter be considered a virtual machine? Conceptually...
I was wondering what are some techniques to locate which code implemented a specific feature, on a desktop application. I am a junior developer, with only professional programming experience lying around web programming. In the Web it is easier to do that. For example, you "inspect" a button with the browser tools, and...
The Incremental approach is a method of software development where the model is designed, implemented and tested incrementally (a little more is added each time) until the product is finished. It involves both development and maintenance. The product is defined as finished when it satisfies all of its requirements The ...
Below is a pseudo declaration for a multilevel inheritance. Base class ( protected int data) derived1 : virtual public base ( protected int data1 ) derived2 : virtual public base ( protected int data2) derived3 : derived1,derived2 ( private int data3 ) Main(){ base b; derived1 d1; derived2 d2; derived3 d3; }...
I've learned about mocking and stubbing and I've seen how they can help me create great test suites that run blindingly fast and thus speed up my development process hugely. However I've also seen the downside when there is an issue that is database centred and wasn't tested for (test doubles or not). So should I have ...
After doing some research and with the help of people on this site, I finally came to an understanding of what interpretation actually is. Essentially, what interpretation means is (correct me if I'm wrong): Scan a piece of code. Come up with a piece of code in another language, with the same meaning. Execute that new...
In this question I presented an idea I have for a simple programming language. The way programs written in this language will be run, is inside an interpreter written in Java, which will interpret the source code directly and execute it. I would say that there is no doubt that this language would be considered a 'progr...
Suppose I have created interface IFolderRepository with methods like that: IEnumerable<Folder> GetAllFolders(); Folder GetFolderWithId(int id); void AddFolder(Folder newFolder); void ModifyFolder(Folder folderToModify, Folder folderAfterModification); void RemoveFolder(Folder folderToRemove); and I've implemented Data...
I really like scope-based memory management (SBMM), or RAII, as it is more commonly (confusingly?) referred to by the C++ community. As far as I know, except for C++ (and C), there's no other mainstream language in use today that makes SBMM/RAII their main memory management mechanism, and instead they prefer to use gar...
As mentioned in this question, I am moving our team towards objects (as opposed to just throwing DataTables and variables around everywhere). I have picked a suitable spot for the project that contains the object definitions, but not sure how I should go about populating some of the objects. In particular, what do I ...
An example of use case when event sourcing is applicable here whose excerpt is: Say, something went wrong in your app and as a result, a user gets blocked for abuse but that user claims to not have done anything to break rules. Now you can go back to your staging environment and play the events leading up to the...
I have to create a schedule control using WPF XAML for displaying items with duration as little as 1 seconds and potentially as large as couple of hours. First thing which seems clear is that I will need some kind of zoom capability, for drilling into the items with very short durations and zooming out to view the it...
Sometimes I run into the problem of having uncommitted code on a workstation that is not ready for a commit but needs to be completed on a different workstation or laptop. Does anyone have a solution for this problem, such as a "soft commit" or some other way of transferring the changes to another machine to work on th...
How do I unit test a function that takes a list of maps and returns an HTML table with the same data in Clojure/Hiccup?
I have been using Dependency Injection in Spring for some time now, and I understand how it works and what are some pros and cons of using it. However, when I'm creating a new class I often wonder - Should this class be managed by Spring IOC Container? And I don't want to talk about differences between @Autowired annot...
Generally, on many platforms, I'm writing my string resources to a .resx or .xml file, and then I'm getting them using some platform-dependent approach. That is, on iOS, I'm getting them via NSBundle.MainBundle, and by using Context.Resources on Android. What are the advantages of this approach, and why not having it d...
Can you recommend a nice way of checking a particular value between calls to a set of functions? E.g. something like this in Python (might not be terribly 'Pythonic'): self.error_code = 0 # this will be set by each function if an error has occurred self.function_list = [self.foo, self.bar, self.qux, self.wobble] ......
I think I have found contradictory design guidance within the Google Android documentation on fragmentation. The first statement below advises each fragment be unaware of other fragments and always communicate only to the activity and let the activity decides what needs to be done. Creating event callbacks to the acti...
I'm working on a client-server sort of protocol right now in Ruby. I've hit a snag where I'm not entirely sure how to proceed. Currently, I have a class, Remote that signifies a remote connection (for use through EventMachine). When Remote receives a message (i.e, network packet), it sends it off to the MessageDecoder,...
Our team has recently adopted agile practices and most of the team is new to agile. In our product, we use some code developed by another team and only they maintain that code. For the last 4-5 years, the previous developers have merged the code they intended to use and not all of that. Over time, the code in our branc...
I work in a small team of developers that supports several pieces of software that a large multi-site company uses. We use Spiceworks to raise issues and support requests throughout the IT department not just developers. We constantly get tickets raised with the following or similar: "Function X is broken, please fix i...
My Android app needs javax.activation and javax.mail (both GPLv2 licensed). However, I don't want to make my app GPL-licensed. What are the possibilities to not break the license requirements regarding the classpath exception? Currently, I use maven-dependency-plugin to pull those packages' source code and merge the co...
My team is currently working on a web platform and we are planning to divide the application in a set of independent services written in different languages, the problem is that these services rely on a domain model layer that will need to be duplicated across the different languages(C# and Java). The Domain layer is h...
I'm trying to find something that will allow a web application to analyze the line or microphone input from a client and transmit that data to the server. I've looked briefly at WebRTC and, although I find it to be the most compelling answer 'future-wise', it is (at the time of writing) far from being complete and/or s...
http://www.thebuzzmedia.com/designing-a-secure-rest-api-without-oauth-authentication/ I've been reading the article and I haven't really grasped it yet. When is the private key given to the client? Say I have a JavaScript client - where would I store this private key (once assigned) - a cookie? I think that this maybe ...
Lets say I have a Enemy class, and the constructor would look something like: public Enemy(String name, float width, float height, Vector2 position, float speed, int maxHp, int attackDamage, int defense... etc.){} This looks bad because the constructor has so many parameters, but when I create an Enemy i...
I have a property that is loaded lazily, any time after the ctor is called. It is possible that the binary that my property relies on is invalid. If invalid I might have to throw an exception. Should I Make the property a method, and be done with it. Leave things as is. Leave the property as-is, but add a method to v...
At my new place of employment we have a Intranet solution containing multiple web applications hosted in IIS. Outside of the development department other departments either source or create other applications / reports that deep link into these web applications. Unfortunately, I have no direct control over these potent...
I've been asked to draw out the Bounded Contexts (BC) and the possible aggregate and the roots of a School domain. The domain consists of students who study modules on a course. The submit their assignment for a module which is then marked by an external tutor. The 'Marking' firstly sticks out as a BC, but im unsure a...
Generally speaking, is it considered bad practice to allow for user created fields in a database for a webapp? For example, I am making a home inventory webapp for my wife, and she is going to want to define her own fields for different items. I was planning to allow her to create item categories, and add "features" t...
Let's assume this conceptual scenario: The database is constantly populated with "a ton" of tasks named PleaseSendAnEmail. A scheduler/listener in background is aimed to handle those tasks. Of course, rules are that a specific mail shouldn't be sent more than once and that the handling should be the fastest possible. P...
I'm developing a PHP application and I find myself doing basically the same code for, say, creating an object based on a form filled by the user. The objects are of different classes, but the process is mostly the same: take the data from the form, apply validation, save/return error. Is there a way to automatize this ...
Have a quick question on how to best structure something for my Java project: I'm a user. I can work at one or more places. At those workplaces, I have one or more roles. For each of these roles, I work a shift. I either came up with: My workplaces have shifts, my shifts have exactly 1 position (what position did I wor...
I was talking today to a colleague of mine about Python web frameworks and our impressions about them. I told him I think Flask having a global request smells badly and is an anti-pattern. The docs say about request context: In contrast, during request handling, a couple of other rules exist: while a request is activ...
Please consider the following situation: You write a closed-source application, let's call it A. A depends on a system API (i.e. provided by the OS), that is in turn configurable to use different backends. Each backend is identified by a simple string value and also selected via this identifier. The API itself is not b...
As a beginner programmer, I don't know how to conceptually think about brute-forcing. My mind can't really fathom how to write code that will try every possibility. I have a problem that I want to solve. Here is a code snippet (there are other functions, but no reason to include them here, they just do background work)...
I have a project that gets all of its data from API calls. The server that hosts this API connects with it's own database (not even sure what DB it is, etc). More or less the idea of a repository is to separate data and map it, right? I shouldn't be concerned where my data comes from. But if, at the end of the day, the...
I've got a library up on GitHub, with some of the binaries also distributed on NuGet: https://github.com/relentless/Http.fs I'd ignored licencing up until now, but somebody's asking about it so I though I should put something on. I want to keep it permissive, and having done a little research MIT seems like a good one...
I have created a DIFF implementation to compare document revisions at work. It is based on An O(ND) Difference Algorithm and Its Variations. One thing that has become important is to take the list of changes and interpret them into human readable text. While the current algorithm is very efficient, it is so much so...
I have a simple factory class (FileResources) with static factory methods providing a default implementation (DefaultFileResource). public final class FileResources { private FileResources() {} public static FileResource get(Path path) { return new DefaultFileResource(path); } } The problem with t...
We're starting to use dependency injection in a fairly large, interactive program. It's early yet, but I have a feeling that the majority of the objects being injected are going to want runtime data passed in to their constructors. Prior to this, I've only used DI in web applications where building everything at the ...
I'm a junior developer (~3 years' exp.) and at my job we're in the process of architecting a new system. My lead developer will be the principal architect, however he's challenged me to try architecting the system myself (in parallel). Over the course of a few iterations of brainstorming ideas and proposing what I saw...
I was thinking about how I can decouple a web-application completely into a server-side and a client-side component. I want to decouple the app to the extent that I can host both components on seperate servers. So, for example, I would have: Server 1 (API Server): A server-side component running on Django on something...
I'm new to testing but wholeheartedly realize how important it is. The main issue is that my company has no top-down support for testing at all. That is we don't have any unit testing and just a bit of human testing (I hope I'm using the right terminologies). I have been trying to get testing started here and have to d...
I have a package of code which is suppose to tell me where to allocate elements. When I add a new element it may require repositioning of existing elements to keep my 'tree' in a format that promises a log-n search. Ultimately when I hand it a current system and new elements to add I should get a list of where to add...
I've been reading 'Introduction to Evolutionary Algorithms'. This method is stated, but not described, and I can't find anything more specific online. p44/45 of 2nd Ed for reference. adding to the current gene value an amount drawn randomly from a Gaussian distribution with mean zero and user-specified standard deviat...
I am writing a Rest API and am wondering how best to handle supporting the different versions. By this I don't mean how to define a URI as V2 or V3, but rather how to structure the code given that it'd need to: Support multiple versions at the same time, eg. V1 & V2 & V3 URIs must be live at the same time. I would ret...
If there are two unrelated tasks, except that the changes are in the same project, and end up touching at least one of the same classes/methods, how do I manage that? Two different developers could each pick up one task. Each dev will create a new branch off of Integration, work in it, then need to Merge. When Merging...
I'm working on two separate projects now that are essentially just CMSs -- a bunch of forms for recording various bits of information. Each project is built to serve many clients, and each client seems to want to record slightly different information. In one project we've handled this either by copying and pasting all ...
I'm new to TDD and wondering about methodolody. Given: A simple project which implements functionality of, for example, a console calculator. It has the following structure: Fairly simple top-level class that takes console input, delegates it to a buisness-logic class and shows output in the console with some fancy ...
In software design, we usually take care of UML diagrams and architecture design. But in case of a data analysis software, we must pay attention to design algorithms and stuff like that. Consider the case of a face detection software which needs AI. Do we need to design AI part of the software explicitly in software de...
That doesn't seem to make sense. In local variable, we sort of know the type anyway. It's local. We're working on it. Yet in function name or global variable, the definition is very far away on other files. It seems that hungarian notations make far more sense there. For example, in objective-c I used this +(CGFloat) f...
From the OSI's OSD: Free Redistribution The license shall not restrict any party from selling or giving away the software as a component of an aggregate software distribution containing programs from several different sources. The license shall not require a royalty or other fee for such sale. and Derived Works ...
I am busy writing a bare-bones Standard C Library for my hobby OS. I am only including the functions I really need for now but the library is still referenced as 'libc' in my source and I plan to expand it to a fully featured C Library. My OS is going to be released as open-source so I would like to know what kind of c...
I see that some software have the version number included as a part of their file name, while others do not. I am more used to the latter type, and I think that is more popular, but I see the former type sometimes in javascript libraries. For example, jQuery's file name is like jquery-2.1.0.js instead of jquery.js. Whe...
The company I work for has commissioned a software company to produce a compliance software for several big companies. As part of our contract it is required of them to provide us with src code and documentation in case in the future we want to take over and further develop the project in house or have another company ...
I checked with meta and apparently this is the best place to ask! The company I work at have many environments, and as such, many Nagios/Icinga etc boxes in each environment. We currently have a dashboard, but it was created quickly many moons ago and needs replacing. It currently scrapes the HTML of every box, builds ...
We developing a web service. And need our important actions (i.e. money transfer) to be protected from accidental calling. In frontend we asking user to confirm such actions. Ok. But how to prevent accidental calling in case of developer mistake? Is it good idea, that action require some confirmation token from develop...
I'm designing a pragmatic REST API and I'm a little stuck on how best to add existing entities to a collection. My domain model includes a Project that has a collection of Sites. This is a strict many-to-many relationship and I have no need to create an entity that explicitly models the relationship (i.e. ProjectSite)....
So, I've been reading the AGPL and here is my understanding (not being a lawyer and I'm not trying to look at it through the lens of "Since I WANT it to be ''free'', it therefore is.". In my case, I am considering the use of itext, an AGPL library, to crack open PDF files and extract the text - that's it. There will b...
I'm developing a site to monitor web services. The most basic type of check is sending a ping, storing the response time in a CheckLog object. By default, PingCheck objects are triggered every minute, so in one hour you get 60 CheckLogs and in one day you get 1440 CheckLogs. That's a lot of them, I don't need to store...
I'm trying to follow the single responsibility principle (SRP) in my applications. I have lots of CRUD classes I just name xxxxxManager. Following the SRP, I made 4 classes for each one : xxxxxCreator, xxxxxGetter, xxxxxDeleter, xxxxxUpdater They end up having only one static method : xxxxxCreator::create(Model $model)...
I really like programming simple things, like solutions for Project Euler, where you can concentrate, write an algorithm, instantly execute, test, verify and change the program until it works. Even for bigger projects I feel I can maintain flow and be very productive as long as I can stay in one IDE (e.g. Eclipse) and ...
The typical programming designing method that I've come to use goes like this: 1. ID the problem and what's required 2. Make your program do something simple 3. Test it 4. Make your program do a little bit more 5. Repeat 2 until all the micro problems are solved by the program as a whole Basically, incremental design....
Two common phrasings for the Single Responsibility Principle (SRP) are "each module should be responsible for a single feature or functionality in a system", and "each module should have only one reason to change". My questions is: is this something that we should absolutely strive for in every class of a system, or sh...
At the office we just got out of a long period where we released patches on a too-frequent basis. Near the end of that period we were doing almost three patches per week on average. Beside that this was very demotivating for the developers, I was wondering what the customer would think about this. I asked the question ...
Let's take a server-side WebServices app, we need to make sure that all function applies every security rules, and keep the code clean. In such a case, I usually prefer to place my security checks on the upper layers. As soon as the user call a function, I check if he has the rights to access it or not. But this strate...
When one says "a class' interface": Does he/she refer to all of the get and set methods - or do they refer only to the methods' signatures and return types, without the inner implementation of these methods? (Aka, the implementation of a 'get' method isn't considered part of the interface, but rather part of the inner ...
Context I am (part of team A) developing a piece of functionality which depends on new APIs provided by team B. Old APIs (also provided by Team B) are there and this is how they are being used in our code... int someFunction() { //-- lots of code here oldAPI.func1(); //-- lots of code again if (something) oldA...
Should I always use is as prefix for boolean variables? What about booleans that indicate something in past? Should I write isInitialized or wasInitialized? Should I write for properties IsManyMembers or HasManyMembers? Is there any best practices? Or I should just write in accordance with English rules?
When is recommended to use read-only properties -- if the language allows me? Are public read-only properties meant to replace getter methods or at least the Magic Methods like what is available as __get() in PHP for example? What is the use of a private read-only property?
Is it acceptable to model a very complex object graph using XML in the database, but leave the rest of a system in relational tables? I'd like to gauge opinion on this as I've hit a bit of a conundrum. Many thanks -------------------- Background I'm building a financial application which, although not at all large in t...
We are going to hold a meeting where everybody will speak in clockwise direction around a table. There are n people with n spots. Each person has a position preference (e.g. some want to go first, some last, etc). Everyone is seated randomly and cannot move from their position. How shall we compute the best starting po...
I'm reading about dependency injection (DI). To me, it is a very complicated thing to do, as I was reading it was referencing inversion of control (IoC) as well and such I felt I was going to be in for a journey. This is my understanding: Instead of creating a model in the class which also consumes it, you pass (inject...
In our company, we are only two IT staffs, and I'm the only developper. I'm developping rich intranet applications using plain php and extjs as javascript framework. Our development cycle is usually very fast, such that often people are using tomorrow what I develop today. This is possible through an automated build sc...
I currently have a test class with a setUp method for creating a temp file and a tearDown method for deleting a temp file. However, only some of the the test_ methods in that class require this functionality. Is possible to either ignore those 2 methods for the test cases which do not require it or to only call those 2...
I have multiple sets containing integers. An integer maybe present in one set or multiple sets. I would like to find/match the sets with the most common integers. Example s1 {1, 2, 3, 4} s2 {1, 3, 4, 5} s3 {6, 7, 8, 9} s4 {1, 6, 8, 10} In this case, I would like to "efficiently" group s1+s2 as they have the most overla...
I am working on project on which I need to open-source part of my code in order to simplify extension by the enduser. What I want, is to make an npm module, that will expose part of my code, so my users can build extensions for the product (in JavaScript), but I want a guarantee that this code will not be used for comm...
My scenario is as follows: Web application, run from the browser, designed for mobile devices. Uses WebSQL storage which may contain sensitive data. Uses Application Cache to enable offline use where there is no connectivity. Can connect to an API where even more sensitive data can be downloaded. Authentication is han...
Knowing that C# doesn't support multiple inheritance, is it considered bad form to write a utility base class? Some initial thoughts: I could create an interface and a concretion, but then the implementation isn't portable Should the developer need to extend the class in say, a decorator pattern, they could implement ...
As part of my workflow, I need to do all these steps in one transaction - I need to ftp files to 2 different FTP servers. - There is also a spreadsheet that gets generated which needs to be FTP'ed. Can this be streamed, instead of downloading and then pushed to FTP server. I am using Ruby Net::SFTP and Net::FTP libra...
I recently asked this question and this comment and made me ponder the whole process of releasing an update to the customers. The next update for our software is planned and the previous time it went horribly wrong because of regression, bad testing, etc... This time we want to prevent the scenario that we test via our...
I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: Scenario: There is this complex algorithm where a large amount of people have worked on for many years. The algorithm creates...
I am currently studying pathfinding and I came across A* algorithm from this site https://github.com/qiao/PathFinding.js I tried to test A* with bi-directional and it is working great. What I wanna do now is increase the path that it can make without adding more nodes in the openlist. For example is that the algorithm...
Is it generally, to a reasonable developer, considered morally acceptable, to take a branch of an open-source repository, and start making changes to it and calling your own? You would be taking this to another open-source. Assume that you will link to the original. Note that this is a question of what is considered ac...
Using Visual Studio 2012 with C#, when I write multi-line comments, VS automatically begins each line with an asterisk, like this: /* * * */ I was just curious if this was the case in programming languages other than C#, or if there was a specific reason for this template.
I am busy with a hobby OS and I am planning on making the project open-source and eventually have support for multiple platforms. With this in mind I have taken the approach of putting all hardware specific code in a separate Hardware Abstraction Layer (HAL) library so that the kernel does not need to know how the spec...
Commitment is a promise, and we all have been taught that you need to keep your promises. But is it realistic to keep the commitment for each Sprint? Sometimes people get sick, sometimes the technical approach is proven wrong and you have to rethink everything, sometimes during further discussions with the product own...
What is the best way to get data from server as fast as it gets to it? (Like instant message, or simple broadcast for example). I first thought about using miniature web server in android and get post requests to it with data. However with this approach I soon understood that I will get many problems with NAT and simil...
The premise is using a language (e.g. C#, javascript) which passes an object by reference into a method. Assume there is an object "Player" which has a property "Level" and there is a method takes Player as parameter and its function is to increase the player's level by 1. The method can be designed something like (c# ...