instruction stringlengths 34 36.1k |
|---|
Does i in for loops means iteration or index?
How could I know the original meaning? Some programmers say it's iteration, some say it's index.
It seems to me more of an index we start from --- we go from zero, to the first in length (which is one, of course), and so forth.
But this still doesn't "prove" to me which fro... |
I am building a web application crawler that crawls for HTTP requests (GET, PUT, POST, ...). It is designed for one specific purpose; bug bounty hunting. It enables pentesters to insert exploit payloads at specific parts of the HTTP requests.
Problem
When using the crawler I sometimes run in to the problem of crawling ... |
I am building an application where I need to store millions of images and later tag them. The tags attributed to the images could change over time as the tagging system evolves. Images will then be searched for by tags.
In terms of storing the files, I have eliminated the option of storing them in a RDBMS; I have tri... |
I have this conondrum I have to deal with.
We have this already pretty big application which main purpose can be classified into 2 main functions:
Core data (deals with a pretty complex data relationships and data analysis).
Data presentation/visualization (this is the piece that keeps growing, the reasons to come ne... |
Let's assume that I have a piece of functionality in my application which is responsible for adding a deleted marker file .deleted in a directory that is considered to be deleted.
What would be that best way to implement this? Static function or an object with a single method that conveys this functionality? Those are ... |
I'm fetching a set of tuples from the database, and putting it into a map. The database query is costly.
There is no obvious natural ordering of the elements in the map, but insertion order matters nonetheless. Sorting the map would be a heavy operation, so I want to avoid doing that, given that the query result is al... |
Imagine a data model of an electric company and the city it powers. The company has several departments that manage at least one neighborhood each in the city. The company database includes information for the homes in each neighborhood, the meters installed at homes, billing history, etc... Any employee in a departmen... |
I have an array of unique integers, for example: {1,3,,7,9,31,46,...}, which I want to compress. I have found compression techniques and algorithms for the list of integers, where some integers are repeated but I couldn't find any compression technique for list of unique integers. I would appreciate if anyone could hel... |
is a simple abstract factory. I know abstract factory is for selecting a product family. But my question is, can we still use this pattern if ConcreteFactory1 needs to createProductC() but ConcreteFactory2 don't? And if we can't use, how do we solve this problem?
|
I have a few blogs/websites hosted on my vps. Recently I've decided to move a db on a single central server/vps because all the blogs have the same structure in terms of code and structure of the db.
The problem is, how can I effortlessly start using "application_id" in my db? It will denote a website data belongs to.... |
Whats the difference between tdd and automated tests? I'm confused.
|
I've been working on a LAMP application(a social network), and am about 4000 lines of code in, and have a working prototype. I learned PHP this way, and thus it isn't programmed very well, and am now realizing I should've used a MVC framework; either my own, or better yet, a pre-made one such as Laravel or CakePHP. If ... |
Preface
In an application that is separated by layers or distributed by services it is common to have classes that are very closely related data-wise, but which we wish to have loosely coupled. My usual solution (in c#) is to have them implement a common interface. (There are other patterns, but this is what I default ... |
At my company, we have adopted full Agile methodologies and related tools.
We plan our sprints based on a set of customer requested features by the end of the sprint. Commonly, we do not deliver the features requested by the customer by the end of the sprint and we push to future sprints.
This has me concerned becaus... |
I'm working on a distributed application and getting deeper into Event-Driven architectures with Microservices. Let's say I have been running two Microservices, CustomerService and AccountService. They both have their own database, and they've been keeping in sync with an event-style messaging with RabbitMQ in between.... |
If I have an React/Redux single page application that has - say - a customers page that lists businesses that are customers, and from there each customer can be accessed with a URL like this:
/customer/1
From there, the page lists contacts at said customer, and the user can drill into individual contacts at that custom... |
today, I like to ask you a question towards the capabilities of C++ to realize a specific software architecture.
Of course, I have used the search but have not found any directly linked answer.
Basically, my goal is to build a program which allows the user for modeling and simulation of arbitrarily composed physical s... |
I'm working with a project that our architect has decided to use dependency injection for almost everything. We use an IoC container. One of the main issues that I keep coming across when using this pattern is "How do I pass this bit of data here to a different object that will be used later?"
Often, the easiest solu... |
I'm working on a site for at-home services. What is the best practice to define a service provider's service area?
My initial thought was to define each provider’s service area as a set of zip codes. If the customer requests a service, simply search for providers with matching zip codes - easy enough. I’ve done a bit o... |
The current company I'm working for has what I consider to be an unusual set up for their version control system. I'm working with it but I can't help but feel what they are doing is suboptimal and that they'd have much better process if they used what I consider to be a more standard Trunk, Branch, Tag approach.
I've ... |
So my manager class does 2 things, load items from file and give one item to a thread that asks for it, it also holds the List that will contain all the items.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Bot.Core.MainEnt... |
I've been working on different genetic algorithm selection methods recently.
At the moment I have a RawFitnessSelction class, a RouletteWheelSelection class and a TournamentSelection class.
I've been asked to use a factory/abstract factory pattern to choose the different selection methods.
I think I'm going to go with ... |
I am using tape for unit testing in Node JS. I wanted to ask one thing about better coding while writing unit testing.
When using different inputs to a single method, is it a better idea to use all cases inside one test function or different cases of single method in different test function?
test('getXYZ: get XYZ from ... |
I found a module (single file) contained within a large project (100s of files) on github that was of use to me. Licence is MIT. I created some PRs but the author didn't seem to have the time to accept them. I asked for permission to set up a new project using his module and they were happy for me to do so.
I copied th... |
I'm currently in a university course that requires students to work in groups on a semester-long project. In my group's case, we've been tasked with making a location-tracking system. There are two primary components to the system: the backend (which houses the datastore, exposes endpoints, et cetera), and the mobile a... |
In C++, is it bad practice create blocks of code inside some function, such as the following:
bool f()
{
{
double test = 0;
test = // some other variable outside this function, for example.
if (test == // some value)
return true;
}
... |
I have a rather large class that contains a number of related member variables. These member variables can be grouped into related sections. We've noticed that the pattern of use of the class is to make a copy of an existing instance, change only a few of the member variables, and then do work with the resulting instan... |
I'm reading Robert Sedgewick's Algorithms book and I often see the term API client. Please take a look at this exercise:
Write an iterable Stack client that has a static method copy() that takes a stack
of strings as argument and returns a copy of the stack. Note : This ability is a prime
example of the value of h... |
We're wondering what the best practise for registering types in a IoC-Container is.
What would be arguments for and against the following principles:
Principle 1: Only one Assembly my.project.DependencyInjection
Seperate assembly for dependency injection
One class (f.e. UnityConfig.cs) where all types of the whole sol... |
I'm currently dealing with a GraphQL project with poor architecture. I read about where to put AuthZ checks and they refer to the "business layer" as to be called from a GraphQL resolver.
Up till now, I thought GraphQL belongs in the Data Access Layer (or at least, JUST BEFORE the DAL), but it now looks like it belongs... |
I was recently hired in a company and I have been asked to help writing an API that was left unfinished. I do not have much experience yet so I am never too sure what are good coding practices.
This API will be used later to create an web interface showing information about the application developed by the company. Bot... |
We're trying to build a solution where we have a requirement to check password compliance of a user with respect to all the systems that he has to.
For example, if system 1 mandates that password should have 4 alphabets and system 2 has a requirement of 5 alphabets, if the user happens to have access to both systems 1 ... |
I'm designing the data model of a payment database. One of the domain requirement is to keep track of how the customer paid and, if applicable, what was used i.e.: Visa, Amex, etc.
In the past I have used PaymentMethod to describe Cash, Credit Card, or Check. But I'd like to use the most appropriate name for the corre... |
I have a Class that "controls" the current application state, ApplicationStateManager.
I have an Enum that lists the possible states for the application
enum ApplicationState
{
Idle,
Starting,
Started,
Stopping,
Stopped
}
ApplicationStateManager contains members such as:
public static ApplicationS... |
I have to write API validation functions where the rules can get hairy and have many outputs depending on the branch taken.
These validation functions end up being a nesting of lots of IF conditions here and there (I try to stick to simple condition IF for simplicity), where I have lots of comments to help what's happe... |
In the following code sample, the processes are assigned to different contexts. And each App object will be bound to only one context. Though all the processes run the same code, only those belonging to the context will execute the methods of App. In order to implement this goal, as shown in the code, I have to add if ... |
I will have a database of products where each record will have a number associated with it, let's say, the number of "sales".
I will periodically update the database so each "sales" field for each record will be updated.
I need to sort these records based on the "sales" columns, descending.
I need to track the "ranking... |
I am new to git and I would like to set up a so-called "integration manager workflow" as defined per Git official website with the following diagram
As far as I understand, to do such thing I need to use the following command :
git --bare init
to make the directory my "blessed repository" and then set up read/write p... |
Since I'm better with visual representations, I basically want to get this done:
I did some searching and could only find this
Git: Branch or Fork?
And this one
A decent git branching model for products that should accompany the version of another, third-party product (and pros and cons of one proposal)
But while a s... |
I've tried posting this question on StackOverflow but they told me to try it here since it's not so specific. I'd like to know the name of the algorithm or technique of following implementation. I wonder if this thing present in standard libraries of other languages (my implementation is in Javascript).
Consider a func... |
I am looking for the best pattern to apply in my problem. I have an interface that defines my service class functionality
interface NegotiationInterface {
abstract public function resetNegotiation(Negotiation $negotiantion);
}
A main class implements it
public class NegotiationService implements NegotiationInterf... |
Following Ordering menu items fed from multiple modules the question was raised to me, who is responsible for ordering and alignment of menu items in a modular application.
The previous link suggests that the module who offers the menu item is responsible for saying where it will be located ("at index n", "after module... |
I want to create a mobile quiz app where users can sign up and compete against each other. For the signup I am just using username/password combination.
I want to ask you what are good ways to store the this data. I was thinking of simply saving the username and password in firebase database. Is that a good way? But t... |
I have a route in a RESTful API where I need to pass a single username (email address) but not password. The route is designed to have GET method, so my options are either query parameters or a custom HTTP headers.
I read that sending usernames via query parameters is not a good practice, but could not find any relate... |
I have two applications, first is like starting point and the main app is second one.
Whenever i have to do something, i have to login to the App1, provide some details to it, then App1 builds a Session(sort of a custom session, embeds lots of serialized data) and then re-direct the session to App2. Once I am done with... |
I was looking at the Apache license, and under "4. Redistribution" I have to meet a few conditions in order to "reproduce and distribute."
What if I simply just want to copy and paste some code into my website/app? Is that considered "reproduce and distribute?" Would I still have to do all those things listed under "4.... |
I am currently working on adding more customization to an entity component system library, although the problem is a little more general than that. In essence, I currently have hard coded containers for almost everything I do.
I use a flat map* for storing components (for those unfamiliar with ECS, just consider it as ... |
I want to figure out if its better to inherit a base class or interface or write the code up for entities. To better paint the picture assume the scenario below:
Scenario:
There are 30 entities
All entities have 2 common fields (createdDate, modifiedDate)
10 of the entities also have a extra field called serverStatus
... |
I have a bit of a mental block when trying to model my scenario whilst practicing DDD.
The problem appears to be around 2 entities you would consider to be aggregate roots. I feel these aggregate roots would be an aggregate root in their own respective bounded context.
Essentially, I have complex rules to apply in thi... |
In java/android we can call code written in the c/c++ language for execution speed advantage. I have heard of Ahead Of Time compilation which (as far as i know) compiles the entire application to native code during its installation.
I want to perform some mathematical operations like compression, encryption (not images... |
My website is running on Azure and I deploy via the Deployment slots feature. When code gets pushed to my production branch, my "staging" site gets the code, I check to make sure it's ok, then I do the "swap" with production site. All is well.
Now, I need to create a 2nd production website, where the only difference is... |
I've read this page about design patterns, and how you should treat them when writing your code. From my understanding, as the title in the link states:
Patterns are not building blocks.
If I understand correctly, this means not to use a design pattern until it makes sense to do so, correct? Don't start off saying yo... |
When I program in Java, I make all nullability explicit; that is, an instance of Foo is assumed to be non-null, and if I want it to be null, I use a @Nullable annotation (or better, Optional<Foo>). But C# doesn't natively support annotations, and Nullable<> is only for value types.
But what if I did something like this... |
Say, a gateway server keeps IPs to a main server and a database in a config file. This makes it easier to change the IPs without having to recompile. Does it really matter if this file gets committed? What conditions would apply to guard an IP address from public knowledge in this scenario?
NOTE: The access to the data... |
I'm building an app with a Client table that lists clients and it's PK by an auto-incrementing ID field.
I need an immutable unique identifier for each client that will be used in business logic. For example client will upload a single file to an AWS S3 bucket, I want to use this ID as part of the file naming conventio... |
I have licensed my software under GPLv3 and made it available on Github as an open source repository.
Am I allowed(under GPLv3) to distribute binary releases of the application so it is easier to use ? I know I am obliged to make the source code available to the end user.
Can this issue be solved if I linked if I link ... |
I had a debate with a friend and I'm looking for a way to resolve it and decide which approach is better for maintenance and whether there's some consensus about a best practice regarding it:
If an application shows some data on the UI (for example order ids that are added dynamically by the user) and there's a button ... |
I'am new in Microservices, and this is the scenario.
Background:
I have an Web Application that requires store and retrieve files and let's say that i need to storage documents (PDFs, Word Documents, Excel,etc).
My idea is to create an API in .NET core that allows you to create store files and provide an ID so that wh... |
Let L be an ordered set of positive integers (for example, the set of all primes).
Here, #L = infinity, and N is a positive number serving as an upper limit. Goal is to list the following set M:
M = {all multiplicative non-linear combinations of L | each multiplicative combination < N}
For example, if L = {a,b,c, ...,... |
As far as I know Lua uses closures to encapsulate local variables,
well I've got a function call in a worker thread which passes reference to a callback function, and the async call will be handled by the main thread, means callback will also execute on the main thread. My question is, because I don't know if accesses ... |
I would like to find out if I understand single responsibility principle correctly.
The function below is suppose to return user ID store in database by using the SAM account name pass into it.
Look at the commented codes below, is it true about the single responsibility of a function/method?
Do this function violate s... |
In a recent MVVM mobile app project I wrote a set of API classes and Database classes where there was a clear flow of logic between both api and db code. To enforce the way api and db interacted I created an additional abstraction/proxy layer.
For instance the login process was to call this new layer Login function tha... |
I am in a confusion where I cannot decide whether a rule is validation rule or Business rule. I have simple POJO with JSR 303 bean validation rules.
public class VehicleDto {
@NotNull(message = "Vehicle ID is not given.")
@Size(min = 3, max = 20, message = "Vehicle ID length is out of range of 3 to 20.")
@... |
My main experience working with multithread environment was using Scala, so if I had an object that was concurrently updated by multiple threads I always used Akka. Now working in Java environment I don't want to bring all Akka dependencies and futures complications for a simple case where I have a concurrently updated... |
I would like to know the efficient way one person from my team could completely understand an unknown git repository from scratch (i.e. i don't provide them any detail) ?
Take the situation depicted herebelow
How could a person from my team quickly and efficiently know the complete structure of the repository ?
How c... |
I'm specifically asking about Django here, but I'd appreciate any insight.
I'm currently writing up a basic social network. My plan is to allow users to make different kinds of posts (ie text posts, image posts, and video posts) and then allow them to access others' posts chronologically on their feed. The feed needs t... |
I'm in trouble, my team (3 devs including myself) works with mobile and backend development and we are dealing with some problems trying to order this process. Let me try to explain my situation, our team has two main problems:
No testers (dev tests their own code)
Lots of interruptions along the sprints, to do anothe... |
In my company we made almost every system in micro-service architecture. I working on the backend system, we have many api that working separately from each others. Today We're come up with the question that which component should have the responsible to give front end the data their required.
Let's say we have
Custom... |
I'm working in a project (with Python, SQL, Javascript) where the devlopers before me have started saving sets into database fields.
Example
Here the field "audience" can have sets as content. Is this really a good and working idea? I'm wondering because I was taught to never save lists into a field in a database and... |
The AngularJS commit message format is a set of rules for how to your commit message should look. It has been adopted by AngularJS and other projects. According to these rules, a commit must be labeled in its subject with one of the following commit types:
feat: A new feature
fix: A bug fix
docs: Documentation only ... |
Lately I've been playing with writing my own programming language, following the excellent Crafting Interpreters book but I've hit something of a snag.
I'd like to extend the parser to accept variable declarations in the form of: var x,y,z and to allow for unpacking like [x,y,z]=[1,2,3] (noting that jlox doesn't, as ye... |
I write lots of code that involves three basic steps.
Get data from somewhere.
Transform that data.
Put that data somewhere.
I typically end up using three types of classes - inspired by their respective design patterns.
Factories - to build an object from some resource.
Mediators - to use the factory, perform the t... |
I have an interface that has ~30 methods and has two different implementations.
I am trying to create another implementation which will have some custom logic and at times it will call one of those existing implementations depending on some conditions.
The issue is that I only want this behavior for a subset of methods... |
From Type Compatibility - Introduction:
Structural typing is a way of relating types based solely on their
members. This is in contrast with nominal typing. Consider the
following code:
interface Named {
name: string;
}
class Person {
name: string;
}
let p: Named;
// OK, because of structural typing
p = ... |
The application requires that admin user can provide same actions like real user. It is normal situation when in application changes IIdentity so that when we click to button "Login like some user" result is as if this user logins via default login page, but in this IIdentity we have property IsAdminLoginLikeSomeUser w... |
Suppose you have an event and you wish to add members to that event. Would you design that as event/:event-id/members/ ? or just make it '/members' where you specify the event id in the POST body ?
Dealing with nested entities. For example. An Event has a Mini Event and You wish to add members to that Mini Event. So a... |
I started working in a stock broker that hired me and more two developers to build a piece of software to help them.
I am the newest member of the development team. My friend, another developer in the team, asked me to create a software engineering model to apply in the project, because the way they are doing now is n... |
While writing personal projects as well as well in the job, I often struggle to proceed on the current task because either I get stuck on what I was thinking or didn't thought about all the corner cases that may arise in the future. I was thinking what if before coding anything I do some brain storming and write a seri... |
Say I have an aggregate root called Customer. In this example, the customer has a collection of invoices.
Is it ever "acceptable" for the Application Service layer to create an instance of the Invoice class? The invoice class is not the aggregate root.
I realise it is not "acceptable" for a none aggregate root from a... |
Going through CS OOP classes a couple years ago, the examples they always used for OO class examples were the standard car/tire/engine and shape examples.
I sat down with the book 'Agile Principles, Patterns, and Practices in C#' and the Coffee Maker example attempted to change my view of OO class design. The book sai... |
Background: I'm working on a new project at work that will run in AWS. We're trying to use a modern microservice architecture and take advantage of cloud technology, but we don't have much experience with that yet. Due to some library restrictions, we need to run at least some of the services in Python, which my organi... |
I've always used public methods and recently been advised by one of my friends to always avoid defining methods as public, as far as possible, though I have worked in any commercial company I have never "really" understood the concept of why public methods are not "safe to use at times".
I have worked a lot with c# an... |
I have a DSP (Digital Signal Processor) with a very well defined application, (this explication will be simplified)
The DSP uses TDM (Time Division Multiplexer) frames to receive audio information, the audio information is processed (simple IIR (Infinite Impulse Response) filter) and then outputted thru TDM, mainly the... |
I have a Console project reads inputs from CSV file and tries to save them to database.
For that, I created a class Person that maps a CSV row.
The CSV file has two columns Name and Age. Person class is like.
class Person
{
public string Name;
public int Age;
}
So the list of all populated objects is List<Pers... |
Can you in "plain English" explain why we need Single Responsibility Principle?
Especially that it moves the what I call "bloat" into other places. See below for more info. By bloat I mean in my specific case, I have multiple responsiblities in a Controller that exhibit themselves as functions/methods. By applying... |
I'm currently coordinating the development of a software for a certain scientific computational task. The developers are all working on the project on a voluntary basis. Our goal is to publish the software as free software once it is done. The whole project is being developed in an academic establishment, where I'm the... |
I am currently reviewing memory partitions and I have a problem that is really confusing me. Suppose you have 5 memory partitions: 100K, 500K, 200K, 300K, and 600K.
Also suppose you have 4 processes that need to be allocated memory. (212K, 417K, 112K, and 426K)
Using the First Fit algorithm and processing the alloca... |
What are the differences between these? I would assume UI would be the overarching interface for a specific application composed of multiple windows. A window would then be composed of either 1 or possible multiple views. A view would then be a portion of the Window that a view could draw on? Am I thinking about th... |
What is the best way to store/expose locations?
Things to consider:
I want to expose only locations from a specific area to user
I want to be able to let user pick more or less direct locations (ex. suburb or city)
It has to be future proof, let's say the area of available locations will expand
Are there more things ... |
As a CS student, I've learned a decent number of programming languages over the years, most of which have had some concept of a "nullable" or "optional" type. Note that I'm not talking about null pointers or references, or weakly-typed languages like JavaScript where anything can be null. Examples of what I'm talking a... |
I am doing C++ programming in Ubuntu and really care about the efficiency of my code. The computer that I work with has 32 GB of RAM and the compilation is done with the C++11 option. I noticed that for a very large dynamically allocated array such as my_array_1 in the following code, accessing elements occur significa... |
In my C++ project, I have two classes, Particle and Contact. In the Particle class, I have a member variable std::vector<Contact> contacts which contains all contacts of a Particle object, and corresponding member functions getContacts() and addContact(Contact cont). Thus, in "Particle.h", I include "Contact.h".
In the... |
I'm in the process of refactoring legacy code. Unfortunately it is a WebForms application with very tight coupling and smelly code. Currently access to database is inside models which looks something like this:
var fooModel = new FooModel();
fooModel.Select(sqlConnection); // Accesses db and populates model's data.
I ... |
Currently we are developing our microservices by running them all locally using docker. We are now limited by the resources of our local machine and we are trying to find a solution to scale our development environment.
We want to keep quick feedback and our current debugging tools/IDE locally.
Based on this article we... |
When I use the Exception provided by the SPL the options are limited. So it's hard to pick which exception would be best suited to handle File exceptions.
I know the best scenario is to write my own Exception (FileException or something), but I was wondering if the SPL could provide of some use here.
I'm currently thin... |
I have a new requirement that for a given User how many vehicles he can drives. At present this information needs to be shown as a list of vehicles. There can be different types of vehicles, for example:
User A
Cars
SUV 1
Toyota RED
Bikes
Fav Yellow
Rocker blue
And so on...
The users are normally family members h... |
Like it happens to many, our C++ project grew larger and larger, and it finally hit the point where maintainability starts to be a concern, mostly due to build times: even by using ccache, every change requires anywhere from 30 seconds to 5 minutes to rebuild and test (actually it seems that "linking" is the time-consu... |
Say I have two classes: Customer and Invoice. The database tables look like this:
CREATE TABLE Customer (ID int, name varchar(30), primary key (ID))
CREATE TABLE Invoice (ID int, date datetime, foreign key (CustomerID) references Customer(ID), primary key (ID))
I am trying to decide whether this relationship would be... |
I'm giving a presentation tomorrow on Software Process and Machine Learning. My primary goal with the process slides are to get across that most of it is really reliant on project management and personal time management techniques. I mention things related to process cycles (waterfall, prototype, spiral, etc.) and I fo... |
Say I want to create a C# implementation of an API for some 3rd party service, and I want to have an option to get the json posts and responses out somehow, what would be an elegant way of doing that?
Example of a method:
public class MyApiImplementation{
public PaymentRespose CreatePayment(decimal amount, string o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.