instruction stringlengths 34 36.1k |
|---|
I know that doubles are more precise than floats and that they should be used for financial stuff and other things that require precision, but why do we use floats? Why not just get rid of floats and use doubles for everything since they're more accurate?
Sorry, if this should've been asked somewhere else. I feel like ... |
After reading the pros and cons of both camps, the consensus I gather is that, go monolith first then microservice only if you really need to. But then those transitioning from an already big monolith are often struggling.
That said, if you're starting something from scratch, what are ways to design a monolithic app so... |
Why do you think the definition of Comparable<T> lacks an upper bound on T?
That is, why is it not defined as:
Comparable<T extends Comparable<?>>
or
Comparable<T extends Comparable<? super T>>
Wouldn't the latter two proposals be closer to the intended correct use of the interface?
The interface documentation starts... |
Let F(x) be a function that calls G(x), in which x must be greater than 0. If G already does assert(x > 0), should F do it as well?
|
Currently I use SVN for my project and the structure looks like this:
trunk/SharedLibrary/
trunk/platform/wordpress/ <- platform base directory
trunk/platform/wordpress/SharedLibrary <- external with relative path ../../SharedLibrary
trunk/platform/joomla/ <- platform base directory
trunk/platform/joomla/libraries/Sh... |
I've been reading up a lot on the subject, and from what I can gather the following statements 'should' be true in scrum:
1) Estimate user stories in story points at the product backlog level. This allows abstraction of the estimates, and the team can estimate together without dispute - e.g. one developer may complete ... |
I am making a card game, it is similar to Bang. You have a boss, which has some HP and you are getting cards with abilities, HP,DMG, etc. I want to make it as a .io game or maybe just a web application, it doesn't matter now. So the language I am building it in is Javascript + Node. But I ran into a problem with struct... |
I have a REST API written using ASP.NET Core Web API. There are a few business logic based messages I want to send to the clients from the API.
I am in a dilemma on which of the following ways I can use to show the messages:
Method 1:
Assign a unique code(number) for each message, send that code to the clients and deci... |
I have stumbled upon the following problem: I have one list of containers with "capacities", and a list of items with quantities. I want to assign those items to the containers. The total capacity of all containers equals the total number of items.
Here is an example. That's the input:
Container A: 50
Container B: 50
... |
Assume I have a canvas that has rendered shapes. I can drag-move around that canvas as if I was in a zoomed in image to move all shapes around. Between the Model and ViewModel I have a ServiceLayer (or Controller, however you'd like to call that ) that generates shapes based on generic object-logic and applies the nece... |
I am trying to plan out php class structure for an order processing project. I've used classes before but I'm still not an expert on OOP yet. I've been searching for hours and can't seem to find the answer to this particular scenario, despite it being very common.
One of the main objects will be an Order. As such, tha... |
So I'm developing a GUI that consists of many widgets such as checkbox, buttons, radio-buttons, combo-box using Python Qt5.
This GUI is to perform some calcualtion based on user choices.
I'm trying to figure out how to go about saving all this data in a file and then repopulating those widgets when the user opens the s... |
I used to work for teams that built software as a service applications. Our requirements, regarding production, were often the same :
A complex service (web application, database, daemons, typically) to be continuously available.
Bugs to be corrected in fast cycles (and to do so, full specification of production bugs)... |
To the best of my understanding Monads were created to allow for composing functions with those that had potential side-effects - loosely speaking.
For me composition implies code like so:
f(g(h(x)))
In order to achieve this in a programming language one has to "line up the types" correctly, so that the output of h(x)... |
I have to use a built-in API that works like this
class MyAPIWrapper {
func callAPI() {
apiObj.delegate = self
apiObj.doWork() // returns immediately, eventually calls self.delegate.workDone with the result on another thread
}
func workDone(result) {
// do something with result
}
}
You interact wi... |
I came from a monolithic world and am finding microservices architecture very refreshing and revolutionary.
Since Microservices are hailed as transformative, as opposed to the boring monolithic (no one will get a pay raise from proposing to their manager a monolithic architecture), why weren't Microservices proposed i... |
I am new to rest, I have an entity called availableJobPositions. I want to get most Interesting job by sending a person skills. which url is good in restful:
api/positions/skill/most-intersting?skills[]=php&skills[]=mysql
or
api/most-intersting-job?skills[]=php&skills[]=mysql
|
When testing an API (with, for example, Java), what parts should I actually be testing when calling methods of my Controller class (e.g. a Spring RestController)?
For example, lets say I've got a logIn method in my controller.
Said method calls some methods of another class (i.e. my Service class), ultimately returning... |
We developed our app for iOS and Android in native code. Before using scrum we had the following development logic:
We define the overall product requirements (for iOS and Android app)
The iOS developer gets some aspects of the implementation and starts defining the data structures, classes, algos and starts implement... |
My UI components are tightly coupled with my UI framework (i.e. Vue + Vuetify). The framework provides some testing utilities that allow you to fake the rendering of these components without the need for a browser. Then, I use a testing framework (i.e. Jest) to take a snapshot and assert specific values and behaviors o... |
This is a simple scenario in an office with employees and their manager.
In this scenario, both managers and employees have a name attribute.
Only the manager can change his own name
Only the employee can change his own name
Only the employee has a designation and a workStat attribute.
The work status indicates wheth... |
I understand that DDD is a design concept and implementation through ORMs are tricky but help me understand how would you solve this problem?
So here is my confusion on changing on aggregates only though aggregate roots. Given my case(rehashed through JIRA case). I feel this aggregate and DDD feels good about how we mo... |
I have been learning about stateful apps vs non-stateful, but I am still a bit confused on this topic.
For example, let's say I have an app running on Node where users are assigned to random rooms as soon as they connect through socket.io. These are rooms of 4 and not persistent in any way, but they are stored in a glo... |
We are working on an event driven system that works a streaming technology (eventhub/kinesis/kafka). Imagine some system is generating events that are sent to the event stream. Then there are multiple diferent processors that are doing something different with the events and based on the events they update some intern... |
I'm new to Machine learning or Ai but I have been a developer for almost 10 years.
I have a news aggregator application that grabs and save articles from news websites, And I have developed an algorithm of my own that categorizes the news based on it's titles.
The way it works is when I grab a new title I split the w... |
I tried creating an Entity-Relationship-Model, but I just don't get if I have to connect some tables and if I have to connect all, how do I connect tables which don't use attributes from another table.
So this is how far I came, I have 1 main table "inventoryManager" and inventoryManager is getting 2 attributes from ... |
It's a bit of a moot point now that async/await is supported by all major, modern JavaScript engines, but I've always wondered why Babel converts async functions to generator functions rather than to Promises, since async/await is just syntactic sugar for promises in the first place.
It looks like generators came in in... |
After reading this guide on how to mitigate markdown's XSS vulnerability. I've been struggling to find the right way for my scenario. Specifically with one of the points discussed in the guide: the best way to find out if markdown contains any XSS attempt is to first convert it to and check the HTML.
Let's say i am bui... |
Let's say we have the following Python class (the problem exists in Java just the same with equals and hashCode)
class Temperature:
def __init__(self, degrees):
self.degrees = degrees
where degrees is the temperature in Kelvin as a float. Now, I would like to implement equality testing and hashing for Temp... |
I have a conceptual question about SW design.
I prepared the following example:
One abstract base class:
internal abstract class BaseFamilyObject
{
//
//...
//
internal abstract IEnumerable<Device> GetCompatibleDevices(OtherDeviceClass otherDevClass);
//
// other methods
//
}
Six object f... |
I'd like advice about on the best practice for Pull Requests organizing on middle size project. Especially relating to Unit Testing.
Currently we create branch for each feature, what is practically good.
Is it acceptable to send PR with random Unit tests (do not follow feature-model)? Is it okay to save time on creatin... |
I have a structure which looks like
Person
ID int
Name nvarchar
Phone
ID int
PersonId int
Number nvarchar
Make nvarchar
Model nvarchar
MultiSim bit
One person can have many Phones
At the moment, the logic I have is when ever the user clicks the save button, the application receives a ... |
I want to use flyweight pattern to return the same instance of my object each time.
public class ThingFactory {
private static final HashMap<UUID, Thing> things = new HashMap<>();
public static Thing getThing(UUID id) {
Thing thing = things.get(id);
if (thing == null) {
thing = new Thing(id);
... |
I've seen a lot of good questions about similar problems but not exactly what I'm looking for.
Given: a non-unique set of symbols (or characters)
(1, 1, 2, 3)
Expected: an output similar to this (the order isn't important, only the elements outputed)
1123
1132
1213
1231
1312
1321
2113
2131
2311
3112
3121
3211
I know ... |
For example, let's say I write a container class, which supports 2 kinds of operations:
insert(x): inserts an element
get_all(): retrieves all previously inserted elements
Maybe it has some kind of hash set under the hood, or maybe an SQL database, doesn't matter.
It works, it's unit tested, everything's fine, but th... |
I am developing a web app that uses a mysql database. I recently encountered some changes that require me to store 3rd party data having an inconsistent schema. I've decided to use mongodb as a solution for storing these entities. Furthermore, these entities have a many-to-many relationship with an existing table in... |
I am working on a desktop app that offers uploading to the cloud storage. Storage providers have an easy way to upload files. You get accessKeyId and secretAccessKey and you are ready to upload. I am trying to come up with optimal way for upload files.
Option 1. Pack each app instance with access keys. This way files c... |
Suppose I have a method in client code that expects an interface...
void DoWork(IDataManager data) {
//use IDataManager interface in the DoWork method
}
And the IDataManager interface looks like this...
public interface IDataManager {
ITypeAData TypeAData { get; }
ITypeBData TypeBData { get; }
}
And each ... |
I have one function that is used to compute distances of an object in 3 different ways.
Is one of the following two methods considered better practice:
Creating 3 different functions, one each for calculating a type of distance
Creating one single function with multiple if-else statements?
I am using python, and hav... |
I come from a webdev background so I'm used to MVC to handle the separation between the views and the logic (and the data/models).
I'm starting to develop using Winforms in C# and I want to know what's commonly used to develop a scalable, maintainable piece of software.
For example, if I want to make a bussines managam... |
A long time ago when starting learning programming I remember a teacher saying that compiler do not care about whitespace and they are useful to make code readable for human beings. It made perfect sense back then, but I only knew some Pascal and C++.
Many years later, after diving in many other languages I began wonde... |
We have a web service that accepts images and metadata uploaded by end users, and the uploaded images would go through multiple steps of processing / reviewing with human involved.
To monitor the status of the service, one of my colleagues suggested we should develop a monitoring program that emulates the behavior of e... |
// Default initialization
int i; // i has an unspecified value
return i; // Probably 0, but Unreliable
i = 5; // i has a specified value
i = int();// This will give it a specified value, 0
i = int{};// This will give it a specified value, 0
return i; // Reliable, no good!
int j; // Workaround, obvious performa... |
One of the guidelines around building ubiquitous languages is that there should be one per bounded context.
In a domain that has more than one bounded context, and therefore more than one ubiquitous language, how should you deal with vocabulary that is different in each context, but related to each other with respect t... |
I have recently started reading about domain driven design and most of the places it's explained or discussed more in conceptual terms. Being a design philosophy it helps to understand the concepts but I was wondering how should I structure my project according to DDD.
For example in a typical structure used in most p... |
I'm working on a reusable client library to abstract a REST endpoint that we use in many of our in-house applications. It is actually split into 3 APIs, and certain endpoints/resources require different types of authentication (OAuth, JWT, and OAuth + additional BASIC). So to simplify all of that, I'd like to JAR up a ... |
Lets say there are two services. One generates event A and the other event B.
We need to build a new service that implements the function C = func(A, B) , which produces the result C.
But as A and B are asynchronous events, they may reach (and invoke) the new service separately.
Depending on what is required, it may b... |
is there anything wrong with writing code in a way that merges view, repository, controller in the same file?
i.e.
global $db;
// or $db = DBSingleton::get_db_instance();
// or global $container; $db = $container->get(Db::class);
$id = filter_var($_POST['id'], FILTER_VALIDATE_INT);
$record = $db->parameterized_query("... |
I'm designing a service that contains different plans and features. I want to freely assign and remove features from plans. The service needs to tell the client both an ID's plan and the features it should have as a part of its plan. I came up with two ideas for how to accomplish this.
The first idea is to store the ... |
To cut a long story short, assume I have a Register, a Provider and a Generator class.
In my Register, I have the addItem method that allows me to add items to a collection. The Provider's job is to access the Register's data and after some logic, provide items from its collection, basically we have the method, in the ... |
A very common pattern in python is:
for something in ['an', 'iterable']:
func(something)
I almost always see the iterable as a list (like in this example), but it could very well be a tuple, set, or something else. Is the list the most performant and pythonic way to do this?
Similarly, I often see the following:
i... |
I understand this is the place to ask questions pertaining to software design. If my question is considered to opinion-based, is there a forum or something better suited for the discussion?
Objective
My goal is to develop an application which can store & manipulate "historical data" covering the full range of time fro... |
In Section 1.3 Terminology, RFC2616 (HTTP/1.1) says:
client:
A program that establishes connections for the purpose of sending requests.
user agent:
The client which initiates a request. These are often browsers,
editors, spiders (web-traversing robots), or other end user tools.
Can someone provide examples of a clie... |
Everyone knows that new developers write long functions. As you progress, you get better at breaking your code into smaller pieces and experience teaches you the value of doing so.
Enter SQL. Yes, the SQL way of thinking about code is different from the procedural way of thinking about code, but this principle seems ... |
Consider several C++ classes which are all defined in a particular namespace. For cleanliness, each class is located within its own file, and are each well-documented.
For the purposes of completing the documentation with Doxygen, we'd also like to add documentation for the namespace itself.
Does anyone have any sugge... |
Say each microservice is using event sourcing which means it has it's own event store, do you typically add another "mother" event store that contains all events from all microservices as a source of truth on how each system communicated?
E.g.,
|
I am making a web UI and an HTTP API for editing JSON documents in collaboration (role and versioning system).
There are several types of JSON documents. Each type is described by a JSON schema, let us say:
schema_a, schema_b
Each user is assigned a role for editing a JSON document, among:
editor_1, editor_2, reviewer... |
I'm currently working on the control software for a system that includes a lot of user controllable hardware and also has many configurations. Configurations in this context refers to a specific combination of hardware. Each configuration can be thought of as it's own "product" for arguments state.
In previous iterati... |
I am thinking of a very flexible application that will build a single entity object from a lot of tables joins. example for an object "Car"
with a code something like this
SELECT e.id, a1.attr_value as "cost", a2.attr_value as "color",
a3.attr_value as "size", . . .
FROM entity e
LEFT OUTER JOIN attrib a1 ON (e.ent... |
Absolutely academic context question-
I found countless articles listing the order of operator precedence in all languages, but what is the logical reasoning behind that specific order?
For clarity of answers, let's talk about the C/C++/C# precedence table, even though it is pretty much the same in all other languages.... |
I designed a Snakes and Ladders game. I divided into a reasonable amount of classes and I believe I did a good job regarding the OOP design.
I have one question about a decision I made for the design, though. I have a class called Config. This class contains a bunch of global variables regarding Window Resolution, amou... |
I have a reporting system which gets time-series data from numerous meters (here I am referring it as raw_data)
I need to generate several reports based on different combinations of the incoming raw_data
eg:
report1 = raw_data_1+raw_data34-raw_data15
report2 = ....
Also there are several higher order reports dependin... |
I've seen here that it was a dividing topic to use "should" as a prefix for a boolean because it could mean that we're unsure.
Then how would you prefix a boolean such as "myButton.shouldShow"?
I feel indeed that it's a little bit weird so I was hoping to find another solution.
|
Assume a Javascript plugin, for a developer, that's included on their website.
<script src="https://external.com/plugin.js"></script>
The plugin makes a XHR request to a 3rd party endpoint (API). So, which IP is detected at that endpoint? Is it the developer's host IP, the client IP running the script, the external sc... |
Let's say you have a ForeignKey MyModel.related_model and this related_model has all fields either null=True or default=something.
Like User.userprofile which I use on several places in my project. Is it better to create it immediately after User has been created?
either this way:
def save(...
super().save(...
... |
I'm doing a project in unity where I turn off the general gravity and implement it myself. What I'm trying to acheive is to have GameObjects be affected by several gravity sources on every tick. I got to a dilemma where I'm not sure where the responsibility of the physics calculation should rest.
Should I:
a) Have Game... |
Suppose I have the Service that receives dependencies via constructor but also needs to be initialized with custom data (context) before it can be used:
public interface IService
{
void Initialize(Context context);
void DoSomething();
void DoOtherThing();
}
public class Service : IService
{
private rea... |
So I am trying to mix my software skills with my electronics skills, and I want to try something a bit different. Basically: buy a walkie talkie, take it apart, remove the microphone and put a rasp pi or arduino between the mic and the cuircuits, encypting everything sound. On the corresponding device I will do the sam... |
To provide zero downtime upgrades of my highload service I use blue green deployment strategy.
Every moment data changing happens, so how to migrate all data consistently? In the moment I switch between blue and green the data is changing.
What is the best strategy to maintain data consistency (as much as possible)?
|
Consider code below
MyController //MyAction //MyHandler
{
public function processRequest()
{
// ...
$myObject = new MyObjectClass();
$myObject->methodCall();
// ...
}
}
Should such code be refactored to use dependency injection instead? If so, for what objects? All of th... |
Consider two strategies for implementing an upgrade of something with multiple versions (e.g. upgrading an installation of some software).
From any version, upgrade directly to the latest version.
Progressively upgrade through intermediate versions, until you get to the latest.
Is there a generally accepted name for ... |
We have a layer that exists in our architecture that, for lack of a better term, bears the responsibility of defining the common models. In other words, when systems need to communicate, rather than point-to-point, this layer is used.
|----------| |--------| |----------|
| System A | ==> | Common | ... |
Some one help me with my design paralysis!
Assume a microservice (probably going to be implemented in Spring Boot) that has implemented an run of the mill REST API, and after receiving an initial request, it then talks to maybe 2-3 other external services(as a REST client to those services) to look up data to do whatev... |
So I was studying here and I was thinking if the whole point of recursion is to break the problem into multiple smaller problems, what if those problems were solved in parallel? A quick search lead me to links like this where people say it's not worth it because of context switching which makes sense, but what if inste... |
There are languages for which functions take exactly one argument and return one argument. This is nice and symmetrical, and there is no need to accept more than one argument because we can use currying: If we want a a function to take two arguments, we can take the first and return a new function (that has the fist em... |
After the sequence diagram are made the sequence methods become code, before writing some code that would alter database records I would like to know how to detect if a sequence is doing the job without damaging some other part's of the system, what comes to my mind is that there must be a way to relate the sequences t... |
My question is, how would I go about making a function that serves the same purpose of the for loop, without using any loop method.
function fl (initial, condition, iterator, code){
i = initial;
if(condition){
code()
}
i = i + iterator
// Somehow repeat without using any loop
}
// The funct... |
Is there any guideline on writing message which are shown to the user of an app using toast?
For example, if an error occurred, should the app display
Failed writing to the file
or
Failed writing to the file.
Should sentences use full stop? I don't see full stops used in some language REPLs when there is only one ... |
I was wondering, are these 2 class diagrams equivalent EXCEPT the fact that in diagram A, a student doesn't have to have a study program?
The way I see it - for example in diagram B a study program can have many students, and for each one of them, an enrollment is created. Diagram A states that for each pair (Study Pr... |
I want to create an application that will run as a service that subscribes to a Google Cloud pub/sub topic, and delivers emails based on 'alerts' that it receives through the pub/sub subscription. It will read from Cloud DataStore to determine the email addresses to mail to, and it will probably use some type of 3rd pa... |
In my application, the transaction id's sometimes skip i.e. 3314, 3315, 3317 ... I think this happens when a payment is made, but mysql rolls back the transaction because of an error down the line.
I was perfectly fine with this.
However, an accountant working in a company that uses my application said the id's should ... |
I guess it was Robert C. Martin who campaigned against using SQL in one of his apps, where he was just fine without DB and SQL initially. Later, thanks to the abstraction a DB implementation could be built out on a single day (which later turned out to be unnecessary). I think his main point was just to not start out w... |
I'm wondering if you would use the mediator pattern on the following scenario.
First of at all, the program must call an API, and persist this response on somewhere (it could be a database, a file, on a blog storage, and so on).
I see two responsibilities involved here:
pull data from the API, and
place it in some ... |
I think I know the answer to this, but it's particular enough that I don't want to go telling other people stuff until I'm 100% certain.
Suppose I have a class with some dependency:
public interface IDependency
{
int DoSomething(string value);
}
public class DependsOnSomething
{
private readonly IDependency _d... |
I was tasked with writing software for my company. As I am now writing a third program (with many more coming), what's the best way to control the distribution/usage of our software?
The software I'm writing should only be used on our network and shouldn't run elsewhere. We are a small company and don't have the infr... |
Not sure if this is an appropriate question for here, please let me know!
In Scala, the ever so useful Option class has an apply method in its companion object that allows us to quickly wrap any value into an Option:
def apply[A](x: A): Option[A] = if (x == null) None else Some(x)
This is super helpful when dealing wi... |
As of right now I am building authentication library for let's say programing site(It needs to be included in the program).
The problem is that there several languages are used and I want to make authentication library that can be referenced in some of bigger languages like c#,java and python(all in one dll).
I heard t... |
When I was building my backend API I used Django combined with django-rest-framework (DRF) because it was the easiest and fastest way to create what I needed.
And I haven't thought about an architecture of it.
And if I understand correctly DRF provides some kind of Model-ViewSet-Serializer pattern.
So my question is: ... |
So I've been reading a lot about this new front-end architecture called the JAMstack, which is basically the modern way of building static web applications.
Any dynamic pages are pre-built at build time and served as static pages instead of being built on request at run time. This way, sites can be hosted on a CDN and ... |
I am developing a web application where users can upload images and add tags to them. Because the audience is very international, I want the app as well as the content to be localizable.
Most of the tags have a counterpart in all/other languages but some won't.
Current situation
Images table
+---------+--------------... |
I have the single big file (1.2GB+) hosted on the server to download currently served using HTTP/1.1.
We are exploring if we can move to HTTP/2 for better performance and security.
All the places on the internet I see people talking about improvement in speed if there are many small files I need to download. What about... |
I've microservice, let's name it Employee. It only has employee logic, but there's a "foreign key" to the (not really) related company. There's no company resource and no company logic in this microservice.
For adding an employee, there is an endpoint like so:
POST /companies/1/employees
For updating an employee, there... |
I have a task where I need to read a big data file and process the data in it. Every row in the file looks like this:
CustomerId ItemId Amount Price
I need to calculate the total cost for the customer, but first I need to determine the most expensive item purchased. "Most expensive" means the item with the highe... |
If the entity should be always in valid state (therefore the properties are readonly and can be set only by methods which contains validation), How can I build this entity inside Repository without executing validations, because I suppose that database state is always valid ? Or should i always excecute validations eve... |
I am currently working on a report regarding a matrix multiplication distribution system I have been working on. But after reading a lot of somewhat contradictory sources online I have become in doubt whether the network created by the system would classify as being decentralized or distributed.
As I have attempted to ... |
I understand the principles behind opaque data types, encapsulation, information hiding, etc. in theory: preventing alteration to parts of a program can prevent people from accidentally messing it up, and hiding the information is basically just to make it more readable. The thing that I just can't seem to wrap my brai... |
I am not looking for an opinion about semantics but simply for a case where having getters sensibly used is an actual impediment. Maybe it throws me into a never-ending spiral of relying on them, maybe the alternative is cleaner and handles getters automatically, etc. Something concrete.
I've heard all the arguments, I... |
We tried to develop a kinda-real-time statistics module to measure how hot/trend a content is. We know it is hard to achieve high end stuff like youtube/FB/twitter, our goal is simpler :
Count click/read/like/etc.. during the last hour/day/week/etc..
Calculate some basic indexes such as likeCount/clickCount, readCount... |
I'm working on a Game Engine (more like a Graphics Engine for Physics simulations) in C++.
I know a bit of Unity and I like the concept of GameObject and Component Unity has and I wanted to use that in my project too.
The code structure at the moment is as it follows:
Newtonic::Engine: owns the scene, the engine's mess... |
The thing that I don't understand is the prioritization between MVC Controllers and Web APIs.
Consider I want to make a website. I can either program to APIs and for the presentational layer, force the MVC controllers to consume the APIs OR simply go with controllers and don't bother with the APIs for the time being.
W... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.