instruction
stringlengths
34
36.1k
We have a large number of classes that is generated by JAXB. There are a couple that have identical fields and I want to see if there is a clean way to map class A to class B. Example: public static class ParentA implements ... { public static class A implements ... { protected String name; } } public s...
I'm trying to implement CQRS for a queue system where user can join a queue by clicking a button. The system will tell the user if queue is full. When the user click the button, it raised the command and triggered event like "user queued at 07:00 AM". The handler for this event then (asynchronously) add a new partici...
I am planning to develop an Event Planning Application. Currently I'm in the stage of planning the app structure, for example database schemas. Basically there will be two kinds of users: The event planner: Has access to a dashboard, list of guests, etc. The event guest: One guest is assigned to one event. Can...
I am planning on creating a wrapper class in c# which will call cryptographic functions provided by .Net Framework, just to make sure I am clear, I am not writing any cryptographic algorithm, just writing a wrapper to facilitate requests coming from other modules of Applications. I have seen a lot of examples in whic...
I would like to create a dll library that will be loading in runtime. The library'll be using internally COM objects with MTA flag. The library will be created in main thread. So I have question: Where there is best place where can I call 'CoInitializeEx' and 'CoUninitialize' functions. In the my dll(init/deinit functi...
This is the first time I tried TDD. At the first time, my controller tests looks like this use RefreshDatabase; class ControllerCustomerIndustryTest extends TestCase { use RefreshDatabase; public function testIndex() { // } public function testStore() { // } public f...
I want to ask: Whether the Role class violates Single Responsibility Principle in SOLID ? I think deleteAccount() is not belong to Role class but Role class is way to extend code in the future There are deleteAccount() in Role and Account. That is ok ? Admin and Moderate violates DRY principle ? Because the deleteAc...
My question is based on a few assumptions so please correct me on any of them below I know that TCP has always been socket based In order for a server to maintain that socket, a thread has to block and wait for IO on the server side A modern web server has to handle at least hundreds if not thousands of requests per s...
Right now we have a highly analytical system which collects tons of various metrics. We need to display this data in a web ui for users to consume. Since we are in early stages of development we are throwing all data into google bigquery, when a users visits the app we run a cloud function to request the data from bigq...
In my application I have entities like employee, client etc. Each of these have methods AddEmployee, RemoveEmployee, AddClient, RemoveClient. I don't want to keep fields like EmployeeName, EmployeeAddress in the same class with AddClient. It doesn't make sense to me to call something like this Client.AddClient(). What ...
I work with some not-monolithic applications, meaning that at some level, it depends on other applications to do the work. At the moment, each application on our stack, when there is an API change, generates a new API SDK, that can be used by other applications that rely on it. The issue is that this adds an explicit d...
Consider class Crate that is a value object. Crate represents a valid 3-dimensional box. In constructor I validate the given parameters, and I throw an exception, if supplied dimension parameters are invalid: class Crate { protected $length, $width, $height; function __construct(float $length, float $width, f...
I'm trying to document some of my JavaScript according to this JavaScript Documentation guide and came across member access (private, public, protected). I was wondering what the classification would be of a member/function that was defined in the child class but only available in the child class's and it's parent's sc...
The Single responsibility principle is defined on wikipedia as The single responsibility principle is a computer programming principle that states that every module, class, or function should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirel...
I am reading and hearing that people (also on this site) routinely praise the functional programming paradigm, emphasising how good it is to have everything immutable. Notably, people propose this approach even in traditionally imperative OO languages, like C#, Java or C++, not only in purely functional languages like ...
As part of a larger project, my team is building a microservices API layer. We do not have experience with building microservices so we have been trying to figure out how to go about the project. The first decision we are working on is if we should use a mono-repository or split each microservice into a separate reposi...
I read theory but I need practical architectural advice on the actual implementation in java language for microservices. In the context of the attached screenshot. Here is my setup. Order Project consisting of the following 4 Modules. Order History (Jar file, Docker Container) Order Placement (Jar file, Docker Contai...
We've been having some debate in the office as to the names used to describe C++ .lib and .dlls When creating a statically linked library, you end up with a .lib file. When creating a dynamically linked library, you end up with a .lib and a .dll Two questions: Is the .lib file that's generated the same in both cases? ...
I have a class with a (simplified) method which returns a string like this : private String doStuff(String currencyCode, BigDecimal amount){ StringBuilder sb= new StringBuilder(); NumberFormat format = NumberFormat.getInstance(Locale.FRANCE); Currency currency = Currency.getInstance(currencyCode); try{...
I am planning to write a program that will produce digest logs for file changes in a particular directory. The idea is that whenever a file is deleted in a particular directory, it will show up in the digest log. In the case that a file is heavily modified and not outright deleted, I also want it show up in the digest ...
I am having a hard time trying to understand the MVC pattern, in particular the role of input fields in this pattern. 1. Conceptual question. Let's say I have a document as model and a text area displaying the document. Is the text area a view or a controller? Because the text area shows the document (for example, af...
Say, we have a public facing REST API which lets user manipulate data using POST, GET and DELETE. The API is exposed via Service A which at the backend calls Service B where most of the business logic is. We recently had a discussion about how we should handle deletion. Approach 1: Service B should provide an explici...
I've got a question closely related to this one. I'm cleaning up a colleague's mess, and I'm afraid that that means trying to work with a language -- JavaScript -- that I'm almost completely ignorant of. Basically, we've got C code, with a bunch of enums defined in headers, passing data to JavaScript, which uses a bun...
I'm doing my first Domain Driven Design (DDD) implementation. My architecture is comprised of .Net Core for defining my domain model, services, and building AWS Lambda functions. I am using Lambda functions as entry points to functionality into each bounded context. In researching DDD, I've learned one approach for c...
I often have to execute some function, save the output, and depending on what the output was, do different things. And then later on use the output as input to more functions. It results in a very specific pattern of code. I feel like I'm missing something simple. ... as if some logic here could be somehow streamlined...
I am writing a serverless application using AWS SAM. I am wondering, would it be a good idea to include in my template a definition of a CodePipeline (and CodeBuild for that matter) for deploying that very application? The idea would be that on the initial deployment of an app, a CloudFormation stack would be created, ...
So, I had a coworker complain about how I made the following code: ... var foo = getKendoDropdown(window.foo); var bar = getKendoDropdown(window.foo); var sna = getKendoDropdown(window.sna); var fu = getKendoDropdown(window.fu); ... function getKendoDropdownList(controlId) { return $('#' + controlId).data("kendoDro...
I have a microservice based application like so: User.Microservice - stores , user information. Product.Microservice - stores products that user created. Order.Microservices - stores product orders Stack: RabbitMQ - for Event based communication MongoDB - for Data Storage Each service has a public HTTP REST API. Each ...
What is the best way to represent two actors, of which sometimes it could be the same person? I have a case where we have approver 1 and approver 2. In most instances, #1 approves and it flows to #2. In other instances, #1 and #2 are the same person, so they can act as both. I tried drawing a box around the two actor...
I’m reading about microservices and a consistent message I’m getting is that microservices should communicate via asynchronous means only. But I don’t see how this can work while also providing feedback to the user? Taking an e-commerce application as an example, we may have an OrderService and a PaymentService. The cl...
We have a PostgreSQL database which we use as an intermediate staging area for our ETL pipelines. In the tables of this database, we have kept the time-related audit fields like creation time and modification time as integers. I'm not exactly sure why but I think the idea was to make the join conditions simpler; in thi...
Assume I have the following method that does the same logic but deals with different objects (It's more a pseudocode): private <E> List<E> updateOrInsert(List<E> list) { if (list == null && list.size() == 0) { return list; } if (list.get(0) instanceof Explore) { List<St...
At my current company, the project I work on is coded in Java, at least for the systems / backend part. Whenever I get assigned a task dealing with the Java code, it take me hours or even days to figure everything out and apply my solutions. The reasons are: 1) Very large Java EE code base 2) A lot of abstraction 3) G...
Does the memory allocated by class pointers get freed by the class destructor once the class method/function goes out of scope? Or do I need to manually free the memory allocated by the pointer (C++). For example, here's a snippet of some simple code : double * const Area() { double * Area = new double; *Area = i...
I am a novice Visual Basic user. I am an engineer, but I don't have much programming experience. I recently purchased the source code for a data recovery tool. I have decided to work through it, line by line, in order to become familiar with the tool itself and VB in general. Hopefully I will be able to maintain what w...
I saw the term code vetting for the first time in a gerrit review page. What does it mean? The line I came across: "No XYZ check was done. However, if this project is intended to be shipped in the future, please make sure XYZ Code Vetting is done."
To make an installation of opensource software for the Windows platform single click, I am trying to convert the setup.ps1 into a setup.exe file. (To make a powershell script executable in a single (double) click, the user might/is still required perform additional actions). So to do that I downloaded PS2Exe from https...
I have an application written in C#. This app uses a GUI for message display and user input, and the GUI is connected to the app via an interface class: public interface IEndUserInterface { void Reset(); void ShowMsg(Tuple<string, string[]> msg); void ShowBoolDialog(Tuple<string, string[]> msg); [...] ...
I had the idea to have a route in my REST API that returns serialized (PHP) helper objects. The client code then can use those objects to format some complex JSON structures for the next request. When the implementation of the REST API changes, I don't have to change the client code. Is this a good idea/common practice...
I support a large enterprise software project which frequently receives enhancement requests from our customer. The customer will only pay for the work up front in fixed-price contracts. We provide a SWAG estimate first, then provide a detailed estimate after they green light the SWAG. The detailed estimates are time ...
In Kotlin the powerful construct of delegation can be used to extend functionality of existing interfaces by reusing existing implementations. class Demo : Map by HashMap {} Questions: What should I be testing? Testing hashmap from the example is not the target of this test. It seems very verbose to verify the comple...
I am working on a SaaS project that will have a trial when the trial is ending I get a webhook notification when 3 days are remaining. I do some stuff with this and one of the things is I update user.company.stripe.trialEnd to the value Stripe tells me for the ending time. When a trial ends I'd like some cron/Lambda j...
How I can consolidate multiple projects by keeping the same namespace and move them into Domain Driven Design project? We are not a software shop and our code is not an API with no intention of being extended. Plus we have like 150 projects in our solution code base makes comprehension hard for developers and IDE perf...
This is basically a code development question that deals with frequent changes to one or more java files among many thousands. A few years ago, as a software intern, I was given a large java / jsp code base and my mentor set me up using intellij IDE to build a WAR file for a web application (a student portal). I would...
I'm working in Java Spring, and I have typical service and repository layers. The repository grabs a JSON; passes it along to the service; service maps the repository response to a DTO. I also need to perform some event logging afterwards (send these events to an auditing REST service), which requires some properties t...
I am a self-learning programmer (with a fair share of python knowledge), and currently a company asked to develop a simple application so that they can track employee expenses (and I thought of using Django) However, they require the app database remains installed in one of theirs internal server structure. Question: H...
Look at this code: Console.WriteLine(user.name); Console.WriteLine("**********"); // 10 stars //... Tomorrow, I needed to use 20 stars instead 10 stars. Okay I would change it: Console.WriteLine(user.name); Console.WriteLine("********************"); // 20 stars //... It gives me an idea to write a method for this wor...
A couple of months ago I wrote a C++ program for computational mathematics that was supposed to compete with a highly optimized C code. After a while I did manage to get it fast enough to beat the C code, but before that happened while analyzing what was slow, I was really surprised about how long time it can take for...
I'm developing a Scrap app to extract some information from a sit. To get that information I have to be logged in to that site. So I use Http post and pass the data needed for login using FormData and log in successfully, so I can browse the private content of that site. My question Is: "How can I tell if the user is l...
I use Spring for backend work and Angular for frontend and maintain each in separate repositories. This was because I considered both the frontend and backend completely separate projects, IE a new frontend can be developed in an entirely different framework and it'd still work with the existing backend and vice versa;...
I am writing an application to be used as a local disc documents store similar functionality to Firebase or MongoDB. The gist of how it works is a column hash table. For example: Say I have a user document { "first": "stack", "last": "overflow", "age": 2147 } I basically iterate each field as a column and sav...
I am currently working on a project which will consist of multiple sub-modules. Each sub-module is developed and unit-tested in its own repository. All sub-modules have to be integrated in one main-project repository. Furthermore I have some "support-functions" modules which are implementing for example a logging tool...
Is it possible to send a funtion or even just code via TCP in python (it is very possible this question is rediculous I have no idea what I'm doing)
We've created a .Net Core Web Application and are deploying it as a stand-alone exe. The main reason for deploying it stand-alone was to not be dependent upon the version of .Net Core installed on the target Windows server. We'll be creating many instances of these environments. This Web App will act as a service for a...
The Named Parameter Idiom as described here mentions that there will be a performance impact when not using inline. Since each member function in the chain returns a reference, there is no copying of objects and the chain is highly efficient. Furthermore, if the various member functions are inline, the generated obj...
I have to manage item locations and life cycle as a new requirement. I'm not familiar in warehousing/inventory/storage systems, so maybe my question is trivial. The task: We have original items that will be processed multiple times. In case of some processing steps the original item will be divided into multiple sub it...
I am trying to figure out how to send push notifications back to the client in the following ActiveMQ scenario: I have a spring boot web application #1 deployed on tomcat on RHEL server. From the user interface (this consists of Javascript,jQuery,HTML,CSS), user clicks on a request files button, which calls a RESTful w...
I have heard of: “Programs must be written for people to read, and only incidentally for machines to execute.” ― Harold Abelson, Structure and Interpretation of Computer Programs and Donald Knuth said that too: https://www.youtube.com/watch?v=CDokMxVtB3k&feature=youtu.be&t=1768 but very often at work, I just read...
We have an enterprise software introduced as SaaS model, and we end up with a huge number of services which are sometimes duplicated but no one knows, so what might be good practice ways to keep track of those services and their business logic in order not to have duplicates which really jeopardize the software.
My current employer has a single namespace into which all microservices for all projects are deployed. Projects A, B and C all use microservice x in this common namespace: Rather than each design and implement their own microservice that performs the same behaviour (for example for some common domain object CRUD opera...
I'm stumbling trying to find a proper way to model this scenario: I have 3 different aggregates within same Bounded Context: A Student A University A University of Interest public class Student : Entity, IAggregateRoot { public string Name { get; } public string StateAbbreviaiton { get; } ... } public cl...
Not sure where to go for an authoritive/text book answer for this question. Suppose a service returns a list of something e.g. Customer, Employee, Fruits, etc. What should be returned when the list is empty? I am working with people using SOAP, and they are sure that just a "success" result is enough. Is there a analo...
Should constants of my class only be public if I know that they will be used from their users or doesn't it hurt to make all of my constants public per se? Is not exposing all constants cleaner?
I've got the following scenario: bool bWantToWait = getRandomBool(); if (bWantToWait){ std::future<bool> bSuccesfullWait = this->doStartWait(); } //lots of lines of code //even more lines of code //doExecuteSomethingWithAsyncCallback if (bWantToWait){ return bSuccessfullWait.get(); } return true; Now of cou...
I have two libraries that handle the mapping from one family of objects to another one. I had to create a middle set of objects for other transformations. So, the NativeConverters libray converts elements NativeElement to MiddleElement, and the ViewModelConverters library converts MiddleElement to ViewModelElements. I...
I am currently developing a simple web-based application that consists of various layers: Model Layer Performs simple CRUD operations and provides access to the databes. Implements functions such as get_invoice(), create_invoice(), edit_invoice() and so on. Service Layer Consolidates operations such as pay_invoice(), c...
Currently, I'm planning a new project of CI/CD with Azure DevOps (with Git, already committed) for an old Solution, which contains 17 C# projects. Technically, we have access to the source code and it's required to write all Unit Tests (since it wasn't planned with them); however, as it's advised in this article: Integ...
I'm having troubles with the issue of distinguishing between "real" 404s and 404s where the path is correct but the id, for example, doesn't exist when it comes to client side apps. Most REST articles and answers here talk about returning a 404 if a resource isn't found. I do understand that a REST URI points to a spec...
I have been reading a lot about Domain Driven Design lately, and starting to feel a little more confident, than when i first touched this topic. I'm using a Asp Core project, with class libraries for: PersistanceLayer DomainLayer(Service) ApplicationLayer UILayer Let's say I have an entity called "Company", this will...
Is there any way to create versioning for stored procedures? I have created an API which fetches data from a database using stored procedures. This API is being consumed from a mobile app. I released the v1.0 of API (www.example.com/api/v1.0/endpoints). Now I've to release the v2.0 of the API (www.example.com/api/v2.0/...
In my experience, the value of time mostly is represented by integer number, by programming languages (C/Java/Golang/Javascript(*)...), and by databases (MySQL, Postgres...), exceptions maybe some GUI/game engines and I always think it is normal. But when I thought more about this topic, I found that maybe it makes mor...
I decided to use Mediator Pattern (with Mediatr) to call my application layer. It's cool and I got how to work with it sometimes, but sometimes I get confused. For example, when we publish a document on our new product, we uses a RequestHandler to do everything and check all rules it needs, it's fine and works like a c...
I need some wisdom on this. Currently I'm learning about micro-services architecture, and so I decided to make a simple project in a micro-services architecture. The project I'm building is just a simple Inventory management application, where the functionality is, well just to add Item and information about it. So at ...
I have a set of pure functions that can be composed almost trivially in a pipe as initialValue -> [f] -> [g] -> [h] -> ... -> [m] -> [n] -> [o] -> outputValue The problem I encountered is that one of the functions in the middle of the chain (e.g. [n]) requires the output of one of the earliest functions (e.g [g]) in a...
I'm designing a backend webservice, and when an error occurs I'm returning it as a JSON to the frontend. This JSON contains an error code, which the frontend maps to an localized string and shows that to the user. Should my error codes be strings or integers? { "error": { "code": 9900, "message": "Invalid ID"...
I am building a common interface for several different backends that are shared libs loaded at runtime dependend on the used platform. It looks basically like the code below. My problem is, that while 90% of the functions of all backends are the same (just different implementations but same purpose) some of them have f...
I have an admin panel which can set a lot of options which will affect some other services drastically. For example I got one that if I create a different category I can just insert it in the Category table and then the front-end will be able to retrieve it. But I'm almost totally lost with what do I do with simple fl...
I am working on refactoring a project code that is wired up in a tangled way. It was started with decent dependency injection and over time with all custom requirements it looks it got tangled up. This is the outline of the service functionality 1. Get the request from the user 2. Infer some business logic based on the...
I would like help interpreting this flowchart. I don't know what k means even though they say what it represents in the question. I can quickly see that since dimension m corresponds to variable X that the first loop has to be iterating on X. Therefore A has to be X(k) → Z(k). Since I know the first loop is on X, obvi...
The title maybe it's a little bit confusing but I am certain that what I want to achieve is a common pattern, even if I didn't found anything on internet. I'm developing a web app that store encrypted critical user data in a database, through server. User must be able to see decrypted data every time access the app. No...
I'm confused about how should I declare an object that implements more than one interface, or derives from a class that implements one interface, and implements another interface itself. Let's suppose I have a generic DAO interface, as follows: public interface IDao<T> { Optional<T> get(long id); List<T> getAll()...
Is it good practice to clean up your DB after running integration tests (which tests APIs that put data into that DB)? I want to have a cleanup method after my integration tests run which will access the DB through a data access layer but is this recommended?
We develop an application using npm with several third-party packages. Now we want to release our app to the public. That we have to reference the licenses of the packages should be self-evident. But this third-party packages are also using third-party packages itself. How should we handle this packages? Shall we inclu...
I'm working on a very large research-led open-source project, with a bunch of other regular contributors. Because the project is now quite big, a consortium (composed of two full-time employees and few members) is in charge of maintaining the project, the continuous integration (CI), etc. They just don't have time for ...
I'm looking forward to the possibility of an algorithm or a way to track how much sale has been made on 3rd party's website because of my client so I can get the commission. For example if a user "A" jumps onto my application and finds a product "Z" if he wants to purchase it, A is taken to the official website of Z. I...
I need to request runtime location permissions for the FusedLocationProviderClient api and, once I have them, obtain Location objects and feed them to an algorithm that will make a query to an endpoint. The results of such a query will be used to update my map View. As of now, I'm using MVVM, so I have an Activity show...
I have a situation where I have different forms, each with 4 or 5 steps (components), and I decided to write one unit test per step. After doing it, I noticed they were very similar and I could just loop through them, changing some values based on the loop index. All good and worked fine, until one of the forms failed...
I'm developing distributed system and trying to use best practices of microservice architecture. I was faced with a situation when I think I need something like distributed locks. Since I have not so many experience in microservices and still not sure about the final solution. I need any suggestions, thoughts, best pra...
Say you have an AWS SQS queue. Your Publisher class and Receiver class is already unit tested. Now you have a worker process that uses the Receiver class to actually receive the messages from SQS. My question how do you usually test that worker process in a automated way just like unit testing?
I'm writing an application that needs to log error/ exception messages but should still continue execution if the error is not a fatal error. I was thinking of making a method that returns a Task but calling this method as a fire and forget and not wait for response from the method. What is the recommendation, is this ...
Java has a notion of separate InputStreams and OutputStreams. Your code reads from an InputStream and writes to an OutputStream. .NET does not have this distinction, instead it has a single Stream class which your code can both write to and read from, depending on the exact implementation. Capabilities can be determine...
I am trying to teach good engineering practices to my team, and in particular, walking them through the basics of PRs and code reviews on GitHub. One of my team members has sent me a request to review his PR, but has added a commit message without any detail, and so I would like to kick it back to him for a better comm...
I am developing a mobile application that will have both free and paid versions. The way I see how I could differentiate between what is a paid and free user is to set a property isPaid on their respective documents. What I want to understand is how to set the isPaid property on user's document securely. One option ...
I am currently working on a project comprising multiple sub-projects. Each sub-project, in turn, consists of multiple components, which might be shared by two or more sub-projects. Let's say, for example, that there are the following components: component A component B component C component D Each component has its o...
This question is more coding style related which is why this question is asked here. I'm new to Python, coming from PHP. I've been looking through Python style guides & code examples, I've noticed the None data type is used where I wouldn't use it. I always avoid using the None/Null data type. I always like to keep eve...
I have implemented a simple bit vector class. However, I have some problems with understanding, how to push data to it. In a standard vector, push_back inserts new element et the end. A similar logic can be implemented for single bit. However, I want to append number with a given precision. For example: 13 => 4bits (1...
For example, what would you name a module containing all of the Pydantic models for your FastAPI project? What would you put as a subtitle in your documentation below an example JSON api response? In XML you'd call it a 'schema' but I don't see that word used to describe this in the json world (because there's no schem...
I have a simplified producer/consumer pattern implemented below. The code outputs: "A" 1 second delay "B" 1 second delay "A" 1 second delay "B" ... What approach can I take here to get rid of the 1-second delay between different letters? What I'm looking for is something like "A" "B" 1 second delay "A" "B" ... ...
I rewrote a very long method in which some data is queried from a database, based on info about a particular account, which is queried first. I split out the account info into an immutable inner class AccountInfo. This is a vastly simplified and altered version of what its constructor looks like: private AccountInfo(St...
I always document my Python code with numpydoc style docstrings. For my private projects, I also generate the documentation as HTML and host them. That is super helpful because this way I can Google it easily. For my company, I didn't generate it and of course I didn't host it publicly. If documentation can't be hosted...