instruction stringlengths 34 36.1k |
|---|
I have 3 subclasses (LowState, MediumState, HighState) which derive from the same superclass (State).
Within the superclass, State, I have declared several variables which need to be accessed and changed from the 3 subclasses.
Is it possible to instantiate these 3 subclass objects from the same superclass object so th... |
Say my website contains 2 functions:
Allow a user to change their own password
Allow an administrator to change a user's password (the user must change again before they login)
Now let's say that there is a business requirement which stipulates that a user is not allowed to reuse a previous password.
In 1, it is ok ... |
I have a function which sends data to a third-party's server using a library they've supplied. The function is very simple. It just takes a list of objects to send, loops through each item in the list, and calls the third-party library's function to upload an object. The problem I'm running into is that my list of obje... |
I just come to a small company.
There are more than 500 solutions in different VS.Net versions and even VB 6.0 projects. They share several dll.
Is there a way to map relation between each program? How can I know in advance what solutions references to a DLL and will have an impact if I change this dll solution.
|
This question comes to my mind having just lost some money while ordering Pizza. Most internet merchants (atleast in India) use synchronous page redirection for integration with Banks and payment gateways.
It works like this: when you visit a merchant site and checkout something it redirects you to the payment gateway... |
Normally, I don't anticipate exceptions and if I get them, its something that I can't fix in my code - bad user input or connectivity issues with the database.
But errors do occur so at the very least, I want to inform my user that something went wrong and log the error.
My exception handling generally looks something ... |
Say, for example, you have a program that sends a message to a server and that server validates it.
Note: The server validation process can have additional test cases due to it being implemented in various countries (you would have to comply with their rules).
If you wanted to automate the testing on this, you could ... |
My project started out as spaghetti code. The more DRY and extensible I make my code, the more it looks like configuration files and code than runs them.
Is that a good thing or does that mean I am doing something wrong?
I am writing a program the scrapes semistructured data from websites and transforms it into a commo... |
I have been playing hangman with my friend over an app for a while now, and we have a gentlemen's understanding between us that we are both "cheating" by using online software both to solve the given word (lookup words with given length, filter words with letters in known positions) and to form new words with the rando... |
I am working on a signal processing project that allows for parallel processing on data streams as well as inputs and outputs to and from multiple endpoints.
The signal chain is broken down into "endpoints" and "nodes".
Endpoints can be declared either input or output, and nodes are anything in between.
The two types ... |
I have Spring+Java Server Faces (Facelets) application for which I would like to create Single Page Application (SPA) version, e.g. using AngularJS (which is the best and most popular GUI framework). But after some investigation of technologies I have come to conclusion that REST (which is necessarity for AngularJS) ir... |
In Java:
private State current_state;
As "State" is a superclass, I can then assign subclass objects to current_state, effectively making current_state point to a different object:
current_state = low_state;
What is the equivalent of doing this in C++. My understanding is that references can't point to different obje... |
I have a requirement where I need to display certain stats on Admin Dashboard in my web application (Angular+Java). These stats (transnational data) are being generated on different servers (connected via LAN to my web app host server) by C++ programs.
Since we don't have a centralized database we can't just store stat... |
I just wanted to make sure that I understand and can properly articulate the difference between these two concepts.
I've always thought of an implementation detail as being the internal workings of some concrete class behind its exposed public interface.
ie: User:getEmailAddress returns a string. It may fetch this... |
I have some integration tests around stored procs. Typically I do the test setup using Dapper. This is fine for simple cases, but in some cases to setup up the system correctly it would be far simpler to call the necessary stored procs. It would be simpler because some entities have many relationships and constraints a... |
Suppose I have a Map which is a private member variable of my class A.
In the same class I create an instance of class B, call it objB, by passing the map to B's constructor.
Obviously this is wrong, because I have leaked a private field to an object of a different class. That class might later on decide to modify the... |
I am redesigning a system by which conference participants can choose which track they want to attend. Participants express their track preferences arranging them in order and submitting them at a certain recorded time (which is useful for prioritizing earlier submissions). Each track also has a different quota and som... |
I have an array in the format:
$array = array(
0 => array(
'name' => 'Item 1',
'level' => 1,
'points' => 10
),
1 => array(
'name' => 'Item 1',
'level' => 2,
'points' => 12
),
...
24 => array(
'name' => 'Item 1',
'level' => 25,
... |
Example:
We have a base class Base and three subclasses which all implement their own version of doSomething().
In an intermediate function f(Base b), we want to call the relevant version of doSomething() depending on which object has been passed.
Why do we need to declare doSomething as a virtual function in Base? Sur... |
It seems to me like Observables are basically wrappers for promises with some helper methods. It also requires a huge library to go along with it. Do the benefits of these helper methods outweigh the cons of importing a library?
|
I am learning algorithms and data structures from this awesome resource Algorithms. Rather than doing dry reading I am trying to re-write all the code myself so that I can learn coding as well as design decisions at the same time(like: what APIs to expose and how to do assertions etc.) so, below is my simplified code w... |
I need to help to validate whether my understanding of when to use Dijkstra and when BFS are correct.
My way of understanding BFS and Dijkstra, when to use what, am I correct?
As I see it. Being given a graph, that can be imagined as N-ary tree, where edges have no special value (all are same length) and we just want ... |
Please ignore performance issues, I am interesting in data flow, safety, modelling, reasoning.
I wonder what are the limitations of exception approach to error reporting implemented like in Java compared to Haskell-like (OCaml, and Rust use same/similar approach AFAIK).
As far as I know in both cases error is part of t... |
I am trying to figure out the best way to define the responsibility of checking preconditions.
Let's consider the following case: we have an Event class representing a sports event and a Matchup class modelling a matchup between players of that event. The event has a set of matchups Set<Matchup> matchups and we can add... |
There is a finite set of unique strings and a limited key space. One key corresponds to one string value and a function must exist to perform the resolution. There is no need to support other associative array methods except lookup. Looking up a key without a value leads to undefined behavior.
I would like to find out ... |
I'm trying to design a simple way of abstracting away data persistence behind an interface, but I'm having a hard time figuring out how much fine grained control should be exposed to higher layers.
Limit, Filter, Order, etc.
Defining an interface for a dumb data repository is all fine and dandy for the basic CRUD oper... |
I have been developing in Java since 8 months, and I didn't face a case where I went to serialize an exception, I'm asking because I saw the serialVersionUID and how Eclipse advise to add it explicitly in the Exception class that you define. So, I think that every(or the majority) exception is being serialized and I do... |
My understanding of REST that is enables modelling service operations as representation of state and transition from one state to another making use of HTTP. I have always understood resources as representations of service side state until recently when I read this article by Jimmy Bogard whom I know to be a smart deve... |
Most of the time we need to understand someone else' code for example I am studying Graph Algorithms from Sedgewick's online resources, the particular code example is taken from cycle detection algorithm here:
private void dfs(Graph G, int u, int v) {
marked[v] = true;
for (int w : G.adj(v)) {
... |
Let's assume there are multiple contexts with the same logical entity but with different notions. Creating such an entity should have the side effect that in all other contexts the same logical entity should be created.
I do this simply by sending a domain event which contains all required fields for all contexts. The ... |
I have been learning algorithms and trying to solve problems and now I have the following problem:
In a 4x4 matrix, and it contains fields with height. There is a start field with given height also the maximum height a field can have. To be able to traverse from on field to another the height of the current field must ... |
I am currently trying to write my own Depth First Search. I have created a class called node.
class node{
private:
bool is_visited;
<data structure to collect edges>
public :
size_t get_number_of_edges();
void set_is_visited( bool val);
bool get_is_visited();
};
Node is bas... |
Consider the below method-
public void operationOnList(List<String> list) {
list.add(1);
}
It is obvious that if list is null this method will throw a NullPointerException.
My question is should I instead check for null explicitly in this case?
public void operationOnList(List<String> list) {
if (list == null)... |
I need to permit users to upload large files to my web-server even if the browser is closed. How can I implement this functionality. I have gone through the feasibility of google drive app but it dose't provide the details of on-going uploads.
|
At the moment I have three different sources where my data are. 1. A Dataprovider, 2. inhouse access DB and 3. Salesforce. Now I want to build a datawarehouse (using ms software) where I want to store the data and create reportings via e.g asp.net mvc or excel. Since we have really small datasets (all together is about... |
I've been learning about UML diagrams and such. While doing so I came across a problem. Which diagram should be drawn first when designing a system, given that use case and such are completed? Is the activity diagram drawn before or after the sequence diagram?
|
My question: is there a canonical way of creating a dictionary of dictionaries and providing an outer/inner key pair? Is there a NugetPackage out there with an implementation?
In my code, I have now a few places where I have a property like this
private readonly IDictionary<string, IDictionary<string, SomeType>> _nest... |
In our Rails application, we are adding notifications. Some of these are blocking: They stop the progress of whatever resource they are added on, because some information on that resource is missing.
Other notifications are simple notifications, and only provide information.
Today I had a discussion with another progra... |
I want to monitor batch jobs which get triggered by an REST API. This batch jobs are long running native data processings. So naturally, I want to return immediately after a REST call e.g. uploaded some data, and the long running job was started.
I have two usage scenarios for job monitoring in mind:
- An user of this... |
Say you have the hierarchical storage concept of "Foo." "Foo" holds an id, various values, and zero to many "Foo." Obviously, in turn, the child elements can hold zero to many Foos. The data is purely hierarchical: a given Foo will belong to zero to one Foos, and thus there is never a concern of multiple parents.
The d... |
Say I have a class with multiple parameters:
case class Foo(a: String, b: String, c: String, d: String, ... )
Now say I want to parse an instance of Foo from a Map[String, String]:
// returns either the parsed Foo as Right, or error message as Left
// example: Map("a" -> "1", "b" -> "2" ... ) returns Foo("1", "2", ...... |
Updating the iOS version on an old iPhone tends to make basic operations like startup, placing calls, and checking settings take longer. The change from eg iOS 7 to 8 on an iPhone 4S has a very perceptible effect.
I can understand why newly introduced features are more demanding therefore require more CPU time to run,... |
If I find an Open Source project I like, but I rewrite the entire thing because it's poorly written. I don't mean the question where you rewrite it slightly different, so I can say it's mine or anything like that. I've seen those questions and answers. This is actually the opposite.
Example (only an example),
I take... |
I'm writing a page that will show the user statistical data about some of our products. Basically the user can get results between a specific time frame, and also add on other data to lookup by.
For instance, I want to grab all the user clicks between 5/5/16 and 5/10/16 for our product. Then I have the option of filter... |
I am building on a CMS where dependencies and files needed for a page get stored in the database. Because this can be very dynamic, I serialize these paths into one Database field into my pages table.
I am trying to store these file-paths on retrieval into an array to use it in a switch and parse it into a web page.
I ... |
A lot of messaging frameworks have the term "topic". In a ddd microservice architecture, do these topics always reflect the domain events?
|
Here I have a very basic ILS (Integrated Library System) done a long time ago (made with C#/SQL Server), in production for years. But now I have a demand of make this system MARC 21 standard compliant, and with this demand came the doubt: Since this standard have a lot of register types, and each register type may have... |
Background
The following code snippet is taken from a problem in, Visual C# 2005: How to Program, by Paul and Harvey Deitel (pp. 735). The code snippet is more or less an application for accessing data using 2 threads via a buffer (called shared). Just skip the code snippet, and look below if you would like a brief des... |
While I was reading this question, the top voted answer quoted Uncle Bob on coding standards, but I was confused by this tip:
Don't write them down if you can avoid it. Rather, let the code be the way the standards are captured.
This bounced in my brain, but I couldn't find a place to stick. If a new person joins t... |
I've spent some time reading the common copyleft and permissive software licenses. Is there a license which allows the creator of an application or algorithm to broadly specify who may use/distribute the product based on their own personal prejudices?
I understand that people use dual licenses to force commercial entit... |
In texts about TDD I often read about "remove duplication" or "improve readability" during the refactoring step. But what makes me remove an unused function?
For example let's say there is a class C with methods a() and b(). Now I think it would be nice to have a method f() which is driven into C. In fact f() replaces ... |
I have a master table T1 which has 1000 records and a ColRef a key column.
There are lots other tables all linked by ColRef.
I have a Stored procedure which takes few hours to process.
I want to split this process like creating a view from T1 select records like 1 to 250, 251 to 500, 501 to 750, > 750. and run this fro... |
I (recently inherited) a asp.net web application in production. After fixing a generic bug in the area of making a table selection - we have a problem regarding security policies not allowing access to a certain active x plugin.
Our client is reluctant to allow permissions (this has fixed the problem on our test enviro... |
I have a program which generates events. They are ordered with a Lamport clock and sent over the network. They may arrive in a different order. On the receiving end I have an object which re-orders the events. This object can be popped like a queue and either returns the next event according to the Lamport clock or fai... |
This may be a stupid question, sorry.
I've read about the drawbacks of global variables a lot on this site. I'm finally trying to increase my code quality for a large project that'll be reviewed by many. I understand that using global vars makes code harder to debug, since one doesn't know where the variable may be al... |
I want to maintain a list of domain names that provide web-mail services.
I searched and received a list of 1634 domains(Free Public web-mail services)
However, is it possible to get updates, if any new domain registers to offer web-mail service,through scripts or through tools.
Or, is it possible to tell by looking at... |
If I update an iOS app as a result of tester feedback during TestFlight, should I be updating the "marketing" version number, or just the build number?
My current (initial) version number is X.Y.Z where Z is currently 0 and X.Y are out of my control (because they relate to the version of the upstream non-iOS product th... |
One of Linus's emails mentions the separation of the Git tools into the "plumbing" (usable by automated tools) and a user-friendly interface on top of the that (which has later come to be referred as the "porcelain").
He also expresses the hope that Git would serve as a base for multiple different SCMs/file management ... |
I am converting some .NET framework targeted projects over to Portable Class Libraries and looking for some best practices.
Usually all of my projects use the same project name and assembly name, and that name is also the base for all namespaces used within the project. If my project name is Project.Name.Whatever, shou... |
I am using darknet framework for object recognition listed here:
https://github.com/pjreddie/darknet
This is its license:
YOLO LICENSE
Version 1, July 10 2015
THIS SOFTWARE LICENSE IS PROVIDED "ALL CAPS" SO THAT YOU KNOW IT IS SUPER
SERIOUS AND YOU DON'T ME... |
I am a beginner with make and I'm wondering about when to use make clean.
One colleague told me that incremental builds with make are based on the files timestamps. So, if you checkout an old version of a file in your VCS, it'll have an "old" timestamp and it'll be marked as "no need to recompile this file". Then, that... |
So I have created an API endpoint (obviously not restful) that generates xml and returns the file path of the files. Its obviously more complicated but that is the gist.
My issues is this. Inside my controller I have all of this code that grabs information from the database (using models / relationships etc) and then ... |
Is it possible to buy the authorship of a piece of software just to be able to remove the credits from its source ccode?
Would that be ok if the author of the library agrees to do so for a price?
|
I have a grid that represents a sampling of a continuous function in a 2 dimensional space. I'm looking for a (preferably fast) algorithm that can calculate the discrete line integral along a straight-line path from one grid cell to a distant grid cell.
This seems like it would be a canonical problem with an accepted s... |
Which is generally accepted practice between these two cases:
function insertIntoDatabase(Account account, Otherthing thing) {
database.insertMethod(account.getId(), thing.getId(), thing.getSomeValue());
}
or
function insertIntoDatabase(long accountId, long thingId, double someValue) {
database.insertMethod(ac... |
We're using ASP.NET Web API and Azure Service Bus and adding logging to our disparate services and systems. We need to track a correlation ID to the headers of each set of bus messages as well as logs related to a single business workflow/sequence together together. I'm just trying to nail down what this should be call... |
I just ran across this old question asking what's so evil about global state, and the top-voted, accepted answer asserts that you can't trust any code that works with global variables, because some other code somewhere else might come along and modify its value and then you don't know what the behavior of your code wil... |
I use C and structs where a struct can have members but not functions. Assume for simplicity that I want to create a struct for strings that I name str and I want to be able to do str.replace(int i, char c) where i is the index of the string and c is the character to replace the character at position i. Would this neve... |
We've got a .NET Solution consisting of a MVC Website and a bunch of libraries for business and data logic. In the past the website was the only way to interact with our business logic, but we're finding ourselves having to share this logic between various systems, and we've decided to expose it via a REST API.
The typ... |
Lately I've been searching for information about creating API's. The company I work for wants to sell some of our products as stand alone devices. Currently these products work inside enormous projects with our own software to manage them. However some of these products have acquired lots of attention from companies wh... |
We are using Spring and want to implement a REST with a "override file" call so we think using PUT verb with a multipart body only to find that Spring don't accept it.
My question is it can't be done in Spring because it isn't the REST way to have a multipart body with PUT?
Note: I know there are ways to skip this rest... |
We have this bean with two properties:
ContainerImage
+ name (final, not null)
+ id (null)
Then there is this method:
ContainerImage create(ContainerImage containerImage);
It receives ContainerImage with name and without the id; and returns new ContainerImage with id populated, as result from the underlaying ... |
It often happens that after designing my regexp (on regex101.com) I want to paste it in my program. Consider this regexp that matches numbers and string (but keep in mind this is general question!):
^(\"(?:[^\"]|\\\")*\"|\-?[0-9]+(?:\.[0-9]+)?)$
I overlined all characters that need to be escaped before pasting them int... |
I´m struggling how to decompose a sprint in SCRUM.
I know in many cases SCRUM is used only for the developing part in the software process, but I want to use it for the whole project (in our case: prestudy analysis, purchase from suppliers, and development.
If I decompose a sprint based on a time limit (e.g. 2-3 weeks ... |
I am working on a project and we have regular (usually weekly), informal meetings, where we discuss the status of the project and the GUI of it.
I'm the only developer there, the other 4-5 people have a non-IT background.
This meeting took much longer than usual, but at one point, one of my colleagues asked about some... |
I would like to link a GPL project to another project with the following clause in its license:
The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
Is this software compatible with GPL v2 or v3?
|
The db.collection.find() documentation includes this explanation of Query Exact Matches on Embedded Documents:
The following operation returns documents in the bios collection where the embedded document name is exactly { first: "Yukihiro", last: "Matsumoto" }, including the order
This seems so strange to me, since ... |
I'm confused about routing. In some systems I've seen only naming conventions. In other's I've seen configuration, and in some I've seen both options (like in ASP.NET MVC5).
In the naming convention based system, it seems to be a RewriteRule that puts the URI into a variable and then simply parsed out.
What is the re... |
Imagine a simple AngularJS REST Service which retrieves (GET) data from REST endpoints on a server. It maintains no state of its own and each method only passes back a promise to whomever is using said service.
Now, should I write tests for this service? If I do, what exactly have I tested other than my mocked httpBack... |
My understanding of how ORM persist works:
//ORM "persist" oversimplification
function persist(&$entity)
{
...
$insertId = api_actual_db_insert(...);
$entity->setId($insertId);
}
//usage of ORM later ...
$this->getEntityManager()->persist($entity);
print $entity->getId(); //prints ID of newly inserted rec... |
In CQRS/ES, a command is sent from the client to the server and routed to the appropriate command handler. That command handler loads an aggregate from its repository, and calls some method on it, and saves it back to the repository. Events are generated. An event handler/saga/process manager can listen to these events... |
Many general programming languages are flexible enough to allow you to support dependency injection. Even without library or framework support. But even if a language is Turing complete enough to solve any programming problem, a language makes choices that impact what is easy and what is hard to do in them.
Is the... |
I have class GameState laid out to basically hold an Array of Players, an Array of StarSystems, and a few other fields that need to persist from save to save. Each GameObject keeps track of its own id, which is also its index in its array as well as the id's of relevant gameobjects.
public class GameState implements Js... |
We have a number of items which the end user will be able to organize into a desired order. The set of items is unordered, but each item contains a sort key which can be modified.
We're looking for an algorithm that would allow generating a new sort key for an item that is added or moved to be either the first item, l... |
For learning purposes, i'm trying to implement a small project using (buzzword warning!) microservices. There are plenty of resources online talking about the 'macro' microservice world -integration, orchestration, service discovery, health checking, topology, etc., however I've found that there is little to no informa... |
In Android development, we have Parcelable interface.
Since I wish to build Data Models that will run on multiple apps and services (not just Android), I would like to add two jar libs that will share some of the code across multiple implementations:
1. The first A is coupled with Android SDK
2. The second B is not cou... |
The view model seems to be the most appropriate place to perform validation yet Angular seems to be pushing me down the popular form validation route.
Why Model Validation?
DRY - Applying validation to the model will centralize the validation logic as opposed to repeating it in every view.
Unit Testable - Since the lo... |
I am implementing an NPC to walk around a virtual space, specifically a cat. I have a series of short animation clips (3-5 seconds). My first instinct was just to choose a random animation when the last one ended, but I realised that it wouldn't look realistic as it would change behaviour too often, even if the next an... |
I recently started developing a small calendar application, in which I can add and view several calendar entries, which contain several data like name, date, alarm settings and so on.
Those values have to be saved locally, so the user can see his calendar entries from earlier sessions as well.
Right now this is solved... |
I am working as the sole .Net developer at a company and I have been tasked with a very large and complex project, an internal intranet site for inventory and time tracking. I have built a project that contains 3 applications, WebUI, Data Access Layer, and Core.
The WebUI is my normal MVC stuff, the DAL contains the mo... |
I have a collection of strings which have a lot of common substrings,
and I'm trying to find a good way to define tokens to compress them.
For instance, if my strings are:
s1 = "String"
s2 = "Bool"
s3 = "String -> Bool"
s4 = "String -> String"
s5 = "(String -> String) -> String -> [Bool]"
then I might want to use the ... |
From what I understand a DomainService should be implemented against a RepositoryInterface, so we could change with easy the repository (which its a part of the Infrastructure layer)
So, if I have:
class UserService{
function __construct(UserRepository $rep){
$this->rep = $rep;
}
function createNe... |
In Python, what is the difference in these declarations…
my_list = []
my_list = list()
…and in these?
my_dict = {}
my_dict = dict()
Are they interpreted the same, and why would you use one over the other? I haven't seen or noticed a difference.
|
I am updating a database design that must be compatible with old and new applications. My goal is to make a design change which minimizes impact on the existing code.
The Design Change
Currently our database has universal data that is stored in each customer database. I want to move this common data out to a different ... |
I recently started working on a new project where the team was considering use onion architecture, which I was not very familiar with, so I started reading about it.
The application is a simple 3D format converter. It will read a sql database, convert the data and then write the new format in another MySql database. Th... |
I understand what cyclomatic complexity is, but I was trying to find the origin/meaning behind the word "cyclomatic" and could not find anything that wasn't about cyclomatic complexity. Does this word exist outside of this phrase?
|
In most examples of clean architecture (Android projects mostly, though) I've noticed that the use-case/interactor classes (units that encapsulate a feature) often share base class/interface, like here or here. Others do not (like here or here), instead allowing interactors to accept some parameters that are then used ... |
I am building a site with a GNU licensed program called OpenCart.
Now I am not "distributing" anything.. but people can see my website and interact with it.
Generally I avoid GNU like the plague as an app developer. No way my customers want their hard earned work set out to be free. In this case all I am doing is fil... |
I'm writing this small utility, FOSS but not intended for wide deployment, packaging in OS distributions etc. My utility depends on several libraries - some are header-only (it's C++), some are headers+compiled libraries.
Now, when it's a library with proper versioned released then life's simple. I have CMake look for... |
In Martin Fowler's article OrmHate, he states the following:
If you have an application problem that maps well to a NoSQL data model - such as aggregates or graphs - then you can avoid the nastiness of mapping completely. Indeed this is often a reason I've heard teams go with a NoSQL solution. This is, I think, a viab... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.