instruction stringlengths 34 36.1k |
|---|
We have handheld scanners in a big warehouse, and there are printers scattered around the warehouse. When certain events happen on the scanner I need to Print a Crystal report to a printer.
The scanner sends everything through a web service.
Currently I have the web service printing the document and it is working (kind... |
Today at work a colleague was looking at a piece of module I had written a month ago as a reference implementation.
I had written a WCF service which a Windows service was consuming.
I have a single operation exposed as below.
[ServiceContract]
public interface IMyService
{
[OperationContract]
void PerformASpec... |
Background: We have less than a gigabyte of documents stored in a database. In most cases there are multiple versions of a document with the same name. The versions need to be preserved.
I've been asked to write a utility to extract these in a way that someone else could easily use. Most likely I'll be writing the util... |
I recently started to work in a startup that been around for almost 6 years now. Our main code base is in Node.js, which means that it has been used here since the early days and therefore there is a fair share of "legacy code" running.
There are some issues, but right now I'm struggling with a specific one: how to dea... |
In this question, I'll use a ruby example, but I think it is a general question.
According to the most popular Ruby's test framework (RSpec), mocking any instance of a class (allow_any_instance_of) is a design smell.
Actually, I don't agree with this statement.
So, I would like to know how would be the "best way/corr... |
In recent years all we have heard over and over about MVC, MVP and MVVM.
By developing an application in VB.NET we are implicitly using the MVP pattern (with windows forms).
However, along at least two decades, millions of developers used versions of VB from VB1 to VB6 not having a minimal clue about MVC, MVP, MVVP (th... |
From Kelvin Murphy's review on Algorithms (4th Edition) by Sedgewick and Wayne
For data structures, it is obviously natural to use classes, but they
also adopt this approach for many algorithms, esp. graph processing
ones. This allows the algo to do pre-processing and to store internal
state, and then to provid... |
XOR is not solvable by using a single perceptron with standard scalar product and unit step function.
This article suggests using 3 perceptron to make a network:
http://toritris.weebly.com/perceptron-5-xor-how--why-neurons-work-together.html
I'm trying to run the 3-perceptron network this way but it doesn't produce cor... |
I'm working with JEE standard. I have the following layers: JPA (Eclipse Link), Data Access, Business Logic, and JSF (Primefaces). Primefaces uses MVC design pattern, so the the presentation layer contains the ManagedBeans (controllers).
When I create an object from an user request, must I contruct the object in the Ma... |
Sedgewick's Algorithm 4ed says
Several fundamental data types involve collections of objects.
Specifically, the set of values is a collection of objects, and
the operations revolve around adding, removing, or examining objects
in the collection. In this section, we consider three such data types,
known as the ... |
I have a web application implementing the MVC pattern where I have controller classes whose methods each map to an HTTP request.
I also have a service layer with a bunch of service classes, with each service class typically containing operations specific to a particular domain entity.
For simple logic (like CRUD), one ... |
I'm working on a project that requires a TCP connection between a client and server. The current protocol encodes the data into hex and then sends it. However, hex increases the length of the payload which isn't really optimal from a networking point of view.
Hex follows a pretty predictable pattern with repeating char... |
Say I use a predefined serialization format X for certain data. Should I indicate the application in a custom filename extension or not? It is quite common
pk3 is a zip archive
XSL, SVG and many others are XML files
Some files are INI files
It is practical to denote the purpose of the file, but
I am unhappy to inven... |
I try to read up on the history of testing and I found an entry that I am having problems researching online. Googeling for Triangle Problems results in geometry hits.
I found an entry on a website.
1973 - Triangle problem (Gruenberger) - In his paper Program Testing: the Historical Perspective - based on the talk hel... |
Whereas there seems to be a lot of information on the Internet about what the presenter both is and does, there doesn't seem to be a whole lot that specifically describes where to put it in a multi-layered architecture. My guess would have been the business layer, but very recently I read something that said the busin... |
I have a for loop where I must skip the first element in a zero-based array.
Which of these shows my intentions more clearly?
for($i=1 ; $i < count(array) ; $i++){
array[$i];
}
or
for($i=0+1 ; $i < count(array) ; $i++){
array[$i];
}
|
There's a well-known dynamic programming problem that goes by the name of the "gold mine." You have a n x n grid, each cell of which contains a certain value of coins. You begin at the bottom left and can only move right, up, or diagonally up and right. The goal of your algorithm is to determine the path through the... |
I am trying to solve two situations here related to making POST requests and handling responses.
Making a request and having request timed out due to no server response, as well as assuming that in this case nothing has been written in a database hosted on the server.
Making a request and having request timed out, but... |
Nowadays I have been practising Java EE. There are may annotations which simplify configuration of servlet container. Such as:
@WebServlet
@WebInitParam
@ServletSecurity
etc.
You can do the same thing in deployment descriptor: Web.xml Personally, I prefer annotations.
My questions are:
can I use annotations fo... |
I have written a parser using Python Ply library.
While doing tests with an input file I have noticed a strange behaviour : sometimes the input is correctly parsed with no error and sometimes, there are parsing errors (and the parser doesn't follow the same rules and consequently finds syntax errors).
How can this ha... |
I am trying to write Stack code using the two techniques i.e Design by Contract vs Defensive Programming but I am not sure if I am doing right or not.I am not throwing any kind of exception or error in design by contract assuming all the inputs will be correct.
|
I'm going through some sort of phase where I over analyze and second guess every single decision I make when attempting to write software that has preventing me from getting anything done.
I recently came across a need to store a"complex" C# object in a SQLite database. To boil down the object into a minimal example le... |
I am working on my first sizable C++ program; a 2-D mario platformer remake.
I currently have an animation class that encapsulates all of the functionality of my animations for all the bad-guys called Animation. Then, I wanted to create the animation class for mario, let's call it MarioAnimation. Mario has an ability,... |
I was reading about finalize() method that it may be invoked automatically when an object is eligible for garbage collection.Now this uncertain.But what happens if we call it explicitly.Does it necessarily do a cleanup or is it just a normal Java call?
|
For a general purpose hash table that aims for both high performance and correctness, when, if ever, does it make sense to assume that hash equality implies logical equality?
To lay some ground rules for the question, assume either that all inputs are non-malicious or that a cryptographic quality hash function is used... |
If we have a code snippet like:
public class Finalizer{
static List list = new ArrayList();
public void finalize( ){
System.out.println("hello");
}
}
What is so special about static here that affects the call to finalize ( ).
Is it because that static members have lifecycle of whole program so a v... |
I want to do movie ticket booking and event ticket booking.
In that how to avoid duplicate booking in short cuncurrency.
I have five seats remaining in my event.
Two user comes both will see 5 seats but only one can book it.
How can I achieve this?
Please help me solve this issue.
|
I am working on an algorithm whose specs says that it accepts 32 bit input (long type).
My actual data is 14 bytes e.g 11:12:12:04:DD
I have created sub arrays like
subarray1[4]={'1','1',':',1} // 32 bits
Can I pass this subarray to my algorithm?
Actually when I print subarray as string then it gives garbage value.
Bu... |
There's currently a huge growth in larger companies offering new languages and / or frameworks for us to use to create websites, apps or software and I'm interested to know for what reason do people think this is? There's always been a few big players (Java, C++, Perl Php, VB, C#, Ruby etc) but a chunk of those were cr... |
I'm having trouble in figuring out why the output for theses two lines is different ..
public static void main(String[] args) {
System.out.println("6.0+1="+6.0+1);
System.out.println("6.0+1="+(6.0+1));
}
The output
6.0+1=6.01
6.0+1=7.0
|
I am trying to implement VIPER architecture on iOS in Swift.
The problem I have is how to set up the object graph. Please ignore the Router and the Entity as it is not relevant to my problem. That leaves us with the Interactor, Presenter, and the View.
Interactor - business logic, has state, does work, accepts commands... |
To my knowledge multi-threading is just an illusion since CPU schedules time for each of the process. So when scrapping at a particular time, only one content from the website will be scrapped and it will also lead to so much of difficulty since all of the process are urging for the same resource so there might be a pr... |
Suppose you are selling a web app. There is no data or operation that involves more than 1 customer. Each customer is totally separate.
How would you prefer to make the deployments?
1) Deploy one instance for each customer, meaning you are running and managing many small apps on different servers/virtual machines/on th... |
I have an event handler. It receives an event and needs to do some work on it. That work is split between common work - things that have to be done for all types of event handler - and specific work - things that only need to be done for a specific app.
There seem to be two approaches to implementing this design. I cou... |
I am creating a software for B2B which targets all kinds of large size companies. It will integrate with existing softwares of companies (CRM and ERP systems). I want to expose my API via REST. However, I wonder that do I need to SOAP web services too since it may not be used by companies?
I mean how is the ecosystem ... |
I have a service which sends a set of queries to the server in a single call and acts on the decisions from the server. I will first introduce what I already have and the questions will follow.
public class Item {
int id;
int version;
String description;
}
public class RequestObject {
Item key;
... |
I recently made an esoteric programming language, and I want to know how to test and see if the language is Turing-Complete. Most places I looked said it needed infinite loops and infinite data storage. Is that all?
Also, do I need to simulate a Turing Machine for proof, or is there an easier way?
It is called NOR and ... |
To simplify the use case, let's say I have a mobile app available for Android and iOS, similar to Instagram, where users can upload photos that can be commented, liked or disliked by other users.
When a user comments, likes or dislikes a photo you uploaded, you would get a real time notification on your phone telling ... |
Following is a java solution of the classic question of rotating a nxn matrix in place clockwise by 90 degrees.
public void rotate(int[][] matrix, int n) {
for (int layer = 0; layer < n / 2; ++layer) {
int first = layer;
int last = n - 1 - layer;
for(int i = first; i < last; ++i) {
int offset = i - first;
// save top
... |
I have decided to start building a SAAS app. I wish to keep hosting costs low initially, whilst still providing a good user experience. Here are the components that will make up my app:
Front End
Reverse Proxy (Nginx)
Auth Service
Web API
Worker Service A (processes data imports)
Worker Service B (makes batches of ex... |
I am working on developing an HTML canvas application, where I need to be able to do my own UI event processing. That's where the stem of this question comes from, but I'd really like to understand how the whole process works.
I've managed to find out that typically events will capture or tunnel town, and then bubble b... |
We had a situation in which a senior developer decided to change some code thinking it would be for the best, which it is, but we still had some problems during that period. Some functionalities broke (no unit tests), but the changes did make sense.
What I'm looking for now is to avoid this happening again and also imp... |
The setup
Let us consider a variant of the classical multithreaded programming problem: the producer/consumer problem. We have some finite number of resources (for simplicity, let there be just a single resource). The producer thread continuously creates new resource units, until the resource buffer is full (in our cas... |
so I made a simple game where boxes fall from the top of the screen and you have the dodge them from the bottom of the screen. When a box falls to the bottom of the screen without hitting you get a point.
The part I'm struggling with is how to change the score variable. For now, I have two for loops looping through a d... |
I hope someone can answer these.
I have a WinForms project with +/- 8 forms. I have an SQLite database and a class that handles the queries to this database. I would like to use the passive View pattern so that the View has no link to the Model.
Is a form a View?/ Can a form be a View? Which derives from a IFormView c... |
I'm working on a project where I have to trigger my windows desktop app to fetch the database for new rows once a user on the internal network send new requests.
I have managed to hack this around through several ways:
A timer on the C# desktop app with half a second interval.
The PHP webapp creates an XML file w... |
I can type ⅓, ⅔ and ½ but can I type 3/3 and 2/2 using unicode? I know that from a mathematical point of view the fractions 2/2 = 3/3 = 1 but I am typing a list where I want to indicate that you have reached the final step (third step out of three steps) and entering "1", after ⅓ and ⅔, would confuse most readers, incl... |
I cant for the life of me figure out why this returns 0 rather than 5. i keeps getting incremented before it hits the last return statement, however it always returns 0, from the first call in the stack. I would think that since the most recent call on the stack hits the return in the block i == 5 first it would return... |
I'm trying to keep up-to-date with the latest-greatest from Angular2, in part by carefully reading the official online documentation. Is there a way to be notified or at least to figure out relatively painlessly whether, when and where that documentation has changed?
With Angular2 being so new, the documentation is und... |
Looking into Dependency Injection in JavaScript, as with Angular, I decided that true DI was overkill for my medium sized project, so I worked on a simpler way to organize my project and implement Inversion of Control.
I felt interfaces aren't really worth the extra syntax since JavaScript has so few data types to dea... |
We have a large project that performs a lot of modelling and calculations. This code is being broken down into smaller, more manageable chunks, by shifting particular calculations into their own classes.
To try and keep the inputs and outputs constrained to the appropriate calculation method, two public nested property... |
In a GUI application (to organize images), I use the Observer Pattern (or anything similar to model-view-(view)controller) to inform other components about changes.
Assuming three components A, B, C which show different aspects of some objects, I can trigger "batch actions" which affect many objects in A and B. Each c... |
The client sends a query (a few hundred characters) to the web service. This query can be split into 20 to 150 subqueries with a simple regex. Those subqueries can then be computed independently and take each up to 5 seconds. Thus we'd like to have those subqueries run in parallel in order for the original query to ret... |
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 ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.