instruction stringlengths 34 36.1k |
|---|
Say I have a DDD application with three bounded contexts i.e. Sales, Production and Marketing.
Say I wanted to setup an administration facility. The admin facility would allow superusers' to change data in the tables that are used by: SalesRepository; ProductionRepository and MarketingRepository.
How would the Admin... |
I have read a lot of materials regarding preferring returning values from function like this:
some_class func();
over getting output by passing it by reference like this:
void func(some_class& input);
I have found little information regarding whether similar rule applies to class private member methods though. Suppos... |
I do programs for several years.
And now I know from my colleagues my pros and cons:
Pros: I can solve very complex problem
cons: I make overcomplicated solutions for simple tasks.
Now I'm trying to fix my cons and looking for generic principles and guidelines for this question:
When should I create an additional pie... |
The context
As a school project, I'm building a PHP and Android app for a fake company. Let's call the company "Express Food", which can talk pretty much by itself.
The "daily meals" are kept by deliverymen who wait in streets for a delivery, we say that these deliverymen are inactive. When a customer orders the meal, ... |
I recently read two articles regarding two different approaches for managing the underlying technologies of a system. The first one was by engineers of reddit, explaining how they gradually extended their deployment and scaling mechanisms, starting from simple python scripts to a full AWS auto scaling solution. The gen... |
I recently worked in a larger project where I touched the topic of distributed systems in the c# world the first time.
I found that
wcf is fantastic for remote procedure calls, but how do you add event communication between services using only wcf?
Here the project requirements:
We had ~15 different services for diffe... |
I'm making a C++ OpenSource project and I want it the more understandable and clean, so I need some point of views about doing things like this :
Server.cpp:
void Server::setOption(type foo, type bar) {/* ... */}
void Server::start() {/* ... */}
App.cpp:
namespace App {
void startServer() {
Server s;
s.setOp... |
I'm currently writing the GUI for my application. As I understand in a MVC-like application are the following components for each feature:
Business data: a complex object hierarchy containing all the data I need
Processing code: code that works on the business data
Controller: Somehow handles the conversion between vi... |
I'm not sure the title is correct, so please advise if you think of a better title.
The scenario is:
We have an API gateway that exposes REST API to our clients (web and
mobile apps).
We have a "sessions" microservice that keeps track of
the logged in users. When a user logs in, a new session is stored in
this microse... |
When doing simple server updates or submitting forms or that type of thing, I have come to a fork in the road...using AJAX:
var ajax = new XMLHttpRequest();
ajax.open("post", "myserver.php", true);
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajax.send('entry=' + encodeURIComponent(entry)... |
As I was working with a friend on a project I noticed that he created custom functions such as:
function is_empty($val){
return empty($val);
}
function is_not_empty($val){
return !empty($val);
}
function is_set($val){
return isset($val);
}
function is_not_set($val){
return !isset($val);
}
and is using them in... |
I am very puzzled with the obsession that many people seem to have with using Microsoft frameworks. I have seen several tutorials and projects (both open and closed source) that seem to utilize all of the additional .NET framework libraries and code when they are not really needed. To be clear, I am not talking about c... |
in C#, an int data type has a maximum value of 2,147,483,647 and
a float maximum value is 340282300000000000000000000000000000000
what causes these data types to have maximum values, where do those numbers come from?
|
I am reading up on authentication/authorization in web applications. Could anybody confirm/correct my current knowledge?
Cookies: in their early version, a text file with a unique client Id an all the other
information needed about the client (e. g. roles)
Session: only the unique client id is sent in a file (also cal... |
How does a highly scaled company serve users on the opposite end of the world?
Take Facebook for example (headquartered in California). If someone hit their endpoints from a place like South Africa, how are they routed to the nearest webservers?
I thought the load balancer would do this, but that doesn't make sense to ... |
Background:
I am working on a node project which consists of a core package and several addon packages. For the end product to work, the core package and atleast one of the addon packages should be integrated. These addon packages are basically database adapters. Addon packages have a production dependency on the core ... |
We are writing a cloud application in a micro-service architecture. We have good unit and integration test coverage for the individual services and we have a set of (public) API level acceptance tests.
For simplicity I will use a contrived example to step through the problem at hand.
Let's say I have a Company and Us... |
I am designing a 3rd-party library for developers to retrieve data from various endpoints of another system which itself has multiple APIs. Each of those APIs may contain the same type of request but return different data, which correspond to a namespaced request class in my library:
api1.domain/type1/schedule.json ->... |
It strikes me as weird that the column expressions (everything between SELECT and FROM) in an SQL SELECT statement come before the table references, when the column expressions depend directly on the aliases, joins and subqueries of the table references. The converse is not often the case, so often I end up writing the... |
I am creating an administration facility for an asp.net MVC application. I am currently trying to create a form that will allow admin users to create roles. I see plenty of code, which looks like this online:
public class RoleController {
ApplicationDbContext context;
public RoleController()
{
... |
In this question about using WCF and/or WebAPI, there is this quote:
I was asking myself the same question until I found this WCF and
ASP.NET Web API comparison page on MSDN (with my own emphasis
below):
Use WCF to create reliable, secure web services that accessible over a
variety of transports. Use ASP.NET ... |
I'm using Django and Django-Rest-Framework to build a simple photo sharing app/website and just now getting around to implementing a "Like" system. A couple of options I've thought about (surely there are more):
In my Photo model, add a Many-to-Many like field containing users that like the photo. My concern with this... |
I'm designing software that will connect to a remote service and send it requests from a local application. This remote service implements a leaky-bucket algorithm to determine whether to process the request, or return an exception.
Documentation for the remote service is thorough. I can design my local application t... |
I'm working on a game framework and have decided to use OSGi to bind it all together, as modularity is core to the game itself.
I want the game to be run as an all-in-one bundle on someone's machine, or writing it as a server, putting the login server on an Azure instance, and having the game engine running on an AWS i... |
Second Year Software Engineering student here.
I want to make a file managing system for a C# notetaking app, every note will be represented by a file and will display a small preview of it, furthermore all notes should be query-able, rearrangeable and editable, the whole system it self should be portable to other plat... |
I have inherited a 10+ year old project that has been handed down through many developers. Needless to say, there are many instances where there is some class or object property that no one knows what it is for or why it exists. The code base and DB scema are in desperate need of pruning.
Obviously I search all code, d... |
I've got a generic container class:
from typing import Container, Generic, TypeVar, NamedTuple
import sys
fixed_typing = (sys.version_info >= (3, 6, 2) or
(3, 5, 3) <= sys.version_info < (3, 6))
T = TypeVar("T")
_Interval = NamedTuple("_Interval", [("start", int),
... |
I read a bit about DDD since at work I came upon a web application, supposedly written according to DDD principles.
Some things which I see however in this application look to me totally absurd.
As I understood, the main point of DDD is about "ubiquitous language" shared by analysts and developers alike, such that the ... |
Most functional languages use linked lists as their primary immutable data structure. Why lists, and not e.g. trees? Trees can also reuse paths, and even model lists.
|
I am creating a multiple wrappers/layers API in Java that go like this
public class Layer1<T extends Layer1>
public class Layer2<T extends Layer2> extends Layer1<Layer2>
public class Layer3 extends Layer2<Layer3>
with methods like public T sees(){ return (T) this;} within each layer
What is the correct way for t... |
I have a client-server system modelling an interactive business process with the following four constraints:-
The client may have stale data, and/or the client may be untrustworthy. All client-side commands must be validated on the server before their effects become "truth".
The client's user experience (though not no... |
It's considered a good practice to commit to git a lot. Sometimes this is necessary where git is used as a delivery mechanism to test in the cloud.
But my git history gets cluttered up with lots of commits, each with a very small and almost meaningless commit comment.
What is the best practice? To reuse the same commen... |
I have a solution with 10 projects, I used to distribute this as an SDK with an installer back in the day.
To change that in VSTS I added the steps to create a package per project, every time I make a change, a build is triggered and a PS script change the version of the nuspec files, in the end the packages are pushed... |
I'm thinking of whether it is possible trying to apply project management methods and frameworks, e.g. PMBOK, PRINCE2 or something like RUP for software applications, that are still under active (iterative) development, but do not have a specified ending . As I've learned, a project is always a temporary endeavor, so s... |
We need a content management system, but we need alot of features that are not available on the market now: integration with Azure AD, integration with our phone system, and a couple others.
I'm having an issue figuring out how to implement a basic feature: allowing the user to add pages to their directory.
Here's my q... |
I work in a project that uses (Spring) Dependency Injection for literally everything that is a dependency of a class. We are at a point where the Spring configuration file has grown to about 4000 lines. Not long ago I watched one of Uncle Bob’s talks on YouTube (unfortunately, I could not find the link) in which he rec... |
Here is the work flow of a class of my program:
Server class instanciation -> Creating socket -> Binding socket to addr:port -> Listening -> Handling clients
Should I put all that stuff in the constructor or in separated private functions ?
|
I'm writing a small microservice-based application. One of the services is assigned the task of querying an external API and processing the JSON response (filtered list of houses). Since I'm using Protocol Buffers to serialize the message that will be sent to the message broker I need to convert the JSON output to the ... |
I want to implement a more robust authentication service and jwt is a big part of what I want to do, and I understand how to write the code, but I'm having a little trouble understanding the difference between the reserved iss and aud claims. I understand that the one defines the server that is issuing out the token an... |
I have such problem: the interface with no in and out parameters.
public interface IIndexer
{
void FillIndex();
}
It should work differently for different kinds of activities( comments, likes and so on). And when I apply IoC principle through dependency injection (via Ninject), my resolver cannot resolve me Commen... |
How should looks update method signature in aggregate root? For example I need to update user address. I have multiple ways to do this, and don't know which is better ("domain driven design way"). First way is to create method in User which get UserAddress as argument:
public void updateAddress(UserAddress address) {
... |
I have some problems figuring out how I should design an application.
On a production line there multiple stations. The products will move from one station to the next. Each station will execute some task on the product.
The tasks should be executed in parallell, so all stations that have a product should execute it's... |
I recently asked a question on SO where I was trying to understand how to catch an exception in a piece of code which runs indefinitely. I was initially expecting that
try:
the_code_which_runs_indefinitely_and_which_raises_an_exception()
except:
print('the exception in the code which runs indefinitely was caugh... |
Consider this simple method.
public async Task AddItem(TodoItem item) {
if(item.DueAt < DateTime.Today) {
item.ValidationMessages.Add( "The date is missing!" );
return;
}
var mappedVersion = _mapper.Map<TodoItemDto>( item );
await _todoRepository.Insert( ma... |
I'm reading articles about REST including a tutorial. I've seen this site http://www.vogella.com/tutorials/REST/article.html, and there is a part for explaining the rest as:
In a REST based architecture, you have a REST server which provides access to the resources. A REST client can access and modify the REST resourc... |
Suppose I want design and implement a a large and complex file format, like pdf or docx; how do I have to structure it? How can they contain so many different data types like images, macros or graphics?
Edit: for structures I mean the ways for storing different data types, I don't think that a plain binary file is so v... |
Very often when coding in Python (or any language where type is not specified) I run into the following problem:
I want to write a function that can accept either a thing, or a container of such things in general. For example consider this subset function:
def subset(df, months=all_months):
return df[pd.DatetimeInd... |
Here is the scenario:
We are running a microservices style architecture on AWS using API Gateway and EC2 instances. Let’s say there are five services: Photo Service, Topics Service, User Posts Service, User Messages Service and User Profile Service. There is also an SQS Consumer service, the “Message Worker”. Each micr... |
I need to write a Software Quality Assurance Plan (SQAP). I am familiar with the waterfall structure and I have seen SQAP samples based on waterfall model. I also know how TDD works, but I could not find any SQAP that is based on TDD/agile. I assume a SQAP for a TDD is more minimal, but still can anyone please clarify... |
Why is the sorted() method on Stream not named sort()?
list.stream().sort()
|
I'm having major troubles trying to get rid of this switch statement. To put a little of context first, I'm working with asynchronous batch operations. These operations can be applied to any entity in the system. You just have to send a different namespace.
Example:
"jobs": [
{
namespace: "client",
request: {"i... |
We're in a process of moving from a huge old monolithic architecture towards microservice one.
UI-centric Product
Our product (which is mostly a large single-page app) is quite UI-centric. Thus the current codebase includes lots of automated UI tests.
Objective: Continuous Deployment
We expect to have a lot of microser... |
I am programming an application and am having trouble finding a good architecture for some of its components.
As part of the front-end app, I have a user authentication system and an API that allows users to perform certain actions on a server.
I have built the following components: (This is in javascript, but I imagin... |
Our documentation team of about ten people recently moved from SVN to Git. In SVN, everybody worked on master -- a model I've always hated, but I wasn't able to bring about that change. As part of the move to Git we've agreed to fix that, but we can't do it just yet (waiting on build changes that will allow builds fr... |
I spend a lot of time answering SQL questions over on SO. I frequently come across queries of this ilk:
SELECT * FROM person WHERE birthdate BETWEEN '01/01/2017' AND '01/03/2017'
SELECT * FROM person WHERE birthdate BETWEEN '2017-01-01' AND '2017-03-01'
SELECT * FROM person WHERE birthdate BETWEEN 'some string' AND '... |
In Hibernate ORM & Spring Boot, during the SessionFactory creation, SQL DML statements can be executed to create tables and/or insert data via files such as import.sql defined in the javax.persistence.hibernate.hbm2ddl.import_files property. As I understand, using this feature is particularly useful for inserting refer... |
I am working on a Review System and I am having doubts about how to handle storing data in the database.
For this review system, there are three different ratings the users can input, I will call them ratingOne, ratingTwo and ratingThree. My current solution is having three different columns in the database called, res... |
If I have an algorithm and part of it has a known worst case numerical value, which is reasonably small compared to the rest of the problem, is it ok to argue that part as O(1)?
E.g. If part of the algorithm involves building a linked list of characters out of a string, where the string may contain each of the ASCII ch... |
I feel confused about the three relationships Association, Aggregation and Composition in UML. I need to finish a project soon, until it became less unclear in my head, is it okay to use only Associations ?
|
We have a mature product that we reuse for new projects. For one project, some tasks were created for already working features. Those tasks were all assigned 1 SP each. So, just as a sanity check, I went ahead and tested a release version of our product in order to close the said tasks.
Now, since I didn't do any work ... |
I have a relatively large GUI based OOP software (in Python) were I rely heavily on keeping references throughout the program. For example I would define a Main class with some stored options as an attribute (code example below). In a second class, e.g. OptionFrame I would pass the reference to that stored options obje... |
How will I have to update "views_count" each time(!) a user loads my page? It will be costly. And I don't need such accuracy when I update "views_count" after a user loads a page.
Then is there any way to buffer "views_count" to somewhere so that I'll be able to update a field in database in one fell swoop, say, by +5 ... |
I am working on a concurrency system based on message queues with an underlying thread pool. A queue can target other queues. Also a queue can be targeted by multiple queues (i.e. children) to create a tree hierarchy and to prioritise some of the queues.
I want to avoid signalling threads each time a message is queued ... |
Is it possible for two variables to point to the same piece of memory?
My professor wrote a short snippet of code where he created a second instantiation of a class and assigned it a previously created object and referred to this as two variables pointing to the same location/info in the memory, which left me pretty co... |
I'm using JWTs for user auth in a web application. I have a user db where each user's unique ID is their email address. To identify the subject of the JWT, I currently have a claim which stores the user's email address in the token. Does that pose a security problem? If so, should I be using a GUID or a hash of the... |
I was wondering if there is a recommended approach to defining a property of a plain object that is used for data transfer, for example via a REST-API which is a list of other objects. Which C# type should one prefer for defining those?
List<T> maybe? It's short, everybody knows it, and we don't have to cast or transf... |
Update: C# 9 should fix this problem using records :D
I was wondering if there is a recommended approach to initializing the properties of a plain object that is used for data transfer, for example via a REST-API.
Here are two variants I can think of:
public class Dto
{
public string Name { get; set; }
public... |
I am currently dealing with an app that has several classes which are used to compare files in various formats (xls, csv, xml, html, pdf...). They are all implementing an interface that is defined like this:
public interface ReportComparator {
// compare files (1 - match, 0 - no match, -1 - both files empty)
... |
If an enum type is dedicate only to a specific class, does it make sense to declare it inside the class itself? I mean, would it help to understand that this enum type was designed to be used only with this class? Another option would be to put them inside the same namespace.
We also need to consider that another Dimen... |
I'm building a RESTful API using Node/Express4 and so far I've been successful. However, I'm not sure where to implement URL data validation - should the router script block invalid URI requests or should it send the controller the invalid data for it to send back an error?
The expected URI is as in the following examp... |
Which is better? I noticed the latter is used in a lot of C code. People will typically malloc an array, and then pass that as a parameter to a function, which will then populate it. Whereas in Java, the former seems more popular.
Is one better than the other? If not, do language features invoke a preference?
|
Is it possible to lock "txt" files using GIT LFS , if not is there any alternative to lock files in git to prevent other users from using it (similar to Checkout in ClearCase)
|
I am designing basic software for smart wireless lighting systems. The software is GUI based, and I have a slider for the brightness setting of a light in my GUI. The lighting system has a RESTful API so I can listen to changes on the slider value and make an HTTP request with the value to the system. The thing is, it ... |
Lets say there is a real time application where a list is shared among multiple people and updates done to the list must propagate to all the subscribers of the list. Like in trello.
The list is stored in a database on a remote server and list is updated with an API call from the app. The changes are conveyed to the su... |
I have a Publisher object that raises an event at regular intervals (think of it something like a clock tick). I then have 100s (or 1000s) of subscriber objects (all instances of a single type or two) which may have to update themselves in response to the event. But most of the time the event won't apply to them, so th... |
If a feature that was done in 2, 3 months and before it was merged into the main branch, and both branches were under constant changes every day, should integration tests be written at this stage?
Will it be too early, because both branches are changing, the UI were changing, and even the specs were changing. If the in... |
Recently, I have been reading the JWT' RFC and I'm struggling to understand the meaning of claim names collision.
The registered claim names are more or less clear. If I got it right, these are addressed to provide JWT specification with a set of claims out of the box. 1
However, when it comes to public and private cla... |
For example, if there's multiple lines to be drawn, I could do
function drawLines(lines) {
lines.forEach(function (line) {
drawLine(line);
});
}
function drawLine(line) {
//...
}
and then in the "main" section of the code I would merely have to call drawLines(lines) rather than writing a forEach th... |
I am looking to build and host a website for a client. Their existing site has a facility that allows customers to make donations and they want the new site to have it too.
My manager has told them that we can just lift their existing code and data and put it onto our servers and has asked me to go ahead and do this.
I... |
The Clean Architecture suggests to let a use case interactor call the actual implementation of the presenter (which is injected, following the DIP) to handle the response/display. However, I see people implementing this architecture, returning the output data from the interactor, and then let the controller (in the ada... |
I'm currently working on refacting an existing project. Basicaly, I need to perform requests to remote services. Current solution is to write tasks to a database and then poll them using cron jobs. This approach creates quite high load on the database. I'm thinking of using a task queue, like Celery for example, to que... |
I was reading "Beginning Spring" and this particular paragraph caught my attention:
The DI pattern resembles other patterns such as Factory or Strategy.
We can say that with the Factory pattern the instantiation of objects
is still within the responsibility of the Factory definition, which
is your code, but with... |
Need an advice on how to achieve decoupling of UI graphs from content.
Preamble:
I have an abstract Sensor interface and a bunch of implementations. Interface defines a couple of functions, such as parsing text to actual values, etc.
On the other hand, each Sensor implementation has it's own defined maximum range, whi... |
I'm a student and I'm learning about domain driven design. From my reading, an important part is removing the getters and setters from a class (thus keeping the implementation of that class private). My question is how can you do unit tests for this class.
Consider the following example:
public class Account {
priv... |
I know that often catching all exceptions (C#: catch(Exception exception){...}) is deemed bad practice.
However, I believe that there are situations where it is perfectly reasonable to do it. For example, if I have a number of operations to perform:
foreach(var operation in operationBatch)
operation.Do();
and a ba... |
I develop primarily using Visual Studio on Windows. The problem is that after a while Windows gets bogged down and I'm faced with needing to reinstall Windows. Similarly switching to new machines is a problem.
Reinstalling Windows is painful because my development environment has a lot of dependencies (such as extra M... |
I would like to show a web page from another website and show it on my website. I want to annotate some text on their website content.
Conceptually I know what needs to be done:
- I will capture their web page's html and probably the css and js files and put them in a folder on my web server. I will keep the images url... |
Rust is advertised as a "concurrent" language, what does this mean specifically and how is it different from other languages such as C++?
|
I am a religious person and make efforts not to commit sins. That is why I tend to write small (smaller than that, to reword Robert C. Martin) functions to comply with the several commandments ordered by the Clean Code bible. But while checking some stuff, I landed on this post, below which I read this comment:
Reme... |
Many web application require a seed file -- a file, written in the same language as a web application, where I have data to pre-populate a database. This makes sense.
Nonetheless, I sometimes see that some parts of that data is extracted into separate, text files to be read from the main seed.{rb, py, php} file and i... |
Description:
Given an aggregator portal the user must be able to create, read and update the requested entity. The entity here are all of different types and live in different systems. The portal shows the metric of the entities at a given unit of time and allows an user to filter the details by their type, name etc. T... |
Built a microservice which will update column value each time when it is called.
Application stack - Spring boot ,hibernate and mySQL database.
Currently we have listed following approaches in case of concurrency scenarios
Creating a column of datatype timestamp ,assuming the customer holds this timestamp value in re... |
I'm trying to practice TDD in my personal project and I wonder how to deal with the situation when after adding new test it pass from the start based on existing implementation?
On the one hand the new can test provide additional documentation of the design and a protection from accidental violation of assumptions.
On ... |
Problem description:
I am running performance test of calculation of PI number with primitives and with BigDecimal class.
Calculation of PI with primitives is around 5-6 times faster than the same algorithm, but with BigDecimal class.
I see a problem with creation of new BigDecimal object in the for loop, when adding ... |
I am building a CMS and need guidance on how to structure the application. I simply do not understand when I should use interfaces or an abstract class.
The system being built is using .Net Core and EF core I plan to allow MySQL and SQL Server as datasource. I also want a modular approach where I can add things on a pa... |
I have a simple task this is what I need the code to do:
Read data from a third party REST resource.
Parse the json object to match my internal structure.
Save the parsed data in my database.
I could just be lazy and have everything done in a single method, but I want to apply best practices, apply tests and have cle... |
I'm building an application with events in different countries and cities. An event is always presented in a local time of a place where it occurs.
Therefore I'm thinking that I won't need a time-zone information along with a date-time of an event in database.
Are there any arguments against this? Should I change my mi... |
Inheritance vs coding to an interface is something I have wondered with respect to proper architecture design but actually have not run into an problems when using abstract inheritance over coding to an interface in my own projects.
According to SOLID principles of OOP Design (and general OOP advice), you should code t... |
does anybody know how the code smells "rigidity", "fragility", "immobility" and "viscosity" can be explained in short code examples?
I've found a lot of text but never a source code example.
Thanks for your hints.
Are there at least very pratical examples, like the following
- rigidity: "if the access permission is che... |
By easy I mean easy to implement in code.
By reliable I mean that it doesn't depend sources who might fail under which there is no good control.
By secure I mean that it cannot be worked around or that if it could be worked around it would be pretty complicated.
The best solution I can think about for the moment is try... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.