instruction stringlengths 34 36.1k |
|---|
So I want to save different URIs in database.
I want format to be forced as well to look up different URIs easily.
Is it better to create table like this:
CREATE TABLE uris (
id INT(11) UNIQUE PRIMARY KEY AUTO_INCREMENT,
scheme VARCHAR(255) NOT NULL,
host VARCHAR(255) NOT NULL,
path VARCHAR(255) NOT NULL,
por... |
I'm quite confused about the following terms:
Software architecture
Software application architecture is the process of defining a
structured solution that meets all of the technical and operational
requirements, while optimizing common quality attributes such as
performance, security, and manageability. It invo... |
You've found some code that looks superfluous, and the compiler doesn't notice that. What do you do to be sure (or as close to sure as you can) that deleting this code won't cause regression.
Two ideas spring to mind.
"Simply" use deduction based on whether or not the code looks like it should execute. However, someti... |
My company has been converting to a service oriented architecture, but we have an odd setup. We have a number of web apps. Each one of these web apps currently has their own RESTful microservice. These microservices are essentially an intermediary to our backend REST services. Although they are generally a pass thr... |
I've started to implement a full MEAN-stack application (MongoDB, Express, Angular2, node) and I am struggling with the data design for the access management in the MongoDB. In my old thinking tracks, I have a potential relational solution in SQL, but I want to design it with MongoDB, if possible.
Here is some mongoose... |
Maybe the title isn't that clear so I will explain this a little bit further. I use biojava to perform BLAST searches. However this BLAST.jar contains a lot of classes:
org/biojava/bio/program/PdbToXMLConverter
org/biojava/bio/program/sax/ClustalWAlignmentSAXParser
org/biojava/bio/program/sax/SummaryLineHelperIF
org/bi... |
Consider you have this 2 simple classes:
class Parent {
public:
virtual void foo() = 0;
};
class Child : public Parent {
std::vector<Parent*> parents;
public:
Child() : parents() {}
virtual void foo() {
std::cout << "Foo" << std::endl;
}
};
It seems correct to me! But my teacher says since... |
I'm working on a project (A development accelerator) which had dependencies with a 3rd party NuGet package for a CMS application. The external NuGet package has some breaking code changes to our application from v1.1 to v1.2.
Since our client could choose to user either v1.1 or v1.2 of the CMS application, so we need ... |
I use a traditional MVC pattern for my web projects:
Controllers: handle use case scenarios steps (can call business logic in models or services)
Views: presentation
Models......
I hit a wall with the model that prevents me from properly embracing object orientation.
I got perhaps the wrong assumption that an entity ... |
Because I work at a company with lots and lots of computers, I find it to be a little ironic that it takes half an hour to cut a release of the latest version of our software.
The bottleneck seems to be integration tests run by Maven, and the cause of the bottleneck is because those integration tests seem to want to ... |
Scenario:
I have a production (P) branch and my current (C) branch I created to work on some new features. Some of them are ready, however work on the rest will take more time than anticipated.
I would like to push to production (and merge with production (P) branch) features that are ready now, and then continue to wo... |
When I declare new classes I like to structure them in a specific style. Each public, protected and private keyword is used to either declare methods or attributes, never both. To further clarify the parts, I use short descriptive comments like in the following example:
class SomeRandomName
{
public: /* methods */
... |
I joined a team which has a different approach to design from mine. I believe in YAGNI approach to design. For example, if a method (interface, class) is unused, it has to be removed. That's it.
People in my team are building a modular app, and one of the modules is perceived as "framework". The app is the only user of... |
When transferring object through an API, as in schemaless JSON format, what is the ideal way to return non-existent string property? I know that there are different ways of doing this as in examples in the listed links below.
Avoid null
Return null
Remove empty property
I'm sure I have used null in the past but don't... |
I have a website where users can upload manuals (PDF documents) for their products. Basically, they first add the product to the system and then add 1 or more manuals to that product. A manual can have multiple versions and all versions should be available in the system. In addition, manuals can contain multiple langua... |
I have mainly worked on RDBMS databases. Recently studied MongoDB and liked where we don't have to define schemas upfront. So application developers straightaway can start writing the code. Major drawback that is stated in most of the articles is that MongoDB(or any other document based DB) is not good for transactiona... |
Which solution for my small problem would you consider a better style? Is there another better option that I am missing?
The logic is simple: Process data from a source until you get the END token.
I have couple of imperfect ideas:
line = read_from_source()
while line != "END":
process(line)
line = read_from_so... |
We have a Java application that uses a live 3rd party data feed. There are several steps in our application and in each step the application reaches out to the 3rd party data feed with the current state of the user flow and received back the data for the current step.
Recently, we have noticed that there have been prob... |
We are a small front-end dev-team working with 18 months of experience and recently we got in touch with a first major project, ie. a medium complexity back-office web app, but with lots and lots of views.
Since there are obviously new sets of problems in this project that we encounter each and every day, it would real... |
I'm building a large Desktop application, which will have a range of functionality, for each I wish to have a specific class.
I'm thinking of using a nested class structure to modularize the code and ensure separation of interface vs implementation:
class Manager
{
public:
Manager(); //Initialise *t and *wapi in... |
Which are the main advantages and disadvantages of me using opaque pointers for all my structures? I have been thinking about using this approach and here are some trivial thoughts that I have:
Trivial advantages: structure implementation is hidden, requiring who uses my modules to use only available implemented functi... |
Sorry for the generic question. I have searched all over and found so many threads similar to this, however not one that answers my specific question - perhaps because the term I'm looking for doesn't even exist.
A friend of mine is learning programming, JavaScript specifically, and he asked me why this wasn't working:... |
When one extends a class, how is the proper way of setting code to be executed upon some event of the base class?
Should one handle the base class event this way:
Public Class Class2
Inherits Class1
Private Sub MyBase_MyEvent(sender as object, e as eventargs) Handles MyBase.MyEvent
' do stuff here
... |
I would like to design a plugin framework, but I have not been able to find an object oriented design that fits my objectives.
My broader design goal is for me to let users define classes in a directory. Then, the program would load the classes at run time. The classes would share a common interface such that the prog... |
I am teaching myself to code again and thought I would write a card game.
I need help with my code design (I am using C#)
To start with I am building it as a console application, and later I will extend it so that it works as a web application.
The question I have is whether the Player objects are part of the Game obje... |
I have been reading a lot lately about some core concepts of JS and inheritance is a bit confusing.
Here are the methods that I know of:
// Base class
function Parent(foo) {
if (foo === undefined) {
throw new TypeError('foo is undefined');
}
this.foo = foo;
}
// Derived class
function Child(foo, bar) {
if... |
Regarding enums in java how I understood is
Sample enum
public enum Strategy {
STRATEGY_A {
@Override
void execute(){
System.out.print("Executing strategy A");
}
},
STRATEGY_B {
@Override
void execute(){
System.out.print("Executing strategy B... |
From my Operating System textbook, application and library interact with kernel by system calls.
But as far as I can see, Windows, OS X and Linux, we can only use C Language to post system calls.
That annoyed me when I want to optimize I/O in our Java application -- since I can't use system call directly, So I have to... |
TLDR;
I'd like to add a (modification) copyright and a MIT License to an Apache 2 licensed file, which I modified.
Description
I modified a file that was licensed Apache 2. According to what I understand I had to do the following:
include the license
include the copyright
stated the changes that I made
I did not inclu... |
I've been studying design patterns. I've learned about Repositories, Unit Of Work, Dependency Injection, MVC. I'm now learning about Service Layer pattern.
I'm trying to grasp the utility purpose of Unit of Work(if any) in a Service Layer.
From my understanding services provide encapsulation for specific model database... |
I have nested containers A and B. The attributes are there to show that classes have some other members. One of my functions f takes another container of such containers (let's say vector again).
ContainerA{
int a;
std::vector<ContainerB> contc;
}
ContainerB{
int b;
std::vector<Element> con... |
Most of us know SOLID, and over the years have understood how useful it can get when we need to change.
Based on S & I parts of SOLID and from experience I used to design my HTTP RESTful services as fine-grained as I could. For example, in a simple contacts management system, I would create and expose these endpoints:
... |
There is a @Mark Seemann's cite from a conversation which states that an abstraction must never implement IDisposable:
I like how @nblumhardt put it almost six years ago:
an interface [...] generally shouldn't be disposable. There's no way for the one defining an interface to foresee all possible implementations of i... |
Recently come across an unusual scenario while normalizing an old relational database.
The Facts
There's ~8 tables linked to a central table, where references between the numerous tables may or may not exist.
There's a lot of data used, and while this table was initially designed, created and mutated over time, perform... |
I know this question might be closed as opinion-based, but what I need right now are some opinions supported by arguments.
I am building an application with Postgres and Ecto (Elixir) as the persistence-layer. There is an entity that references itself so that you can build a tree-like structure with it. The more I am t... |
if (0 == strcmp(val1,val2)) or (strcmp(val1,val2) == 0)
vs
if(! strcmp(val1,val2))
Any studies or style guides that support one these styles over the other?
|
So, I am trying to create an English language trie data structure implementation in C++. I have created a Trie and TrieNode class. The TrieNode class takes in its constructor a vector<string> that is a list of words to construct the Trie from.
My solution to getting this vector<string> was to use an EnglishWordsListGen... |
The CMS we're developing is getting really messy. One of the failing parts is "unit testing".
To put it simple: what we call unit testing actually is something rather vague, closer to integration and functional testing, but one of my coworkers (which unofficially is our lead) doesn't care about "sticking to the definit... |
I've got a medium-sized project now that's just nearing the end of the "sloppy caffeine-powered prototypes for client demos" phase and transitioning into "think about the future" phase. The project consists of Linux-based devices with software and firmware, and a central administrative web server. 10 prototypes current... |
I'm trying to code a kind of simple video game where there are two kind of players:
Human Players: They enter an keyboard input
CPU Players: A random input is calculated
For Human Players there is a T round time and a T' input entering time. Let's say, if T=20 and T'=5, a player has 20 seconds to start typing, but on... |
I have to do a task which is reading a text, and create a Class diagram. One of the entities is a Shopping Cart.
My doubt is how to represent a Shopping Cart in a class diagram, later on an E/R diagram and implicating an ORM in the process. I've been reading a little bit before asking but I cannot clarify my ideas.
Def... |
I'm creating my first c++ game engine project (for learning purposes) and in it I've attempted to implement an entity/component system utilizing some data oriented design principles while also not fully giving up my object oriented way of thinking. I have data only component structs:
(Example)
Position.h
struct Positio... |
There are only two members in our development team and we started to work on a medium scale web application (Laravel).
My question is about testing especially TDD, Do we really start to follow TDD strictly or start development without any test framework and later hire some developers for testing?
But if we didn't follo... |
There are no keywords in Java that relate to network operations.
The "socket" methods such as in OpenJDK dont seem to talk to the network card on the machine anywhere, they simply tell a socket to "connect" to some IP address.
At the lowest, primitive level, how does the JVM know when to call the network interface card... |
I have recently come across the term REM statement and wondered, is it synonymous with comment?
|
I need some advice on an approach to log raw request/response data from a few webapps, for all operations and hits on all APIS accessed via HTTP methods (mostly HTTP POSTs), that I have hosted.
Objective: capture raw response body at the end of request-response life-cycle. The app is built using Python/Java and nginx i... |
In some high level package (which I don't own) I have a Route interface.
Now this Route interface contains the detail for a specific rout within my system. The high level package does not contain a method to add get parameters to the route, like /customers?a=b.
class CustomerRoute extends BaseRoute implements RouteInt... |
Background:
We are in the process of converting a traditional multi-service Windows Service (WS) application into an Azure Service Fabric microservices grid running on a Service Bus messaging layer.
In the WS application, the "data loader" service was a singleton to prevent duplication of effort with regards to loadin... |
I am trying to achieve a round-robin algorithm for sports scheduling that also guarantees a fair or balanced home/away rotation.
I based my algorithm on the round-robin scheduling algorithm:
def round_robin(teams, rounds):
# bye
if len(teams) % 2:
teams.append(None)
schedule = []
for turn in ra... |
I was just reading the Wikipedia page for WebAssembly and it says: “WebAssembly is… designed to be faster to parse than JavaScript” , which got me thinking, what makes a certain language or data format faster to parse than others and what parsing algorithms are used?
|
Been given an awkward design challenge, and I'm not sure how best to handle it.
The scenario is this: in the system there's a concept of "Client". Each client has various bits of supporting metadata such as contact name, business sector and so on.
The system does two things. It takes bookings against each client, and i... |
I'm trying to write a python script that creates 10 threads at a time and runs until I stop it (ie closing the console). I just need it to do basic logging, so when it fails, its just logs a failed result to a log file.
The part of the script that I need to thread is just a simple selenium script that goes to a webpage... |
I'm using ASP.NET Core's builtin DI container. It's missing some features I need, so I need to use a third-party container.
The top ones on Nuget are Autofac and StructureMap. SimpleInjector is consistently the fastest, so I'm considering it too.
I have a large code base, so I want to integrate an external container wi... |
I am planning to build a version control system to learn some advanced programming concepts in the process.
I've used git , perforce and svn.
I was wondering if any of them or other uses delta uploads and download like syncing only changes for individual files instead of entire files.
|
I have this problem: Class1 and Class2 are of same Base type. They are representing the same concept but with slightly different implementation. If I model them "the right way" in Java, I would have it something like this:
abstract class Base{
public int id;
public abstract void someLogic();
}
class Class1 ext... |
I have a list of about 15000 items in my database, every one of them has a unique ID and name. New items are added regularly but usually not more than ten a day.
My frontend uses a form with autocompletion and this autocompletion is based on the name of the items above. That means that every time someone hits a key, an... |
I have to write a software requirements specification for a software system that consists of two front-ends, an Android app as well as a web-application. The Android app and the web-application have similar use cases, but the web application offers more options: Contrary to the Android app for instance the web applicat... |
Recently I debated with a colleague of mine about to the following issue:
I claimed that it is not MVC sane and good practice to directly load a Model via Zend Framework's ViewHelper because it is a View related stuff and it should call another controller by a hard acceptance.
My colleague claims the opposite that a V... |
I started development of simulator for simulation of distributed algorithms in language C. My work consist of creating simple language for algorithm description and simulator which takes the described algorithm and simulates it.
At first I decided how to represent distributed environment. This simulator will run on sin... |
My project can benefit from a bit of code from the Apache commons-math3 project. Specifically, my math heavy application would benefit from using the FastMath class which avoids using extremely precise, but slow, native methods.
I have a choice here.
I could add an entire maven dependency for this one class (FastMath)... |
Suppose that you see the following pattern in code:
function foo() {
...
var someFlag = false; // Until contested
for/while/if () {
...
// Possibly deeply nested in some non-trivial logic
someFlag = true;
...
}
if (someFlag) {
// Additional processing of some ... |
If an Entity doesn't have an unique ID, we usually use auto increment number to distinguish entities. But sometimes, we have to hand that ID over to people so that they can use it. So using auto incremented numbers is not a good fit for this.
Think about IDs you give to students to distinguish them. In that case, IDs s... |
When writing block code in languages like C++ and Java, people usually argue over whether brackets at the end of a line should have their own line.
if (condition) {
if (condition)
{
However, I have never seen anyone even suggest the second format below. Are the following equivalent, and if so, why have I never seen t... |
Below is a line that handles socket connections in a simple Haskell program.
mainLoop :: Socket -> IO ()
mainLoop sock = accept sock >>= forkIO . handle . fst >> mainLoop sock
The "flow" of data in the function is not consistent: it's left to right when using bind >>= or >> (sequence?), but right to left when using fu... |
I have set of spatial points defined by coordinates (x,y) . I want to find the bounding rectangle of given area that maximizes the number of point inside the rectangle. The obtained rectangle should have sides parallel to coordinate axes.
Please suggest.
|
I am working on a networking project. Where I am creating a dashboard to view real time status (CPU/memory usage, up/down traffic and few others) of multiple routers by calling API request to server which will call another API request to the routers ( Mikrotik Routers, they offer api to do configuration and get statuse... |
I was working on migrating over a project which uses a static logger, and a static email service.
The email service logs emails sent, and the logger service sends an email if there are any logging issues (like DB down, etc.). If the email service fails, it can also log the issue.
If the logger fails, it tries to send... |
I'm part of a development group with 5 teams, total of about 40 developers. We're following the Scrum methodology, with 3-week sprints. We have a continuous integration setup (Jenkins), with a build pipeline taking several hours (due to extensive automated tests). Basically, the development process works well.
However,... |
We are supporting data exchange in JSON, XML and SOAP for our customers.
The bird view of the data flow would be like this
Partner 1 sends request for some data with XML data
Partner 2 sends request with JSON
Partner 3 sends request with SOAP
To have a general approach for all partners.
We have created a file for ... |
I would like to know if the code below is a good implementation of the state design pattern. Everywhere I see the state pattern to hold the context and a change in state doesn't return anything. But in my example below, I return the new state (i.e. North/east so on...). Please review and help.
public abstract class Dir... |
I'm writing a simple web server in Haskell, and putting in a bit of logging. I've got some calls to a logging function in a chain of IO >>=. It all feels a bit manual. Is there a better/more "Haskelish" way?
log :: (Show a) => String -> a -> IO a
log label val = getCurrentTime >>= \time ->
putStrLn ("[... |
I started a job as junior programmer a few months ago. The system we are working on has been in production for ~2 years. I wasn't involved in the begging of the system and the design.
One thing I have noticed is that the system major version is already 11.Y.Z. Form my experience working with other systems and libraries... |
Are there useful programs that don't take inputs such as:
A user's keyboard input;
an interrupt from a clock;
data from another server etc.
A program that computed/printed out predefined data could be turned into a file, right?
|
I'm working on a PHP app, using three main branches: 'master' (current stable release), 'bugfix' (for patches) and 'next' (for next minor version).
We store the current version number in the code - it's used for a few things including checking for updates to the app, and also simple cache-busting for CSS/JS files (like... |
I've got a relatively high-traffic public-facing product-based website backed by SQL Server as the point of authority. It has some search capability on some of the columns of the Items table (year, color, that kind of thing), and then a need for a full text search on the Description column (also in the Items table, ea... |
I'm trying to process XML files that are too big to fit in memory. They range in size anywhere from dozens of megabytes to over 120GB. My initial attempt had me reading the files as plain text, in chunks of a few thousand characters at a time, and looking for individual completed XML tags in the little String chunks:
F... |
I am using Rust 1.15.1 and, recently, I stumbled over a problem I could not find a straight forward solution for.
When you look at examples using pattern matching they usually destructure the object in the match expression and continue to work with members within that object. However, I'd like to NOT destructure it, bu... |
I'm about to start developing a single page web application that is very simplified a multi user documentation system. The front end will probably use Angular2.
The project has a short deadline, so I've been looking for "shortcuts", i.e. using various ready made services instead of implementing everything from scratch.... |
I have JavaScript object which is converted to JSON and sent every time the user changes some filter for the search (for example, after he clicks the button or select/unselect item in the list). Data gathered through this JSON is filtered and used for building database query. After query is executed, results from datab... |
Problem:
Comments deteriorate when renaming a variable/class/method/etc in Visual Studio. Occurrences of said symbol in comments do not get updated by refactoring (no surprise, how could VS know).
Partial solution:
In XML comments (say, in a <summary> tag), we can use <see cref="..."/> to refer to anything and get it u... |
I'm writing a program that has one class called Driver, which reads audio, sends it through an effects chain and then sends it to an audio output. The effects are created from dynamic libraries (using either LADSPA or LV2 interfaces). So I wrote a class called DriverMediator that manages the shared libraries that conta... |
If you need to access application information from a database for analytics, is it better to copy the information first and analyse the copy or is it okay to analyse the data retrieved fresh from the application database?
|
What are the techniques and technologies that people use to store spatial data over time that performs fast when querying?
For example, you have a map where people add data at certain locations over time. How would you implement fast querying for the data available on a certain date (that date and before) or exactly on... |
Assume I have a modal dialog where I allow the user to change values of an encapsulated configuration through different UI components and I want to save the effort to implement a validation per component or restrict the component models to allow invalid values to be chosen/entered and rather validate the state of all v... |
I have a library in C where the API uses "objects" to interact with the application. These "objects" are opaque pointers that are created, destroyed, and modified via API calls.
These "objects" do not exist in a hierarchy and their lifetimes are loosely managed. As a result, the library has to keep pools of these objec... |
A construct I often use when the list of "things to make a decision on" gets too big to be practical in an if/else or switch statement is to make a table with values and callbacks. For example, something like this (C):
struct keymap {
int key;
int (*callback)(struct data *data);
int end;
};
...
struct ke... |
I'd like to write an Angular2 application that consumes a REST API backend.
However I'm worried about the number of req/sec that such a request will generate, due to Angular "watches" or equivalent change detection algorithm
Should I limit from the beginning the watches (data binding? change detection algorithm?) to on... |
Here is the scenario where I have difference of opinion with the developer.
We have this module that needs say - a username, password and server-IP-address as inputs from the user. First scenario, if all information is right, the user is able to get the functionality working. Second scenario, if any of the informatio... |
In a web application I'm working on, there are 3 types of scripts (same applies to stylesheets):
Those needed on every single page (e.g. jquery)
Those needed on several pages, but not all (e.g. a lightbox library used on pages which show user uploaded images)
Those needed on a single page (e.g. something specific to t... |
I am working on a team where my mates introduced the service & repository pattern. We work on Lumen micro framework. So from the controller, the call is passed to the service and then to the repository.
We use controller injection. The service and transformer are injected into the controller's constructor. The service ... |
I'm new to DDD + CQRS, and I'm working in a project that has this implemented, but I wonder why the guy duplicates the models.
I understand, that one is for writing (commands) and one is for reading, but both implement the same fields, except that ReadModel only has getters.
Is there any advice against having the field... |
For example, when you submit a Register form, you have to check in the Domain Model (WriteModel in CQRS) that it is in a valid state (example, email address syntax, age, etc).
Then you create a Command, and send it to a Command Bus.
I understand that Commands should not return anything.
So how do you handle an error be... |
Let's say I want to have a function to load a project's data from both a json and a file path, the first idea which comes to my mind would be having a couple of functions such as:
def load_project_from_json(json_data):
...
def load_project_from_path(path):
with open(path) as f:
load_project_from_json(f... |
In my contrived example, I have a rectangular grid of nodes, where each node is either empty, of Type 1 or of Type 2. All nodes are directed to the eight nodes around them (horizontal, vertical, diagonal). For each of the nodes of Type 1, I want to find the distance to the closest node of Type 2. For all points, their ... |
For example, with Spark SQL's data DataFrameReader, you can invoke something like sqlContext.read().schema(customSchema).json(path) where schema function returns DataFrameReader itself with the added configuration of customSchema. Similarly, Jackson's ObjectWriter has with function which returns ObjectWriter itself wit... |
Doesn anybody have practical experience with implementing a (micro)service based on AWS Lambda?
My team is currently working on an MVP. We started with a monolith and that has worked very well. It's a new business domain and we still have to learn a lot about which bounded contexts make sense and where to draw boundari... |
We are implementing many algorithms which typically have lots of shared, publicly known and security-relevant parameters.
Currently, we simply use a class holding all the parameters and two predefined global objects:
class PublicParams(object):
p = q = 0
def __init__(self, p, q):
self.p = p
sel... |
Team can have N users and users can have N teams.
One user can have N answers.
Answer belongs to one user.
I need help to build database structure. Important is to get team record from any answer. User can answer only with one team
|
I'm relatively new to jwt.io and authentication and I'm using JWT.io in following manner.
Server Side
Once user logs in, I generate a token with userid embedded inside and pass it back to the user in the message body
Client Side Browser/JS
I'm storing the token in localStorage and for each subsequent request, I'm passi... |
There is an ongoing debate about the following property, and if it should be tested or not. We're working in C#.
MyClass prop => value;
Should I be writing the following unit test :
IMyClass _viewModel = new MyClass();
Mock value = new Mock<Bar>();
Assert.AreEqual(value, _viewModel.Prop);
Personally, I say YES, becau... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.