instruction stringlengths 34 36.1k |
|---|
Why is it considered good style to do all imports in a python application at the beginning, even if what is imported is used only once?
I have been programming only shorter pieces of software for a few month now, around a 1-2 thousand lines of code, and it would seem to me to lead to clearer code, if imports that are ... |
In system testing, a software system is tested against requirements.
In unit testing, a software module is tested against the internal requirements for this module which depend on the specific software design and are not visible to the users in general.
I don't like the term internal requirement because a requirement i... |
I'm new to programming and mongoDB and learning as I go, I'm attempting a mapreduce on a dataset using mongoDB. So far I've converted the csv to json and imported it into a mongoDB using compass.
In compass the data now looks like this :
_id :5bc4e11789f799178470be53
slug :"bitcoin"
symbol :"BTC"
n... |
I am having a real difficult time writing some clean code with a simple user registration/login manager. I am trying to stay out of nesting/callback hell, and am also not seeing any benefit in using the supposedly cleaner async/await.
Take for example my user registration code. It must perform 3 promises in sequence
E... |
What type of components could benefit from RPC over HTTP, vice-versa? Does there exist other information exchange mechanisms, what are their use?
I've seen smart people use both, I'm sure for reasons I don't quiet understand. Thanks.
|
I am a beginner in C++. I'm currently experimenting with the Chromium source code and have noticed the following:
For many of the cc files, there exist an h (header) file which is imported by the cc file. The content of the header file seems to be a set of abstract functions which is fully declared in the cc file.
For... |
Given a simple loop in C or C++ such as the following:
for (int i=0, j=0; i<5; i=i*2){
j=j+i*1;
}
I would like to use a tool (gcc, clang or any other) to optimize the code without actually compiling it. I just want to see my own source code optimized. Is such a tool available?
|
I am new to PHP . I have primarily worked on java. I want to run the helloworld program for PHP. I got it how to do it through
blog
But I have got some basic questions :-
Do I need to install both Apache and PHP separately or there is a way where Apache come bundled with PHP ? On google , I see to install LAMP but n... |
If my function meets the two requirements listed below, I believe that the function Sum returns the summation of the items in a list, where item evaluates as true for a given condition. Doesn't this mean that the function can be classified as pure?
Requirements
For given set of i/p, the same o/p is returned irrespecti... |
XSLT is a mature, widely accepted standard.
It can be used in browsers (even in old IE) and on the server side (nginx has an XSLT module, which can be used from programming languages, of course). Its implementations are compiled and, therefore, should be much faster than Python or JS. The JS implementation Saxon JS can... |
If I define a variable of a certain type (which, as far as I know, just allocates data for the content of the variable), how does it keep track of which type of variable it is?
|
Should the function that operates on the object return it?
Shortened example:
class Example1
{
public function method($a, $b)
{
$result = new Result($a, $b);
$this->multiplication($result, 2);
return $result;
}
private function multiplication(Result $object, $value)
{
... |
Do I need to create a different use case diagram for my mobile app and for my web app? I have a mobile and a web app but mobile users cannot access the web application. Only the admins can do that.
|
I am designing a multi-tenant application which will use the same database schema for a separate DB instance per-tenant (i.e. every time I get a new customer, I create a new database for them). This approach is desirable for its simplicity in that I won't need to filter data per-tenant -> I can just select every User i... |
In the context of domain-driven design, events usually describe something that has already happened (domain events, integration events). Commands on the other hand are directives that may or may not be executed in the future. This distinction is also given in another SO answer.
However, in event sourcing, we have event... |
When authoring OOP code, sometimes you have a file that only contains one class, and nothing else.
PEP8 says that all modules and all classes should have docstrings outlining what they do. But in this case, the module is simply a container for the class. If you put a description of the class, then the information is du... |
Consider unit tests for two (or more) consequent layers in web-application, backend, eg views (these are concerned with parsing form parameters, rendering the response) and actions (application logic). In the view, calls to actions are mocked. In the actions calls to underlying level are mocked. Tests are fast, but are... |
I have a simple neural-network which can create new text out of words which are likely to come after a specific word.
The code lacks of comma placement and punctuation.
It also can't transform a sentence into a question.
The code has the following steps:
Read the training texts
Create the network out the above explain... |
I am trying to make my own programming language by making an interpreter for it in Java, but lately people have been telling me that an interpreter needs to be in the same language as the one it is interpreting. Is this true? Then what am I building?
|
Is there a generally accepted term for a method that does nothing more than calling another method (and returning its result)?
|
How do I manage maybe 1000 SQL-queries in a Golang REST API?
My SQL experience is at the upper basic level using Postgresql. I am today using a tool that you can use plain SQL as well as sort of ORM to direct access the database. The aim of using ORM is to make simpler, but with complex queries it really makes it harde... |
I'm not sure if this is the right place to post this (I'm fairly new, but Stackoverflow and Superuser suggested this site for my question), but here goes.
I currently have the following:
A frontend - made with WPF
A Dll
An IO-server - Hardware.
The Dll contains ways of communicating with the IO-server, and the fronte... |
What's a good place to put pure functions that have connections to a system?
public class Core {
System system;
}
public class System {
SubSystem subSystem;
// subSystem.Multiply(a, b);
}
public class SubSystem {
public float Multiply(float a, float b) { return a * b; }
}
In this case, the SubSystem ... |
I have seen many implementations of the Builder pattern (mainly in Java). All of them have an entity class (let's say a Person class), and a builder class PersonBuilder. The builder "stacks" a variety of fields and returns a new Person with the arguments passed. Why do we explicitly need a builder class, instead of put... |
In my current situation I am one of two developers at a manufacturer. We have been extending the functionality of existing applications (ERP and some others).
These third party applications do not allow for much modification of their database as it may/would break the application. We are strongest in T-SQL and have m... |
I'd like to document that code encapsulated in a class is "time-based" in a Java-like language – the code behaves differently based on what time it is currently. To make it testable, it would read from a TimeProvider interface or something similar.
Should this documentation be done through an interface or just as func... |
Recently I've heard a lot about automating test is taking away manual jobs from the QA sector.
When I look at example of what it is about most of it is just running a sequence of functions over and over to make sure it ends up in same results or other similar kind of tests.
What exactly is groundbreaking there?
Couldn'... |
At the end of a 2 week sprint and a task has a code review, in the review we discover a function that works, is readable, but it's quite long and has a few code smells. Easy refactor job.
Otherwise the task fits the definition of done.
We have two choices.
Fail the code review, so that the ticket doesn't close in this... |
Note: this question is not strictly PHP-oriented, since both Docker and Composer can be easily used outside of the PHP ecosystem (although such cases would be rather rare IMO).
In one of the projects I work for, the production environment is set up in a way that uses an image with Composer only (i.e. https://docs.docke... |
We have a system which generates db records and a ever increasing id named archive_id ( bigint in postgres).
sample table: record_table ------ archive_id bigint,info varchar
Another system continuously polls the first system DB and get records in its system based on archive_id column.
When first system DB is restored t... |
I was trying to find more info on the matter but could only find this:
In C++ why and how are virtual functions slower?
The answer says that the virtual call "Get[s] the right function address from the vtable into a register (the index where the correct function address is stored is decided at compile-time).".
But how ... |
I know -- it depends, right?
What I'm asking is whether the notion that sprints/iterations in agile development should always be back-to-back, with only a review and planning meeting to separate them from each other, is correct and/or good for a team? I've been on plenty of projects for different companies now where we... |
I am making a project using the Laravel framework.
I plan to create unit tests for my project. But I feel I don't really have an idea what to test because I mostly use library or framework functions. Even though I create my own functions, they usually are compose of functions called from Laravel and libraries I use. He... |
I'm currently working on an Android application that broadcasts the location of the device every 5 seconds.
Pseudo showing current app process:
deviceLocation = getLocation()
if (hasChanged(deviceLocation)) {
putRequestWithLocation();
} else {
// Send heartbeat so we at least know device is still connected
... |
Let me illustrate with an example.
Say I want to create a class Returns that generates the returns of a stock for example. Returns can be arithmetic or logarithmic, and I want to be able to choose at instantiation which I want. For the moment, I do the following:
def arithmetic(prices):
daily_ret = []
for i row... |
I am reading "Patterns, Principles, and Practices of Domain-Driven Design" by Scott Millett and Nick Tune and so far it has been a great read (first 2 chapters read) but one term they seem to use a lot and appears to have a fairly abstract meaning is the term "model". They talk about developing a model using domain kno... |
My original design has a domain service that did a lot of work which resulted in an Anemic Domain Model (concepts like BalanceCalculators, AccountServices, etc.). I refactored my design which resulted in Accounts computing the the balance (which is a domain concept).
However, this resulted in me needing to hold a refer... |
I recently watched "All the Little Things" from RailsConf 2014. During this talk, Sandi Metz refactors a function that includes a large nested if-statement:
def tick
if @name != 'Aged Brie' && @name != 'Backstage passes to a TAFKAL80ETC concert'
if @quality > 0
if @name != 'Sulfuras, Hand of Rag... |
In my app server's authentication implementation, an authentication token is generated for every user that has logged in. According to some highly recommended security tips (Implementing Secure User Authentication in PHP Applications with Long-Term Persistence (Login with "Remember Me" Cookies)), this token must be upd... |
We have a team of about 40 engineers who work on a large SaaS platform. As with any organisation, we have an enormous backlog of things we want to deliver from our roadmap. But of course, we also have a backlog of bugs, of all priorities, as well as occasional production incidents to react to.
We're aware of a few mod... |
I'm designing a system that will
Act as proxy calling a service on a back-end in context of user and his session
Manage sessions for users on multiple back-ends
I will expose the system over HTTP.
Most of the requests will need back-end-id, user-id and session-id parameters, now I can model it as path parameters
/:b... |
The UI team deliver the HTML files to the development team.
Developers code PHP on html files to make the website.
But later we face a lot of changes in design. The designing team makes the changes in HTML file and the developers find the committed changes and integrate the same in PHP files. Sometimes the HTML changes... |
I have to sympathetically resolve a debate internally. Take this scenario, it's not perfect but bear with me.
As Arthur
I want to upload multiple lists of appointment data during
the day
So that a SMS message is sent to the patient to check their
emails.
The file is exported from a 3rd party system in .csv, we... |
I have an old branch (old-branch) which I last used approximately four months ago that I used to develop a feature for a specific project. It was never merged back into master because the feature never played out according to plan and was abandoned.
Since then, the project has come a very long way and the codebase now... |
I am trying to understand what exactly an API is.
From my current understanding, an API (Application Programming Interface) is a contract provided by a software instance, that guarantees a defined set of behaviors, which are triggered by a defined set of actions.
An API is a "public" sort of construct, as it defines th... |
I am a sole developer and I recently wrote a new web application in the form of a API with Swagger and front-end. This was customers could use the API on their own, usually forscripting.
It is nearing completion, and my boss who is not a developer brought up that the API looks too difficult for the consumers, and he fe... |
I'm trying to get the Repository/UnitOfWork pattern figured out. We're working on a project with EntityFramework and our DBContext contains 200+ tables.
Right now our approach is to inject whatever repository is required to a service. This way the services can only call a few methods from the passed repository. Service... |
I have been working on a project that integrates spring-cloud-based microservices and MVC applications with SSO. currently, I use spring-session for the session repository service. My current applications login component contains an authentication server to create a session in the backend, and a frontend client calling... |
I want to implement tracking of changes in plain-text documents, in a way similar to how it works in MS Word or Apple Pages. What I am unsure of is the data model and how to store it.
Goal
The expected properties:
disk space frugality
it should be possible to revert all the changes and get the original document
multip... |
For example I need to find a user which its status is 0 and its name is John. So beside usual methods for a Repository pattern (e.g. find, create), I decide to create a method in UsersRepository called findJohnWithStatusZero or to be more generic, a method called findUserWithStatusAndName
UsersRepository.php
<?php
cla... |
I'm a bit new to MVVM, but here's my dilemma:
I have a model (or models, but let's keep it simple)
I want to show that model data on multiple different views.
Ok, so ViewModel for each view gets created
UserControls get created (my views)
each Usercontrol gets a ViewModel
Here's my question: What/where/how do I hand... |
I am developing a service which will expose some APIs through REST end-point.
I have some API which can take a lot of time like say 5 to 10 minutes to complete the requested operation.
I am also writing the client side application which is multi-threaded and it can make multiple requests to server at the same time. If ... |
I have a bunch of PHP 5.6 code that I would like to get up to 7.2. My biggest concern was the change that causes an error when you call a function without enough parameters. Previously, this was a warning. This is the change I know for a fact affects me, but others may as well. So what I did is I put together a small... |
This applies to the Google API for situations where there are many (thousands of) hits in Web text searches.
When searching large text sources, typically books, the default display order of results of well used search terms A and B may list the hits with A and B close together in the text block, first.
But not always.
... |
This is almost getting me crazy. EF bring us a very convenience experience in development.
However, if we need to use the Entity model in the upper layer, we always put a reference from the upper layer to DAL or some layer at the lower which is holding the Entity class. I have visualize the situation.
... |
First of all I am going to give you a brief explanation of what i am after doing. I want to write a program that applies filters to an image using a strategy design pattern. I have read some documentations about the pattern and decided to use it like this.
First I will create an Interface called FilterStrategy which ha... |
I've been scouring information on Entity-Component-System designs for weeks to try to figure out how to implement it in C++, and there are lots of wonderful explanations for different aspects of it, but the one thing everybody seems to overlook in examples is how you actually access whatever the data members are in a s... |
I need to have some common functionality while the derived class needs to have singleton behavior.
For example:
class A
{
//common file functions
}
class B : public A
{
//Needs to be singleton . since there is specific file of this class
}
class C : public A
{
//Needs to be singleton. There is also specific file of t... |
While going through the book 'Head First design patterns ' on Factory Method Pattern chapter , I came across the following question and answer at pp.135 (print publication date of the book : 2004/10/25)
Q: Are the factory method and the Creator always abstract ?
A: No , you can define a default factory method to produc... |
I have some background in Petri nets, and in my last UML training, the trainer explained how activity diagrams are essentially a form of a Petri net with Petri net semantics.
Now read that fork and join symbols are used for modelling concurrency in UML activity diagrams, and I am a bit unsure whether they are actually ... |
If you were streaming JSON to the end user, and every "buffer" of response was in the format of, for instance...
{ "something": "here", "other": 1}
You'd be in a spot where the entire stream together would look like this...
{ "something": "here", "other": 1}{ "something": "else", "other": 2}
So the entire response reco... |
So I'll take the context of Red Hat FUSE as an example because this is what I know. I know that Apache Camel which is the library on which is based FUSE doesn't consider itself an ESB (http://camel.apache.org/is-camel-an-esb.html) but that they consider that Apache ServiceMix can be considered an ESB. But according to ... |
I am designing an Intranet employee reward web app using ASP.NET MVC C#/MS SQL Server. This will only be accessed from within the network.
Employees and managers will be able to give a reward to other employees for a job well done or for specific employee appreciate days. About 1000 employees total.
I'd like to not r... |
Suppose your team writes a software system that is (quite surprisingly) running fine.
One day one of the engineers mistakenly runs some SQL queries that change some of the DB data, then forgets about it.
After some time you discover the corrupted/erroneous data and everyone scratches their heads as to which part of the... |
Hopefully this topic is not opinionated and I could maybe get meaningful answer please. Our problem is, imagine you have two microservices: Car and Driver. DTO of the driver could be let's say as following:
DriverDTO
{
id: 1,
name: "John Smith"
}
and CarDTO:
CarDTO
{
name: "Ford",
driver: {
id: 1,
... |
What I want to know is, how can we still make use of assembly today, in productive manners?
When assembly outperform C, so it would seem practical to write a section of the project in assembly rather than C, even if this will be a section of C/C++ project. I am not talking about pure assembly project here
I also referr... |
I have learned a significant amount of coding, however, it's always been in a scientific environment (not computer science), completely self-taught without anyone to guide me in the right direction. Thus, my coding journey has been ... messy. I've noticed now that whenever I build some type of program, by the end, I re... |
I am making a b2b-webshop system that will have multiple customers. Each customer will have a separate active pricelist which contains the products that they can buy and the prices that applies for that customer.
I am struggling designing this. What is a good practice?
My database looks like below right now, and Im thi... |
Besides the fact that all primitive types of C++ are copy assignable except the reference type, it also doesn't play well with containers or any other parts of the language where copy-assignable semantics are needed. I personally believe this is the reason that std::reference_wrapper had to be introduced to the langu... |
An app generates a PDF based on user entered data in text fields. Copying and pasting users can inadvertently end up pasting "tags" in the field. Eg -
<foo@bar.com>
The PDF generator plugin does not like this and crashes throwing an exception. The App vendor says this "escaping needs to be done on the plugin side"... |
I am just looking into microservices and containerization for learning. I have not really implemented anything yet. In principal I get a lot of the layers of the pattern.
One thing I am not understanding and cannot find a good answer on is a microservice's database. When speaking of a database per service is that per e... |
I am building a internal crm which has contacts which are just people with first name, last name, email, phone etc. Contacts can be one or more types e.t.c. job candidates, hiring managers, customers, workers, sub-contractors etc... and based on the types there are more fields specific fields.
I am building the softwa... |
I want to move a bunch of similar methods to an external class. The class is initialized with the original class instance. From there I can access it either by property (persistent instance) or by method (new instance each time).
Which approach is favorable? In a real system I will have many of these classes holding ma... |
Persistence is an essential requirement for preferences. Developer's preferences are saved in .idea/ folder. It is recommended to add .idea/ to .gitignore to avoid merge conflicts. But then settings are lost whenever
Project is cloned to a new environment
Project settings are messed up and you want to roll back
New de... |
Context: we have a responsive web application developed in React.js, which we have successfully used a few times to run user studies on Amazon Mechanical Turk. Now, we would like to add interactivity tracking to this app. Concretely, we want to track interaction events, which can be either multi-touch gestures (pinch, ... |
Why we do this is for "Planning before we code" and one another point is to "help the newcomers in the team".
We are a team of 5-8 members. We do have API documentation and Readme included with our projects. Writing a solution document once is not a hard task. But problem facing is, It is time-consuming and hard to m... |
The software should be able to:
Draw shapes on a drawing
Save drawings
Load drawings
Adding a new shape should have a limited effect on existing code. There is no user cases, no clues about possible evolution.
I chose a factory pattern for the shape creation. To do so it will use creator classes. It is not clear to ... |
I want to extend class Base which is defined in specific API and the extend the extended again. As you can see below, draw method of intermediate class calculates variable top and I need to use it in second subclass:
abstract class Base{
public abstract void draw();
}
class Sub1 extends Base{
@Override
pub... |
I'm trying to write an application server in python. I have a master process and multiple worker processes created from the master using fork(). I have two approaches in mind about how the workers should handle request data.
Using pipes pass data received by the master using accept() to an idle worker. The worker rece... |
I have a series of points (x,y) and each point has a colour (in the LAB colour space). I need to associate points by similar colour and then spatially. So the end result is each point becomes part of a local cluster or segment.
Is there a specific data structure that is suited to such a scenario? I'm trying to find a d... |
Context
Let's considering a standard web application handling cars. Each car has an owner. So the car structure looks like:
cars(
id INTEGER PRIMARY KEY,
...
owner_id *???*
)
For simplicity reasons, I am using an external Identity Management, in my case Auth0. My question is "how to represent users in a database... |
Description
I'm designing a Node.JS application (more like a full website). The app will send five JavaScript files and will have <script> tags linking them together.
Question
How can I prevent users and attackers peering and editing my code?
An example would be:
Ctrl + Shift + I
In Devtools, goto Sources, select a ... |
Take the wikipedia definition:
Agile software development is an approach to software development under which requirements and solutions evolve through the collaborative effort of self-organizing and cross-functional teams and their customer(s)/end user(s).
so what is this saying? It's saying
groups of developers wor... |
I have some older xsl transformations that I will modify soon. They generated XHTML code from a home-grown XML format. Since I am touching these XSL files anyway, I am wondering how I will deal with HTML 5 not being XML anymore.
I guess it won't be terrible if I still generate HTML (the browsers will still display it),... |
I have a REST API. I want to monitor it -- that it's always up.
That's the canonical way to ping it? Especially when all of its calls require an API key.
Should I create an empty open end point which returns "200 ok" specially for monitoring it?
|
I've been looking through class and friends and similar c++ arrangements to share data, and cannot find how to program levels of share.
No players can know what the other players have in their gold-sack or their arrow quiver, basically.
Only a few players can know such things.
Basically, how do I set up security levels... |
I just started working with a pull and fork model. I keep sync my fork and create a new branch when I have to fix something or for a new feature.
I'd like to know what to do when I have to face the following situation:
Let's suppose that I start creating a new feature
When I finish my new feature and before creating a... |
I have created a login form for my website, but the issue is how to process the data provided in the form by the uses.
You see, I can't just write a basic function like this one -
myfunction(){
if(usename==='xyz' && password==='pqr');
return true;
else{
return false;
}
}
'Cause it will be clearly visible to all in the... |
I am not the first one to ask this but i also did not get anything concrete from other such posts to tell me what is needed so i am posing the question here. Feel free to refer to some other resource.
My organization is constantly trying to implement the agile methodology as its shiny but we know we have not implemente... |
I’m working with legacy web app for managing an animal shelter which need to be rearchitected/redesign, so it can scale and be possible to deploy in a central location.
Currently it's physically deployed on the servers at customers locations (9 and more waiting till centralizing will be possible).
Short description of... |
//This represents my rows in my database
public class PersonModel
{
public int Id{get;set;}
public string FirstName{get;set;}
public string LastName{get;set;}
public DateTime CreatedBy{get;set;}
}
//This is what the client receives
public class PersonDto
{
public int Id{get;set;}
public strin... |
Elements of my team and myself are experiencing some difficulty performing design meetings. The symptoms are:
We get off track easily, a combination of low understanding of the content of the system and want for the solution to be your solution drives the conversation often.
We are unable to come to an acceptable conc... |
I was reading what is a changelog in keepachangelog.com
and says that we shouldn't drop our git logs for the creationg of this file, but I see a lot of projects do it like the Angular framework repository, so I am wondering what is the recommended strategy for doing this, what kind of users are we aiming for or the spe... |
I'm curious on the best way to handle lookup-type codes that can be shared across bounded contexts. For instance, state codes, or business-specific type codes that might be used in more than one bounded context. Does it make sense to have a single database for these, with an api in front to fetch the code lists, or d... |
We have weekly planned release cycle. Following standard semantic versioning system. Like first week V3.0.0, next V3.0.1 patch release, next week V3.1.0 minor release.
Apart from the above planned releases we have N daily bugfixes and hot fixes.
My question is how do I maintain the semantic version pattern?
Should I d... |
I'm interested in all the cases where shunting-yard algorithm can tell if an expression is not correctly written from a syntax point of view.
So the Shunting-yard algorithm takes an expression written in infix notation and transforms it into prefix or postfix notation.
As a simple example, the one taken from wikipedia:... |
In a DDD designed application with CQRS principle how do we handle the case when a command needs to be validated before it is executed on an aggregate and the validation needs to query the existing data?
For instance, in my system I have Customer, Project and Ticket aggregates. A Project belongs to a specific Customer ... |
We develop an application which has now been installed on a few thousand customers sites.
Unfortunately, we have no customer data collection built into the software. This is something we want to implement in the next version. We want to collect a few parameters from the software (what features they are using), as well... |
I am creating a CMD like program where the user manage his "drive" with commands.
I would like to know if there is a way of doing this type of application in a easier/better way.
Actually I'm doing like this:
Listing the commands
I created an enum with all commands to be easy to add and manage commands
Executing the c... |
If I have a page with three cascading dropdownlists, is that an example of controlling the state of a web application (assume it is part of a larger application)?
I want to make sure I understand state management and the need for a system like Vuex and Redux and having the store pattern, one singleton to run it all thr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.