instruction stringlengths 34 36.1k |
|---|
Observation
There are many Exception subtypes that don't have any added state or behavior. For example, ClosedByInterruptException code.
Question
Why is subtyping without adding state or behavior "acceptable" in the case of Exception? From what I know, an interface should be used when defining new behavior, and a class... |
I am trying to figure out how to use OpenCV with XCode's Swift. I need to do realtime video processing for the project I am working on, but I can't seem to find any good references on learning OpenCV within Xcode. As far I understand the native video processing in Xcode is not very powerful.
The main problem I am facin... |
I regularly play a 2v2 game with 12 friends and I want a database to keep track of players, teams, scores and games, with the intent of creating a ranking system.
Since we regularly change teams I've come up with tables players, teams and games where the games have two teams (team1 and team2) and the teams consist of t... |
I am experimenting with converting an API to GraphQL, and I have a database that has many-to-many relationships that are stored via link tables; something like this:
CREATE TABLE accounts
(
id int,
last_name varchar,
first_name varchar
);
CREATE TABLE files
(
id int,
content varchar,
name varchar
);
CREAT... |
Both seem like parallel MPI communicating network of processes. I identify actors with services. Are actors more dynamic (you can create them and kill as breathing whereas service network is more static) or what?
|
ECMAScript 6 introduced default parameters. The default value can be any expression, so you can use it to make a function throw an error when a parameter is not supplied:
const mandatory = (name) => {
throw new Error(`The ${name} parameter is mandatory`);
};
const foo = (bar = mandatory('bar')) => {
// some code
}... |
On some machines the operation of data path between ALU and registers is controlled by microprogram . On some machines , it is controlled by
hardware .On machines with software control of the data path, the microprogram is an interpreter for the instructions at machine level. It fetches, examines, and executes instruct... |
I've read that when your program needs to know what class an object is, usually indicates a design flaw so I want to know what is a good practice to handle this. I'm implementing a class Shape with different subclasses inherited from it like Circle, Polygon or Rectangle and I've different algorithms to know if a Circle... |
I'm building a custom Notification section, which provides notification or messages to multiple users on any particular object update, I've created a HTML page like Dashboard where I have added a Alert section or notification section, which shows a particular record updates, like there is a Object (table) lets call it ... |
I wanted to ask this question that has been bugging my head for a long time. Recently, I have started to develop a distributed system which has continuous and frequent database lookups in a loop. Let me describe it to you.
There are entries in a queue, which can be matched mutually among themselves. For example, let's ... |
I'm building an OSX app that utilizes a Redis instance. It would be cumbersome to have the user install and boot a Redis server session only for the app to communicate with it. I'd imagine there are design patterns to handle these situations, regardless of the system (OSX, Android, etc) and database being used (MySQL, ... |
In the MVC pattern, is it good programming practice to make all instance variables in the view(GUI) public so that the controller has easier access?
I started to make setters and getters for everything but then gave up because it was way too many. Why does everything have to always be private anyway?
|
I've found that a common task for web applications I've built is to react to a change in the state of the database. That is, any user interaction that affects the persistent state may change views that are dependent on that data, possibly views for other clients. The challenge is to update all affected views immediatel... |
I'm fairly new to CQRS and Event Sourcing, though I have built one application (ASP.NET MVC) that uses it for a part of its business domain (one "bounded context" if you will).
So I know how to implement it, and I've seen the benefits.
In the near future, I will need to create a new application that is solely focussed ... |
Sorry for the non-descriptive title, I don't know how to explain what I'm trying to achieve succinctly.
In most SQL use-cases, we have records in the database that have properties, and we are trying to retrieve records which match some conditions. For example, we may have for instance a table of products, where each pr... |
I was working with GTK in one of my projects and I noticed that the library supports inheritance. As you can type-cast a child struct to its parent struct and vice versa. Other than GTK I've never seen this used (so flawlessly):
struct parent p = {5};
struct child c;
c = (struct child)p;
c.b = 1;
Does using the parent... |
In a MVC application, integration between controller and views are often a matter of:
class HelloController {
public function sayHello(Request $request) {
return new Response($this->templating->render('view', [
'name' => $request->get('name')
]);
}
}
However, there are many frameworks out there wh... |
I have the following global statement calls sprinkled throughout my PHP legacy codebase:
$jobnumber = db_quick($sql);
db_query($sql);
That is, those function calls have been initialized in the global scope and they themselves call upon a previously initialized MySQL global object, i.e:
//initializes MySQL connection o... |
I am using a JSON map to save objects (e.g. users) whose ids are the keys of the map but the object (user) itself also contains the id.
JSON
{
"john":{
"username":"john",
"age":30
},
"bob":{
"username":"bob",
"age":40
},
"chris":{
"username":"chris",
"age":50
}
}
C... |
I am doing a code review for a commercial software system. I noticed that some user's story and even sub-tasks when are implemented they result in a large code commit and usually end up in changing tens of source code files (java classes, javascript files, HTML, etc)
I expect that when someone implements a subtask or ... |
I have two elements inside a container. I don't need to give the two inner elements any id or class since they require no CSS or JS references.
Is giving them an id just for the purposes of communicating their purpose good practice? Or should I leave an HTML comment instead?
|
There's shuup django based e-commerce web-framework which is licensed AGPL-3.0
I would like to use it in my commercial project, which ultimately means that I'll want to modify a thing or two in the source files, also add a dozen of extra features to fulfil specific project requirements.
After reading an answer to a sim... |
I want a feasible way to compare my project with my friend's project. I first thought it was enough to compare based on the number of code lines. But for some reason, people kept saying "LOC is not a good measure".
So, is the following method (I cooked up myself and I don't know if there is anything like this) good e... |
When programming using (pre-emptive) multithreading model on a single processor, we need to deal with synchronization, deadlocks, etc. Do any additional concerns appear (and correspondingly, new techniques used) when switching to multithreading on multiple processors?
|
I'm working on a code base that dates back at least 15 and possibly as much as 20 years, where the older code is still functional but includes thousands of JSPs full of Connection, PreparedStatement, and ResultSet objects, as well as hard-coded SQL, to manage data access.
Yes, it's about as painful as it sounds ... b... |
I have a big list of email addresses and I want to find out which of those are duplicates.
How to define "duplicate" is exactly what I'm posting about here.
I know from experience that with Gmail, it's possible to remove all the periods and the mail will go to the same destination. However, from what I've gleaned this ... |
I have a class that sets up an array of nodes and connects them to each other in a graph-like structure. Is it best to:
Keep the functionality to initialize and connect the nodes in one function
Have the initialization and connection functionality in two different functions (and have a dependent order on which the fu... |
If the supervisor and its child actors are sharing the same messages, which is the right place to keep those case classes? Should it be in both Supervisor and the individual actors or should it be in a separate file? I have read that the best practice is to keep it in the companion object of the actor.
|
Is it possible to intentionally stress and break part of a computer on a mechanical level using the specificity of C/C++ in targeting addresses? All of this talk of addresses and pointers is not a mere matter of abstract logic, you're actually sending electricity to specific areas of your computer.
In my mind I picture... |
Let's say we have an application with a DAL, business layer, and presentation layer, we do dependency Inversion, and we place the database repository interfaces at the business layer.
At the data layer we use EF for database access. Who owns the entities? The business layer or the DAL?
I mean at the business layer we s... |
I make very long programs. There are many files.
Basically I have too many function.
Every code can pretty much call every function.
If I want to pull out some function and store it as a library so other function can use it I am in trouble. That's because one file has function that's used by other files that has functi... |
A bit of down time at work let my mind wonder a bit. I was designing a single location application on Digital Ocean (load balancer to app servers to DB with DNS). All fine. Then I thought what if the application will have a lot of traffic in America and Japan so I want to have data centers located in strategic geograph... |
I am confused about Dependency Inversion in general. Lets's say we have 2 layers: Layer0 the low level layer, and Layer1 the high level layer.
Layer1 should define the abstract interface, and Layer0 should implement it. However if Layer1 requires other types then the built in types,
then in order to use Dependency Inv... |
I'm developing an admin dashboard with different areas, where different users may have different permissions. For example:
News
John: edit, view, add, remove;
Carlos: edit, view;
Mario: --;
Support
John: view;
Carlos: edit, view;
Mario: edit, view, add, remove;
The way I control this permission is via JSON arra... |
I'm writing some code for a scientific simulation and I'd really like to use this as an opportunity to get some unit testing practice under my belt. I understand the idea of tests in theory, but I just can't quite see how to apply it to my problem to prove a mathematical result comes out correctly.
For example, a big ... |
I have a module, say 'M', which has a few clients, say 'C1', 'C2', 'C3'.
I want to apportion the module M's namespace, i.e. the declarations of the APIs and data it exposes,
into header file(s) in such a way that -
for any client only the data and APIs that it requires is visible; rest of the module's
namespace is hid... |
I have been in arguments with programmers that mixing elements with animations and react is very bad practice, and that all animations should be in a style sheet because that is something presentational that is only concerned with CSS.
However, I have also seen a great number of libraries using elements like VelocityCo... |
Have you ever seen a significant non-theoretical project where the underlying database engine had to be changed? Was it a major undertaking, taking months of work, or was it conceived and done in a day/week?
I have seen a few online posts/messages conveying one to write database-handling code in such a way as to allow... |
I'm working on a GUI application using the MVC pattern, but the controller has proven to be much more complicated than I originally thought it would be.
The application has options which determine how the operations in the action listeners function, so I started to use the state design pattern. But then I realized tha... |
Lets say I have a class Person.
class Person{
Person(std::string, int);
void walk();
void talk();
void eat();
private:
int age;
std::string() name;
};
Now lets say I want to add personality to this person object. How should add this feature to this person?
I was thinking of inheritance
clas... |
My application is similar to a very simple CAD program. The user can create and modify a database of several thousand, simple 3D objects (e.g. cubes and spheres). Each object has a position, orientation, and size. I anticipate having these objects serialized in the database.
I want to render objects in the database in ... |
< backstory >
I grabbed a book called Code Complete at a used bookstore the other day because I heard it was a great book, and started reading it. After around 10 pages I realized that I've been kind of stupid about a recent project I've been working on. A bit of clarification I should put in at this point: I'm not at ... |
We were taught that objects are self contained things with data and behaviour and therefore they should have methods that act on their attributes. But there are several situations when this coupling between entities and their behaviour is not observed:
Entity frameworks (like .NET with POCO and Enterprise Java with PO... |
I mean, it's a matter of choosing words more than there is any difference between function and constructor call. The thing which is named "constructor of an object" can also be named "function with name object returning type object".
One could argue that C++ does not allow one to have the same function and type name; ... |
Background:
So I'm trying to create my first game engine for learning purposes. After looking up a few articles I was able to design the beginning portions of my engine to at least get me going. My design so far involves have my own "Framework" layer for which all other, higher level subsystems (graphics, input, audio,... |
Developing a co-founded idea software product can have sometimes misunderstood information about roles and responsibilities. A Management role is responsible for understand and delegate the operator's role.
The next figure will produce a possible and hypothetical project structure from Steering Committee, Management Te... |
I have a project which uses 3-4 different open source C/C++ libraries.
I built these libraries for several platforms and checked in include files and static libs for different platforms in my project.
However, I struggle with a couple of problems. All of these projects are around dependency management. And I am lookin... |
(For more backstory/explanation, see my previous question.)
I'm a middle school student working on a very, very informal project; my problem statement is as follows:
There is no way for theoreticians, researchers, and students in the field of quantum computing to simulate and test complex, large quantum circuits in an... |
I have quite a few years of programming experience pre-university and have been
working full time as a mobile dev at a small company for about 3 months now, so
am quite far ahead of almost everyone in my courses at university.
We will have a group software project consisting of 4-5 2nd years (including
myself), one or ... |
In JavaScript, you can have a loosely typed language. So doing the following is acceptable:
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var matchType;
var found = false;
var depth = {};
var i = cursor.column - token.start;
var bracketType;
var brackets = {
")": "(",
"(": "(",
... |
I've been assigned to create a development policy for our project which is a test case management web application using Spring MVC and Java.
For instance, I think I would have to create the coding guidelines to be followed by the new joinees in the team. Also including the project architecture so that whenever a new jo... |
I have a list of IReader that I read at the beginning of my program. Later on I need ReaderFactory to get appropriate IReader based on Extensions it can use. The problem is the factory needs to know about available readers. So I have two options:
Make static ReaderFactory with method static Get(string
extension) and s... |
I am having a very difficult time because my colleague seems to exhibit
Premature/Unnecessary optimization efforts
Premature deduplication with questionable abstractions
For example, we use a modified VIPER architecture. He introduced a base class for the Router component (using generics) as part of implementing the f... |
Most often I need to call a service method from a controller, and based on the outcome, if there's an error show an appropriate error message depending on the error (or some other action, showing message is just an example), otherwise proceed.
A very simple way I am using is returning an Outcome object from such method... |
We have a legacy C++/CLI solution that generates primary executable, but is being expanded out to generate libraries as well as including relevant unit testing. Since we have a number of classes in both the library and executable that implement a common interface, what is the correct way to organize the solution for it... |
In a NoSQL database (MongoDB), I need to store a list of creditcards for a user and to keep track of which one is active.
I came across 3 patterns:
#1 Keep the active property in the Creditcard schema
User
| _id: String
| creditcards: [Creditcard]
| ...
Creditcard
| _id: String
| active: Boolean
| ...
#2 Keep the ref... |
I got this idea from this question on stackoverflow.com
The following pattern is common:
final x = 10;//whatever constant value
for(int i = 0; i < Math.floor(Math.sqrt(x)) + 1; i++) {
//...do something
}
The point I'm trying to make is the conditional statement is something complicated and doesn't change.
Is it bett... |
In a Microsoft ecosystem (i.e. WebForms/MVC/WebAPI VisualStudio projects) why should I rely on an external task runner for JavaScript files like Grunt if I already have MSBuild at my disposal as the default building/task running system?
When I first saw grunt in action I wondered why it was even being used, as it seeme... |
In conventional web application there is single action per one button click from user. So clicking on submit form, send email or change status, delete user etc all this does single action per page load then shows status message.
I am creating new application and trying to decide the likelihood of ever needing multiple... |
Replace each symbol (letter) with a number so that the equations hold across all 3 equations. Solution should be able to solve the general case of any 3 equations. Can assume 2 terms summed to an answer. A recursive solution would be a bonus.
pot + pan = bib
dog + cat = pig
boy + girl = baby
I saw this in the book ... |
I have to give my one of the biggest interviews next week and I am working hard for that. I have also enrolled myself for some mock interviews for that. So, coming to the problem last day I had this mock interview and I was asked this question:
Search an element in a sorted and rotated array
at first I was clueless but... |
I've been implementing a network protocol, and I require packets to have unique identifiers. So far, I've just been generating random 32-bit integers, and assuming that it is astronomically unlikely that there will be a collision during the lifespan of a program/connection. Is this generally considered an acceptable pr... |
I have released many open source software under Apache 2.0, now I'm providing a SaaS using that software.
Basically, I need to prevent people just taking my software and just rebrand it to provide it in SaaS, being in direct competition with my own SaaS.
AFAIK Apache 2.0 makes that possible, even the rebranding (changi... |
I have a software component that is a part of a bigger software product.
The software component lives in its namespace Component.
Also the component has an interface (some part of it is below) that other components use:
class IComponent {
...
virtual void AddClient(unsigned int id, Component::Client client) = 0... |
The question is only relevant for typed programming languages, dynamic solutions aren't satisfying. Let's assume that the language is C++.
Example architecture:
- DisplayObject (base class)
-- Container (derived from DisplayObject)
-- Sprite (derived from DisplayObject)
So I have a game engine in my hands and it only ... |
How to handle a next kind of situation in general:
I've defined two aggregate root types AR1 and AR2. The AR2 holds value-based identity of the AR1. I have to keep eventual consistency between those aggregates so if some command changes the state of the AR1, I have to change states of every AR2-objects, which hold the ... |
I'm programming a small web scraper in python which I want to speed up by parallelizing things. The scraper is crawling URLs whereby a single URL can represent an 'item' or an 'index'. An index in this case is a list of URLs of other items and indexes. The parsing for an item URL differs from the parsing of an index UR... |
picoTCP (an open source embedded TCP/IP stack) has always had a development focus (both in picoTCP itself and with picoTCP) on linux & gcc systems. The final target is usually an embedded micro (ARM based). For this reason we put quite some logic into the makefile to keep modularity high. We're also using compile flags... |
We are in the process of developing white label apps for iOS and Android app. I was thinking about the test strategy for handling white label apps with minimum resources. My company is targeting for at least 50 customers for the first year.
Is there a way to handle white-label app with limited resources(testers)?
For ... |
I'm in the process of developing an ASP.NET Core WebAPI that uses EntityFramework to access the datastore. One of the things we need to support is sorting and filtering.
I'm assuming that the HTTP query-string will be populated with the various criteria for the filtering and sorting. But I'd like to see some actual re... |
I'm actually a programmer on a few languages, but I realized I really didn't know much how the computer works on a deeper level.
So I thought a good idea to discover and learn how does it work was to create a basic programming language. I come here to ask you if this is a good idea or if there's a better way or learnin... |
At work I was assigned a task to investigate on the severe slowness of an application I am not familiar with. Simple requests were taking several minutes to resolve.
Here's how it was before (simplifying):
There is a facade method to get a subset of information about orders, with the customers
There is a CustomerDAO,... |
I wrote a utils library (5 KLOC) that a lot of my projects use. I've also written a very small project (150 LOC) that needs just 1 or 2 of the classes in the utils library.
I really don't want to add such a large dependency for such a small use, but the other options...moving/copying the classes or having a utils2 libr... |
Introduction
I am working on a Java EE Web Application that is a basic CRUD app. It is built with Servlet and JSP technologies, without any Frameworks. I am doing it to make my hands dirty in plain Java EE things.
Project structure
Here are directories/packages of the project:
entity - entity classes which are simple... |
I know I should encrypt the password whenever I save passwords for security.
But I don't know how should I encrypt password that when I save for autologin.
If the password was just for checking user, I can encrypt passwords with one-way encryption like pbkdf2. But the password should be protected, and I should access ... |
My department is about to make some new hires. They are likely to be a) junior or b) more experienced that myself.
This year I have helped some C engineers transition to C# and observed some interesting code structure being written. I wish to learn more about why they are doing it, if I should encourage 'my way' and wh... |
I'm working on a web application that stores identifiers, such as usernames and email addresses in a "normalized" form and a "non-normalized" forms, for a variety of reasons. For example, an username 'John_Smith' would be normalized to 'johnsmith'.
However, some of the user interfaces need to work with the normalized r... |
Over the course of the past few days, I've been trying many different methods for correctly calculating jump targets in bytecode, but none have been practical or reliable. Furthermore, the methods I've tried did not allow nested if-statements and/or elif statements, which are important features of any language.
I am wa... |
The following commentator writes:
Microservices shift your organizational dysfunction from a compile time problem to a run time problem.
This commentator expands on the issue saying:
Feature not bug. Run time problem => prod issues => stronger, faster feedback about dysfunction to those responsible
Now I get that w... |
I'm working on an automation project in C# and it has 2 wrappers: DesktopAutomation and BrowsersAutomation. The first has a dependency on UIAutomation.dlls (access to the MS desktop elements) and the latter on Selenium. Their role is understood I hope ;)
Now, There are user actions on the browsers that require a depend... |
I have that self-hosted RESTful messaging service with authorization, SSL and more good stuff that goes with it. Now, I would like to consume that service, so I need an UI. Usually (for cross-platforms sake) I tend to develop ASP.NET MVC web application, but this time I'm not sure how to proceed.
However, I have some i... |
I know GA questions are often almost impossible to answer exactly, but I'm looking for some general advice (although specific advice would be great too!).
I've just written my second GA, which tries to find a phrase (say "i like bananas"), which it does by generating binary strings of 5 times the length of the target s... |
I'm working on an Agile program and we are debating on how to deal with what we call "stabilization sprints". We have to build our team and decide on several key items but it seems there aren't really a well defined guideline to help us decide about them (or we can't find them) so I was hoping to pick your brain on thi... |
I'm creating an HTML5 game using javascript and have got some problems during the first instantiation of the objects of the scene.
Scenario
Self-written 2d game engine that supports multiple types of objects.
'Glossary'
An object is a scene-related entity, and is always an extension of a model, which is abstrac... |
I teach software engineering at undergraduate level and I have a question to UML practitioners.
Most software engineering textbooks take a serious effort in covering UML diagrams. But on the other hand, I heard from many graduates that UML does not seem to be used in the trenches anymore.
What UML diagrams are still ... |
I want to understand how EF track ID when the primary key is identity. (DB first)
For example
class User
{
int Id; //auto generated via SQL identity, also the primary key of the table Users.
string Name;
}
//adding a new user-
User user = new User () {Name="TestUser"};//Id will be 0;
DB.Users.Add(user);
DB.Sa... |
I've always thought that a "common library" was a good idea. By that I mean a library that contains the common functionality that is often needed by a few different applications. It results in less code duplication/redundancy.
I recently read an article (can't find now) that said this is actually a bad idea and went as... |
I like working in languages with static types, because I like using types as a tool for designing an API before I start coding it.
I also like TDD, because it helps me concentrate on working in small steps to ensure I get consistent results.
But when I combine the two approaches, I often have this problem: I design the... |
I have a piece of code parsing a text file line by line. I have to goals: Testing the syntax of the text and extracting information of it. It is quite likely that syntax errors occur so I want to provice helpful information about where and what.
To give an idea of the problem, I have a text file like the following (sim... |
I am in the process of creating my own concatenative language, heavily based on Forth.
I am having a little trouble understanding how the compiling words CREATE and DOES> work, and how they are implemented (How the state of Forth's run time environment changes exactly when they are executed).
I have read the following ... |
Occasionally, the most logical name for something (e.g. a variable) is a reserved keyword in the language or environment of choice. When there is no equally appropriate synonym, how does one name it?
I imagine there are best practice heuristics for this problem. These could be provided by the creators or governors of p... |
This is more of a theoretical question which I hope is okay!? I want to code my own drag and drop jQuery plugin, but i'm wondering the best way to go about structuring my code and actually doing it.
Note: This MAY be opinion orientated as well but I don't mind, I just need suggestions on a good way to go about this an... |
I'm working on a website project for a software engineering course. This site will be using a database to store data, currently through JDBC and MySQL.
Now the first thing I would want to do, is use the bridge pattern in order to decouple JCBC/MySQL from the implementation of the website, so that if in the future we de... |
I'm trying to design a N-Tier Solution for my existing WebAPI project.
I have a WebAPI project where, as of now, all the business logic are written in the controllers and the data validation are done by annotations.
This is now leading to duplicate code across controllers when I'm trying to implement same logic.
So I t... |
Let's say I want to program a parallelized web crawler which has a shared FIFO queue (multi consumer/multi producer). The queue only contains URLs. How do I detect the end of the queue?
A worker process is always consumer and producer at the same time because it takes an URL from the queue, crawls it and adds any found... |
I'm not really sure if that is right "stack" to ask that question, well two questions actually.
What's the potential use for capped collections? (besides logging)
Capped collections cannot be sharded, but they can be replicated. In case of network partition and after rejoin, how is capped collection synchronized/merge... |
What is the best way to find the duplicates in a list of a list of integers (no matter what position thay are in)?
I don't necessary need code just the best way to go about this problem.
eg:
List<List<int>> TestData = new List<List<int>>
{
new List<int> { 1, 2, 3 },
new List<int> { 2, 1, 3 },
new List<i... |
problem:
Making a video-game has the following challenges on variable storage:
send player states every 50-200ms, so store position/ rotation as efficiently as possible.
store large blocks of data for each player regarding their cooldowns, abilities, and loadout
all variables have to revolve around the connection id a... |
I'm looking at the upcoming Visual Studio 2017.
Under the section titled Boosted Productivity there is an image of Visual Studio being used to replace all occurrences of var with the explicit type.
The code apparently has several problems that Visual Studio has identified as 'needs fixing'.
I wanted to double-check my... |
I'm exploring composite pattern to write a file system, one of my requirements is to create a unique root element in this case a directory, similar to Linux System ('/'), I have seen many examples of creating this in the client like this:
class CompositeDemo
{
public static StringBuffer g_indent = new StringBuffer(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.