instruction stringlengths 34 36.1k |
|---|
I am currently implementing a TCP Proxy Server. The huge problem I have right now is that, based on the clients' TCP data, I am trying to determine whether the client is making an HTTP, FTP or SMTP request.
My solution, I am thinking that I have to read the first line of data of the TCP data. For example, an HTTP reque... |
Suppose of this question the following:
I'm in full control of this project
I'm writing a media player
Obviously, a media player will allow a user to adjust the volume, so I might have a class that looks like this:
public class Audio {
private int level;
// Constructor and other attributes left out
pu... |
You've probably been in the same situation: there's a class of objects which have a specific date before* which they should not be considered "active." But how should you represent "active since forever?" PostgreSQL or Python, for example, have very definite but different earliest possible datetime values.
Let's say I ... |
I have dell edge box that is stored in another location, the edge box is having 4G sim card internet access with dynamic IP address that changes frequently, I usually use ssh putty with the 4G IP address which is IPv6, now if the IP address changes i will not be able to know the updated ip address of the edge box, any ... |
I have implemented application using microservices architecture. I take a user story to implement. This involves front end/UI, and two microservices to implement the user story. So I have three components involved. Should one team implement the user story, or should the user story be split among three teams.
It is poss... |
I'm currently planning an architecture for a system that should consist of multiple microservices. We definitely want to make use of a message broker (probably RabbitMQ).
A simplified diagram of my current approach looks like this:
As you can see in the diagram I added a Response Queue, which is used by the services t... |
I have or am going to have a database with countries and their emissions. Countries in the API have a 3-letter ISO Code. Should I use this for identifying the countries in database, or just a plain numeric id?
CREATE TABLE country
(
countryid integer PRIMARY KEY NOT NULL,
),
CREATE... |
In Clean Architecture by Robert C. Martin the dependency rule points strictly from the outermost layer/ring to the innermost.
As an example a Dependency Injection Framework should lie on the outermost layer (frameworks) to allow for it to be replaced.
However, a DI framework which relies on attributes would clearly bre... |
If I have a SQL Server fact table with four dimensions (OrderDate, Customer, Product, Region), my understanding is that it's best to create a non-clustered index per foreign key (dim key column in the fact table).
Assuming that is correct, is it optimal to combine OrderDate with each dimension in each of the non-cluste... |
a few years ago I wrote a python script for reading CSV, handling the headers, filtering data, renaming stuff via RegEx...bascially to do various ETL stuff.
This was done using a exhaustive configuration file that defined all the sources and all the targets. It worked quite fine - but the configuration was everything b... |
When implementing interfaces, as a general rule, Impl is evil. Ok, but is it evil in the following case?
I've a service that has (and probably will have) only one implementation. In such case, normally I don't need any interface. But, the "contract" must be shared with other modules because the service is exposed using... |
I'm reading the book Dependency Injection Principles, Practices, and Patterns and I read about the concept of leaky abstraction which is well described in the book.
These days I'm refactoring a C# code base using dependency injection so that async calls are used instead of blocking ones. Doing so I'm considering some i... |
Sometime ago in a code-review (C++) I suggested to change the input argument from Path type to Optional<Path>, where the function has specific logic for unset path. It looks for me intuitively better, but the author appealed that Path::empty() (empty path) method should semantically mean the same as unset Optional.
My ... |
I have a question about versioning when I depend on a third party (TP) project's versioning. Our current process is to release a new version every time TP creates a release with security fixes. The problem is when a TP release contains new funcionally that we want to use in some but not all of the projects we maintain.... |
Are there any published standards of archive files to hold webassembly (multiple files) with a metadata file that defines the entry point? I'm thinking of something similar to JAR or APK.
|
Lets say you are coding a function that takes input from an external API MyAPI.
That external API MyAPI has a contract that states it will return a string or a number.
Is it recommended to guard against things like null, undefined, boolean, etc. even though it's not part of the API of MyAPI? In particular, since you ha... |
I've my front end written using HTML/CSS/Javascript. Front end is communicating with the backend(Oracle database) using Java Webservices (Spring boot app).
Situation #1:
User clicks on the Download button, using Ajax call, I call my Java webservice, java webservice returns the data in JSON format, I display this data i... |
I have an object that acts as nothing more complicated than a data store for a collection of items. I do this because it lets me bind the data to a single object, which I can store in the Unity (game engine) editor and assign to a bunch of other objects so they all operate on the same list of data.
I'm not really sure... |
I have a user table that has 4 rows with id = 1, 2, 3, 4. I delete the row with id = 2 and insert another user and the user will get id = 5. What will happen to the id = 2? Will it be used again or do I rearrange the ids? Rearranging ids doesn't make sense if I have a large amount for every delete operation.
|
I recently had a discussion with a friend about code maintainability with regards to modifying an iterator inside of the body of a loop (C# syntax):
List<int> test = new List<int>();
for (int i = 0; i < 30;)
test.AddRange(new int[] { i++, i++, i++ });
The code works fine, and as expected adds 0 - 29 into the list.... |
My team and I have this Desktop client developed in JavaFX. It basically has a "Remember my password" checkbox. If the user ticks this checkbox, reboots, and reopens the app, the user should be automatically logged in. I'm using a cheap trick just saving a temp file to the temp directory. It's encrypted and it contains... |
I'm actually studying about web development.
I was just asking why a lot of web apps and chats(Whatsapp, Telegram, Discord, and a lot, a lot more!) are using cache.
I mean, after learning cache systems like Redis and Memcached, I was asking how could I use them practically.
For example, Redis can cache entire pages for... |
From general observation I've come across the standard to be 36. I was looking to incorporate a uuid in my urls but didn't want it that long. Is there a minimum where I can still keep the uuid unique?
|
I'm designing a relatively simple web application using .net core. I've mostly done desktop development in my career so far, so I'm a bit new to the nuances between desktop and web development.
In this application there is a business logic layer and a presentation logic layer which takes the business logic and transfo... |
Although I understand privacy concerns, the measure has been imposed by politcians and I want to know what the proper way to put this into place would have been.
Right now, each site has to implement GDPR compliance which is kind of redundant with no promise that your wishes are actually respected.
Wouldn't it make mor... |
While designing a complex system some of my colleges came back with the idea of having two separates APIs, one that will perform the writes into de databases and another one that will only do the reads.
I fail to deeply understand why separating those two concerns can be useful for the whole system. It can be useful wh... |
Relatively new to Domain Driven Design i decided to try it out in an saas app currently under development/refactoring. I've refactored the identity part out to it's own context (class library in .net) and came up with the following Domain models:
Organization. Is an Entity and Aggregate Root (all users in the system s... |
I have a collection with millions of items of Generic type T. Assume this list never changes.
I want to perform many types of searches with subsets of fields of type T. Some with only 1 field and others with 2 or more fields.
Each search almost always returns more than 1 result.
This answer is very close to what I want... |
I'm working on a problem, in which i have some real time weather information of different cities through out the world. I'm exposing subscribe function to interested people/clients, with input:- location(this would be the name of the city) and time(HH::MM::SS).
Now, lets suppose, N number of people subscribe for Locat... |
UML Diagrams says:
A use case is a kind of behaviored classifier that specifies a
[complete] unit of [useful] functionality performed by [one or more]
subjects to which the use case applies in collaboration with one or
more actors, and which [for complete use cases] yields an observable
result that is of some ... |
While mostly every company got it's standard on APIs, the question just came out after that one of my colleagues stated we must use different object models for creating and getting objects from API.
To be clear, he states that when you want to get the object from the API you will receive an object like this:
{
id: '11... |
I am trying to figure out the optimal branching strategy for my organization. And I have few doubts.
We have 3 main environments, Live(Production), UAT (pre-release) and Staging. Similary in GIT we have 2 Major branches. Master(State of Prod) , and Dev.
Developers start with checking out Git Dev and creating a feature ... |
I'm looking for a design pattern that might work for this class I am working with. This main class is an entity using Domain Driven Design.
public class TimeCard() : ITimeCardHeader
{
public int TimeCardHeaderID { get; pivate set; }
public int ContractorID { get; internal set; }
public S... |
I have one request interface IRequest and two classes ClientAddress and ClientOrder are implementing it. The same design is followed for Response with inteface IResponse and classes ClientAddressResponse and ClientOrderResponse.
I have tried to do it 2 ways but I am not sure which is better way
With Explicit type cast... |
I want to have two methods, one which returns all items and another, which returns specific Item by name (assume Item has name field):
Item getItem(String itemName)
List<Item> getItems()
How should I name these methods? I'm not sure about getItem and getItems cause these methods just looks too simular (it's hard to ca... |
An application I'm considering writing needs to show a text that a user has edited at a particular time.
So consider if we have a text the user is editing from Time A to Time X, and I want to show what it looked like at Time L.
This text can be for a long running process, and it can be theoretically big, therefore it ... |
I recently started working as a programmer and I am currently going through some codes (in C#) written by my colleagues. I have noticed that they tend to include logic within function calls within some conditional statements. For example:
if (MoveSpace(currentPos, distance * time))
{ doSomething }
They would also incl... |
I am developing a financial system and want to have a defined policy for rounding monetary values.
Given the following layers:
View
API
Entity Model
Persistence
If I am passing a monetary value through these layers, and maybe using it in calculations in the model, at what layer (if any) should I be applying my "defau... |
Scenario
I have an application where some operations require the authentication of an admin.
Example Steps:
I need to validate the admin's username & password
insert a row into a MySQL table (if credentials are valid).
One Trip Approach
If I use a single Connection to the database, with multiple PrepearedStatements... |
I'm trying to encapsulate permissions logic for a particular view model in a way that the permission logic has access to the view model object, but is also exposed inside of it
Trivial Implementation:
public class ClientViewModel
{
public Client Client { get; set; }
/* permissions section */
public bool Ca... |
Why do I define my Queries, Data, and Mutation as Singleton when using GraphQL in .NET Core?
From the doc's dependency injection page:
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDependencyResolver>(s => new FuncDependencyResolver(s.GetRequiredService));
services.AddSingleto... |
A language agnostic approach since I see this problem in both compiled and interpreted languages with the builder pattern.
Let's say I have a Model that has 10 required fields and 5 optional fields. Of course, adding all these fields to the constructor would be a mess, but the constructor would allow us to easily chec... |
I would like to be able to debug building a binary builder. Right now I am basically printing out the input data to the binary parser, and then going deep into the code and printing out the mapping of the input to the output, then taking the output mapping (integers) and using that to locate the corresponding integer i... |
e.g I'm parsing whole Excel file with many rows, that has an column which contains Date.
I'm not sure how to handle error-handling when it comes to parsing string to DateTime
Here's an sample code which is in C#
for (int i = 1; i < sheet.RowsCount; i++)
{
// cells are strings
var cells = sheet.GetRow(i).Cells;... |
Most of the react application I've seen are organized with components that, in my opinion, do too much.
They may follow this pattern:
class MyComponent extends Component {
constructor() {
this.prop1 = this.props.prop1;
this.prop2 = this.props.prop2;
}
render() {
//....
}
o... |
Currently i'm working on a small platform with a simple client-server model and will soon go in a closed beta with a launching customer.
In essence it's an Electron application which is mostly used for logging in, and fetching files/information from a simple PHP+MySQL backend with some other related functionality rega... |
Let's take the classical example of a function that may return a number or not.
In typescript this can be represented like this:
function f(): number | undefined {}
A more elaborate way would be to build a maybe type and use that for the typing:
type Maybe<T> = T | undefined;
function f(): Maybe<number> {}
To check ... |
I am working on a project where logs of all kinds (e.g. errors, warnings, etc.) are stored in a database table, in the same transactional database used for the other business purposes. It is a MSSQL database.
A good practice is to use a NoSQL databases to store logs, stream them and query them (e.g. using the ELK stack... |
Generally, I read that large methods benefit from some sort of inlining and the C# compiler does this sort of micro-optimizations automatically. I understand that if a method is called just one time in an enclosing method, performance might improve when inlined even if the method itself is large. However, if a large me... |
Kubernetes provides a very elegant mechanism for managing configuration for pods using ConfigMaps. What's not clear from the documentation is what the recommended practice is for using ConfigMaps to manage different configurations for different environments, and also to deploy configuration changes when they occur.
Ass... |
I have a very large monolithic legacy application that I am tasked with breaking into many context-bounded applications on a different architecture. My management is pushing for the old and new applications to work in tandem until all of the legacy functionality has been migrated to the current architecture.
Unfortunat... |
I am trying to do a design for notification part in the system I have 2 parts inApp notification and email notification so I used strategy pattern where I have interface NotificationSender with one single method send
NotificationSender{
public void send(A,B,C);
}
then I have 2 implmentations
InAppNotificationSende... |
We have two teams, each using git, and would like to share a small project between them. Git submodules sounded like an obvious answer until I started searching and found lots of "submodules will bring you pain!" opinions out there. An answer to a related question here suggests git subtree, which seems to be baked in... |
I'm trying to create a website as a forum similar to Reddit, but on a smaller scale (no comments also). The website will allow users to post a link to a forum. Then they can view a list of New or Trending links based on upvotes (gathered from an external API).
So basically all I need is to have a REST API to post links... |
Consider an abstract example, just to illustrate - you have a service for loans, which gets requests to borrow X USD, checks if there’s enough USD to lend that, if yes - marks that amount as reserved for a loan and sends a message to another service which actually processes the loan, and responds with success, if no - ... |
If passwords are stored hashed, how would a computer know that your password is similar to the last one if you try resetting your password? Wouldn't the two passwords be totally different since one is hashed, and unable to be reversed?
|
We're building a new web-based industrial application and one of the questions that are hammering our heads for the last few days is about the integration between different "microservices" on this architecture.
I'm using microservices with just a pinch of salt because we're not totally embracing the concepts to define ... |
We're trying to re-think the installation process of our software suite and I'm trying to find out what specific pitfalls we're facing without using my/our limited lens of the Windows software landscape today.
We have gathered a set of issues that an installation of our software potentially has to handle, and I would l... |
I have many models in my project that are unrelated to each other. I wanted to group them but I wonder what's better:
Folder/namespace per group
Group1.Constants, Group2.Constants
Group1.Models, Group2.Models
Group1/
├── Models/
│ ├── Class1.cs
│ ├── Class2.cs
├── Constants/
│ ├── Constants1.cs
│ ├── Constant... |
So the basic scenario is I have a class that starts/stops service objects with the methods start(String serviceid)/stop(String serviceid). It is designed to then forward various execution tasks to the appropriate service.
What I am trying to achieve is for the start/stop methods to be non-blocking. Hence if you start y... |
We are trying to move from a monolith application to a microservice architecture faced by a spa application. One of the reason, is that we want to expose some services of our business to partners and another reason is to build a better user experience via an spa application.
In the old application I had a webapplicatio... |
The pain that I've often felt when creating database migration files, is best described in this Speakerdeck: Sane Database Change Management with Sqitch.
Paste entire function to new "up" script
Edit the new file
Copy the function to the new "down" script
Three copies of the function!
And I end up with no clear di... |
Please let me illustrate with a simple example. Suppose we have a Weather object:
class Weather:
def get_forecast(self, day, place):
forecast = "code that calculates forecast"
return forecast
On the other end we've got a weather forecast web app that accesses the Weather.get_forecast method direct... |
I have <5 years experience in the software industry and this is my first time doing QA.
Before the stories in a sprint move to UAT, I am supposed to retest every single story in ~1 day in an environment between QA and UAT.
The purpose is that multiple teams have their own QA environment where they exclusively test the... |
I'm creating a proof-of-concept for a Go-app for my organization. I've read all of the intro docs on setting up a Go workspace, packages, etc. However, I am still unclear about the relationship amongst the recommended directory structures, packages, AND the fully-compiled applications that will eventually be deployed. ... |
I am currently writing a memoire on the evolution of developing tools. Among them is of course the programming languages. I made some researches, and a lot of the most popular languages are scripts languages like Javascript, Python or Ruby But when comparing performances, they are not as efficient as VM languages or co... |
I have a script that migrates data in the database.
It copies property X to property Y.
If I want the script to be idempotent, what should it do on subsequent call if X changed?
For example:
X is 'a'
==> I run the script, then Y is 'a'.
now X is 'b'
What would subsequent call to the script do? set ... |
My application has a grid with a list of Car objects from a third party system
[{id: 1, make: "Ford", model: "Focus", ...},...]
The user can select a Car and use its data (after some transformation) to create a Car specific to my application. The app does this by filling in a form on another HTML page with the transf... |
I have a class that uses constructor DI for IEventAggregator
public SomeViewModel(IEventAggregator eventAggregator)
{
this.eventAggregator = eventAggregator;
eventAggregator.GetEvent<SomethingChanged>().Subscribe(UpdateResults);
}
I have another method in ... |
I want to setup a dedicated test computer that can be restored to a specific system state. The reason for that is that the software tests to be executed on that machine include the installation process. Software can certainly be uninstalled, but that often does not revert the whole system back to its original state.
I ... |
In most definitions of negative testing, the idea is that we test outside what is specified/expected and it is highly related to robustness.
So basically, if the behavior for such conditions is defined, I would be positive testing as we verify behavior that is specified, isnt that so?
An example requirement:
REQ1: Nam... |
I am new to ef and liking it since it reduces the overhead of writing common queries by replacing it with simple add, remove functions. Agreed.
Today I got into the argument with my colleague who has been using it for a while and approached him for advice on when to use Stored Procedures and when to use EF and for what... |
I'm working on a server, which you can pass some form of authentication as input (like connection string) and it will connect you to your database. So the DB connection is going to be dynamic. There can be multiple users at the same time, connecting to different databases.
What I'm wondering is, is there a preferred wa... |
I am planning some app as a part of our product. One part of the app will be to receive push messages.
Sometimes it's months between uses of the app and, by experience with other apps I've used, it seems like there is some timeout. If you don't use the app in a while, it will stop receiving push notifications.
So, doe... |
I'm trying to modernize a very old PHP application for a customer to keep its code base up with modern coding standards. I am permitted to restructure things a bit, but dumping the entire app and switching to an existing framework is not yet an option. I just need some general tips on how best to restructure the applic... |
Let's say you're loading a denormalized flat file of purchase transactions that looks like this:
| location_name | location_zip | product | product_price |
|---------------|--------------|---------|---------------|
| downtown | 90001 | fries | 2.99 |
| west side | 90048 | burger | ... |
Anyone know, how many users are valid to use the prototype of the software that we have made? I have conducted research on the reference to the "Software Engineering A Practitioner's Approach book Roger S. Pressman". There is no mention for valid users of software testing?
|
Is it a bad design pattern / anti-pattern to create a whole bunch of specific middleware to replace functions in-route. So instead of doing this
router.post('/myRoute', (req, res, next) => {
checkParams(req.body).then(paramsResult => {
if(paramsResult.status === 'failed') return res.send(paramsResult);
... |
What data structure i can use to lookup given a fromCode and toCode apart from hashMap which results in more number of entries in the memory.
We are ok with log(n) efficiency also.
Example data:
fromCode toCode distance
100 200 10
100 300 20
----- ---- ----
Assume fromcode and to... |
Currently: ASP.NET Core 2.2.
I've been doing quite an extensive research in this topic (Domain Driven Design used together with Clean Architecture):
DDD: Where to place domain event handlers?
And I've seen a couple of DDD and Clean Architecture Repos to better understand:
https://github.com/VaughnVernon/IDDD_Samples_N... |
I am working on a web application which allows users to review pdf documents. These documents are submitted from another public facing website. A typical workflow involves:
A document is uploaded on the public facing website and stored into document management system (DMS).
The internal web application grabs the docu... |
I am trying to add a new template to an existing CodeIgniter 3.0 project where the original developer had not planned for additional templates/themes.
The primary objectives are to:
a) make a usable copy of all existing views and css files and leave the originals unchanged.
b) allow for core updates as they are release... |
My question is how I can achieve more encapsulation in TypeScript.
I have a class Item, with a public setter isOwned, but I only want to call this method in specific situations: if the item is picked up or dropped by a Player.
/** @package A */
class Item {
private _is_owned: boolean = false
// ...
/** ... |
I am recently studying computer science and I was introduced into boolean algebra. It seems that boolean algebra is used to simplify logic gates in hardware in order to make the circuit design minimal and thus cheaper. Is there any similar way that you can use it to reduce the number of code lines in your software in h... |
I have a C-coded function that realizes a very long calculation on a microcontroller. I try to optimize it for speed at the moment. The function content is created automatically using Mathematica. It has hundreds of calculations and looks like this:
void calcResult(float *result, float arg1, float arg2, ... float argN)... |
I like to write classes with two constructors: a primary constructor used in production code, and a default constructor just for unit tests. I do this because the the primary constructor creates other concrete dependencies that consume external resources. I can't do all that in a unit test.
So my classes look like this... |
I would like to save the current "value" property of several components (e.g. a Slider) as a configuration profile when the user clicks on the Save button in my application. However, the Save button is in a different file than the rest of the components. How should I deal with this? Some solutions that I have thought:
... |
I'm working on a .NET Core REST API and I'm writing a service class to create new user accounts. I have the following code:
public async Task<UserDto> RegisterNewUserAccount(CreateAccountDto userInfo)
{
EnsureUserDoesNotAlreadyExist(userInfo);
EnsureRfidCardIsNotAlreadyClaimed(userInfo);
... |
I'm using a lot of async Task<IEnumerable<T>> methods and I want to stop doing this everytime to get the items as a list:
var items = await AsyncMethodThatReturnsEnumerable();
var enumeratedItems = items.ToList();
So, if I do something like this
var items = (await AsyncMethodThatReturnsEnumerable()).ToList()
Will it ... |
Could it also have made sense to call it a "Form", as in the Platonic sense of the ideal form that represents the thing which earthly objects strive to emulate?
|
Why is argv declared as "a pointer to pointer to the first index of the array", rather than just being "a pointer to the first index of array" (char* argv)?
Why is the notion of "pointer to pointer" required here?
|
My question is about the construction of main loops running in the background listening to commands and signals and how are they constructed to be efficient. For instance in live music synthesis programming languages like SuperCollider or PureData, you have somewhere a sound server waiting for changes in your source co... |
Consider the following architecture:
Application A
Application B
Commons-Util
A and B share a lot of functionality. That's why we plan to extract the shared code into a commons library.
I am aware of the advantages and disadvantages of multi modules vs. separate repositories.
However, I'm not sure for what to go in ... |
I know that the following function is a virtual function and needs to be overridden when extended by another class:
virtual int getAge()=0;
What i don't understand is the following syntax I have seen in places:
double getAge(int id) override;
Is this also a virtual function? I thought the word "override" is only use... |
In Javascript, converting [] to a number (e.g. +[]) gives 0, while doing the same to {} gives NaN. This leads to entertaining wats like this:
> 2 / []
Infinity
> 2 / {}
NaN
Is there a historical reason for this, the same way that there is a historical reason for typeof null === 'undefined'? http://2ality.com/2013/10/t... |
My project relies on a specialized component which is stuck (by its configuration) to an older version of the framework my project is using. This makes updating to the latest version of the framework impossible.
What are the best practices when dealing with this type of issue?
|
I'm having trouble grasping the value proposition of the "command" half of the CQS principle in a system that doesn't implement command query responsibility segregation.
The CQS principle states that a method that returns a value is a query, and should never affect state. A method that affects state, should never retur... |
I'm writing a program, part of which consists of determining if a given file is a PNG. Knowing that a file doesn't have to be named with its respective filename extension to be of a certain type, I decided to check for it's header. However, after not being able to think of anything better, I wrote this if statement wit... |
I'm working on a web project that executes CLI commands to perform running tasks to spare users from having to wait since PHP/Apache combo cannot (to my understanding) create a separate process for said long-running processes.
Is the this the best approach for running long for running long processes that do not force ... |
I'm in the process of designing a new desktop application which is very different from other stuff I did before, and so I'll be happy if I could be pointed towards the right direction regarding the basic building blocks of it.
The application should read a binary file, process it "line by line" and after some chunk of ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.