instruction
stringlengths
34
19.9k
I came across some code recently where in many, many places, expression evaluations were being assigned to different arrays one index at a time. A psuedo-code example: array[0] = item1[0] + item2[0]; array[1] = item1[1] + item2[1]; array[2] = item1[2] + item2[2]; or array[0] /= variable; array[1] /= variable; array[2...
It is one thing to say that agile methodologies are good in settings where requirements are poorly understood, or that significant novelty is involved. But should it be applied where outright innovation is required? If yes, how? If what you are contemplating is unknown in the industry, or even thought to be impossibl...
In Purescript, IO an other effects are managed with the Eff monad, and extensible effects, which are declared like this: main :: Eff (trace :: Trace, random :: Random) {} So if I understand well, this main declaration only allows to log to console, and generate random numbers. The trace :: Trace, random :: Random is ...
I am new to DI and I would like to know how DI might be used to help resolve this problem. If I have an ILatLongLocation which implements a Latitude and Longitude, then given two of these I can produce a Distance using a variety of algorithms, but I can also reasonably pick one of these as the "best" algorithm at desig...
I've inherited some Java code which I suspect harbours some concurrency bugs when synchronizing between a thread that queries data and an IO event that updates the same data. I'm trialling a static analysis tool called ThreadSafe which indeed detects various concurrency issues (i.e. field accessed from asynchronously i...
I am working on a multiplayer game, where a player has many storages to store items in. Storage Storage is the system that allows the user to deposit items, and take them back. Example of storage types: Inventory: Same as WoW inventory, you can add items, drop items, move items from slot to slot. Bank: Bank is what y...
We have a job table that triggers a notification when a new job gets inserted. Clients that can handle such jobs may subscribe to those notifications. When a client receives a notification, he can "lock" the job, so no other client will try to process it. We have also take care of errors and if a job takes to long to p...
I have a long list of IP addresses that show some pattern of closeness Example: XX.249.91.16 XX.249.91.21 XX.249.91.32 XX.249.91.160 XX.249.91.165 XX.249.92.15 XX.249.92.25 XX.249.92.51 XX.249.92.234 and sometimes a whois reveals a range like this XX.163.224.0 - XX.163.239.255 I would like to create...
One of the things I like about the new Apple language Swift is that it combines procedural programming with algebraic data types. What other languages do this?
The usual example of Data Oriented Design is with the Ball structure: struct Ball { float Radius; float XYZ[3]; }; and then they make some algorithm that iterates a std::vector<Ball> vector. Then they give you the same thing, but implemented in Data Oriented Design: struct Balls { std::vector<float> Radiuses; ...
I have been reading a number of posts and I am leaning towards building an SOA. My main dependencies are: Need to support multiple clients Need individual client environments to not effect other client environments For example, if I want to add a text field to Client A's application, but I don't want Client B to be...
From what I have read, K&R seems to be a good place to start learning programming in general, and C programming specifically. However, I've just started the first chapter and I have a few questions. They may be extremely simple, and I apologize if that's the case (I am new, after all) -- but your helping me answer them...
I have created an app that manages a Data cleansing workflow. Each row imported needs to store an arbitrary number of key value pairs in addition to our standard mysql schema. The key values need to be searchable. I am using rails + mysql currently. What are my options? As of now, I am just adding a new fields to the ...
Traditionally software build numbers fit into the format Major Minor Release Build Where a Major version is implemented whenever there are breaking changes, Minor when new mini features are added, Release when something is published and Build each time it's built. I find the last two digits work really well in a CI e...
I got two classes. busiObj(created from ancient flat files) key(provides means to tell busiObjs apart) key has a c'tor that takes a busiObj public key(busiObj foo) { bar = foo.someThing; [...] } I want to create the key in the c'tor of the busiObj public busiObj(...) { myKey = new key(this); [...] } ...
I'm working as a developer / architect on a software project. The project manager decided not to follow the Agile principles, but to rather have an Excel sheet with all the feature requests and their estimated (remaining) effort. I'm required to update the estimated remaining time of each feature that I'm implementing ...
I know output to the console is a costly operation. In the interest of code readability sometimes it is nice to call a function to output text twice, rather than having a long string of text as an argument. For example how much less efficient is it to have System.out.println("Good morning."); System.out.println("Please...
I have referred What is the difference between And and AndAlso in VB.net? to understand the difference between And and AndAlso. I am from C# background - and C# has AndAlso only - no And.. And I don't see any practical use/advnatage of And. Is there any practical use of And in VB.Net? Reference Or versus OrElse What ...
I'm wondering if anyone knows of a language that supports automatic-evaluation. (not sure this is the right term. so let me describe what I mean below) For example, a program asks for an int as its input, one can give it 2 + 2, which evaluates to an int with value 4. Of course, one can certainly make a program that acc...
If I am planning a structure for support testing in Linux, a structure that will contain packages, such files as shell and build scripts, app configurations, DBs, sources, tests and jars for to be managed, applications for be managers, users, permissions, etc., what diagram could be used for it? Just now I am using the...
I've got myself into a bit of a mess. I've got code coming from Main, through myMethod and down to OtherMethod. One of the parameters can be either an int or a string, which affects OtherMethod but none of the intervening methods. public static void Main() { myMethod(number: 10); myMethod(letters: "ten"); } pu...
Licensing question - am I allowed to use a GPL binary executable (.exe) in my copyrighted .bat script? Namely I want to use FART command line tool (find & replace text in files) in an install script for a proprietary product. Is such use actually static or dynamic type of linking?
Since trying to use them will cause an error what is the workaround to get the same effect as them? My Base Class: public abstract class IPacket { public abstract int Identifier { get; set; } public abstract void Handle(); } Child Class: public class DoSomething : IPacket { public override int Identifier ...
I'm learning about code contracts in .NET, and I'm trying to understand the idea of pure constructors. The code contracts documentation states: All methods that are called within a contract must be pure; that is, they must not update any preexisting state. A pure method is allowed to modify objects that have been crea...
My database is going to store words, so the Word table is the most important. The Rhyme table lists which words a particular word perfectly rhymes with. It consists of three fields: RhymeID - primary key. WordID - foreign key linking to Word table Rhyme - a non key integer which refers to a different record in the Word...
I come from a C# background before my existing role. I am developing a VB.NET app. The code I inherited had option strict set to off and all other directives set to 'None'. I have recently switched option strict on and corrected all the errors. It will take me about one day to correct all the warnings. I am trying...
(This is question involving user experience, but I am primarily interested in the best practice technical solution to this common problem.) There are several places in my website where users are redirected: login screens, pay walls, etc. Sometimes these can be stacked. For example, login, then pay, then land on a part...
I'm implementing a mechanism to notify a group of users about newly inserted blog comments. The architecture uses the Redis Pub/Sub mechanism. By definition, the pub/sub mechanism aims to propagate message to the right subscribers, without storing/persisting anything. Although blog comments are obviously persisted in D...
A lot of my security experienced friends have told me that I need to code my web applications for working under the Suhosin PHP patch, Suhosin being "an advanced protection system for PHP installations [...] designed to protect servers and users from known and unknown flaws in PHP applications". Sense stating that feat...
For example, Objective-C, Swift and Ruby (i.e. RubyMotion) integrate with the Cocoa framework. Is this done via linked libraries? I assume they call functions in existing binaries instead of simply recreating some common interface.
I was given a task to prototype a Desktop Application with the ff. requirements: Must use javascript, nodewebkit, node.js Must be multi platform specially Windows and OSX Can take a screenshot of a certain area where a use can point and drag Must be able to watch multiple directories for changes Mostly 1,2,4 are poss...
Moinsen, I am somehow stucked in a design problem. Language is ANSI-C. Lets assume we have a tinkerbox of software-modules: one module for the logic Logic (at least) one module doing some logging Logger two modules, both giving a "frame" to let the program run, lets say one with a GUI one for commandline ... Theref...
Given an array of ordered pairs of values, what algorithm will find converse duplicates? [Converse meaning the same values, but in the opposite order.] That is, given [ab,ac,ad,bc,bd,ca,db] is there an efficient way to find ca and db, being the converse duplicates for ac and bd? The application is simple enough: the or...
I need help with organizing my arguments for why it's MADNESS to develop against production data. Backstory: I started working here six months ago and I noticed we're developing directly against production data. The codebase is local, but the database we're connected to is live data! So i have to be super careful const...
Context: Imagine you're writing a plugin to a program (let's say Foobar Plugin for Eclipse) and you want it to have an API which other people - such as the creators of Barbaz Plugin for Eclipse - can call in order to provide integration. ("Whenever a foo is barred, our plugin also bazzes it automatically! ... if the fo...
I'm struggling to point a finger into the right design pattern. I have a web site which user can register and interact with the system. I want to add the following abilities to a user: Each user will be in a stage. Let's say that we have 5 stages. when user is register, he will be in the 1-st stage. User will be able ...
The following is pseudo code, I tried it in Java and PHP and both worked: class Test { private int a = 5; public static function do_test(){ var t = new Test(); t.a = 1; print t.a // 1 } } Test::do_test(); Why can you do this in OOP paradigm and what's the use of it?
I'm struggling to point a finger into the right design pattern. I have a web site which user can register and interact with the system. I want to add the following abilities to a user: Each user will be in a stage. Let's say that we have 5 stages. when user is register, he will be in the 1-st stage. User will be able ...
The "value" ranges from 0 to 15 (its possible values). When will those 4 "if" conditions be met? If my (int)value = 2 does this mean 0010? if ((int)value & 0x1) { //statement here } if ((int)value & 0x2) { //statement her...
I'm in a situation at work where I have to transfer responsibility of a large code base that I inherited, re-factored and enhanced to another developer. This is the first time that I have to do such a thing and although I always thought it would be trivial the actual steps I have to follow seem vague. The code base I m...
We are currently refactoring our controller methods in ASP.NET MVC application. At the beginning we've separated data access layer (our goal was to remove LINQ from controllers entirely). Now we are thinking about another step - how to create a business logic layer to reduce number of lines and logic in controller. Cur...
I want to enable some real-time notifications about friend's activities (social network). Technical context is: Webapp calling backend (REST API's). Scenario is: Kevin follows Bob. When Bob posts a new comment, Kevin should be notified immediately (near real-time). Besides, when Kevin logs in, he should be able ...
I have an open source project (Cockatrice) that uses mysql for the server component. I'm planning some changes to the schema, but right now the only management I have is a script that runs the proper CREATE TABLE statements. Before I start rolling out changes I'd like to get a schema management solution in place. The a...
Let's say I am checking a directory for the existence of a file, and then depending on whether or not the file exists, I act accordingly. For example, see the two Python snippets below. if os.path.isfile(file_name): # do task A else: # do task B or if not os.path.isfile(file_name): # do task B else: # ...
There are IObservable and IObserver interfaces in .NET (also here and here). Interestingly, the concrete implementation of the IObserver does not hold a direct reference to the IObservable. It doesn't know who it's subscribed to. It can only invoke the unsubscriber. "Please pull the pin to unsubscribe." edit: The u...
We have decided to build separate applications for user authentication and user management. The reason is that the the former is a "this just needs to always work, and do so instantly" style service, and the latter includes a much-larger user-interface component with many requirements and features. Unfortunately, whil...
I've started a job as mobile lead in a 100employee company. Their Mobile products (iOS and Android) has been developed by external teams, and now they have decided to assemble internal teams, so I'm heavily involved in hiring ATM, both for iOS and Android. I will have teams of 5 people for each of the platforms. I've b...
Should the reporting logic to extract domain data in a certain format reside in domain objects or separate reporting objects? The reporting logic needs to: select entities/data which match selection criteria e.g. date range apply data validation rules e.g. date range, boundary values, missing values apply type of repo...
I just noticed that the FSharp.Core namespace includes generic array types of up to 4 dimensions, i.e. Core.[]<'T>, Core.[,]<'T>, etc. C# and VB seem to be doing just fine with System.Array - although it's not clear to me how they manage to support strongly-typed specialized array types like int[], string[]. I guess t...
I have an application where I have a set of core features. The application itself HAS to work in core only mode. I would also want to make the application extensible such that, when certain jar/plugin files exist in the classpath/installation location, additional features would be available, things would just be there...
First things first: I need to apologize in advance about the bad choice of title for this question, but I really couldn't come up with something meaningful. I'm actually looking for suggestions as to what this kind of problem in called, so that I can do some research on my own. I will gladly change the title once the s...
I am bidding on a government contract (my first) and there is a section requesting that I provide a high-level outline of a quality control plan that would ensure that the end product is ISO-9001 compliant. I don't know much about ISO 9001 so I am certainly doing my own homework and research on this, but thought I woul...
Abstract: So, as I understand it (although I have a very limited understanding), there are three dimensions that we (usually) work with physically: The 1st would be represented by a line. The 2nd would be represented by a square. The 3rd would be represented by a cube. Simple enough until we get to the 4th -- It is kin...
If I had a dime for every time I've seen this macro in use, today I would be coding just for fun: #define SAFE_DELETE(p) if ((p) != NULL) { delete (p); (p) = NULL; } Why do programmers insist in keep using this macro when delete checks for null? Is is because it sets the pointer to null at the end? Then why not at lea...
I use Volley to return JSON from an API. I parse this JSON and add StoreItem objects to a List, then use an adapter to display in a listview. I use the cache functionality in Volley, and I'm wondering how I can approach the issue of deleting/adding items. I know I'll need to make a POST/DELETE request with Volley to ac...
Disclaimer: I know that datatypes are a little bit subjective to which scripting/programming language you are using, I like to write in Python as a matter of preference; though I am happy to hear about any lanugage/implementation. What is the best datatype to store a three-state variable? Something capable or represent...
I have MS C# and MS SQL 2008 database project. It can capture employees' records with pictures of more than 1000 records. Presently, I'm able to capture say 150 records on PC1 using my installed C# application, save the records into XML or CSV file format. My friends are able to continue registration or entering (i.e f...
First I want to say Java is the only language I ever used, so please excuse my ignorance on this subject. Dynamically typed languages allow you to put any value in any variable. So for example you could write the following function (psuedocode): void makeItBark(dog){ dog.bark(); } And you can pass inside it whatev...
Please note that this isn't meant to be a Java vs. C# argument. I'm a Java programmer with no C# experience, asking just out of curiosity. I did some reading on C#, and it seems it has much more features than Java. A number of examples: Type inference. dynamic keyword. Delegates. Optional parameters. Lambda and LINQ (...
I have been asked to re-write an old C/C++ project in C++11. The old project is multi-platform, however, in order to deploy the system on other architectures the current process is to log into a remote service which has all the available target platforms (Red Hat Linux, Umbuntu, Sco Unix et al.) and build the .exe on e...
We have been using Team Foundation Server (TFS) for source code management of our solution which contains components for a number of platforms - asp.net, windows & android so far. We now wish to develop iOS apps for the solution but is there any integration possible between XCode and TFS? What's the best way to use TFS...
This may be an pointless question based on opinion, style, and context but I've been racking my brain trying to decide whether or not to make use of custom exceptions and would love to hear some pros and cons from anyone with experience from both approaches. For example I'm trying to decide between a custom ObjectNotFo...
At the place I work we are using a SafeReader class that wraps an IDataReader. One of the 'features' is that if the field you are trying to access wasn't in the query then it just returns a default value. So I am working with some code that is already in place, but apparently never fully worked as it accesses fields th...
You can find an endless list of blogs, articles and websites promoting the benefits of unit testing your source code. It's almost guaranteed that the developers who programmed the compilers for Java, C++, C# and other typed languages used unit testing to verify their work. So why then, despite its popularity, is testin...
I'm looking at using GCM to send notifications from my rails app to an Android app. The getting started guide says: In the resulting configuration dialog, supply your server's IP address. I'm using Heroku, so the IP address is changing frequently correct? Can I still use GCM? Was looking at using the rails gem and I c...
I know that when we speak about an array having 1, 2, or 4 dimensions, we mean arrays like this: 1: [0] 2: [0,0] 3: [0,0,0] 4: [0,0,0,0] ... Is the first 'axis' of an array the only thing that defines its dimensionality? Can an array with 4 dimensions be represented these ways? [0, [0,0,0]] [[0,0], [0,0]] or does th...
Consider the following Java code: public class HumanStateImpl implements HumanState { private boolean alive; private Color skinColor; // getters and setters, other state fields @Override public boolean isAlive() { return alive; } } Now imagine I want to have a class that represents Ha...
One of the code bases I work on has a development environment that is running on a dev server and cannot be copied over to my PC to locally test and develop. I am wondering what is the proper way to work with this code base? It is object oriented and I have found it to be very tedious and time consuming to do my work u...
Since what matters is not how the code does it but what it does, would you consider wrapping a function with a different name just to clarify it's behavior in certain situations a good practice? Real life example with pseudo-code: Let's say I have a small module to generate hardware signals. Now naturally one expects ...
I want to create a data access library that can build a DataSets with relations which can easily be written to XML with dataset.WriteXML(). This is a get to know C# endeavor that will hopefully gain me some productivity as well (lots of converting relational tables to XML from different data sources for document genera...
I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content management system with an existing MVC framework as well. This is going to be a little difficult to explain, so sorry in advance...
In .NET, it is idiomatic to suffix exception types with Exception. But most, if not all, sources I have seen for custom exception types in F# don't follow this idiom. Most seem to use the suffix Error. From F# For Fun and Profit exception MyFSharpError1 of string exception MyFSharpError2 of string * int From Microsoft...
I have been working on Software-Defined Radio projects for almost a year. This is an area which requires lots of signal processing (digital filters and FFTs), communication theory (modulation, equalization and synchronization) and information theory (specifically, coding theory, as Huffman, Linear and Convolutional cod...
This post from Python creator, Guido Van Rossum, mentions an early attempt to remove the GIL from Python: This has been tried before, with disappointing results, which is why I'm reluctant to put much effort into it myself. In 1999 Greg Stein (with Mark Hammond?) produced a fork of Python (1.5 I believe) that re...
The place I work at does the following: They manage a dev version of an app They manage another replicate version of that app, they call this the rep version The live version of the app that is running They believe branches are evil We are asked to manually copy paste the code from one version to another. What are t...
I am working on a web front end + front end services. I receive good sized csv files (10k lines). My service processes them and condenses them into one larger csv file (up to 300k lines). This larger file will be turned into an html/pdf report after some extrapolation. My questions are: Taking 17,000 files and turnin...
I'm currently taking course on introduction to algorithm and I came across the parallel mergesort algorithm. My question is: Is there any differences in the algorithm plan if it runs on a 2d mesh instead of infinite linear proccessors ? Thank you,
I'm designing within an application that I inherited. I have done a lot of work to "consolidate" the CSS which was extremely overworked through much copying and pasting without a lot of strategy behind it. One curious thing I found was to style ALL divs as: <style> div{ float: left; } </style> Do any other applicati...
I've used parts of source from an existing Java library project with what appears to be a 3-clause BSD license. I've made significant changes to the library which makes it possible to use it in a new platform, and also added several new features, and new example projects using the modified library. I want to know if an...
Recently some people said that I was wrong when I explained why one cannot insert a Number object into a list declared as List<? super RationalNumber>. (This assumes that RationalNumber is a subclass of Number) My explanation was that in List<? super RationalNumber> the <? super RationalNumber> stands for an unknown su...
Say I have a class workStockItem, that I wish to serialize. Which is the better style? using a static method or using a non-static method (maybe even implemented as a property as seen below) Example implementations: internal static byte[] serialiaze(workStockItem toSer) { IFormatter formatter = new Bina...
I am working on Android with the query() method of the ContentResolver class and it accepts 6 parameters, (uri,projection,selection,selectionArgs,sortOrder,cancellationSignal) for selection and projection parameters. I am little bit confused with the selection and projection part of query. In below example, what is sel...
I am building a scientific application in matlab which handles several hundred large matrices (large as in 'very few of these will fit into ram'). Each matrix is contained within a dedicated object to handle its metadata (the property's name is .data). I use the getter method to load the data from file into ram as soo...
Context of my question: I am reading C#. Trying to understand Static keyword. I understand that when Static is applied to a member of a class, it can only be modified by the class and not the class object references. I will take an example here. public class BluePrint { public static string BluePrintCreatorName; }...
Let's say I wanted to close my "GPL v 2.0 (or similar)" licensed project, to which I'm the only contributor, and make it closed source. Do I still need to make the existing "GPL v 2.0 (or similar)" licensed code available after closing the project or can I refuse giving out the source code for old revisions that was p...
For example lets take this method: public List<string[]> ReadAll(int listCapacity) { List<string[]> list = new List<string[]>(listCapacity); while (Read()) { list.Add(GetCurrentRow()); } return list; } If listCapacity is less than zero, an ArgumentException will be thrown by the construct...
There are some good examples of well-documented code out there, such as java api. But, a lot of code in public projects such as git and internal projects of companies is poorly documented and not very newcomer friendly. In all my software development stints, I have had to deal with poorly documented code. I noticed th...
When referring to or documenting a typical lock-free circular data structure (or class or object) used to communicate between arbitrarily long asynchronous threads or processors: "queue", "fifo" or "FIFO" are commonly used. Is there a technical reason why one term might be the more accurate or better communicative usag...
I've been working on a ASP.NET Web Api 2 project as a learning exercise, and I was wondering what the norm regarding commenting is. I use the Repository / Service Pattern, and everything is very much decoupled, which results in having a large number of classes whose purpose is pretty clear. I also name my variables in ...
I'm referencing this link about closures: https://stackoverflow.com/questions/111102/how-do-javascript-closures-work This is specifically about javascript. In the second answer with 956 votes, The author returns the nested function "sayAlert" after assigning it to the var keyword as shown below. (Example 3) function sa...
I'm not a native English speaker, currently I'm reading some articles about Scrum. I was wondering if the English terms used in Scrum seem strange to you? For example, backlog instead of todo; artifact instead of element; retrospective instead of review; even the name of Scrum, it make no sense to me as a process name....
I want to make the basic trigonometric functions in maths inbuilt functions using my own header file . so as the users can do trigonometry in c language compilers.
I have been using Symfony2 with Doctrine2 for some years. I have recently started using Microsoft's Entity Framework with MVC5. From my Symfony2 experience I understand that a repository's job is only to retrieve and return objects, no additional operations like Saving. Now every examples I have seen for EF has a metho...
Say I had a PHP page with a calculator interface, but I want to transfer the sum to Windows Calculator.exe and then get a reply from the application back to my PHP page, how do you go about doing this? I understand that the sum could easily be done in PHP and it would be pointless using another application, but I just ...
I have a class that basically builds up a memory-efficient version of a structure to be used in a performance-critical section of code. The resulting structure is ugly but extremely fast, so not using it isn't really an option, but I also can't use it as the only representation of my structure because it has parts not ...
I have a project built with Gradle, which contains libraries which can be used freely outside the main project, like this: The folders with a square at the bottom right are project modules. I want to opensource this project (I mainly use Git and GitHub for tasks like this), but I have no idea how to organize it. Shoul...
I have a database class with the following interface: public Database { //returns false if p (its ID) is already available //otherwise adds p the the list and returns true public boolean create(Person p); //returns false if p (its ID) was not found in the list //replaces the available Person q (q.I...
Haskell's type classes are a very powerful tool and give Haskell a great expressive ability, compared to functional languages that don't have them. When were they invented, and who invented them?
Over the past few weeks I've been mulling and researching how to fill a gap in our testing methodology. In simplified terms unit tests are too small and traditional integration tests are too big. A frequent scenario comes up where A and B both use component C. However A and B have slightly different requirements for,...
So after a while of working in programming field I still haven't figured it out how exactly should programs be structured, in a large set I mean. Which I think it's also because of working in an enterprise development. Say that I want to write a program, a messenger for a LAN network. How do I really know what classes ...