instruction stringlengths 34 36.1k |
|---|
I built a .Net web application for a company and it is going to be hosted on their own web-server that don't have access to the internet. the solutions i have thought so far is to get the MAC address of the web-server and check it before the application runs, this will require to get every MAC address in the applicatio... |
Take a hypothetical camera company providing an API to manage its users and cameras. Each user owns cameras, and every user of a camera has a role assigned (one of admin, operator, viewer - these are defined in a database, and we might add new roles later).
If I have a GET request that fetches details of a camera using... |
I have a question regarding what is supposed to be backend and frontend for desktop applications and in this special case, an Excel Addin VBA.
My application contains lot of forms and modules. I assume the Excel UI and forms with events and basically the frontend, but what about the backend?
The VBA code fetches data a... |
I have several areas in a program where I am doing the following check on the same two booleans, but each spot has different text being written to a file via Stream Writer based on the value of the booleans.
Example
if (bool1 && bool2)
{
StreamWriter.WriteLine("Stuff to the file");
StreamWriter.WriteLine("Stuff 2... |
I have a dataset in a key value store (similar to Cassandra). The data model is -
Key - ServiceName / timestamp_in_milliseconds
value - operation
In the write side I get some operations for a service and I store them as the key value model above. These operations can come at any frequency, once a day, once an hour or ... |
I'm adding new functionality to an existing application it was done using JHipster.
I've notice that some endpoints follow this pattern:
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("userManagement.updated", userDTO.getLogin()));
The wrapOrNotFound method:
public static <X> ResponseEn... |
Naming things is hard but naming them properly is really hard. We are working on an app, that analyzes the data of multiple apps and creates some reports.
And we are hitting our heads against walls with the infamous User class problem.
We have used User class in different parts of the app to mean totally different peop... |
I have N applications using ORM, SQL-statements and stored procedures to access M tables from an MSSQL Server 2017. There are some shared tables that are used by various apps.
Let's say I am forced to alter an existing attribute in one of these shared tables. Now I do not want to miss updating any application that uses... |
I've always considered long lived feature branches a symptom of some underlying problem, but I've recently moved jobs and the company I am working for now encourages long lived feature branches. They say it's fine as long as you merge master (well, the Dev branch, but whatever branch we all work off of) into the featur... |
In our Ruby on Rails app, we have a set of conditions to define the status of a user. Currently, there is logic that checks if those conditions are true given a user. We are in the process of writing code that will fetch a set of users from the database based on these conditions.
A couple of my colleagues believe that... |
In the company in which I work, it is customary to model entities using Interfaces when developing with Typescript.
To me, it seems much more effective to model entities with classes and then create instances wherever an object of that type is needed.
When I talked about it with my colleagues including the CTO, I a... |
I have a relational database similar to the one in the diagram where there is one table called app instance which is the foreign key in almost all other tables in the database. It is meant to represent instances of the same web app.
Essentially if I need to run a test version of the app, I could create a new record in ... |
I'm lately trying to implement a specific problem using an object-oriented approach. I get the main principles and its advantages, but I fail to apply it to a real world problem. Most examples one could find consist of Cats or Dogs being implementations of Animal. These however don't give me enough understanding how to... |
I understand that having 3 or more parameters as dependency is a sign that the class may be doing too many things, however there are cases that the class really needs more than 3. My question is, is consolidating the dependencies in to just one parameter an acceptable practice?
E.g.,
Instead of Foo needing to instantia... |
I need an advice on securing interaction between an application App and a microservice RecordApp.
App is the main application, where all users are registered and do some activity. RecordApp is a utility application where App users can store records that publicly visible in the App (like sub-twitter). RecordApp knows n... |
Say I have an Delivery class which should have a Destination property (among many others). Destination can be an Address (country, city, address line, post code) or a Port (international code, name). As you see these two types do not have any overlapping attributes. The only thing they have in common is Destination str... |
What considerations should I mind when designing methods or functions that take in a lot of parameters? A lot meaning over 4 but less than 10.
Example, I am debating whether to pass in an array like so:
function makeAssembly(array $params)
{
$pump = $factory->fromModelNumber($params['modelNumber'], $params['stages... |
I am working on designing a brand new Data Ingestion Pipeline with the Key highlights of the new project are as follows:
Download and Update data to/from SharePoint using SharePoint APIs
Download and Update data to/from JIRA/incident management application using JIRA APIs
Download and Update data to/from SQL sources u... |
I have been using Gerrit in my work environment and I find it really amazing and powerful because of its elegant use of git's branching features to create virtual branches for code reviews (the "refs/changes/*" branches).
However a common pain point in using Gerrit I have came across is its "single-change:single-commit... |
Has there ever been a consensus on which convention is "better":
User.GetById(int id); or User.Get(int id);
i.e., is User.Get(int id); not descriptive enough? Or does is the parameter implication enough? Or is it just a matter of personal preference?
(And obviously, consistency across a project is more important than a... |
We have one scrum team (distributed Agile) working on one code base. Due to parts of the team being in different time zones we wanted to divide the one team into two scrum teams. Our model with one scrum team was:
Create a user story (feature) branch from the develop branch.
After testing, merge back the user story b... |
This is a related question and the OP appeared to go with extreme levels of granularity. The answers gave a good overview but I gather it's still somewhat down to personal interpretations/situations as to where to draw the line. I want to know from the examples below which one best represents SRP.
Example 1
Say you hav... |
Need to understand the below definition, from the protobuf tutorial:
mergeFrom(Message other): (builder only) merges the contents of other into this message, overwriting singular scalar fields, merging composite fields, and concatenating repeated fields.
Based on the answers found here, I could assume that:
Question... |
Where is the implementation interface in Python documented that allows the async loop runners (from trio, asyncio, curio) to start the whole shebang?
We know that sync functions cannot call async ones and yet the async implementations have a magic function that starts the whole event loop, e.g.:
trio.run(some...async..... |
DynamoDB is the database solution, I'm using to store my items. It's a NoSQL/Document database and I got a real problem on real-time updates of items.
First, the saved format is like
{
expiredTime: 'Yesterday(this is a epoch or formatted string)',
state: 'enum values EXPIRED and VALID'
}
The problem is I need accu... |
I have a Java EE Application in which I have an Interceptor class like this
@Interceptor
@Logged
public class LogInterceptor {
@AroundInvoke
public Object logMethod(InvocationContext context) throws Exception {
...
}
}
Now when I want it to work I annotate the target method with @Logged. Please correct ... |
Nowadays everybody wants to be agile. In every team I worked with, the shape of agile was different. Some things are common - like daily stand-ups or planning, but other parts vary significantly.
In my current team there's one detail which I find disturbing. It's lack of functional requirements. Not only there's no wri... |
Assume a client is making a request to an API endpoint that returns a JSON response where the structure and data change depending on whether the request was successful or not. Possible responses may look as follows:
Scenario with a success response
{
"status": XXX,
"data": [{
...
}]
}
Scenario with a failure... |
This question is about designing unit tests, something I started learning short ago.
I know the principle that if you are testing too much in a single unitary test it is a smell, either of code or design itself.
Scenario
I am computing a tax return form based on tax figures computed over the course of a year. Those fig... |
I'm adding Immutable objects support to my Micro ORM called "Symbiotic"
In the case of a create, I need to pass back a newly created version of the value passed in because the object is immutable and I need to update the newly created identity. For non-immutable values I just set the identity property, but obviously I ... |
As a minimal example, consider the following (in Python):
class Foo:
def __init__(self, bar):
# Assume bar is a valid at this point
self.bar = bar
def divide_by_bar(self, num):
return num / self.bar
If the attribute bar is public, my understanding is that it is valid for the client to ... |
I'm currently designing a server with the following structure:
A TCP thread pool that receives data from the network
A queue that holds these requests
A worker thread pool of a fixed size that takes requests from the queue and executes some work where a ConcurrentHashMap is read, and results analyzed. After the work i... |
So earlier today I found about IronPython:
IronPython is an open-source implementation of the Python programming language which is tightly integrated with the .NET Framework.
This was my first experience with using multiple programming languages in a single program. I thought it was really cool that I could effectiv... |
In a microservice-based system, it exist some principles. Sam Newman often refers to them as these:
You should always model your application around the domain
A culture of automation. Automate whats possible to automate
Hide your implementation details
Decentralize everything
Deploy indepentently
Isolate your failures... |
My company just went through a merger and as a result my small team has been expanded. From our side we have been using React for several years, and I firmly believe for us it is the superior choice in every way to Angular, which they use historically. We both have our own templates which have been developed over the l... |
In short: Out of order commands end up with out of order events, so does the ordering of the events matter in such situations?
Since we are uncertain about the order of commands when an asynchronous message queue like Rabbitmq is used for sending the commands,so we are uncertain about the order of the resulting events... |
Im not sure if this is the right place to post this kind of question, but, I heard from a colleage that he creates all his views in a table view and for each item creates a separate cell.
e.g. A title would be a different cell, image a different cell, etc.
Is this a normal practice or is this something that should be ... |
Quite often I have methods that do the following:
Process some data
(frequent, but optional) Save some state to database
Publish a message to a queue / topic
What options do I have to protect myself against transient errors (but not only transient) with #3? Implementing a retry / repeat mechanism is one approach, but... |
There are thousands (or tens of thousands) of possible movie titles.
New user enters my website and selects hundreds of titles that he likes.
The only single goal of my website is to output the list of other users that liked exact same titles, but with only very minor differences - say, only 1-5 titles between users ar... |
The aggregate root's state is the product of the commands it receives. So different order of receiving the commands produce different aggregate root states.
How can I check domain rules based on the state when the order of commands are not guaranteed?
How to check if a command can be executed based on the last state ... |
For this question let's consider a system in which the users can match with each other (let's say for simplicity exactly like the dating apps).
User1 matches User2 (and the other way around) only in one of the following cases
1. they both like each other
2. one of them special likes the other one and the other one ju... |
I'm planning to construct a workflow/environment for training and serving NLP classifiers, that follows something like:
The model training system takes in annotated documents from a subset of a variety of preconfigured sources, along with a set of user-defined parameters on how to run the model (e.g. which n-gram feat... |
I am trying to design an object-oriented library to handle geometric calculations. However, I am trying to exaggerate on being "tightly" object-oriented and applying relevant "best practices". I know that there is no reason to be dogmatic about patterns, I am just trying to squeeze out every bit of possibility that I h... |
C# extension methods have seen a rise in usage over recent years. The offical microsoft guidelines on usage state: "In general, we recommend that you implement extension methods sparingly and only when you have to" The extension method guidelines.
On the other hand Microsoft are now using them heavily in dot net core (... |
Is the sum of the cyclomatic complexity of all section in a file the total cyclomatic complexity for this file? If it is, is the sum of a set of related files the total cyclomatic complexity for this set?
This is confusing for me because most of the examples of cyclomatic complexity I've seen are from fragments of code... |
We've extracted our email sending into an EmailService - this is a microservice that provides resiliency and abstracts the email logic into an Infrastructure service.
The question is how the interface to the EmailService should be defined, with respect to the information it requires about the [User] domain
Approach 1:... |
I have a NodeJs backend that interacts with MySQL database. Let us assume that I have a schema similar to this:
Book
id
name
Author
id
book_id
name
So, I have two tables named Book and Author having 1-M relationship between them such that 1 book can have multiple authors.
Now, I have designed a GET request... |
I know that in x86_64, there exists a 128 byte red zone above (or below, address-wise) the stack pointer that functions can use without subtracting from rsp.
This sounds to me like the only things that need to be aware of the red-zone are situations in which code will get interrupted by other code running on the same s... |
So I have a database class which has methods dedicated to specific actions. For example I have below method which accesses and writes to a table in the database:
def trackUserPerformance(self, verbform, verbsolution, erroneousUserInput, isVerbCorrect, date):
with self as db:
cursor = db.connection.cursor()... |
I'm curious about the terminology for compilers with JavaScript.
When you're writing about or describing technologies like Webpack (bundles multiple files into one, and performs optimization) and Babel (converts ES6 to an older version of JavaScript), would compiler be the best word to describe these?
|
Background: I have seem some argument for using enumeration classes instead of enum in C#, in particular, this section from a book available at MSDN. On the references there is this "Enums are Evil" article which in turn makes quite a good point on the matter.
One of the reasons quoted is particularly convincing:
Imag... |
Had this happened:
A developer make a new feature, but not working, since last year, total code change is 100+files and 10k lines.
Until recently, with help of another developer, get it to work.
Now the code review is huge to include all changes.
Seems there is a common sense that unfinished incomplete change shouldn't... |
I'm working on an OpenID Connect Hybrid flow, basically the response type in my case is: code id_token
Problem: I can't seem to persist the session of the user when logged in using the id_token.
I built the app using .Net Core's built in OpenID Connect authentication handler and Cookies handler.
However, the cookies ar... |
I have created a web service which can also send emails (using Gmail SMTP). This is deployed using Kubernetes and a health check is run every 30 seconds.
Since a team member changed the login credentials we use for sending emails, a check for the SMTP connection has been added as part of the health check. Now the healt... |
How should sprint tasks be planned when you won't know the next task to be done until the current task is complete? For instance, consider the case of optimizing a program's performance. Until you fix the current bottleneck (which may take much less than a single sprint), it's difficult to figure out what the next bott... |
Due to resource limitations (embedded), I want to make some functionality that a class provides optional. The decision to include this optional functionality should be made at compile time.
For example, I have a simple pool-based memory allocator, which has optional statistics support. The statistics support should be ... |
I want to represent an Edifact message in an OOP Language. An Edifact message has the following structure:
message := [ ( segment | segmentgroup ) ]
segmentgroup : = [ ( segment | segmentgroup ) ]
In words: A message is a list of segments or segmentsgroups. Segments are the base element, segmentgroups have a rec... |
I have a use case of scheduling a person to some work for some time range. Eg. A service for assigning a person A to work for time range X to Z in location C.
The only constraint it has, is one person cannot work on 2 things at same time. Eg. if person A is assigned to work in time 2019-07-21 to 2010-07-25, then person... |
The app is to communicate with a bluetooth device with assorted data (config, measurements, service logs, status telemetry) - and it should cache obtained data so the user flipping between activities doesn't need to re-download everything when coming back to a prior activity, or the data was obtained in a prior activit... |
I have been asked to look at moving our current architecture to microservices. I am aware of the warning to always assume a request could fail.
So I am aware we should always be prepared to retry the request. However, when designing this, I am also assuming that the retry can fail.
So with that in mind we have been lo... |
I am in the middle of starting up a new project and just wanted some reassurance as to which approach to DTO's returned by the read-side was easier to maintain in a real world application with reasonable complexity.
I realize with a DTO per query, it would allow for a specific query's response to diverge from the other... |
I am currently making architecture for one application in which we have different types of user and every user has different types of functionalities to perform.
I am confuse in one point if i try to implement the business logic according to user types the architecture becomes tightly couple where as the code is more o... |
Let' assume we have an IFiltersRepository repository that provides data about a list of "filters" that are used on the search screen of an app (filter by color, by price etc).
The repository has the filters in-memory in a HashMap.
The repository could now expose the data it provides via an interface:
public interfac... |
There is a base class Product having all the generic properties and methods which a product should have.
abstract class Product
{
public abstract function process();
}
Now, These are the few types of products which may or may not have similar logic.
class Shirt extends Product
{
public function process()
... |
Currently I have a .NET core application, which fires up a new thread to hold each customer account. Each thread instance:
Is long running for many months or more
Holds open SignalR Websockets and calls 3rd party APIs
Needs to be super responsive
Has 1 instance for every user account as it connects to unique web sock... |
So I have the feeling that one can forget object oriented programming when reactive streams are in use, due to the lack of the async-await syntax (because with the call chaining, the state has to be explicitly passed between blocking and non blocking substeps), nonetheless I also think that dataflow programming alone i... |
Our company has a legacy assembly-like language with some terrible design choices. I'm pretty sure the language is not going to change, since way too many legacy things might change their behavior which would be obviously unintended.
I'd like to use/find any language which has at least C-like syntax ( or something simi... |
Let's say we have a REST API application A consumed by other 30 applications. Application "A" uses a cross-cutting security implementation using a Security NuGet package 1.0. All minor/major changes are properly versioned and backwards compatible (e.g. not breaking existing consumers with new changes).
The problem is,... |
I have this requirement:
Csv Upload (using opencsv)
Should display if the record is inserted (if it doesn't exist in the db) or updated (if it exists).
Eg.: 5 records inserted 2 records updated.
Usually I use repo.saveAll(entityObjList) to save all the entries.
Since I have to keep track of number of updates and in... |
In my job I have a small disagreement on whether we should utilize helper functions for making datasets especially in laravel framework. A sample for the test is:
namespace Tests\MyAppTests;
use PHPUnit\Framework\TestCase;
use Carbon\Carbon;
class MyTest extends TestCase
{
private function makeATwoHourSpan(Carbon $... |
I always like to overthink things, so here's my thought of the day:
Should setters only set the values of class properties, and not perform any other logic?
Suppose I have a class
class User {
private:
int age;
bool is_alive;
public:
int GetAge();
void SetAge();
bool GetIsAl... |
In a web app I am building, I might finish two distinct minor features at the same time: Implementation of a new web page, and implementation of the notification bar. After merging both of these into master on GitHub, and resolving any existing conflicts, I will release it.
My current release is v0.9.1
When I release ... |
Let's say we have a typical service class method who does few things, input validation, db object retrieval, some business logic execution and then saving and returning record to user. This is irrespective of any language we are using.
methodA(args1, args2, args3) {
returnValue1 = validateArgs(args1, args2, args3)... |
I was watching the following video by Vladimir Khorikov, which recommends to "Refactoring Away from Exceptions" pluralsight.com - Applying Functional Principles in C# - Refactoring Away from Exceptions and instead using a Result object. You can also find a blog about it here: enterprisecraftsmanship.com - Functional C#... |
I find myself repeating the same code when writing unit tests, for example... When writing functions that work with files, In the setup for the test i often write some code to create a file (in a directory specified with an environment variable) populate it then after i have run the test I destroy the file and folder.
... |
Suppose there are app1 and app2 in a microservices.
app2 needs to call app1's RESTful APIs.
Cache is needed since the call will be frequent. So after a successful RESTful call, there will be cache available for app2.
My question is who maintains the cache, app1 or app2?
Any comparison between the two? Is there industry... |
I'm creating a framework that needs to execute certain tasks, I'll use building a car as an example for this. So, an individual task could be something like weld metal or screw bolt. But there are also collections of tasks, I call them jobs. Each job can have X amount of tasks, so combining these two tasks could get us... |
In our environment (as in many others), it is often the case that one microservice must call another in order to accomplish a task.
In our environment, authentication is clear enough - we have a signed JWT containing a list of permissions and roles, as well as a user ID, client ID, and so on.
What we're less clear on i... |
Currently, whenever I am developing a feature, I write the behaviour tests for it using mocks for our downstream services. These mocks are dumb always serve the same output. I faced something grave today. My BDDs were passing in my local and build environment. Therefore, I went ahead and merged my changes into the 'mas... |
Let's imagine I have a single web app containing features which are topically related, but have highly differing implementation requirements.
Let's imagine that this web app is about fruit, and contains the following features:
A fruit encyclopedia giving details about various kinds of fruit, including full 3D models t... |
I'm new to APIs. Conceptually, I understand what an API is, but I get confused when it comes to the some of the technical details.
All of the tutorials I've read talk about URLs and endpoints, and they describe them as being the paths/addresses through which APIs can be accessed. This part is very clear; no confusion h... |
I am a new hire (as a software engineer) in a company and the Linux (Ubuntu 18.04) machine I got has no java installed. I tried to install Java SE 8 kit from Oracle but apparently there is a new licensing model (in which I am not familiar with) and you have to create an account before you can download their JDK. My que... |
I've been reading about data hiding and there seem to be slightly different definitions of it, so when trying to come up with a practical example, I'm not sure if I'm doing the right thing.
So far, I got that data hiding protects data from being accessible in an unexpected way. This makes me think of two different case... |
This is currently my User-Role-Permission model in the Db schema (excluded other tables to avoid confusion). My implementation goes like this: I have a Customer table and each Role has a different set of permissions to enable the User to interact with it. The User with Salesman role can only read from it while Admin ha... |
Suppose that I've an API that publishes a post in my Facebook account. What HTTP code should I return if the user hasn't linked yet his FB account with my API server (it's just an example)?
I found "412 Precondition Failed" but I think that this is not the right use case.
So what is the best HTTP code for telling that ... |
The use of instanceof might be a code smell and I am in front of the following code which seems ok. Would you consider that instanceof should not be used in such case? What would be the pattern to use?
<?php
interface Account {}
class PrivateAccount implements Account {}
class PublicAccount implements Account {}
cl... |
I recently sat a test, and got the wrong answer on a question, which made me question my knowledge on the V-model. The answer was a true/false and here is the statement relating to the V-model.
'Each stage of the SDLC has a corresponding verification and validation stage.'
Initially, I answered true, but it got me thi... |
I am working on an API solution, split in three projects:
API
Domain
DataAccessLayer
I have created an interface, in the Domain project, ICustomerRepository, with a single method:
Domain.Customer GetCustomerById(int customerId)
--
The DataAccessLayer implements this interface with a FooCustomerRepository.
Foo is a a... |
My boss wants an automated weekly report on how many git issues have been moved to and from various "lanes" (pipelines) on a virtual kanban board. I wrote a quick python script to get that data using Github and Zenhub APIs, and now I'd like to write that data to disk.
My current plan is to run this script once an hour,... |
Context
Domain
I have a CQRS domain with requests, authorizers, handlers, response objects, entities, filters, pagination.
It only depends on:
external services (email, other APIs, etc...)
a database/persistence layer
a way to retrieve the current domain user logged in
Web API
This CQRS domain is called from a web AP... |
I'm working on a program that tests a digital circuit. The digital circuit can process accesses from multiple different caches, CACHE0, CACHE1, etc. The digital circuit can handle accesses to different memories MEM0, MEM1, etc. and a special kind of memory SPECIAL_MEM. The special memory can be accessed in multiple mod... |
I would like to make a SaaS which would be a multitenant system. Development is done in Laravel, which is less important. What I would like to know is how would you handle having a master admin account (for me) with which I could observe number of tenants, subscriptions and their types, permissions and so on?
Currently... |
Say I have a class that is used to monitor the size of a directory. Currently it can only monitor the size of a single directory:
public class DirectoryMonitor {
private final File absolutePathToDirectory;
public DirectoryMonitor(final File absolutePathToDirectory) {
this.absolutePathToDirectory = che... |
I'd like to build a client/server application that doesn't require the client to open a port in its firewall for incoming connection requests. In other words, the clients will be able to communicate with each other over the outgoing connections that they initiate with the server.
This will be very similar to, for examp... |
I am trying to abstract some functionality from my desktop application (JavaFX) for changing views.
So, what I am thinking is:
Navigator interface with methods like goToAccountsOverview(), goToAccountDetails(Account account) etc. The implementation will depend on a ViewFactory to create the Views and a DisplayingViewCh... |
Typically the way to communicate between parent <-> child component in Vue.js is to send the child a prop and emit an event from the child, which is listened to on the parent.
However, if you pass in an object to a child prop, updating the object in the child will update the object in the parent as objects are passed b... |
In DDD, creating smaller aggregates is encouraged where possible, but in a system we are designing we are running into an issue regarding the identity of aggregates.
The system evolves around phyisical events, like music festivals or sports events, and within these events there are separated bounded contexts representi... |
As I understand the "Same Origin Policy" is a browser security feature that aims to protect the user. It prevents scripts to load data from another webserver (typicall with ajax).
So esentially there are 3 actors:
The User in the Browser
The Original Website
The "other origin" Web Resource
Does it protect the user ?
... |
Let's say I am designing a TODO application and therefore have an aggregate root called Task. The business requires to keep a list of TaskLogEvent that provides them with a history of how the task changed over time. As the Task may have hundreds of these events, I will model this TaskLogEvent as a separate aggregate ro... |
This is a theoretical problem that bothers me. Let's say we have following, simplified structure:
interface ParagraphInterface {}
interface ParagraphGroupInterface
{
public function getParagraphs(): array;
}
interface ParagraphRendererInterface
{
public function render(ParagraphInterface $paragraph): string;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.