instruction stringlengths 34 36.1k |
|---|
Background:
So there is a (Ruby) web app with a production Postgres DB (hosted in the cloud)
I would like to run some machine learning algorithms in a Python setting on the production data and (ultimately) deploy the model in a production setting (in the cloud)
I only know how to run these algorithms locally on say a ... |
Suppose I have a Button class with a color attribute.
I also have a Canvas class which stores all Buttons.
Every time a color is being changed, some side action must take place (in this example, for simplicity, a counter will be raised).
As follows:
class Canvas {
buttons: Array<Button>;
counter: number = 0;
... |
I am developing an iOS application that plots a large number of locations on a map, I have selected a data structure that is suitable for the pins on the map, though I am stuck on an approach for the data.
Each entry in the dataset is an object that contains a few strings primarily identifying items such as street addr... |
I have a question regarding proper design of tests.
Suppose that there is a class A
class A{
public:
virtual int methodA();
virtual int methodB();
virtual int methodC();
virtual int methodD();
};
And class B
class B: public A{
public:
int methodA();
int methodB();
int m... |
i've been wondering about it for a while now but never found any answers. is it possible to use something like a condition variable without a lock?
I have a vector of objects, and a thread pool, and I want each thread to access a specific cell once than go to wait for the master thread (that currently waits) to "broadc... |
I am wondering about the correct architecture to work with a progress bar in C#. But maybe it applies not only to C#, because I need an architectural look at this.
I'll explain my question with an example. The user presses a button and then the program starts to work on a huge algorithm. One part of the algorithm is ta... |
I doubt about to which semver version I should update my public NPM package. I didn't change any code, but I had to drop some node engine versions due to a dependency package which had a major update after using object spread props.
I have my doubts because my package has no changes that will break usage of my package,... |
I was reading an article from Microsoft regarding Widening Conversions and Option Strict On when I got to the part
The following conversions may lose precision:
Integer to Single
Long to Single or Double
Decimal to Single or Double
However, these conversions do not lose information or magnitude.
.. but according... |
I have a scheduled operation in my spring boot application using spring boot scheduler.
this operation executes every period of time(30 minutes) and adds data in the database if conditions are met.
I was wondering how to model this operation in a UML sequence diagram.
|
I have researched DFDs reasonably extensively, and received some feedback from peers about my first DFD. I have since reworked it to avoid lines crossing by duplicating the 'Pokemon' data store.
I have read that it should read left to right. Does this mean I should create another 'Pokemon Trainer' entity on the right, ... |
How does one go about e.g. missing documentation in the source files when using semver? I have just released 1.0 of my library and noticed that a class is missing JavaDoc - is it ok to release a PATCH version? I read the semver definition but could not find anything about that topic
|
I'm working on a test project, with the intention of using DDD.
So far I have this basic project structure:
My question is: How should the Core.Domain.Services be referenced? do I create an interfaces project like what I did for the application services, and use Dependency Injection ?
Edit: To be more precise, let's s... |
At start, I have these classes in code and consequently tables in the database.
Person
Company
Address
Both Person and Company have an address. So I have to establish a relationship between them. Person one - Address many (let's say a person can have more than one address). I know the same address can be for two perso... |
Suppose I have a function that returns an instance of a struct with the following declaration:
struct data API(void);
Suppose also that there is a chance for the function to fail with an error during the execution. What is the best way to indicate that an error occurred?
A solution that comes to mind is to create a st... |
I'm working on a class that receives a relational EDM/data model (e.g. a SQL DB or OData API manifest) and performs a couple tasks on them (not necessarily at the same time, could be two separate runs). The class/alg doesn't know anything when it starts, finds everything from the schema data, but the schema doc is stat... |
I am currently trying a create a fairly simple, declarative RESTful CRUD framework, whereby I can define a resource type, and have both the API endpoint created, as well as the the functions to Create/Read/Update/Delete the declared resource.
ie. the usage would look a little like this:
interface Student {
name:... |
I have a large project that is build contract based, where all functions verify input parameters and return values. But there are also cases where they for example verify that a call to a function is not null(while the same function also verifies that it doesn't return null).
And I am starting to think, what is the rea... |
I am designing a toy project dealing with the bank account management in F# with Event Sourcing.
I would like to get a bit of review (not really a code review) about my Commands and Events to see if things make sense to someone else.
// Force to use a certain Guid generation function
type BankAccountId = BankAccountId... |
I have an application in which users can create an order and payonline using stripe.js
When the order is created it's status is set to unpaid. The user then has the option to review the order on a checkout page and make a payment on a payment page which has the form for them to enter their card details.
I use the orde... |
I have a method:
public static void AddPersonToPeopleList(List<PersonModel> people, PersonModel person)
{
CheckWhiteSpace(person.FirstName, "FirstName");
CheckWhiteSpace(person.LastName, "LastName");
people.Add(person);
}
That calls the helper methdod:
public sta... |
I’ve been developing in Spring Boot for just over a year but have yet to understand the benefits of using an Autowired constructor and I was wondering if someone could explain this to me and what would be considered best practice.
Let’s say I have a bean as follows
@Component
public class MyBean {
void doSomeStuff... |
While I am learning C++ based on how develop in modern PHP frameworks I decided to use the Dependency Injection pattern with services as Singletons.
For making myself clear let suppose we have the collowing classes:
class B {
public:
B(){};
}
class A{
public:
// Dependency Injecting class B into class A
... |
I'm very new to micro-services but am trying to learn, so apologies for any ignorance or incorrect information.
I have been looking at event-sourcing architecture for microservices and I have a question when it comes to making a command/post requests and having to wait for their response.
Take this example:
I want to ... |
If you have a view file which you want to re-use for different pages which have, for example, slightly different page headings, is there a 'best approach' of the three below? (Considering separation of concerns, business/presentation logic, etc.)
As an example, if I have the same ‘What is your address’ page but for a n... |
I've been thinking about a simple software design problem. Imagine I am writing a web application to edit a tree of objects. Each node of this tree has an ID property that is filled in when the node object is POSTed to the backend. A user can create a tree hierarchy with multiple nodes before anything is sent to this b... |
I am writing a processor for the Citation Style Language (CSL) in JavaScript.
Before I explain what my problem is, I must give some context first:
CSL is an XML specification for describing how to generate citations and bibliographies in a particular style (e.g. Harvard, APA, etc.)
Let's say I wanted to create my own c... |
I'm working on a project that integrates with a third-party service via API, and the third-party uses callbacks to update us on the status of the operations being performed. These callbacks can be hit up to a day after the original method call as we're dealing with complex financial operations.
I need a way to authenti... |
I'm using a raspberry pi 2B with raspbian lite.
I have made a program that communicates with a LoRa module (RFM95, sx1276 chip) and collects data from a sensor.
The data it collects, are stored in a file date.log and goes to Google Drive using third party software.
Now I want to make an asynchronous TCP service to col... |
I have a c# solution which uses mssql database to store data.
In my database there is a big table of entities (e.g. accounts) for each of which the TimezoneId field is defined. This field is filled during the registration of a new account using the MaxMind GeoIP2 library.
+----+-------------+------------+
| Id | Accoun... |
I'm not talking about the usual refactoring of new code you do as part of a development. This is more Boy Scout Principle type changes.
While I understand why they're all made in the same branch, it seems there is some mileage in keeping them separate:
The intention of the functional change is clearer in the maintenan... |
Picture this feature:
Respond to a user from the event stream
The event stream is like Twitter's home page, a stream of messages or events that were triggered by any number of users. The feature is to build a reply feature to one of the messages. Think the ability to reply to a tweet from the your personalised homepa... |
I am trying to code a game which currently uses a matrix ( that I am calling a map). On this map are islands which can be generated n times. The purpose of the algorithm is to distribute the islands across the map in a way that makes use of the space to ensure they are not too close or too far away from each other. Thi... |
Can event sourcing be considered as the same architecture pattern as event logging? Right now we plan to Kafka (or Kinesis) as a pub/sub persistent event data store. We shall not be implementing any kind of snapshot/lookback feature as our business-case actually does not need it. We had thought about using Sql Server T... |
I have a simple toy project that deals with Banking operations (cash deposit, withdrawals, wire transfers, open and close accounts).
I am wondering whether there is something wrong about saving invalid operations.
Say the command sent (eg. withdraw cash command) to the Event Sourced system is flawed, for example the ba... |
I have a Pose data type, consisting of x, y, and rotation values.
This being a robotics application, the Pose data type is used in about a dozen places throughout the application. Connecting all these up with dependencies makes the diagram very messy, is there a better solution?
|
Let's suppose we have a Web Application that uses an Open Id Connect service provider, the Web Application uses the Authorization Code flow to get access to a different API, and therefore gets an access_token and an id_token at the end of the exchange.
So, now that we have an access_token to our API, we'll include it ... |
So I have the following case. I have an interface A and an implementation AImpl. Now I have another implementation of A, called A2Impl, which references any instance of A besides implementing A already.
So I have now drawn the following UML class diagram:
Would this be correct? How do i draws this correctly?
|
Take the following instance for example:
CreditCardApplication class
public class CreditCardApplication
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
public decimal GrossAnnualIncome { ge... |
I appreciate if someone could clarify my confusions about the following quote from Distributed Systems, by Coulouris et al:
Consider the functional decomposition of a given application, as
follows:
• the presentation logic, which is concerned with handling
user interaction and updating the view of the ... |
I want to loop over a number of rows in a database and I have implemented an object in order to access the rows. Now when using this object I am not sure about the best practice. Implementing an iterator looks nice in the higher-level script but is somewhat unnecessary.
So I wondered, what are the benefits and disadvan... |
In one mock solution, I have created 3 mock projects to implement layered architecture design mainly the - Presentation Layer (Web) - Domain Model Layer - Infrastructure Layer. I haven't yet to add Application Service Layer (Web API).
For simplicity, I have only two domain model entities: Customer.cs and Category.cs. I... |
I have an API route as so:
GET /api/item/like
Which makes a like object between the logged in user and item object, and it works fine.
Is this the correct way to have a user 'like' an object? Or should I use PUT or POST? If so, how?
|
I hope this is the right place to ask since this is a programming related question.
I’m developing a venue reservation app (similar to booking.com) and am almost done however I have 1 request for clarification/advice from people with far more experience.
Let’s say there are 2 individuals (PersonA and PersonB) looking ... |
I have a common issue I encounter which I've solved with a Factory class in the past but it always felt a little "off".
Let's say I have multiple Exporter classes which implement IExporter, which has a single method:
void Export(string outputPath);
...each Exporter class knows how to export different types of data (fo... |
I've just started my first proper internship in industry (not learning to code but learning to write software that does stuff). My employer makes use of Apache Spark, as they do a lot of Big Data processing, which exposes an API in four(+) languages, Python, Java, Scala, Spark SQL (and R).
In the toy programming I've ... |
Say I have a bounded context called: 'Loans' and the following APIs:
HSBC
NatWest
TSB
The three banks above are consumers and have an API. I am using the scatter gather pattern (https://www.enterpriseintegrationpatterns.com/patterns/messaging/BroadcastAggregate.html).
Would I have one domain model (.NET Project) for ... |
My team and I use a git repository to keep track of our projects. This repository is cloned in our Windows PCs that we use to develop most of our software. However, we also use another machine ( a linux VM, which we access through ssh ) to develop other parts of our software.
The idea here is to keep track of the files... |
Let's focus on a single endpoint, which always returns an encoded JSON object with a well defined and documented structure.
But when an exception is thrown, the exception itself is formatted to a JSON object with the next structure:
{
code: 462
message: 'whatever specific error occurred'
}
Is this legit or all respo... |
Suppose I have the following problem:
I have Users who work in Departments. A user can work in multiple departments and a department can have multiple users. Each departament gives to its users only one role.
Could someone review this design?
|
When building parallelized applications using Java, a developer sometimes finds himself with a thread being blocked indefinitely because of a four-year-old bug in the spring-bean-web-rest-foo-bar-factory - dependency, possibly ruining the carefully orchestrated parallel architecture without any log message pointing to ... |
One Premise I worked under for API development is "The Consumer of the API adapts to the API." For example if I call Yelp or Twitter API I have to adapt to it. There is no way they are going to modify it for my requirements.
This leads me to an issue that has recently come up with a vendor. A vendor solution needs to ... |
I'm developing some C++ code that eventually will be compiled as a DLL to be accessed with Python through CTypes. My workflow is generally that of compiling the DLL and running the Python script which calls the DLL.
However, when rapidly iterating and debugging, that can get cumbersome. Sometimes I want to quickly ru... |
I'm looking for some advice or potential options for loading javascript files in real time long after the DOM has fully loaded. Those javascript files need to be sent over a WebSocket connection, and thus are unknown on page load.
Backstory:
I've been working on a VR game for the past year and a half, and progress has ... |
In a course, a test's solution says the following has a 4-tier architecture
But it seems to have a 3-tier architecture to me.
I don't count the client (web browser) as a tier itself, but the test's solution seems to count it.
Which one is correct, according to the wikipedia article or consensus?
|
Basically I need to execute different actions given a certain condition. The existing code is written this way
Base interface
// DoSomething.java
interface DoSomething {
void letDoIt(String info);
}
Implementation of the first worker class
class DoItThisWay implements DoSomething {
...
}
Implementation of the s... |
The question/s
I'm working on a small scientific Python package. Many of the public methods it is going to offer will have to deal with dimensional input. A wavelength, for example, which could be available to the user in microns or as the equivalent vacuum photon frequency or who knows how.
I could simply state what u... |
Displayed data can be changed in the underlying database by any user. How do you show the change to all the other users?
For instance, I have database tables for building and associated rooms. Any user can bring up the lists in their browser and edit. So if user A changes the capacity of room 123 in building X from 30 ... |
I am currently working on an OpenGl program whose performance I would like to improve. The performance is okay but not ideal on powerful dedicated GPUs, but is abysmal on integrated graphics (< 10 fps). In a normal program (CPU-based, no OpenGl or other GPU API), I would run a profiler (perhaps the one built into CLion... |
I've run into this issue a few times. I have preexisting framework objects that do not share a common ancestor. An example of this would be a class representing a an environment variable and a class representing a key in a config file. Both have a key and a value, and for the intents of my use, that is the part that I'... |
Trying to figure out the best place to store calculated properties related to a base entity class for use through out the application, namely in view models and DTOs.
For example, a base entity class of OrderDetail may have properties OrderedQuantity and UnitPrice. Where would I put the calculated property ExtenedPrice... |
There's is a statement from https://martinfowler.com/bliki/DDD_Aggregate.html:
An aggregate will have one of its component objects be the aggregate
root. Any references from outside the aggregate should only go to
the aggregate root. The root can thus ensure the integrity of the
aggregate as a whole.
What I hav... |
I am working with Reddis but this could apply to any PubSub implementation. Essentially we are trying to implement an event system using Reddis's PubSub capabilities.
As an example UserA creates a WidgetX so we would publish a "WidgetX.Create" event. There could be multiple subscribers that subscriber to this event. On... |
I know that the compiler and architecture of a processor also have a role to play in this. But this is more of a "can it" rather then a "does it" question.
I have already tried to research this, but all I could find out is that int16_t and int8_t are used for the times where you need a precise size in the length of the... |
I'm thinking of not keeping user orders as separate Aggregate instances, but combine them into one UserOrders. Is such an approach going to have some flaws in terms of DDD? Along with orders, I would keep the deliveries (that can spread across the orders) and payments info.
There is probably will be not many orders cre... |
Occasionally, I want to write an interface that provides some complex method, and I want to make that a default method that uses some protected helper methods.
The objective is such that I can later on change the logic in the complex method and have the changes apply to all implementations of the interface, some of whi... |
For example:
var duckBehaviors = new Duckbehavior();
duckBehaviors.quackBehavior = new Quack();
duckBehaviors.flyBehavior = new FlyWithWings();
Duck mallardDuck = new Duck(DuckTypes.MallardDuck, duckBehaviors)
As the Duck class contains all the behaviors(abstract), creating a new class MallardDuck (which extends Duck)... |
Often I find myself writing a unit test for code and repeating some or a lot of the logic in the unit test to make the unit test DRY.
For example, consider the following piece of code:
function speak(conditionOne, conditionTwo) {
if (conditionOne) {
return "Hey"
} else if (conditionTwo) {
return "Sup"
} e... |
Say I have two classes abstract class A, class B extends A, and I let A has a private field of type List<String> to indicate that every subclass has a field of type List<String>(so I don't have to declare it for each subclass). Now if I want to let B to decide which implementation of List<String> it want to use(e.g. Ar... |
I am making a multiplayer card game and am using NodeJS as my server with SocketIO.
My question is how should I be managing multiple game rooms (say an n number of game rooms) ?
Currently I have it setup as the server holds a JavaScript object which will hold all the game objects.
let games: {
“room367”: Game(),
... |
Structure
I have a structure like this:
level 1 items represented by a capital letter (A, B, C, D,...)
level 2 items represented by lower case letter (a, b, c, d,...)
level 3 items repredented by numbers (1, 2, 3, 4,...)
these items are grouped into "combination" consisting of:
(level 1 item, level 2 item, le... |
I frequently find myself pulling up helper methods in order to make my code better, but end up with duplicate method names. Is there a standard way to name such methods without getting duplicate names?
Example of code before:
function hello(suffix) {
if (typeof suffix === 'string') {
return `Hello ${suffix}`
} ... |
I recently had thoughts on handling the flat vs nested architecture when designing a RESTful API.
Would there be anything wrong with having a system where your nested resources can be specified within a query parameter of the API request? This is only needed in certain complex situations, otherwise you would just acces... |
NancyFX has Content Negotiation feature that I can write additional serialization adapter for S-expression by implementing IResponseProcessor interface.
And there is a problem... S-expression's MIME type seems to be text/plain.
So the web server cannot decide actual text file type in HTTP_ACCEPT header.
Is there well k... |
We want to build a rest api layer on top of a soap webservice.
Our current situation is that we have a coldfusion application that talks with the webservice, both running on different servers. The webservice has no rest support which is something we do want. It will also never support such a thing in nearby future. The... |
What is the common practice of adding parameter to a method of a java class?
Normally if I am modifying an equivalent method written in older python (without type support), I naturally put the new parameter last to avoid making changes to existing code.
However here is my situation:
class A {
public void doSomethi... |
(Disclaimers: I have checked on Google and this site. I have read this answer, which is the only related one I could find here. Additionally, that answer is from 2017, and I wonder if things have changed since. I have read the help and Meta pages about what is on-topic. However, it's been a while since I've asked a... |
I have two functions that group a list of dicts according to the value of a certain key. Here's how my array looks:
const sections = [
{
file_id: '1',
heading_level: 4,
readme_file_name: 'Quick.Quick.md',
section_codes: [
1,
3,
],
section_id: '1',
title: 'Nimble',
},
{
... |
I understand that having circular dependency can be bad design. However, I have a question regarding a certain class structure.
As an example:
ocean.ts
import {Boat} from './boat';
export class Ocean {
boats: Array<Boat> = [];
getWaterLevel() {
return 5;
}
createBoats() {
for (let i =... |
In Service Oriented Architecture (SOA), should there be One Single Database "with the share as much as possible philosophy" or Multiple Databases by Service/functional area?
I know in Microservices, the hard rule is to apply one database per area.
Just curious if the hard rule applies to SOA?
This is not opinion based:... |
I have a network application F. It receives requests from one (or many) client network function. F can handle multi-client requests using an epoll loop. F maintains a state machine for each client(user). F also maintains some context for each user or client. Whenever a message is received from a client network function... |
I'm programming a telegram bot with Python and, for a number of reasons, there are no classes in the whole project, just several functions correlated to the the file where they are located. E.g., my parse() method is defined inside a parser.py file.
If I'm not structuring the project in terms of classes and objects a... |
I am studing the importance of the design pattern and I am not able to understand if could be a bad behavior to create a global static factory class (maybe using singleton?)
I put an example hoping to make it clearer.
Put that I'm creating a simple game, it could be mastermind or battleship or whatever.
I could have h... |
Does it optimize a program in java to declare methods private wherever they can be private or it doesn't change a thing and it's just a question of encapsulation? I was asking myself if declaring a method public was heavier than a declaring it private in terms of memory consumption.
|
Assume we're building a fleet management system that is monitoring telemetry on a fleet of cars. Important telemetry include like location, speed and engine temperature. Metrics are mostly dynamic and depend on what sensors they want to install (e.g. vibration, tyre pressure, weight sensors).
Metrics are viewed as pote... |
I am new to database managment, and I am wondering if it is a good idea to create temporary users to restrict access to only a single table.
Like having an user named _logs can only (read?) and insert to the logs table.
I am unescaping the values and I am using environments vars, but I think it would be more secure, bu... |
I am working on multiple projects as a developer and second line support, It happens that I fix a bug on one project, test and deploy the change then leave the project for months and return back for another bug fix or change request.
It also happens that I start development on some project, then it's put on hold for a ... |
Reference:
http://junit.sourceforge.net/junit3.8.1/javadoc/junit/framework/TestCase.html#setUp()
setUp should have ideally be named as setup
I've explored if any duplicate method setup is used in its parent hierarchy, because of which they renamed the method to setUp, but couldn't find any.
|
Let's say you have a game, and players of your game can get scores. You also want to be able to post these scores to a server using calls to a web API. Obviously, you want to be able to tell who sent the request; you only want to trust calls to this web API that came from your application.
If I understand correctly, th... |
I'm currently creating a mobile app and have the following issue.
I am required to only allow the user to login from a device that is registered to the users account. A user can have up to X number of devices registered at any one time.
So when the user registers and they first sign-in. I would need to register the dev... |
To exchange data between our standalone frontend application and the backend API, we currently have a REST API, with standard endpoint to list/create/update/destroy ressources with a consistent naming and appropriate routes e.g for users:
GET /api/v1/users: list all users
GET /api/v1/users/{id}: return a specific user
... |
In our project, we have 5 teams working on a monolithic application in 3-week sprints. Until now, all commits go into master (via Gerrit). Our test pipeline is too lengthy to ensure quality pre-commit, so we have to accept that some commits break things. I'm aware that the root cause here is the pipeline, and a breakin... |
I am currently building a game series information site and have come to a design issue. I have a table called Abilities that would have character ability information in it. Depending on the game there could be special columns added that are unique to just that game. For example one Ability in Game A requires the use o... |
In Domain-Driven Design (Eric Evans) the discussion on side-effect-free functions talks about separating commands which "result in modifications to observable state" from queries which have no side-effects.
Then there's this part (emphasis mine):
Strictly segregate commands into very simple operations that do not ret... |
Situation:
A Client is requesting a resource from a Host multiple times, usually with minutes or hours between requests.
The Client has a signed, verifiable token, which we'll call a Receipt, that asserts that they should be allowed to access the resource. (The Receipt will eventually expire, say at the end of the m... |
I'm a long time Java developer, but with so little traffic on SE, I don't limit my viewing to any single tags. I've noticed that C# questions with async/await come up a lot, and as far as I've read it's the standard (but somewhat recent) asynchronous programming mechanism in C#, which would make it equivalent to Java's... |
I am working on a python project and I didn't use classes but created different modules and added functions in them.
Now I need to draw a diagram to describe the project/application for a paper. I already have a context level diagram and activity diagram. But now I need to describe the functional implementation of the... |
The CI flow for our Node.js app looks roughly like this:
Currently, this all takes place in a single TeamCity 'job' with three 'steps' (the Test step runs 4 concurrent child processes).
Problems with the current approach:
The whole job takes too long – 15 minutes. (The Test subprocesses run in parallel, but this o... |
Backstory (You can skip)
Awhile back I was developing a console toolkit for displaying debug messages and the like:
It gives me colour coding, blinking, underlines, bold, italic, etc.
While developing this library, I quickly learned that nesting with ANSI escape sequences was impossible, but assumed that good reasons ... |
My Java application uses Hibernate and H2.
It process music files within folders. Typically for a folder it would read the files in the folder and store each file as a Song class in database, then later on it would add additional data to those Song objects.
The application is multi-threaded so therefore multiple folder... |
Background:
we have 2 bounded context: Inventory and Sale
application context is Point-of-sale system
Scenario:
When a Checkout happen on Sale BC, we would like to decrease quantity in Inventory.
Problem:
We have 2 handlers in this problem that is interested in Checkout or PurchaseCreated event:
The handler from Inv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.