instruction stringlengths 34 36.1k |
|---|
I am fairly new to implementing CQRS and Event Sourcing, while applying rules of domain driven design. Let's say I have an Order aggregate and inside it is a list of OrderLine entities. I'm using this model in the context of an event-sourced system (with CQRS) and so the state changes are mainly driven by events. Chang... |
I'm building a system using a document type database.
The system has users. I was told that in production it is best to avoid making outright deletes. I understand the convention is to either mark users as deleted or to transfer them to a deleted table in a RDBMS.
For document type databases what is the convention?
I ... |
I am working with an N-tier application, and I'm updating the Data Access Layer (DAL) to use a new ORM. As I'm updating the DAL I'm finding some issues with how we save objects to the database.
One question I have is should the DAL have a simple SaveObject(objectToSave) method that checks for it's existence in the dat... |
I am designing a RESTful API that has a set up like this:
/users - returns all users
/users/123 - returns user with the id 123
/users/123/comments - returns all comments for user 123
I am looking for the most correct way to return all comments for all users. Comments don't have their own ID or identifier and they don't... |
I'm a software developer recently in charge of entire project (project manager). The project I'm working on (with 6 other persons) is a complex Java-based application that's being developed for over 5 years. The entire time we were using SVN, without branching. Now, I would like to switch to Git as I do believe Git wil... |
In the context of creating an ecosystem, the graph below reveals information about it's behavior.
Dot : A node with the entity's name. There's a tree, grass, a fern, etc.
Blue arrow : A requirement. The tree requires grass and high altitude.
Red line : Cannot co-exist with. Grass cannot co-exist with stone.
This ma... |
There are a lot of functions that accomplish the same thing, but using Applicative vs Monad definitions.
Some examples are:
(<*>) vs ap
pure vs return
(*>) vs (>>)
traverse vs mapM
sequenceA vs sequence
liftA vs liftM
liftA2 vs liftM2
etc.
And for Alternative vs MonadPlus:
empty vs mzero
(<|>) vs mplus
In the scena... |
I realize this may be subjective, but I don't see any clear-cut place for asking questions on good software design principals. I'm sure there are some software patterns and anti-patterns I should be aware of here.
I'm not asking about UI/UX or how to code anything. I am asking what would be a good design pattern to fo... |
I have read Eric Evans book. I was under the impression that a Domain Model should not have dependencies injected (even repositories).
This statement is supported by questions like this: https://stackoverflow.com/questions/20035810/should-domain-objects-have-dependencies-injected-into-them, where the answerer says tha... |
I am running 10 instances of the same executable where each executable is accessing a different 1/10 chunk of the total data that needs to be processed on a Windows Server 2012 R2. (Intel(R) Xeon(R) 2.4GHz (2 processors), 64GB RAM)
My question is if the CPU hits 100% usage, are the 10 instances still being parallel pro... |
I'm not sure how to best approach this problem. I've got an object in my local database, for example this one:
{ title: "my-object", uploaded: false }
I convert this to a file, say my-object.txt and upload it to a server. Once it has been uploaded I set, locally, the field uploaded to true, so it will now become:
{ ti... |
I'm storing files as REST API resources, sending and receiving them as base64 strings, along with some other metadata. What's the best way to handle GET for the collection? (e.g GET .../api/files)
The standard response to GETting the collection (to my understanding) is to return the full contents of all resources, but ... |
Thanks Maven archetypes the barrier to start developing of services for new RESTful APIs is very straightforward - you can get more or less a project template and start filling in your code.
Now as I am new to Scala, is there some compatibility to use/integrate with Jersey in a similarly convenient way or is there a "S... |
I'm working on my final project for a course named Web Applications in ASP.NET.
Basically, it's a web application for shopkeepers to manage their clients' money accounts in their stores.
In order to open an account, the shopkeeper and the other person have to agree on the length of period for the account, the interest ... |
I have several services that implement an observer interface and one service that implements the corresponding observable interface.
I'm currently using unity together with Prism so I would prefer to keep this combination. My current solution is to inject the observable service in the observer services and let the obse... |
I am building this IoT device which should send data to an API.
I would use some "hardcoded" api key to access it, but on the other side I also have a front-end that uses JWT to access data.
What do you suggest? Maybe RPC instead?
|
I came to know about virtualenv and pyenv a while ago, and used them separately for a while. Recently, while investigating best practices and tools for Python development I found pyenv-virtualenv. I find it useful (it takes care of using the right method for creating the virtual environment depending on the Python vers... |
I am looking for algorithms to make single elimination and double elimination brackets.
The first step was figuring out the seeding algorithm, byes included, which I found in several places in SO: here (where byes can be introduced simply b replacing the last n excess teams and shifting the seed positions n times) and ... |
That question bothers me for years, so, imagine some code that in 99% looks like a non-sequential (order does not matter) list of some specific objects method calls - and those calls are independent one from each other, like:
conf.addCollection(...);
conf.addRule(...);
conf.registerEvent(...);
I can implement method c... |
I am new to Assembly, and based on my understanding, an ISA (Instruction Set Architecture) specifies what instructions are available for a particular CPU.
But does an ISA also specify what registers are available in the CPU?
|
I encountered a scenario where I cannot decide on which is the best (or worst) naming strategy. The context is the following: a bracket (as in a tournament) made up of nodes, where is node is made up of two abstract elements which can be a seeded player, a bye, or a reference to another node.
We clearly see a hierarchy... |
The following image shows where the sections of a process are laid out in the process's virtual address space:
You can see that there is only one stack section (since this process only has one thread I assume).
But what if this process has another thread, where will the stack for this second thread be located? will it... |
Use-case:
As part of an Airline Application I am building - I am developing a set of (RESTful) API's each for Flights, Lounges, Loyalty etc. There are some common methods which should be accessible from all the API's.
Current Implementation:
At present, we have deployed these as separate war files on our Tomcat servers... |
Currently we are slowly replacing a custom made ORM framework with Entity Framework (EF). One of the steps is to make sure we can update and insert records through database views with EF, just like we are doing with the current ORM. The views provide security by filtering on accessible records for the user, preventing ... |
I have been wondering about this for a while.
What applications is programs like visual studio programmed in? But also, where is operating systems like android, ios and windows written in?
I just find it hard to imagine how developer environments are/were made, when they didn't exist! Get me right, I know that other d... |
The C# docs have a page on indexers, which appears to use "indexer" to refer to the construct required to enable instances of a class to be accessed via square bracket notation.
Indexers allow instances of a class or struct to be indexed just like arrays.
// Define the indexer to allow client code to use [] notation.... |
I've read a bunch of online resources about this, but wondering if there's a better way to test an idea for a product before spending countless weeks building the darn thing?
I've read about things like Validate.tech that test product ideas in under a day, but it seems wrong to lure people in with a landing page and no... |
I am implementing a token-based authentication system for a REST API using a short-lived access token and a long-lived refresh token. This is an abstract overview of the relevant API endpoints (HTTPS is enforced for all endpoints):
Endpoints:
POST /register/
POST /login/
POST /logout/
POST /password/change/
Implement... |
Suppose a function deserializes and validates some object from string and returns the result as Either<string, MyObject>. So an object is either completely deserialized and valid or some kind of error happened. Now suppose if even only some of the fields are valid the deserialization function should return them. How th... |
I have seen this done in some applications, and it's not clear to me that this is ok or if it's a separation of powers violation.
|
I haven't developed any production applications for the Linux OS. There are a couple of things that bother me:
As I understand different distros have different set of libraries
Debian vs RPM packages
Different UI - Gnome vs KDE
What do people do to handle all of these differences? Is there a way to abstract away from... |
Background
Based on Item 4 in Scott Mayers Effective C++, when appropriate, it can be good practice to initialize all member properties of custom types via the member initialization list (in same order as their declarations), even for non-POD types with accessible default CTOR:s.
[Excerpt From: Scott Meyers. “Effectiv... |
In a calendar app adopting a MVC architecture, the Model consists of objects representing the days of the week.
The View consists of labels displaying the days as strings or integers, depending on the user interaction.
Therefore I need some logic in my app for the mapping from strings to integers, and viceversa. Is thi... |
I'm building my first ever web-based game in PHP/MySQL and I'am having difficulty conceptualising how to deal with saved game data instances. It's a football manager game with tables like...
players, managers, matches, results, injuries, stadiums, leagues etc
My problem is that some of those tables need to hold comple... |
I've got one requirement that is:
When one employee starts working on a project and when he finishes working on it he must inform the system so that it can generate a report afterwards of how much hours a certain project required.
The requirement itself is simple, I just want to see if I'm thinking right about it. My... |
I apologize in advance if this is a dumb question
As an amateur at programming who has been learning the basics of Java, I have started to wonder how the visual side of applications is created.
Basically I am wondering if there is a sort of equivalent to HTML/CSS for programs.
|
I am refactoring the code for a music player I wrote in Java/JavaFX.
I have a few key objects which are accessed throughout the program by various other classes. I think there will be four or five by the time I finish moving everything around. There is only ever one instance of these objects instantiated for the life ... |
I'm developing an API that allows consumers to create a resource. For example, a "user" resource can somewhat be created via POST and this payload (trying to use JSON API, btw):
POST /users HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "users",
"attribut... |
Since bundling and minification is all about optimization and making pages load faster, it appears to me that it would be logical to create one bundle for scripts and one bundle for styles per view basis, so that to load all scripts and styles a browser will need to make 2 requests at most. So let's say I have a _Layou... |
I have a class which contains various fields and they could be accessed with the help of getters and setters like the following
public class Student {
private String name;
private int age;
private int sibblingsCount;
private String elderSibblingName;
private String youngerSibblingName;
public ... |
I'm looking to improve the readability of a lengthy C++ function. This function contains a number (> a dozen) variables that are used throughout. The main logic of the code is a long list of condition checks (sometimes nested, sometimes with loops) followed by various actions. Because of the lengthy number of lines det... |
I am new to Scrum and I have been reading the book of Kenneth entitled "Essential Scrum" and I have some doubts regarding the poker planning.
I understand the mechanics of the game, and for what I see the number that is in each card could represent the "approximate" number of ideal days that a user story should take; i... |
Is it ok to add deferred assertions like this
var actualKittens = actualKittens.Select(kitten => {
Assert.IsСute(kitten);
return kitten
});
Why? So I can iterate just once even with statements expecting materialized collection for example:
CollectionAssert.AreEquivalent(expectedKittens, actualKittens.ToList())... |
I recently had a discussion where we argued if it is a good idea to make everything const if possible.
The argument did go like that: If I expose an internal part of the class by returning a non-const reference to it, I should not make that getter const even if it is possible.
For example:
class Foo
{
std::un... |
At work, a 3-layer-architecture is the go to whenever a web application is needed.
I don't mind this, but many of the applications we start, do not seem to have an initial need for this. These applications are pretty much just a user interface to the database. This results in a ton of business logic that just sends th... |
When developing a many-to-many relation I create 3 entities: Car, Part and a CarPart which contains the lists of both entities.
On the client-side of the application I want to be able to directly access all the Parts of the Car without the need to use the many-to-many objects, to accomplish this I use the AutoMapper li... |
Currently I'm using logger in my project in the following way :
private static final Logger LOGGER;
static{
LOGGER = logger.getLogger();
}
I got a code review for using static block to initialize the logger variable. I was told to intialize the logger variable in the declaration statement itself.
private static fin... |
I am starting a new project on which I am making a reservation system as a PHP/ MySQL web application.
Basic functionality should be:
admin can add default appointments (several pro day)
users can attend the appointments (with a by admin set max).
Currently I'm figuring out how to make the database structure.
I was thi... |
This looks like another network's question, but I think it fits better on here rather than StackOverflow, since it's not gonna have one basic answer.
We are in the context of iOS development, I'm trying to simplify the use of UITextfield. More specifically, let's say this is an "Amount" textfield when wiring money in a... |
(Note: I'm not sure how to frame the question properly, so please feel free to edit it or comment about how I can improve it.)
I guess this question, while covering a fairly wide scope, is pretty limited to statically typed (object-oriented) languages (I'm using Java in particular) for implementing CQRS and Event Sourc... |
You have a server that sends the client data. A JSON object.
{"name": "folder1", size: "2406"}
The client updates it's data:
data = newData
And the client is updated. Reactive frontend coding as usual.
However the client needs to keep it's own state. It also has isOpen for that folder. So it's object looks like ... |
In a Java/Spring MVC/Hibernate application I have model objects that contain references to other model objects where the database has foreign keys. So for example, I might have:
@Entity
@Table(name="branches")
public class Branch {
@Id
@GeneratedValue
@Column
private int id;
@Column
private St... |
Note, presently have no experience composing or modifying C++ code, which the code that will need to compose or modify is written in.
Specifically, window.speechSynthesis.speak() does not currently provide an option to return the audio generated by the function call as a Blob, ArrayBuffer or AudioBuffer at either Chrom... |
I am building a software where UI, Business Layer and Data Access Layer are tightly coupled in a single tier.
I want to decouple layers, because a change in the database can cause the change in my presentation layer.
Is it a good practice to always decouple the entity classes from the presentation layer by implement... |
When I start a new project, I tend to look at other people's source code who have implemented the same project. This gives me an idea on how the overall project is supposed to be created and the basic flow and the implementation logic of the program.
The problem with this approach, I feel, is that I am not thinking fo... |
I see code like this sometimes (mixed PHP and JS in this case, but could be any server-side language):
<script>
var data = <?php echo $bigDataStructure ?>;
// then lots more pure js with no php mixed in which can access the data variable
</script>
Which seems like an appropriate way to pass data from a server-side... |
I am studying Domain Driven Design and was introduced to the concept of Onion Architecture, which uses the terms of Core, Domain, API, and Infrastructure.
I am from Java background and am familiar with and typical project structure (legacy MVC pattern) configuration, model (both value and entity), repository, service,... |
I have been familiarizing myself with Googles Security Design Whitepaper. As far as I can understand, and with respect to a Micro-services architecture, from the Access Management of End User Data section, Googles authentication scheme works as follows:
User authenticates with the "Central User Identity Service" and i... |
I have just a basic site with registration. With all other data, it stores the registration date in MySQL. If I'm in USA or in Canada, and I register at 2017-03-07 (Y-d-m), in MySQL it's 2017-04-07 because we have 10 hours time difference. So if I want to display the date in my site, it says that it's happening in futu... |
I'm trying to build a project using the clean architecture, as described here. I found a great article on how to do this in Go.
The example is a very simple one, and the author puts their code into packages named based on the layer they are in. I like Uncle Bob's idea that an application's architecture should clearly c... |
Design 1: For a web application. In the past, if I insert a record/data in UI, I will save this new data to the database, then the UI will be reloaded (like clicking browser refresh icon), but this UI reloaded action will query the database again to fetch all data into UI. I know this will slow the web application perf... |
I write code while traveling, and I almost always use cafe (but sometimes on a room in AirBnB).
However, the problem is that too often the Wi-Fi at cafe is awful, either too unstable to keep connecting, or too often to get a server error. In many times I even could not connect to the Wi-Fi.
Another painstaking, yet mo... |
Note: When I used "complex" in the title, I mean that the expression has many operators and operands. Not that the expression itself is complex.
I've recently been working on a simple compiler to x86-64 assembly. I've finished the compiler's main front end - the lexer and parser - and am now able to generate an Abstra... |
I recently had a discussion with a coworker about network timeouts. This person wanted to have 1 second timeouts because they believe the optimal user experience is one where the user doesn't have to wait long before knowing if something fails. However, at scale 1 second is far too short to cover the range of network c... |
In an android project, I don't see how the following architecture can be considered MVC.
The team said:
Android apps are fundamentally MVC
the Controller is the Android Activity.
the MVC View is the Android View.
This does not look like a correct MVC architecture to me,
so I disagreed because:
they handle input ev... |
My current .NET project looks like below:
Solution (.sln)
--BusinessProject A (.proj)
--BusinessProject B (.proj)
--DataLayer (.proj)
--A separate project calling ExternalService 1 (folder)
--A separate project calling ExternalService 2 (folder)
--A separate project calling ExternalService 3 (folder)
--A sep... |
System model has Workflow container class, instances of which may contain subclasses of the Node class, specialized for different behaviors (eg, Initial, Intermediate1, Intermediate2, Final). There are other classes Node classes use as a context, eg, User and Content (which can have Workflows of different kinds), but t... |
I have an API endpoint that returns some statistics. Currently the response looks like:
Option 1:
{
"stats": [
{
"name": "some-stats-key1",
"value": 10
},
{
"name": "some-stats-key2",
"val... |
I am using dependency injection on a project to inject services using Unity dependency injection
private async Task<T> GetResult<T>(HttpResponseMessage response)
{
if (typeof(T) == typeof(byte[]))
{
return await(response.Content.ReadAsByteArrayAsync() as Task<T>);
}
else ... |
Hello fellow Software engineers,
I've been doing a lot of research on microservices these last few days and have come across a great deal of articles and videos explaining the concept, programming models and things alike.
Now I am tasked with designing a platform that offers microservices and I've run into a snag. I ha... |
I need to build a small website for my ops team that will have a series of iframes pointing to a couple of Kibana graphics. The website will have, lets say, 4 links, each pointing to a a specific website page with X iframes in each, with different iframe URLs.
The thing is, I don't want to statically type in the URLs a... |
I know that McCabe basis path testing ensures that all linearly independent paths are tested, making sure that all code branches were covered in an effective manner.
But nowadays, I doubt anybody designs tests from the source so I am thinking whether this can be used on a higher level, e.g. general flow of an applicati... |
Background
In a typical Model-View-Controller application using a database to store the model, the consensus seems to be that lookup tables are a solid design decision for enumerated types. Although some DBMSs support ENUM types--a more straightforward solution--people cite disadvantages like "data not being treated as... |
Please see the code below, which I took from Jimmy Bogards wicked domain models:
public Offer AssignOffer(OfferType offerType, IOfferValueCalculator valueCalculator)
{
DateTime dateExpiring = offerType.CalculateExpirationDate();
int value = valueCalculator.CalculateValue(this, offerType)... |
What's the difference between "to" and "as" method name prefixes like
toList(),
asList(),
etc...
When to use which when designing a method?
|
In order to have make sure all code eventually goes through pull request code review, we've started creating branches for features and bug branches off of develop following the git-flow style.
The only problem is that once a bug is found in a release branch, we often have to make a branch off of the release branch in o... |
How do I construct a system that has all of the following:
Using pure functions with immutable objects.
Only pass into a function data that the function it needs, no more (i.e. no big application state object)
Avoid having too many arguments to functions.
Avoid having to construct new objects just for the purpose of p... |
I don't know which methods should be public, because I have the test methods which require a node and a node is something which no one must know about.
public static class Node<K, V> //nested static class of AVLTree
public class AVLTree<K extends Comparable, V>
public void insert(K k, V v)
private Node insert(Nod... |
I'm using an Java Servlet (with embedded Jetty, no Spring, no frameworks) and I'm adding asynchronous processing and caching to it. The exact implementation is irrelevant to this question and it's not very Java-specific. My problem is the overall code structure, which before the additions looks like this pseudocode
voi... |
So I've gone through a few tutorials on writing .NET Core MVC Web apps. I think I've understood the flow from routing a request to the controller (with the EF-dbcontext injected into it) manipulating the dbSet model and onward to the view returning a response to the user.
I've been writing a little personal app to und... |
In the title, with namespace-related elements, I refer to Enums, Delegates and other elements that do not belong to a single class, but to the whole namespace, or application.
I know that I can cram these into the namespace just about anywhere, for example, if I use WPF, I usually put them into App.xaml.cs, so that I a... |
I have data for a certain domain distributed between a microservice and a legacy database. I have a search which spans fields on both legacy and microservice database. Previously (before microservice split), it was done with 1 sql query. Now I need a REST call and a query to legacy database to serve this search functio... |
We are a small shop and focus on web development. We have a website that users need to login.
I want to outsource the "app" development by getting someone to build the app and packages for android and ios - but basically our website will be the application.
We've done a test that works fine, but the user lands on the ... |
Agile requires the correct level of documentation, not too much or little, no "good luck" statements (I can't remember the SO question that used this.)
So if you are writing User stories and the like, how do you start out in the initial negotiations? You don't just write a contract or statement or work that says, "Bui... |
All of the enterprise projects I work on seem to follow the same pattern.
A request is issued to the server (from a client or Api)
The server side loads some data from a database
Modifies the data in some way
Commits the changes to the database
E.g.
//Client after user click cancel on the order screen
_apiClient.... |
In Think Python 2e "class" is defined as "A programmer-defined type. A class definition creates a new class object."
But isn't a built-in type considered a class too?
Using Python 3.4.0, the following code:
class File:
"""Represents a computer file."""
...
print(type(str))
print(type(File))
print(type("Mahmud"... |
I came across it in this article:
You call a method and pass it a parameter that doesn’t affect its control flow.
This is still coupling, but we’re starting to reach the kind that
isn’t so bad. Sometimes you need parameters! If you wanted to remove
all coupling you wouldn’t be able to pass data between objects at ... |
Most of the groundwork for coroutines occurred in the 60s/70s and then stopped in favor of alternatives(e.g., threads)
Is there any substance to the renewed interest in coroutines that has been occurring in python and other languages?
|
In my current software engineering course, my team is working on a library management system that is essentially a command-line/REPL environment with a half dozen commands, e.g. checkout, search, etc. We've elected to use the command pattern for this, so each command will be represented as a class. Now, there's the que... |
Alright....so this is driving me nuts as I'm trying to encourage the team to write more tests yet here I am unable to determine whether the following example is considered an integration or a functional test case.
Consider the following:
We have a simple web application which routes/exposes a number of JSON feeds. ... |
I have asked a similar question before, but I still struggle to 'get' this.
I have a bounded context that is UserManagement which contains all the details about User, UserId etc. This is separated as a context as it is useable in two separate applications.
I have another bounded context that stores all the reusable cod... |
I want to tag the values of variables with a "quality" attribute that can be changed dynamically during my programs execution. My first thought was to abuse the standard attribute functionality by tagging the value with my custom quality attribute. EG
[QualityAttribute(Quality.Bad)]
int value = 0;
...
value = 1;
(** s... |
I am currently working on a Web Application. One of the objectives is to use the MVP (Model View Presentation) Design Pattern. We would like to use WebSockets to communicate between client and the server.
My question is: Do I have to put the code for WebSocket handling in the Presentation, or would it be better to put ... |
I have just started to study about computer systems and I came across this line. How can the difference in the contexts in which we view data objects make this happen?
Bytes store numbers, now that number represents something, a symbol or a character or something else so how can the same sequence of bytes represent dif... |
I have a Mandelbrot Set explorer project that I have hosted on GitHub. I used it to learn how to generate the Mandelbrot set, and to get more experience with using the Java ExecutorService. It works great, but I've just been tacking on new pieces as I go along, and it's becoming a mess. It's already broken twice after ... |
I'm a Network Engineer and I'm learning software developing in my spare time. I have some doubts about some OOP concepts. I'm trying to get an understanding of what is the difference when these terms and phrases are used.
When one is asked to instantiate a class, is this another way of saying create an object for that... |
Let's start with a loose definition of 'marker interface' (please correct me or dispute this if you disagree):
If applied to a type, a marker interface doesn't provide any contract
of methods to implement for that type. A marker interface gives
semantic meaning.
So, OK, that's fine. However giving something a mea... |
What are some best practices for writing memory-efficient (for the lowest peak memory usage) CSS? I realize this is a broad question, so I have broken it down into two main categories:
What are 'do's and 'don"t's regarding which CSS properties should be used for what things in what circumstances for the smallest memor... |
When designing a RESTful API, should your URI map to tables (for the most part). I have 2 tables that look like this:
Users
+-----------------------------------+
|id|first_name|last_name|email|role |
+-----------------------------------+
|1 |Jonny |Walker |a.com|User |
|2 |Jim |Beam |b.com|User |
|3 |J... |
I have to perform a number of 'housekeeping' tasks that need root access (Linux, Debian). Generally one time only, but I do need to check that they have been performed.
I don't really want to run the whole program as root though. Is there a good pattern to do these tasks without having the whole program as root?
The ta... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.