instruction
stringlengths
34
36.1k
Anemic domain model was criticized a long time ago by Evans and Fowler, since apparently it goes against object oriented principles, etc. The DDD community is clearly aligned with this statements. However, in recent years there have been disagreeing voices claiming it's not an antipattern at all and that it is an examp...
I'm currently refactoring a large subsystem with a multi layered architecture, and I'm struggling to design an effective error logging \ handling strategy. Let's say that my architecture consists of the following three layers: Public Interface (I.E an MVC Controller) Domain Layer Data Access Layer My source of confus...
I was reading on this software engineering page about the use of static methods. However, I'm confused, and maybe it's about the context in which it talks about static. The idea is, that static is really bad for testing and shouldn't be used. When creating immutable class, sometimes the constructor is private and a st...
I have a try/catch block which looks like this : try { geoms.add(convertLineToGeom(ln)); } catch(IllegalArgumentException e) { System.out.println("ligne n°" + counter + " : " + e.getMessage()); } My function convertLineToGeom might throw different exceptions that I made myself, all of them extending IllegalArg...
I sometimes see these two terms be used interchangeably. What is the actual difference between these two terms? How are they used differently? Are there any other alternatives to these two libraries?
If I find myself fetching one peice of data, and then fetching its 'related data' in a separate request, is this bad API design considering I could package all of this data into one response object? To provide some context: If I am viewing a product's page, I find myself fetching the product's specific data, and then f...
Just a small bit of background. Right now my team tags release candidates in version control. I've learned that this may not be the best thing to do because we still have to go through user acceptance testing before we really release whatever application was tagged. So now we know that tagging release candidates is not...
I see this term a lot in the context of software architecture ("domain-model", "domain-driven-design" etc.). I have googled it, but I get tons of different definitions. So what is it really?
I have some Views and Presenters. In my architecture, they have a circular dependency, so the View has a reference to the Presenter and vice-versa. Now, which is the more commonly used: class View { View() { this.Event += presenter.EventHandler; } } or: class Presenter { Presenter() { ...
Is the term "payload" used exclusively for the payload of (let's say http) request or it may be used to describe the useful information in the response of a request? If its used for both payloads (request and response), is there a way to distinguish between the two?
Background I need to implement a URL whitelist to limit the number of pages that a javascript widget can be deployed on. The requesting domain is already limited for an account, but I now want to restrict each account to a list of up to 7 paths. Theres a couple of layers I can think of / combine, but none of them alone...
I have a REST API in development were some resources are user related, and users need to authenticate to access those resources. It's tempting to take a shortcut and replace an identifier of: /profile/[user_id]/ with /profile/ considering that the user_id is known based on authentication data. In such case the /profi...
Let say I own a resturant that makes a pie. I want to cut this pie according to the input parsed from the file. That hold the key to the information on how the Pie is to be cut. I use CircleDividerParser class to parse the file.txt. file format: pie_cuttin_style_name = is key for searching it back radius = radius or p...
I have an AR and I can't figure out the best way to create/edit some of the complex aggregates contained in it. These aggregates have many parameters so I decided within the domain model to use Value Objects instead of primitive types. public class Load : AggregateRoot { public virtual string Name { get; protected ...
Say, I make an ajax request to a server from a page, something like "show more articles". Is there a common agreement on the format or rather structure in which a result should be returned? Something like this: {articles: [{id: ..., title: ..., created_by: ...}, {id: ..., title: ..., created_by: ...}, {id: ..., title: ...
I understand that I should consult a lawyer for this if this is is an important matter, but since it is not, I am just going to ask here. What are the legal implications if one distribute their work with only the clause: This work is licensed under GNU GPL. I have stumbled upon one such work. Since there is no "single...
Imagine this scenario: You are relatively new to a very large codebase for a GUI application. A bug report comes in. Since it is a GUI, the report is not expressed in terms relating to functions or exceptions raised from the code, instead it has screenshots of the GUI, descriptions, maybe a video. What strategies do yo...
I would like my project to adhere to the SOLID principles and write clean code, but I am still not very clear on when I should separate from the service layer. I have a Web Api 2.0 Controller called ParkingController which has the following method: public List<Week> GetParkingPlaces(DateTime date) { date = DateTim...
I am not trying to launch a Microservices vs SOA debate but I find hard to understand the following statement: "Microservices architecture does not support contract decoupling, whereas contract decoupling is one of the primary capabilities offered within a SOA" As I know REST contracts can be specified via Open API (ex...
Working at a company that loads all javascript at the end of the page load. This means I can't do $(document).ready() on my page, because jquery isn't loaded (the scripts are injected into the footer by some template or other). I'm stumped on how to address this. I have one page where I want to run a function that is i...
I'm trying to refactor a 2.5KLOC god-class (with about 68 data members and 62 member functions) that performs a wide variety of text formatting and layout operations. After a careful analysis based on: Which member function reference which data members and, The logical formatting sub-tasks I've partitioned the data ...
Unsure if the question is too broad, or opinion based. Though will ask anyway. I'm currency reading through Microsofts "Architecture eBook", found https://www.microsoft.com/net/learn/architecture. It has a supporting solution that is found on Github, https://github.com/dotnet-architecture/eShopOnContainers The sample a...
Here is an example implementation using Onion architecture: https://www.codeproject.com/Articles/1028481/Understanding-Onion-Architecture The webpage suggests a solution structure of: Domain - Solution Folder Domain.Entities - Class Library Project Domain.Interfaces - Class Library Project Service Interfaces - Solutio...
I'm building a wpf application which implements the following features: Take user input and read data from databases perform some calculations on it Showcase it to the user in multiple types of views and write changes back to db Proposed architecture: Database -> Entity Framework -> Repository -> Business Logic -> Da...
I received a big old fashioned requirements document. But my team is working using agile methods (a combination of scrum and kanban), so what we need is user stories. Is there some guidance for "translating" requirements into user stories? Obviously I don't want to start from scratch, as someone did good work to compil...
How small can a scrum team before it's no longer effective? Are there diminishing returns or hard limits on team size before you should abandon scrum?
I recently finished a project which contains more than 30 different pages/features. Each one with some CRUD and more subpages. Each page is totally different from another in purpose. All of it was made using ASP.NET MVC Core and some Ajax for querying some rendered views. Today I'm starting a new project that will be s...
I have several subsystem managers for various uses, for example: AudioManager CollisionManager InputManager etc. At first I wanted them to be all singletons, however now want to make the architecture a little bit cleaner. The main idea is to use only one big singleton (for example System) and it will contain all of th...
Coming to JavaScript from C# and C/C++ world, I'm used to decorating my private members with underscore. But a couple of JS devs I know have told me it's not common in JS world, and my code looks "weird" to them. I got intrigued and interviewed about 4-5 more JS devs and they all confirmed. Just to be clear, her's my c...
My application's model includes a number of entities that share many common properties, and are operated on by many of the same classes. If I was using an ORM, I'd define an abstract class with the common properties, setup class table inheritance for persistence, and have the classes that operate on all these entity ...
I have seen proponents of isolating data management and storage into microservices in a way that each microservice has its own data store (at least in a logical sense). Hence, joins and aggregations are made in the application layer. Why is this better than using, for example, a relational database where different micr...
I have the vague sense that programming now is a more high-status job than it was in previous decades; that it used to be looked upon as more rote, manual work. The sense is that, while today fresh Stanford grads flock to Google, thirty years ago Ivy League graduates were seen as better suited to manage programmers, no...
When building a Service Oriented Architecture (because the services will be used by automated systems or other consumers), how can I go about creating a simple, dynamic form-based web frontend for said services. As an example: A service needs 10 input values and returns a set of matching elements. To get to the values ...
How do I go about unit testing a private method that gets called in a loop like this one: // Calls MethodToUnitTest in a loop public static string Generate(params int[] values) { if (values.Any(i => i == 0)) // return empty string if any value contains 0 return ""; return strin...
I've asked this question myself for a thousand times now but I can't seem to find the correct answer. I'd like to separate a part of reusable code from the actual project however both the project and the reusable code part need each other. Let's give an example. I've setup a working CMS which has it's own git repositor...
This question is a clearer version of a question I posted on SO. I have a C++ Planner object with a method that computes a Route from a start point to a destination point. Planner is the owner of the computed Route pointer. Now, I have a second method (call it TestRoute), that takes the route object and tells if the de...
I have a C++ interface for video provider. Frames can be rotated (Portrait/Landscape) as a result of platform-specific functions. enum class EFrameOrientation { KUp, // default orientation KDown, KLeft, KRight }; Class gives the user info about orientation: virtual EFrameOrientation getFrameOrientatio...
We have a PHP based web application with a lot of project data. All of our customers have a dedicated instance of this application. Now we want to allow a very limited access to some third party users to access some data (read only). We want to create a new dedicated app for these read only users and allow each our cu...
The insurance company for which I work has had an ongoing software development project for the last several years, which has been split between multiple lines. software package: The suite we are using is broken up between several major packages, they are independent, but tied to each other, each with it's own domain: ...
I'm having some concerns about injecting my Entity Framework DbContext into my MVC controller. Below is a sample of my code. The way I designed this is so that I can better unit test my Controller code by injecting a real or mock DbContext. What I'm currently planning to do is using Unity and the IDbEntities interface...
Uncle Bob Martin frames the Single Responsibility Principle as "A class should have only one reason to change." I wonder, is there any name for a converse principle like: "a single reason to change should impact only one class"? In other words, you shouldn't have to make changes scattered across multiple functions, c...
Is there a pattern to handle the following scenario : I have a set of business transactions captured and stored in a mongoDB database that need to be executed at a future date that is also stored in the database. I'd like to build a process that will trigger regularly, scan the database and pick up the transactions th...
So in my mind, the usual users table that we are used to having, is going to split in two: whatever data is within the Identity Provider the domain specific data (user.facialHairStyle) is going to still stay in the user table. One difference is that it will be missing the regular properties covered by the Identity Pr...
I am new to DDD and struggling to find the correct way to solve a simple problem. Let's say I have am working on a project where I am processing credit cards using a third party API that has the ability hit a credit card terminal or use saved credit cards to process a payment. I have a payment entity, a request entity...
I have a situation where I want to track page views, click events, etc. in a time series database but am having scalability issues in the case where I want to retrieve aggregated groups of data that has very high cardinality. The problems I'm trying to solve are: What are the top N referrers within a given time range?...
I'm sure this has been asked multiple times but for me it's more specific as I know what I'm building. I wrongly posted this to stack-overflow (now removed) so I'm hoping this is the best place to ask. I'd like your help deciding how I should move forward database wise for the platform I'm building. I'm currently using...
I am in a software engineering class and I need to pick a design pattern to use for a 'feature'... I have two features, and one of them is to have a feature where a user can enter a zip code and time span of days (up to 7). A collection with weather ratings for each day is generated (say a vector of ints, with 1 being ...
Is it desirable (from an architectural standpoint) to have more than one Presenter communicating with a View? In my particular situation I have one presenter communicating with multiple views, and each of those views have their own presenter. In other words, each view has two presenters. It would be feasible to use inh...
If an app allows its users to signup using multiple platforms like facebook, google, twitter and also use local signup, How should the users Table be defined in the database? Should all users be stored in a single Users table in the database irrespective of their signup mode. Or is it better to breakdown and create a s...
how should the MVP pattern handle views created at runtime ? for example There is a mainView (that has a model and presenter) that needs to display a list, each item in the list is represented by it's own view, listItemView (which also has it's own model and presenter). the listItemViews need to be created at run time,...
BACKGROUND I am trying to design a micro-services based SaaS application, where each micro-service would be packaged into their specific Docker container. I also have a CLI tool (a binary file) that functions as a Swiss knife (i.e. does more than one thing) and there are a few micro-services that would want to use the ...
I am researching Microsoft entity framework and I am confused about when it should or should not be used. I am interested in the relationship between entity framework and product management methodologies, design methodologies and .net web development frameworks. The information I am finding online isn't enough. Does an...
Trying to understand concurrency with CQRS, I came across that question: https://softwareengineering.stackexchange.com/a/349575/286881 But there is something I don't understand when it is said that: it do so by appending the new events to the Event stream if and only if the version of the Aggregate is still the one ...
I’m a bit confused about this type of UML diagram which I’ve seen used in non-consistent ways. Component diagrams often represent some sort of architecture level snapshot of the application in development, they are very close to deployment diagrams, just a bit more abstract (i.e. without the node details). Some people...
This is a sweet spot thing for me. But I am not sure what rules others apply to the challenge. In this codebase I have many large types. Mostly types called *Service. Large types are cool. But I tend to like a smaller surface of interaction. Let's say we a Configuration type. This type has Activate, Save, Publish, Reve...
I have a hypothetical C++ code containing these two classes: Master: it's big, does a lot of things and is meant to have only one instance; Slave: quite the opposite. It can also do a lot of things, but it's small, and has many instances. Every slave needs access to the master, so it is injected through the construct...
Does npm allow you to publish earlier versions of a package? The only documentation I could find was on npm’s site: [npm-publish] Fails if the package name and version combination already exists in the specified registry. Once a package is published with a given name and version, that specific name and version combina...
What criteria do you use to decide whether execute a test on target or on host in a sprint? We have integration testing using a server for an embedded system project. We are starting to learn and researching on how to apply integration testing and I do not know how exactly decide. What are the scenarios for each appro...
This question came up today while discussing with a colleague about the 'create account' page for the website we're working on. My colleague's opinion is that we should make the registration as quick and seamless as possible, therefore we should just ask the user for his email and take care of the rest. I agree with th...
The app should allow users to signup using both local login and also from other platforms like facebook or google. The Users table has a required password field. If an Users signup using the local registration form he/she will fill in the required password field. But what if the User opts to use facebook to signup to t...
As part of validation, we perform name similarity check and allow only if the threshold is reached. I got some help from StackOverflow regarding the implementation and finally implemented JaroWinkler algorithm. Recently we observed that it is not reliable for long names and some false names also cross the threshold. I ...
I am trying to understand if C++ types are classes, like in Python for example. Otherwise what datatype is the type itself? E.g. int a = 10 what is int? Is just a token label used by the compiler to decided the space to allocate to the variable?
PROBLEM STATEMENT: Print the items that differ between the following two left and right sorted data sets: A A B C C D D E G F H EOF EOF The proposed solution should print: B E F G H Here is my data-driven implementation of this algorithm in pseudo-code. It appears to produce the de...
I'm developing a JavaScript UI client and my back-end developer refuses to pass me the data in a form that I don't have to transform afterwards. So, I'm currently working on a mapper that contains a lot of knowledge that will only lead to problems later on. In addition, the objects we receive are sometimes very deep an...
I have a class with a Name property, where the name is set by the end-user. In order to ensure compatibility with the rest of the environment, and to avoid rejecting a lot of inputs, some processing of the name is done automatically: public string Name { get { return _Name; } set { if (value == null) ...
We are contracting with a group to create some cloud services for us, and would like to write a requirement for them stating that a particular API call will provide results within X seconds. They are pushing back, saying such a requirement can't be guaranteed because the problem may be in the Internet connection and n...
I have some classes being serialized via frugal (this is an open source extension of Thrift). The primary reason this is relevant is that the serialization process is out of my control and needs to support multiple languages, so I cannot easily modify it. Imagine my classes look like: class response_component: valu...
I have developed an embedded product, which has a dot-matrix LCD, some buttons, bluetooth and WiFi functions. To me, the functions are rather complicated as one of the operating mode can interact or change other modes. And one mode can be actived by different ways, such as by the graphical user interface, Bluetooth or ...
(Apologies if some of my terminology is off, I have not seen much on this subject and am using be best terms I could come up with) Should data model logic live in the database schema? I am making a distinction here between business logic and data model logic. By data model logic I mean things specifically to do with da...
I have recently come across the idea of persistence ignorance, the idea that your domain model should be ignorant of the persistence layer of the application, and that got me thinking. I have been doing my best to keep different parts of the application loosely coupled, wrapping things like the ORM in interfaces so tha...
I'm planning to set up a client side git hook to force a commit to fail if any file in the commit contains the text "donotcommit". Is it possible to hook the execution of "git add", such that I can run a shell script at the time files are added, and permit or deny the add based on the exit status of the shell script.
I am troubled lately about the use of abstract classes. Sometimes an abstract class is created in advance and work as a template of how the derived classes would work. That means, more or less, that they provide some high level functionality but leaves out certain details to be implemented by derived classes. The abst...
I have two files : file1 : contains the value of the variable. file2 : contains collection of steps (subset of collection of file1 ) to follow. Step contains the set of instructions. - > file1.txt x1 = 34 x2 = 33 x3 = 90 ... x12 = 101 x14 = 233 .. x41 = 901 ... ...
I am writing a bot for Matrix using Ruby which allows users to subscribe to RSS feeds and when a new item shows up on the feed it gets sent to the room. The problem I have come up against is how do I get the program to sit and wait for new commands from users while also fetching feeds every 2 minutes? Some solutions I ...
Is it bad practice to use an incrementing primary key to refer to a real world field, such as an id number for an employee? Suppose that 1 is a valid id number for an employee. I am really tempted to use the incrementing primary key as the id number. But I might have ignored some potential problems it might cause. I've...
We are trying to determine the best way to authorise users in a microservice architecture, while ensuring microservices have limited permissions. Our architecture uses a central authorisation service to handle issuing of JWT tokens. We have the following requirements: Users should be limited to perform certain roles. ...
/users?role=admin, where admin is probably some kind of slug vs /users?role=2, where 2 refers to our internal roles dictionary table primary key. Which of the two is prefered?
In the semi-functional Java world, I see development methodologies that make heavy use of dependency injection and mocking frameworks to achieve high levels of unit test coverage. In order to achieve thread safety, behavior is encapsulated in objects which have no state and no side effects (except maybe writing to the ...
Context In my application I use the MVVM pattern. I'll have a ViewModel that can contains information of a student. This viewmodel is used to communicate between my view and model. I use ASP.net core MVC whit vue.js. My project contains out of the following elements: Views (UI) Controller API (responsible for respondi...
I'm currently using the wxPython library to construct a GUI. One interesting aspect of the library I've noticed is that it uses CamelCase notation to write method names, as opposed to the snake_case notation that PEP 8 recommends*. This isn't to much of a surprise however since wxPython is basically a wrapper around th...
I have a finite directed graph (of several weakly connected components). Having two elements I need to check if there is a path from the first one to the second one. The easiest solution is to create the incidence matrix and then using it calculate the connectivity matrix (the further is obvious). But I feel it is not ...
Let's say you have a multiplayer game where different player threads are constantly updating the same game state. How do you best update this state without suffering locking bottlenecks or corrupting the game state? I'm thinking non-blocking data structures like AtomicInteger, AtomicReference, etc. Would that be correc...
After a user invites their contacts from within my app, I want to send the first user a notification "so and so installed the app, you can now connect with them." So when a user invites someone, I send the invitee a link to my landing page, with a unique ID param in the url. Then I know which user got them this far. ...
Modern Windows 10 can run binaries that were compiled on 20 years ago for Windows 95 or NT4, however I imagine that the libraries that the code is calling would have changed massively since then. I know that it is possible to maintain binary compatibility while further developing a library (in C++ for example by not ad...
In Germany we use the expression "Clean Code" (loanword) to describe source code that is well written. Lately I came to translate "Clean Code" literally to german and had an idea that in english there could be several meanings: Clean Code: well written source code Clean Code: a set of rules (code) to keep everything c...
Recently I got a chance to contribute to a project. The project is very vast and contains many independent modules like brand section, store section, user section etc. All these modules contain respective models that contains business logic. Admin has all capabilities like adding a brand to a parent organisation. Creat...
I am developing a bot which I need to start and stop at will. I have 2 buttons in my form, StartButton and StopButton which change the state. The Bot has 4 possible states: starting, started, stopping, and stopped. I am now trying to manage the state transitions. So far I have 4 boolean variables, one for each state. B...
I was reading about composition and I'm wondering if it violates the O in SOLID, and what should be done to fix the situation. In the article the author uses a Fruit and an Apple. At the end the writer admits it would be better as a "is-a" relationship rather than "has-a". Suppose however, you decided to stick with com...
I have been asked to come up with a design for streaming data to the cloud. I have a closed system on a local server. I need to stream recently registered customers or updated customer records on the local DB to a cloud-based CRM and make data available to serve the firm's website. I came up with following design flow:...
We need to organize a way to exchange messages between servers in multiple data centers. Messages are not critical. We just need to be able to send messages from any servers in any data centers to any other servers in any data centers. We are thinking to use Kafka as a message broker for this use case, but we are not s...
I've been given the task to design a system that has a product's price have different amounts of different taxes based on different factors. For example in the US you would get a few - one based on region and another on state and such, while in the EU you get VAT. I'm trying to figure out a non-hardcoded way of differe...
I'm trying to start adding some tests to my code. Please take it easy on me cause i'm still new to this stuffs. As far as i understand dependency inversion, all the dependencies will be place inside a class constructor and they must be an Interface so that we can easily fake it. By following this rule i may end up havi...
What are general guidelines or rules of thumb for when to use a domain-speciifc object vs a plain String or number? Examples: Age class vs Integer? FirstName class vs String? UniqueID vs String PhoneNumber class vs String vs Long? DomainName class vs String? I think most OOP practitioners would definitely say specifi...
I am implementing some kind of web application that has basic social network functionality and browser text game. I do it basically for myself only in order to learn couple of things. (like using websockets and full-stack development) So the architecture I came up with looks like this Generally my web pages consist of...
We have been tasked with implementing a dashboard containing multiple widgets. The dashboard itself and all widgets need to access various secured APIs. Our authorisation protocol is OpenID. Currently, the dashboard requests an access_token with all scopes required by all widgets. Widgets use this shared access_token t...
I've a bunch of classes where one is Abstract class. I draw few derived class from that Abstract base class. For example, class IBase{ public: *register(): bool* *update(): bool* }; class Derived: public IBase{ // implement register () // implement update () }; class Derived2: public IBase{ // implement registe...
Context There is a modular C++ application. Each module provides an interface (an abstract class) which is used by other modules. There are no circular dependencies. The module interaction happens via direct method calls in one way, and via events (a variation of the observer pattern, similar to Qt's signals) in the ot...
I've noticed this correlation, but I'm not sure if it's just coincidence or if others have noticed this as well?
A bit of context: Earlier today I had to update some SQL code that another colleague of mine provided, and since it’s a pretty large script, it’s stored as a separate file (which is then read and executed at runtime). While doing this I accidentally reintroduced two bugs we had a few months back, namely: For whatever ...
I’m working in a project that is building a system to manage data (10-20 million records) collected by a research organization. One of the challenges is that even though the data is superficially similar across the organization (having reasonably similar set of fields), there are currently 20-30 different databases use...