instruction
stringlengths
34
36.1k
I am using bool flag to call base class function when needed to imitate virtual constructor. I am using this way for inheritance purpose. I have a Base class constructor with int and bool. The bool part is there to check whether to call fun() or not. By default I make base class flag true. Then for Derived class I make...
Umbrella activities are defined as "the non SDLC activities that span across the entire software development life cycle". Considering this definition, can we say that project planning is an umbrella activity, as the plan continuously changes throughout the process? Are there any umbrella activities in software project ...
I have to represent a certain data structure, in which I have nodes that are related between them. Each node has its numeric id, and a list containing the next directly related nodes and another list containing the previous directly related. So my code now would be: class Node { int id; ArrayList<Node> previous...
I design and works on lot of projects involves REST APIs. But one question is always occur to me if it is acceptable way to do REST. So according to REST manuals online, REST is build upon two major HTTP concepts. HTTP Verbs and HTTP Codes ( their are other thing but I am focusing on these two concepts ). So If I nee...
Is it considered to be a good practice to convert all types of exceptions (exceptions from internal logic of application + exceptions from application's external dependencies - for example: File System) to application specific exceptions? For example, I am developing a Job Scheduling Software in Python (using layered ...
I'm looking for perspectives from other web/ui developers. I'm a UI developer and my company requires that I use components built by another team within the company. That team has developed some patterns over time that I would consider bad practice, but I thought I'd see what others think before I raise any awareness...
So I am asking this after reading the following: Why shouldn't I use the repository pattern with Entity Framework?. It seems there is a large split of people who say yay and those that say nay. What seems to be missing from some of the answers are concrete examples, whether that be code or good reasoning or whatever. T...
I have recently come across the terms migration pattern and refactoring on the topic of migrating monoliths to microservices. Is there any real difference between the two terms, or can they be used interchangeably?
I'm designing a database for name statistics (how many people where given that name). The data consists of names, and numbers for how many men and women were given that name within a time period (primarily 15 year time periods, but this varies). The data is rather simple, but I still keep getting stuck with the schema....
I am somewhat new to writing tests and I want to build that habit into my workflow. So for example I might write a test that a user can create a blog post however I'm not sure on how to do that effectively. Should I have a test case to verify that every field is validated? By that I mean I could either only write one t...
I know that triggers can be used to validate stored data to keep database consistent. However, why not perform validation of data on the application side before storing them into the database? For example, we store clients, and we want to perform some validation that cannot be easily done on DDL level. https://several...
Generally, we are looking to create a logging framework that can target human readable output as well as various structured data formats. So, a goal is minimizing code duplication in packaging the format functions. We created a library of functions that can be used to format log entries. The client can then iterate a...
In my C# solution, I have a Tests project containing unit tests (xUnit) that can run on every build. So far so good. I also want to add integration tests, which won't run on every build but can run on request. Where do you put those, and how do you separate unit tests from integration tests? If it's in the same solutio...
We are trying to move from a monolithic architecture to a microservice architecture. We thought of what would be the best way to segregate our services and started doing so one by one. Now we have a question as to how we should make dependent calls. Let me explain in detail. Lets say we have different microservices. On...
I have been reading into possible design patterns and have found the use of singletons always referred to as an anti-pattern. I am currently using a singleton for the sole purpose of gathering configuration details based on my current build environment from a .ini file. My singleton only has one public static endpoint ...
I see some services which takes a requestId from client as the mandatory attribute while some services doesn't. I feel it is a good idea to have a request Id from the clients because it helps in debugging through logs, that is, what happened with this request. Can someone provide the good reasoning or the best practic...
For example, suppose my input data and UI is not in 1 to 1 relationship: html: <script> aChanged=function(){ }; bChanged=function(){ }; cChanged=function(){ }; </script> a:<input id="a" onchange="aChanged()"/>,b:<input id="b" onchange="bChanged()"/>,c:<input id="c" onchange="cChanged()"/><br/> a+b=<span id="a+b"></s...
I'm using mongodb for our web application. Recently I'm think of adding redis for caching objects which usually is the setting/configuration. But the mongodb already cached the frequently accessed items. So, do I need a redis for this use-case and why?
I am working on a project which requires me to execute standard HTTP calls with session tokens. I am building a custom HTTP client, with a custom authenticator, something like this: Client client = Client.Builder().withConfig().withAuthenticator(Authenticator); and my authenticator is an interface public interface Aut...
Considering a Python Project structure such as the following, where there are "empty" packages with __init__ files simply pulling code from the lib folder: . ├── foo │   ├── fred │   │   └── __init__.py │   ├── henk │   │   └── __init__.py │   ├── _lib │   │   ├── classes │   │   │   ├── corge.py │   │   │   ├── _stuff...
I have created an application to import CSV files, each CSV file that the application imports can contain different data, with new formats of the CSV files being added in the future. Rather than hard code each import I have created a definition in JSON that details each file. I have written a basic import class that im...
This is an object-oriented design question that is specific to Spring Boot. I'm extending a Spring Boot application that has an interface that is being extended and used inside another service. The interface uses dependency injection to choose the implementation. I don't want to change that. I think the inheritance ...
I'm working on a project that involves online purchases. I have my web api in C# and my client in REACT (javascript). Server and client are connected with SignalR. I want that when an ORDER is changed all the clients that are watching the details of the order receive the warn to refresh the page. My question is: which...
Payload: { "selection": { "ids": [1,2,3,4,5] }, "image": { "backgroundColor": "#FFFFFF", "headlineColor": "#000000", "format": "PNG" }, "processors": [ { "repository": "org.my.world.app.repositories.RepoX", // fetch data from this Repository ...
Currently I have something like the following def writeThis(fileHandle, name): fileHandle.write('Hello ' + name) writeThis(fh, 'Alice') Something about this doesn't feel right however, it feels like I should try to minimize side effects and have something like the following def foo(name): return 'Hello ' +...
I’m trying to make a AMQP integration layer for my app. This layer would only consume messages from my customer’s queues and the result would be a specific action in my application. My application is a type of CRM. It manages recipients and it can send emails to these recipients. What I would like my customers to be ab...
For the occasions that I've been offering SaaS, I've been asked to develop Apps that are pretty much a clone of regular e-commerce webpages, but with a few features like notifications and, well, being an App in itself. The thing is that it's localized to wherever my client operates, so if a guy asks me for an App to se...
Our team is in the planning stages of creating an enterprise solution for our back office. Our goal is to have one singular entry point for common tasks, such as changing an address or reprojecting a loan (we're an FI). We want several front-ends that are categorized by domain, but could pull from any number of these...
Looking at Stack Exchange API docs, I see methods like answers/{id}/downvote answers/{id}/downvote/undo comments/{id}/delete. Should this be considered a RESTful API? (The docs does not mention the word REST, but anyway it at least resembles a RESTful design, and here and there it's assumed to be so). I'm asking becau...
I'm new to DDD and I'm trying to figure out the aggregate root. I'm sure this question has been asked a million times. So I have : Products (thousands) Catalogs (hundreds) CatalogEntries that associate a product to a catalog and a price (prices are different depending on the catalog) A catalog can exist without a pro...
Lets say I am building some large application ( multi-page app ) using Laravel. And laravel will allow me to make an API and a website on the same application. Since the website and the API will communicate with the same database, I was wondering if it is better to consume the same API for the website using s...
For the most part, I am able to distinguish between functional and non-functional requirements, but at times it is not clear for me. For example, the following are non-functional but they seem functional to me: The software must use SSL encryption for transmissions Or The software must store the configurations in an X...
In the standard c++ library, all containers and all input/output streams have their own constructors and destructors, that handle all the relevant resource acquisition and release. So for most tasks that would require destructors (e.g. memory and file management), the modern developer does not have to define the destru...
Is it a good practice to use the static member methods to check if an object of a class is NULL or not. The object would be sent through the parameters offcourse. Something like, #include <iostream> using namespace std; class Box { public: static int checkNull(Box* b) { if (b != NULL) c...
Let's say I have a User model defined. It makes sense that methods for retrieving certain fields of this model lives in the model file. My question is where something that generates a unique UUID, or username should go. If I have a method for generating a unique username and it isn't specific to a particular instance o...
When writing a flow chart, I can understand that it is a best practice to generally read left-to-right or right-to-left per locale, and/or top-to-bottom and generally for the directional flow of the chart to be consistent. But, when it comes to a diamond ("decision") element and its yes/no or true/false result arrows, ...
First let me state the asynchronous approaches:- The user enters a character into the username form field. I create a connection to the database, use a prepared statement to confirm whether the username already exists, close the connection, and pass results back to initial page. AJAX is at work. All of this happens fo...
In an event sourcing architecture, what is the typical pattern for passing information about related objects (aggregates)? For example, in a order processing system, should OrderCreated event (published by the OrderService) contain productId or a Product? Assuming there's also a ProductService), with the first option,...
I've just read the book called Clean Code. The author (Robert C. Martin) talks about a single responsibility that a function should have in a program. It should only do one thing. Now, I would like to understand how is it now possible to reuse a code that does multiple things. Let's say I have a method called runTraffi...
I'm building a hybrid mobile app that has slightly different versions but share 99.9% of the code. There is a paid and free version, which differ in one function only. Also there is a slight difference between the iPhone and Android versions. I have the code in a git repository but I don't want to replicate the repo 4 ...
I decided to make an application, networking application, don't know what it has to do yet but mainly it should be a cross-client kind of like framework networking application/library. Since networking especially with sending stuff, should I use async since it's basically IO (as far as I understand, I = getting data fr...
I want to test an abstract class with: Pure virtual methods that should be overridden in sub-classes Non-pure virtual methods that use the pure virtual methods (as opposed to this question) class Fu { public: virtual void func(int count, std::string data) { for(int i = 0; i < count; i++) { ...
Let's imagine that we have this Page component: const Page = () => <> <Topbar /> <Drawer /> <Content /> </> I'd like to test some interaction within the Drawer and the Content components in an integration test, mounting our Page component, so I'd write a mock for the Topbar component, because I don't n...
(This is a conceptual question but as reference, I'm using Android Studio (Java) and Firebase Firestore...) My app currently has a structure where the user can follow authors and favorite their works. Each user on the backend has a set of follows and favorites which updates according to this activity. This seems like a...
Say your making a library Foo that depends on a 3rd-party library Bar. Bar throws a custom exception \OtherVendor\Bar\CustomException. Is it recommended to just throw that exact exception to your clients (devs using your lib) or should you catch it then convert it to your own exception? E.g., try { $bar->stuff(); }...
The more declarative code is, the less explicit technical details it contains and the closer it gets to requirements expressed in domain language. In the extreme case, there is no more difference between requirements and code. My question is not about whether this is possible or not. But surely declarative programming ...
I'm working on a system that stores details of customer purchases for several stores. One statistic that they would like is to know how many unique customers they have had over a specified day range, for a particular store, or all stores. One way I can think to do this is storing data in a relational database (SQL), l...
Background We have a team of 8 devs and 1 QA (tester) and we're struggling with dependencies between tickets and causing a lot of merge headaches and/or people waiting around for the next bit of work to pick up. Our current GIT flow model (branches): Release | > Epic (Feature Branch) | | > Ticket : This is w...
I'm implementing an App for fun. It consists of a soccer round-robin tournament simulator in which all teams play each other. A Team consists in a simple object: class Team{ String _teamName; double _defensePower; // 30..90 double _attackPower; // 30..90 } and Match is: class Match { String _info; Team _ho...
I know the compilation process goes with this flow: source -> parse -> AST -> intermediate code -> assembly -> machine code and in the case of Java you will have bytecode which is translated by JVM. In languages such as C/C++ and GO, we parse the source code and output direct machine code in a compiled file, easy enou...
As mentioned here: The main aim of CI is to prevent integration problems, referred to as "integration hell" Our project is a 3-tier web application, with frontend(Angular 6), backend(Springboot) & Database layer For front end code(Angular 6), we have one source code repository(.git) For back end(SpringBoot), we hav...
I have an interface with only one title field: protocol Artist { var title: String { get } } (A) Should I pass the whole object as I did here: class Album { func setArtist(_ artist: Artist) { /// Handle } } album.setArtist(artist) (B) Or set that only field: class Album { func setArtistTitle(...
I have recently begun studying UML. All is going fine so far until I saw the following: This is a class Called Point2D It has 2 attributes which are x, type float and y, type float. It has 3 methods __init __(takes parameters 'x' and 'y', both of which are float) returns nothing distance (takes parameter 'target' whi...
Given the following class: class S { ... private: void Action1(); void Action2(); . . . void ActionN(); } The Action functions are related, which are called in the constructor. For logical reason, I want to separate these methods: class SActions { public: SActions(Smth...
As briefly introduced in the question title, I am trying to design and implement a server application able to let clients share audio contents between themselves. In order to achieve that, I decided to let the server have the following features: it should listen for incoming TCP connections using a dedicated thread. i...
I have a method that returns the percentage change of a data in a certain period. After calling that method, i need to know if in the current period the data increased, decreased or is the same when comparing with the previous period. The problem is that in some cases, the data of the previous period is equal to zero. ...
In my database (mongoDB) I have a model called exam and each instance of the modal has a somewhat large json object (500k). I'm using strapi cms to make the query, using graphql plugin. However when fetching all the ids of the model, the fetching is extremely slow even though i'm only interested in the ids and the json...
I am doing some work to refactor a class. It currently a 'God class' and contains all different logic/operations solely in that class. One of my solutions is to extract all different parts of logic to their own classes. This will result in an 'Orchestrator' class calling all separate classes to execute logic. Example: ...
I am looking at blockchain and trying to see how Merkle trees (or perhaps Merkle DAGs) can fit to a graph data structure with circular references. For example, say I have this data model: var profile = { setting1: 123, email: 'foo@bar.com' } var user2 = {} var user3 = {} var msg1 = { body: 'foo' } var msg2 = { body: 'b...
I had a class hierarchy with several classes that interact with each other. After introducing new feature that is optional (but it depends on external libraries) I have the following code (just simplification): #ifdef (FEATURE1) #include "feature1.h" #endif class Engine { public: void useFeature(bool value) ...
I'm writing an API for a JavaScript library to let my users offset an object from another. I have to provide my user with a way to describe a "vertical" and "horizontal" offset. My problem is that I don't have any point of reference except for the very same position and orientation of the said objects. In the above ex...
How do you design a website that allows users to query a large amount of user data, more specifically: there are ~100 million users with ~100TB of data, data is stored in HDFS (not a database) number of (concurrent) queries is not important, but each query should be as fast as possible support some simple queries such...
I am writing Unit/Component test using In Memory DB. When I write Unit/Component test, I came across with the following question. I have the following two BL methods. ToCreate ToGet So when I write Unit/Component test, I need to create some sample data for the unit test. When I write a Unit/Component test for "ToGet...
We are designing the software based on the FDD (feature driven development). Our architecture is microservice. I want to know that microservices are demonstrated by the feature set? In other words, is each feature set considered as a microservice? As I know the feature set in FDD is the same as epic in Agile. so if thi...
This is basically an extension to my previous question. That time our internal discussions didn't end up anywhere and the whole issue was forgotten for the time being. Now we've touched upon it again, this time with username/password credentials for external systems. So, a more generic/slightly different version of the...
I know there are a lot of threads regarding this topic, but I can't find the answer for this precise topic: First of all, with the "first assembler" I mean the program that translates, let's say, the instruction "mov" to the specific machine code the ALU understands, 1100111 or whatever other binary number. There's so...
I have a question concerning the "Uncommitted Read" Isolation Level under DB2 DBMS for z/OS. In this article https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/perf/src/tpc/db2z_isolationissues.html in the IBM Knowledge center it is stated that when using Isolation Levels other then Repeatable Read, the follo...
Below is the GitFlow workflow, we are using for a project. So, in our project master branch currently has only one git commit with just a Readme file. develop branch is forked from that commit. As of now, there is no other develop branch. We are currently in a stage, running Dev(build) staging of pipeline(Jenkins) an...
I've stumbled upon a problem: "I can't split my domain models into aggregate roots". I'm a junior developer and novice at DDD. I really want to understand it, but sometimes it's really confusing. From this point I want to describe my domain briefly. My poject dedicates to provide users opportunity to create any kind of...
my goal is to convert this class diagram into Java code. How should I approach this, given that I want the constraints to hold at all times? It creates a chicken-egg problem where the first Course or Student created will always be alone in the world, thus violating the minimal multiplicity constraint of either "teaches...
Below is the Gitflow workflow followed, where master branch has the commit history(git tag) of different releases. From release mgmt aspect, we are deleting the release branch after merging with master and develop branch. To apply hot fix, we first git checkout a specific release commit from master branch and then cr...
The AMD64 specification talks about /0 with regards to instruction encoding but I don't have a clue what is meant by that. For example, in Volume 3 the ADD instruction has three forms: ADD reg/mem16, imm16 81 /0 iw Add imm16 to reg/mem16 ADD reg/mem32, imm32 81 /0 id Add imm32 to reg/mem32. ADD reg/mem64, imm32 ...
While applying for a job interview I found this line in requirements. Experience with clean code writing practices like avoiding callback hell like promises, async Does this line make any sense ? If yes, can we actually stop using promises and async ?
I'm new on API and still undergoing some research to gain knowledge for my presentations for next few days. Different motherboard have different CPU socket. So I was just wondering, do API affect the different kind of CPU that only compatible with their own motherboard? Like for example, (I don't know if this is true ...
Should AutoMapper be used to take data from ViewModel and save back into a database model? I know the opposite practice is good software practice: to have Automapper to extract database models, and place them in Viewmodels for front end web applications. I was reading this general article here: The article was not spec...
Note: This is a follow-up to this question on StackOverflow. I have to write a wrapper in Python to an external API, accessible through HTTP. The code is supposed to be publicly available on GitHub. For this reason, I thought, it would be nice if a person cloning this repository wouldn't see tons of warnings. I opened ...
I would like to make a simple web application (a static website where all computation happens on the client) that generates a mesh and displays it. I have a working prototype in Unity and now I'm wondering what a good framework / language is for the task. The problem: I would like to use Typescript or Javascript, but n...
I want to know which practice is more convenient having the following example, (my app is a Rails app but this can be applied on any framework) I am trying to create an endpoint which contains author posts filtered by year using an REST-API. Having the models: class Author < ActiveRecord::Base has_many :posts end c...
I have multiple methods calling each other to simplify changing anything in the code and to avoid fixing errors and copy pasting. It looks like this: Is this a bad practice? Does it cause too much overhead from experience? (I don't have any performance problems but I try to do best in every case I can) Is this a goo...
For example. I have a function which generates an array with random numbers. int[] generateNum(int n) { int[] result = new int[n]; /* Logic to generate random number */ ............... return result; } Then space complexity of the above program should be O(n) or O(1)? This question is more of about spac...
In Scala, declaring a val as lazy means that its value won't be evaluated until it's used for the first time. This is often explained/demonstrated as being useful for optimization, in case a value might be expensive to compute but not needed at all. It's also possible to use lazy in a way that it's necessary for the co...
I am fairly new to Docker and Kubernetes and I have a question for which I could not figure out the answer myself. I am working on an application that does string matching on data extracted from multiple sources but the problem is it's painfully slow. The bottleneck is composed of two nested for loops. For each row of ...
I'm building a user license portal, store, SSO, and mini CRM and admin for internal people to manage those users for a niche 3D software company, similar to Autodesk. Licenses are sold to both companies and single users. What is the best way to avoid company data duplication Not all companies have tax Id and we do not...
I have situation that 3 different instances with the same method signature are doing their job repeatedly. interface IArgs{ //args stuff } interface IExample{ void Populate(IArgs); } class ExampleA : IExample { void Populate(IArgs a){ //todo } } class ExampleB : IExample { void Populate(I...
Considering a class method that takes a "vector" (Tuple or List of either int or float) of defined values such as the following: import sys from numpy import isnan, array, float64 class Shape: """ This is the Shape class. Create 3D shapes described by a length 3 vector dimension input. Example: >>x=y=z=2.5 >>Shape([...
I have been looking at BDD but there is something that keeps confusing me. Consider this user story: Given a user has placed their order And the payment was accepted Then a confirmation email should be sent. Based on this, I see different things being done: Some sort of functional test to see whether an actual email ...
Consider this example command line session... $ git --version git version 2.19.0.windows.1 $ echo "header" > ancestor.txt $ cp ancestor.txt left.txt $ cp ancestor.txt right.txt At this point, I've made an ancestor file and started two "branches". Now I'll make a change to each one. $ echo "on the left" >> left.txt...
Should I define an interface for every public behavior class (excluding data classes)? I've spent many hours searching and reading to find a clear answer. If I search "Do you define an interface for every public class", 90% of the answers say you should not. However, I have yet to find any such comment explain how to d...
I would like some guidance in setting up my document structure Elasticsearch. The company I work for has an app that stores around 20,000 new phone records each day in a SQL database. And we feel we could benefit from the features that Elasticsearch provides (fast searching). So we are going to start storing these reco...
I am working somewhere where programming is an important part of the job, but where code review is something nobody ever heard of. Being kind of enthusiastic about programming, I've seen a lot of questions about code reviews, here and mostly on Stack Overflow, but I could not experience it myself in a professional cont...
I'm hoping someone can give some guidance on an issue I'm having. I have: A WebSocket service, where I have a single method on the server that handles all traffic. Lots of different kinds of messages, each message has a "type" and we select which handler class to use based off that value. In the HTTP world I would h...
I have a web page that loads a very long list of custom web components, each with their own shadow DOM and a stylesheet shared by all instances. Originally, I included the stylesheet as css file reference in a <link> tag to the code more readable: (function () { const template = document.createElement('template'); te...
I'm working in TDD for my data access layer in MongoDB and I don't know what should I test? I think that I shouldn't test if the queries return what they have to return because It's a MongoDB concern. Some help please!
I have a medium scale e-commerce application. Over a period of time our monolithic project got quite heavy in terms of code base. I was exploring the solutions for it and found micro-services is one option but found it like a very early optimization which involves too many risks and increased development cycles. So, I ...
I am designing an interface for reading and writing video frames to various inputs and outputs. Stream operators seem to me a superb alternative to named functions for the task. This is the gist of it: struct FrameSource { virtual FrameSource & operator>>( cv::Mat & frame ) = 0; virtual ~FrameSource() = default...
I have a class that provides basic functionality of a modal window. For different situations I need to provide different modals(different number of buttons, titles, etc...). I have a kind of factory that can compose those modal windows, like in the example below. class ModalProvider { static ModalWindow makeModalWi...
A sensor identified by the serial number “ABC1234” fulfills a measurement function identified by the name “Pressure sensor 7” in a production facility. Within the production facility, nobody cares what the actual sensor fulfilling the function is. Actual sensors breaks on a regular basis and must be replaced. When peop...
I am on a team of ~20 people that is part of a very large organization. We have been using the same codebase for ~5 years and have released multiple derivative projects from it. I've had some 1:1 conversations with team members and most of them are also aware of the various code smells and don't like them, but refactor...
Every time someone reaches me and asks me to define the Dependency Injection in a conceptual way and explain the real pros and cons of using DI in software design. I confess that I have some difficulties to explain the concepts of DI. Every time I need to tell them the history about single responsibility principle, com...
I have an Odata API server that I can't change only access it, I can do CRUD operations on it. However I'd like to authenticate users, that are stored on this server. I can retrieve a user (his email, password everything necessary), now I'd like to authenticate him so I'd probably use JWT tokens. However as I said, I c...