instruction stringlengths 34 36.1k |
|---|
I have a script which starts from cron with regular interval and sources in around 10 variables. Should I keep those 10 variables in one configuration file in file system or is it a better practice to keep a separate configuration file for each variable? What are the advantages of one approach over another?
|
I want to maintain a buffer of 5 seconds of sensor data.
The sensor data consists, among other things, of accelerometer readings in x,y,z dimensions, gyroscope readings in x,y,z dimension and magnetometer readings in x,y,z dimension.
My initial idea is to use an std::deque<SensorReading> which stores 5 seconds of the ... |
I am developing a web based application which is about tracking Fleet units.
Actually i have already developed the system but in the last six years things changed a bit. Ordinary the software specification was about monitoring vehicles in real time and then doing various reports.
How ever during the years we got so man... |
I have once started a MVVM/WPF project, which was eventually built and deployed, and for that I studied a lot of the Caliburn.Micro MVVM Framework. The fact is: I ended up not using Caliburn.Micro for that, and ended up implementing some MVVM concepts myself (specifically, just the ViewModelBase and RoutedCommand class... |
We want to add error feedback to our application. I had a look at existing solutions (e.g. raygun.io), but these work "in the cloud", which is a no-go for us:
most installations of our application are offline, so we will need to export the collected logs to a file and then send it per email.
I don't feel comfortable u... |
I currently work with a young team of developers using ASP.NET, TeamCity and Octopus Deploy. One of our developers thinks that our system is flawed and introduces the inability to test production hotfixes. What is the best solution to this problem?
We have three environments: development, staging and production. Basica... |
My boss is the db administrator in a new software project and he came up with that design where every table will have both a auto-increment clustered key and a guid primary key (or possibly composite guid keys on some rare cases). Every relations between tables will still use pk as references, making the clustered fiel... |
As per the below diagram, except for interface Iterable, all the remaining constructs (interface / class / abstract class) sit in same package java.util
Why does Iterable sit in java.langpackage?
Note: The intention is to understand the packaging aspect of java programming.
|
As per this link, it is an advice that:
A good object should never change his encapsulated state. Remember, an object is a representative of a real-life entity, and this entity should stay the same through the entire life of the object. In other words, an object should never betray those whom he represents. He should ... |
I'm trying to read the parser of PHP, that says:
top_statement_list:
top_statement_list top_statement
| /* empty */
;
It is a left-recursion, but why it don't looping infinitely?
My question is because I'm trying building a parser for study, but I don't know how code that. Maybe it is similar to (regex-... |
Is continuous integration about more than just automatically testing code, either periodically or after every commit to the main repository?
Before today, I'd heard the term CI, and about CI services such as Jenkins, and RunCodeRun, and assumed that it was merely about having a server independent of developers' machine... |
Let's say we are building a document management system.
One project has many documents. I decide to make projects as aggregate root.
If the logic to add one document into project is complicated, I can put it in aggregate root like:
class Project
{
public function addDocument($params){}
}
But I can also make this j... |
I am sitting through a very well-explained and thorough video tutorial series, using Visual Studio 2012 as my developing environment.
Anyway, one thing that is hard to figure out is this. Say you have this code
static void Main()
{
int[] myArray = {0, 1, 2, 3};
Array.Reverse(myArray);
foreach (int it... |
I'm implementing a program where the user can 'create a musical scale' from a variety of notes (identified by their names), and the program will generate music from this scale.
I want to implement a class that takes a note and a length, and generates a SoundWave. So one option would be to expose the following method:
p... |
I was reading Effective Java, and I came across passages that talk about ways you might implement a serializable singleton, as if this was a perfectly normal thing to do in Java. This immediately baffled me, because my intuition says that:
Being serializable necessarily implies value semantics.
Being a singleton neces... |
I need to write a RandomQueue that allows for appends and random removal in Constant Time ( O(1) ).
My first thought was to back it with some kind of Array (I chose an ArrayList), since arrays have constant access via an index.
Looking over the documentation though, I realized that ArrayLists' additions are considere... |
Often times in programming, we need to represent some value which can easily be represented using a simple primitive type.
For example, in a game we might need to represent the velocity of a moving object. This could easily be represented with a double value. This object might also have a value of mass; this can also b... |
I am building an API for minecraft called the Quantum API. We all know that reflection can be used to do some nasty stuff to classes, and even cause undefined behavior if used without care.
Is there a way to make classes and objects immune to reflection? Perhaps with a security manager? Or vice versa, restrict a certai... |
This is a direct follower to this question. An answer given to that questions says (my understanding), that nowadays using string-based enums instead of integers isn't a much problem, because hosting costs and general DB costs are today much, much lower, so we can afford for some "database size waste" (generalization).... |
I am trying to identify the parts of an architecture.
The server (Python) acts as a web-service, delivering files and data. The client (JS) requests the data which it needs by sending xmlhttprequests to the server.
I read that there can be a "middleware" layer that connects the application with its node of the distribu... |
I have a class that is backed by a double value, and I am wondering about accessor method names that preserve abstraction. Based on my experience in Java, there seems to be at least two precedents:
toDouble(), which mirrors toString()
doubleValue(), similar to Double.doubleValue() and BigInteger.doubleValue()
I need ... |
Our db is optimized for minimum join count (partially denormalized). E.g. our User entity contains account data (nickname, facebook id, etc), user numerical statistics (total games played, total wins, etc), guild related user information (guild id, membership type, etc) and so on - everything in the same table.
We use ... |
Lets say I have two arrays A and B
A = {1,2,3}
B = {12,11,67}
and have max sum value S = 10
How many maximum number of unique pairs can be formed between the two arrays who's sum is less than or equal to S.
For e.g., the two possible values here are [1,11] [2,12] hence the answer is 2. If there are none, the answer ... |
I am building a script that checks a large network of sites for invalid links. The idea is to flag links that continuously show as not available so that they can be cleaned by the administration team.
The basic process is this:
Grab a set of pages - approximately 30K per day, not the same 30K each day - and extract al... |
This question confirmed, what I was already aware of -- instead of directly storing strings in table, I should rather use integers or enums and join them with lookup table, to get, as a result, string, that I actually want.
But, why should I use lookup at all? If I'm getting an integer from base table, what prevents me... |
I would like to create a plugin system to allow new controllers to be added at runtime. These will be api controllers and not views.
I know I can add controllers from other assemblies at startup by using the following and this works.
public void ConfigureServices(IServiceCollection services)
{
//Add Controllers
var... |
Suppose that there are two classes that define objects of vastly different function such that in the datastore, the information they require is divided into two separate databases.
For example, the classes Employee and SteelExtruder may be placed in the databases `human_resources` and `capital` respectively. Rather tha... |
When applying the interface segregation, should you have separate interfaces for a straightforward setters and interfaces that perform an operation before setting? For example, say you have a class:
class FooClass:
public GettableFoo,
public SettableFoo
{
virtual int getRelevantData();
// member of... |
Fair warning, I'm new to functional programming so I may hold many bad assumptions.
I've been learning about algebraic types. Many functional languages seem to have them, and they are fairly useful in conjunction with pattern matching. However, what problem do they actually solve? I can implement a seemingly (sort-of) ... |
Given the following problem (a slightly simplified description of trading in the computer game Escape Velocity: Nova (system map)):
Given a set of (solar) systems.
Each system is connected by hyperspace travel route to one or more other systems; each route connects two systems.
Making a hyperspace jump has a cost in d... |
I'm designing a library built on web scraping that tries to provide an API to a popular news site. I am representing each of its articles as a collection of 'elements' (IElement), such as images, videos, blocks of text, soundtracks, etc. The problem is, I can't think of anything each 'element' has in common.
Text? Nop... |
I would like to ship test code alongside a product. Specifically, provide an option so that anyone with a copy of our program can hit a "self-test" button or pass --self-test on the command line and run through the complete suite of unit | integration tests.
I mostly want to do this to help debug problems discovered in... |
I want to fill a circle with alternate colors like a lollipop by drawing circumferences of increasing radius on a Cell matrix. I am currently using the Midpoint circle algorithm to get the points. The problem I have is that there are some gaps when filling a circle this way.
In the example below (original is number 1) ... |
I've got some code that has a sequence of ifs that work, but just feel messy. Basically, I want to choose the largest of three integers and set a status flag to say which was chosen. My current code looks like this:
a = countAs();
b = countBs();
c = countCs();
if (a > b && a > c)
status = MOSTLY_A;
else if (b > a ... |
If you are updating a variable in a RESTful API, for example person's weight, how should this be laid out?
What I have thought of:
PUT /person/1/weight?weight=150
PUT /person/1/weight
{"weight": 150}
PUT /person/1/weight
150
There's been a few answers on this but I don't feel like it's been answered in a clear, solid... |
I am working on a control-panel for a VoIP program and I've been working on it for a while. It started off as a small project that I just did because it was fun, but over time I added more and more features and it has now become something quite complex.
I have a file called functions.php and it contains functions for h... |
Most of cloud computing technologies are based on virtualization. The advertisement of cloud computing technologies often refers reliability and reduction of costs. But when compared with container technologies such as Java VM, live migration and hardware abstraction of virtualization is much more difficult.
So what is... |
When using an enterprise service bus, is it responsible for;
a. the successful delivery of a message to a consuming application
b. to successfully deliver a message until the application's logic completes successfully (up to a retry threshold) ?
c. something else
With RESTful calls, a request will always have a resp... |
I'm trying to write a generic function summ in rust - but to no avail. Could someone please elucidate the problem?
fn summ<T:Add>(a:T,b:T)->T {
a+b
}
|
We finished the development and closed the sprint(two weeks). But the code has not been reviewed. So in the third week we don't start a new sprint and keep clean up(refactor) the code. The scrum master told us that we can still log the time to the previous tasks.
My question is that since we close the sprint, does it e... |
I've been searching for so long about how to design testable classes in Swift but every information site just describe basic stuff like how to test, how to assert, why is testing good...
My current design (which I'm not so sure is the best) includes a singleton ApiClient class that gets initialized on the AppDelegate.... |
I am debating this with myself. Does NHibernate's ISession offer a proper and correct unit of work if used without a transaction? In absence of a transaction, every SQL command would be wrapped by the database server into a different transaction. So there is still a chance that in a batch of 10 SQL commands (flushed fr... |
In all the Service Bus examples and tutorials I've seen, they cover publishing a single message to a single Topic that is picked up by a single listening Subscriber. Whilst this is good for a simple practical overview, it doesn't really explain how Topics should be used in the real world.
I have a large ecommerce appli... |
I have a couple plain object classes to represent data read from a file. They look something like this:
public class Command {
private String name;
private List<Message> messages;
}
public class Message {
private Type type;
private Map<String, Object> params;
}
with getters and setters for the variable... |
Currently working on an ajax call to an ASP web service (.asmx).
In a situation where I POST to the url/.asmx/WebMethod, am I exposing information of any kind?
In the 'WebMethod' I am running a PostJsonAsync that calls an API and passes along a json string.
As I am still learning, I've been told that calling any public... |
I am planning to develop a new application that will heavily use a library that will be developed from scratch specifically for the application, but made general enough for it to be used for other programs once it's finished.
So the development of this library is going to be heavily driven by the development of the app... |
I have three functions:
ValidateUsername(), which determines if a string is a valid username according to some rules
SetUsername() which sets a string as a user's Username if it passes validation
AddNewUser(), which creates a new user and, among others, sets a string as his or hers Username using SetUsername()
All th... |
I'm trying to find a good design pattern, or perhaps series of patterns, for injecting error handling and retry handling when getting data from a webservice.
For instance, I have:
do {
//get the data here
data = Datagetter.getMyData(request)
if(data.hasError())
{
//handle error
}
} while(s... |
I'm using a Python library which is currently under GPL3. The maintainer has decided that he would like to change the licence to one which does not contaminate larger works (probably either the MIT licence or MPL2 if that makes a difference).
The question is how does he go about changing the licence? In particular, obt... |
Our application queries the database primarily using Linq queries backed by Entity Framework but we sometimes call legacy stored procedures. Sometimes we want to replace an existing stored procedure with a Linq / Entity Framework query. Is this possible to do even if the stored procedure uses temporary tables? If so... |
I've been working on refactoring some code, and I think I may have taken the first step down the rabbit hole. I'm writing the example in Java, but I suppose it could be agnostic.
I have an interface Foo defined as
public interface Foo {
int getX();
int getY();
int getZ();
}
And an implementation as
publ... |
I'm trying to play around with the 6 degrees of separation problem, specifically the Kevin Bacon game to find alternative ways of playing the game. I want to eventually port it over to MapReduce, but for now, I'm concentrating on plain old Java to get a solid understanding of the problem.
Basically I have a working pro... |
Background
I have a Web API 2 project, without any extension of ASP.NET MVC or ASP.NET projects. The API will only be used to communicate between the server and Windows 8, Windows Phone 8.1 and iOS applications. No website will consume the API. The API makes it possible for a user to manage products in a warehouse. A u... |
Suppose I'm reviewing code that job applicants send to prove their skills. Clearly I don't want to run executables they send. Not so clearly I'd rather not run the result of compilation of their code (just for example, Java allows to hide runnable code in comments).
What about compiling their code? I want compiler warn... |
What would be better DB design for a social network website.
A single table with more columns and less rows or multiple table with fewer columns but more rows.
For example:
User can post an update on their wall or in a group.
Two DB designs that I could think of are:
1)
UserPosts: id, userId, post, datetime
UserGroupP... |
Interested in some opnion...
I'm introducing unit testing of JS into a team, it'll largely be testing modules with many dom interactions and updates.
Traditionally I've always used mocks and spys when testing libraries such as jquery, but as this is a team new to unit tests I thought fixtures may help them to get up an... |
According to Wikipedia, Eric S. Raymond said that one of the 17 Rules of Unix is the "Rule of Generation", stating that:
Developers should avoid writing code by hand and instead write
abstract high-level programs that generate code. This rule aims to
reduce human errors and save time.
How is this rule to be inte... |
In our application we have several transactions, where each step is extensively logged.
Pseudocode:
@Component
public class OurServiceImpl implements OurService {
...
@Transactional
public void doComplexTransaction(...){
String transactionId = generateTransactionId(userid, date)
log.info("========... |
Context
Due to the statelessness of the REST architectural style involving that each requests stands completely alone, leading server to never store any informations about client.
Thus, pessimistic concurrency control are not suitable because it would requires that server store which client gets the lock on a resource.... |
I'm reading through The Mythical Man Month for the first time. In it, Fred Brooks* proposes a model of software development based on how a surgical team works. There is a "surgeon" (a senior developer) who does almost all the design and implementation work, a "copilot" who discusses these ideas with the surgeon and occ... |
I am currently reading "The End of Error - Unum Computing" by John Gustafson (Youtube). What I am still not sure about is how the cases handled in IEEE by negatively signed zero are handled with unums.
So, first of all, unums permit to represent certain exact values (similarly to floating points) and additionally permi... |
I am writing a finite state machine in C++, designed as a library.
Furthermore, I have a GUI implemented as a separate project which needs to update the user interface according to state changes happening in the library.
The way I implement the communication now, is that the GUI is calling a library function which re... |
I am wondering if there is an established standard or protocol when working with APIs for document management systems or ECMs. For example, let's say I'm working on a new product and I want it to have support for both FileNet and Documentum. Is there a protocol established across the major ECM systems that I could targ... |
I have a fairly large piece of software which takes certain file types and visualizes them / creates a host of buttons for manipulation of the image plotted. I feel like I'm finding bugs / pieces of code that don't actually work once a week, but I'm struggling with understanding how can I write tests for this software?... |
I tried to make the question title as generally applicable as possible, but I'm not certain I worded it so well. It was brought about by a very specific problem I'm having, and for the remainder of this question I'll just try to describe that.
I'm attempting to write a small game engine with graphics, physics, and coll... |
Note: When I say "open source", I am talking about GPL. Substitute with "free" if you prefer. When I say "closed source", I mean "not GPL or MIT, etc".
We have an open source (GPLv3) webapp that we develop and sell support and hosting for
(similar model to redhat).
Note, this isn't a website that we host that happens... |
I have a class that is responsible for performing conversions from/to twenty-something types. Let's call this class ConvertUtils.
For C# programmers out there - this class expands .Net's Convert class.
It looks something like this:
public static class ConvertUtils {
public static object ChangeType(object obj, Type ... |
I have an BallEntity class that is part of a game that uses a Entity Component System architecture.
This class have 'components' that are like the attributes of that class.
I create and initialize this components in getComponents method. To build this components I need others objects, like a Sprite (that is the image ... |
I was looking into how to optimize web pages and the biggest way (code-wise) to optimize a website is to reduce the number of requests a browser has to make to your web server to get the full page.
The most obvious ways of doing this are:
Sprite sheets instead of individual images
Put all your css into one file
Put a... |
Lets say i am writing a web app that accesses user accounts in a database. If the account exist use that data. But if the account doesn't exist create a new one.
Should this be done with two or one methods.
One method would search by name and if found get the account, but it would have a try catch block and if the quer... |
I am working on a Website and trying to decide if I should create separate thumbnail image for each image user uploads. Or just set a smaller width/height when displaying thumbnails.
I am planning to set a limit of image size to 2MB.
Any suggestion?
|
I'm writing a game in C++ using OpenGL.
For those that don't know, with the OpenGL API you make a lot of calls to things like glGenBuffers and glCreateShader etc. These return types of GLuint which are unique identifiers to what you just created. The thing being created lives on the GPU memory.
Considering that GPU Me... |
How should one unit test a function which (among other things) maps an integer to a string?
If the function were to map 0 => string0, 1 => string1, 2 => string2, should I test for each of 0, 1, and 2? Or should I just test one of these cases?
|
Today I was corrected for mentioning "External Merge Sort" as an example of a divide-and-conquer (D&C) algorithm and after doing a lot of research online and in the most prominent books on algorithms, I started to realize that External Merge Sort is usually placed in their own separate categories and never referred to ... |
Let's say I have the following classes, auto generated by Entity Framework, that have an association:
public class Parent()
{
public int ParentID { get; set; } // PK
public int ChildID { get; set; } // FK
public string Description { get; set; }
public Child Child { get; set; } // Navigation property
}... |
I was a TFS User where we had a single Solution with multiple Projects and one developer can check out his project when they need. Also the Build system can do separate build for each Project or entire solution at once.
The Project structures include “App” (Mobile App), “Web API”, “Client” etc. There may or may not h... |
I'm refactoring an old app to use dependency injection.n I'm pretty new to DI.
I have a class that used to be a singleton. I'm refactoring it into a non-singleton class and using the container to manage its lifetime (as a single instance). It has some initialization that used to be done in the constructor but it see... |
Our system is structured in such a way that we get a lot of key info for our calculations and other such logic from lookup type tables. Examples would be all kinds of different rates (like interest rates or contribution rates), dates (like effective dates), and all of kinds of different misc info.
Why did they decid... |
Take the following example:
public interface ISerialRVD
{
RouteValueDictionary ToRVD();
}
public interface IViewModel : ISerialRVD // Here?
{
Int32 Page { get; set; }
String Action { get; set; }
}
public class myViewModel : IViewModel, ISerialRVD // Or Here?
{
}
I understand that if I make IViewModel in... |
I am a member on the QA team but tasked with majority of the management of the Jira instance. We have launched our product on one platform, and will be starting to develop it shortly on 2 more platforms. I am primarily concerned with just the bugs on the database for this reason. Tasks etc are used elsewhere and I only... |
I'm wondering how to handle a ViewModel in the traditional sense, which includes both properties and methods, and another "view model" which is simply just the properties -- perhaps the ViewModel would return a this view "entity", or something.
Let me explain:
Domain Model:
public class Workout
{
public int Id { g... |
I am constructing a new class which handles deciding which class should process the requests from a web service. I'm looking for a solution for a problem that I am having regarding extensibility with this new class. Each request will be processed differently, and the logic for processing them each are in their own cl... |
I'm working on a Soccer management game. Project is fairly new and small and I'm new to PHP. The project was starting to get a bit messy so I've been looking into refactoring. The first thing I've done is to make my functions smaller, which helps a lot. I also added my functions to my classes, since they were originall... |
The company I work for already has a fully functional web app that is written in java using JSF framework. I'm now in the process of creating a mobile version of this web app and having some general questions on where to put this mobile web app.
Should this mobile web app be a separate project, packaged in a different... |
I've been researching micro-benchmarks (e.g. using JMH or Caliper, though not necessarily limited to Java). Now, there are many articles which describe how to write a benchmark but I haven't found much on when to write a benchmark (and when not to). There were a few things that go in that direction, e.g.
Continuous de... |
Lets say that we have a user (like super-hero) that want to see all wars that is going on in a world so that he can stop them. He can't prevent them all, because he needs to sleep sometimes and so on. But if a war have happened when he was asleep, he wants to know about that (so he can punish ones who started it for ex... |
I have been told that flag arguments(boolean arguments) are a bad thing because it complicates the signature of the method and means that the method does more than one thing.
An issue I have with this rule is what if I have a html factory class that builds raw html from arguments passed in. Then lets say I want an opti... |
So I'm trying to implement a lazy-evaluating data type (in PHP, though that shouldn't matter any) where you can queue up actions to take on a set of data. This data can come (theoretically) from any traversable object: arrays, generators, and other iterable objects.
So for instance, given a $collection object containin... |
I am building a very simple email templating system in C#, and it works amazingly, but I have a personal issue with the way I designed it:
Template looks like this:
Hello {UserName},
Welcome to ....
And the way I am replacing the tokens with values is this:
foreach (var variable in variables)
{
str = str.Replace(... |
Hopefully Iʼm posting this in the right SX, and Iʼve tagged it correctly.
I have a legacy system that Iʼm making additions to which contains a custom list object.
This list object can contain two types of elements, another list, or an item.
Part of a current task requires that I make an adjustment to the list in such a... |
My app's launcher activity checks a bunch of requirements like whether GPS is enabled, there's a network connection, the app has device administrator privileges, etc. Some of these checks display dialogs or take the user to another activity to resolve the unsatisfied requirements. I'm looking for a way of doing this ... |
I'm in a place were I know how to build apps and have submitted at least 5 for different clients to the app store and wanted to step up my game. So of course I went to Apple resources and analyse the code deeply (I've used Apple code resources before but just to find answers and move on). And I realised their code is r... |
I stuck somewhere that I can't find a solution! There are plenty of validation questions here, but as far as I see, most of them were asking about entity validation. But what about request validation?
I'm developing a service for web application. Basically I have 3 modules which are Web, Domain and Repo. A request for... |
Why in Objective-C we should be typing explicit references to methods like stringByAppendingString to concatenate strings, when in some other languages we can use operators for that?
For example, Java and C++ let us just concatenate strings in a similar fashion to the way we make our programs add two numbers.
|
How to log method calls on a per object basis for a particular class?
I.e. after instanciating a = myClass() I somehow want to keep a log for what methods have been called on a like
a.reverse()
a.loadNewData()
a.substract(somenparray)
later I want be able to look at this object's history/log e.g. a.log().
All logging ... |
I'm experimenting a little with creating a socket server, in PHP. In doing so I'm trying to abstract away the kinds of sockets I think I'll be needing, that I've tentitively named:
ListenSocket — the 'master' socket, that is bound to an address/port and listens for and accepts incoming connections.
CommunicationSocket... |
I don't know if there is any difference in performance, or its just a matter of choice, but I am a perfectionist like that, and I'd like to know.
Lets say you have the object HolySheet. You can set its properties in three ways:
HolySheet sheet = new HolySheet().setPropertyOne("asd").setPropertyTwo("foo");
or
HolyShee... |
I want to write a small daemon in python under Linux that accepts connections and authenticates the user (details for this don't matter) and then forks a child for the connection and becomes the user. I will probably even want to start a whole new python program for dealing with the users connection from then on (passi... |
public class MyClass
{
public object Prop1 { get; set; }
public object Prop2 { get; set; }
public object Prop3 { get; set; }
}
Suppose I have an object myObject of MyClass and I need to reset its properties, is it better to create a new object or reassign each property? Assume I don'... |
I had a heated discussion today about our MVC application. We have a website written in MVC (ASP.NET), and it usually follows the pattern of do something in the view -> hit the controller -> controller builds a model (calls a Manager that gets the data, builds the model in the controller method itself) -> model goes to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.