instruction stringlengths 34 36.1k |
|---|
Okay, I have a list of people in a database, can you point me to some sample coding that will show me a good algorithm to determine who the next person in line is?
Because people can be added to the list in mid stream, so not sure how to always pick who is next.
I've spent a lot of time trying to figure this out and I... |
While reading through an answer to the question Clarification about Grammars , Lexers and Parsers, the answer stated that:
[...] a BNF grammar contains all the rules you need for lexical analysis and parsing.
This came across as somewhat odd to me because up until now, I'd always thought that a lexer was not based up... |
I am a web developer who is planning to build a web application which requires user-generated input, with that input presented somewhat like a blog in the sense that there is an article with pictures, and a gallery, along with some special features which will require me to add custom html and js, with Google API integr... |
In certain programming languages, the meaning of certain names may be fully determined at compile-time (i.e. without running the program).
Example:
A function in C has global scope; when the name of the function is used somewhere else in the program (and the variable is not shaded by another variable of the same name) ... |
I have a documentation repository on github which submodules other project repositories.
I want that everytime there is a change in any projectname/docs/*, it automatically be reflected in my documentation repository's submodules. Do I have to setup a jenkins job for this (git submodule update) or does submodule do th... |
I use liquibase for source control of our database. I put there changes to the schema, static data and procedures. So far I've kept permissions out of it; we have just four users with very well defined permissions that don't change. Now, for a new application, I need to create a new user and grant it table and column-s... |
I have been asked to do the following:
Take a project within a repo (repo has multiple projects inside)
Build ant build script that will build two separate tomcat webapp war files. They are two web apps.
The two war files have to be different web app since there are functionalities required in one war file and must no... |
A typical piece of code printing a number to the console is this:
Console.WriteLine("The number is " + 1234.5 + ".");
This contains English text and formats the number using the locale of the current user. This can result in mixed output (here, German):
The number is 1234,5.
The application is not localized. It's us... |
Studying beginners course on hardware/software interface and operating systems, often come up the topic of if it would be better to replace some hardware parts with software and vice-versa. I can't make the connection.
|
What is the formal name for this specific problem scenario in an event-driven architecture, and what are the common approaches to handle it?:
After an action or event is dispatched, several subscribers will execute in order. But after the first subscriber is executed, it triggers a new action which also has several sub... |
I'm familiar with the Page Object Pattern from doing Selenium tests. It seems to me like the Angular 2 team has borrowed this concept in their testing documentation.
But I feel like this is not precisely the same concept. In Selenium tests, the Page Object quite literally represents an entire HTML page. In the Angular ... |
I'm working on an architecture document based on quality attributes. I'm trying to explain our search algorithm based on tags, historics and some bi information as a way of favouring a quality attribute.
I read some material about this (Software Architecture in Practice, Third Edition) : usability is the closest I got... |
I am writing a Python module that uses Numpy. I am trying to follow the Numpy docstring format. In many of my functions, the same parameters show up. It seems repetitive to explain what they are in more than one function from the same module. Is there a common practice when dealing with this?
|
Say you are writing an ORM like entity framework. You write basic POCO, and then let entity framework do the job of creating equivalent structures in the database according to those objects.
This can get hard if those objects have foreign key relationships. Theoretically speaking we would need some sorting in order to... |
We are aiming to reduce code noise that would be common for all Controllers such as basic CRUD.
public interface IGenericController<T, Y> where T : BaseMaster
{
IEnumerable<T> Get();
T Get(Y code);
HttpResponseMessage Post(T entity);
T Put(T entity);
T Delete(Y code);
}
this would be use as
pu... |
Instead of unintelligible names and acronyms for new products and services, is there any other way of naming software that could also say what it is and what it does?
For example, instead of naming a software Abricudabrah or similar which typically means nothing and says nothing about what it does, could there be a nam... |
The first 90 percent of the code accounts for the first 90 percent of
the development time. The remaining 10 percent of the code accounts
for the other 90 percent of the development time.
— Tom Cargill, Bell Labs
What does that exactly mean in practice? That programers do substantial amount of work and that they... |
I have a ASP.NET MVC application and connects to the SQL Server running on a different server. I wish to know which is the default protocol used between the MVC app and SQL-server to exchange the data.
|
In my organisation people regularly have 3K+ emails in their inbox. They're swamped and non-important email is ignored and lost. (Think big Corporation). Email ceases to be a useful medium in this environment.
For a while on our CI Server (eg Jenkins) we ran builds that you could view the status of on the Jenkins site... |
Using Semantic Versioning, I have a product that is version 1.0.0. It has a configuration file entry shipped with the product that specifies an operation timeout value:
myTimeout=1000
I need to change this configuration value. Is this a MINOR or PATCH increment? It's not a bug fix, but it's not really introducing a ne... |
I was wondering how you handle issues like that in your company.
Usually when something goes wrong at a customer he needs to:
Submit the issue he encountered
Add logs / configuration data
Suddenly the logs are not in high debug level - so he needs to increase debug level and reproduce the problem
Then again, you can't... |
Today we found out the cause of a nasty bug that only happened intermittently on certain platforms. Boiled down, our code looked like this:
class Foo {
map<string,string> m;
void A(const string& key) {
m.erase(key);
cout << "Erased: " << key; // oops
}
void B() {
while (!m.empty()) {
auto to... |
How important is a documentation? or a spec for that matter?
I've been writing software professionally now for about 5 years. Each new job I start I am more often than not faced with spending a few days reading the code trying to figure out how everything works, taking notes, and eventually producing the documentation ... |
Our organization currently has several web applications running on lamp servers. They are mostly static content, but also include php via codeigniter / laravel / vanilla php.
Whenever we make changes to any of the files we will update a git repository on a separate server to track that change. However, we also have con... |
I am a student working on a mvc project to move a site from coldfusion to .net mvc. Were are also redesigning the site in the process so I am working with other team members, the design team members have a basic understanding of razor, but aren't expected to know any other parts of the framework.
I've always tried to u... |
I have a class called class object which have variable called density (_OMEGA is related to density : density = _OMEGA*x). I also have configuration file(a txt file) where I say _OMEGA = 1.4. Then I read that _OMEGA and other configuration variable from the txt file into a container in class config which I will be usin... |
I have two options for implementing caching in my web application. I can either add a Varnish cache outside of my application code, and cache the responses on a per-request URL basis, or I can use an in-memory cache like memcached to store the results of database accesses.
I am having a hard time choosing between these... |
I'm writing a Matrix type, and I would like the following code to define a 2,2 integer matrix, put its first element at 3, and throw an exception upon reaching the third line:
Matrix<int> a(2,2);
a[0][0] = 3;
int b = a[10][28];
For this, I need to overload "operator[][]". Let me explain further:
My matrix is define... |
The using directive gives us access to types without using their fully-qualified names:
using MyNamespace.Foo.Bar;
The using statement acts as syntactic sugar for try/finally blocks which ensure that objects are disposed of properly:
using(var x = new MyDisposableClass()) { ... }
These two situations seem to have not... |
I develop (mainly UWP apps for personal enjoyment atm) on a x64 laptop, but in Visual Studio I have been blindly using the default x86 solution platform.
Should I be using x64 or x86? (so ashamed to even be asking)
There's a few previous questions that touch on the subject and mention differences at a high level but t... |
At work we have a quite complicated system. Let's call this system, System_A. Our QA team has created another system, call this system, System_B, to test System_A.
The way System_B is used is as follows. We generate inputs (using System_B itself), IN, process such inputs back through System_B and generate outputs, O_B... |
Suppose I am using ionic2 to create hybrid apps, and it is common that I can finish a job by either using features of ionic2+angular or just html+ javascript+css only, for example, click to disable a button:
html+ javascript+css only solution:
<div id="myDiv" onclick="(
function(){
document.getElementById('myDiv... |
I've been reading the top posts of stackoverflow and SE and all over the place it says how bad singletons are but I am unsure how to rewrite my code.
As of now I have two projects that bind into a gameEngine that each have a singleton class to access the content:
Singleton for retrieving/creating an instance of a 3d s... |
I've been following the quick tutorial on using Castle Windsor in MVVM WPF:
TUTORIAL
I've set everything up (as for the basics) but I came to the point of creating a new Window after a button click. This is where I got lost.
Basically, from what I learned, the container should NOT be referenced more than once.
public c... |
Hypothetically, if you (I / someone) were to create a multi-threaded application, utilising the processing powers of multiple cores (for example, using TPL in C#). Would that program crash, if it were run on a computer with a single core? Or rather, would the application move to context switching / time-slicing?
|
Programming against interfaces is an often-heard good practice in software development. Together with extension methods, this provides a great functionality. However, in C#, there are limitations to that. Let's declare a simple interface for a 3D-Point:
public interface IPoint3D
{
double X { get; }
double Y { get; ... |
I have joined a new workplace where they follow Agile (Scrum). There are several products, each has an internal product owner, but the development team is an external vendor (developers and scrum master).
As a scrum master, i see this is a slightly different situation from Scrum Classic, where you have all your resourc... |
TL;DR is val name <- more readable than name val <-?
I'm designing a semi-concatenative, postfix language. I haven't given much thought to the style in which variable are assigned, and now I see that there are two (main) ways to do it. Originally, a variable assignment looks like:
variable value <-
So, here's an examp... |
In Android, I rather frequently need to get results from more than one service that utilizes an asynchronous callback pattern and I want to know if there's a better way to handle this pattern than what I'm doing.
Right now the way I handle it goes something like this: I call both services and pass them my callbacks. In... |
I'm writing a handler for download/import of data. After inserting data to the database, several import jobs can be called, but usually it is just one. So there are two methods to get the import job(s), that can be overridden from the abstract base class, one being abstract, the other one using the first one.
Please ha... |
I am developing data analytics algorithms that are supposed to process large amounts of data.
Thus I am aiming to develop my mathematics already in such a way that it is possible to distribute the algorithm later on many machines (Big Data).
I am able to develop my algorithms in such ways that it calculates some inte... |
I was reading the Go-lang documents and found under the section of Types that Go has no type hierarchy.
What does that mean exactly? Is it like python that types are been checked at run time (dynamically typed) rather than 'compile time' (statically typed)?
|
I know that long time ago computer scientists decided to treat all pointers to memory cell of address 0 as NULL. However, the memory cell at that address does exists after all, right? In that case, what value is stored there? Since it's OS that decides how to allocate memory it should be able to access (and modify) val... |
In Lua, I can create an object like so:
local foo = Foo.new({10, 10}, 3, right)
or like so:
local foo = Foo.new({
pos = {10, 10},
len = 3,
direction = "right"
})
The former is more compact, whereas the latter is more understandable and flexible.
Which is generally considered the better form of accepting a... |
Is there any adequate reason for a manager to forbid the use of Git GUI Clients in a developer team.
I was talking to a friend about - let's call Foo Git GUI Client - all the features and how i was able to speed up some tasks and he said that any client is forbidden by the managers in his company.
Question is: Why?
A c... |
I'm not quite sure of the proper flowchart notation for returning an object/value from a function (I'm also looking for some quick tips on proper flowcharting notation in general, if anyone notices any glaring issues).
Key key = FindKey();
Ferrari f355 = Valet.GetCar(key);
f355.Go();
|
I am building a service that will push notifications to many other services. It has a couple of different notification types that each consumer may care about, but likely will not care about all of them.
Instead of requiring many different endpoints, I am thinking of making a single endpoint that has a notificationType... |
During code review, a minor suggestion was presented that some implicit behavior be made explicit. The reviewer had skimmed over the code in question, became confused after mistakenly interpreting the code's purpose, and only discovered the cause after some careful analysis. Below are the implicit practice and suggeste... |
So much of the benefits around Event Sourcing apply to the being able to audit the system and show an aggregate's state throughout its life. However, I haven't been able to find any examples of where to record who issued the command and when with was issued.
I have been doing a lot of my learning by dissecting the CQRS... |
I'm trying to debug my MCTS implementation for TicTacToe (it doesn't block obvious wins for the opponent). I was wondering what the algorithm should do if it expands to a node which is a game over state. Should it continue to "simulate" that node and back-propogate the results up the tree or just ignore it if the node ... |
Our team has just started using JIRA. Now we are looking for advice on how to build our process in the most convenient way.
We have stories to be implemented in further sprints as well as bugs to be fixed.
The question is how should we approach those bugs. I see following options:
Assign bug to a developer
Create new ... |
I've written some apps using simple imperative way - now I want to learn more about building software the object oriented way.
My goal is to take an Excel file and load one of the tables into memory. I can do this by:
Creating a list of strings for each row, and store the table in
list
Creating a structure/ class for ... |
I am making a desktop based financial app in Ruby On Rails for my friend.
I have a little concern over the system time I am using since time log being very important. What if system time changes because of some hardware issues. Should I go for time from internet or what are the alternates for this issue?
|
I'm building an application that is responsible for reading data from files and displaying them in charts. The whole application is responsible for manipulating data from files, which means I have to use different parts of the same object in almost every part of my project. Charts need actual data, list of opened files... |
I have a Document class and a DocumentItem class. A document creates multiple DocumentItems.
As my project has evolved, I realized that DocumentItem needed some "deep" logic to properly display, first checking a database, then the web. My code ended up looking like this:
class DocumentItem
...
function getValue()... |
I sometimes stumble upon code similar to the following example (what this function does exactly is out of the scope of this question):
function doSomething(value) {
if (check1(value)) {
return -1;
}
else if (check2(value)) {
return value;
}
else {
return false;
}
}
As you can see, if, else if a... |
What database design would you suggest for the following example?
Example: Imagine a bus with some people inside. Every person has some attributes like name, etc. Also there are driver- and passenger-specific attributes. Every few hours the roles change - meaning, that the driver becomes a normal passenger and one of t... |
I have a function
function name(src, dest, remove) {
copy(src, dest);
if (remove) {
delete(src);
}
}
What name should I give to that function? Alternatively higher order function like this:
function name(remove) {
if (remove) {
return function(src, dest) {
copy(src, dest);
... |
While working on a project, I decided to create a database class to manage my DB connection. I started looking for the best practice to do that, which is usually either a static class or a singleton pattern class.
Answers I've found, such as:
http://javarevisited.blogspot.com/2013/03/difference-between-singleton-patter... |
I've been a proponent for training on our team since I've started with a new company. I'm dealing with two newer technologies now and my peers have given me their opinion that additional training would help everyone, including some new hires to the team. However, management hasn't bought into this idea. They say yes... |
I heard that Lua is great for configuration files, so long as you are secure about it. Lua has been used as config files by programs such as awesome and (recently) conky.
However, I also heard that using programming to configure a program is an anti-pattern.
Since Lua does not get compiled as part of the program, would... |
I have read at a few places, that Postfix is easier to evaluate & easier to convert to Code than Prefix.
I understand that if you parse a prefix expression from left to right, you might not be able to evaluate directly(as some operands might be prefix expressions as well); but if you parse the prefix expression from Ri... |
What I want to Achieve ?
I want to dump all logs in a single line which got collected during a request.
Why I am doing this?
General approach, i.e. logger.info(), dumps log in file at same time when you call function. Due to this, Logs get mixed up and can't read them sequentially as multiple threads are using same fi... |
A closure is a record storing a function, together with an
environment: A mapping associating each free variable of the function
(variables that are used locally, but defined in an enclosing scope)
with the value or reference to which the name was bound when the
closure was created. (Wikipedia)
Here is what I... |
Recently I am using a software package which seems pretty useful, but which I don't understand how it works internally.
This package contains software generated by several PhD students and lecturers of an university among several years, which reflects in code style. There are several papers related to pieces of this s... |
I've made a program to play TicTacToe against a human using a Monte Carlo Tree Search (MCTS) with UCB1 for node selection. The program will play moves until it wins but it will not make any attempts to block the other player. Is this the nature of the algorithm or have I made a mistake in implementation?
|
If you imagine a company like Amazon (or any other large e-commerce web application), that is operating an online store at massive scale and only has limited quantity of physical items in its warehouses, how can they optimize this such that there is no single bottleneck? Of course, they must have a number of databases ... |
I'm developing a server which provides a virtual block device via SCSI interface. The device is constantly bombarded by requests to read/write data blocks. Sometimes I need to lock this device (or make it read only) just to perform some device-wide operations on it - for example, a full backup.
I worry about incomplete... |
I have a console application (dotnet core, ubuntu), that looks like following:
void Main()
{
try
{
var job = new Job();
job.Start();
while(Console.ReadLine() != "quit");
}
catch(Exception e)
{
//some handling
}
}
While Job is implementation of JobAbstract class:... |
my question would be can age be considered a composite attribute? Because name is a composite attribute and it can be divided into first name, middle name and last name. And therefore can age be a composite attribute since you can divide it into years, months and then days?
|
I am trying to develop an algorithm, but I barely can describe it so I'm not sure what to look for.
I have two images img_A and img_B. img_A is the original, while img_B is an image of the same item but slightly different. Let's say one is a photo of a person, while the other is a drawing of that same person. This mean... |
Please excuse the long post. There is a question, just bear with me.
A Little Context
We have a site which is required to adapt considerably based on a variety of user settings, the group the user belongs to, where they come from and other things. We used to include the relevant bits on the model for the page, so if th... |
I'm moving from a coupled architecture to a decoupled architecture using microservices with AWS Lambda.
Here is my current architecture:
Each API Gateway route is linked to a specific Lambda, each of them has a specific task, but they all share common code.
Pain points:
- I have to deploy all the Lambda when modifyi... |
Consider the following C API:
void BeginTransaction(State *s);
void AddToTransaction(State *s, Object *value);
void CommitTransaction(State *s);
void Foo(State *s, Object *value)
{
BeginTransaction(s);
AddToTransaction(s, value);
CommitTransaction(s);
}
I created a C++ class to wrap this API:
class StateT... |
Like the author of this question from 2012 and this one from 2013, I have a 3rd party library that I need to wrap in order to properly test my application. The top answer states:
You always want to wrap third party types and methods behind an
interface. This can be tedious and painful. Sometimes you can write a
co... |
In the below tree,
typedef struct lcrsNode{
void *item;
struct lcrsNode *parent;
struct lcrsNode *firstChild;
struct lcrsNode *nextSibling;
}lcrsNode;
typedef struct Tree{
lcrsNode *root;
int size; // Number of nodes;
}Tree;
What are the advantages of maintaining parent pointer in a tree node? D... |
I'm working on a piece of software in Visual Studio. I created a PKCS#12 archive in Visual Studio to strong name sign my assemblies. I then extracted the public key from the archive using OpenSSL.
I realise that I must remove the PKCS#12 archive from the VS solution before making it publicly available but what do I do ... |
I'm in charge of switching our 10+ years old code base from SVN to Git. Currently we have one single monolithic repository containing all of our projects. We have shared libraries and multiple projects using said librairies.
I've been looking for a way to host all of our projects into seperate repositories. I have lo... |
Is it fine not have any post-condition in a test case?
For example, there is an employee information system or module and an employee can login into the system and views his/her profile and logs out.
If I write a test case for it, I can't think of any post-condition possible in this test case. Can I write it without p... |
I've been working at my job for about a year. I primarily do work in our GUI interface which uses methods from a C backend, but I generally don't have to deal with them except for return values. Our GUI is structured pretty reasonably, given our limitations.
I've been tasked with adding a function to the command line ... |
I am creating an application based on the cloud for the management of articles. I'm also a desktop developer so I never had problems with the internet absence, mainly because I was working with db locally, and then on the user's PC.
This time the app is on the cloud, then I would know if there is a way to continue work... |
Representation 1 - Multi walk tree
typedef struct multiWalkTreeNode{
struct multiWalkTreeNode * parent;
void *item;
struct multiWalkTreeNode **childPointer;
}Node;
typedef struct multiWalkTree{
Node *root;
int size; /*Number of nodes in the tree*/
}Tree;
Pictorial view:
Representation 2 - LCRS tree
typedef... |
I am not familiar with the various options you have when dealing with COM components. A legacy system in our company has published a COM API with a mixed mode dll to allow .NET components to interact with it.
It also allows the legacy system to run out-of-proc.
However, when setting up a simple windows app, it seems th... |
Let's take some blogging application.
User in this application has email, password. When a new user is registered, he should activate his account (for example, via email). But... is account activation, password, password reset tokens, etc, are domain concepts?
So I'm thinking to divide User concept into 2 parts: Accoun... |
I am currently on an angular 1.x project, and we are about to add user interactions that will cause data changes.
We already identified some flows in our app that seem like flux might resolve, so we are going to use flux.
We don't yet know flux, and the libraries that exist today seem like an overkill.
We have an id... |
Our agency is currently using and maintaining the CMS we have developed in .net MVC on SQL server.
Since the cms is highly optimized and uses various cache tables to run very fast even with thousand of pages we want to keep it the same and use it for some php websites we will do in the next months.
In this condition yo... |
My web application has a dashboard page written in angularjs that is intended to be displayed on a screen in a room as a way of monitoring the information therein.
It's a dumb screen connected up to a machine with no easy access to input devices so I want to minimise the need to interact with the browser window. This ... |
I am looking for help designing the code to create a menu displaying multiple categories. Currently, the code (classic asp) makes a call to the database and then loops through the results, so it is all inline. I am porting the code to MVC 5/C#. What I am doing now is getting all the categories from the database, pas... |
What is the recommended option to design a privilege system?
My application has some users with several roles(Admin, consulting, expert, reporter..)
Each role has some privileges (read document, write document, send mail, read mail, write mail, read book, write book...).
Is a unique privilege must give access to only a... |
I read "The Why of Y" from Richard P. Gabriel. It is an easy to read article about the Y combinator, which is quite rare. The article begins with the recursive definition of the factorial function:
(letrec ((f (lambda (n)
(if (< n 2) 1 (* n (f (- n 1)))))))
(f 10))
And explains that letrec can be def... |
I am currently initiating myself to the latest RC of Angular 2, coupled with typescript. So far, I really love it, but I however already stumbled upon a few existential concerns.
The @Component annotation, along with the class approach of typescript, are intented to encourage code and component reusability. But, there'... |
I have created a complex query that references a specific date (year and month to report on) on numerous parts of the script. What would be the best artifact to have to only change 1 line of code and have that cascade to all my script each time a new reference date is needed?
I understand that there are issues declarin... |
In C++, size_t (or, more correctly T::size_type which is "usually" size_t; i.e., a unsigned type) is used as the return value for size(), the argument to operator[], etc. (see std::vector, et. al.)
On the other hand, .NET languages use int (and, optionally, long) for the same purpose; in fact, CLS-compliant languages a... |
I have to program a generic client that uses diverse concrete clients (diverse APIs), all sharing the same interface. I have to log the response of the client.
To accomplish this (logging in background without user having to manually do it), I created these classes:
Request, Response, ClientService, Client1, Client2, C... |
I'm working on a project where we are creating some REST APIs
My question is when we are creating an API to update an entity that contains a children reference, i.e.
{
name: '...',
email: '...',
country: {
id: xxx,
name: 'xxx'
}
}
Does the update api accept a country object or just a co... |
I recently joined a software project and discovered that the current architecture relies on line numbers of input data files. For example, the data on line 248 of an input file corresponds to file ID 247.
My gut tells me that this is dangerous and bad practice, but I'm too green to be sure. The people working on the pr... |
I have an ASP.NET Web API application. It uses enums for some fixed sets of states or types. Now I need to extend enum to support more values. But it will break backwards compatibility so I need to create new version of method. Is it better to use strings for this purpose? I suppose I can easily extend a list of possib... |
I am building a simple Q&A app with PHP, HTML and JS. I have three tables: users,question and answers, each table has it's own primary key and questions and answers both have foreign key constraints. questions store users.uID to look up author, and answers store question.qIDto identify which question they belong to, an... |
We have an enterprise application. Maven build, about 20 submodules with more submodules. We have a dedicated Ops (operations) which deploys our application to 10 clusters. Installations are running different versions, about 5 customers total. Language Java. We are actively developing all parts of the application so ev... |
During prototyping a simple ddd application from public transit domain I've faced a problem with one value object - Transit Pass:
Each Customer can buy a transit Pass thatallows a passenger of the service to take either a certain number of pre-purchased trips or unlimited trips within a fixed period of time. A detaile... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.