instruction stringlengths 34 36.1k |
|---|
I'm looking for a data structure that supports this use case - there must be one out there!
A set of objects of type T can be stored in a Group, parameterised by the type T. A grouping has a GroupIdentity that uniquely identifies the group. Any T can only exist in one Group.
A management object, let's call it GroupStor... |
I am reviewing a colleague's code and as part of the changes, this person introduced a few new pure data classes like so (C#):
public class Result : IResult
{
public bool Succeeded { get; set; }
public string ResponseMessage { get; set; }
}
And then afterwards defined an interface for the data schema, and used... |
I need to model a set of tasks in BPMN v2:
1.0 a report is sent out
following which two paths emanate:
2.0.1 report is further formatted, followed by
2.0.2 additional information is added to the report
2.1.1 report is reviewed, followed by
2.1.2 information on the report is acted upon
3.0 further action is taken
I a... |
I'm building a small personal website. Basically, they are 20 short sound files. Clicking a button will play one of those files randomly. Once played, that file will no longer be played. So in total, the user clicks the button 20 times, each time getting a new random sound.
My question is should the frontend (angularj... |
I am about to create my own event-driven API in JavaScript.
Most JavaScript that currently exists, e.g. in-browser JS for controlling the DOM, lets you register event handlers like this:
object.on('eventname', function handler() {});
'eventname' is basically a magic string, which is generally recommended against (righ... |
There are a lot of famous open source tools, for example: gcc, git, mercurial and etc.
However, they don't provide a nice API for developer.
Someone will say, they are command-line tools instead of library. But in my point of view, there is no conflict between a good interactive tools and a good library.
It can definit... |
A few times in my career I've found myself writing decoders for responses from IoT products or weird apis that insted of using JSON or XML as a response, they reply with something like HC010410290203123, and they provide certain documentation to explain that...
HC 01 04 1029 02 03 123
HC = This segment's name
01 = fiel... |
I am currently in the process of developing an ASP.NET Core application which requires internationalization to Russian.
I have been reading over the documentation that Microsoft provide for .NET Core internationalization, which requires wrapping your strings in the IHtmlLocalizer and IViewLocalizer interfaces.
My bigge... |
We are replacing a legacy application that runs on a single Oracle DB, and the decision has been made to replace it with a microservices-based application running on Azure SQL.
Do we do data migration from Oracle via the microservices, or do we do direct data migration from Oracle to Azure SQL DBs?
Advantage I see with... |
I'm trying to build a project using onion architecture (just a "Northwind"ish type app to get more up to speed with .NET Core). I also want to get a better grasp on Onion Architecture principals. I understand it's not a one-size fits all solution, but I want to try to utilize most of the principals in this sample app... |
For a few months, there's a heated discussion ongoing in Guava's issues (#3302, #3320) about having introduced several internal dependencies, namely "failureaccess" and "listenablefuture".
Some of the introduced dependencies are empty, as evidenced by their version-name: com.google.guava:listenablefuture:jar:9999.0-emp... |
In my searching although this question seems to get answered a lot, the answers don't really cover what I want to ask.
I'm learning assembly and my question is, in higher level languages e.g C data types are defined as a certain length e.g
Char: 1 byte
Short: 2 bytes
Long: 4 bytes
Here's a block of memory, say I defi... |
I am building a solution where IoT-devices send in measurement-data to an API that's hosted on AWS. For each measurement-type the user can set a threshold value; that when reached will trigger an alert to be sent out.
My design is based on events, so each new measurement that's received in the API generates a work item... |
(The code I'd have to post is huge, I'll resume to just function names)
I'm currently faced with the following issue on my project: I have a "each module from this framework can have a small view that users use to control its behavior" view-container sort of.
Basically each module can have a visual spot in a list, wher... |
I need to create a program to manage an association.
Members of this association have different roles and each role has specific characteristics.
My problem is that I'm not able to abstract this concept in my program.
This is what I thought so far.
Create a class Person that has generic attributes for members and not m... |
The language is PHP. I have the certain, in my opinion, code smell, it doesn't feel right: In my controller class that ingests objects of the same type (interface, it's ViewBlockInterface), I check if these certain objects have certain methods and based on that, do stuff, if not, just skip that object in the array.
if(... |
How to create a recommendation algorithm ("If you like X and Y, you might like Z")?
I want to create an algorithm which recommends "You might also like" items from an itemlist, based on user's current liked itemlist (favorites) and based on those created by other users with similar preferences (in JS/MySQL, but that sh... |
We are using GitHub and CircleCI. I know that pull request mergeability can be made to be dependent on the most recent commit, using status checks. Is there any way to make it depend on whether or not a build is running? How?
|
We have a large Git repo. The files are a mix of styles: tabs vs spaces, unix vs windows line ending, JSON formatting styles, etc.
We'd like to change every file to be consistent.
However, if I make the change, git blame will show me as the last person to modify every file in the repo. This would be literally true, bu... |
I need some advice...
I started working at a financial business world recently.
Looks like the DB architect uses auto generate function to create stored procs. At the end, we have way too many procs doing almost 100% same thing.
Let's say, we have a table with a flag. He creates 3 different procs to pull out the dat... |
The SRP seens fairly reasonable when you first look at it. Every class should have one reason to change. Every class should take care of one thing. Right. But let's see this class:
Employee {
CalculatePay();
Save();
DescribeEmployee();
FindByID();
}
This class was used as an example by Robert C. Martin... |
One reason I like .NET is because the 'solutions' and 'projects' lends themselves to good architecture.
Good architecture makes it easy to follow the happy path of Domain-Driven Design.
I've fallen into a habit of this kind of architecture for my projects. It's just a common sense approach for the onion architecture, p... |
It is widely accepted, that UT's are necessary for any large project with automated testing. However, it is rarely the case, that 100% of the production code is covered by UT's.
There are of course, marginal cases, where UT's are useless waste of resources, e.g. simple setters/getters. On the other hand, there are case... |
I have encountered two patterns to make a singleton class
Holder class
public class Singleton {
private static final class Holder {
private static final Singleton INSTANCE = new Singleton();
}
public static Singleton obtain() {
return Holder.INSTANCE;
}
}
Instance variable class
public... |
This question is about how many bits are required to store a range. Or put another way, for a given number of bits, what is the maximum range that can be stored and how?
Imagine we want to store a sub-range within the range 0-255.
So for example, 45-74.
We can store the example above as two unsigned bytes, but it strik... |
Let's say I want to use CosmosDB for Event Store, where have single collection for all events. Currently it is not horizontally partitioned, but it is a possibility for future.
Now, I need to implements event handlers, ideally as Azure Functions, but AppService will work well as well.
Do you have some guide, how to imp... |
So, essentially the flow of my application works like this:
A user selects some options to start a process on the server.
Once they hit submit, on the server it opens up a console application that processes large amounts of data and then exits when it's finished
The idea being that the user can start multiple processe... |
I am trying to understand trunk based development with semantic versioning for a Python project. Has anyone had any experience of adopting a trunk based development with semantic versioning for packages?
I store the semantic version in version.py:__version__
On the trunk (main) version.py:__version__ would be 1.0.0-SNA... |
If I were to have a class with a property on it should I be testing the get and set functionalities separately or together?
class MyObject
{
public string Name { get; set; }
}
[TestClass]
class MyObjectTests
{
MyObject subject
[TestInitialize]
public void TestInitialize()
{
subject = new M... |
When learning Git for the first time, I posted Git branching and tagging best practices. I learned a lot from this and have adapted git flow patterns to my personal projects since then. I am now in charge of a project at my job where I am trying to apply these concepts with a team for the first time.
We have been mergi... |
Can someone explain how floating point numbers are stored in C, as for 32-bit float, 1 bit is parity, 23 bits for mantissa and 8 bits for exponent. So for numbers greater than 2^23(still in the float range), there is no space in the mantissa to store them.
|
We have a web app in which we allow users to log into the app using any Open ID provider(e.g. Okta, Google, Facebook etc.). We want to implement the correct Open ID Connect prescribed methodology/workflow to keep the user logged into the site.
The existing implementation, looks at the expiry of the Access Token then if... |
I am interested how multi datacenter (multi homing in Google terms) systems handle writes to strongly consistent user data? Is the master replica for each user placed in the same datacenter and writes are done through log structured queue (or directly forcing the user to wait)?
Alternatively, do companies use an archi... |
I read through a code example on github
and instead of initializing the object using a constructor, they made every setter return the object itself to call it over and over again
See, constructors
DataSetIterator mnistTrain = new MnistDataSetIterator(batchSize, true, rngSeed);
vs chain of setters
MultiLayerConfigur... |
I'm working on an infrastructure for inter process communication.
I have created two interfaces, one to send data and another one to listen to data being sent:
public interface ISender<T> : IDisposable
{
void Send(T dataToSend);
void Disconnect();
}
public interface IListener<T> : IDisposable
{
event Even... |
I have a project where I develop a software which consists of a CORE which is in a separate project, developed separately, and a CLIENT which's base is the CORE but adds to the functionality with modules and whatnot. But also extends the System and other CORE classes. This is required because there are multiple SUBCLIE... |
I am coding a poof-of-concept throw-away GCC plugin (see this for more context) which would use the HTTP 1.1 protocol to interact with my Bismon (GPLv3+ code on github, but unreleased; draft technical report here) system (which provides some Web & HTTP service using libonion). Both server and client are on the same tru... |
I have to work on some code that was CAST-audited. The report says that it is bad in Java to use public static and that accessors should be preferred. That is also what I was taught at school.
The application uses public static fields in various classes to define the values that should be used in attributes etc.
Coming... |
Some base points:
Python method calls are "expensive" due to its interpreted nature. In theory, if your code is simple enough, breaking down Python code has negative impact besides readability and reuse (which is a big gain for developers, not so much for users).
The single responsibility principle (SRP) keeps code re... |
I have been practicing this hybrid approach for dependency injection in the last couple of days and I am wondering if it should also apply to components which are within the same package?
For example:
I have a GPIO module that uses the device chip and that required to be mocked for unit testing. I also exposed its Pin... |
I have an application that connects to SQL Server using windows credentials, which works very well for the domain paradigm. The client is now transitioning away from having a domain server, and is going to a distributed model using Sharepoint (the company is perhaps only going to exist for another couple of years). T... |
I'm trying to follow the Model–View–ViewModel pattern in a Xamarin application and am wondering how the View should be able to change when a given ViewModel is finished. Below I have listed the ideas I have come up with doing what I need.
Creating the new View directly in the ViewModel.
Currently, each ViewModel explic... |
In Rust, Send (or Sync) marker traits are used to indicate whether a value of a type (or a reference to that) can be worked on within threaded context.
However, it is an attribute of a function or a procedure that whether it is thread-safe, as frequently seen in C function man-pages (e.g. man 3 rand).
So, why rust is d... |
I'm working with some software that uses an HTML form for a user interface to change some configuration information. The back end is a database (loosely speaking).
The front end has a hierarchy of values which can be changed in <input> or <select> fields
When's the right time to push user-initiated changes into the dat... |
I am building a JSON-RPC over UDP socket API in Java. There are 6 objects that will be transmitted in JSON:
jsonRequest
jsonSuccessResponse
jsonError
jsonErrorResponse
jsonNotification
jsonSubscription
Under most of these, the following fields would be added to the message and be of types String and Integer:
Version... |
I'm planning an application in C# which has a feature of sending messages.
ATM I'm doing the non-businesslogics and frameworking stuff.
The idea was to make an abstract base class which is inherited when used.
In there, i'll implement what should happen with the message and when another one should be sent
Ex:
abstract ... |
We have been developing a requirements model for a travel agency system. There are two kinds of member users: premium and free. Both users are able to cancel their previous reservations. Unlike premium users, free users have to pay a cancellation fee as a result of cancellation.
In the use case diagram for the previou... |
I have read lot of articles on google how kafka cluster works. Trying to summarizing my understanding here . Please let me know if any point is not correct here?
Producer Side
Say Kafka cluster have one Topic with three partition(P1,P2,P3) on three nodes.
Each partition has two replica(R11, R12),(R21, R22),(R31, R32)... |
For a long time, the use of these Monad structures has been restricted to a very small circle of languages, many of them purely functional (mainly due to problems related to the management of the IO). Recently, these structures have also been adapted to imperative languages
My question is: we talk about same design pat... |
We have a system that holds credit balances, and we thought event sourcing would be a good fit.
Getting the current balance by reading from an eventually consistent projection works.
However, I still don't understand how to make sure that the debits/credits on the credit balance is valid/consistent without going throug... |
In the context of SDLC, I know that Verification and Validation is about verifying the deliverable input from previous phase and validating the output of the current one.
And that testing is a phase among the SDLC phases.
Based on my research, I found from UToronto lecture notes that:
V&V performed by a separate contr... |
Suppose I have game achievement class that stores achievement information like name, popup message, etc.
class GoldMedal implements GameAchievement {
@Override
String getName() { ... }
@Override
String getAchievementDisplayMessage() { ... }
}
Then when the game ends, I want to record current achievements to... |
What are best practices for modeling "arithmetic business types" like money or time?
Is it recommended to make classes with explicit plus/multiply operations? Should there be a class for every currency?
Or is it more practical to not model them at all with the type system and keep them as BigDecimal?
Example:
The bu... |
We have a product that contains features (Let's say feature A, B and C).
We are about to move it to production (a web application) for a certain client.
However, as per my boss, we will deploy the product to the client's premises. The client will also have the source code.
Now, my boss wants to restrict the features fo... |
I am practicing professional C++ by building a differential drive robot that applies a Go-To-Goal Behavior.
What is I have written so far is an Agent that consumes the following interfaces:
Actuators Interface
Odometry Interface
PID Regulator Interface
The motion of a differential drive robot is governed by the unicy... |
I don't dislike global state, but that could be due to the lack of experience. I was thinking about what the usual implementation of global state is:
A big variable where data flows in a non-consistent, unpredictable but most importantly, non-standardized way, referring to all CRUD operations.
An implementation like gl... |
Problem
Say we have a C# class with is serialized to JSON (currently via Newtonsoft's JSON.Net) and stored in a database:
public class User
{
public string authInfo;
}
If the class definition changes, the old data will fail to load. Even if we try to update the database by hand, data may be lost unless we have ser... |
We have a web application that all update, insert and DB operation procedure handle via SQL Server DB 2017. What is the best way to handle and get error (in Web-app or SQL server error handler?). for example a foreign key error occurred, is it better to handle it via DB or Code?
Update 1:
for all operation from serve... |
I am developing a website where customers can register products they bought in order to receive a benefit in the form of e.g. a cashback, a discount or promotional goods. In the future, we also plan on developing more of these websites in the future.
The website includes the following several registration steps:
One o... |
My team is interested to apply TDD in our next software project. We have a discussion about how many details should be specified in design specs before the developers start coding.
Some of us propose that we should specify all classes and their relationship in specs before writing code because we have to design all tes... |
I am building my first web application, it links to the serverside through RESTfull Web API (Angular on client side, ASP.Net Core and EF Core on serverside, Automapper to map API Resources to/from domain models).
In the application I have two main models (simplified below as Delivery and Order) and each has its own API... |
I am planning a spring boot application that can be extended with plugins. However, I haven't found out yet whether spring boot meets my requirements in this regard.
I imagine the following folder structure:
application
core <-- core jars
main_application.jar
...
plugins
PluginTypA... |
I'm using a pretty old library to make server requests which is not properly tested and it not really matching nowadays requirements, so the plan is to migrate to a new one over the next release. So the idea is to plan a migration testing suite in order to make the transition painless.
The thing is, the new library wor... |
I'm trying to switch to clean architecture from a traditional layered architecture approach and trying to figure out where to put business logic. Please consider the below scenario -
Employee class (exists in Efcore db first scaffolded in core)-
class Employee {
public int Id {get; set;}
public int TimeWorked {... |
I am trying to create a Put endpoint using rest. Let's say that under the link
/addresses/12345
I am trying to add a new address (if that id doesn't exist) or I'm trying to update it if it does already exist.
My application has several layers Controllers, Services, Models and Repositories. Given the fact that the busi... |
I need to send jobs to worker queues according to resource usage and other metrics like how many jobs have been processed and how successful they were.
There is also the need to “weight” these parameters to each other eg that if the success rate drops under an acceptable value others values might me acceptable now?
Ho... |
My intuition tells me that moving duplicate/common codes among subclasses to the superclass (so superclass now have a new method) is a bad idea, but I have seen this technique used/described in both Design Pattern and Refactoring(e.g. pull up method) books. After some thinking my idea is that now subclasses' behavior i... |
On our prod db we have two tables:
companies
invoices
Relationship:
A company has many invoices
An invoice belong to a company
The invoices table contains duplicate invoice_number for each company. What is the best approach to make invoice number unique for each company. what ever approach we go with, the changes sh... |
Recently, I've became the integration lead for a large distributed system. I have two main challenges before I can take on anything else: first document all system interfaces and it's relationships and prepare to upgrade for a new cloud infrastructure (and getting away from IBM stuff).
The first goal is tricky. We got... |
We are building an pseudo-rest API (because no body cares/funds for a full blown rest API for internal use - which is OK).
So we have elements of Rest API (links for resources, API naming conventions and standardized output data model following some naming conventions in google json standards).
But because of this Our ... |
I just have an idea about dependency management in Spring IOC environment that seems to be better than the typical approach, but I am not sure because I can't find any references or example out there that talk about it, though the idea is very simple. I will explain the idea comparing to the typical approach. Please he... |
I have multiple REST-ful APIs that I'm using as my "back-end". I also have multiple web apps (.NET MVC). These web apps make calls to the APIs for data. So, an object being returned by an API will be the same as the object being expected on the web app side (serialized from JSON of course).
For example, if my web app m... |
I have a Parent object which looks like this (pseudocode):
class Parent {
String token;
Child[] children;
}
It contains a token string and an array of Child objects. My problem is that each of these Child objects needs to access the token string from the Parent class.
My first hunch is to loop through the children... |
I am looking to build an app where the only way a new user can enter the app is if they have been invited by an existing user. Are there any API's, tutorials or resources that can help me achieve this. I am using Firebase as my backend and I know it has phone number verification, but I want only invited users to be giv... |
I've been having the hardest time understanding the difference between AWS Kinesis and Logstash.
From the description of Logstash it says
Logstash is a light-weight, open-source, server-side data processing pipeline that allows you to collect data from a variety of sources, transform it on the fly, and send it to your... |
As far as I know, each webpage is created in a two stage process, initiated by a webserver request and ended in a webserver response:
Parsing: markup (Say HTML) is executed as is, or created by executing a "server-side" or "backend" programming language such as PHP.
Rendering: Styles (say CSS), are added upon the pars... |
I'm learning angular and have been reading about various backend solutions like direct db access, REST, and graphql. One thing I haven't seen addressed anywhere yet is how do you protect privileged information from being leaked to an unprivileged user.
Say I have a list of users with the properties id, displayname, log... |
I want to develop a GUI in python for my company in order to sell it to the customer.
Being fresh from the university where I used pyQt, I promptly started programming using that library, just to discover the fact that it is under GNU GPL, making it unusable for my purpose.
Searching in the web for an alternative, I en... |
I have the following if statement and I feel it could be made simpler to read by breaking the terms up into their own named variables.
if os.path.isfile(os.path.join(dirname, 'file.json')) \
or (os.path.isdir(os.path.join(dirname, 'folder'))
and os.listdir(os.path.join(dirname, 'folder')) != []):
So it would look some... |
I work on refactoring an Java application based on a CAST audit. One of the criterion says that
To respect OO encapsulation concepts, private fields should always be
accessed through accessors
So far, so good. However, the audit highlights all private fields in the class that have no mutators, regardless how they a... |
Usability requirements are focused on User interfaces, how easy they are to learn, how quick access to some frequent menu options are provided, etc. Suppose we have the following requirement:
The system should show menu options after user login within 1 second.
What type of Non Functional Requirements is this? A perf... |
I'm defining a class structure for persisting to our cassandra database, and I'm unsure about using a combination of an abstract class and an interface. I have two concrete classes, one for persisting reports and the other for persisting configurations. They both have separate entity classes defined else where that the... |
At the risk of having this question closed as too broad, would like to know if a microservices-based application/architecture could be delivered with a traditional waterfall development methodology/teams where development team builds, test and hands over the code to operations?
Vice versa, a devops setup/team could als... |
We have been using Scrum as our project management platform for a while, now we are moving toward Lean UX and hypothesis driven development practices. We are using Poker planning to determine the effort needed to deliver the outcome.
We have decided to use Barry O'reily's proposition of including both user stories and ... |
My team are looking to push our shared code to a private NuGet feed in Azure Artifacts. At present the plan is to set the package version in our csproj files and set up CI on the master branch of each library's repo.
For production this flow is fine, but we'd also like to be able to iterate on new library versions and ... |
I have trouble with some of this jargon so I apologize if I misuse some of it.
In my past experiences Story Estimation (planning poker estimating how difficult/complex certain tasks will be with fibonacci numbers) happens before Task Breakdown (figuring out the implementation details of how the team thinks we should im... |
Say I have the following class, which maps to a database table:
public class Person
{
public Guid Id {get; set; }
public string Name {get; set; }
public DateTime DateOfBirth {get; set; }
public string ImageURL {get; set; }
public string ImageBytes {get; set; }
//Methods go here
}
Not... |
I get it for feature branches:
A feature branch is created from develop.
One single PR is then created, going to develop.
If there are conflicts, fix them in the feature branch.
Quite straightforward.
Concerning "multi-destination branches" though, like release or hotfix branches, how are conflicts supposed to be res... |
I'm writing some web socket (wamp) connectivity tests. basically one end pings, and the other end records it.
let's say I have the latency for each ping. So I'm tracking the min and the max latency figures.
the test however can run for a long duration of time, so a single min/max value won't tell me much about the na... |
I have a class that looks like this:
class MyClass
# takes an array of actions
def initialize(actions)
@actions = actions
end
def act
@actions.each {|a| a.do}
end
end
class Action
attr_reader :type
def initialize(func, type)
@type = type
@func = func
end
def do
@func.call
... |
When you have an endpoint that can take a set of valid parameters, how do you do validation on a non-empty set of elements?
Say you have a request /api/endpoint?my_list=1,2,3 where 1, 2, 3 are the only valid values for my_list. What do you do when the following request is made: /api/endpoint?my_list=1,3,7?
Should you f... |
I am currently implementing the transformer architecture for sequence to sequence problems. Key part of the model is the attention mechanism, which is basically a matrix multiplication, followed by a masking operation and a softmax function. My initial thought was to wrap this 3 steps in a function, that looks like thi... |
I am considering what it takes to implement an email server. Google Cloud basically doesn't allow you to send emails at scale (they block the email ports pretty much), though it sounds like you could receive email. AWS on the other hand allows you to send emails for about $1 per 10k. This sums up some other SMTP servic... |
We have 2 to 3 dozen microservices that serve our customers.
These services are deployed in a Kubernetes cluster, and they're only accessible to the outside world through 3 or 4 API gateways.
We found that sometimes the same data is needed by two or more microservices, so we evaluated a couple of strategies to solve th... |
We are starting to integrate our SQL Server workflow with Git, by which I mean generating scripts for all objects and storing them in a Git repository so you can pull, edit, commit, push and apply, rather than just modify objects directly.
One problem we have is that certain objects (in this case, stored procedures) ar... |
I am building a service responsible for sending email/sms communications. The service receives a request that contains information necessary to build an email/sms template and the recipient information of where to send it.
Example CURL request:
curl -X POST \
http://service.local/api/finance/payment-reminder \
... |
I'm trying to apply Clean Architecture to a simple ASP.NET MVC Core app by following Microsoft's ASP.NET architecture guidelines and their eShopOnWeb sample project.
In the standard Clean Architecture approach, business logic is put into "Use Case" classes in the core project. In the Microsoft's example, there are no U... |
I'm designing an app which use a Knowledge Base filled with rules.
Depending on the context some rules will be applicable and others will not.
I need to get first the list of the applicable rules and optionally later the list of non applicable rules.
The system doesn't need both at the same time and I want to avoid ke... |
As part of my bachelors thesis, I'm trying to develop something akin to a painting program. That means, I have a toolset, be it selection, drawing, highlighting, etc.
I'll have a canvas that displays my current model, based on a set of rectangles/spheres/polygons I have already drawn and created.
Some tools require th... |
I am planning to start a new asp.net core MVC web application. One of the features we are having is that anonymous users can register inside our web application by entering their email addresses. then our system will send them a confirmation email, to activate their accounts.
Now by default the system will show error ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.