instruction stringlengths 34 36.1k |
|---|
I'm tasked with implementing a spec for a simple simulated shopping system. The spec however uses strange abreviations everywhere (it has a 2 page long table of nonsense abreviations). For example the contains lines like this:
Each potential VG has a AL of VGI's.
When replacing the abreviations using the abreviations... |
I'm trying to refactor some code, so it uses dependency injection.
Take this (non-sense) example class:
class Foo {
protected $min;
protected $max;
public $bar;
public function __construct($min, $max) {
$this->min = $min;
$this->max = $max;
$this->bar = new Bar($this->calc());
}
public functi... |
In Java and C#, you can create an object with properties that can be set at initialisation by either defining a constructor with parameters, defining each property after constructing the object, or using the builder/fluid interface pattern. However, C# 3 introduced object and collection initialisers, which meant the bu... |
What is the recommendation regarding re-using DTO's as a child in another DTO?
I'm using ASP.NET Web API (C#) and consuming the results with Angular 1.x (not sure if that really matters).
I have the following DTOs
class SiteDto {
public int SiteId {get;set;}
public string Name {get; set;}
public DateTime CreatedDate... |
I have come across a programming question in which I have to determine :
Does there exists at least one pair in a given unsorted array such
that
|i - j| <= K and |A[i] - A[j]| <= x
?
For example:
A = {5,4,8,3} and x = 3 and k = 2.
Answer: Yes - any one of (5,4), (5,8), (4,3)
I have tried it many times but couldn'... |
I've been reading about C++ memory models and think I have a grasp of the basic concepts of happens-before, synchronizes-with and inter-thread happens-before. However, applying them in some examples has been difficult. In particular I have been thinking about the following sequence of operations when they are repeated:... |
I'm running a Java application that creates 50 threads as part of a threadpool; each thread running in an object that reads 1000 unique rows at a time from a MySQL table. So each object has it's own SqlManager class I created which can open an Sql connection.
wait_timeout is 28800, which would be 8 hours (am surprise... |
The web App has four distinct user areas.
The frontend for people off the street
The user area for logged in users
A teacher zone
An Admin c-panel
I am using CodeIgniter with the HMVC extension.
Here is my current list of module folders. Each database table has a corresponding module.
Each module has a MVC triad exc... |
What is the convention about describing the direction of the stack, i.e., about what the words up, down, top, and bottom mean?
I noticed that with stack data structure API, top usually to refer to the most recently added item. I never saw high level language or library documentation refer to the newly added item in the... |
I have R objects, where R >= 3.
I have a N-sized array, where N > R.
I would like to determine in which indexes of the array I must put the R objects so the distance between any two neighbors will be equal, or the most similar possible.
Eg:
for N = 4, R = 3
{1, 2, 3, 4}
{o, o, , o}
or
{1, 2, 3, 4}
{o, , o, o}
for N... |
Our scrum team consists of the usual scrum roles. We do not have a UI/UX designer and the developers work the UI/UX with the product owner. Here lies a problem. Everytime we are about to create the backlog and we do not define the exact UI/UX design before the beginning of the sprint we end up spending too much time du... |
I have a small circle (on a sphere) with given center and radius and I want to mark grid points which are within the small circle.
The grid itself is discretised in evenly spaced longitude and latitude degrees in a geographical map.
My simple algorithm that I implemented to solve this goes from the center of the small ... |
I have an asm/C code which implements some image filters. The objective of this project is experimentation with different implementations, benchmarking, plotting and reporting data to write a paper with relevant insights.
So for example one work-flow I need would be:
Start at a base code implementation (Step 0)
Compil... |
For example, if I have a method
public void method(Pair<String, Object> pair){
...
}
Should I create the method
public void method(String str, Object obj){ this.method(new Pair<>(str, obj); }
if it is not to maintain an existing API? What are the considerations?
|
Good day, I am new to java and new to this forum but I request a bit of help. I am learning java on my own and I am currently learning binary trees. I have come an algorithm that is giving me a little issue. It is a binary tree code that basically inserts five nodes into a tree structure and then traverses the tree. My... |
I have a Node.js application that reads and writes images from a server. The images are stored in a directory on an Ubuntu operating system. Express static routes serve images from that folder when accessed by mywebsite.com/images/xyz.jpg. Currently, anyone who can log into the server can see what's inside the image fo... |
The difference between a command and an event in bus communication seems a little vague to me. I know that commands should be executed once only, while an event can be handled multiple times, but still I'm not sure when to use a command or an event.
Let's look at an example:
When a new user registers to a web applicat... |
The codebase I work with has a certain pattern prevalent in all public methods, which goes like this:
public void UpdateUser(User userArg)
{
Framework.NullCheck(userArg);
var user = userDb.Get(userArg.Id);
Framework.NullCheck(user);
user = userArg;
userDb.Update(user);
}
The NullCheck method is... |
So as my the title says, SonarQube is complaining whenever you use
list.size() == 0
or
list.size > 0
However I started changing to isEmpty() and !is.Empty() and noticed the code becomes way less readable and had to change it back, therefore I don't think it's better to use the isEmpty() method as you have to read t... |
What makes SDLC a "lifecycle" in the first place?
Let's say that a software vendor signed up a contract with a customer who does not require their software to maintained or supported by the vendor. In that scenario, would the lifecycle repeat itself?
In other words: is maintenance, feedback, or support an integral pha... |
I'm writing the core logic of Pokemon Gen I in Java (8), and I am struggling to figure out the best way to implement the turn-based aspect of the game. Right now I have a Battle class which has two Players each with a PokemonTeam.
The idea is that one Player takes a Turn (a Battle has many Turns), and some action happe... |
Given a modern 64-bit architecture with 6-bytes used for each page pointer, 1 MB pages, and 16 GB installed memory:
a) How would I calculate how much memory can be addressed by the paging solution?
b) How would I calculate how large must each page table be?
I'm not looking for the answer. I would just appreciate a clea... |
I am working on a WCF Service that returns the Status for a Device.
A Device has multiple Status for different Companies. I need to develop a WCF Service that allows a Company to retrieve the Status for their Company (and only theirs).
What is the best way, to differentiate between this companies in WCF.
As far as i c... |
I have a desktop application with each window decopuled into presentation layer (containing the Form/Controls etc.) and application layer (Controller/Presenter - naming is irrelevant to the question). Presentation layer is passive, it only displays the data provided by application layer and comunicates with it using ev... |
On a POST (or PUT) webservice, I know can use three different type of parameters, I can send my parameters in the path of the URL /objects/{path_param}, after a question mark in the URL /objects?{param_name}={Param_value} or in the body of the request.
For GET webservices, I use path to identify a ressource, and query ... |
Wikipedia gives a few examples of statements that we all know:
Return statement: return value;
Assignment statement: var value = expression;
Call statement: expression;, e.g. action();
If statement short: if (expression) expression;
If statement long: if (expression) { n statements }
Is there a general term that incl... |
I'm trying to design a hierarchy classes that extends the integers C types. What I'm trying to achieve is basically the following:
I have a basic class called Integer this class is an abstract class, the only thing I wish it would provide is basically the basic operations between integers, namely +,-,*,/,&,^,|,~,etc if... |
I have recently implemented quickselect, an algorithm for computing the k-th smallest element of an array, which, roughly speaking, works by repeatedly partitioning the array around a pivot and suitably shrinking the array.
The implementation rearranges the input array, which it recevies by reference, to avoid wasting ... |
I plan to release my very first app on Google Play Store but I am still a bit confused on the concept of releasing software. I tried to read a few articles online about the life cycle of software development but it left me with more questions.
My Question is: Can I and should I release my app if it has a lot of unfinis... |
I usually understand code by fiddling around, or by inserting printfs here and there, but this time around, that isn't possible, since the end product is an OS, so any suggestions on how to tackle this problem?
|
I'm about to implement my first State Machine and I'm left with one question, which is the acceptable coding form on who should change the state of the object/entity? Should the StateMachine change the state? Should the object itself change its own state? Should a sevice (e.g. IncidentTicketService) change the state of... |
In C++ a variable is allocated in the 'Call Stack' ('Stack') or the 'Heap.' Frequently when referring to allocating a variable to the 'Stack', people use the phrase "Push to the Stack."
My issue with this is that the variables allocated to the Stack can be randomly accessed in any order. Therefore, the variables are no... |
I have a conceptual problem here. When i query my database, i often do so with joins. So a result set row might look like
+------------+--------------+------------+-------+----------+----------+---------+
| CustomerId | CustomerName | MaterialId | Sales | Quantity | Salesman | Manager |
+------------+--------------+---... |
I recently I started learning Rust and Scala and what struck me was the lack of inheritance model that I'm used to in C++ and Java.
Although I can model simple things with structs and traits in Rust, I want to see a more idiomatic way to model different kinds of problem domains using traits and composition.
For exampl... |
When is it advisable to write a class that can do multiple things?
A bit of background: my boss prefers to write things that can be used over and over again. While I tend to agree with this sort of concept (OOP and all), there have been some instances where trying to do such a thing causes, what seems like, extraneous... |
SOAP has a standard way of propagating errors, a SOAPFault field in the envelope. This standard also implies a number of things, such as its structure.
RESTful, being an application style, implies much less on how errors should be propagated. There's no concept of an envelope and more and more I believe that the servic... |
I'm trying to store more than 512 combinations of a game somewhere locally on my hard drive as a single file permanently unlike the temorary nature of arrays. If I store it in a text file like I normally do, I wouldint be able to access the n'th combination easily. Is there any database kind of thing where i can store ... |
Getting useful feedback early in the development cycle gets you to a high-quality feature faster.
And the most useful feedback can be in the form of users actually using something in the wild, instead of in a contrived setting. If you see users use a feature during their actual use of the product, their experience is "... |
I have a couple of questions about the practicality of developing a WPF application that loads data into memory from a text file and then manipulates the resulting object(s) instead of transactions with a database such as SQLite. Multiple views would have bindings on the resulting object(s) in memory. Persisting the up... |
I've done a number of LOB ASP.NET MVC projects (MVC5) and would like to re-structure how I handle some things for a new project. Specifically, I have a component that I want to re-use throughout multiple places in the application.
Current Method
Let's say I have an app that handles patient case management. Part of th... |
What is complexity related to number of operations/interactions between objects within a system? as that number increases the programmer capability of understanding and maintaining the system degrade.
|
Is there a distinction between a function definition (not a declaration) and a function?
For me a function definition, is what gets defined by the programmer in the source code while the function it self is what we get after compilation. Is that a valid distinction?
|
Now I'm working in a mobile apps company, and Objective-c ,c++ (for iOS) and Java (for android) are my most frequently used language. Is it a good habit to just use common language features among them? (for example: never use multiple inheritance which can be used in c++ only)
I know there is already a famous thread si... |
I have a small issue with namespace and class naming. Here is a practical example:
ResourceLayer.cs - Public component that holds the manager and the map provider, implements an interface
ResourceMapProvider.cs - Provides a bitmap representation of the resources
ResourceManager.cs - Is a repository of resour... |
I'm trying to pass a parameter to create a thumbnail in AWS Elastic transcoder, which shouldn't be that difficult except I know nothing about regular expressions.
My log is giving me the following error:
Member must satisfy regular expression pattern: (^$)|(^.*\\{count\\}.*$)\n
I just need to specify something calle... |
We have three layers in our application. Service layer to provide an external API. BO layer for our business logic, and a DAO layer for our database connection.
Let's say every time we update a File, we also want to change something in the Folder, for example 'last modified date'.
This needs to be done in a transacti... |
I'm doing a little bit of cleanup and I'm trying to gather all the spread SQL queries done to an object into a single place. I have a class whose responsibility is to present a CRUD interface to the developer, and to encapsulate the results coming from selection queries into objects, that at the same time can be update... |
On websites like Facebook and Twitter, you've got a function to log off on all devices. How does it work?
Does it work with IP addresses or something? What happens when you login on a device and use that function?
P.S.: Facebook and Twitter are just examples in this question. It was just easier to explain what I mean.
|
In situations when we need to write something like this:
if ($doStuff) {
$obj->doStuff();
}
is it acceptable to write something like this?
$doStuff && $obj->doStuff();
If not, why?
|
In his book Patterns in C, Adam Petersen describes using a pointer to a struct, which is declared in a header file, to create a first-class abstract data-type:
/* Customer.h */
/* A pointer to an incomplete type (hides the implementation details). */
typedef struct Customer* CustomerPtr;
/* Create a Customer and return... |
I've moved this from Stack Overflow and this was the suggested place to ask. This has been marked as a possible duplicate of a question about the merits of composition over inheritance. I'm not asking that question, I'm looking for strategies to manage development given the code we have.
The context of the question is... |
I've seen an API list methods with both of the following signatures:
methodA(...) : ReturnType
methodB(...) : typeof ReturnType
I understand the first but not the second.
My question comes from reading through the API for Angular2 where I encounter both of the above. For example, class TestBed lists two method... |
Logging is something that is necessary but is (relatively) rarely used. As such it can be made much more compact in terms of storage.
For example the data most commonly logged like ip, date, time and other data that can be represented as an integer is being stored as text.
If logging was stored as binary data, a lot of... |
I heard somebody say their language has a convention where the names of functions which mutate state must end with an exclamation point. I'm trying to write more functional code and I like the idea of somehow marking functions according to their side effect status i.e. none, inward side effects, outward side effects (I... |
Currently in our business we use Team Services in the cloud with a single self hosted build agent which runs locally on a server in our office.
As we are expanding and taking on more work there is an increase in the number of queued builds. As a result we are considering adding additional build agents to cope with the ... |
I've been reading the 3rd edition of [Algorithms][1] by Cormen, Leiserson, Rivest and Stein. For DFS and BFS their algorithm loops through all the vertices first and colors them white.
1) If the color attribute were part of the node/vertex you would have to traverse the graph before you traverse the graph. And if you c... |
I am discussing the architecture for a new project with some colleagues. The project is relatively small and can be considered as a 'normal' crud web application.
Everybody has come up with an architecture where they are comfortable with. For example the onion architecture and the Domain Driven Architecture. Some progr... |
In most languages I've used it's common practice to replace the reserved word class with clazz when you have a variable that refers to a class. This has become a sort of de facto convention, to the point where if I see klass it surprises me.
Is there any "replacement word" that's even close to as popular for the inter... |
I've recently read a number of (layman's) articles on quantum mechanics and quantum computing, and keep seeing examples along the lines of "Quantum computing can crack passwords quickly by trying all combinations at once". The example goes on to show that rather than passing in an N-bit value, an N-qubit value is pass... |
Suppose I want to create a portable OS, that needs a USB flash drive only to work. and i wrote my boatloader in the first sector to be loaded by the BIOS, from here on, what can I do to load my OS kernel, which is located somewhere in a USB drive?
|
My understanding from reading threads like this one is that the point of ems is to define all measurements in your webpage, by the base font size, which can be set by your browser.
For example, in Chrome you can do this by going settings -> show advanced settings -> web content -> font size: very large. I might do thi... |
This question is inspired by a question about final in
java.
In C/C++, should I use const whenever possible?
I know there is already a related question about using const in parameters. Unfortunately that question and it's answers don't fully answer my question, because it's only about function parameters, but I would ... |
I understand how you create flowcharts or data flow diagrams for simple linear based programming. But how do you design a flowchart for event based programming, like a game that runs on Unity3D? How would you structure it?
|
How, if at all, is Message Passing Interface (MPI) related to the general concept of "message passing"?
Admittedly, the question does sound ridiculous. Surely, "Message Passing Interface" is an interface for message passing, right? Nonetheless, it's not actually clear to me if MPI is somehow related to the general con... |
I was reading through design philosophy of java and this line struck me:
"The VM checks whether the signature of the Java code is valid and would refuse to interpret if any change of the code is detected."
how does the vm ensure that bytecode hasn't been changed?
java design philosophy
|
Hi I'm working on a c# MVC code first project. I've started the project and have created the Models, database frontend etc.
Now my attention has come to writing something that can read an excel document and import the data into my database.
This is a bit of a fiddly task, to say the least - so I did start making a unit... |
I'm doing an project where I'm using a microservice architecture. All the services within this architecture communicate with each other using an AMQP broker (RabbitMQ).
When something happens in a service, it publishes an message to RabbitMQ and the services interested in this message can process it whenever they are r... |
I'm working on a simple class to get a token from an API. As simple as it is, it has different aspects.
A connection to the API is needed for this to work at least the first time. Credentials are stored in the code (security is not the subject).
A token should not be fetched from the API more than once every 9 hours,... |
We're building a website to manage our company asset, and apply Agile/Scrum to this project.
We started with the Product backlog as in attachment.
We planned to start the first Sprint but the team concern about system requirement - things outside PB such as hardware/software architect, database design, security, user r... |
I sometimes hear about making web-site fully API based, meaning that even in browser the page is constructed based on API endpoint and practically nothing else.
One of the benefits I see in this is that when you will make smartphone application you already have API that works and tested. And in case you need to change ... |
Say, I have a function, RegisterUser() which takes in an user's registration details such as their username, name and password and registers them if there is no invalid data. For such functions, it is important to report all errors at once, instead of stopping at the very first test at which validation fails.
An except... |
I'm working on the design of a compiler for a language in which I have to use curly brace for two different purposes. I am currently stuck in writing a non-ambiguous grammar but I realized that some other language have the same behaviour.
That is why I'm trying to understand how a part JS/Ecmascript grammar is built. ... |
I am looking for advice on handling states in a WPF MVVM environment.
As an example, assume we have
A TreeView (or some other ItemsControl) with some items and
a button that is enabled when an item is selected.
My ViewModel contains a property SelectedItem that is bound to the SelectedItem of the TreeView.
When the ... |
I have this piece of code
if (!expr1) {
codeblock1;
} elseif (expr2) {
codeblock2;
codeblock1;
}
It is pissing the hell out of me because I am trying to refactor it in such a way that there is no repetitive code, but I keep getting different results.
if (!expr1 || expr2) {
if (expr2) {
codeblo... |
I am developing an iOS app and I am moving to a VIPER-like architecture. It looks like this:
View--ViewModel--Router--ViewModel--View
The difference from the VIPER is that I have have one global Router instead of many Wireframes (it is motivated by the app functionality: almost everything can be opened from anywhere). ... |
I have heard both "fundamental types" and "primitive types" being used.
Is there a difference in what the two phrases are referring to?
|
In many languages, the syntax function_name(arg1, arg2, ...) is used to call a function. When we want to call the function without any arguments, we must do function_name().
I find it strange that a compiler or interpreter would require () in order to actually detect it as a function call. If something is known to be c... |
It's time to improve my workflow. I never had the responsibility of setting up the infrastructure, managing git, versions or releases. For me it was simple push/pull most of the time and I think, the workflow wasn't state of the art. I'd like to change it and as there are so many ways, I'd like you to help me, finding ... |
With hierarchical state machines, and their UML state chart counterparts, all the references I've found so far suggest that an active state must be a leaf state.
I've looked at Samek, and papers that implement HFSMs in C++. Most suggest any transition to a composite (read parent) state must be followed by successive in... |
Let's say I have the following entities that can be accessed at the following URIs (using the standard pluralization):
/things/:id and /otherthings/:id
I want to expose for performance reasons, an api that will response with the following structure:
{
"things": [],
"otherthings": []
}
The call is so that my clie... |
I have simple POCO classes, like this:
public class Book
{
public string BookId { get; set; }
public string Name { get; set; }
//etc...
}
I want to get all those classes and generate another classes, which called viewmodels, for example, the output would be:
public class BookViewModel
{
[HiddenInput(Di... |
This is a Gitflow process question. In all the documentation (and diagrams) I've read about Gitflow, they always indicate that once a feature is completed it is merged back into the develop branch.
But the one thing that I never find defined anywhere is what the definition of "a finished feature"? Is testing (Quality A... |
I'd heard about Design by Contract a long time ago and always was confused by this question. The approach uses real-world client-supplier analogy to describe caller-callee relationships. It stays, that if a client ensures preconditions before calling a supplier, the supplier will get the benefits by avoiding preconditi... |
I'm hoping for a sanity check in my design thinking.
I'm working with a small team on a website based on a MongoDB database. There are several collections in the DB -- for example, one representing persons, and one representing polls. Persons vote in polls, and their votes are recorded in a votes array in each poll, as... |
The project I am working on for about a year now was used to create a new mysqli connection to the database each time there was a Query to the database. In order to quickfix this problem at places where this strategy had some serious performance issues I created a global $connection variable that deliveres a PDO instan... |
I'm working on a small example application to learn the concepts of CQRS and event sourcing. I have a Basket aggregate and a Product aggregate which should work independently.
Here's some pseudo code to show the implementation
Basket { BasketId; OrderLines; Address; }
// basket events
BasketCreated { BasketId; }
ItemA... |
I'm taking the Computer Architecture course in my undergraduate study.
I see that in loop unrolling, one of the constraints is the number of available registers.
Since the number of registers depends on the architecture, is a generic pre-compiled binary targeted for the worst case (least number of available registers)?... |
I've been tasked to query 2 large csv files which are roughly 1 GB in size each. The files contain related data, so file one may contain a list of order numbers, Order Dates, etc and the file may contain the order lines, stock codes, quantity, etc.
Other Restrictions:
No Access to a database - so I can't just bulk ins... |
I am new to the software design lifecycle and the various processes that it consists of. I was taught/told recently that units should not be included in the SDD because the software cannot "test" those requirements because units do not mean anything in the software domain.
An example of this could be..
"..shall...occur... |
We are moving towards developing a web app in a micro-services architecture.
We thought about running the services behind a API gateway that will handle authentication and will proxy the requests to the appropriate services.
We have encountered a problem while setting up the development environment. How can we develop ... |
We're developing a big application with a vast GUI and complex business layer.
Without going into too much detail, the application is currently implemented in a rich native client, but functionality is roughly seperated into core business logic related parts and the (also complex) GUI which is based on an MVC paradigm.... |
I'm wondering what's best practice in next use case:
I'have a view that displays data for 3 resources User, Company, and CompanyType (chosen in select, can be added dinamicaly so it's not enum).
What is the best way to retrieve data:
1)Call API 3 times to get data: /user/id/, /user/id/company, /company-types
2)Or creat... |
If I have pure functional programming language with* very very smart optimization* proccess, is it possible to reason about memory usage, just by looking at type signature?
add :: Int -> [Int] -> [Int]
F. E. If the answer to my question would be yes, function add would allocate exactly (1+n+y)*sizeof(Int).
The reason... |
I am currently sketching out a project I am doing at my job, where I will have a self hosted WebAPI, connected to a serial device, where the app I am creating will configure that device. No, it is not a Raspberry PI :)
So instead of having a database as a data source for the API, I would make
calls to the serial device... |
I am designing a process of transforming a JSON object to HTML/CSS. It consists of:
Identifying special components
Extracting the special components
Parsing the styles
Parsing the layout etc...
I am currently working with a promise chain:
Promise.resolve(true)
.then(copyBluePrint)
.then(transformJsx)
.the... |
Generally game audio engines use a rather simple system for rendering audio:
1. position an audio source in space
2. apply effects on the audio clip depending on the area the object is in
3. shift volume / phase / pan depending on the angle and distance to the listener
But in real life audio propogates in waves through... |
I would like to know if one of the two following equivalent grammars (since they can produce the same rules) is preferred (and why).
For instance the second grammar is more concise but is it a good thing that in the second form the rule b can produce εor such rules should be avoided.
G1:
a => X b Y
| X Y
b => c b
... |
Background
I often write software for systems that are responsible for testing manufactured products. For every product that gets tested, we have to generate a report for the test-results. The way that we do it now is that we create a .txt file with the test-results and write that file into some folder on our network d... |
A colleague has challenged me with an interesting question. To be honest I have no idea how to deal with it.
Suppose the following:
Every 5 minutes you get a new file with one hundred thousand new
records. You need to store the records in a database table within
these 5 minutes.
First, I'd stream that file beca... |
I am writing a unit test with mocks and I am concerned about over specifying the test. The idea being that if the implementation changes in a compatible way the test shouldn't fail since that makes the test fragile and inconvenient.
For example, if the implementation calls mock.add("foo") followed by mock.add("bar") or... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.