instruction stringlengths 34 36.1k |
|---|
I've started reading Domain Driven Design.
I've got a situation where an Aggregate Root has a child object that needs DB interaction in order to perform it's business logic because one of the constants it uses is saved in the DB.
Example:
User creates a Customer
User creates a Review on that Customer
Review might need... |
Let's say that I have a custom database contacts, and there are two tables inside:
contacts
- user
- group
A user may belong to many group, and a group can have multiple user. If I add/update/remove a user into the database, group should be updated too (if the user belongs to any of the group). How should I implem... |
I'm making the transformation from being a web developer whose pages often contain loads of <script> tags to one whose pages contain modular Javascript, encapsulated in functions, etc. I'm trying to work out the best way to handle the situation where the code in a particular script file assumes that another script has ... |
I recently got into a slight argument with the other developer on my team about the correct way to develop with SVN and Eclipse. My way of developing in multiple branches is by creating new workspaces for each branch. The reason I create new workspaces for each branch is so that I can separate features/bug fixes from e... |
We have a ASP.NET Web API that provides a REST API for our Single Page Application. We use DTOs/POCOs to pass data through this API.
The problem is now, that these DTOs are getting bigger over time, so now we want to refactor the DTOs.
I am looking for "best practices" how to design a DTO: Currently we have small DTOs ... |
Whenever I am using issue tracking on GitHub with my team, should we unassign people from the issue once we close it?
I don't know which way should be done, and if there is any advantage to unassigning members.
|
Our project uses Jacoco for code coverage metrics. Previously, we have checked the line and branch coverage against percentage values. However, the documentation also describes an "Instructions" level, which counts Java byte code instructions. From their documentation:
The smallest unit JaCoCo counts are single Java b... |
From Zend Docs there is this example of how to use Zend\Di, which is a dependency injection container of Zend Framework:
// inside a bootstrap somewhere
$di = new Zend\Di\Di();
// inside each controller
$movieLister = $di->get('MyMovieApp\MovieLister');
Guidance on how to get $di into your controller is not given in ... |
Please see the DDL below:
create table Person (ID identity not null, varchar(name), Gender char(1), dateofbirth datetime, primary key (id))
create table PersonOffer (PersonID int not null references Person(ID), OfferID int not null references Offer(ID))
create table Offer (ID identity int not null, description varchar(... |
This is probably a sloppy way to see it, but I wonder if the idea of longitudinal datasets (to be used in ggplot2, for instance), can be exlpained as complying with the criteria of data in a 1st normal form. I know the latter comes from the relational database field, but I would see entities within a db that is 1st nor... |
Assume I have two different error cases that logically have the same HTTP status code. What's the canonical way of providing data dependent on the error case in the response so that clients can respond differently depending on the error? Today I parse the error message--is there a better way?
|
I try to understand better what the statement below means on Uncle Bob's TDD Harms Architecture,
"As the tests get more specific, the production code gets more generic."
Below is my understanding on how to get more generic on production code:
Using abstraction for method arguments, and return type, if possible
is the... |
Working on a side-project writing an API and when it comes to authentication I am a little stuck. I am trying to decide what the differences between using Basic Auth vs $_POST fields for the actual login.
Once the login gets posted, I will return a token to the client that will then be used on subsequent API calls.
My... |
I have a REST endpoint that gets a list of customers in a JSON format.
GET /webservice/customers
{
"count" : 80267
"customers" : [
{
"id": 1,
"name": "John Doe",
"email" : "jdoe@yahoo.com"
},
{
"id": 2,
"name": "Michael Bay",
... |
I am currently responsible for reviewing one of my team mate's code for a front end web app. We have established a workflow which involves creating a feature branch in git for each feature we define. Say our app lets you scroll a list of items and click through to the item detail - then the kind of features we have def... |
I see some classes in the .net framework that support reading and writing, saving and loading, classes whose main responsibility is not them, for instance the Stream classes and the XML Dom/XLinq classes.
|
I typically write code that only I use, but I do have a public github with some JS libraries. A key component of most libraries are events. My question may be opinionated, but I don't know where else to post it and it is important to me as a perfectionist.
When writing an API do events need to be re-sent through each l... |
I recently joined a SaaS company that has so far not been using source control track and maintain their development, instead just separately working on their own portions of a given client's codebase. In an effort to help and positively contribute, I've begun using git on my own contributions and want to bring more (in... |
I am reviewing a big C# code base and thought on how to mark it as reviewed when it is, in order to not review it twice.
Currently I have a ReviewedAttribute which I use to decorate members that have been reviewed:
public class ReviewedAttribute : Attribute
{
}
That approach however, misses an important aspect:
How t... |
I am trying to understand the broader implications of blockchain apart from the main advantage of immutability. Are there any?
It seems like the distributed nature of the ledger can be an asset when it comes to data redundancy but it also seems like performance would be terrible since, as I understand it, all the histo... |
I was just trying IDs on the CSS tab and I noticed that a little warning sign appeared "Don't use IDs in selectors"
Why does the CSS tap recommend me not to use IDs in selectors?. Is there something wrong about them? (the selector seems to work perfectly).
The "{}" code sample says my code is wrong too.
|
I want to add push notifications to an chat application I am working on.
Initially I thought that I should write business logic to detect that a message wasn't delivered and then attempt to send the notification for the unread message. If a user's online presence is detected, I can skip the push notification call.
Howe... |
In my application, I have to get data from our ERP. For this example, let's say product data.
Some of the data will come from the API that our ERP has provided us, whilst some of it will come from direct DB calls as the API doesn't give us all the required detail.
For this situation, do I just do with a single Reposito... |
When we are developing a software supported by continuous integration (CI), I imagine 3 roles working together:
Software developers, adding functionality to the system with merges to the repository.
DevOps, maintaining the CI pipeline that supports developers.
Testers, working on the "verification" part of CI.
My pro... |
I am having trouble to understand the following question for my Computer Architecture assignment.
Consider a system that has a direct-mapped cache that contains a total of one megabyte; each line contains 64 words. The main memory contains one word per cell. It has a 32-bit address, and contains a total of 8GB. How man... |
I have some data in my ERP that is formed in a very odd way (think a HTML field that contains many different fields, formatted in HTML that need to be pulled out using XPath).
Is the transformation of this data into the model fields the job of the repository? Or should the repository only deal with getting the records ... |
I have a lot of data. Objects with other objects nested like this (JSON):
{
id: 12,
Code: "a code",
country: "at",
prices:
[{
{ price: 100, from "2017-05-05", to "2017-06-05" },
{ price: 150, from "2017-05-06", to "2017-06-06" },
{ price: 200, from "2017-05-07", to "2017-06-07" },
}]
}... |
I have an abstract class structured somewhat like this:
class AbstractQuery(object, zip_code):
def execute(self):
"""
Retrieve information about a zip code
The information returned will depend on the subclass
"""
url, params = self._build_query(zip_code)
response = re... |
I have to write an windows service in .NET 4.6/C#, which reads messages from RabbitMQ queues and does some processing based on message type. Processing includes reading the message and based on business rules, insert/update SQL database and send out another message confirming the successful processing of the message re... |
I'm developing a ML/AI solution and I'm looking to write some unit tests.
I end up with large objects with a lot of data. These come from a data source which is built at runtime. The data created as a composition of information retrieved directly from an API - I have mocked that response into a simpler result, but in o... |
Presume this situation:
Max Number of 256 key slots.
Key slots are defined by a struct, and a variable for each (256) has to exist.
User defines which keys slots are active at initiation (in my example, I just coded them in). They however will remain constant throughout execution.
Program receives input, sends it to s... |
I have a table of discounts/offers, which are only applicable when meeting certain requirements. Example:
Size: medium, Category: classic, Max. Ingredients: 3, Delivery: collection
Meeting these requirements results in the user having the products for a lower price (absolute price, not relative).
I am thinking about ... |
When a local web server is already running at port 3000, I wonder why the npm module drydock is able to provide data also through port 3000? I thought once a port is used, then other process cannot use this port?
|
No idea how to write a good title for this question.
I'm thinking about introducing an operator in a DSL that makes hidden identifiers (like variables) accessible. Think this.foo in Java or C# to access a member that was hidden by a local foo. Or base.bar when bar is a member in the current class. Let's call this "exp... |
What is the difference between so called Traditional Software Development (TSD) and Behavior Driven Development (BDD)?
I've seen a lot of different development methods that teach developers to talk in business language. Yet, to me, all of this seems like common sense.
How could the developer(s) ever think they could ... |
I have now put another rephrased version of original question as requested by the user in the comments with class names mimicking real world scenario of postal office (though I dont know how real world the rephrased example is). Original question had abstract/generalized class names. Also uploaded the correct code for ... |
Does anybody face the issue with Design Validation and related overheads?
When we deliver a Solution we have a lot of so-called Streams (usually 3-8, average 5).
Each Stream is responsible for its functional Module (e.g. Asset Management, CRM, Billing etc.) and prepares Technical Design for it.
The issue is that the fu... |
I think this is a common design problem, but I keep scratching my head every time I face it.
On one side, we have our API which sends or receives simple structures aimed to be consumed by web apps, mobile etc. We could potentially have multiple APIs aimed for different devices. On the other side we have our internal do... |
Assume I'm writing a library in Java for performing network calls. I want it to be efficient for cases like highly loaded reverse proxies etc (10s to 100s Krps coming in and out; client requests served in the same DC in under 1 ms; relatively simple processing of results), also, each incoming request might start severa... |
We have a list of about 100, 000 customers. Every night, we run a batch search of these customer names against a list of known criminals/suspicious persons. This list contains around 1 million entries.
To ameliorate false-negatives, we're using fuzzy string matching which catches small mismatches between the customer n... |
Imagine a table T, with 2 columns containing data. Everyday, one row is added the table.
Now you add 3rd column to the table (After adding this column too, one row will be added the table everyday).
Since the column has been added, its value will be null. So single time executable script is necessary in-order to upd... |
Firstly, let me clearly state that I am completely against this, I have real issues with unnecessary, obsolete, untested, shitty code, especially when they end up on a production system. My background is in build and release management/devops and I am now working as a Technical Consultant supporting an outsourced deve... |
I'am working on a project that use MySQL as RDBMS. Recently, we have to manipulate a big json data.
So, the first solution that comes in mind, and for many reasons, is to cooperate mongoDB with Mysql however it can add complications! (We use Symfony).
But from MySQL 5.7, MySQL supports native JSON data type which provi... |
I'm Working with php and we using enum's by create an Abstract class that mocking enum behavior - but my question is cross-languages.
Where all the helper functions like toString, getEnumTypes, checkValidValue, etc... should be, in a dedicated utility class: EnumUtil or in the AbstractEnum it self (all enums extends A... |
I want to add error handling to:
var firstVariable = 1;
var secondVariable = firstVariable;
The below won't compile:
try
{
var firstVariable = 1;
}
catch {}
try
{
var secondVariable = firstVariable;
}
catch {}
Why is it necessary for a try catch block to affect the scope of variables as other code blocks do? C... |
I'm in my first two months as a software engineer and just wanted to get advice on if this can be improved upon.
I've created a class that represents data from RFID in the form of a message:
class RFIDMessage
{
string _a;
string _b;
string _c;
string _d;
string _e;
str... |
Following REST principles, I would want to create a GET method for my API that make a search using some criteria and return the results to the client. The problem is that the criteria can have up to 14 parameters, one of them is a list of complex objects, so...
I don't even know if it possible to encode/decode these ... |
In my workplace, the client is obsessed with line-by-line code reuse. And they use a tool that uses LoC as measure of code re-usability.
Often for two modules, if the logic is same as of now, those modules call the same method. Which reduces no. of lines, but seems like a long-term manageability disaster.
Are my concer... |
I know there are many books on writing clean, modular, readable and whatever else you can say but frankly speaking I find it very hard to remember every advice given on those books. Frankly speaking either you know things or you know nothing at all and find it very difficult to relate to your daily job I think it's so ... |
I have an annoying code smell in my asp.net core api that I am passing around, and I can't come up with a way to fix.
In an MVC controller action, usually there is a very straight forward logic, at least in my case.
Validate model (before calling the action)
Query relevant data
Do business logic
Send response
Now in ... |
I understand the relationship between an aggregate root and a repository i.e. there should be one repository per aggregate root.
What is the relationship between the application service layer and the aggregate root/repository. I assume there should be one application service per aggregate root?
Should the application ... |
This is not (supposed to be) an opinion question, but it is a newbie question, so if there is just a resource I haven't found that I need to read, point me there :)
I am in the design stages of a microservice-based ETL system. One service in particular seems to be a natural candidate for functional programming over oop... |
I know that logging is supposed to tell a story about what your users are doing. Eg:
User 1 created a thing
User 2 deleted a thing
User 1 tried to access a thing and encountered an error
This is very useful, but what is even more useful is having detailed information about every single HTTP request:
HTTP GET /In... |
I have a large database of customers. There's a need to identify customers who have two or more customer IDs.
This comes mostly from people at the front-desk creating new customers instead of searching for their existing IDs or doing a bad data capture, so we end up having this sort of thing:
ID name sur... |
NOTE: I am new with the whole concept of state management. I never got into the older languages that "explicitly used" states.
I dived into React and Redux for the past week, and as I'm getting into more complicated code, I stumbled across one thing:
I now have to sync the UI changes with the Redux state for even the m... |
I am writing an implementation of middleware chain in Python. Here is how a middleware function looks like:
async def logger(ctx, next):
print(f"Started doing stuff with {ctx}")
await next()
print(f"Finished doing stuff with {ctx}")
And this is how you use it:
app.use(logger)
app.use(some_other_middleware)... |
I raised this issue on the github project for RazorJam.Insightly, where as you can see it turns out that an error is occurring because for the particular items that I am retrieving and deserialising from JSON into an object, the ADDRESS_ID value is too large to fit into an int.
I initially wanted to submit a change req... |
I have two tables:
area (
id int PK autoincrement
code varchar
)
products (
id int PK autoincrement
name varchar
area_id int PK to AREA
...
)
The classes are persisted using eclipselink like this:
@Entity
class Product {
...
private Long id;
...
private String name;
...
@JoinColumn... |
So I decided to created a stack-based virtual machine and the result came out pretty good (in my opinion!). The first iteration was a basic toy VM.
I did a rewrite to make the VM work more realistically by giving it byte-oriented memory and data stack as well as n-byte oriented opcodes. After much testing, including a ... |
Below are oversimplified examples, but I wonder which route to take what is the best practice when designing API, the simple or the more complex and robust which is better?
This looks good and goes along with scala ADT concepts but I fear that it would become overly complex and the clients using my API will a little h... |
Apparently, for some built-in type of C++, the following does not hold: a==b || a!=b
Which type/value is it?
The question is originally from
this video:
https://www.youtube.com/watch?v=etZgaSjzqlU&index=4&list=PLHxtyCq_WDLV5N5zUCBCDC2WqF1VBDGg1 at the beginning,
for which the slides are:
http://stepanovpapers.com/Journ... |
I'm designing a REST API using authorization/authentication via an API Key.
I tried to figure out what is the best place for it and found out that many people suggest using a custom HTTP header such as ProjectName-Api-Key, eg:
ProjectName-Api-Key: abcde
but also it's possible and ideologically correct to use the Autho... |
I know this has been asked a lot of times but we are talking about entity classes here. Plain dumb objects containing nothing but primitives for properties. The purpose here is to store data. Our entity can be created in a variety of ways, we never know which set of properties will have a value, it is given by real lif... |
We are planning to use Spring Boot with JPA for our next project and I am wondering how much flexibility JPA gives in reality. If we start developing using a self-hosted PostgreSQL server and later want to change to Amazon RDS PostgreSQL or SQL Server, will we run into a lots of problems? On paper, JPA should serve as ... |
I try to understand better under what circumstances one-to-one correspondence between test code and production code is not needed, after reading Uncle Bob's TDD Harms Architecture. For example, first:
"a one-to-one correspondence implies extremely tight coupling."
then below:
"If you look at part of FitNesse written af... |
I am trying to wrap my head around clean architecture but I am struggling with the concept of how to avoid some dependencies.
I am implementing an API in Java for personal use, however I was trying to find some examples and came across this post:
https://android.jlelse.eu/a-complete-idiots-guide-to-clean-architecture-2... |
My organisation modularised their monolith into maven modules in dependencies up to four deep. Originally we used the maven plugin to auto-increment the version numbers in the pom every time someone did a checkin. Then parent dependencies could pull in the updates by updating the version numbers in their pom.xml.
This... |
This question is not about a specific framework. but I'm currently working with asp.net core.
The problem I'm facing is the concurrent update of a resource in the web application (race condition). I'm not talking about synchronizing edits to a wiki document by let's say conditionals HTTP requests. both requests are rec... |
I am working on a process that requires two different portions of it to make use of an ORM (I am using Insight.Database for this), and I am not sure where this portion of the code belongs, as I am not currently creating an abstraction layer over it but using Insight.Database directly.
An example of the code layout is a... |
Lets say I am trying to design a district.
I have
1) house
2) community (groups of 2 or more then 2 house)
3) city (group of more then two community)
4) district (groups of 2 or more then 2 city)
What I have so far :
class house{
public:
house(std::string name, std::st... |
I come from a self taught background and am trying to shore up my weaknesses in OOP, specifically C# and class design. I've been reading Code Complete 2 and it became apparent that I'm not following good class design principals. I currently have a ReportHandler class that generates a report based on a ReportType enum t... |
Should automated unit tests be a part of the build process, or should they be manually run when someone makes changes to the code instead?
To me it seems like making it part of the build rather than leaving it a manual process has some clear advantages. Running your tests with the build would make them run more freque... |
For instance, if I wanted to make a game which used a Python main file, but have another file with Ruby methods on it, how would I call those methods individually?
Secondly, how could I make a Ruby gem/library with python code in it? I can't find a way other than exec("python file.py") which is not a gem, requires the ... |
If there is tag 1.1 for master branch in github, I want to create a pull request with some commits that only apply to that very tag. Is this possible?
|
In this specific case I'm using C# and Emgu, where I made a wrapper around the Capture() object, purely so that the end user of the library that I made doesn't have to put using Emgu` in their client code.
My wrapper adds no functionality, and I've been debating whether it should even be it's own thing or if I should j... |
I work at a small to medium enterprise that are in the business of handling the processing of transactions for the selling and purchasing of "online, electronic products". Things such as prepaid mobile airtime, mobile data, electricity and even water and gas metering.
We are a Microsoft shop and all our skills and arc... |
Let's say I have a small CD burning library written in Python, with a CD class and a Burner interface + implementation classes:
# Module cd.py
class CD:
def __init__(self):
self.folders = []
self.files = []
# Module burners/burners.py
BURNERS = []
# Module burners/cdburnerxp.py
class CDBurnerXP(CDBurner):
... |
I have a very interesting question that has proportionally blown up amongst my friends and I. This deals with handling user issued tokens from a series of authentication microservices.
Remarks:
Each Auth Service is backed by its own data store
Each Auth Service can issue a token that only its data store knows about
... |
After reseaching the differences between OAuth and JWT, I decided to use JWT on my next project for simplicity and performance reasons.
From what I learned until now, and please correct me if I'm wrong, JWT is self contained data, hashed with a public key on the client. I then can check it against a secret key and ver... |
I am trying to create a device management system for over-the-air updates. The system basically has 3 parts:
Mobile client devices running android located at different places
REST Backend written in Java using Jersey Framework running on Google App Engine.
Web front end running on the browser of the users.
The use-c... |
I’m trying to apply DDD, CQRS (saga, fire and forget principle, etc), ES in my current project, with help of akka. Never done it before in real projects (just played a litle bit), sounds great in theory, blablabla.
But sometimes it frustrates me, sometimes I think it just buzzwords.
Do you have experience with those ... |
Below are the common phases applied, for a real world requirement(data) map to DBMS specific schema.
Conceptual models ER/EER/CODASYL/Hierarchical bridge the gap, in mapping the real world data(requirement) to DBMS specific schema.
In RDBMS world, object-relational impedance mismatch is the cause for applying these ph... |
I have two APIs to follow & unfollow a user.
domain/uid/follow (http POST) to follow user
domain/uid/follow (http DELETE) to unfollow user
It follows user and responds with http code 200.
When user tries to follow again (already followed user) I respond with 401.
Questions:
1 - Should I respond with 40... |
all programming languages have api's to interact various systems
as a example
javascript languge has Dom api to interact with the web page.
C language languge has file access api to interact with Files.
my questions is how to create such a API's From mere programming languge ?
as a example
how DOM APi created in ... |
Let me begin by stating I have already reviewed the following related questions, and just wanted to showcase the software architecture which I have inherited to see how opinions may vary.
When is a BIG Rewrite the answer?
Would you re-design completely under .Net?
To rewrite or slowly refactor old C++ project
So, I ... |
The problem:
Let's say I want to create a java app (currently using java 8) that works like a dictionary. I want the app to give the user the capacity to add and search for words, every word must contain a name, a meaning and zero or more examples. In addition, I want the user to be able to add more examples to a word ... |
I've been working over 10 months on a legacy project (yes, in PHP, what a surprise!) that has database IDs hardcoded all over the codebase. Of course this makes problems like we can't maintain it w/o a production dump, no tests, etc. I already vomited over that.
Moving on, there is one particular case that I can't see ... |
I have an api where visitor can send an email through subscription:
/api/subscribe
To prevent massive load due to public exposure, how can I secure this endpoint? Do I have to use database or can I do it without that with some kind of caching, inmemory etc which releases ever 10 minutes etc?
|
Summary: Is there a good design pattern to reduce duplication of information among tightly interdependant values?
In my line of work its fairly common to have a relationship among quantities such that you can derive one of the quantities if you know the others. An example could be the Ideal gas law:
Pv = RT
You could i... |
By current design, most data is stored in MySQL, and we use the repository pattern in our web app as the layer to fetch data from the DB. We do the same thing when fetching relations, using our framework's models and ORM to fetch models and their relations all in one go.
Some of our tables, mostly log-like tables, have... |
My question comes from this other question.
The first time I read the question, I understood (maybe worngly) that the OP was asking for a different way to initialize the object in such a way that it would allow him to extend and make easier the maintenance. Hence my answer.
However, some comments seem to agree with pas... |
I am trying to develop an API that tries to integrate features of various service providers. I am at the phase of developing a model(class structure that identifies with the context of domain) that helps in unifying the fields for data that gets sent out to different service providers.
The problem I am trying to solve... |
I'm using CMake to build my application and CUnit to test it. And I was wondering if there is a way to avoid including the production source files directly from the test code by name (#include ../src/foo.c strikes me as awfully ad-hoc).
I have heard of collecting the production code into a library and adding it to the ... |
I basically have the following situation:
+------------------+
| |
| Input object |
| |
+--+------------------+--+
unique_ptr<Subobject 1> ... |
I'm building a game with the LibGDX game engine. The engine works by registering an implementation of an interface that receives callbacks on the game loop. The interface looks like this:
public interface ApplicationListener {
/** Called when the {@link Application} is first created. */
public void create ();
... |
Setting
Let's take the following example:
We have a series of entertaining events on the television with each lasting only an hour and this goes on for 3 weeks. We want to create a simple App that displays the name of the next event.
We store the event in the above hierarchy where Weeks can store Days and Days can sto... |
The goal is to take a binary space, say 64 bits, and make certain parts of it "valid" and certain parts "invalid", then increment, starting at 0, through that space, avoiding the invalid areas.
Space is made "invalid" by applying an arbitrary number of arbitrary rules. For instance "if bits 2 and 49 are set, that numbe... |
Most people agree that it is a good thing to split a software development project into many small tasks each of which can be implemented within a few hours. But the finer the granularity, the more total effort has to be put into defining the exact scopes of all the individual tasks in order to avoid gaps or overlap.
My... |
Using python syntax,
threading.Barrier(NUM_THREADS) establishes a control point and all participating threads block until all of the participating “parties” have reached that point. It lets threads start up separately and then pause until they are all ready to proceed.
Can someone explain, a real time scenario(multi-th... |
When I want to make a method final, first of all I ask myself:
Should this method be final?
The answer is obvious sometimes, for example imagine this:
class Dog
{
private $name;
public function __constructor($name)
{
this->name = $name;
}
final public function getName()
{
retur... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.