instruction stringlengths 34 36.1k |
|---|
Often in math a vector or matrix will be denoted by a single capital letter. Would it be bad to have some variables such as this?
Vector3 A = ...
int Bx = ...
int By = ...
int Bz = ..
I would normally never do his but it seems weird when doing some vector math, especially when using ints and capitalizing the component ... |
I have a set of data (assume they are objects) with unique immutable names, like this:
class Datum {
final string name
// other fields
}
Considering that:
I don't need to support rename. (The names are immutable as I mentioned)
The names are unique. Among the data I store, there are no two data with the same ... |
Which is better as a design perspective?
An object that gets initialized and then checks to see if the parameters passed to it are valid before destroying itself (so in __init__) or
Check to see if the parameters are valid and then the object gets initialised?
I think the answer is the latter. However that leaves me w... |
We have 25 instances of the same database facilitating different production plants in our organization. Basically, location X uses it's own copy of the database, location Y uses it's own copy, etc. The database facilitates the same functionality and persists the same type of data for each location, so a microservice th... |
I've been doing some functional JavaScript. I had thought that Tail-Call Optimization had been implemented, but as it turns out I was wrong. Thus, I've had to teach myself Trampolining. After a bit of reading here and elsewhere, I was able to get the basics down and constructed my first trampoline:
/*not the fanciest, ... |
A search tree is a data structures which represents a set of elements.
A 2-3 tree and a B-tree are search trees. The elements of the sets they represent are placed only in the leaves of the search trees.
A binary search tree is also a search tree. But the elements of the set a binary search tree represents are placed ... |
I've start wondering what's the best practice when handling objects in web development.
Oversimplified the process when there is a page request often looks like:
Page request.
Fetch object data from database.
Create object.
Return object to page.
And on POST or save:
Get data from page.
(Create object) could be d... |
I am trying to encrypt a password for my school project. Here is the process:
Let's assume that I have a string p (n characters long) which contains the password.
The program reverses the string and stores it in string r.
It takes each character of p and r, applies the XOR operator and stores it in string e.
Next time... |
I am trying to find ínformation on how and where to write folder level scripts for Adobe Acrobat and Adobe Photoshop. This is what I found from Adobe:
https://acrobatusers.com/tutorials/folder_level_scripts
None of the info on this page works for me since it is outdated. Anyone have any tips? I have contacted Adobe Sup... |
i have a question about software engineering best practice.
Let's consider a class "User", with 2 subclasses "Student" and "Teacher"
if we need to specify some data for "University special council" that could be consider a sort of attribute both for student and teacher, how will i set it up? is that an abstract class? ... |
I have seen many questions on whether to design data first or code first when designing a new application. I wonder if some have the same conclusions/ideas as me. I come from painting/digital design/UI background and naturally I went into Front-End. Currently I can code and build UI's quickly in HTML5,JS,jQuery and Ang... |
I have been doing some practice problems on LinkedList but more than half of my time is spent on managing null pointer issue in my code, provided I have to keep track of current, previous and runners sometimes.
I need to know is there any way / model to deal with such issues?
Example:
public void deleteMid() {
Node... |
I have a code snippet in Java:
int y = ++x * 5 / x-- + --x;
So my confusion was since x--(postfix) has higher precedence than ++x(prefix) operator so x-- should be executed first then ++x.But a book states otherwise.Am I right in my thinking?
|
I usually have no problem deciding whether some data has to be global, static or on the stack (No dynamic allocation here, so no use of the heap). I have also read a few Q/A such as this one but my question is more specific since it involves a huge amount of data, huge compared to the system memory.
I'm working an exi... |
I have a simple donation form using Jquery Validation and Bootstrap
You can see the simple form here : JSFiddle
Currently the form is just simple HTML, javascript, and css. It validates correctly and I'm happy with the usability. What I want to achieve is to move this to an ASP .Net project using web forms. But I have ... |
I have to design and implement an algorithm for my university project that searches a given set of documents based on the keywords/query given. Assume that each document contain few sentences and these documents can be stored in a suitable data structure. When a query is made I have to display the documents that contai... |
A (partial or total) mapping from set S to T is a special relation between S and T. The difference between a mapping and a relation is that: a relation between S and T in general doesn't require that for each s in S, there exists no more than one elements in T corresponding to s.
A hash table is a data structure which ... |
Let's say I have an app that displays details for a person. Each person can have zero or more phone numbers and zero or more notes attached to it.
Thus, I have a Core Data entity Person with one-to-many relationships to the Phone entity and the Note entity.
I want to show these in a UITableView, where there is one sect... |
I'm not looking for recommendations but I'd like to know how some of these types of ticketing systems work when it comes to a specific functionality. Imagine an IT or helpdesk ticket system where someone creates an issue. Within the issue one can respond / comment on the issue (one to many relationship between an iss... |
Suppose I have a large, multi-line case statement, which checks several variables before returning a final value.
case
when (foo='bar' OR foo='foo') AND (bar='foo') then 200
when (foo='jar') AND (bar='glue' OR bar='true') then 212
else 0
end
I want to generate a table like the following for it:
foo |bar |va... |
Because my application works with very large collections of integers, Eclipse Collections seems like a very useful framework because of its primitive collections. I've tested it already, happy to see significant performance and memory improvements - so much that I'm considering just ditching the JDK Collections altoget... |
There is a XML link, which provides the children of any parentID given.
http://www.browsenodes.com/xml.php?action=BrowseNodeInfo&node=1036592
Then you can run the URL again with a children ID and it will provide its children.
When there is no more children of an ID, the return response will have no-children indication... |
Is there a known best practice when referring to the authenticated user in an API URL?
For example, the Facebook API uses /me as a prefix to all the resources of the authenticated user.
But I can think of other solutions such as /my, /self or the long one /users/{id}.
Is it just a matter of preference/taste? or are the... |
I'm building my first PHP web app with AngularJS as the front end and utilizing Slim to create a REST-like API for the web app to interface with. I'm finding that the majority of my code I'm writing is SQL, there is very little PHP logic in the backend except for sessions and input validation.
Each endpoint might have ... |
I'm a data analyst, not a software developer, and I often find myself writing a function like this (shown in Python syntax here):
def apply_many(arg, *funcs):
return [func(arg) for func in funcs]
so I can do things like
from random import random
# generate 10 random numbers for demonstration
x = [random() for _ i... |
I think it would be easiest to explain what I'm asking with an example.
function getLastNode() {
let current = this.head;
if (current == null) {
// Here, we could either return current, or return null
}
while (current.getNext() != null) {
current = current.getNext();
}
return... |
I've been reading a lot about micro-services lately, and here are some of the conclusions I got so far (please correct me if I'm wrong at any point).
Micro-services architecture goes well with domain driven design.
Usually one MS represents one bounded context.
If micro-service A requires functionality which resides i... |
In internal computer memory Char value ,string and integer how they differentiate time of storing and retrieving .
Char A =ASCI value 127
Int value 127
Binary is same then how computer understand this value..
|
Here is the flyweight pattern structural diagram:
Here you see UnsharedConcreteFlyweight which GoF explains:
UnsharedConcreteFlyweight :
Not all Flyweight subclasses need to be shared. The Flyweight
interface enables sharing; it doesn't enforce it. It's common for
UnsharedConcreteFlyweight objects to have Conc... |
Lets say you have a Database, and a Data Access Layer (DAL)
The DAL will be consumed by a various number of products which access the Database.
As time goes on, you add new fields and tables to the Database, and therefore update the DAL from version 1.0.0 to version 1.0.1. Everything is fine and nice :)
Your team deci... |
C# allows implicit conversions of integers to strings when used in an expression. For example, this is completely valid:
int myInt = 10;
string concatenatedString = "myInt is " + myInt;
string interpolatedString = $"myInt is {myInt}";
However, when the int is not being concatenated or interpolated, C# requires an expl... |
In the API I'm working on there's a bulk delete operation which accepts an array of IDs:
["1000", ..., "2000"]
I was free to implement the delete operation as I saw fit, so I decided to make the whole thing transactional: that is, if a single ID is invalid, the entire request fails. I'll call this the strict mode.
try... |
At work we have an interface that is getting bloated. The interface is designed to be easily implemented by an immutable object. So it looks something like this:
//there is no behavior here, just data access
interface DataBlock {
String name();
Integer idNumber();
Double score();
Instant time();
/... |
I am creating a template class in C++ for numeric operations and I want to restrict it to only numbers or similar numeric types. My question is that is there any way in C++ to restrict a template class to a specific domain as in java its simply:
public class num<N extends Number>{}
answers will be appreciated
|
In computer programming (I code in c#), why are pure functions easier to reason about?
From my own experience, I find that pure functions are easier to reason about because they lack side effects, and they lack state management. As a consequence, such code is more simple and straight forward. Beyond this, can anyone s... |
I have a functionality which I must deal.
The requirement of a project is to transform papers to pdf and store this files.
The main functionality is that the user is being able to search words in the content of the files, for example it the user is looking for any book that aims on "biological risks", the software has... |
So in a relatively famous blog post, Eric Lippert categorizes exceptions as lethal, vexing, bone-headed, and exogenous. He defines vexing exceptions as ones created by unfortunate design decisions and gives the example of Int32.parse from C#. Attempting to parse a user-input string as an integer may well fail, and is i... |
I have the following scenario for which I've been experiencing performance problems:
The context is a level editor of a new engine for an old video game (whose source is unavailable) in Unity. Basically I'm writing a level editor for Unity to shape old data structures into contemporary, more usable ones, i.e. parts/ent... |
Say I have a product listing backed by a SQL table. It's a large data model (truncated here for brevity) but let's say looks like this:
public class Product {
public int Id { get; set; }
public int Number { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public deci... |
Since Swift 3 is boasting its new capabilities, it occurs to me that I don't actually know why Swift is server-side. I've been hunting "Full Stack" and the listings have MEAN, they have C#/ASP, some do MongoDB, Hadoop, Rest/SQL, but my main point is the interface language.
I was thinking, could it be network requests? ... |
I'm currently developing a web application for government land planning. The application runs mostly in the browser, using ajax to load and save data.
I will do the initial development, and then graduate (it's a student job). After this, the rest of the team will add the occasional feature as needed. They know how to c... |
Consider I have a vector and map as class members:
class MyClass{
protected:
std::vector<int> myVector;
std::map<int,std::string> myMap;
};
Should the getter and setter access the container itself like this,
class Myclass{
public:
std::vector<int>& getMyVector(){
return this->myVector;
}
s... |
I like asciidoc, resp. asciidoctor, for documentation purposes. It is way better than MS Word and integrates better with source control compared to tools like Confluence.
Furthermore, I am aware of tools, which allow you to write executable parts within your asciidoc documentation. For example, PlantUML code can be inc... |
Does it make sense to add microservices to a monolithic architecture? E.g. if the monolithic system is old and is seen as too big, can it slowly be turned into a microservice based architecture?
Another Part of this question is: Are there big disadvantages for "mixed" architectures, i.e. parts are monolithic and other ... |
How to handle multiple stories with changes on the same big Cobol program/module in a Scrum Sprint without ending in a mini-waterfall at the end of the Sprint?
The risk is that the development sub-tasks of multiple stories are linked to each other, with 1 or 2 (pair programming) developers, and by this action all those... |
I know how to code and get things done but almost all the time it takes me too much time to create a first working version of the algorithm/application.
I start from one part and then jump to another and then realize I need something else and jump to another part.
I think I lack on the planing part and dividing the goa... |
Say I'm writing a complex application that consists of 3 parts: Services (Web API), Scheduler (Windows Service) and Web (MVC Project). They all share the same DB. Services are used only for posting data to DB. Web is used to interact with DB: display data, modify it, set some flags in it. Scheduler has several jobs in ... |
Pull requests are a great feature of modern vcs hosting. They provide a consolidated view of everything that's happened within a branch's development, including a master diff of the composite change, and all the discussion that's taken place.
My question is this: Is there any downside to issuing a pull request immediat... |
There are various metrics like "test case effectiveness", that is calculated as (Total number of bugs found / Total number of test cases executed).
While this produces some numbers in the beginning, when run on a mature product, usually no bugs are found. But then I would get 0/100 = 0% and it does not make sense to re... |
I am studying SDLC models from a book. While attempting the exercise questions, I found these questions:
What is the best choice among process models to address tight schedules and cost of the software precisely?
What should be the best choice among different process models for development of any general software, suc... |
The problem
You're given an n number. Check if that n number can be splitted in half so that both sides of a | are prime numbers.
Example:
Input Output
223 2|23
123 Not possible to split.
My Idea
I was given an example of n number that has only three digits, and in that case it would be easy to finish the task, bu... |
Original Class
class HomeController
{
function __construct()
{
$this->setPhpRenderer('Module');
$this->repository = new HomeRepository($id);
$this->proposalService = new ProposalService($this->repository);
$this->quickAdd = new QuickAdd($this->repository);
}
}
/*
* Instanti... |
I am developing a mobile application back-end service using Laravel 5.3. I am following REST API.
Application having payment gateway integration and it needs more security.
I followed JWT auth by using the tymon/jwt-auth library for laravel.
I have few concerns: my token getting expired after 1 hour, after that server... |
So recently, I had a client ask me to restructure his Database hierarchy which consisted mainly of changing table names and column names and creating cross-references to stop red locks.
He later emailed me about his 'program' no longer functioning: which the reason was simple, he hadn't updated the queries in his progr... |
This is language agnostic. I want to develop a simple custom assertion class using test driven development.
The class will have an assert method called assertCarIsNotDamaged which will check if a person's car has no damage. It will check a hash map of car parts and their desired status with the status of the parts of ... |
So my exact case is that I have ~1400 domains on an ancient, self-hosted bind server and I'm looking to migrate them to a hosted service. The trouble is that the hosted service's API has a rate limit of 150 requests per 300 seconds and each domain will require at least 3 requests to migrate. [Note: This API does not pr... |
I am trying to understand how interpreter pattern can actually be implemented.
As per the diagram; an expression has 2 nodes: terminal & non-terminal. Can it have multiple type of nodes as well? Because I believe it is drawn considering the math expression transformed in binary tree DS where leaf nodes are number and... |
This is probably a dumb question, but how do programming languages work on a low level? If you go to the Go language GitHub page here, it says almost 90% of the source files are Go files. How is it possible that a programming language is made up of itself, especially 90% of itself? I can kind of understand how a langua... |
I serve static content from Tomcat. Someone suggested moving the static content to a web server in order to optimize performance. How are web servers designed that makes them better at delivering static content?
|
I am reading Real-Time UML Workshop for Embedded Systems and I do not understand what they are saying here. I have bolded the parts of the text that I do not fully understand. I am trying to understand this from a C stand point of view.
An interface is a named collection of services. Services come in two
basic flavo... |
Google Maps API lets one use polygons to create shapes on a map.
What I wish to do is nest these polygons, and use them to describe data which can then be used for navigation.
Let's say that the data is population density. A series of nested polygons would surround a major city, each one with a value. The most densely ... |
I'm writing a boolean that will toggle between these two forms for writing markup into my strings, but I do not know what I should name my boolean.
bool setMarkupForm(bool markupForm);
Is not obvious enough to me to tell me what it is doing. What terms are used to differentiate between:
<element></element>
and
<elem... |
BEFORE:
I have an interface that has one method definition
public interface IDockable
{
void Dock(DockerContainerConfig config);
}
Everything is ok for my first implementation
public class DockerContainer : IDockable
{
public void Dock(DockerContainerConfig config)
{
}
}
public class DockerContainer... |
I am looking over Simula language to see how it compares to C++/Smalltalk, and I have two questions that are difficult to find answers to because each time I type in Simula into Google, it gets replaced by "C", "Python", or "Simulation".
Was Simula case sensitive?
What file extension was used for Simula programs?
|
We are building a Microservice architecture for our projects, with mostly front-end Symfony applications interacting with back-end RESTful APIs.
The problem is this approach is breaking the Symfony entity management relying heavily on Doctrine with database. Where Symfony usually handle entities with Doctrine, automati... |
Recently, one of my colleagues stated that the cache should always be required dependency. We should require it in non-null constructor parameter. And we can't use null-object pattern with it.
How to bring over this point of view? What do you suggest? How do you inject cache in your technologies?
update1: By cache I me... |
I have been asked to document coding standards for javascript at my organization level. Does maintaining coding standards at my organization level sound worth enough? kind of old timers? with the way, how javascript evolving with frameworks like AngularJS, should we just refer the industry standard instead of keeping t... |
I want to model some mathematical structures. For this purpose I want to define an interface, an abstract class for general purpose algorithms and concrete implementations of that class (I have three in mind).
Now the situation arises that the general purpose algorithms that do not depend on the details of the datastru... |
I am currently planning a monitoring server for a distributed system. In a file (or maybe a database, someday) I save all the servers and parameters that I want to monitor. When the monitoring system starts, I parse that configuration file and store the content in a Configuration class (see source code below). In order... |
Anonymous function expressions in JS bug me as they make stack traces and Chrome Dev Tools profiler output harder to use, so I've decided to name ALL my function expressions from here on in. The obvious thing seems to be to name them the same as the name I am assigning them to, e.g.
this.myFunc = function myFunc() {};
... |
This code golf question got me thinking.
I wasn't even aware that the Cashier's Algorithm was a formal thing.
Reading it, and Googling around, I see that all solutions seem to concern themselves with paying out the fewest number of coins.
I wondered if vending machines operate exactly that way, or if they think “uh, o... |
I don't know whether to call the data dynamic or inconsistent. But I need to create profile pages for people generated from xml or json. The challenge is in the data the is returned. The data is bibliographical data about a person, and the APIs that are returning it are old, 11 years old. They need revisiting.
the data... |
For storing sparse matrices I know there are multiple formats that are common, like COO, CSR, DIA, ELL, HYB, etc. (Link to some storage formats), but I haven't found that any of these stores the number of nonzeros per row.
I am considering creating a sparse matrix storing format similar to CSR except that instead of ro... |
I am currently in the process of putting together a matching algorithm. The matching process is as follows:
Query data is used to perform a "lookup" on a set of reference data in order to determine an applicable id which is then later used in a sales order
When the lookup data is queried, quite often more than one res... |
Background
I am designing a language, as a side project. I have a working assembler, static analyser, and virtual machine for it. Since I can already compile and run non-trivial programs using the infrastructure I've built I thought about giving a presentation at my university.
During my talk I mentioned that the VM pr... |
I've been thinking about the Traveling Salesman Problem. In examining it and grids of cities, I noticed that I could frequently pick out the shortest route just by staring at it. Granted, I couldn't necessarily get the solutions for the complex grids, but if I could get the simple ones there had to be a way to consiste... |
How can my program best represent a translation between imperfectly-matched data structures?
I am tasked with a one-way translation of data from one system to another. Both systems are established, I don't have the option of changing their data structures.
If the structures corresponded item-for-item, it would be simpl... |
I can't figure out why microprocessor systems implement unsigned numbers.
I guess the cost is just double the number of conditional branches,
since greater than, less than, .etc, need a different algorithm than signed,
still are there any algorithms that unsigned numbers are a significant advantage for?
my question par... |
The offical Scrum Guide states that
The Product Backlog is an ordered list of everything that might be needed in the product and is the single source of requirements for any changes to be made to the product.
Does this mean that the Product Backlog also contains requirements that have already been successfully implem... |
Let's say I've got many functions and each function accepts an unordered list (order does not matter). For each function I want to see if this list is valid based on certain rules (a knowledgebase that has the rules for each function's list).
Each one of this lists is at its core a combination, right? And each combinat... |
I have a large number of instances of a class. Those instances can fire an event. The only important thing for that event is which instance fired it.
I have another instance of a class (and maybe in the future more classes), that want to subscribe to that event.
For example (in pseudo C#):
class Button
{
public even... |
Recently I developed an Android application which is very difficult to maintain. We are stuck in a complicated situation. We developed Android Apps which contained 500k LOC and another team developed the same application for SetupBox which is 300k LOC.
These two applications share some logics and features but they have... |
I have been reading a bit more about trunk based development, my company currently mainly uses the git flow model, and I had a question regarding the commits that happen on the trunk and how they are versioned.
I'll use the Paul Hammant blog post to try and keep the question less subjective. So below we have the branch... |
I'm in the process of designing a library system. There's one application for the librarian to manage books, manage users, etc.
But, we also need to ensure that subscriptions are paid on time in this system and to ensure only people who have an active subscription can enter the library.
My solution to the above problem... |
After seeing an article on visitor pattern, it is clear to me how it works. And I created a sample program for my understanding;
main(){
SortingAlgorithm bubbleSort;
:
intList.sort(bubbleSort);
}
class IntList implements Sortable{
:
public void sort(SortingAlgorithm algo){
return algo.sort... |
The operation of increase-key or decrease-key is for updating a key within a max- or min-heap, respectively.
Why doesn't a max-heap have a decrease-key operation, and a min-heap a increase-key operation?
Thanks.
|
I was suggested to define a singleton in Python in the following way:
class Controller:
pass
# ...
controller = Controller()
However, this way, controller cannot be replaced with a derived class.
What are other sensible ways to define singletons in Python Django?
Maybe, when defining a reusable app, I should ... |
What programming language along with implementation and compiler can I use to study the pure, unoptimized space complexity of an arbitrary algorithm? And what methods can I use to do so?
For example, Scheme and Elixir implement tail call optimization. If the algorithm I wrote were recursive, whatever methods I could u... |
Working on WPF (UI programming) in C# I've started frequently injecting methods into the constructor of my view models.
For example:
public class HtmlRegexListViewModel : ViewModel
{
private readonly Action<HtmlRegex> onSelection;
public List<HtmlRegex> HtmlRegexes { get; private set; }
private HtmlRegex sel... |
For programs that read in source code, transform that source code, and then write back out the transformed source code so that it can be read and edited by humans, what sorts of data structures are typically used for representing source code with all its textual details? Is there a standard "textbook" data structure fo... |
I need to expose an API A which internally uses another API B. API B accepts an array of product codes and returns their information. That array could have any length but API B will return information of only first 10 product codes and silently discard the rest, i.e. doesn't throw an exception or return an error.
Now w... |
I don't see the reason to have classes for stacks, queues and deques if we have the data structure linked list, since a linked list can act as both a stack and a queue (and always has the functions of both, if not just named differently).
So this brings forth my question,
Is there a specific reason I should use stacks... |
I'm doing my third online course in learning java because I couldn't get over how to even start a project from scratch. There was a lesson in this new course that made me ask this question of the code and how to write it. It was verses using the dot notation when using class level variables.
This is how the instructor'... |
In .NET framework, System.Threading.Semaphore is an IDisposable that requires manually invoking dispose. However, in JavaSE, java.util.concurrent.Semaphore is not a Closeable nor an AutoCloseable.
Why do they choose different API design? Which one is better?
|
I am developing a product that uses custom hardware with accompanying software. It requires additional components which are sold separately to make the overall application work.
Using these additional components makes it similar to a razor-blade style business model (see http://www.investopedia.com/terms/r/razor-ra... |
I'm designing an application using Micro-Services and I'm unsure on the best mechanism to use to collect data from multiple services.
I believe there are two options:
Integrate an 'inter-service' communication mechanism that allows the services to talk directly. The API Gateway would call an individual service, which ... |
I've just written a simple mathematical library which consists of pure functions that take a few arguments, do some computation and return a result. I'd like to write unit tests for this library, but most frameworks I could find (Jasmine, Mocha, QUnit, etc.) include a wide range of bloat, ranging from regex matching to... |
Suppose you are developing a Python standalone application (not a library).
Would you make it a Python package? Or just files next to each other?
If you would make it a package, what would be the "starting point" file (where the first line of code runs)? The __init__.py? Or a short "startup" script outside the package... |
I am learning React+Redux now and came to the testing section. Many people use Mocha or Jest to test React components, so far so good, makes sense.
I previously have experience using Selenium and I see that Mocha is quite different in a sense that it tests just small parts of a web page(ReactComponents) and not the wh... |
Consider a class with a number of methods that are required to return a number of values each. In a strongly typed language such as C#, we can have the effect of returning more that one value from a method by using DTO classes.
Consider that the values that my methods are to return collectively are these (let's call it... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.