instruction stringlengths 34 36.1k |
|---|
I’m building a payment system for some ebooks with Reactjs on the frontend, Firebase as hosting and database and cloud functions at the backend side. Customers don’t need an account to buy ebooks so they are not logged in or getting an account.
At this point I’ve got a form for their firstname, lastname and email and a... |
I am trying to design and implement a solution for the following problem I am facing in one of my projects.
There are n (say 30) clients that send me data points of the form {timestamp, object}, where ‘timestamp’ comes in strictly ascending order.
I (server) need to listen for them and process the aggregated data from ... |
Any Java project that uses my jar, will almost certainly have an additional dependency on another jar, which my jar also contains as a dependancy.
Problem is, that other jar has multiple versions.
How can I avoid any issues that might arise, in the likely case that your project's version of the 2nd jar is different fr... |
I got a proprietary software (something like a DMS system) to process the documents in file system. The software provide very limited API to manipulate the contents of the documents in DMS but it allows to call command line while processing the document. I plan to write a python program to query the database and extrac... |
I've decided to write two methods, one providing general functionality, and one doing something more specific and narrow that can be done with the more complex method, though maybe with worse performance than a dedicated implementation.
As an example, say that I want to write the methods map and iterate, with the forme... |
Researching this topic took me a long time, mainly because of my lack of knowledge of how RSS actually works, I understand that generating RSS is basically generating an XML file with multiple items each of which have its' own title and description..etc.and then we can display these items on the front-end.
I am asking ... |
I am trying to create a simple app which has 2 activities, which enter text on one activity and then displays it on the title bar if another activity:
EditTextActivity:
MainActivity:
I know the standard way to implement it is to use startActivityForResult:
public class EditTextActivity extends AppCompatActivity {
... |
I have been looking at examples of good REST APIs, and I read that Rackspace's cloud servers API is often cited in comparison with AWS's RPC-like EC2 API.
However, I also saw that their API reboots a server like so:
POST /servers/{server_id}/action
{
"reboot" :
{
"type" : "HARD"
}
}
While this mak... |
Is there something that ratio of the metrics LOC and Sum Cyclomatic Complexity in a project with many modules can talk about?
Does it show the logical complexity of a module/project?
|
I wrote a class ShaderWrapper in C++, that wraps around OpenGL shaders. In the constructor I generate the actually OpenGL shader object, but this method only returns me a handle/id of type int. The actuall shader object is stored somewhere in global space. So my ShaderWrapper objects only have to store one integer each... |
Docker has a lot of potential to solve problems in my workplace in a large team (100) of software developers and it's use to solve problems in my workplace. This includes:
Having a cluster of Docker Hosts that you can run jobs on
Having CI agents run as docker images so you can scale up horizontally as need be (and gu... |
We all know De Morgan's Laws
!(a && b) === (!a || !b)
!(a || b) === (!a && !b)
Is there a community consensus around which one of these representations is easier to reason about (and therefore) produces more maintainable code? If there is not, what is this community's opinion?
|
tldr: I have consumer-like classes that require a number of pieces of information to do their job. It's an "all or nothing" kind of thing: the "producers" providing them with data need to provide all necessary pieces of information or there will be a problem. I want to provide some assertions to make sure everything ... |
I'm using dependency injection to supply one of my classes (SomethingManager) with something it needs (SomethingEngine). In the constructor of the SomethingManager I set some properties on SomethingEngine. SomethingManager
then exposes a set of methods which wrap up calls to SomethingEngine as well as some small bits ... |
I'm working in a team of about 15 people and we're currently in the process of switching from svn to git and establishing a new workflow with git.
I decided to use gitflow as our new workflow because it can solve some issues we had with our not-really-existent workflow using svn where everyone just put his/her code int... |
C often seems to be taught in terms of contracted examples without much regard to code safety, such as buffer overflows etc. I have often wondered if there are proven, totally safe ways of writing C code, because I have seldom encountered C written to handle all eventualities correctly. And now, reading that even the b... |
I have been learning DDD and keep getting stuck at domain separation. I'm currently tackling a "Product Catalog" domain. Now in this domain some products are missing a description or image. I would like to add them if they are missing from outside sources.
Currently I have 2 models: "Product" and "RemoteProduct". Remot... |
I have implemented a ViewFactory to seperate the generation of View Models from the Controller logic. The ViewFactory implementation has a comprenhensive set of unit tests that cover all paths.
As this is a refactor of existing code, I had unit tests which cover the same scenarios, with similar mock setups at the contr... |
I am trying to write my first "real" library.
In my case it will provide a java/kotlin API for sending network calls to a server.
I am a big fan of TDD and would like to code the library in the same way.
Normally I would now separate the networking code from the other code to test if the networking class gets called co... |
I am considering how to write a repository for a new project.
I like the idea of a generic repository like this for the basic CRUD operations:
public class Repository<TEntity> : IRepository<TEntity> where TEntity : class, IEntity
However, I also read that this is against the spirit of DDD. Therefore as a compromise I... |
I am looking at designing an application that has a Microservices back end and a SPA front end. I have some concern about performance, a single CRUD page to populate may require calls to 6 or 7 service endpoints which I can't imagine will be fast.
Is is good practice to implement an additional service layer that essen... |
Is there a way to apply the Single Responsibility Principle to a function where two things need to occur in a loop in order to not need to iterate twice?
For example, suppose I have a function like the following (in pseudo-Python):
def process_stuff(list):
for item in list:
process_one_way(item)
pro... |
What is the best place to use TransactionScope class? Is it in the business logic or data/repository classes?
Example if used in business logic class:
using (var scope = new TransactionScope())
{
Repository.DoSomething();
Repository.DoSomethingMore();
scope.Complete();
}
Example if used in data/repository ... |
I'm looking for a strategy to manage my third party dependencies. I don't mean package managers and vendor techs, I mean a process of making decisions about to add a third party lib or to write something by myself.
My personal aptitude is "not invented here syndrome" - I always desire to write something from scratch "t... |
Situation
I have a Desktop Application and a Web Application.
I need the 2 to interact with each other. Such though that when a button is clicked on the Web App the Desktop App activates and replies with a form for the Web App to fill in and send back. My biggest concern is doing this as securely as possible with mini... |
I'm mainly thinking of x,y coordinates but I guess 3D coordinates and higher also apply.
Let's say I'm writing a function to return the center of a rectangle given its width and height. Which is the more logically correct out of
center(width, height) {
return {
x: width / 2,
y: height / 2
};
}
... |
Which arguments should someone consider when designing a new system and has to either store the name of a person as one field or separately as first/last name?
Pros for single field:
Simpler UI
No ambiguity when trying to enter the name of a person, who has a very long name (often non evident which is the last name / ... |
I have an application comprising a bootstrapper executable, a core library and several plugins (shared libraries). The core library is implicitely linked to all components, the plugins get linked/loaded explicitely by the core library. When the plugins functions get called, I pass several objects defined in the core li... |
Situation:
My app exists as standard and branded version, the branded version has some tiny additional features but most stuff is the same.
Right now i have a basic library with popups and visual elements that i can use in every app i make. Then there are several modules (libraries) (features of the app "things one can... |
I am developing a retail management app with inventory management, I am facing a logic design problem and I don't really know how to address the problem:
How do I reconcile selling item pieces from a pack, for example, I can sell a carton of milk(24 pieces) for 200, and single piece milk for 10.
If I have my products i... |
Assume we have a function that updates a User's password.
Once the 'Update Password' button is clicked, an UpdatePasswordEvent is sent to a topic where 3 other services are subscribed:
A service that actually updates the User's password
A service that updates the password history of the user
A service that sends out a... |
Lets say you have a library that licenses with GPL v3. You have two pieces of code, one of them is your "loader" and the other is your real "code".
So your "loader" makes a request to a server, and the server gives it a string of the real "code". The "loader" then runs the real "code". You are never given a binary vers... |
I've been working on a large distributed system typically with over 10,000 clients living on a single network (LAN) all accessing a central set of API's in the cloud. Not exactly a challenging problem. Where it gets interesting is that each client may be requested to upload a large amount of data anything from a 1 KiB ... |
I'm trying to determine the best way to handle a few issues I've come up with on handling images for my site.
Background:
A small site that houses movie information. I have an admin section to upload multiple movies images per movie.
Image files would be hosted on a CDN so access would pretty much be open.
References t... |
What is the difference and when would you prefer to use Object.defineProperty vs get/set methods in javascript for getters / setters?
Ex:
class Foo {
constructor () {
Object.defineProperty(this, 'bar', {
get () {
return this._bar;
},
set (value) {
... |
I have to edit other people's JavaScript code. The code usually loads some data from a Web API, generates a table, places it into the HTML page, and attaches some event handlers.
Due to the async nature, the program flow is pretty confusing, so I am trying to briefly document it, otherwise each time I get lost trying ... |
I have a process running in a Azure WebJob that generate an Excel file containing images and I want to measure the performance of this process in time.
This process has the following metrics;
The number of images
The time took to finish the excel
I want to create a graph that shows me how these two metrics variable o... |
I have following large object (20KB) cached in memcache -
Product :
{
BasicInfo, //~5KB
SellerId, //int
CityId, //int
AdditionalInfo //~15KB
}
This is being accessed at multiple places-
At some place, only sellerId or cityId is required.
At some places, only basicInfo is required.
At some places... |
I have a base class that has an abstract method;
public abstract void DoSomething(ClassA obj);
I have several derived classes each implementing this method and each checks obj for null (there is no case in any derived class where this should ever be null)e.g.
public override void DoSomething(ClassA obj)
{
if(obj =... |
I have a one-way large ETL pipeline in Scala where I start with protobuf schema A and end up with protobuf schema B. I want to create a many-to-many mapping between the fields of schema A and schema B, where schema B uses a subset of the fields from schema A. The ETL is complex and has lots of transformations where inf... |
I am currently developing my own project where I want to use an API to connect to the database on a web server.
I understand that when requesting data, you should use GET and when you want to upload data, you should use POST / PUT. The problem occurs when you want to log a user in. You are requesting data, meaning it s... |
I generally use auto increment IDs as Primary Keys in databases. I am trying to learn the benefits of using GUIDs. I have read this article: https://betterexplained.com/articles/the-quick-guide-to-guids/
I realise that these GUIDs are used to identify objects at the application level. Are they also stored as the pri... |
What programming language first used / invented the 'Safe navigation operator' (?.) ?
Unfortunately, the Wikipedia page on this subject does not have information on it and googling yielded no readily available answer.
|
Writing code, in my opinion, usually involves 2 kinds of code: logical and functional code.
While the logical part of the code always differs between every app and its goals, often the functional part doesn't change that much (especially the low level simple functional code) and is often reused a lot in the same projec... |
I really hope this is a good place to ask this since the answers might be subjective, but here it my problem:
This is probably irrelevant, but I'm working with Python and Django here.
I have the Django User and each user is related to a Company. The user can create a company and save different copies of the Company a... |
Our situation
We have 8 teams and each team produces 8 artifacts (A,B,C, etc). Half of the teams use Git, the rest use clearcase. I would like to have each team utilize Git but this will be a struggle (wish me luck).
Each team is responsible for building their own artifacts. These artifacts can be scripts, iso's, jars ... |
With one boolean, it is simply 0 and 1, and it's straight-forward to query.
With two booleans, it becomes necessary to specify what each number means, ex:
0 F-F
1 F-T
2 T-F
3 T-T
Here it's easy to query for all entries where the first boolean is T by foo > 1. But what if it wants all rows where the second boolean is ... |
I'm looking at an API scenario where you have an entity, like a phone call, which you can stop once and start once. I was thinking of modelling this as something like the following:
{
start_time: null | date,
end_time: null | date
}
However, I don't want the client to actually be able to set these fields freely. R... |
There are loads of types implementing ActionResult like ViewResult, PartialViewResult, JsonResult, RedirectResult and so on. I have seen two approaches when creating action methods, either always use ActionResult or specify the concrete type which is returned by the action (if possible). What advantage does specifying ... |
In different design books I have read that
First identify the purpose of class (abstraction).
Class should only do one thing (SRP).
methods are defined as responsibility of the class.
As per my understanding public methods handle the responsibilities of the class which require other class [ie interacting classes]
My... |
A C# .NET application talks to an external component by calling a known API and marshalling interop structures from the component's response.
This is already implemented and working well. However, once versioning comes into the equation, things get a bit more complicated: as the component will evolve over time thus req... |
I am working on a feature that will allow the user to configure an email to be sent a time he chooses. Once he has saved this configuration, email will be delivered at his chosen time (or around that time) daily until he/she deactivates that configuration or deletes that.
There can be many such configurations having di... |
In a DB-first EF6 application, we have a data access layer which handles all the interaction with EF.
The objects pulled from the context are EF-generated C# classes, these are then mapped to equivalent POCOs in the business layer. This is a common suggested approach as it decouples the layers.
So whilst the applicatio... |
Being a complete noob to the actor model way of doing things, I a struggling to understand how I would store transaction history in an Actor Model. In the example from ProtoActor Persistence (https://github.com/AsynkronIT/protoactor-dotnet/blob/dev/examples/Persistence/Persistence/Program.cs) the child actor produces a... |
I am relatively (read: completely) new to software development and releasing software; furthermore, I am confused by the terms of the GPL license.
My question (which may have been answered many times over without my knowledge) is as follows: if I use a GPL-licensed piece of software to modify my code, without actually ... |
Preface
I'm having trouble determining if I can use the Qt framework for developing a cross platform desktop app.
Situation
The app is open source, and the libraries it uses are also open source.
So I can provide the source code for the whole app without issue.
However, the app will be communicating with hardware that ... |
I am more experienced with the Database First approach for Entity Framework. I am currently looking at a Code First project, which returns domain model objects from the repository.
Database First
Please see the code below, which is a Database First repository method I created:
public dbPerson getPersonByID(int personI... |
I just finished my compilers course. One of the topics discussed was ways to make compilers more efficient. For example: tail recursion, inlining procedures, strength reduction, removing dead code, constant propagation. Considering that the main reason why C is more efficient than Python is because it doesn't have dyna... |
I am writing DDD bounded contexts with some entities using event sourcing for their persistence and other entities using SQL databases.
To simplify writing of the entities that use SQL persistence, given everything is controlled via the entity in the domain layer is it common practice to skip the notion of referential ... |
We have a config.ini file with methods associated to tables, something like this:
[assoc]
people = getPeopleTable
food = getFoodTable
in our main program we instantiate a database object and we call them like this:
output = getattr(self.db, 'getTable')(config.get('assoc',table))
and in our database class we have the ... |
Say we set a variable in Python.
five = 5
Boom. What I'm wondering is, how is this stored? Does the compiler or interpreter just put it in a variable like so?
varname = ["five"]
varval = [5]
If this is how it is done, where is that stored? It seems like this could go on forever.
|
Say, I have an entity which has a column "inserted_at". Now I want to add a column "expires_at". It can be in hours, days or months.
There're 2 approaches to this:
1) add 2 columns: valid_within_value:int and valid_within_unit_id. Or even a single column: valid_within_value_in_hours:int
2) or add expires_at: datetime
... |
I want to capture the connection between an application and the database in a way that is consistent with relationship between entities as defined in the content meta model.
We are using the full meta model ref 34-8 i beleive my question relates to the data extension and the Infrastructure consolidation extension.
Th... |
For example,to create alternate layout in ListView which uses different alternate color :
<LinearLayout
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textview_publish_date"
a... |
Is overriding a pure virtual function with default arguments good or bad?
class Base {
public:
virtual int func(int i, int j = 10) = 0;
};
class Derived : public Base {
public:
int func(int i, int j = 20) override;
};
|
I'm learning how to work with the MVC pattern, using Laravel, but I have a question. This is an example case, there is a User model and the user can register by itself or an admin can create a new user account using the admin panel, the user should be logged in after the registration and the admin redirected to the adm... |
Say you have a virtual machine with the following instruction set.
0 ACC <= [S] Copy address S from memory to ACC
1 ACC => [S] Copy the value of the ACC to the memory address S.
2 ACC + [S] Add the value at memory address S to the ACC value.
3 ACC - [S] Subtract the value at address S from... |
Aside from the probable dozens of bugs you can spot in the code below, I'd really like to know what would most people would consider testing in the code below. I have 8 similar exported functions, so I believe it is those that I should be testing.
The problem is, they all call the private function sendTokBoxMessage so ... |
I have a User Authentication module in my project, that is managing all user information and is regulated with certain granular access rights as Create User, Change User and Delete User. These are obviously meant for administration uses and a regular user will not have those permission sign to.
Never the less, as a reg... |
I have a class which acts as a Adaptor between an HTTP request and our Application's custom domain request.
So every Http request element: URI, headers, content are mapped to our customized domain object elements.
Another class DataMapper which performs serialization/deserilaiztion of content.
This class is used by th... |
I'm working on a project using Python Flask-SQLAlchemy with a model like this:
car has components,
components can have errors
car has a hybrid_property 'broken' which is true when one of its components has errors.
Tags can be added and are assigned in a table(car_id, error_id, tag_id)
one of the tags will be something ... |
Describing the situation
I'm working on an application (based on the Spring Framework) using a search index (lucene if that matters) to make content of that application searchable. Documents are added/updated in that index whenever the content of the application is being changed and deleted whenever the corresponding c... |
Is this a "overkill" design to store XML data in a relational database?
One point is that these web API REST services can later be used by other applications.
|
I know we should have at least 3 different environments while developing a solution:
Development: The programmers are free to change and push changes any time in order to quickly test their code and integrate with other changes, without the fear of breaking anything - this is connected to the TEST databases and servic... |
Say I have a bunch of repositories:
CustomerRepository();
SalesRepositor();
EmployeeRepository();
etc
Say each one of these has a create method e.g.CustomerRepository could be:
public void Add(Customer entity)
{
_dbContext.Set<Customer>().Add(entity);
}
Say I wanted to use a GUID for all of the entity IDs. Where... |
One of our team likes to write code like this (C#):
if (_someVar != null)
{
_someVar = null;
}
Rather than simply:
_someVar = null;
I've never used the former as I always assumed it was unnecessary, especially in a language like .Net. Before I get into a debate with them I wanted to know if there is any benefit i... |
I've always tried to keep models for direct database interaction only, and keep all the actual logic in the controllers. Usually, a framework or platform provides more flexibility to models and limits the freedom of controllers.
Models are usually able to be called from multiple controllers.
Models are usually able to... |
I'm confronted with a "microservices" architecture consisting of Spring Boot services fronted by a Vaadin Spring Boot application (with an API gateway in between), all written in Java. Communication between the frontend app and the services, and between services, is done using JSON over HTTP (I'm not calling it REST s... |
Recently I picked up the habit of typedefing various types within template classes, as is done in the standard library. For example, a container class might look something along the lines of:
template<typename T>
class custom_container {
public:
typedef T value_type;
typedef value_type* pointer;
typedef val... |
at my company we are using AWS Cloudformation to manage our infrastructure. The templates are written in JSON. The problem is that the templates are getting bigger by the day 5k Lines. Company policy is to write certain projects in one template (i.e. I'm not able to divide up the code into separate templates). And as a... |
A friend has asked me to write a small software program for his own purpose. I haven't started it yet but am thinking about how to distribute it. I mean, there are licensing, encryption and things like that when releasing a software product right?
I just want to know, as a beginner, what I should consider when releasin... |
I am relatively new to Visual Studio (I've spent most of my life on Linux) and I am fairly befuddled about the Windows build process, especially regarding NuGet.
I have a Xamarin PCL solution with several projects (for each implementation), and I removed the packages.config files in each directory and replaced them wit... |
I'm working on a program that solves a certain type of systems of equations. The main data objects are Equation, Variable, Solution. Then I have this interface, which represents all things that I want to expose to the UI layer.
public interface ISystemSolver
{
// Configuration
int NumberBase { get; set; }
b... |
E.g. when comparing two integers as follows in a C-like language:
if (3 > 2) {
// do something
}
How is the judgement whether 3 is greater than 2 (true) or not (false) made internally?
|
I have big asp.net web-forms project, I'm using Linq2SQL, I have 1 model per table (same properties as generated classes by Linq2SQL, I add this models to have more controls of fields).
For some tables I need multiple ViewModels, for example for Product table I have following models:
ProductBaseViewModel contains Id, ... |
I am designing a library to wrap an API with Clojure. The API requires user credentials to authenticate user related calls.
My first approach was to have functions that do each task the API can do:
(defn send-email
[credentials email]
(call-api credentials :email email))
(defn send-message
[credentials message]
... |
I've already asked "Dealing with a large interface".
I have a further question regarding that situation. It was pointed out to me that I used a lot of getters and setters and so I broke encapsulation. I'm aware of this, but I can't really imagine how I would code this differently. All my getters seem natural to me - th... |
I am looking for a solution following best practices to simply periodically validate database entries against some business logic.
For instance, I have the database with employees, and another table with incoming calls.
My service should periodically run the validation task (or tasks, it might be a lot of business rule... |
I'm building for a client's service that allows developers to build client side forms, similar to formspree.io, etc. Basically, developers can set an action to their HTML forms which send the POST data to my service. However, I need a way to authenticate requests.
Formspree does it like: <form action="https://formspree... |
I have access to a Response object in my python backend for returning HTML pages, etc. I can declare headers, content-type, etc.
Instead of re-engineering the Python to use something like Django/Flask (which would allow me to parse JSON data on the backend and stick in right on the page), could I do something like add ... |
I am experienced with OOP but I am just starting to use the MVC model.
I would like to know what are the recommended practices to use PDO within the model and still keep a high level of abstraction.
I have seen on the internet various approaches, the ones I liked the most were:
Making the model extends a specialized cl... |
An interviewer asked me this question:
Given a function f(ar[]) where ar[] is an array of integers, this
functions claims to sort ar[] and returns it's sorted version ars[].
Determine if this function works correctly.
I approached this question as:
First check if the returned array ars[] is actually sorted in e... |
In the repository pattern, is it a "bad idea" to call a service method from another service method?
In most cases, I naturally end up calling repository methods from my service methods. However, in some cases, calling a service method from another service method seems to make sense because the existing service method n... |
JSON supports the following data structures (Java equivalents): Scalar, Array/List, and Map.
A Set is not supported out-of-the-box in JSON.
I thought about several ways to represent a set in JSON:
[1] - As a list
However, a list has its own ordering, so the following two lists, ["a", "b"] and ["b", "a"] are not equal a... |
2022 Disclaimer: I asked this question when I was novice. It is bad.
There are two major mistakes I did :
some of the names given are really bad, because in production code, when you name something xyz_controller you expect it to be a MVC's controller, and that was not the case ; it was a service, and a poorly designe... |
Let's say I have an interface describing a simple service
public interface AccountService
{
public int getUserId(String userName) throws UserNotFoundException;
//...
}
I've written the UserNotFoundException exception myself and it is specific to this service. Apart from that, anything else that could go wron... |
My team is working on a progressive web app. We've been searching for a solution to so that viewers of our app cannot exit the app (it's an in shop app, which we use at our stores that shows content related to the store). I've found several solutions involving putting physical covers over the devices back/home buttons,... |
Years ago, when I read The Mythical Man-Month, I found lots of stuff which I already knew from other sources. However, there were also new things in there, despite the book being from 1975. One of them was:
The Surgical Team
Mills proposes that each segment of a large job be tackled a team, but that the team be organi... |
Let's say I've got a REST endpoint which is returning a list of people from some location, which can be referenced by address.
GET /people?address=London
A response could be:
[{
"name":"Jane",
"age":72
},{
"name":"John",
"age": "23"
},
....
But let's say there are people from London UK, but there are also... |
I'm making a language, and I'm considering disallowing inheritance. To be clear, this means:
class A {} //Valid
interface B{} //Valid
class A2 extends A {} //Invalid
class B2 implements B {} //Valid
However, I've also got composition:
class C = A; //Simple wrapper type around A
class C = A {
fun myFunc(){} ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.