instruction stringlengths 34 36.1k |
|---|
After two hours reading/searching in about examples and usages of selection behavior of object flows, I guess that selects all tokens which satisfy a criteria (like a query) and this can change order of tokens as specification in 15.2.3.4 Object Flows says:
If a selection Behavior is specified, then it is used to offe... |
I have a data science application that involves training tens of thousands of small individual Gaussian models. By "small", I mean that any individual model can easily be trained on one of our worker servers. In fact, we should be able to train several at once on each node.
I have been exploring using Spark with Yarn, ... |
If I'm building microservices using Node on Docker images - it's necessary to keep an idea of what version of Node I'm using.
The idea is - I'm going to be running Node locally in development - and then it still needs to work when running on a container.
If my Dockerfile looks like this:
FROM node:10.10-alpine
# Cr... |
I've got a design problem, and I figure it's not something totally uncommon so there must be some good practices out there.
I have 2 domain entities: Process and Task.
A Process is essentially a list of Tasks.
The functionality of a Process is to know what kinds of tasks it consists of (Task instances are created using... |
I’m looking for information on a pattern that I have used recently. The basic idea is that there is a type with a property that can either be compile-time (template parameter) or runtime (member). std::span is a good example of this pattern. Here is an example of the pattern in its purest form:
// sentinel value
conste... |
GOAL: to have a main class which has some global variables which need to be modified by other classes.
I have a class with a structure like below
public class ClassName {
public static int variable;
public void meth1(){
}
...
}
Then I have other classes which need to use and upd... |
I'm programming against a API Library which provides classes like Document, Folder, ContentElement, Action...
These classes are basically just their respective representation from the database.
I'd like to extend (doesn't necessarily mean subclass here, could also be composition) these classes for easier handling in my... |
When you create an extension method you can, of course, call it on null.But, unlike an instance method call, calling it on null doesn't have to throw a NullReferenceException -> you have to check and throw it manually.
For the implementation of the Linq extension method Any() Microsoft decided that they should throw a ... |
We are developing a new Angular SPA which leverages Keycloak for its SSO abilities using OpenID Connect (OIDC). The app is currently designed to use the Implicit flow to retrieve short-lived access tokens via the keycloak JS adapter.
However, recently, I've been seeing some emails in the ietf mailing list indicating ... |
First, I read an excerpt Edsger W. Dijkstra's 1974 paper "On the role of scientific thought":
Let me try to explain to you, what to my taste is characteristic for all intelligent thinking. It is, that one is willing to study in
depth an aspect of one's subject matter in isolation for the sake of
its own consistenc... |
I "herited" a lot of Spring Boot code which is basically an asortment of REST Webservices.
All those webservices are separated into an interface and an implementation and I find it hard get a grasp of which method is doing what and change an implementation.
The interface usually looks like this:
@RequestMapping(value =... |
I was reading on this SO page about when to check parameters when constructing an object. The accepted answer suggests throwing the exception from the constructor so that an invalid object cannot be constructed.
I agree with that approach, and I can't see how a Person can be constructed without a name.
However one of... |
When a system is running low on available memory can it ask programs in general to give up any non-vital memory without shutting down.
Like a process signal which causes the processes to yield any memory they can which does not render them unusable.
Think of it as a stage before caching them to disk or terminating the... |
I am attempting to write a code to test Lamport's Mutual Exclusion algorithm for safety as a correctness measure. I am running the alogrithm on a single core cpu machine with multiple processes sharing the same processor clock. One of ways I was planning to test was by recording the entry and exit times of each process... |
As per the documentation at https://firebase.google.com/docs/cloud-messaging/js/client,
The FCM SDK is supported only in pages served over HTTPS. This is due
to its use of service workers, which are available only on HTTPS
sites. Need a provider? Firebase Hosting is an easy way to get free
HTTPS hosting on your... |
My vendor can log in to a master management system (System A) which manage multiple subscriptions of a SaaS (System B). Each System B is hosted separately on an isolated server. System A and system B communicate through REST API.
My vendor holds the decision to update System B, which lead to multiple version of System ... |
The general and pretty much standard way of packaging a python distribution is to use setup.py, however I've seen an approach where the code is not installed, it's just invoked as a script, and any adjoined library (that is, it is part of the same codebase, not one that can be retrieved from pypi) is eventually made ac... |
I have an abstract base class that is inherited by several different other types. They were all using a type injected into their constructor. So I moved this property in to the abstract base class. The base class doesn't use it in any of it's methods. It is used in every single one of the inheriting classes though. Sho... |
I am trying to write a client for a restful service. I am confused in designing the models. Below are the details:
I have a Model named UnicastMessageRequest, it's definition is like this:
public class/abstract-class/interface UnicastMessageRequest
{
public string tId { get; set; }
public IDicti... |
Having two classes:
public class Parent
{
public int Id { get; set; }
public int ChildId { get; set; }
}
public class Child { ... }
When assigning ChildId to Parent should I check first if it exists in the DB or wait for the DB to throw an exception?
For example (using Entity Framework Core):
NOTE these kind... |
When I am working in ASP.Net MVC or WebApi, I often find myself creating Views or return data structures that include 'List<>'s of objects. Meaning that I have a list of data objects that I want to return as part of a view.
I know that best practice is that the property for the List should be a IEnumerable interface. B... |
In C#, the DateTime property Month has a type of int (a 32 bit signed integer) yet its range will only ever be 1-12. What are the reasons the C# team chose int over a smaller numeric type such as byte(8 bit unsigned integer)?
|
Context
Currently I'm struggling with correctly modeling a small instruction set I want to send as JSON to an Android application to generate a list of UI parts. Right now it's layered as pretty much a single cascading tree of objects/conditions and meta-data.
Small example:
{
"instruction": {
"remarks": "",
"steps": ... |
I find the following dilemma often. Suppose you're retrieving Json messages from a database, message bus, event store or whatever, and you need to deserialize each message into the proper type.
Something like var deserializedObject = Json.Deserialize<?>(jsonMessage);
What's the best strategy/design to do so?
I guess th... |
As far as I know, ideally testing should be done extensively as hard and far as possible, however sometimes (always) we are required to ship quickly.
In case of a delayed or a over-deadline projects, is there a best practice in how much testing is enough? or is it subjective? Obviously no testing is planning to fail, b... |
I have primarily worked on java. Now Learning PHP.
After reading couple of articles on google, i got the understanding but got some doubts too.
Compiled vs Interpreted
Java Compiled language :-
Developer writes helloworld.java, compiles it and run it on JVM. Java needs to be explicitly compiled first by developer and
h... |
I have recently joined the company where I see below stack to handle the http request
CDN -> LVS(Load balancer) -> NGINX -> Apache
My question is about using advantage of NGINX b/w Load balancer and Apache. Folks who took this decision left and most of the team is new.
I read couple of articles on google where most ... |
As far as I know, there are two commonly used patterns when dealing with services communication in a microservices architecture:
Direct-calling other services. For example: Service A handles some data, then it needs to tell Service B to do something with that data. A knows B's endpoint URL and calls it directly.
Using... |
For our project, a protocol is specified for communication between an embedded linux device and a PLC/HMI. This protocol includes CRC checking.
However, the communication is now done over TCP (TCP protocol includes CRC), so my question is whether or not a CRC on top of TCP has any meaning ?
|
Currently, I'm trying to migrate multimodule angular + spring 4 app build with ant and ivy to Spring Boot and build it with Gradle. The issue is that I don’t how to create build upon some custom requirements.
Currently, app consists of 10 separate modules, each module is built to WAR file and deployed on a standalone t... |
A common pattern I've been using for JS/NodeJS applications is the following:
import { utility1, utility2 }
function exampleScript() {
utility1()
utility2()
// Does something
}
Basically my main application function would rely on smaller helper functions that I could separate and modularize. But I'm not sure what sty... |
According to my teacher,
A CONTEXT diagram NEVER shows what goes on INSIDE a system!
It only shows the EXTERNAL entities and the circle is the SYSTEM BOUNDARY. ie the boundary between what is INTERNAL to the system and what is EXTERNAL to the system.
In the context flow diagram I'm given, driver entity is not show... |
First of all, I am sorry if it is a duplicate, I could not think of any "correct" wording to search about this.
Second let me clarify: By "equivalent" I mean methods that are meant to have the same behavior, either because api design or other reason.
An example of this is the Java Deque interface (or ArrayDeque if you ... |
I have used some kind of "listeners" where I have an interface implemented by classes that need to be notified of some event (e.g.: CurrencyListener, with a method currencyUpdated(Currency currency))
Then, the object that needs to send a notification, has a list of listeners (List<CurrencyListener>) and just iterates o... |
A team created a structure like this (pseudo-code):
struct Rectangle {
int left, right, top, bottom;
}
Half a project later, the team realized that two thirds of the code was filling this structure with coordinates where top < bottom and the other third used top > bottom.
A requirement is that the coordinates wil... |
I have seen examples of methods whose name ended with a preposition applying to the first (and most often only) parameters.
But other examples don't use this kind of naming convention.
Which do you think is more readable?
For example, should I make a method like this:
getColorFor(Player player)
or like this?
getColor... |
I am making a REST API in Go using PostgreSQL.
Quick introduction:
I suddenly have a case where I have different variations of the same basic entity, one of the variations have maybe 12 extra fields than the base, and two other variants have a few more fields. I have mapped this using the Inherits syntax in Postgres wh... |
Most of my work is written in Java using Spring Boot. In a recent project my entities contained no business logic, Spring Data was used to handle repositories and I have service classes that controllers would call to retrieve certain data or perform actions on an entity. For example, you might have a UserService with a... |
Working in the embedded systems space, our products usually require multiple binaries for each of the microcontrollers within a single product. Using SVN previously, we would bundle validation and production releases into folders that contain all the necessary binaries to be loaded, e.g., v01_00_00, v01_00_01, and so o... |
During the development process many migrations may appear. Is there any point to keep them instead of merging them all together?
Let's take a look into a simple example.
During development we introduce a new model Person:
public class Person {
public int Id { get; set; }
public string Name { get; set; }
}
Migr... |
For example, suppose I have 2 arrays:
let arr1=[5,2,1];
let arr2=["abcde","ab","a"];
my work is simple : to check if length of strings in arr2 are larger than corresponding element with same index in arr1, so:
let arr1=[5,2,1];
let arr2=["abcde","ab","a"];
is true,
let arr1=[5,3,1];
let arr2=["abcde","ab","a"];
is ... |
I hope the question title already answers the subject here. Lets say I have a number of ids that needs to be validated in a request.
Example:
request uri:
[POST] /album/{album_id}/song
Request payload:
[
"song_title": "hello world",
"genre_id": 2,
"artist_id": [100, 102],
"lyrics_by_id": 201
]
Now, as we know... |
In the space of 3D geometry, I need to compute the magnitude of the cross product of two Line3D because I want to check whether these two Lines are "parallel" to each other.
Line3D is consisted of 4 fields, x1, y1, x2, y2 denoting the two points. the x and y are of the type double
In theory, two lines are parallel if ... |
I'm unsure about several things:
I have a class that implements a NotificationDispatcher interface. This class I named WhatsappNotificationDispatcher, another implementation goes by EmailNotificationDispatcher.
The Whatsapp message delivery itself is implemented by the API of an external service provider.
So now I h... |
An algorithm takes 1 second to execute a dataset of size N on a particular computer. Replace it with a computer that is 10 times faster. What will be the size of the dataset you can process in 1 second on the new computer if the execution time for a dataset of size n is proportional to n^2?
I am having a hard time wrap... |
Is there really any actual use for private variables and specific moments where they would be your only possible option? Or can you just set all of your variables as public without any actual changes to the program? It seems like a pointless practice that doesn't really change much, from my perspective, so I'm wonderin... |
I'm working on a portion of an ERP system where I need to process data in a way that's similar to a series of batch jobs, and I'm struggling with deciding the best program architecture to use. I'm asking here because I know I'm ignorant of a lot of state-of-the-art programming methods, and I'm worried about designing ... |
Would there be any downsides of creating sub-interfaces for virtual member functions that have different parameter types? A drawing of this is shown in the image attached.
Apple and Orange do not share similarities and they themselves are interfaces. Making a higher level Fruit interface would run into the same issue... |
I want to understand different ways to object design classes. I have three different classes. Generally I am creating a file parser.
The classes:
CustomerData - which shows text Data Model.
A File Parser, which will take data from file and place into Generic List
And Folder reader, which will run FileParse for All F... |
Reposting question as Previous post on same Topic was not clear.
Currently our financial application receives multiple feeds in csv format from client, there are usually 100k to 5M rows of data. When this information is processed we need to enrich the data and store them, various look ups are performed and based on da... |
I'm familiar with the serverless programming model e.g. GAE and AWS lambda etc. But what is "serverless mesh"? I googled it and found no definition.
|
I have a very large class of 59 methods and about 3000 lines of code. I know that's far larger than most people would want, but the class represents a virtual machine, and most of the methods are run time functions, so I think this is one of the times when a large class is warranted.
The question I have is how can I be... |
I am thinking on how to structure a project. I wonder if it is a good practice to use different entity classes between the BL and DAL in order to decouple these layers.
I have worked on projects where entity classes where in a separated project/package. Then BL and DAL used the same entities.
But I can imagine that ... |
What is the official name of the principle, in language design, where the language tries to offer one way of accomplishing a particular task (as opposed to have multiple ways of accomplishing the exact same thing)?
|
We've got a situation where I have to deal with a massive influx of events coming in to our server, at about 1000 events per second, on average (peak could be ~2000).
The problem
Our system is hosted on Heroku and uses a relatively expensive Heroku Postgres DB, that allows a maximum of 500 DB connections. We use connec... |
I have to rectifiy an application that basically serves content by using two REST endpoints. Both endpoints transfer files to the browser, one endpoint does so by providing the file in binary format, the other sends the file base64 encoded.
The application had a file handle leak in the endpoint that serves binary data.... |
I am planning to design a new web application using ASP.NET MVC 5. I used to write a lot of JS/Jquery code on UI when I was a beginner with Web forms applications. After reading/learning a lot of software designs/patters/practices:
MVC pattern suggest that you should not include any business/application logic on Views... |
I was wandering around google and saw a paper in which the author says in introduction that Agile methodologies, (in my own word) does not put enough emphasis on software architecture and design...
Why does it bother me ? I'm a junior software developer. Being a junior, I mostly write codes. I don't bother about higher... |
Assume the following C code:
#include <stdio.h>
int main()
{
int a = 5;
int b = 15;
return a + b;
}
Compiling it using gcc creates an assembly code which includes the following:
movl $5, -8(%rbp)
movl $15, -12(%rbp)
movl -8(%rbp), %eax
addl -12(%rbp), %eax
Why is the compiler moving 5 and 15 ... |
What’s a good strategy for storing point-in-time data in a relational database?
For example, let’s say you have products and orders. Every order has some products. But they’re not the products as they exist now, they’re the products as they existed at the time of the order. You may later change the product price, remov... |
I am writing a simple program to parse a text file and place into Generic List.
Sample Text:
1,Joe,CA,58,2
2,Matt,TX,63,5
Sometimes, there may be an error, with missing data in the file
1,Joe,CA,58 // missing one number
2,Matt,TX,63,5
I wrote a catch statement to handle such errors.
My Software Principle Question... |
I'm sure this must have been asked before, but I can't find anywhere that actually answers my question, so apologies if I have simply overlooked this.
I am currently learning Haskell, and loving the way it balances flexibility allowing rapid prototyping with functional purity. However I'm trying to get my head around b... |
I've reading about Domain Driven Design and Anemic models.
I generally work with an ORM such as Hibernate, and I'm struggling to understand in DDD what a business model can and can't do.
For example, if I have a Customer object, I would need to pass this off to a Service class in order to have it persisted to the datab... |
I need to create a distributed application with timers / periodically checking two timestamps for elapsed time.
Is it possible to achieve following behaviour with the actor model:
Spawn Child actor
Send Message to Child actor to start the routine for checking the timestamps
Do something when timer expires without rece... |
The paper in question is Peter Keen's "Information Systems and Organizational Change". This is considered a classic paper in software engineering, I'm studying it right now for a retrospective on a project that has been difficult. The paper is about why the implementation of MIS (management information science) system... |
When writing large amounts of recursive code (for valid reasons), I have come across many parameters that are not used in specific functions, but are still needed for a subset of all of the functions.
IE this situation (a, b & c are numbers):
function fun1(a, b, c) {
if(a > b) {
return fun2(a, b, c);
} ... |
In Laravel 5.6 an Illuminate\Database\Eloquent\Relations\BelongsTo relation was given the ability to support default models. This allows a model that will be returned if the relationship is empty.
Most of the code for doing this lives in the Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels trait, w... |
In our company, we develop information system software in C#.NET, which has client-server-module architecture. Module project does not depend directly on server/client project, but only on shared parts. So the structure of core projects looks like this with their dependencies:
server depends on
server-shared library... |
I am currently developing on a small library allowing to read and write Java .properties files while retaining all the formatting (comments, whitespace, etc.): https://github.com/hupfdule/apron
This library has a saveTo method to write the content of such a PropertyFile to a file or an OutputStream. At the moment this ... |
I have looked through answers related to this but they don't seem to solve my problem.
I am fairly new unit testing and testing as a whole. I just finished a small web application using ASP.NET Core MVC and I wanted to write tests for the projects. I am using xUnit and Moq.
The project has a business logic layer that c... |
The Domain has the Domain Models.
The Infrastructure layer has Commands and Queries, forming CQRS.
Commands return Domain Models, and Queries return DTOs.
In any API, the DTOs are stored in the Application layer, never in the Domain, but if Queries return DTOs, must the DTOs be stored in the Domain? Is it a good idea?
|
I have the following aggregate:
Checkout (root)
Requirement: CouponRequirement, AnotherRequirement, YetAnotherRequirement
Coupon
A Checkout has many requirements that need to be fulfilled in order for a Checkout to complete. Each Requirement has a fulfill(data) method that is responsible for the fulfillment process.
... |
I really love clean code and I always want to code my code in the best possible way. But there was always one thing, I didn't really understand:
When is it too much of "separation of concerns" regarding methods?
Let's say we have the following method:
def get_last_appearance_of_keyword(file, keyword):
with open(f... |
I work on a small team (2 primaries with one or two other occasional contributors) on a project/product that spans a number of separate platforms. We do embedded firmware in straight C on Arm0 chips. We write python and a little bit of shell scripts for small Linux computers that are similar in size to Raspberry Pi's. ... |
The paper in question is Peter Keen's "Information Systems and Organizational Change". This is considered a classic paper in software engineering, I'm studying it right now for a retrospective on a project that has been difficult. The paper is about why the implementation of MIS (management information science) systems... |
Is there any engineering reason why is it like that? I was wondering in the case of a RDBMS that it had something to do with performance, since a "YEAR" is more specific than a "MONTH", for instance: you only have one year 2000, but every year have "January", which would make it easier/faster to filter/sort something b... |
We have a developer toolchain, governed by a config file. Each developer can have their own version of the config file. What is a good way to store separate versions of that config for each developer in a single Git repo? All I am thinking is just separating it by developer's name and putting all the config files in di... |
I looked through a lot of articles, blogs, and SO topics about separating domain object and data models. Almost every answer said: You should have separate classes for the domain and data persistence, because...
I understand why it is good, but I haven't found any even pseudo example to solve this problem, and I have ... |
The distinction between roles and claims is that roles describe a set of users and claims describe a property of a user. So there can be a role "Administrator", but there can also be a claim "HasElevatedPrivilegeBadge". Both can allow the same action. Now which one should I pick if I want to allow only certain people t... |
We are restructuring our entire database / filesystem / user identity system. As a first step, we have determined that we need to assign each user/employee in an organization unique ID. Surprisingly enough, there does not seem to be theoretical resources regarding such a problem.
I wonder whether there are some recomme... |
How can consecutive periods of time (defined by a start and end date) be stored in a database?
For example:
from 2018-01-01 00:00:00+01:00 until 2018-06-01 00:00:00+02:00
from 2018-06-01 00:00:00+02:00 until 2018-10-01 00:00:00+02:00
from 2018-10-01 00:00:00+02:00 onwards (meaning 'indefinitely')
The important factor... |
Please note: although my question relates to DDD, I am also interested in this from an architectural and OO design perspective. This question may also be a simple case of CQRS and/or interface segregation. Code examples are in Swift as this is the first language that comes to my head right this second, but this is uni... |
Let's say I have a function that calculates a sensor output, all values are >=0, but also I have to detect some error situations like "NO_POWER" which I encoded with value "-65500". On my application there are classes that only care for the real output value (regardless if an error is present) and other classes that ne... |
The way I explain it to myself is that a business rule is a requirement for a domain concept of an application.
One of the core tasks of my current app is to send notifications. Therefore I have a Notification entity, amongst others.
We are now facing the situation that I need to split a message in 2 parts and batch se... |
Is it acceptable to use id in HTML forms and subsequent code processing (controller, view, model, repository layers)?
For example I need to show something like this on a web page:
Select Motor Choice:
* 460/50/3
* 380/50/3
* 460/60/3
In HTML this can be done with a radio control, where each line has a value attribute,... |
We are going to develop an enterprise level application which will be run by a dozen microservices. Every microservice will be inside docker and all this will be orchestrated by Kubernetes.
Obviously, we need some logging solution and here is a catch. The application will have two kinds of logs, the first one is regula... |
I am working on an enterprise level application. I have an event table in the database. I need to update my events' states in the database on a precise date and time. There may be 200 milliseconds delays max. Since my event table will grow over time, I think long-polling may be a performance issue. In my application, w... |
I understand we need it to mark a class whose objects can be serialized, but do we strictly need this for behind the hood logic to work? We could just serialize the object using necessary methods. On the other hand, if we want to prevent serialization, then having this attribute makes sense, in that case [NonSerialize... |
I'm trying to decipher/understand the best way to implement Model-View-Presenter architecture for the following Android example app...
The App:
I'm attempting to implement a very basic weather app using MVP but I'm hopelessly lost on the best way to implement the pattern. The app consists of two Activities - MainActivi... |
I'm an undergraduate student and I have this assignment on a Discrete Event simulator. Currently I have completed to the end of v1.2 here. Attached also, is an algorithmic overview.
I have wrote my code as such to solve the problem at hand. This code passes all given test cases, but I think there is definitely room f... |
I am working on trying to understand the SOLID object oriented design principles. I was able to get the "SOL" pretty easily, though "L" required some hand holding because I am bad at definitions. I think I understand the "I" (I might not, which may belie my confusion). But "D" or Dependency Inversion is tripping me up.... |
I recently came across a dictionary with lists for values passed as an argument:
Demo(Dictionary<string, List<string>> arg)
It got me thinking---normally I would abstract any list or array to an IEnumerable with the same element type. Similarly, a specific dictionary could be abstracted to IDictionary. But a nested co... |
I have an existing SPA application where api calls from user browser are forwarded to application server hosted separately. My application server have all business logic and repository to connect to DB. Something like below :
we are thinking of merging application layer with rest api so that new design would look like... |
I am trying to wrap my mind around a Liskov Substitution Principle and I came across this article.
SOLID Class Design: The Liskov Substitution Principle
In this article, the author gives an example of a Flightless Bird(Penguin) to extend a general Bird class that would be closed for "addition to the new type of birds."... |
I'm confused about the behavior I should expect from a client when thinking about design patterns. To be more precise, I'm reading the Head First Design Patterns book, and on the difference between the abstract factory and the factory method pattern, it explains that by using a factory method, we don't have full contro... |
In a distributed asynchronous system serializability cannot be achieved, but we still have to somehow provide the semantics.
Consider quite natural requirement that user must have unique email or no email at all. (Option of not having an email implies that we cannot use email as a unique actor's address.)
What should h... |
I have a class UnitInfo which represents a collection of unit information with methods to get the unit information in a structured way, such as a specific encoding, etc. This unit info consists of information which must be read from the unit via serial port communication. The constructor of the class is given the seria... |
I am trying to solve the following problem in a microservice architecture. I am very new to this architecture so let me know if I miss use some of the concepts.
Here is the problem I need to solve:
In an E-Commerce system, a user can place an order for some products.
15 days after the order creation, the system must... |
Consider this code:
new FrameworkClass( [ 'query' => $_POST[ 'input' ] ] );
FrameworkClass is supposed to do input sanitization and validation. Should we just trust 3rd party code to do it's job?
My argument would be that I would rather have my input data sanitized/validated twice than trusting an external library.
If... |
I try to use the best coding standards/practices, however in all of my googling and classes I have never learned which is proper form for declaring/defining variables like the examples below. I have seen numerous different people (teachers, classmates, coworkers) define variables inside and outside of the constructor s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.