instruction
stringlengths
34
36.1k
I have been asked to develop a small game for a conference. The game isn't anything big and since I have had previous experience with SFML, I figured it would be the easiest to use. The SFML licensing page says that it may be used in proprietary software, however, it includes several other libraries that are licensed u...
I am working on a project that requires a series of flat files. I will be doing some data checking against simple date like: ID;StatusCode So a typical file might be like: 13993;R 38293;A 19349;I How do you decide if it makes sense to turn these values into a hash or if it makes more sense to just do straight string c...
I am writing a C++ application. Most applications read and write data citation needed and this one is no exception. I created a high level design for the data model and serialization logic. This question is requesting a review of my design with these specific goals in mind: To have an easy and flexible way to read and...
It might sounds like a silly question but here is my problem. We have 100s of databases and in each of those databases, there is a country table. It was ok this way but we ran into minor problems at some point like : the different tables were using different country code (2 letters, 3 letters), some country code were i...
In what programming language did the use of the percent sign (%) to mean modulo/remainder originate? This previous post1 explains that the symbol % was likely chosen because it includes a slash, clever for an operation related to division. It also mentions the influence of C's use of the symbol. However, I'm not certai...
I had given an answer on SO, the question was concerning a problem with a relative path. My answer was to use an absolute path, which I thought seemed simpler. The asker claimed to need a relative path, but I couldn't tell why. It seems reasonable that if you know to go to ../../../foo/bar/, then you would also know ...
I have a question about passing data using bundle between fragments. I need to pass the URL from a Product object to the next fragment, so I don't know which is the best approach: to pass only the URL or the whole object? What are the reasons of choosing one over another? Bundle bundle = new Bundle(); bundle.putString(...
I've been programming a C web server from scratch as an interface for controlling ESP8266 WiFi modules that I plan to use to control appliances & lighting with relays. In an attempt to make a user-friendly interface, I hope to implement auto-device discovery in an attempt to make the experience more seamless. In what w...
We have a lot of code in our internal codebase that calls our libraries internally - these libraries often have a lot of arguments (think matplotlib) and our code is often doing only a specific task and simply passes the **kwargs on to the next function called. E.g.: def our_method(dataframe, **kwargs): result = do...
I'm wondering what is the best practice for holding immutable data, more specifically in C#. For instance, lets say I have an immutable object called Foo. public sealed class Foo { public int Bar { get; } public Foo(int bar) { Bar = bar; } } Currently, I have been holding these objects in a stat...
Here is the Makefile I found on the internet for using rf24 on raspberrypi: ############################################################################# # # Makefile for librf24 examples on Raspberry Pi # # License: GPL (General Public License) # Author: gnulnulf <arco@appeltaart.mine.nu> # Date: 2013/02/07 (versi...
What's the current best practice around path parameters in URLs? For instance /artist/name A long time ago I might have made artist.html and then passed in a query parameter /artist.html?name=name but it seems path parameters are the standard (and nicer to look at). So assume I'm using apache, nginx, etc. Are these ju...
I was installing boost and I came across an option named "runtime-link". After searching a bit, I came across yet another complex topic: "runtime system" that according to Wikipedia: The runtime system is the gateway by which a running program interacts with the runtime environment, which contains state values that a...
I have been working on a project in JavaScript which requires a data structure (read only), to be shared between two functions. var mySharedData = ['hours', 'minutes', 'seconds']; Now I have two functions that need access to this (static) read only data structure. var sampleFunction1 = function(userSuppliedData) { ...
I am trying to follow the DRY principle in my programming as hard as I can. Recently I have been learning design patterns in OOP and I have ended up repeating myself quite a bunch. I have created a Repository pattern along with a Factory and Gateway patterns to handle my persistence. I'm using a database in my applicat...
I just started collaborating remotely on a project. Project manager explicitly asked me to download Dart SDK 32bit version. Since I have 64bit machine I asked why to find out more about it. I was told that "we're compiling the Dart code into Javascript that will then run within website/webapp. Therefore," he said " we ...
I'm developing a game, I will generate objects. I have create an interface called IObject which has the following properties: String tag // Tag for the object Vector3 position // Where the element is positioned Mesh mesh // This is how the object looks like Material material // The material from which the object is bui...
I am working on a +10k LOC program, and I need to ensure its output is always the same for given input. The program consists of dozens of modules and classes, inherited by a MainClass. (The examples below are very simplified compared to the actual code.) Initially I created tests ensuring multiple instances of MainCla...
I am trying to wrap my head around MVVM and "models should not have behaviour". If my getter depends on an environment variable, should it be in the model or viewmodel? Does it make a difference if that getter is specific to one viewmodel vs many? Also, I have complex setters that might have side-effects and logic. D...
I have created a Slackbot that integrates with Submittable.com. For example, I can trigger a response that displays all current submissions in Slack. I now need my Slackbot to post in Slack whenever there are any changes or new submissions on Submittable.com. Do I need to open a web-socket that is always listening to S...
Today I was reading my favourite C++ Programming book (C++ Primer Plus) and the section which was about variables and character sets in C++, however I got really confused about Unicode and Wide character set. Can anyone explain me why we should use wchar_t? and isn't it possible to use Unicode (\u) instead of it?
I am creating an application which uses ews-java-api to connect to an MS Exchange server. Once the connection is authenticated, the api dictates use of ExchangeService object for searching mailboxes, fetching mails and then reading its contents. The emails are read by different classes down the line for analysis and a...
I am in the process of designing and building a small web app. While implementing a first prototype I discovered that I make many unwritten assumptions about the behaviour of the interface. For example: When the user selects a product in the product browser, the product inspector quickly slides out the left side displ...
I am working on some numerical programming and need to generate the results for a model given a variety of input parameters. Since the model takes a while to run, I was planning to save the data to some sort of text/json file, so that I can just load the results later. However, since I will end up generating a bunch o...
I'm developing a client-server software for an enterprise customer. I'm being asked to limit the number of user accounts to a number N. Each user logs in with it's own username/password combination, and the customer's system administrator can create as many accounts as he wants using the Web interface. The web server i...
I have a Node.js Express RESTful HTTP server I will call server A and an Express socket.io server I will call server B. Server A responds to all HTTP requests by clients and server B listens to the MongoDB oplog and sends database updates currently to all clients. I don't want to send all DB updates to all the clients ...
We are building a suite of native mobile applications to supplement our existing application that currently only supports a web interface to the server. The application can be installed and hosted by clients on their own infrastructure or hosted by ourselves for clients who want to make use of it. Big enterprise custom...
I would like to ask how optimizer software written in C/C++ can be linked to simulator software written in FORTRAN or any other language. I have copied the section of journal article of Singh and Chakrabarty (2011). In the present study, MODFLOW 2000 and MT3DMS 5.0 are linked as independent modules with the optimi...
We have this code which, when simplified, looks like this: public class Room { public Client Client { get; set; } public long ClientId { get { return Client == null ? 0 : Client.Id; } } } public class Client { public long Id { get; set; } } Now we have three v...
I know there is Fitsharp for combining Fitnesse and .NET. And there is RestFixture to combine Fitnesse and REST. Is there a way to test a RESTful service with Fitnesse under .NET? If not, is there a different way to perform integration testing on web services?
We're designing a rest endpoint for retreiving name autocompletion suggestions for hotel names. Currently it's defined like this: GET /suggest/:term, so that if you queried `/suggest/hil' you would get responses like "Hilton Paris", "Hilton New York", etc. One of our colleagues argues that this is against REST API desi...
Situation I'm designing a database abstraction layer for sql (mysql, sqlite) and mongoDb. The goal is to give the user/developer a library which is able to create queries for different databases. Without even knowing which type of database is queried. Let's say we have a class which is able to create for example the w...
My windows service is neatly separated into 5 components - each with their own interface and pulled together by a bootstrapper. One of my requirements is to provide configuration options in my app.config for the different pieces of the application. I started with the following interface: public interface IConfiguratio...
How do you normally approach transitive dependency issues that occur at run-time in large software projects? For the past three weeks, I have been trying to start a component of a large piece of software within another component of the software, but it intermittently dies due to transitive dependency issues that are o...
C# 6 introduces expression-bodied members, which allow for simplified code in methods and properties that only return the result of an expression: public override string ToString() { return string.Format("{0} {1}", _field1, _field2); } becomes: public override string ToString() => string.Format("{0} {1}", _fi...
Currently my team has a number of constants defined as static final strings. I want to be able to iterate over these strings as if they were an enum in one location, but everywhere else they are used just as constant strings. The other developers do not want them as Enums because they don't want to have to add a .val...
This is more a design than an implementation question. I am aware of how to integrate a C++ DLL within a C# main app that acts as GUI. Believe me that I've read all other questions on similar topics, but none of them clearly answer my question, so here we go: I have a C++ DLL with a few functions that interact with an...
Right now we're implementing a (honestly overly complex) role-based permissions system where users will be assigned to roles and those roles will be granted permissions on some combination of resources. Fairly traditional, and I think fairly straightforward to implement database-wise by linking a table of users with a ...
I am having trouble writing a simple command based system for a chatroom. I want users to be able to do chat actions such as /j myChatRoom or /join myChatRoom /w user12 Hello or /whisper user12 Hello etc I've spent a while and all I can come up with are crazy substring and indexof searches, trying to chop off pieces of...
I've written a module in my application that creates a mesh from existing coordinate and face data. The number of vertices in the mesh could easily exceed 10 million and the same goes for the faces. The problem with the raw data is that the faces are defined by the coordinates of their vertices and not the index of the...
I have a list, to which I write once in every update Loop and then I spawn some tasks which create read that List and create a duplicate to manipulate that data. More or less it's List.ToList() call to create a new list instead of using it by reference. Each task manipulates that data in it's own and produces it's res...
I'm writing a Rails app which uses ActiveRecord ORM and a Postgres DB. I've got two attributes which are similar but are separate fields in the database. The assignment and saving of these is kinda complicated so I've put that side of things in their own method. The pseudo-code is as follows myObject.attr_a = get_the_s...
We use XML serialization to store class settings. Each setting-class has (but doesn't reference) corresponding implementation-class. Therefore we can easily make a "settings dll" without any dependencies. That's why there is no implementation code included inside setting-classes. What would be the best way to construct...
Generally when estimating using an Agile points system on an experienced project team, the points have meaning relative based on past experience - that take into account: understanding of the business domain skill and experience of the team obvious traps in the technical environment (service integrations and environme...
I developed a software application a year ago, I delivered it with a simple documentation. For example, it has an special and complicated login system as requirement. Now the customer calls and ask me to change the application for support a new kind of users, then I review (quickly) the tables, views and code that I ne...
I often come across situations where creating and editing actions are very similar, but they are not exactly the same story. So should they be handled as separate user stories, or as one? For example, I could have: Option A: US A1: As a system administrator, I want to create new user accounts so that I can specify wha...
Edit This isn't a question of whether or not the ternary operator is harmful. It's about whether or not there's a consensus about whether or not it should be used outside of assignment statements. /Edit Based on a boolean, I want to call one of two different functions (with no return value). I wrote this bit of javascr...
I am building an application in python with a python wrapper for WPF and with DAG support. I am currently at a point where I have to decide a consistent way of interacting between the data and the view. As far as I see there are currently two obvious solutions. First one is similar to how Android Applications are stru...
I have an MVC site which uses the repository pattern. I don't feel like I'm using the MVC style enough, so I'm getting ready to re-architect some of it. But I'm also wanting to do it so if the front-end ever changes, it will be easier to swap out. Here's what I have currently Models - some of my models contain my entit...
I am designing a simple ticketing system in Laravel 4. The system will simply allow a User to create a ticket, and an Administrator to answer it. The User will be able to: View a list of his tickets. Create a new ticket. View the replies to one of his own ticket. Add a reply to a one of his own ticket. Close a one of ...
How can I implement my cross-platform library (e.g. on JRE) to operate in a thread-safe manner on object references, so that native front-ends on other platforms can observe the object and take advantage of Observable patterns? A little background--there is a concept of data binding used in most front-end frameworks. I...
I'm trying to develop a small reporting tool (with sqlite backend). I can best describe this tool as a "transaction" ledger. What I'm trying to do is keep track of "transactions" from weekly data extract: "new" (or add) - resource is new to my app since my app may not have tracked this resource before as it hasn't bee...
I'm getting my feet wet with Android app development and tying to find a good way to manage database interactions across multiple similar objects. My goal was to have a structure like: public abstract class DatabaseObject{ public static abstract String getTableName(); public static abstract SQLiteDatabase getD...
I'm considering options for specifying an API in a code library (e.g., XML or JSON) that can be consumed by various clients. In addition to the standard kinds of input/output specifications, I'm considering including RBAC information to allow clients to make informed decisions about whether an API could be called in a ...
I have searched for this question, but I haven't found a good answer. Even the Wikipedia Article on URIs does not explain it thoroughly. I thought it was the protocol for accessing a web page. e.g. HTTP/HTTPS/FTP, but the wiki article says otherwise. Some URI schemes are not associated with any specific protocol (e.g....
Is there any reason (for instance: performance) against moving state "cleanup" code in a finally state? Example: this.state.InProgress = true; // logic here this.state.InProgress = false; With finally state: try { this.state.InProgress = true; // logic here } finally { this.state.InProgress = false; }
As per the title, should I be explaining syntax that I use in my code when I have a reasonable expectation that a developer looking at my code in the future will not be familiar with it? Short caveats or explanations could be added in-line while more complex constructions would be referred to by name and version number...
In C# for example, arrays have Length property. But other collection types like lists, etc. have Count property. Is there a reason why these two are different? If so I would like to know.
I'm trying to get a better understanding of the flux pattern Facebook introduced a while ago. From what I understand the dispatchers dispatches every payload to all registered callbacks. Does anyone know what the main motivation behind this broadcast is? Why not use something more like an observer pattern and only send...
Here's a quote from "Agile Principles, Patterns, and Practices in C#" By Micah Martin, Robert C. Martin Simplicity the art of maximizing the amount of work not done is essential. Agile teams do not try to build the grand system in the sky. Rather, they always take the simplest path that is consistent with their goal...
I'm in the middle of developing an asp.net webforms application to a customer, i've been using DataAccess and BusinessLogic layers in a folder structure within my application, in which my DataAccess classes use ordinary SQL queries to access the data. Then for certain reasons, for the remaining part of the project, I'v...
I have a conceptual problem that I want feedback on. First and foremost, the layout of my system. It contains a server, with many clients connected to it. The clients get fed data from the server at variable intervals. At the moment, this data contains: Faults, Warnings and Locations. Faults, Warnings and Locations all...
I understand the idea of package scope, and at times have even thought I wanted it. However, every time I set down with a serious intent to try using it I discovered it did not fit the needs I thought it would serve. My main issue always seems to be that the things that I wish to limit the scope of are never in the sa...
I am just beginning to develop in Dynamics AX 2012, using X++ (my background is .Net). The development environment in the application stores all classes for the application in one long classes list. I had started out creating several base classes and sub classing these to implement several features to read a file, par...
This is kind of philosophical question... Today i spent way too much time to debug a method which was generating a SQL command. I figured out the error was because the code was generating something like: WHERE X BETWEEN 10 AND 5 which wasn't returning any value, while the correct form was: WHERE X BETWEEN 5 AND 10 My...
Consider the following code snippet: -- list_1 = [1, 2, 3] -- list_2 = [4, 5, 6] final_list = list_1 ++ list_2 result = map (+1) final_list Is the time spent by it proportional just to the length of final_list, and the price of list concatenation is not paid? My idea is that concatenation is done lazily; to quote th...
When I have an Object that has lots of fields is it better to have them all as fields or try to find logical groupings as their own Objects and make those the fields? I guess it comes down to which is the greater evil, too many Objects or too many fields in an Object. Less Objects, more fields: public class LotsOfField...
I'm developing realtime web chat using pubsub pattern. To be concrete I'm using python and tornado-redis on back end and websockets (WS) (tornado) on front end. I have WS connection open and close events. So I stuck with the problem what is the best solution to store current online user list. Here are some theses: I w...
I'm working on a library that contains a large number of components that have namespaces that are nested. Also, when a new module inside the library get's added, we then have to add the namespace and sometimes this namespaces can change and then it becomes hellish to maintain. I have been thinking of a solution or app...
This is my situation I have a website, mobile client and desktop client. They can all pretty much do the same operations (website might be able to do more now but in the future they might have the exact operation set) The technologies varies: for website ruby, for desktop c#, for mobile objective c and java I am wonder...
Some times I need to modify an array key for example something like: $temp = array(); foreach($arrayIWantToModify as $key => $value) { if($value % 2) == 0) { $temp['odd_' . $key] = $value; } else { $temp[$key] = $value; } } I always use a temp array to achieve that, but I had a memory probl...
We need a JSON Schema Validator for .NET. The only library that we found is Newtonsoft Json Schema. The problem with this library is that has a "strange" AGPL license with limitations, from the site: AGPL 3.0 : Free with limitations (1000 validations per hour) Otherwise we should get a commercial license for each de...
I have a question on modelling an Entity\Aggregate root in DDD. I am refactoring a project that uses Entity Framework and business logic as services, the services contain lots of logic which I believe should be in entities in DDD. public class Contractor { public int Id {get;set;} public DateTime ContractStartDa...
Say I have an interface Species that's defined as public interface Species { String getId(); String getDescription(); } The question is simply this: Should I create different classes to represent these two fields, even though it does not add additional clarity to the code? For example public interface Specie...
First of, sorry for the vague title. In our website framework, we have modal classes to represent our database tables, that hold a rows data. I'm currently working on a stat style page, and I'm wondering how other programmers handle linking lots of models together. For example, on the page, I'm listing all Customers, w...
I am reading a book on architecting enterprise applications. In this book the Event Sourcing pattern is introduced which can be used as the "command" part of a Command and Query Responsibility Segregation (CQRS) architecture. Event Sourcing is described by Martin Fowler as: The fundamental idea of Event Sourcing is th...
I'm trying to determine when a web application should query a database for related data that may or may not be used in the current request. As an example, consider a database that tracks assets for a company. There is an Assets table, an Owners table, and a Users table. Assets may be assigned to an OwnerID, and Asset...
I work at a small web development company, and we use no dependency management whatsoever at the frontend side. External libraries are simply downloaded and pasted into the lib folder of whatever website needs them, and our own libraries are happily copy-pasted. All websites are built on ASP.NET MVC. Recently I was ask...
In C, you'd often/sometimes (as a matter of style) use a file-scope static variable where you'd use a private class member variable in C++. When scaling to multithreaded programs, simply adding thread_local in C11 or the long-supported extension __thread fits well. I know you can do exactly the same in C as C++ by putt...
Take the data from the Oracle scott database. I have modified it to have multiple levels of management from the original, select * from scott.emp order by mgr desc; empno ename job mgr hiredate sal comm deptno 7839 KING PRESIDENT 11-17-1981 5000 10 7369 SMITH CLERK 79...
My general feeling is that this is a question which must have been answered but I am struggling to find resources for it. I know little about mobile app dev but my knowledge of web services is pretty good. We are looking to expand our existing software suite to include a mobile app. Each client has the software and da...
What advantage(s) of string literals being read-only justify(-ies/-ied) the: Yet another way to shoot yourself in the foot char *foo = "bar"; foo[0] = 'd'; /* SEGFAULT */ Inability to elegantly initialize a read-write array of words in one line: char *foo[] = { "bar", "baz", "running out of traditional placeholder na...
I'm evaluating a library whose public API currently looks like this: libengine.h /* Handle, used for all APIs */ typedef size_t enh; /* Create new engine instance; result returned in handle */ int en_open(int mode, enh *handle); /* Start an engine */ int en_start(enh handle); /* Add a new hook to the engine; hook ...
I've been trying to learn domain-driven design (and similarly Onion Architecture) the last week or so. I think I've got an understanding of it, but like math, I suck at extracting all of the details... So, I'm designing/building an ASP.NET MVC application (building a site to promote game jams), applying DDD to the proj...
I am trying to build a rest API for an android app. Suppose I have a users table with (id, name, email) and a songs table with (id, song_name, album) and a rich join association between them as streams having (user_id, song_id, listen_count). I want to fetch details about all the streams and show it in the app as a lis...
The established procedure regarding releasing code out in the open is to accompany it with a license. Out of the many flavors that exist (BSD, MIT, GPL, LGPL, Boost ...) there are some that prohibit using the code in proprietary software, unless you pay an agreed fee ofcourse. I have two questions on this : How is s...
I have few UI components in an angularjs web-application. Each display data based upon same input. One shows stats which are calculated on the basis of a time period. Other shows a chart of daily progress of all of those stats in the given time period. I have designed both the components in such a way that they make th...
I'm currently writing a web service that will be consumed by an android app. To access user specific content, one must authenticate against the service. Since I'm not (primarily) using a webbrowser to make calls to my API, a solely session based authentication is not an option. I don't want to pass the users credent...
In an object oriented module describing a database, should I pass DB description data structures to the constructor in the constructors of derived classes, or should I instead create ("virtual" that is dynamic) methods which create the data structures and call them in the constructor? These data structures are long (ar...
Trying to clearly state the semantics of a function call. In calling a function, are the arguments passed to the function the ones the calling code initially gives or the ones the function receives? With code like below, the calling code in bar() calls foo() twice. This first time with int 2, then ... 1) Function f...
C# 6 is here for a while now and brings with it some syntactic sugar that Resharper is kind enough to highlight and recommend that I "migrate to". Should I apply these fixes automatically to the entire code base and commit? Even though this question can apply to any new feature in the language, the main ones I'm consid...
I was inspired by a video on hotswapping JS files with React + Webpack for the web. I started trying it out with React + Backbone + RequireJS. Seems to work, as long as I stick to the stateless parts of the code. I get really confused however, when I start thinking about what would happen if I swapped out some JS code ...
I am very new to web development and am trying to create a website using client/server model. From what I understand, the front-end (client-side) calls URLs specified on the server to get information. So if my website was www.example.com, when the user clicks a button on my site, a request will be sent to www.example.c...
I'm having trouble defining this data pattern I've come across working on several applications. It consists of: An object type which is composed of many objects itself A second object type, where each instance 'has many' of the first object And, each of the sub-objects of the first object are modifiable per each asso...
Sometimes, when I'm programming, I have to decide between adding a static method to a class that accepts an instance (or more) of that class or adding a non-static method. Here's an example: Static public class Integer { // ... public static Integer add(Integer a, Integer b) { // ... } // ... } ...
I recently ran in to this common invalid operation Collection was modified in C#, and while I understand it fully, it seems to be such a common problem (google, about 300k results!). But it also seems to be a logical and straightforward thing to modify a list while you go through it. List<Book> myBooks = new List<Book>...
I am looking for some clarity and hopefully some advice on writing clean architecture for a large system. My Companies "Web Solution" is +-10 years old, my job is to rewrite it. It is written across a few thousand asp classic pages all with their own sql queries with absolutely zero consistency (I spend the vast amount...
I am currently learning about Event Sourcing via the book Microsoft .NET - Architecting Applications for the Enterprise. Event sourcing is, in my own words, an architectural pattern of storing "events" instead of "current entities". Current entities can be created by looping over the events belonging to it. The problem...
I was reading this. It says that Some people believe that the purpose of inheritance is code reuse. In C++, this is wrong. Stated plainly, “inheritance is not for code reuse.” The purpose of inheritance in C++ is to express interface compliance (subtyping), not to get code reuse. In C++, code reuse usually comes via c...
I understand how to convert infix to postfix/prefix but I do not understand why postfix or prefix expression are used in computer system? What is the advantage of postfix prefix over infix expression?