instruction stringlengths 34 36.1k |
|---|
In one of his books, Robert Martin provides an example of test-driven pair programming conversation while developing a Bowling Game Scorer in which one asks about user stories' inputs and outputs.
The inputs are throws and the outputs are scores.
So I realized I had never thought about a requirement's inputs and output... |
TLDR:
In a Headless CMS (or a Decoupled CMS), the content retrieved by the front-end needs to be identifiable (somehow). This is where I'm stuck. I can describe my guesses of how platform-agnostic content might be made identifiable (see my attempt at a guess below). But I can't find real-world confirmation of tried and... |
I am currently in the process of creating a use case digram for a new system that we are building and have stumbled upon an interesting scenario.
The system has a number of primary actors which include Corporate and Non-Corporate users. Each of these users can “do something” within the system from a variety of differe... |
I would like to generate analytics on a per-user basis on how many times they've viewed a particular page for 7 days, and how many times they've viewed a page during their lifetime as a user.
This will be tracked in 1d, 7d, 14d, 30d, and lifetime intervals. If a user visits the page today, they will appear to have 1 vi... |
The current workflow we have in place at my company with regards to git is:
Develop on a branch
Push every so often
When done developing, open a pull request in Github
We have a reviewers on that pull request where they comment suggestions for improvement. However a lot of the changes they are requesting can be made ... |
I am trying to design a Rest API backend based on Loopback. Since I heard nodejs is not very good in computing since it will block the thread, can I make a async call just for using java to calculate them, but also host them on same server where the nodejs application is running.? This way it willbecome non blocking. I... |
I have the following setup:
different teams
shared eslint config (that imports airbnb rules as a basis).
Whenever a developer decides to update libraries, if eslint/prettier have updates, it's a pain. The main reason is becuase normally eslint or prettier are introducing new rules. If we update these libraries, they ... |
Abstract:
I'm attempting to create a "data interoperability API" or in other terms "high-level query interface API" that will be consumed by (data scientists, web apps, any who wants to query multiple datasets).
Assumptions:
The underlying data will usually be in these formats:
1) Best case scenario - XML (with prope... |
In the book UML 2 and the Unified Process from Arlow and Neustadt has been told:
Analysis classes should have 3 to 5 responsibilities
But as you know we have the SRP that tells us something else!!
why so happend?
I'm confused
Which of the following deductions is correct?
Case 1- The different definitition of responsib... |
I'm trying to understand why sizeof(a)/sizeof(t) is inferior for getting the length of an array to sizeof(a)/sizeof(a[0]) if just as it's possible to have different types, my elements could also be of different lengths. so what makes dividing by the element size uniform?
|
Background
Building a mobile App for product X which is currently hosted as a SaaS solution. The product X does not support OAuth currently, implements basic authentication and generates Session token after authentication. Product X also implements SSO supporting native SAML 2.0.
Use Case
Mobile App also implements SSO... |
A relation R(A,B,C,D) is given.
C and D are equivalent (C is the course ID and D is the course name, one implies the other).
C and D are prime attributes.
Does that violate the requirement of 1NF or any other NF?
|
Writing automated unit tests is followed as a part of our development process.
We also do have an established code review process for the development code that is written.
Should the test code be reviewed? If yes how to make it less time-consuming for both the author and the reviewer?
|
I understand an interface is a contract and if a class implements that interface, it must define those abstract methods from the interface. What I don't understand is, how is data passed between two classes that use an interface?
So for example: In Android, a Fragment has an interface, say OnFragmentInteractionListener... |
I'm writing my first Redux app. In my store, I have ~300-500 Island objects that I retriev from an API and index by an id string in an object (being treated like a map). When I'm editing one of these Islands by setting editId in the store, the buttons for the other Islands need to be disabled. I can think of three w... |
I have been trying to use Node.js since it was first released, and in all of the intervening years, not once have I encountered a single Node.js project that worked as described when using the directions for initial setup, testing, and/or deployment in that project's official documentation.
Is this due to immature pack... |
I'm trying to find a good way to manage permissions for a high number of mongo documents.
What I want to do: Apply group/user/and or application permissions to mongo documents.
Idea 1: Use mysql to control the relationship (con's duplication of data, 2 diff systems)
Idea 2: Add metadata to each document (con's: would ... |
I'm struggling to find how to correctly design a database in order to store and retrieve data for my software.
Basically, I'm designing an application for a gym (C++, MySQL with PhpMyAdmin):
each user (unique ID, name, surname) can have one or more training routines
a training routine is divided in training schedules ... |
Currently I'm developing a movie reservation system for diving into Spring Framework.
I'm using Spring Data JPA for database modeling. I have several model classes but I am stuck with time-based logic in my application and can't finish modelling phase.
Here's the general design of my classes.
every CinemaHall has one ... |
I am developing an app and splitting this into microservices. The app is a booking system. There are two microservices - 1), bookings and 2) company details.
For the bookings microservice, this contains entities such as customers, bookings, services, etc etc. All these entities are related to each other @ the database ... |
On Android, do people create separate apps accessing the same database? For example an app that has users, producers and a customer support.
How can one decide if it makes more sense to have a single app for this case, or multiple apps accessing a shared database?.
For example having a single app and classifying each... |
Please help me to understand what is event based data integration in simple layman term with some examples?
How it is different from other form of data integration.
Some sample use cases will be additional help.
Thanks,
Rajneesh
|
I'm not sure if this is the adequate site (maybe CodeReview?) but it's the only one here in StackExchange that have got a "clean code" tag ... There is no need for downvotes if this is not the correct place just inform me in the comments and I will move it.
I've got this piece of java code
private void executeCommand(... |
I would like to use UML diagrams to show some processes I am designing and would like to implement.
The processes involve using a queue, and adding and taking out elements from it.
In one of this process the adding and taking out elements are done by two different threads.
In the other, both operations are done by ... |
In order to build a messaging app, I have followed this example : https://github.com/gorilla/websocket/tree/master/examples/chat
This consists of a Hub, running in a single goroutine in the program, which binds together the Clients (the intermediary between the socket and the Hub).
In this example, each Client (connect... |
I wrote this class:
using System;
using System.Threading;
using System.Threading.Tasks;
public interface IJobScheduler {
void RunDaily(Task task, int hour, int minutes );
}
public class JobScheduler : IJobScheduler, IDisposable
{
Timer timer;
/// <summary>
/// Run the ... |
Don't be afraid to make a name long. A long descriptive name is better
than a short enigmatic name. A long descriptive name is better than a
long descriptive comment.
Robert C. Martin
Did I understand Clean Code right?
You put the whole information that you would put into a comment into the class/method/... name.... |
One common issue with secure passwords is that users tend to "cheat", one common cheating pattern we meet recently is the "password swap" antipattern where the user basically keeps using the same two passwords forever.
e.g.:
Password1!
Secret2$
Password3!
Secret4$
This antipattern works because:
any new passwords is... |
In the project I am working on we are building a feature where you have a file with 2 buttons. Button 1 opens the file in your browser, button 2 starts downloading the file. I see these as 2 distinct interactions.
We are using Angular 8 in the front-end and ASP.NET 3.0 in the back-end, but I think the front-end stack ... |
I am trying to build a system that tells the user on which platforms (like Netflix, prime, etc.) a movie or series is available. What is the best way to go about it?
I have considered the following:
Scraping the web to collate this information (it seems too unwieldy)
Manual entry in DB (along with scraping to adjust ... |
Last time I used I created a REST API client in .NET I used exceptions to represent status codes which don't indicate success. (404 was returning null). It's been quite some time since then and my ideas have evolved a bit. Now I am using Blazor for part of my project and I am faced with the problem of API client design... |
Let's get to an example. Suppose, I have a Course object with the following properties: (course' code, course's title, credit of course etc.). When expressing this as a JS object, I can do it in the following ways:
1.
const course = {
course_code: 'CSE123',
course_title: 'An example title',
course_credit: 4... |
I have used Utf8Json a lot (it is very good) but have since adapted some lower level code and started using Utf8JsonReader directly.
Looking into the code of the Utf8Json library, I see JsonSerializer.DeserializeAsync as ultimately it is using the System.IO Stream class which itself has Stream.ReadAsync functions.
Look... |
I had begun scouring my code for optimization opportunities (execution speed, data parallelism, workload parallelism) yesterday when I noticed that there are very few opportunities for speeding up integer divisions. Integer division is heavily used in a hot spot area. Not only is it slow relative to the bit shifts, it’... |
I want to write a program that performs heavy computations and I want it to be as fast as possible, so I choose C to be the language. Nevertheless, I was told that in spite of its simplicity and high efficiency one can easily make things slow instead of fast AND get himself absolutely nailed into his feet.
Okay, so if ... |
Often, when any low-cost computer peripheral device is sold, it is sold with a CD containing the device's controlling firmware. Why can't it simply be sold with the firmware pre-installed by the manufacturer so that it does not rely on the host system itself to do this task? Does this have to do with price/memory const... |
I am looking at all the green and red boxes here, and am wondering what it would look like if one were to "implement TLS" today? What should you implement if you were to implement TLS today?
Do you need to implement all of the previous versions? (SSL 1-3, TLS 1.0-1.3)
Do you need to implement all the cryptography algo... |
I have two approaches to solving a problem but I don't know which one is better.
I will give a simplified example.
First approach
The database will look like this:
color |
--------
FFFFFF |
0000FF |
The code would have to deal with the specific values and do something like:
If (color == 0000FF)
displayBlue()
If (c... |
The rule I was taught: "the method should be in the Object that it is invoked on"
a student joins a course => the join method should be in the Course class
a player drives a car => car.drive(..)
but another possibility is: the join method is in student. the course has an addStudent Method.
the reasoning is "I tell ... |
I am going to use the FreeRTOS on my hardware platform. My plan is to model individual tasks as C structs containing task execution period, task priority, task stack size, task name and maybe another atributes. Then I am going to define public “constructor” function called task accepting values of individual task attri... |
I have a function whose job is to look through a string that is a post's content and find certain pieces:
public static function findInsidePostContent( $post = Null )
{
//post_content comes from a WP_Post object.
$post_blocks = \parse_blocks( $post->post_content );
//Look inside, do some things.
}
The fu... |
Context: I am a new hire out of university at a large software company tasked with either refactoring or re-writing a large legacy method (~500 lines, ~2000 lines expanded with private method calls) that performs a complex workflow with many responsibilities. You can imagine it applying a complex series of interdepende... |
I have X number of servers in NLB listening to an event that gets published by a backend system.
I am planning to develop a windows service that listens to the event and then calls an internal API. Here, each server in the NLB is subscribing to the event.
Is there a way that I can make sure that my API is called only... |
Say I have 100 users, each with varying strength, and each with a top 5 set of "preferred teammates" and a top 5 set of "preferred enemies". I want to sort the users into two teams.
User
{
int Id;
int strength;
List<int> PreferredTeammatesIds; // arbitrary limit of 5
List<int> PreferredEnemiesIds; // arb... |
I designed a rest api software with 2 simple layers: Controller and Service. The controller handles the coming http request and redirect to a service method. In the beginning of development every was going well with the standards CRUDs. The problems now is the complex reporting query.
For each persistence entity I crea... |
I've a JSON file which I'm trying to de-serialize into POJOs.
public abstract BaseClass {
private String baseClassField;
abstract String execute();
}
ClassA extends BaseClass
public ClassA extends BaseClass {
private String classA;
private SomeInterface interface;
@Override
public String execute(... |
Problem description
Publisher-Subscriber architecture with a central registry where agents can either promote their capabilities or search for a given capability.
The project must be developed with C/C++. A GUI used to compose a chain of agents is a nice-to-have (not necessarily C or C++).
Current state of my thinking
... |
I've really been struggling with this concept a lot in my head, and I was hoping I could get a poke in the right direction here...
I have a process that is supposed to take a certain number of phone numbers and send them all text messages (through Twilio). That's all fine and working...my problem is, I don't know how t... |
How would you architect a simple cascading stylesheet like inheritance object?
For example, I have Apple that extends Fruit.
class Fruit {
constructor() {
this.total = 10;
}
}
class Apple extends Fruit {
constructor() {
}
}
On Fruit there is a property named total with a value of 10. The a... |
To make a long story short, I needed a property of a button to act as a "secondary text property" and retain the original .Text value of a button, and the only String property that wasn't ReadOnly was the .Name property.
I was sure it was going to break on runtime (as tons of code references the name of the control) bu... |
I am in a situation right now where a solution has been proposed that uses a csv file. The proposed file structure essentially contains three atomic values;
ID
Thing 1
Thing 2
Fine. As we were discussing this solution, someone mentioned that some customers might use our ID while other customers might use their own, d... |
I know that:
Computer keyboards have an Escape Key
The symbol for the Escape Key is U+238B Broken Circle with Northwest Arrow (⎋)
and I also know that:
HTML5 & CSS3 both have escape characters
Javascript has the backslash escape character (\) etc.
But are we using the same word "escape" in these two distinct contex... |
Some background:
We have similar entity stored in different databases because historically the entity used to come from different vendors(and it still does) and we stored it in three different databases.
All the DBs have SP written over them which returns the entities based on few filter.Table schema of result set retu... |
I want to add some custom retry logic to the AWS sdk (but this isn't specifically about that). So whenever it throws a specific network exception it waits and tries again and whenever it throws a specific auth related exception it calls a function that tries to update it's credentials and tries again.
I want to avoid a... |
I have a build pipeline that builds my C++ project on Windows, macOS and Linux. The build process generates 100 libraries and files on each OS. So I have a directory with these files, and I want to package them proberly.
File foo.dylib goes into osx.zip.
File bar.dll goes into win.zip
Is there a standard format for thi... |
I'm trying to engineer this:
200 subclasses [ Derived Classes ]
After a subclass is defined, I wont need to edit any other file. [ Decoupled ]
Subclass Definition registers itself. [ Definition is Registration ]
What I could do instead:
Create a class [ One big one ]
Create an enum value (or similar) for every func... |
I work for a small-medium sized startup with a development team of 20 people and a very strong engineering culture. Engineering itself is split into smaller sub-teams and I am the only person responsible for a particular component (which is quite critical to the whole organisation).
We have now finally managed to hire ... |
I have a multi-language web site. On the web site, users can search products and services by geographic areas.
I am asking which is best approach to performs search of geographic areas. In this moment I am using geographic coordinates.
I stored in my database the boundaries of different areas, then when user input a c... |
I want to clear my application cache after updating an element of my domain.
In that case I raise an event NodeEndPointReferenceChangedEvent from my Domain Layer.
The cache in managed in Services Layer.
I'm not sure where I place the NodeEndPointReferenceChangedHandler who will be responsible for catching the event and... |
I wanted to ask about your ideas on how to solve the problem that I have to solve in my application (App1). This is the classic Fronted + Backend (Angular + Java EE) application to which I am currently adding authentication and authorization. However, the matter does not seem to be simple for several reasons. First, th... |
I'm learning about Software Architecture and especially about scaffolding large-scale architecture and patterns for modern web applications.
I've noticed that I don't have a pattern for data validation or rules, sometimes I add validations or checks () in client-side layer and others in the server-side or by adding req... |
I'm new to API design. I've been reading numerous threads RESTful vs RPC patterns for API design, but I feel like none directly addressed my exact use case, so I just wanted to get a second opinion.
Let's say I want to build a web app which recommends neighbourhoods to live based on two criteria:
Your income (i.e. wha... |
I am building a system composed of a few micro-services over AWS.
I encountered the need of a certain MS to do the same logical work but of a big range of work load.
for example, the same logical work could need 2vcpu and 4GB ram and another will need 4vcpu and 16GB ram.
What is the best practice here? have all the ins... |
Let's say we have a situation in which we have a particular entity, for example an User which has a set of related entities e.g Book.
At some point in time, a group of users phisically receives a new Book.
That means that each user in that particular group has now a new Book.
At this point someone has to connect to a p... |
We have built an iOS/MacOS library, that is being used by several iOS & Mac Apps of a very big company.
The library is being distributed through Cocoapods and Carthage, the package managers for iOS and MacOS libraries.
We have pipelines set-up to build on every commit. The test suite of Unit Tests, UI Tests and Integra... |
I have had hard times naming boolean fields.
On the one hand, i've read that it is good to name them as affirmative statements, like hasAge, or canDance. It's not a problem when naming local variables, for example
boolean itemIsActive;
boolean everyItemHasName;
But i don't see how these rules could apply this to field... |
I'm at the stage where I'm taking my MVP app and trying to refactor and structure it in a way that it is maintainable and extendible. I'm new to software architecture or design so I'm having early struggles deciding what pattern would suit best my application.
How do I go about and investigate if Domain Driven Design ... |
I am building a SDK that will simplify the use of my API.
The problem is if when I have to return property of type enum. For example, I use strings instead of int for displaying enum such as
{
"type": "CAR"
}
instead of
{
"type": 1
}
Now, my question regarding SDK design/development is should I parse this "type" pr... |
I created a forum where I want to display notifications and messages as soon the user gets them. I don't want them to need to refresh to page to see if any notification/message been sent, but I also don't really want to implement 3rd party (like Pusher), that's why I thought I would go with polling.
Basically, if a use... |
I know difference between waterfall and incremental strategies. But I'm somewhat confused because I see that there are methodologies which use incremental or iterative approach but I cannot see any examples for waterfall strategy.
For example Scrum is a methodology that uses incremental or iterative strategy but is the... |
I don't think any of them are good practice. In addition to that they make the code longer.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for
Optional initialization
var i = 0;
for (; i < 9; i++) {
console.log(i);
// more statements
}
Disadvantages:
Can have side effects
Option... |
I have come across a small issue with the git work flow in the team.
When starting to work on a user story, we create a feature branch from the develop branch. Once the user story is finished, a pull request is created and another developer completes the code review. Then the QA tests the feature on the feature branch... |
I am working on an API that allows a client document to updated under the endpoint of PUT /client/{documentId}. As part of this document, I need to include an extra field 'ReplicateInManager' that notifies the server as to if the document needs to replicated in an external system, alongside the database for this API.
I... |
I am in the process of refactoring a large C++ code (~2300 files, ~600K lines, mostly older C/C++98 style code) and there are definitely memory leaks that could be shored up using C++ smart pointers. Is there an incremental path towards migrating towards smart pointers or is this an "all or nothing" proposition?
For ex... |
After reading/watching a lot about Event Sourcing, there is one thing I don't fully understand: Events that lead to triggering of other events.
Let's take StackExchange's "close question" feature as an example. The feature requires
commands like VoteToCloseQuestion, and CloseQuestion (direct close for moderators), an... |
I am trying to learn DDD. I am modeling a property management domain and I think I have two contexts (subdomains?): a property management context and a resident context.
Let's say I have an aggregate root Apartment, that holds Floorplans and Units. Each Apartment can have many Floorplans, and each Floorplan can have ma... |
I'm working on a Python application in which there are two Singleton classes: App and Configuration.
The former seems straight forward, only ever instantiate one App instance; the latter seems controversial.
From the searches I've done, I need Configuration to be accessible from other modules that update the applicatio... |
Let me start by saying that I'm not questioning the utility of encrypting EBS volumes, nor asking how it works.
I'm just wondering what specifically encrypting EBS volumes is protecting against?
For my personal laptop, the reason to encrypt the hard drive is if it ever gets stolen, while the thief could create a copy o... |
I was reading about the clean architecture, and I don't get this part:
Don't use your Entity objects as data structures to pass around in the outer layers. Make separate data model objects for that.
As long as I don't let the entities leak out through an API - that's why I create Presenters -, what's wrong with letti... |
Im looking for a good way to find a value from the given list based on a text.
Example:
This computer has 16GB ram and with the best processor in it. Case is made from aluminium.
And I have criterion like amount of RAM with possible values:
4GB
6GB
8GB
16GB
I can't do search for value in text because it can find e.... |
I've got an Algorithm class whose responsibility is to find if a given word is in a list of words.
As part of doing that, the algorithm first has to lowercase the words, remove punctuation, and remove any stopwords. Then, finally, the algorithm tries to find the given word in the cleaned list via the find_word method.... |
I was wondering what's the principle behind it, and whether I should treat all functions from module that are not used anywhere else at the time as private, and mark them with underscore prefix so others know that these are not used anywhere else. Or maybe only mark as private those that are 'not meant' to be used anyw... |
Is there a way through encryption/keys/jwt or anything else to ensure that the data being sent through a POST request is only data coming from another request I made on the client to a 3rd party endpoint like Instagram?
I haven't been able to think up a secure solution to this. I've tried thinking about solutions where... |
Is it bad practice to add false or ... or true and ... for the sake of promoting code genericness and/or ease of use?
As in:
SELECT *
FROM table
WHERE TRUE
AND IsEnabled
AND SomeField = some_value
AND SomeOtherField != some_value
in SQL or in javascript for example:
if (false
|| prop === 'category'
|... |
I have these classes and I want to instantiate each one of them easily.
All the data to create them are in a json file and there will be a lot of different objects in the end. Each objects have a lot of attributes, I would prefer using a helper. A, B and C can be instantiated and used separately even if A might depend ... |
I have a system that subscribes to Kafka topics (i.e. a message bus) that publish life-cycle events. My system needs to digest and save these events and later serve its clients (the users of this database) with time intervals information between the events.
For example, if the Kafka topic exposes the availability/stat... |
I have built a few stacks in my time as a self-taught full-stack developer, but I think there may be a hole in my knowledge that you can hopefully fill in for me. I have built a few stacks that all have a core architecture like this:
Backend in Go, interfacing with a Postgres database or doing some core logic
RESTful ... |
I'll demonstrate with an example of the normal distribution in Python.
def norm_pdf(x, mu=0, v=1, p=1):
"""Returns un-normalized probability density of normal distribution at x.
mu: mean
v: variance
p: precision (inverse of variance)
"""
# if they specify v
return 2.71828**(-(x-mu)**2/v/2)
# if they spe... |
Let's say we are using TDD while developing some Calculator class (the simplest case - it should provide add, sub, mul and div public methods). We initially start with develop branch. The following patterns come to my mind:
Pattern 1:
At the beginning we would be able to add numbers. We create feature-add branch and do... |
I am creating a Nodejs website and the website is about selling photos, although I will store the images on the static folder but in the low quality or watermarked. But When the user Purchases that image, I want to give him the link of the image through a secure connection. Please Guide me sensei! I am new to the devel... |
Consider the following
Group A
Job A {
Depends on Job B of Group A
Run User -> User1
}
Job B {
Depends on Job C and Job D of Group A
Run User -> User2
}
Job C {
Depends on Job D of Group A and Job A of GroupB
Run User -> User1
}
Job D {
Depends on Job E of Group A
RunUser -> User3
}
... |
I'm used to using static link libraries in my projects. This doesn't make the solution heavier and allows to be updated more easily.
However, I see some GitHub repos providing in their sources the code of the libraries they use (the example that made me raise this question is the libffi library entirely taken in the so... |
I am developing an application, and want to implement a certain functionality. I find that this can be done in the stack I am using, however it's hard to implement. I can create a microservice with this functionality embedded using another technology, and use it for that particular aspect of my overall application. Thi... |
I have a web service which is exposed to UI owned by our team. This web service is responsible for creation of objects and saving it in the DB (NoSQL Database). The object being created has multiple implementations and behaviours which can be changed at runtime. How should the APIs be split? I have three approaches in ... |
I have multiple apps (app 1, ..., app n), that don't know each other but use the same services. At the same time, there is a single application to configure the services (let's call it backend).
One service in particular simply stores content, that we have created using an editor and provides it to the applications thr... |
I'm working on a project that uses PubSub(GCP), my question is not specific to GCP, it's more regarding to the architectural pattern(I'm used to statically typed languages, and I have a hard time figuring out how to do this the right way).
The services that I'm working on are written in go and what I would like(at leas... |
I often read definitions for Polymorphism such as the following:
Polymorphism is the ability to have objects of different types
understanding the same message
But the above definition also apply if we don't use Polymorphism, for example if we have an object of type Circle with a method draw(), and another object of... |
The classic example for a transaction is withdrawing money from a savings account and depositing it to a checking account in the same bank.
Yet I have the suspicion that DB transactions are actually not used for such examples, but rather that eventual consistency is achieved with a a journaling system that reconcile... |
I have an ongoing project where the directory structure currently is a mess (github Directory) and I would like to strucure it to eventully create a python package out of it. Below I have outlined a potential outline of the structure to package it and would like some feedback if below is a senceble way to do it on, or ... |
I recently learned about the decorator-pattern to dynamically extend existing behaviour. So I have this code:
IMyInterface b = new A();
if(someCondition)
b = new B(b);
if(secondCondition)
b = new C(b);
and so on, where all classes A, B and C implement IMyInterface and B and C are the decorators. So the final r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.