instruction stringlengths 34 36.1k |
|---|
I'm a beginner in DB. I have studied some basic examples but now I'm studying more complex cases that involve many tables related to each other. I'm studying how to model a DB for a conference system but there is a detail that seems difficult to model.
The detail is, a conference can have multiple registration types an... |
(JAVA) I have about 50 Getters, all return the same text, tag, type. Text and tag are String and type is int. The purpose is a forms that use repetitive fields along with form specific fields. I am having trouble with simplifying and reusing code?
public class DataTransferClass {
private DataTransferClass(){}
public c... |
We're having a lot of fun and success using Azure Functions, but looking for advice on two related design issues. Our first challenge is that we need to communicate job state back to the UI. So the customer has a list of items, and each one can have background processing associated with it. The UI should reflect either... |
In Domain Driven Design, the Domain Layer can have several (traditional) services. For example, for the User domain, we may have:
A UserFactory, that builds User objects in different ways
A UserRepository, which is responsible for interacting with the Persistence Services in the Infrastructure Layer
Is a UserService ... |
I try to write "clean code" for most of the time. But practically find it very hard, meaning - gradually business requirements changes dramatically or the business requirement which seems like just a condition force to modify existing code.
If we go for "extend" instead of "modify" approach, implementation seems clean.... |
Using C# it's common practice (I think) to omit indentation and brackets with nested using statements like this:
using (var fileStream = new FileStream("filename"))
using (var streamReader = new StreamReader(fileStream))
using (var myCustomReader = new MyCustomReader(streamReader ))
{
///...
}
I've been refactoryi... |
I have a table of data and I can create , update and delete rows. I have apis to do these operations. The following steps happen
I create a row and send a create request to server.
I update some values in the row and send an update request before the response of create has come.
In server since the create row has not ... |
I'm trying to add error handling to a function that reads data from a DataSource (which performs all the parsing etc. required). Unfortunately (due to a lack of versioning until now) some of the values that I try to read from the DataSource may fail to parse (because they are malformed or simply missing), resulting int... |
I need to implement JWT tokens in my ASP.NET Core API app to handle authorization.
My question is, what is the risk of generating my own JWT token within my API app as opposed to having it handled for me through a third party solution such as Azure Active Directory B2C or Identity Server?
There's a nice article written... |
I keep running into a problem at work, and I'm hoping that others know a solution either from personal experience or from best practices.
I am not a programmer. I do, however, heavily use RDBMS tables which are populated by code that our programmers write. I also use other products of our developers'. Most often, these... |
I am building a web app with a lot of different API calls: our own proprietary REST API, third-party library API calls, etc. All of these calls either retrieve data, update data, delete data, or create data. Virtually all of our third party dependencies provide JavaScript APIs as well as Node APIs. Initially I gravitat... |
I am writing a library for some data structures in C that will be used in embedded systems. I have had issues designing and coming up with a solid error handling plan. This API is only subject to logic errors which is why I am so conflicted. By this I mean the preconditions might be: "x != NULL" or "index < size of con... |
I am designing a program with the flow as outlined below. Note, these are all network calls, there is no system I/O (hard drive).
Initially, multiple independent API calls need to happen - they don't rely on the others at all. The response from these will be processed and if they meet certain criteria, they should spa... |
Context
I recently read about the object-oriented technique of making a distinction between objects and passive data structures, best summarized in Clean Code:
"Objects hide their data [...] and expose functions [...]. Data
structures expose their data and have no meaningful functions."
I am considering using C# s... |
I’m trying to figure how best to define a Use Case using Clean Architecture and DDD. Let’s say I have an application that handles the pick, pack and shipping of a delivery. Here is the flow:
User enters a deliver to populate the screen with shipping information
User selects line items and clicks a button to Pick
Use... |
The definition of UTM(Universal Turing Machine) is a Turing machine that can
simulate other Turing machines, so as far as I can guess operating system is a
UTM, since it can run multiple programs on a OS.
|
We know that writing JUnit tests demonstrates one particular path through you code.
One of my associates commented:
Manually writing unit tests is Proof By Example.
He was coming from the background of Haskell which has tools like Quickcheck and the ability to reason about program behaviour with types.
His implica... |
I have data flowing from Kafka into MongoDB real-time. This is just raw data and various APIs are served using this data in real time.
The APIs respond using aggregation queries. However when data to be aggregated is large, the response time of the API is too high.
What technology or methodology can I adopt to achieve ... |
i am faced with the following scenario and i wonder if you guys have some tips for me on how to approach this.
One of my colleagues is going to leave the company in a few month and i am ordered to do a rewrite of his application, since the technologies he used are outdated. Problem is, there are no requirements and th... |
I have some Scala code that I wish to unit test using ScalaMock:
class CancellationManagerSpec extends FlatSpec with MockFactory {
"Cancelling a shipment" should "check shipment is not already shipped" in {
val manager = mock[CancellationsManager]
(manager.checkStatus _).expects(*, *).returning(true).once()... |
I if may point out I don't have a code issue nor the requirement for code review, hence posting here.
I'm generally looking for a better understanding on how to truly architect a SignalR .Net Client project to prevent multiple HubConnections being instantiated.
I/We have a prototype in a staging environment, which succ... |
I have a mainly Scala application and I am interested in approaches to integrating Python code into this application in a way that is proven by you personally to be successful.
In this context
integrating means allowing Scala code to call Python code, somehow, and use the results or access the exception
successful mea... |
I have some code that reads five numbers from a database:
class Repository extends DatabaseRepository
{
function getCoefficients(string $model)
{
return $this->getDatabaseLink()->query("
select a, b, c, d, e from coefficients
where model = ? and active = 1
", $model)->ge... |
Say that we have a class Car that contains objects of type Wheel
class Wheel {
public:
void SetFriction(double f) {
friction = f;
}
private:
double friction;
};
class Car {
private:
std::array<Wheel, 4> _wheels;
}
Now, I want to offer the owner of a Car access to the friction of the Wheels.... |
I'm working on a web application that manages specimen freezers so our researchers can manage and inventory all the gross stuff they've made. A freezer looks like this:
1 Freezer
+- X Racks
+- Y Boxes
+- Z Cells
+- 3 Cassettes
+- 5 straws
So, pretty much what's going on is I have a potentially inf... |
Notwithstanding its popularity, is there any empirical evidence that shows that Dependency Injection (and/or using a DI container) helps with, say, reducing bug counts, improving maintainability, or increasing development velocity on real-life software projects?
|
I often come across methods/functions which have an additional boolean parameter which controls whether an exception is thrown on failure, or null is returned.
There are already discussions about which of those is the better choice in which case, so let's not focus on this here. See e.g. Return magic value, throw excep... |
Say, I have a table Categories. On a page I have a header and for each category the colour of a header varies.
A colour is of the presentation level and I've heard that what's related to the UI/presentation level shouldn't be stored in a database.
There must be exceptions. However, in this case I figure that a colour ... |
I inherited 1 million lines of C++ legacy code. Throughout the code variables like bCPCHAR bPCHAR, bCPDOUBLE and bPINT are used. They are defined like this:
bCPCHAR: const char *
bPCHAR: char *
bCPDOUBLE: const double *
bPINT: int *
I was thinking of removing this level of indirection, especially because bCPCHAR and ... |
eSpeak implements SSML parsing. SpeechSynthesisUtterance, at least as implemented at *nix, does not parse SSML input at Chromium or Firefox browsers.
How to identify and extract the relevant portions of eSpeak for the purpose of including the code at Web Speech API implementations at modern browsers to be able to parse... |
one of the first modules I’m working on in a python program I’m putting together is a journal.
I’m getting comfortable using the print function, but for this project it would be great if i Could differentiate some of the text output from others. For example, here’s a text output sample from the program:
November_29_201... |
We have an application that has a mix of both fast (< 1 second) and slow database migrations (> 30 seconds). Right now, we're running database migrations as a part of CI, but then our CI tool has to know all of the database connection strings for our app (across multiple environments) which isn't ideal. We want to chan... |
I’m new to API development and I have a question that might seem dumb, but I literally have no experience with API design, so bear with me.
Having said that, my question is: should different resources point to different scripts on the server? Or all resources should point to the same script, with different arguments?
E... |
I understand task as task in C#, but this questions is not related to C#.
Let's say I have single thread and two tasks (both CPU-bound). I would like to run them concurrently, without running one of them at the expense of starving completely the other one. How this could be implemented without assuming the code will so... |
I'm trying to understand how this method works and everywhere I check it I find there's something faulty or maybe it's that I'm not understanding something from the method.
Here there's an explanation of the method for reference.
Some things of the method don't make much of a sense for a while or do-while loop. I mean,... |
We want to design a solution for generation and validation of OTP(One Time Password) process. We decided to create OTP process as a separate micro service. Since OTP need to be communicated to users we felt a need to create a separate micro service for communication (SMS, mails etc.).
While designing we came up to a p... |
I have 4 entities: Event, Message, Flow and Document.
Event table stores a limited (seeded) number of records. Message has many events and each event can be related to many messages. The name event_message was given for the intermediate table.
As you can see, the convention for intermediate tables are: {tablename}_{t... |
I've been using the APIs of a ticketing service which returns arrays of data more or less complex based on the entrypoint called. In order to simplify my life when consuming such API I wrote some classes to map locally arrays to objects so I can:
get suggestions from the IDE when coding instead of checking always the ... |
This is more a question about structure than coding. So i have a class named Planet and all planets have their modifiers for example: Is breedable? Damageable? etc. I already have a base planet class but i dont know how i will do that in a scalable way since i need to check if any planet has a certain modifier.
BasePla... |
So I've been flirting with Event Sourcing and CQRS for a while now, though I've never had the opportunity to apply the patterns on a real project.
I understand the benefits of separating your read and write concerns, and I appreciate how Event Sourcing makes it easy to project state changes to "Read Model" databases wh... |
We know that for Database Systems - the Consistency in ACID properties is part of the acronym:
A - Atomicity
C - Consistency
I - Isolation
D - Durability
We know that for NoSQL Systems, the Consistency in the CAP Theorem is part of the acronym:
C - Consistency
A - Availability
P - Partition tolerance
Michael Nygard wri... |
I have a usecase where I am supposed to store entire payload from a third party API in addition to the DTO, say XYZDto, its translated to.
There are two ways to achieve that -
Translate the payload into DTO as it is and when it comes to converting it into corresponding entity, I would do entity.apiPayload = convertToJ... |
I have various types of tasks, each task involves the following -
Use an XyzAPIProvider to query and obtain a payload
convert the payload into a list of XyzDTOs (ModelMapper)
convert the list of DTOs into list of entities (XyzDto2EntityConverter)
store the entities into database using JPA repository (XyzRepository)
... |
I'm wondering if there is a any standardised terminology surrounding the following concept so I can try and research some best practices... here we go
In my current place of work on our database we have what we refer to internally as 'validation groups and codes'. A typical example of their use would be for select list... |
Given a recursive subroutine in single threaded environment which starts numerous asynchronous I/O operations and registers callback functions for each of them. This callbacks will be called on the completion of the operations.
Which ways are recommended to detect when all of the I/O operations are finished, in other w... |
Application I am working on requires text contents to be extracted from various proprietary document formats like Microsoft word documents (doc, ppt, xls ), pdf and etc.
I am planning to implement a micro-service which takes document in proprietary format as input and returns extracted text as output.
This solution r... |
I'm making the tables for an application, and I need many tables with images.
Instead of storing the BLOBS on each table, I'm thinking on storing all the images (BLOB) on a single table, to unify the processing of all images with a small set of routines.
I'm not asking if I should store the images on a table made only ... |
In the past, I've always opted to write scripts for my sites (such as things that did DB modifications, pre-load data, etc) via sequential code, meaning something like
$mysql = new PDO();
$data = $mysql->query();
$updatedData = doSomething($data);
$mysql->query(... $updatedData ...);
At most, I'll include a file at th... |
I am trying to understand how to separate the domain model from the persistence mode so that the two can vary independently as described here and here
I understand the benefit of mapping the ORM directly to the domain model i.e. speed of development. This would be my normal approach.
Say I wanted to separate the domai... |
I'm developing an application where it read data from different data sources. And then those data should be pre-processed and then go through some chain of steps (Filters ?) where those data will get processed and augmented. Finally those data should be written to a common data base.
I'm thinking of a Pipe and Filter ... |
So far I put functions into objects, if those functions work exclusively on the object's variables/state. Basically I'm following a non-anemic/rich domain model approach.
However, it becomes more difficult, if the behavior is only partially based on the object's state. In those cases I see two options:
Non-anemic appr... |
I have a base class called ProductRepository and there are other classes which extends it; such as PushProductRepository or SocialProductRepository.
class ProductRepository implements ProductRepositoryInterface
{
private $product;
public function __construct(Product $product)
{
$this->product = $pr... |
We have a set of micro-services all built according to the Domain Driven Design (DDD). The micro-services communicate via Domain Events with each other (OrderSubmittedEvent, CustomerBilledEvent, ...). We implemented everything with Spring Boot and use JMS with ActiveMQ as the message broker. All events are published to... |
Is there any sort of concept in DDD related to an "Application Gateway"?
I'm defining an "Application Gateway" as an API layer (REST, GraphQL, etc.) that provides a single interface for clients to interact with.
This would be in contrast to the client talking to the application layer for each bounded context.
This appr... |
I have a set of annotations which are used for tracking failures/success of a function.
Now, there is a class A which has a function f(). This function needs to be invoked for different business use-cases.
What is the right way to track failures/success per business use-case basis?
One of the possible approach can be c... |
I want to manage music notes in a C# program, and I wrote a couple classes for that. However, I think I'm having trouble respecting the DRY principle. Either this or I'm overthinking things. Sorry if the question has already been treated somewhere else, I couldn't think of more explicit keywords and yet found nothing a... |
I heard rumours that when a new program is executed in Windows 9x, that app had to specify how much memory it needs to allocate beforehand. How is this different in Windows 10 ?
|
Default values are often suggested to be part of failover mechanism for microservices. At a high level, for any services (say microservices here) the nature of the operation can be broadly classified as Read Or Write.
Having default values for Write operations doesn't sound reliable.
Return values for Read operations ... |
There doesn't seem to be a lot of literature around the best practices when it comes to containerization of Java applications and I'm curious as to what the logical approaches are. It used to be that we needed to setup some sort of server, configure its runtime (libraries, etc.), and deploy packaged Java applications, ... |
I've looked at some other threads but they don't quite answer my question, I think...
I have a CircularBuffer object which I have separated from a ThreadSafeCircularBuffer object so that the CB logic is separated from the concurrency logic, mostly for a clear separation of logic/function and partly to make testing easi... |
I am developing a website that accepts uploading a specific type of data. In particular, the data must be a human-readable text string in the order of thousands of characters. The data is input into a text field that is then uploaded to the server when the user clicks a button.
I want to ensure that all data entered in... |
Note: this is a follow-up to this question.
I am developing a website that allows users to upload large chunks of data to my Java backend. Once validated, the data must be stored on disk. Here, "large" means in the order of 10 KB up to 100 KB.
Given that a large number of users can submit large chunks of data at the sa... |
I have written a Monix Consumer that wraps a Kafka Producer and am at a loss about what to name the result. KafkaConsumer is already a class, which has essentially the opposite meaning which the developers in this code base are much more familiar with. The opposite names are because Kafka names accordingly to consumi... |
The codebase consists of 190 Fortran 95+ source files, and directory of binary coefficient files required for the use of the code. The binary directory contains about 4000 files, some of which are greater than 100 mb, but no larger than 200 mb. The vast majority are less than a megabyte.
The files do get updated occ... |
This is a question about how to work in teams.
Recently I worked on my first larger (~80 classes, Java) programming project with a team of 6 people, though only 4 of us were continously working on the code. We distributed the work to be done early on and at some point I needed to call a method that was not yet impleme... |
So, earlier I asked this question about infinite-depth objects and arrived at using the Composite pattern to model that a freezer contains a rack contains a box and so on and so forth.
There's now been an ask to add the ability to move a container (and its contents) from one hierarchy to another. So, i may start with ... |
I have a hierarchy of functions, many functions are called by a single function.
There are three options:
Use defun: i.e. all functions are global even the ones that are only intended for internal use by a single function. Use a package to export the functions that clients should call.
Use labels so that the function... |
I'm working on re-writing a code base in the shipping/receiving domain and my current plan is to implement the receiving part using a state design coupled with a command/decorator pattern. I wanted to pick some other software engineer's brains to help gain different perspectives.
Consider "Receiving" to be the process ... |
I'm trying to develop an OSGi application to handle my game engine. This game engine will be making use of the Entity-Component-System pattern. Part of this pattern is the use of GameSystems.
I had initially planned on exposing the GameSystem interface as its own bundle; this way other contributors can create their own... |
So this isn't a question on how to do it, but more of a clarification on how it works. I'm using Vue and I'm creating a file that's usable by on both the client side and the server side (logic should be consistent and changes should be easily made).
So what the file uses is the module.exports object. I can understand t... |
I am trying to split a dynamic number of ranges with associated attributes, so that whenever 2 or more ranges overlap, the overlapping section(s) are split into unique ranges with the combination of all overlapping attributes. To be more specific, say I have
1-10 - attributes a
7-12 - attributes b
9-15 - attributes c
... |
I'm writing a Linked List in C.
list.h
typedef struct list_struct * List; /* Defined in list.c */
List create_list();
void destroy_list(List list);
void list_add(List list, void * item);
void list_remove(List list, int is_target(void *));
... /* Other handy functions like 'list_size', etc. */
list.c
typedef struc... |
I am writing a utility in Go that concurrently attempts to crack passwords given a salted hash and the salt. That part works fine, but now I'd like to take advantage of go routines and have them crack concurrently. The issue is that the word list is shared and they all iterate line by line over the same word list. Shou... |
In opening I would like to say; I'm pretty new for programing. I'm working with JS for a year. Using Sencha's ExtJS and usign Bryntum's Siesta test tool for unit and integration(ui) tests.
Right now developing an application through Mastering Ext JS book. I've started to write tests only for a couple months. First of a... |
For example, let's say I have this wonderful interface:
public interface BestService {
public String whoIsAGoodService(String serviceName);
}
Going down it's implementation, we can find the following method:
@Override
public String whoIsAGoodService(String serviceName) {
String ipFromName = this.findOutIpF... |
Let's say I have an interface for the Command pattern with undo functionality:
interface ICommand
{
void Execute();
void Undo();
}
This comes with a contract. Basically the command can be in one of two states - either it has been executed or not, and that determines the only method that can be called.
To add a... |
In the advice of Mockito about how to write good tests, it is written that we should not mock value objects (https://github.com/mockito/mockito/wiki/How-to-write-good-tests#dont-mock-value-objects). They even say
Because instantiating the object is too painful !? => not a valid
reason.
But I don't understand. What... |
In a REST API interface, should I explicitly check that the client used only the parameters used by the API, and return a HTTP 403 if a parameter the API doesn't know about was included in the request?
A bit of context. I'm working on a API which minifies JavaScript and LESS files. Originally, JavaScript files were min... |
I have a question which I'm not sure how to generalize and ask properly, so I'll try with an example.
Suppose that I design a parking lot management system. In my system, I have the objects Car and ParkingLot, where ParkingLot holds a map from car registration number to Car objects. One of the methods of ParkingLot is ... |
The objective of my application is to control and monitor sensor based equipment (temperature, humidity etc). Data from the equipments is transmitted using GSM, Ethernet or Serial port channels. When data is obtained the program needs to store it in the database and then to notify users in their UI. Users are able to s... |
From the official docs:
AVOID defining a struct unless the type has all of the following characteristics:
[...]
It has an instance size under 16 bytes.
[...]
I know that one reason for keeping it under 16 bytes is that structs are intended to be used on the stack. However, are there other reasons?
I... |
We know that in Prolog - non-deterministic predicates are a feature used to whittle down combinatorial problems.
In Haskell we see some similar non-deterministic behaviour to Prolog in the List Monad.
In Haskell we also see non-determinism in choosing thunk evaluation order:
But there is nothing telling GHC which of... |
In the tutorial I'm doing it uses interfaces to inject things, for example it uses a IHotDrink interface, then creates a Tea class that implements IHotDrink. It then has a third class called Restaurant that has a IHotDrink field inside the class and assigns a value to it in the constructor. It then goes on by injecting... |
From Effective Java 2e by Joshua Bloch,
An example of the sort of situation where it might be appropriate to ignore an
exception is when closing a FileInputStream. You haven’t changed the state of
the file, so there’s no need to perform any recovery action, and you’ve already
read the information that you need f... |
These days, all I hear is how MVC should contain additional layer called services, turning it into SMVC. But to me, it seems like too much of a decoupling and instead want to engineer my app something like this (example for changing user name)
View sends new input to Controller
Controller sends the request to Model w... |
C++17 introduces the [[nodiscard]] attribute, which allows programmers to mark functions in a way that the compiler produces a warning if the returned object is discarded by a caller; the same attribute can be added to an entire class type.
I've read about the motivation for this feature in the original proposal, and I... |
Recently in my company we had a project where the deadline was very tight, and everything was going according to plan until I was unavailable due to extreme personal issues.
Eventually we missed the deadline by 4~5 days.
What are the usual recovery plans for these conditions? should my company attempt to outsource a de... |
Every day I see SO questions with some variation on this theme (C#-ey pseudocode)
method MyButtonClickHandler(){
string sql = "SELECT * FROM table WHERE column = " + myTextBox_Text
sqlcommand cmd = new sqlcommand(sql, someConnectionString)
datareader rdr = mycommand.ExecuteAndGetReader()
while(rdr.HasResultRow... |
Currently my architecture is very much event driven. Every API request is served as quickly as possible sending events that run after the response.
However this is a monolith and the event handlers run under the same process that manage the API. Responding a single API request is efficient, but the process CPU will qu... |
Project description:
I have a nodejs project where I try to build a bluetooth mesh like network,
each node consists roughly of 4 parts the frontend part, the message broker, a bluetooth client and a bluetooth server.
The message broker creates the bluetooth server, client and all the dependencies and runs in its own no... |
Imagine a Control is being created.
It has some DependencyProperties and there are some properties which depend on the DependencyProperties, but doesn't need to be seen or updated from the outside.
For example: Foo is a DependencyProperty (that can be both read and write from the outside) and Bar is a common property ... |
To learn CQRS I'm putting together a really simple command/command handler implementation. In a lot of examples, I'm seeing the concept of a "Command Dispatcher". I'm not seeing a lot of literature on it.
I'm wondering what a Command Dispatcher is and why is it necessary? Is the Command Dispatcher and the Command Bus t... |
Is many Levels of multilevel inheritance is considered bad?
This is my design
BaseFileProcessor
RefundFile Processor inherits BaseFileProcessor (Has n child class)
FailedRefundFile Processor inherits RefundFile (Has n child class)
FailedRefundFile for CardsPayment inherits FailedRefundFile (n child class)
|
I have a need for a distributed data store, where existing solutions may not work as the computers these will be running on will be extremely resource limited, for instance 64-128MB RAM. Plus, as a fun exercise.
I'm looking at writing a simple implementation of the RAFT algorithm, however the data store, which will si... |
I have only theoretical knowledge about ESB.
Use case:-
I have ecommerce like application where I can receive orders from multiple sources in different formats .
Once application is submitted I need to send emails to couple of systems
Once application is submitted, I need to submit one output file to third party sy... |
I'm reading Elliotte Rusty Harold's Java Network Programming. In chapter2, I've read the text about makrSupported() method of InputStream class. The author explains that this method is not object oriented. Because the function for checking mark() available is not provided by separated type. How is the design to be more... |
There is web App_1 which is on dot net while another web App_2 is on java. App_1 need to interact with App_2.
App_1 can be inter or intra company application.
My question is does in general prominent ESB products provides the way dot net application send the dot net specific object/message on channel, then
transformer... |
As mentioned in wiki,
A service-oriented architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. The basic principles of service-oriented architecture are independent of vendors, products and technol... |
I am building a web/mobile application with Django Rest Framework (DRF) that enables authenticated users to post snippets and/or vote for other user's snippets. All users (authenticated or not) can also get the list of recent snippets (paginated, ex: 5 per page). Snippets, users and votes are stored backend in database... |
The GoF book "Design Patterns" describes the Memento pattern as an object encapsulating its state in a separate object. However, the book specifically describes the memento for use with a specific caretaker; in their example, a undo/redo provider.
However, this pattern, especially in C# when the Memento is made a struc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.