instruction stringlengths 34 36.1k |
|---|
So I don't know how to formulate this clearly, as it's quite confusing. Hence the reason for asking this question, to overcome the confusion.
I will do my best to make it clear, but part of the reason I ask is because I don't know how to make it clear (I've been thinking about this on and off for a while):
If you store... |
When a method is called and must return a value for further processing, but for instance a message has also to be provided to the UI : what is the best or most common way to deal with those 2 outputs of a single method ?
ex :
public string exportStuffToFile() {
(...)
//do some work, that should be notified to the use... |
Why are magic NUMBERS considered bad practice? For example:
memcpy(ResourcesDir+GameDirLen, "/Resources", 11);
What is wrong with the 11? Why are magical numbers so bad?
Please, my question is entirely different from this one. Mine is about why they're considered bad, and the linked one is about what qualifies as one.... |
Obviously I imagine a CAS does more than BigInt does. But I'm wondering if there is a difference in implementation between BigInt integers and CAS integers (whatever they may be, symbols?).
Wondering because I would like to implement a robust math system eventually and am not sure yet if BigInt would be pointless if yo... |
I need to know what types can be merged together like can I merge MVC and layered architecture? so please can someone list what types can be merged together, and an example on how to merge.
Can I even merge software architecture?
I am trying to solve a problem, that is asking me to discuss about merging two software s... |
I am trying to understand what is the proper approach when the objects generated from a Repository have a reference to objects which are responsible for another Repository.
Let's say I have terminals which can have a list of possible quantities assigned and each quantity has a type. In this case I have 3 repositories T... |
We run an infrastructure in our organization, where a list of configs are provided and we check which config a given user satisfies.
For eg:
config_1 = {"a": 1, "b": 2, "c": 3}
config_2 = {"a": 1, "b": 2, "c": 4}
config_3 = {"a": 3, "b": 2, "c": 3}
For each attribute there is a sql query to get the data, for eg:
Selec... |
I am writing a command line tool in C++ that takes several arguments, some of them file names but also option parameters.
Is there a standard way to parse and implement these options? A simple way would be to clean the input and use a map to convert it to an integer and use a switch statement in the main.cpp. But that ... |
I have developed an open-source vue.js scaffold which is based on my exprience and study on various vuejs
projects.
Currently it has a good structure(i think), but i'm nervous about is it good enough for a chat scaffold and the goal of this question is about where is the better place for scss files in this scaffold?
... |
Its ok to have hardcoded strings on backend? Example:
Log.e("Error connecting to the database")
The text "Error connecting to the database" should be hardcoded there? Or should it be in a separated file with all strings? Or in a constant at the beginning of the class?
|
I am developing an event-sourced Electric Vehicle Charging Station Management System, which is connected to several Charging Stations. In this domain, I've come up with an aggregate for the Charging Station, which includes the internal state of the Charging Station(whether it is network-connected, if a car is charging ... |
If a class can only perform one task, could it be considered to be "too specialized"?
My intuition is that classes should be abstractions that are capable of representing themselves in multiple ways. I'm reviewing some class definitions that are so specific that these objects cannot be used except for a single use cas... |
I'm trying to come up with a DDD solution. Let's say we have two entities: User and Post and User is a root aggregate.
User {
List<Post> posts;
public List<Post> getPosts() {
return posts;
}
}
It sounds good to only use UserRepository to retrieve a User, along with its posts, but what about return... |
So, I got a question here that appears to be opinion based. Rather than tackling how and where I need to implement IDisposable, I'd rather question myself how the code is written, is it a good design.
I got a base Node class which has a StreamReader and StreamWriter and 2 derived classes Client and Server. The Client o... |
Context: Java, fairly new developer
I have inherited code from a friend for a project that processes variables. The first thing i notice is the class has a ton of member variables. I have always been under the impression that a lot of member variables means the class is designed poorly.
The class itself only has one fu... |
I get that a front-end isn't secure on the web because one could theoretically access the front-end code by opening dev tools and changing the code.
Do I also need to be careful about security for a mobile app? (meaning not a web app)
Based on what I'm reading here https://www.quora.com/Can-we-get-the-source-code-of-a... |
The absolute value function is an instance of the norm function in one dimension. I've seen instances of libraries where the absolute value function is overloaded to also take the norm of higher dimensional vectors. Would it be better practice to define a new function, say "norm," or is there some reason why overloadin... |
How to make memory-efficient code, but still have all the possible code nicely encapsulated ?
I have a feeling that the OO (object oriented) approach is more intuitive and the code is nicely organized and encapsulated, but it can use a lot of memory, because there are usually many live object instances in the memory.
I... |
If I keep versioning at the global level then it would save the clutter at each controller level,
// main.js
main() {
registerGlobalRoutesPrefix("/api/v1");
}
// controller1.js
@Route("controller1-route")
class controller1 {
@Route("my-api-route")
myApi() {
// do something
}
}
Here all controllers don't need to... |
Java interface design: where should I put a lot of duplicate code that will be used by all subclasses?
interface Tuple {
void method1();
}
class Tuple1 implements Tuple {
@Override
public void method1() {
utilityMethod();
// some code ....
}
private void utilityMethod(){
// ... |
So, in the process of creating a user there are 4 possible outcomes:
Username is already taken
Email is already taken
Username is invalid
Email is invalid
Here is what I have in the controller for now:
const user = await this.addUserService.add(username, email, password)
if (user) {
return {
statusCo... |
I stumbled upon this answer in codegolf.stackexchange.com where they talk about point-free programming. The following was a code example.
instead of
foo.Select(x=>int.Parse(x))
you can use
foo.Select(int.Parse)
Questions:
How does Select() know how to pass the variable into int.Parse()?
Is the point-free ... |
I am trying to get myself familiarized with the design patterns and I am reading through this line on the relationships between different patterns. I cannot get my head around this one though,
You can use Abstract Factory along with Bridge. This pairing is useful when some abstractions defined by Bridge can only work... |
I am reading some data from USB, do some packet processing and then send the result to the Ethernet port.
The USB ports are connected to an onboard USB Hub where it communicates with the Microprocessor via PCIe bus.
Also, the Ethernet HW communicates with the Microprocessor via PCIe bus.
The program itself is small an... |
We have are a small team of 6 people working with Scrum and Git.
We are developing a quite complex webapplication with the ZK Framework. It uses Java and a MySQL database.
We have adapted the "Git workflow" by Vincent Driessen from:
https://nvie.com/posts/a-successful-git-branching-model/
This results in the following... |
I regularly have the situation that I have some complex logic that I break into steps. For example an import of an Excel file where I need to apply some logic or a complex calculation that I break into smaller calculations.
Another situation is shown below. This is one big User Story: As a user I want to show the graph... |
During my investigations of List<T> enumeration I noticed List<T>.Enumerator is struct. In opposite for instance to System.Array.SZArrayEnumerator or System.SZArrayHelper.SZGenericArrayEnumerator<T> that are classes.
It seems this not typical usage of struct since enumerator has no traits of value type. For instance it... |
I've been tasked with creating a booking system and need to figure out when rooms are available at specific time slots on each day.
There are 5 available meeting rooms that can be booked at fixed times each day, these times slots are:
07:00 for 13 hours
13:00 for 24 hours
13:00 for 48 hours
What is the best way to ca... |
Assume you have a class C. C defines a public method (member function) C::m1.
Calling c.m1() (c is an instance of C) can either
Return after mutating the object c it was called on.
Throw an exception of type E and leave c unchanged.
Because of (1), C::m1 cannot be marked const. However, if C::m1 throws it should (by ... |
Suppose I'm working on software to be installed on a Linux machine (not mine).
Say the software consists of applications the user might start independently; an application which will likely be started on desktop environment login, a service which should be started when the system boots; and libraries, some shared among... |
The company I work for has a ticketing platform. The backend system consists of a few applications talking to each other via HTTP and through events in Kafka. A ticket has a sell_start_date field indicating when it can start being sold. We have to develop an application exposes available tickets as a HTTP service. For ... |
I'm a contributor to a framework that's designed for producing synthetic data. The system allows the end-user to create custom data generators and load them into the framework. Currently we store the available generators in a dictionary. We then look-up the generator by name, and return the value generated by that to t... |
I'm building a front end that interfaces with a 3rd party API, and my question is regarding the proper pattern to use with that third party API.
My existing code isn't very sophisticated, and I find that I'm writing the same code over and over again.
var httpClient = //dependency injection here
var response = await... |
Say if i have two floating point numbers
double a = 0.1
double b = 0.1
Then a, and b, after going through the EXACT SAME set of complicated arithmetic operations, on the same computer, then compare. will a==b always return true in this case?
|
Let's say your application takes in a user request and you don't trust the front-end validation (because you never trust the front-end validation). In your controller or other handler, you want to convert this input into a domain object, since you'll need to pass it around a bit. In this scenario, what's the best pract... |
I am working on a tool that primarily uses bash scripts and C++ code.
Generally I have experience with basic tools written in C and C++ in which we can have a build system like ./configure; make; make install in which we can simply install the libs and bins to the locations provided to third parties like /usr/local/lib... |
Sometimes I find myself in situations where just by happenstance two things can be treated the same way. But they aren't truly the same, it's just coincedence.
Let me give an example, imagine we are in something like JavaScript so that types don't get in the way of my example. Suppose we are writing some event handler,... |
In a microservice based multi-tenant web application, there are some cases of tenant specific logic where I am unclear about the proper strategy to handle them. Thank you for pointers.
These two cases I think I have a grasp on. They lie at opposite ends of a spectrum:
logic that can be well abstracted. e.g. call to ru... |
I'm building a simplified web tracker as a side project.
One of the things I'm unsure about these cloud-based trackers (like Google Analytics) is how they prevent abuse of their platform; in other words, how they authenticate incoming requests.
I assume that they do some kind of check to verify that an incoming reque... |
I'm currently developing an application using SFML. My biggest concern at the moment is making a layer of abstraction over the library, so I can easily change it to something else if needed. What I'm struggling with is designing an abstraction that's intuitive and not leaky.
An example: drawing in SFML is done using dr... |
I have a Web API application that needs to support localization for multiple languages, and I want to know which approach would be most suited.
For simplicity, if I have a collection of books in the database, and the titles need to be translated into different languages and return to the user, is any of the following g... |
What is the meaning of:
You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failure
by Robert Martin on TDD? Is it write only the needed unit test and not more than that? What about "compilation failures are failures"?
|
I'm working on an application (using Onion Architecture) and I want to have good log of entities' changes.
I'm struggling to find any good examples of what are the best practices - and I want to avoid bad architecture decisions at the beginning of my project.
Let's say I have few Entities (Aggregates in fact): Customer... |
I basically read across the entire internet that exceptions are bad, slow and should be avoided whenever possible. This confuses me because I thought I have a "valid" case to use exceptions.
Consider an input parser which transforms a string into an expression tree, that a calculator can evaluate. For me this seems per... |
Within our codebase we have integration tests like these:
func TestActivateSuspendedFoo() {
// setup all dependencies
baz := jsonToStruct(
"baz": {
"a": "someInfo",
"status": "active",
"start_date": "01/01/2020",
}
)
SendCommand("create_baz", baz)
... |
I am still trying to wrap my head around CDN's in a real world scenario.
Suppose I am building a Netflix clone.
I have about 1,000 terabytes of video content stored in an S3 bucket.
Since Netflix is used globally, I'd probably replicate it across the globe for lower latency. So, now I have 20 of the same S3 buckets... |
Well consider a relative simple server for a SPA application. Written in nodejs with express and knex as backends.
Now if we do it properly each function will have unit tests (as they are always all visible to the end user). But besides of the choice of what function to create unit test for, is abstracting away the dat... |
Everyone creates bugs, including me and my teammates. When bugs are pointed out to them, they're friendly and try to fix the bug. But their fix is 'wrong' and just creates a more subtle bug. Usually this takes the form of them thinking that the bug is an edge case, and they put some special check in.
Sometimes they wi... |
I work in a young (< 3 year-old, <15 employees) startup. Our core data product is a recommendation engine. One of my primary responsibilities is to prototype the recommendation engine. Because the company is so young with very few clients, there are not many observed data (< 1000) in our system. We heavily rely on exte... |
I'm trying to build chat application in Android (future maybe webapp also) using websockets. The purpose of this project is to familiar with websockets, get know websockets and real time applications. Right now I'm able to send/broadcast the messages to all clients(android) connected to the websocket server running on ... |
I am reading the book TDD by Example and one of the patterns demonstrated was the self-shunt pattern.
Basically, if I am not mistaken, if I have a test like this:
test("list of users should receive a new user"), () => {
const user = new User()
const listOfUsers = new ListOfUsers()
listOfUsers.insert(user)
}
Then... |
I'm working on a project which at the moment is not being used for any commercial purposes, and I'm managing the data by using a SQL Server Database.
I read here that I should pay for it if I ever wanted to upload this database in a productive environment.
So my question is: Is there any alternative to keep using it fo... |
I am trying to create a simple setup for xUnit. At the moment, the function does not access to database.
So, here is my structure: I have 2 projects in my solution. First is my class library which is going to be the function to be used by the callee. The function is plus and minus 2 numbers for simplicity reason.
names... |
Say I have a server exposing an api that let me retrieve 'things', there are a lot of things, and as such retrieving all things at once could take down the server, hence the exposed API returns paginated things instead. The exposed API is something like this:
Page<Thing> getThings(int pageSize, Optional<Token> previous... |
Say I have a method like so:
public boolean extract(String string)
{
// return true if string can be extracted, false otherwise
}
And a caller
if (!StringUtils.isBlank(myString))
{
boolean isExtracted = extract(myString);
}
// do something else
Does it make more sense to move checking the string is empty or null in... |
We have a wpf mvvm application with a lot of "panes". Just like the draggable panes in visual studio for example.
All of these are individual usercontrols with their own viewmodels and im trying to figure out how they should communicate with each other. For example: If i add an address in the address editor pane, the a... |
Let me preface this by saying that I am familiar with RDBMS. I have a solution using mysql/mariadb but I am not happy with the efficiency of the solution so I'm looking for alternatives.
I'm trying to find the most efficient way to store large amount of integers and be able to retrieve specific subset if it exists. Le... |
I have a Buffer which wraps a stream of binary data.
The first byte indicates order, either big endian or little endian, which is needed to unpack the data.
class FooBuffer implements Buffer is
private field stream: resource
private field order: int
constructor FooBuffer(stream) is
... |
I've been interviewed by some experienced engineer, when he strongly disagreed with some statements I said:
Assuming full control over your applications, It's a standard practice to make writes-to-database exclusive to one single application or controller (not about multiple application instances, but different applic... |
Red-Green-Refactor
Green stage says, Make the test work quickly, committing whatever sins necessary in process
Having an idea of writing a test & make it work quickly, does not look intuitive for a good software engineering approach.
Refactor stage is the actual stage, where we do real programming, after performing si... |
Here is my class library code which I have C# and xUnit.
namespace XUnitSample.ClassLib
{
public class DataAccess : IDataAccess
{
public void AddPersonToPeopleList(List<Person> people, Person person)
{
// TDD: 01 - Write a unit test which 'shouldfail'
// If the 'shouldfai... |
I have these 2 methods which give the same result. One is without yield and another one is with yield.
public static IEnumerable<object[]> Data() {
return new List<object[]>
{
new object[] { 1, 2, 3 },
new object[] { -1, 1, 0 }
};
}
public static IEnumerable<object[]> Data2() {
yield ret... |
(This question isn't a duplicate of Why do we need the async keyword? - it's more of the opposite: I'm not questioning the async keyword - I'm asking if compilers could elide the use of await completely behind the scenes, making async code syntactically identical to synchronous code)
The await keyword in many languages... |
The title is deceptive; the question is really "why does C++ have classes and not only structs?"
Often, people ask why C++ has structs if they are functionally equivalent to classes. The answer is (as in most not-type-safe/not-OOP/not-modern/not-... things in C++), is "inherited from C to not break compatibility". Well... |
Suppose you are writing a software where there is a popular existing library that does not have all the algorithms/features you want but provides some "vocabulary" (equivalents of std::vector/std::string for domain) types you could use.
Should you use that library and be tied to it or write your own types you use on f... |
I'm using GitLab for open-source projects, they are all configured with the same visibility settings.
However, one of the projects is behaving differently from the rest.
The Project visibility is Public.
I've configured Pipelines visibility with Public and Everyone With Access.
While the repository is accessible, us... |
Requirement
I am currently working on an android application that uses MVVM, live data and databinding. I have a use-case where I need to show a Comment button in multiple screens in my android app.
The business logic is simple, when the user clicks on the button I need to check if the user is logged-in to the app or ... |
We have a series of environments; Let's call them Development, Integration, Business and Production.
As a rule, we do not let master get deployed beyond Development, meaning any code which is to be tested by the business in the Integration or Business environments must have a pull request approved.
The problem arises w... |
I have seen tutorials like this one about how to import models from assets, instead of having them in your code. What is the purpose of that? Why not have them in your code? This also applies to textures. A comment on this question of mine says to not do this.
Isn't it easier to have the data in the source file ready ... |
I currently maintain an Excel file that has ~20 inputs which is used to modify thousands of simulations. What I'd like to do is expose the inputs as API endpoints for both analytical developers and my own frontend. Where I keep going back and forth on is wether or not the caller should ask for the state after each mo... |
So I'm trying to create a simple website where I run a computationally intensive task on the backend based on input submitted by a form. For reference: my goal is not too dissimilar from something like this. Here the underlying computation that's being performed is too intensive to be run by the webserver and should be... |
I've found two definitions – roughly:
the order of things that feels natural or standard to humans (like alphabetic order)
the order of things that is natural or intrinsic to the data type in question (like ordering numbers from smaller to bigger)
The two can obviously overlap, since what's "natural to a data type" i... |
The link bellow is the Intel Instrinsics Guide for intrinsics functions. (SSE, AVX, etc.)
https://software.intel.com/sites/landingpage/IntrinsicsGuide/#
Does this functions also works on a AMD CPU, with the exact same header files and function prototypes?
If not, where can I find the same guide for AMD CPUs?
Thanks!
|
We are designing an API with multiple controllers and having discussion on where should we put one of the functionality and which controller should take responsibility to hold that. Will try to explain our use case by taking the example of Flight, Schedules, and Pilots. (consider all are having dedicated Controller and... |
I'm trying to get to grips with Domain Driven Design and MediatR. A reaction to being involved with applications that favour Services for almost everything. I see so much value in DDD and I'm trying to increase my understanding to write better more maintainable software.
For software context I'm using a .netcore Razo... |
I'm using a microservice architecture. when something went in one microservice I want to catch it in another microservice. To say briefly I have synchronization. But there I have one problem, I have a domain model with its own attributes and behavior, I would like to get that data in another microservice. Basically I'm... |
As an example, in PHP you can run
gettype($myVariable);
to obtain the type of a variable $myVariable.
Is such functionality antithetical to OOP principles?
|
I have a trained neural network about to go into production, and am wondering about when to update it with new data.
Say, if the "Similar questions" banner when asking a question is recommending other questions with a neural network, trained some time ago, on duplicate questions. Under what circumstances should Stack E... |
I'm looking for references that might help explain what I've seen in software engineering regarding processes for developing in the front-end vs the back-end. They are both difficult, but I tend to feel that the front-end is easier to write stories for, and to possibly estimate the amount of effort (time).
There might... |
I'm building some Minimal Perfect Hash from multiple datasets using the CHD algorithm
I would like to know if there exists a "smart" way to combine all the different MPH obtained from previous steps and use them to build a new one at minimal cost.
|
My boss has this idea in his head that once something gets through code review and lands in develop it should be "good enough" to never be touched again.
He is not very pushy, he has been a developer for 10+ years and still codes. So I can't just put it down to "he just doesn't know how programming works". He is not th... |
How are these principles applied in the context of streams and lambda expressions? In particular, the applicability with respect to the following three principles: - Single Responsibility Principle (SRP) - Liskov-Substitution Principle (LSP) - Open-closed Principle(OCP)
I feel like Lambdas, in general, have single resp... |
In 1970, Edgar Codd published his landmark paper ‘A Relational Model of Data for Large Shared Data Banks’ where he defined relational databases as well as their normalization to first normal form (1NF) in section 1.4, page 381. It is a procedure for eliminating non-simple domains (domains whose elements are relations) ... |
I was recently tasked with thinking about returning optional tracing information about the execution of a complex algorithm. It's the kind of data you need to analyse the inner workings - a bit like logging of intermediate results but being programmatically available to the caller and optional.
I only had rather bad id... |
After many research, I still can't find a neat answer about this question:
Let's assume 'lo' is our loss for a state-action pair calculated with the Bellman eq.
I don't understand wich one here is correct:
Should I backprop the same loss for every output Q(s,a) in my network?
Should I ONLY backpropagate the loss for ... |
I have been the sole developer on a project for the past eight years. Right now it's one big monolith, but at this point it's really three separate apps, and those really need to be broken down as the apps use some of the same data.
My original plan was to break all the bits into microservices, but after researching t... |
I'm developing an ETL process in Python and Pandas to pull data from a rest API, and then dump it into a relational database. A few of the fields that come back contain sensitive that I do not want to expose in the wider general purpose table.
I can run a drop column command and then not worry about the data. But I wan... |
As a programmer I have found my code frequently elicits the reaction "I don't understand". Whenever I get this response I try my best to explain my code patiently, and not make anyone feel afraid to ask questions.
I am pretty sure I've got the second part right, people are certainly not afraid to ask questions about my... |
I am exploring the ECS pattern and my pet project is a simulation of an economy where the primary mode of interaction between economic agents is a transaction. Some of these agents are market makers (they passively advertise offers to trade - sometimes called making a market). Some agents are market takers (they browse... |
HTTP has safe and idempotent HTTP-methods.
Idempotence in HTTP is not exactly the same as idempotence in mathematics, the definition states:
Methods can also have the property of "idempotence" in that (aside from error or expiration issues) the side-effects of N > 0 identical requests is the same as for a single reque... |
I have multi endpoint for my website ( Backend, Api, internal api for application and ... )
There is a lot of code that duplicate between this endpoints.
for example for signup I repeat these lines 3 times
$user = User::create(['email'=>input('email')])->save();
Email::signup($user);
// and there is more logic
So my q... |
I've been working with C# and .Net Framework for a little more than 1 year. When I arrived on this project, there was already someone who laid the solution/projects structure and his approach was "separation of concerns" oriented and I tend to agree with him on this one.
But recently we asked some contractors to work o... |
I have a base class [for example]:
class base
{
private:
std::string name;
public:
virtual void set_name(const std::string& name) = 0;
virtual std::string get_name() const = 0;
};
And 20 class inherited from it.
And I have a UI (build with Qt) which user can select type of class to create it.
for handle... |
I've started developing a Java API which will consist of just a couple of public classes, a public interface (to be implemented by the user and used as a callback, like in the Observer pattern). All other classes are private and/or package-private. I want to use TDD. For all the reasons stated in other posts on this si... |
I am currently working on a domain that is fundamentally driven by analytics. I'll use a fictitious example to illustrate my question.
Suppose the application is a service based on House Prices. The goal is to use predictions generated by a data analysis pipeline to help real estate agents make buying and selling decis... |
A valid sequence of code-points can begin with one or more combining mark, which form a grapheme cluster that has no base glyph.
I'm unsure how that should be handled, if at all.
For example, consider a string consisting solely of an accent, with no "letter" attached. Is that grapheme cluster valid? should it be "sanit... |
TL;DR event-driven system seems to focus on a highlevel view of the system ("error rate is 0.5%"). How are IT operations supposed to locate and remedy individual issues in such systems?
In today's mainstream push towards distributed systems the even-driven architecture is often regarded very well. Among the benefits o... |
So, I have project in which several WebServices will be created (REST). For the sake of simplicity, Lets name them A, B, and C. A and B handle different tasks, but both of them consume C, which is the only one with Database access.
A - Manages X Tasks
B - Manages Y Tasks
C - Manages Database Interaction
They all are pa... |
I've never coded in Python. In languages like C# or Java a lot of people write interfaces for (almost) every class so the code can be more easily testable (by implementing IoC) or other reasons and is considered good practice by many.
I'm confused because Python don't have built in interfaces as the other languages I'v... |
The more I write OOP, the more I realize that besides reasoning & structure, there isn't much for me and things make more sense if I combine that with functional or just straight-up non-OOP. Not over-engineering is truly a blessing when working with large code-bases and in that case, your #1 goal should be to create c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.