instruction
stringlengths
34
36.1k
Especially when working with some kind of ORM like Entity Framework I often see classes like: public class Foo { public int FooId { get; set; } } accessing the id will look like foo.FooId Is there any logical reason why is this preferred over just naming it Id? public class Foo { public int Id { get; set; }...
I've seen many articles describing differences between Domain Model and Data Model. However none of the articles have picture representations showing difference. https://stackoverflow.com/questions/3507671/whats-the-difference-between-data-modelling-and-domain-modelling Can someone provide a picture example showing dif...
I've been doing a little research into algorithms for matching spelling mistakes in names. From Soundex through to metaphone and Beider-Morse. All of these algorithms generally focus on last names with an ever widening language ability (beider-morse being the most useful across a lot of different languages). I'm wo...
From what it sounds like, a 64 bit processor means aligning to 64 bits, which means if you have unicode utf-8 stored in there, each 8-bit chunk would take up 64 bits of space. That doesn't really make too much sense, so I think I need to do a bit more to understand exactly how cache aligning works. But thanks to this g...
I am developing against a file spec that lists the data type for certain fields as CHAR(<length>) The spec is for a fixed width flat file. In most cases, possible values to populate the fields are obvious (either delineated in a list of choices, or simply alpha/numeric by design). One of the fields stores an error mes...
I'm starting to dive into domain driven design for a new project. The software solution will be used by several departments to assign tasks to their employees. The task assignment process is mostly similar for these departments. One of the differences is that some departments assign tasks to their employees only, other...
In an environment where you can't merge code that fails tests you obviously can't merge new, failing tests. But how to deal with a newly found bug exploit, meaning you wrote a new test exposing an already existing bug? Test-driven-development would say: Hooray, you have the test, now fix the bug and then commit both. B...
This is my first post here and I'm glad to join this great community and I hope to learn a lot here and help if I can(though i am a very beginner). I have a theoretical question: I am trying to add to the single cycle datapath the following command jm IMM($rs), that will, using address in the command, will jump by the...
My web app generate log entries on hooks such as model.save. Right now, I have a class Entry (representing a log entry) with a string field content to contain the text of the log entry. Examples of such entries: Entry(content='Account 123-456-7890 spending changed to $500/day') Entry(content='Account 123-456-7890 pa...
I'm coming from the monolith background, using a single large relational database. From my research, many proponents of the microservice architecture favor the event-driven rather than REST driven architecture. The following question applies to inter-service communication, between bounded contexts (in DDD terms) and NO...
The structure of our project strongly separates the three different parts: core - data classes, POJOs, sometimes aggregated with annotations (e.g. for XML/JSON serialization) plugin - plugin for a large enterprise application that is based on Swing ui - additional UI components in JavaFX, does only use the core data c...
Given following microservice architecture: Every post has a user, for which we want to have all information available. Is more custom to: Have a local user cache in the posts microservice Make api calls to the user service on every request Store user information along with every post I don't particularly like...
I have a number of attributes I need for various page loads and other backend tasks, and I'm debating on whether storing these things in a database or calculating them on the fly. For instance, if there are files that users can upload, and you want to track the size, space taken, format, etc. would it be better to calc...
I create an object that holds the status of a job. The job has many stages, some concurrent. Worker threads constantly monitor the status object to see if it's ready for the next stage to begin, if it is the perform the job, update the status object and end. Is it some form of pub-sub? Is there a java framework for im...
We have two developers working on the same project. One is doing the front end and the other doing the back end. Everything is working well, however we have come across the developer doing the back end stuff and getting though it faster than what the front end developer is working on. Therefore the back end dev skips a...
I am writing a type checker for an ML dialect that involves generating "fresh" (new and unique) "type variables" (values representing unknowns). My strategy, and the strategy that seems to be used in tutorials, is to identify type variables with a unique integer and keep a counter that is incremented whenever a fresh t...
I am looking for text compression algorithms (natural language compression, rather than compression of arbitrary binary data). I have seen for example An Efficient Compression Code for Text Databases. This algorithm basically uses the words as symbols, creates a dictionary from them, and replaces them with integers. ...
FIRST AND FOREMOST: Forgive me if the following question falls into the "off topic" category of this StackExchange, due to its slightly opinion polling nature. This is not my intention, I am simply looking for good practice advice in regards to general API design. I am current implementing an applications development f...
The question is about choosing the appropriate design for the scenario described below. This is a repost from https://stackoverflow.com/questions/51940180/unity-injection-with-too-many-constructor-parameters where it was suggested to put the question here. The question seems to cause a severe controversy even among so...
I'm working on a code base with a coworker who has a habit of checking the results of a constructor for a null in a fashion similar to this Person p = new Person(); if (p != null) { p.Name = "John Smith"; } My understanding of the .NET landscape is that a constructor will never leave an assignment unfulfilled unle...
I am currently designing a web application which is pretty similar to Twitter but with some unique features for my company. Technologies are Vue2, Spark framework and PostgreSQL. I am trying to decide on how to design the ER and how to integrate the client side with my API. Let me break down the problem. These are the ...
I am working on a project to help learn DDD and am trying to do CQRS and Event Sourcing. Code is in C#. For this example, lets say I have 2 aggregates, Customer and Product. My aggregate repository has a get method Get<TAggregate>(Guid id) that loads all events for that ID, creates a blank TAggregate instance, and then...
I am in a situation where I believe type providers would be useful. Consuming type provider in F# could be the way I finally dip my toes in F#. However, I understand that writing type providers is hard. It may not be a suitable first task in F#. Is there a reason why it would be problematic to write the type provider ...
I have a module as below: def normalize(sub_item): pass def process(sub_item): pass def cleanup(sub_item): pass def calculator(item): pass def main(item): for index, sub_item in enumerate(item.sub_items): normalize(sub_item) process(sub_item) if index == 0: c...
I have a Web server (Local) and File server(Remote). I need to create a duplicate of an xml file in the same location with different file name in the File server. The size of the file is random, but the maximum file size can be 45mb, and I have 200 users a day. I'll be using ftp_put in transferring files between server...
I want to use gitflow in combination with semantic versioning. In gitflow, you bump version numbers on every release or hotfix branch. This inevitably leads to version conflicts if a new development cycle (with a new version number) is started while the current release process is still ongoing. Let's say, 1.0.0 is on ...
I am in the process of refactoring and improving a codebase. One of the major missing features is transactional safety and certain errors arising from each repository having its own DbContext. The current setup is as follows: The BLL (FooManager) connects to as many repositories (FooRepository, BarRepository) as it wa...
Assume I have a class like this: public interface IService { // Gets some data, possibly from a website / database List<string> GetStrings(); } public class ItemViewModel : BaseViewModel { // Some view-related data... // Dependency private readonly IService _service; // Property to which we b...
Similar question: How do you handle versioning in a multi-sided project? Since the question above was asked almost 4 years ago, I was wondering if any new ideas have emerged . - We have a situation where we develop a platform that will have multiple instances. For example: https://instance1.myplatform.com https://inst...
Consider these two ways to declare a field in a C# class option A public class AuditController { public DataAccess Service; } option B public class AuditController { private DataAccess service; public DataAccess Service { get => service; set => service = value; } } Which one is better? My code analyzers ...
Currently, I work in a company that divides the product into squads, and each squad is responsible for a different product (or software). The squad that I've been working takes care of a software that all other software use (It's a Payment Gateway), and every change that we do, we need to communicate to the other squad...
I was going through some articles related to Futures and Callables today and was thinking about the best practices when working in an MVC based environment. I was wondering, should one be creating Future objects in Controllers and force service classes to return a Future object. I have a case when one particular API n...
I am trying to build code generation and transformation tool and hence I need software for Abstract Syntax Tree manipulation for at least three languages (Coq, Haskell, Java). So far I have managed to find custom software for 2 of the languages (Haskell, Java) and I wonder - why there is no universal program that can t...
This suggests just storing BigInts as an array: // n = -123 var n = { sign: -1, digits: [3, 2, 1] }; However, if you have "big ints", that array will get large: var n = { sign: -1, digits: [ 1, 2, 3, ..., n_100 ] }; A hundred digit array, that would be pretty slow if there were a lot. Maybe there is a...
I'm trying to understand how servers handle many requests when they start to run out of RAM. Let's say you have a server with 1GB of idle RAM. Let's pretend it was bombarded with 1024 requests in 1 second and each request sent over 1MB of data. Let's pretend that the server was dumb and it didn't send a response back t...
I want to understand how Behavior-Driven Development (BDD) can be applied to building CRUD applications. I have read a lot on the subject but I just don't get how I'm supposed to apply it. I learn best by example, so I built a mini CRUD application and I would like for someone to complete it by adding the tests. The a...
Say I have a blogging system. Users can create posts that will get automatically published unless some score is reached. So when users save a post, we do some calculations and add up some numbers to score it. Below is an example of how I have this working: $post->hasTooManySwearWords() // adds 3 to the score $post-...
I designed a function which, afterwards, I noticed it is clearly doing 2 very different tasks in the same time. So now I am thinking to split it into 2 different functions, each one of them doing only what it should do (SRP). Obviously, one of these functions will call to the services of the other one. But I wonder if...
I am building a comet service which will push new data to the client on mobile devices. For this, I am using websockets to deliver messages to the client. The problem I am facing here is the reliable delivery of a message to the client. How can I be sure that the data I sent over the websocket was actually received by...
I'm writing a couple small python scripts to do tasks and act as 'bots' in some applications that will all read/write things for configuration and some very low-level logging of information; Whats the best way of storing these snippets of information? Currently I've made a single config.json file that has Bot tokens, u...
Say I have the following ER diagram: What I know is that the "one" side of the relationship means the following: Each student can meet 0 or 1 teacher. So for example student3 can meet teacher7, but it can't also meet teacher4. But does the "one" side of the relationship also mean that student3 can meet teacher7 twice ...
This may come off as a bit confusing, but it's a question that I keep finding myself asking as I pile on more and more responsibility to older systems and features that I designed previously. Trying to get to the gist of my question is a bit difficult, but I'll try to illustrate it with some examples. A couple of years...
Lets say I am building an application where clients can book bus tickets. The only thing they do is select, origin, destination and the type of service (express or standard). The system will then book the ticket against the right bus company api. The user does not need to chose service provider as it has already been n...
Practicing some of the ES7 features, I started developing a class to perform some actions on the DOM and use the new features. I used Babel to make it work on the browser, and the code looks something like this: class myModule { constructor() { this.myProperty = 1; } myMethod = () => { //... } //... }...
Like in the title: how do you integration-test server failures that return 500 HTTP responses? For example: There's a server with a /save endpoint that accepts files on POST and saves it into the server filesystem There's a library/dependency X which handles the file saving functionality somewhere deep on the other en...
I know this question came up by a lot of people here and around the Internet but I couldn't manage to find a really clear explanation how to do queries spanning multiple microservices. Imagine that I have 2 services, one is managing user relations, and one is responsible for blog posts. If I just want to get the 20 lat...
Python added the async/await constructs in 3.5 in 2015. The Javascript community made steps towards it for a bazzillion years and finally added a very similar implementation to the draft in ES8 released in 2017 (From my understanding). Typescript also added async methods in 2015 in version 1.7 that to the untrained ey...
I'm working to design a REST API to be consumed by a React SPA. The client-side of the SPA queries data about a relationship between two entities: Team and Player where Teams have many Players and Players can only belong to one Team. I want to query all the Teams and then get all the Players for each team (which you co...
I am in the process of upgrading an existing website to ASP.NET Core 2.1. The goal is simplification and ease of maintenance. Existing site is using: EF and .NET 4.6.2 A [Users] table in SQL Server which is related to a lot of other tables in the project. New site is using Dapper instead of EF, plain SQL statements d...
Say I have file paths like this: my/long/directory/structure/index.js my/long/directory/structure2/index.js my/long/directory/structure3/index.js my/long/directory/structure.../index.js my/long/directory/structuren/index.js my/long/directory/index.js my/long/directory2/index.js my/long/directory.../index.js my/long/dir...
In this article, blrfl makes a good case (How to design a good receipt number) for keeping things simple. Don't encode information into numbers - any information needed can be looked up. I am very much in favour of this, but thinking about it now, I have a slightly tangental question. If my data has whatever records i...
I have a simple class that has a private field and a public property. The property also calls a static helper method which it is kinda dependant on and i feel this might not be a good thing. This is my code: public class PathLine { private Vector2Int _gridA; public Vector2Int GridA { get { return _g...
I have a big system of classes and objects which rely on each other in order to function. Should I put all of the require_once() calls for dependencies at the top of each class file? ie: <?php require_once( 'neededClass.php' ); class MainClass{ $this->neededClass = new neededClass(); } ?> Or shoul...
I have the scenario below and what I want to do is to build a retry mechanism to retrieve a status. So, what we have is a payment system and we want to call a 3rd party provided periodically in order to retrieve the payment status. More specifically, we want to do it exponentially, 1st time after 1s, 2nd time after 2...
The framework mix problem I'm using two frameworks -- PingIdentity's SCIM 2 SDK and Spring LDAP -- to deserialise a SCIM resource (i.e. JSON) to a Java object then write it to an LDAP directory, and the other way around. The trouble is, both frameworks want to annotate the fields of my Java data class and this is getti...
On GitHub if I want to contribute to another user's repo I clone it, make changes and submit a PR, at which point the owner can choose to merge or not. I am trying to figure out how to create a similar flow with a private Git server. We have a Git repo at work that I do 90% of the work on, but occasionally my co-worker...
I have some doubts about non functional requirements in a web app. Are quality attributes non functional requirements? Also, these are all examples of non functional requirements? The system should have a score >= 80 in PageSpeed All network transactions should be encrypted The users need to login to the system to acc...
If I understand the concept of read models correctly, then it's just a simple query to return a use case specific data set. But a DTO seems to have the same purpose, but in a more complex way (mapping an aggregate for a specific use case). I'm building a search function and I feel like using simple read models would be...
I have an entity framework model called Employee. Whenever I request a list of all Employee rows I first want to make a soap request to get any new employees from another system and update the sql database with them. Is there some sort of binding that I could apply to the model or would I just have to add another model...
For my system I would like to record constantly, which independently I can do. Additionally, I need to be constantly reading some sensors (using SPI), which independently I can also do. My present problem is combining the two tasks. I need to record all the time, but also read the sensors 10-50 times per second. Using ...
I'm having a read at J.B. Rainsberger's blog post on integrated tests and wonder in which way an integration test is more harsh with our design? We write more integrated tests, which are bigger and don’t criticize our design as harshly as microtests do
I'm developing an application that handles sales for multiple clients, when the client sells a particular item, that information should be send to the admin. The count of each item sold and the item names. I've done that by setting a simple server online and sending POST requests to that server with the appropriate dat...
I am working on some legacy code that involves Orders placed by Customers. There is a new requirement to classify each Order by Business Unit. The Business Unit Name will be stored in a new column on the Order table. The Order is not an actual object. I have an Order Number, which I can use to retrieve two different X...
We have created software for Rugged and mobile devices, and it gets deployed on the device. Admin has a provision to send an update to those devices. We use GCM or WNS for sending a notification to the devices that it has an update. Problem: If all the devices request for an update at the same time, then we will have ...
In ES/CQRS, do/can we treat requests as events? Consider the following flow A guest visited some url and posted data to create a new account. Here is one way to implement it 1- Invoke CreateNewUserCommand [payload = posted data] 2- Invoke CreateUserHandler(CreateNewUserCommand) 3- Fire CreateNewUserRequestedEvent [pa...
For example, I have a for loop, which element 0 has additional function to run compared with other elements, my question is, should the additional function be: 1.place inside for loop for(int i=0;i<this.arr.length;i++){ this.arr[i].a(); if(i==0){ this.arr[i].b(); } } 2.handle separately from for loop...
I have two applications A and B. Application A was written before application B, actually B was initially the same fork of A thus, each of the application had the same modules and same code in it. The structure of updating the codebase of both the project has been in such a way that: updating the codebase of A will do...
My team follows the practice of including JIRA issue key in each of our commits and also in the title of a Pull Request. Each developer usually make changes in a branch on his/her own fork and then raise a PR aka Pull Request against master branch of the main repo. Given all this, I want to understand if naming the bra...
I have a RESTful services developed using Java Spring framework. It's not a huge application, around 12K lines of Java code. Front end is in Angular and DB is No-SQL world. Recently I came to know that Java SE is no more free for commercial software. I am on Java 8, for my customer getting all Java security updates ar...
Say I have the following ER diagram: The "one" side of the relationship of the above diagram means the following: Each student can meet 0 or 1 teacher. So I can't do something like this: But can I do something like this?: I think the answer is No, because these two implementations are just two different ways of reco...
I am trying to develop my package structure based on features rather than layers, but am struggling to find a package name for some of the classes. I have seen people use a package name of common for classes that seem to span multiple packages, but I cant seem to find any good resources on the best way to go about deci...
Factories are used to create objects. I was wondering if it's against the purpose of a factory, if I would bind couple of objects together in the factory. Let me illustrate this with an example. Let's say I have a factory that produces modal dialogs. The factory can instantiate a view, which will display on screen. A...
Imagine a couple dozen services (sets of options), each of which contains a subset of all available options. I want to create a web form listing all possible options so that users can check the boxes for the options they want, then, after the form is submitted, return a report listing the services from best match to wo...
Suppose I have the following List to hold a list of fruits. Example: def fruits = ["Apple", "Orange", "Grapes"] def fruitsBowl = ["Apple", "Grapes", "Orange"] // Will print false println(fruits.equals(fruitBowl)) Only after I call .sort() them will both collection be equal. fruits.sort() fruitBowl.sort() // Will pr...
As a followup to this question and one I asked a while ago, suppose if I had an Author class structured like this: class Book { private String title; private Set<Author> authorsSet; Book(title, authors){ this.title = title this.authorsSet = authors } } I accept a set for two reasons: ...
Objects contains 2 method overloads where one takes an object and the other takes a Supplier of that object: public static <T> T requireNonNull​(T obj, String message) public static <T> T requireNonNull​(T obj, Supplier<String> messageSupplier) and the similar public static <T> T requireNonNullElse​(T obj, T defaultOb...
I'm building an app where end users can add custom fields to database tables. Think of it like a CRM app, where sometime you just need to add an extra field to your customer table. Pretty much all CRMs have this feature. I'm using a traditional SQL database. Should I do it by changing the data structure itself via ALTE...
I'm designing a type in C# that will be used as an algebraic type in a functional style, but is not a collection type and does not implement IEnumerable. If this type is a Functor, should I name its projection method Select or Map? Similarly, if it's Filterable, should I name that method Filter or Where? What are th...
I was watching a recording of a conference by Sandi Metz on testing. One of the things that I struggled with was that she said not to test outputs of the object under test (her example was query messages since she uses rails.) Here is a gist summarizing what she was saying and here is the full talk. Let's say I have ...
I had to implement a module that after completed, the client suddenly asked that for a while it would not need to be displayed, so I was told to comment it out (since we probably will use it later) which I did. Now that I'm reading that commenting out code is generally a bad idea, what would be a good approach to set ...
Setting the debatability of using personal accounts on the workplace aside. Context: The company I work for is dedicated to creating apps for other companies. Because of this we have many different clients and handle many different projects within our company's Github Enterprise organization. I'm one of the people in ...
I have the idea of develop a model that predicts the battery charge level of my system for now until the following 5 days. The battery is charged using a solar panel. I am writing my code in Python 2.7 . I am able to measure the battery level in % (%100, 90%, 80%...%10). The model does not be very accurate, %10 error i...
Hi all I love stackoverflow so helpful. Afaik IOS has some security measures that dont let other apps (such as jvm) execute code from your app. Not sure how much this is true. But anyway, I heard that there are some problems when you try to run java application targeted for Windows on android phone. Is that because som...
In my project I must implement a feature for encrypting some information when it is written into the database, and decrypt the information when it is reloaded. Should this concept be implemented in the domain model? Or is it cleaner / more maintainable to do these operations in the repository?
For some context: I am currently developing a Java application that needs to execute an executable in the command line. But that's not what this question is about. Now, usually you would pack all required resources of a Java application into a folder in /src/main/resources/, but a executable file will obviously not be ...
What concrete objective advantages do chained functions have vs an options parameter for object initialization? What do I mean? Well as one example there's a library called dat.GUI that uses the chained function style of setting things up. For example a simple range slider has 4 or 5 parameters. /** * @param {object}...
I have a problem with my e-commerce site. There can be multiple simultaneous requests to add items in the shopping cart, I was moving towards the design where when an item is added to the shopping cart the stock count would be reduced in the database. However When the system was under load the item row would be locke...
Very often developers are asked to provide estimates (at least rough ones) when a solution or feature will be ready. What steps development team should take to ensure that estimated solution will be delivered in time in accordance with provided estimates?
Say I have a class of User and that user has an Id & Name, in request response modeling, I would make a request with Name on it and a response with Id and Name, thereby my domain model would be public User { public int Id { get; set; } public string Name {get; set; } } In SOA (web api) this is ever so slightly...
I'm adding mod support for a game I'm working on. I parse a data file that looks something like this: "requirements": { "is_class": { "class": "warrior" }, "is_in_faction": { "faction": "elves" } } From this data, I create a list of Requirement objects which convert the data into bound delegates via reflectio...
What is usually done when an aggregate is asked to apply an "impossible" event to its state? For example, if a ShoppingCart aggregate has already applied a CustomerAckRec (The customer has acknowledged receiving the shipped item) event, and is now asked to apply an AddedItem event? This question confuses me, because on...
I have a rails app where users can upload data and then the backend processes it and creates a bunch more data that gets stored with the record. The data processing is async and handled outside of the rails app. Currently I have been storing the unprocessed data in the same table as the processed data and then adding t...
I am developing an Online Application portal. But I am stuck in designing my database tables, and am unsure about the best approach to take. Background: how the portal is supposed to work Let me tell you a scenario and how the portal works. Sam is applying as data encoder. So he go to the online application portal, fi...
We are developing some context using CQRS approach. We ended up with command handlers emitting events. It seems to be a poor idea for us. However, we can't find any alternative approach. We struggle with two particular group of scenarios: Creating new aggregate. Creating an aggregate may result in either success or f...
I have been debating this question internally for a few weeks now and I keep coming up short in finding a good answer to the question. I feel an example would be more descriptive than just talking about it so I will start with that. I have a Python project repository structured as follows: . ├── common_package │   ├── ...
I'm trying to figure out the best solution for the below. Any help would be great. So basically I have a service (that can be scaled horizontally), which listens on a queue. Every message received will be dispatched into a job and processed concurrently. The job will (in same order): Generate some data based on the me...
I am writing a software that splits big files into smaller files and I have coded several solutions. I am measuring the execution time of each of my solutions. (with threads, go routines, MPI etc) and want to objectively compare them. If I run more then once the same solution, the execution time will be less and I unde...
I am taking an introductory course on Distributed Systems, and while reading a introductory tutorial the author discusses that 5 Rails servers behind a single load balancer all connected to one database, is not an example of a Distributed System for the reason that : A system is distributed only if the nodes co...
I'm working on a trie data structure. My simple, initial understanding: trie data structures require a fixed root node. This node cannot be deleted. When iterating through all nodes in a trie (in pre-order), should the root node be reported included? Should the "size" of the trie include the root node? It seems that i...
I am writing applications in C++ using an sqlite database. Suppose I have a simple user system with a user database. User Class class User { private: void LoadFromDatabase(uint32_t id); public: std::string name; uint32_t age; void SayHello(); void SetAge(uint32_t age); };...