instruction stringlengths 34 36.1k |
|---|
I regularily come across code that stores some custom properties in JS Objects from external libraries, for example:
/**@param OpenLayers.Feature feature */
function doSomething(feature) {
feature.customProperty = "anything";
}
I disapprove of that, but I am not sure about the ideal solution to bypass this short... |
I have trouble understanding if I should pass an argument to a method as a primitive value or as an already-obtained object.
Consider this simple example
interface Channel{
String getId();
String getName();
}
interface ChannelRepository{
Channel findBy( String id);
}
public class DummyChannelRepository ... |
We have a 3-tier architecture: Web, Business, Models using the MVC pattern. Models are Code-First using EF6. Currently we access the dbContext directly in our Controllers to query and save changes. We define all the relationship constraints on the Models. However, we have many additional constraints on the models that ... |
Is it a good practice at all?
E.g. we have an API layer which has to call some service when it receives a request, and the work which that service has to do must not be done concurrently. If there would be no API layer one would just use a queue and dispatch tasks there and the service would consume and process those o... |
In my organisation for one of the project we follow Agile Scrum methodology and following is distribution of the man power for the project:
Scrum Team:
SM
ProxyDev1(Internal): 50% in the project
ProxyDev2(Internal): 50% in the project
Dev3(Internal): 100% in the project
Dev4(Internal): 100% in the project
Dev5(Externa... |
Developing Big Data processing pipelines and storage, you probably come across software which is more or less a part of the Hadoop ecosystem. Be it Hadoop itself, Spark/Flink, HBase, Kafka, Accumulo, etc.
Now all of these have been very well implemented, offering fast and high-quality solutions to the developers needs.... |
I was reading on SO and SESE about exceptions and control flow, but I can't seem to determine or figure out if using exceptions to validate parameters is a violation of that guideline.
Suppose I had a method that wrote a message, obviously, I don't want the recipient of the message to be blank. For this example, recipi... |
I'm really looking for one good example how to PUT operations should be implemented correctly.
What I understood until now:
The operation must be idempotent
When the resource doesn't exists it will be created new one, API returns status code 201 - Created
When the resource exists and has changed, resource will be upda... |
I need to design a system that will take jobs (basically calling some web api) and run them at a future time (15 - 45 minutes depending on the job).
The first idea I had was to store the job and the timestamp of when it needs to run in some db and then have workers running each minute looking for jobs to run (select wh... |
I'm quite new in the DDD-World and I'm just trying to figure out all the basics so please bear with me!
I have the following Entities:
- Datamodel
- Object Types
- Object Fields
A datamodel can contain 1..* object types and each object type has a unique name and can contain 1..* object fields.
A field has a certain ... |
I have a site where user logs in. I need to calculate the log-in activity score based on the age when he logged in. For example :-
If user logins today he will have high score than the user who logged in yesterday or sometime in past.
Similarly user who logged in this week will have high score than the user who logg... |
I'll take out the ellipsis to make this easier/quicker to read:
Large group project in school, stakeholders gave a fuzzy explanation as to what they want. I suggested that we:
sketch the GUIs so we all understand what is requested, find problems, ask eachother questions, to clarify in general so we all think of the s... |
I've worked with a lot of off-the-shelf systems and generally speaking they all, at a database level and above, have metadata such as CreatedBy/On, ModifiedBy/On etc against records/entities to give at least some visibility to who did what and when.
Obviously though these fields are fairly shallow, you'll never know wh... |
Scenario
I'm a new developer, using MSTest and I've encountered the following issue:
SomeClassTest // Uses a Fake Widget Controller.
Test Initialize
{
Many lines of code to initialize Fake Widget Controller
}
Test Method
{
Uses fake widget controller
}
AnotherClassTest // Uses same Fake Widget Controller.
... |
I was reading here about OOP and methods, and the accepted answer states that method names should be verbs. However, that doesn't really answer my question.
Suppose if I had a Character class with a private List inventory.
public class Character {
private List<GameItems> inventory;
// constructor and other... |
I have 3 software components of a Web Application:
1. JS-client application 1 (JSApp1)
2. Java Spring (REST and Websockets) server app (SRV)
3. JS-client application 2 (JSApp2)
My current task is to send some data from JSApp1, save them in the SRV DB and respond to JSApp1 telling whether the operation was successful or... |
Would you consider
WHERE SomeDate <= '2018-01-01 23:59:59'
instead of
WHERE SomeDate < '2018-01-02'
When the intention is that SomeDate goes no further then 2018-01-01
a code smell and if yes then why
|
I am wondering about the Gherkin syntax for some scenarios. Suppose I have following events A, B{1}, B{2}, C, D1, D2, G.
Where uppercase{number} events like B1, D2 are parallel events(simultaneous).
Where uppercase events like A, G are normal events. The symbol || means OR but && means AND.
Now how I could write Unit... |
I am looking into improving my overall application architecture and (I think) I understand the issues my Anemic Models are causing.
Here is my current architecture:
Controller with injected Service and Controller Action accepting a DTO
Service with injected repository. Service function takes DTO, calls repository, do... |
I need some guidance in designing an API wrapper for my backend APIs. I have tried to keep it as specific as possible.
Context: We have a project which supports certain file operations like edit, create, merge etc.
All the services are exposed as rest APIs. Now I have to create an API wrapper over this (client library)... |
We have an already running MQTT setup for communication between smart home devices and remote server, for remotely controlling the devices. Now we want to integrate our devices with Google Home and Alexa. These two use HTTP for communication with third party device clouds.
I have implemented this for Google Home and af... |
I'm refactoring the framework of our company, trying to fix the issues we had in the past.
We're a team of 6 developers, and we have various needs and issues in regards to tidying up our framework.
Right now, we want it to be the solution we import in all our projects, because it has all the code we reuse every time. T... |
which approach should be taken when adding entities to an aggregate?
I could add an constructed entity to the aggregate
$book = new Book($title, $releaseDate, ...);
$library->addBook($book)
or I could pass the parameters to the addBook method and let the method to construct the instance:
$library->addBook($title, $rel... |
I am trying to understand the difference between an event log and event store in the context of event sourcing.
A really nice explanation I found is that an event store is the single source of truth for the write model and an event log is the single source of truth for the read model.
Therefore say I wanted to use CQRS... |
It's been a long time since I was first introduced to Event Storming in a DDD workshop. More recently we decided to apply it in practice and we have planned our first sessions with a facilitator (someone from the company who has experience).
The only thing i'm wondering now is how the process AFTER event storming take... |
I am building a CLI tool which will potentially support many commands. Ideally, I want to abstract out each command to implement an interface that demands a "run" method. From there on, it would be a simple regex match that delegates to the appropriate command class.
The issue is, not all of these commands are stateles... |
motivation and context
I am designing and implementing the web interface of my bismon server program (a research prototype; in a few words: an orthogonally persistent, reflexive, homoiconic, dynamically-typed, multi-threaded, domain-specific language for static source code analysis; it runs on Linux only). It is free s... |
Suppose the client wants to build an online shopping system. If we think of use case scenario, a database or a bank would be a secondary actors to this system.
Is it valid to have a user story like
As a customer I want to be able to access the database so that I can view catalog items
Or
As a customer, I want to a... |
Suppose I have a use case, like this example.
Normal Flow:
The user will indicate that she wants to order the items that have already
been selected.
The system will present the billing and shipping information that the user
previously stored.
The user will confirm that the existing billing and shipping information
... |
I have a website with basic crud operations that involve data and photos.
I also need to extract the metadata for the photos that are being uploaded.
My original implementation did not have var puts = new List<Action>(); so the following code
puts.Add(async () => await _s3Client.PutObjectAsync(BucketName, key, file.Op... |
I recently came across a demand to create a web system (which will be done in PHP, but is for any language), to have the same functionalities of a mobile application already ready. This app has a complete and well written API in NodeJS.
With this situation, I had a question about the possibility of using the API in th... |
I'm looking for some sort of standardisation, in a similar vein as POSIX for compatibility and familiarity between different commandline-interfaces, but for error reporting. Notably, I'm looking for:
formatting rules
standardisation of logging practices
rules for error code choice
good habits on how much, and what to ... |
Consider a "large-ish" data set (~2-5M rows) that goes through multiple stages of cleaning/processing:
library(dplyr)
largedat %>%
mutate(
# overwrite v1 based on others
v1 = somefunc(v1,v2,v3,v4),
errv2 = anotherfunc(v2,v5)
) %>%
group_by(v5) %>%
mutate(
v6 = otherfunc(v7,v8,v9),
errv7 ... |
I'm working on a library that lets me write operation on an input "stream" of data (I don't call them that, but it's a potentially unbounded input regardless, think data coming from a socket).
I might have one operation that eg: applies a frequency shift to the incoming data, and then another that applies a frequency-s... |
I have created the above picture to illustrate my question.
Is there a section within memory (lets say from address 0x1 to 0x15) that all processes use to place their text segment in (left figure), or each process gets a random location in memory to use for it's combination of heap, stack , text and data(right figure)... |
Assume a Parent -> Child relationship in RDBMS.
questionnaire table and question table.
question table has a foreign key questionnaire_id to store which questionnaire it belongs to.
Questionaire can have n number of Questions, say max 500.
When a user creates/updates a questionnaire API call sends the big json docum... |
I am writing a test in pytest for a software. This test relies a lot on console output generated by the software.
The flow is something like:
* start the program
* send some commands to the program
* wait for some output from the program
* send some other commands, wait for further output
I also need to write the ent... |
A software company develops software packages for commercial animal
farming. A special function in C calculates the daily amount of feed
for different kind of animals dependent on their bodyweight. This
function already run flawlessly for years in a software package for
farms. And now it's integrated into a pa... |
I am working on a multi contributor project, having ~2500 Commits. It has multiple components, i.e. Frontend, Backend and Data Processor/DB Ingestion.
Now that we are expecting more contributors, a Versioning System should be implemented, and should be displayed on footer of Frontend, as vA.B.C, where A = Big Change, B... |
Here's a class with a method that calls different functions based on a parameter set in the constructor:
functions = {
"arg1": f1,
"arg2": f2,
"arg3": f3
}
class C:
def __init__(self, arg):
self.arg = arg
def _util_method(self, v):
return functions[self.arg](v)
def method1(self... |
Why should someone use a stream processing engine like Apache Spark, Flink, Hadoop instead of just a normal backend worker which works on something and returns the results as soon as it's done?
Credit card fraud checking example is given when we talk about these solution so what is the problem by just write a program a... |
I guess the goal of separating UI and business logic goes way back. I found a Martin Fowler article, from nearly 20 years ago, which is pretty clear about the benefits of the separation: https://www.martinfowler.com/ieeeSoftware/separation.pdf
I'm undertaking a development where I believe the domain layer I develop wil... |
Onion architecture has a core which is composed by domain model, domain services and application services:
I'm in doubt about those two service layers, domain services and application services.
I've been reading that they're related to DDD but I'm not familiar with DDD myself.
I'm not asking for the relationship, just... |
In Javascript, there seems to be or have been an idea that undefined represents a missing primitive OR object value, while null represents just a missing object value.
See, for example, this section in Speaking JS.
The use of null in JSON, however, does not seem to obey this principle. If the value of my key is missing... |
I was doing some reading here and one of the suggested answers states:
In short: Don't try to decide how an object might react to some action
from the outside, tell it what happened, and let it deal with it.
This other answer suggests:
But in general, I recommend trying to achieve orthogonality, your code
stays... |
So I was discussing coding with an associate of mine at work, and was mentioning how I was working on a project where I'd need to transform the data that was provided into a standardized format before processing it (applying business rules, validation, etc). He suggested that the standardization of data should be a com... |
I've heard the phrase being thrown arround and to me the arguments sound completely insane (sorry if I'm strawmaning here, Its not my intention), generally it goes something along the lines of:
You don't want to create an abstraction before you know what the general case is, otherwise (1) you might be putting things i... |
I'd like to highlight that this questions is about a System Sequence Diagram (SSD) and not a simple Sequence Diagram and of course any help would be appreciated!
I'm reading Graig Larman's book Applying UML and Patterns and I was wondering if it's possible to represent an if statement in a SSD to exit the system. For ... |
I need to create requirements model for my software(first step of software engineering), But I don't know which icon of UML can help me to implement requirements model.
|
Currently we are integrating with a 3rd party system. This includes data sent to this 3rd party where the customer is able to see it. My current task is to provide visual documentation (PDF) about which values from our tool land where in the target system.
What I am struggling with is the fact that screenshots of both ... |
Some years ago I wrote and released some software under the MIT license.
Recently I noticed that one (or some?) of the forks have altered the leading copyright notice at the top of the license, i.e.
Copyright (c) 2014 <my name>
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy o... |
In our domain we have a concept of billable activities that get logged by a user. The modeling is pretty straightforward -- the User is an aggregate root, with the Activities being a collection under the user (an activity doesn't make any sense outside a user, and we have rules to enforce at that level).
We're in the p... |
I have 1 long running process wrapped inside a method and it is for 2 different types like below:
Type1
Type2
Code:
public interface IBaseType
{
MyResult LongRunningProcess(int jobId,int noOfTimes); //doenst save long running process data in database.just returns the results to consumer
void Lon... |
I have a method that creates a data file after talking to a digital board:
CreateDataFile(IFileAccess boardFileAccess, IMeasurer boardMeasurer)
Here boardFileAccess and boardMeasurer are the same instance of a Board object that implements both IFileAccess and IMeasurer. IMeasurer is used in this case for a single meth... |
Tag dispatching
is used to:
dispatch based on properties of a type
Is there any reason to make tag values constexpr or even
const?
There are code samples demonstrated both constexpr and
non-const tag values. For example,
the selector tag value in wiki
is not declared a constexpr. OTOH, in the c++
standard,
section ... |
class DataFrameAnnotation:
def __init__(self, df: pd.DataFrame):
self.df = df
def transformation_1(self):
self.df + 1
def transformation_2(self):
self.df + 1
def main(self):
self.transformation_1()
self.transformation_2()
....
return self.df
My question is if there are any iss... |
I understand that there are major technical differences between how a strongly typed language is compiled and how a type annotated language is compiled/transpiled.
But as a developer writing in a strongly typed language and a weakly typed language with type annotations feels pretty similar to me. I can't really articul... |
I'm struggling with logic that is duplicated in the front end code and the database. Right now, I just put a comment.
Here is a small example (the current system has a lot of much more complicated formulas).
In the front end, I have a single property that everything use to see the result.
Class CartItem
' The same... |
I am learning for an exam and I have a question which I am struggling to give and answer for.
Why does no iterator base class exist all other iterators inherit from?
My guess my teacher is referring to the hierarchical structure from the cpp reference "http://prntscr.com/mgj542" and we have to provide a other reason t... |
I have a method login() which essentially sends a login request to a remote server. As I do not want to waste server resources on processing invalid data, I decided to consider sanity checking the input before I send it.
The code looks something this:
//Method to log user in
public void login(String username, String pa... |
From what I have learned, in Perspective based reading, the document/code/etc., is inspected from different perspectives. We consider roles like software designer, tester or user.
Each role follows the scenario assigned to them, and reads the code/document, etc. Each role also creates an artifact; for example the pers... |
Background: I'm working on a project with a self-driving machine with a tank-like control, somehting like:
forward()
left()
right()
stop()
The code is running on a raspberry pi. The GPIO outputs are inside my class Machine. Currently the development process is very simple, we're programming, put on raspberry, test it... |
No code to show (and not really a code issue) but I have an iot-ish application running that is using PI Zeroes as clients and they are slow. A single POST takes about 10 seconds round trip, the delay seems to be almost entirely within the client side Python script, possibly related to slow connections but I would like... |
What are the best practices to organize your unit tests in classes?
I see different possibilities:
1) One would be to write one "container" class for each function you want test and then subclass that to group in each subclass all tests that are similar in some way - e.g. one subclass contains all tests where... |
We have a requirement for a security audit that our password policy must disallow the re-use of a previous password from the last 4 used passwords.
We can accomplish this fairly easily by making a call to the server to allow it to compare the password candidate against the database's previous password hashes, but that ... |
In computer science courses at University, assignments written in OO languages such as Java had file systems similar to this:
TreeNode.java
BinaryTree.java
Assignment1.java
etc. ...
In writing some of my own projects, it seems like splitting up each class into a file is very trivial, especially when classes are very ... |
I am trying to design a geometric intersection API. Below is the code to represent geometric elements.
#include <iostream>
#include <memory>
// Since I did not write the Shape class I cannot edit or change the geometric elements class.
class Shape {
//
public:
virtual ~Shape() {}
};
class Segment : public Shap... |
Various analytics tools will track the number of handled and unhandled exceptions (crashes) that happen in an app. This obviously helps us find problems we didn't know existed and will fix it.
Quite often, exceptions happen in try-catch blocks and are handled, but in many cases they still are situations that should not... |
I have an app that uses JWT tokens for user authorization. Now, I need to be capable of deactivating users (users won't be allowed to use the system but still exist in the database), but as a requirement for that, I need to know if the user is not logged in. Is there some kind of best practice for handling this kind of... |
Question: Given that two services operate on a common complex object, what are possible design patterns and supporting technologies of exchanging the object and (possibly) sharing the implementation?
How about aspects like
deployment (independent release cycles on the two services)
testing (using different implementat... |
I have been programming my classes in the following mode. I create a public function that has a call to a private function that has all the logic and functionality. Something like:
public class MyClass
{
public string DoStuff()
{
return ActuallyDoStuff();
}
private string ActuallyDoStuff()
... |
In a hypothetical system that handles adding users, there are several business rules. Some of the rules can easily be checked in the model. For example a user registration can only be saved if they entered a 10 digit phone number.
But what if we want this phone number to be unique?
In most databases it's fairly easy ... |
I am required to analyze and make an architecture of an application. While analyzing the requirements I find, in my system user personally identifiable information (PII) confidentiality is a very sensitive quality requirement and it must be taken to the NFR (non functional requirement) section. NFR requires that all th... |
Backstory (You can skip)
I am building an API for managing Files and Directories in a consistent manner across a project. This is for deduplication and consistency when performing a task, and in this particular case, I want to ensure that a file is closed and the mutex is unlocked. Now this is a straight-forward task t... |
We have a few tables with a large amount of data and with indexes on those tables to help in faster retrieval.
We are also using Spring Data JPA JpaRepository for adding data to those tables using the .save(Iterable entities) method.
Now, I know that the index is going to slow down the inserts in the DB.
But my questio... |
Some background
I am the newest member of a small team of 3 developers. For the past two years I have been working with them on an application the two of them made roughly 5-6 years ago. This application has no documentation and no design or analytical methodology has ever been applied to the development process. The l... |
I am part of a new dev team that is assigned to work on a legacy app. The app currently has no regression or automated unit, integration and system tests.
Due to technical debt and convoluted architecture, automated unit tests would be difficult without refactoring the code. However refactoring code is not a something ... |
At my work we have a typical microservice architecture, but one of the issues we are running into is sharing data across multiple services. We have certain data that is used by multiple services and so we have to share the data across services. Our databases are separated out by service, for reference.
To give an examp... |
So, I've fallen into the fad trap, and started replacing a large amount of linq queries with extension methods.
For example:
orders.Where(o => o.Status == ShippedStatus.Shipped).Select(o => o.ID)
has become :
orders.ShippedOrderIds
Extension methods are static with all the cons implied, and I believe the 'most-correct... |
I recently started working at a place with some much older developers (around 50+ years old). They have worked on critical applications dealing with aviation where the system could not go down. As a result the older programmer tends to code this way.
He tends to put a boolean in the objects to indicate if an exception ... |
I'm a little confused about
commands role in event sourcing
distinction between domain and external events
If my understanding is right
a command represents an action initiated by an actor in terms of the domain
a domain event is an event can be consumed and produced by aggregate roots
an external event is just like... |
I'm building a mobile application using Expo & React Native. As the user interacts with the mobile app I need to store their interactions in Google BigQuery, so they can later be used to train machine learning models. Think 'user swiped left', 'user clicked image' etc.
I have a few options in mind:
Host the app on Goo... |
Say I have a database with 100 tables. Scattered throughout the tables are some string columns for short things that could be considered usernames/tags/categories/hashtags/addresses/placenames/other short names. Also scattered throughout are integer columns ranging from super tiny numbers like 10-50 to super BigInts li... |
I am new to object oriented design and learning about interfaces and design patterns. In this example, I am trying to create class for cars. My question:
Is it good practice to use base class and then inherit from it. And then use interfaces for implementing different functions? If not, then what would be the best way ... |
It seems pretty common knowledge that code is read far more than it is written. Does this mean that if a tool produces code that's checked in, then it's a net negative (saves the author some time in writing it, but more than makes up for it in time spent by everyone else reading it)?
If not, why not?
If yes, is there s... |
I have came across a concept in recursion which says that when loops are compiled or interpreted then they get converted to recursive functions. If it is true how it takes place ?
|
Before I ask my question, I'm aware of Eric Lippert's Wizard and Warrior series.
I'm trying to understand GRASP, but I'm having a hard time determining if this class violates GRASP.
Suppose if I had the following Character class:
class Character(ABC):
def __init__(self, name, strength, attributes):
... |
Our project is in its early stages and we are currently using Uncle Bob's Clean Architecture (also known as the Onion Architecture).
An overview of our project is as follows:
domain package
Contains our business entities
usecases package
Contains operators that use our domain entities to perform use cases
Contains ... |
I'm working with firestore and have encountered several situations where a document will contain stale data which is a duplicate of the source of truth located elsewhere in the database.
For instance I have a chats collection with documents that contain:
users: [{
name: 'foo',
companyName: 'bar'
}]
The source... |
I've been working on a library at work which provides a simplified API for a few underlying libraries (face recognition, text to speech, etc.).
My boss asked me the best way to describe this concept in English, and I couldn't find something that felt both succinct and adequately conveys what the library does.
The best ... |
I want to create an application that has some optional steps. But I could not decide how to do step plans. It looks like a workflow.
I have a Work entity. This work includes specific business steps.
Step-1 : Demand of work. ( DemanderName, DemandDate, DemandFiles )
Step-2 : ...
Step-3 : ...
Step-4 : Work investigatio... |
I have gone through ken thompson's compiler hack paper, can't we just go through the complier's source code and check for any backdoor, what was the article's point?
https://www.archive.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf
Can we be sure that there are no backdoor's if we check the latest language's ... |
I have situation where in the Repository class I have a dictionary:
Dictionary<TableName, Dictionary<EntityColumnName, SourceColumnName> map1 = new Dictionary<TableName, Dictionary<EntityColumnName, SourceColumnName> ()
with methods for manipulating data (Get,Save,Add etc).
Now there is a need to search by value from ... |
Assuming we have different classes with methods that possess the exact same description, however execute code a bit differently for the same return type.
class Foo:
"""This is the Foo class Docstring. It is a type of Bar source."""
def getBar(self,pos):
"""
This is the Bar method.
It ca... |
I know it is lot of code. But I am trying to understand the concept of Factory pattern with interfaces and base class. I have a base class of Car that implements an interface which will be implemented by every derived class.
Then I have another interface that will be only implemented by few derived classes. OnlyImpleme... |
Suppose I have a one C++ process, and I want this process to run eight threads in parallel.
And suppose that:
I have a computer with two (2) physical CPUs.
Each CPU has four (4) cores, so that's 4x2 = (8) cores total.
Each core only allows one (1) logical thread, so (8) logical threads total.
I am using an x86-64-bit ... |
I currently have a Web App using ASP.NET Core 2.2, Domain Driven Design, Clean Architecture, and CQRS. I'm using MongoDB as persistence.
I have developed a Repository pattern to abstract the MongoDB implementation. But I've been doing some research on how to prepare the application against outages, timeouts, and discr... |
At my company, we use a distributed pool of virtual machines to run our UI and API tests. These machines are all connected to an onsite server which the pool uses for publishing the test results and outputs.
The problem is our storage on this server is limited, and each day we are producing 500MB - 5GB of reports (csv... |
This is a basic question, but I don't have any sense of what other developers do in this scenario.
The Situation
I am creating an interface to allow end users to insert and update data in a table stored in an Oracle database. The interface will ask for an Excel worksheet and then generate a MERGE script with SQL to ins... |
Apologies in advance if this is considered opinion based, but I wasn't sure where to ask it and was interested in learning if there were any definitive best practices.
Say an application calls a service from one location, but a requirement is that a == 1. You would want to perform the a == 1 check in the service to be ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.