instruction stringlengths 34 36.1k |
|---|
I am trying to design a RESTful (or maybe I should say RESTlike, since I am not designing a fully RESTful API, e.g. not hypertext driven) API as part of a refactoring of an existing "take-a-number" queuing management system.
The basic concepts and workflow are :
A given site (location) can propose several different se... |
This is really just a theoretical question by a python newbie who wants to understand more.
I keep forgetting the colon after the block initial statements in python. Those are what I mean:
for <variable> in <sequence>:
if <blah blah>:
My thought is that one reason I keep forgeting is, that they are de-facto implicit:... |
I've just joined a new company that has recently switched development from PHP to C#/.Net Core. They're writing a new CMS from the ground up in this new environment.
Before me, there was only one developer working on this new system, and he set up a system that is rather hard to work with. I'm trying to think of ways t... |
I have many client applications that sync up to a central server.
I am using C#, MS SQL server, Win Forms, ASP.NET MVC + API.
I need to learn/figure out how to perform a 2 way sync for data changes across my server database and local databases.
My server and local databases are almost (but not quite) an exact match.
Th... |
Lets say we have a backend server maybe a database or whatever. When generating the use cases for that server who would be considered as the actor? System(front-end) or the user(user interacts only via the front-end with our server) ?
|
I have recently mastered the Lambda expression that was introduced in java 8. I find that whenever I am using a functional interface, I tend to always use a Lambda expression instead of creating a class that implements the functional interface.
Is this considered good practice? Or are their situations where using a Lam... |
Thinking about statelessness I wonder how I can overcome the issue of saving the user's password on the client side in a secure but also comfy way.
I assume the client always sends credentials to the server and that uses CPU power to verify the authenticity and also make sure the user has the authorization to do whatev... |
I am looking to an IoT like system which must deal with a wide range of data complexities. As an example, I'd like to model a 'thing' and I know all things have a location. However, when the actual data arrives from these things (from different vendors), something like latitude can be spelled, it may have different n... |
I have used data-driven design in the past and it has worked quite well. What I dislike about it is if you need some form of a string whose value has to be updated based on other values.
e.g., "Exports %x percent of %y". In that case you will need an extra column serving as an identifier, to tell which variable in your... |
I have a limited amount of input types:
34:56 = sensorA#, sensorA#, sensorB#
2:5 = { led# }
66 = otherSensor
2,3,4,5 = greenRelay#, redRelay#, relayA#, relayA#
a:b implies range.
{name} implies a global name for the dataset.
# represents automatic enumeration in the name (not relevant for the
question)
Single v... |
This question is about finding approaches to solve a specific problem.
I have a table which has several metrics with values.
[metric1] [metric2] [metric3] [metric...N]
Those columns are fixed.
I need the user to be able to generate calculated metrics using the existing columns.
Let's say that a user made a custom metr... |
I have a 2500 line Character class that:
Tracks the internal state of the character in the game.
Loads and persists that state.
Handles ~30 incoming commands (usually = forwards them to the Game, but some read-only commands are responded to immediately).
Receives ~80 calls from Game regarding actions it is takes and r... |
I have an object Carconstructed using builder pattern.
Issue was a lot of code redundancy.
Car.Builder builder = new Car.Builder("Mercedes");
builder.numDoors(carConfig.getNumDoors()
builder.engineType(carConfig.getEngineType())
builder.isManual(isManual)
builder.build())
Car.Builder builder = ... |
In software development we usually do a analysis phase where requirements are taken, user interfaces are designed (for software with ui), etc. After the analysis phase you know what to do, and you can estimate (aprox.) the effort and the cost for the future tasks. But usually I noticed in some companies, the analysis p... |
I think I understand what Promises are about, and I think I understand what continuations are about, but I still fail to see what their connection is.
In what ways do Promises use Continuations. They never return, which is explained by the fact that they use Continuations, but I don't see when and why they do the "jump... |
I just wrote a function and I'm not sure if it is a good idea.
The motivation is, I'd like to store some internal bookkeeping data along with my business data in one big happy javascript object. When that object is consumed, I would like to strip the internal variables. As a convention, my internal variables take t... |
what does it mean when some technical guy asks did you work on cloud ?
I have worked primarily java based web applications. But sometime in discussion/interviews technical folks asks Have you worked on cloud . To me cloud looks very broad term and I can think of below three related work related to cloud
1. work on we... |
GO has embraced,
1)
JavaScript/Python language constructs,
Higher order function
Closure
Slicing
Range operator
Anonymous function(inner function)
Provides abstractions for map object
for..in as for..range
2)
C language constructs,
Non reference type('var a int')
Variadic functions
Overriding init() function
struct ... |
If I make a class, that in the constructor accepts an array or collection, but this array or collection is optional (the parameter can be null), and then I store that collection in the object in question, in the constructor i need something like:
this.coll = coll == null ? null : coll.clone();
Should I unit-test such ... |
What is the best course of action in TDD if, after implementing the logic correctly, the test still fails (because there is a mistake in the test)?
For example, suppose you would like to develop the following function:
int add(int a, int b) {
return a + b;
}
Suppose we develop it in the following steps:
Write tes... |
For simplicity's sake, let's say I'm maintaining a fork of Bootstrap. My changes are specific to my theme, so they'll never be merged back into the original Bootstrap project, but I still want to make sure that my project has the latest changes. Over the life of the project, I'll merge in Bootstrap's changes several ti... |
I was reading the RFC 2616 regarding HTTP/1.1 when this term came up:
Therefore, the HTTP/1.1 protocol provides these important elements: [...] Protocol features that provide full semantic transparency when this is required by all parties.
[...]
The Cache-Control header allows a client or server to transmit a
v... |
I'm developing an app (for Android) which uses data received from my rest services. These services use also GPL libraries: if I have correctly understood, if a server side web application uses GPL libraries it has not requirements to release its source code as GPL. Has my app code any requirements if it uses this rest ... |
C is a static-typed language that is not type-safe, because pointers(void *y) let you do pretty much anything you like, even things that will crash your program.
GO is also a static typed language
Despite, GO has pointers(var y *int), it is still considered type-safe language.
Question:
Considering GO pointers,
Why GO... |
So I am working on a legacy system, that had one database server. For reporting and to split the work load it has been moved to a Master / Slave setup. This process is done and seems to be working well with little to no lag between an insert or update on the master, and it being copied to the slave. The problem I have ... |
Imagine I have to manage products.
Products have features , features maybe have free input option, or set of limited options,
not all the probabilities will be available:
options01/features01 * options02/features02 * ... options0n/features0n
so I have a set of rules where on
specific condition on a feature:
black... |
Virtualenv appends its own path to $PATH, effectively overwriting the Python to the one picked when the virtualenv is created. Would changing the $PATH work equivalently as virtualenv in a compiled language with shared libs?
I am asking this because it seems that there is no easy replacement of virtualenv for e.g. C (w... |
I am creating some software that runs on a machine that performs multiple tests on a product that is built at my company. I am also trying to improve my coding and I have been recently researching design patterns and seeing how I can apply them to my code.
The part I am currently looking at is the actual test sequence.... |
Here's a small illustration of my question:
Assume a build job that consists of 4 independent tasks named A-D. D takes longer than A-C do in sum.
A build system that cannot incorporate the relative task times might schedule the tasks like this:
---------------------------------------
CPU1: A | C |
---------------... |
I just realized that in Python, if one writes
for i in a:
i += 1
The elements of the original list a will actually not be affect at all, since the variable i turns out to just be a copy of the original element in a.
In order to modify the original element,
for index, i in enumerate(a):
a[index] += 1
would b... |
At work I'm using Java, but I'm planning to study some other programming languages as Python or Clojure.
I'm thinking of coding one project in Java in my Git repository and, during my study, coding the same functionality in Python or Clojure.
Because it will be a project without an effective value at work and by a pers... |
I ran into an issue where I forgot to resolve my promise, leaving the remainder of the chain waiting (Forever). Thankfully in my case I was able to track down the issue in only 10 or so minutes, but I could see this being a really big pain in the butt if I don't figure out some way to check for orphaned promise chain... |
I am currently learning about various object oriented design patterns. I came across a pattern called the builder pattern which is basically where you build a complex object through the use of creating simple objects that build on each other step by step.
My question is, in what scenarios would such a design pattern be... |
Working in an architecture roles I was asking the team that was developing a component to add some logging at certain points. For this I was offered and NFR document to fill in.
Does logging fit as a Non functional Requirement or could they go somewhere else. in oneway a NFR document is convienent for a boiler plate r... |
I made a simple algorithm that makes my logs more suitable to be plotted. A logfile has the following structure:
timestamp bytes
and looks like this:
1485762953167032 517
1485762953167657 517
1485762953188416 517
1485762953188504 517
1485762953195641 151
1485762953196256 151
1485762953198736 216
1485762953200099 216
1... |
I am required to write tests for an API at work to make sure we don't break it as we develop on it. So far, the solutions that cam out are as follow :
"prod" code and "devel" code running on the same DB (with a dump of the production database);
"prod" code and "devel" code running on their own DB.
Both solutions requ... |
my question is related with Angular 2 Modules (@NgModule).
Previously I’ve worked with angular 1.5.8 on huge business application and I’ve got used to Angular 1.x practices.
Important background:
Right now I'm developing something more then single application. It's going to be more like business platform. We set up com... |
In scrum how do you handle sizing things accurately without overcommiting and still keeping the team honest?
In my agile team I am seeing us size things large with some buffer, usually 2 or 3 points larger with typical ticket sizes 5 and under, to account for mistakes in the sizing so we don't overcommit in our sprints... |
I'm working with particular classes of matrices which admit fast operations without resorting to dense linear algebra. To keep the heierarchy simple, I'm currently doing the following (greatly simplified):
class Matrix:
def mvm() # matrix-vector multiplication
def is_square()
def is_psd()
def is_symm()
... |
I'm working into a project that needs to implement a Reverse Socks5 connection.
In practical terms, the browser (Chrome/FireFox/Opera/IE) will connect on a local socks server (127.0.0.1:8080), and on this same server I will have a remote client connection on another port (192.168.0.9:8081).
Once I open a website on the... |
In GO, rule is, methods can be defined only on named type and pointer to named type.
In C, below code, operations are defined on type(say List),
typedef struct List List; //list.h
typedef struct {
bool(*canHandle)(ImplType);
List*(*createList)();
....
const void*(*listGetItem)(List*... |
I'm currently working on an architecture that have the following structure:
(central server)
/ | \
(local server) (local server) (local server)
/ | | | | \
(PC) ... (PC) (P... |
I and three other people got some money to build an educational mobile app (sociology for high school students). The software requirements are decided largely by ourselves. The team will consist of the following people: two experts, one whose role is to create the teaching material (questions, text, etc) and one who wi... |
I am using software in my code that is distributed as BSD license. It has a lincense.txt which describes the original authors who wrote that software. It asks me to retain the txt file, etc when i publish my code which i will do. But do i also have to cite it when i publish a paper? The license doesn't say anything abo... |
I'm creating an application that allows you to input Orders, an order has some basic information: who ordered it, what date, etc. It also has a list of line items that are ordered. Each line item can (probably 50% of the time) have it's own delivery date separate from each of the other line items, they can also be star... |
I want to preface this question by apologizing for its length, especially the code samples; however, I believe I have included the minimum necessary code to illustrate the differences in approaches.
I have a class with a number of instance attributes, and each of these attributes has some respective attributes.
For ex... |
Background:
pthreads follow pre-emptive scheduling, whereas C++ fibers follow cooperative scheduling.
With Pthreads: the current execution path may be interrupted or preempted at any time This means that for threads, data integrity is a big issue because one thread may be stopped in the middle of updating a chunk of d... |
I'm developing a framework with C++, and it contains three layers:
Low level functions which do the hard work
An upper layer which uses the low level functions to accomplish tasks (functions at this level generally uses only one lower level function and explicitly accepts the pointer of the function to know which func... |
Says, I have employee table, with {id, name, unit, etc..} what is the preferred ways to get this data if I frequently use this data, my first option is to query it from database when needed, something like this,
public static List<Employee> GetEmployees(string unitID)
{
List<Employee> employees = new List<Employee>... |
I'm currently working on a n-tier web application using ASP.NET Web API 2.
It has been decided to use boilerplate as DI framework.
Now, I need to reconsider the architecture that ties the business layer to the persistence layer.
The current architecture is making use of a Persistence Facade that exposes the writing/... |
I know that, on github, you can define a protected branch and allow only certain users to merge a pull request there.
Say, for instance, that users A, B, C and D are developers and A is team leader and the one that should be responsible for merging the pull requests into the protected development branch. It happens tha... |
Scenario:
we want test drive a create method, the resulting method would look like this:
public MyModel Create(MyModel model){
var dao = TransformToDao(model);
dao.Date = DateTime.Now;
var result = _repository.Create(dao);
return TranformToModel(result);
}
I think two test points for this method should... |
I have a war file of a web application which I want to deploy in production mode. I am confused as to how I should go about it. I was currently working Apache Tomcat to develop and debug the application. Will tomcat be suitable for a production release as well if I'm expecting heavy traffic on the web application? If n... |
Say I re-implement a method for finding the position of a string within a string. So I get either the position which is an integer, or a "magic number" like -1. I see this pattern in so many programming languages, where some return a value like null, some return some random "out of range" value like -`, some totally th... |
I'm quite new to designing large programs in C++. I'm writing series of operations, each of which have their own class, which will be invoked by the ProcessMgr class.
I'm using ProcessMgr as an interface class, from which each operation can be invoked:
class ProcessMgr
{
private:
class OperationOne;
class Opera... |
I structure my Android application following Uncle Bob's Clean Architecture which basically comprise of at least following relevant layers:-
Presentation - Using MVVM approach. This layer contains Android's Activities and their corresponding ViewModels.
Interactor - This layer encapsulates application's use cases logi... |
Out of curiosity. Say I have a class with a data member:
class Base {
public:
//methods and constructor,set and get, operator overload etc
private:
int data;
};
class Der : public Base {
public:
//just overload of some of the methods in the base class, please note there's no data member
}
The idea is bas... |
We have an ASP.NET MVC application and a bunch of libraries that are used by the application. There are cross-cutting concerns and dependencies like loggers, repositories, user tokens etc that almost all of these libraries need to work. Some libraries are dependent on other libraries and so on.
For example -
... |
Say you commit, pull, have a conflict, resolve the conflict, and then commit. Since the local change already has a commit with a meaningful message and the remote change being pulled has its meaningful commit messages too, what should the message be for the commit that resolves the conflict? Often I find myself making ... |
Rstudio has a community version for free:
https://www.rstudio.com/products/rstudio/#Desktop
But mentions the license is AGPL v3.
Does this effect the licensing or IP rights of code written on the platform or is it referring to extending the IDE itself?
The paid version commercial license seems to be talking about exten... |
I have a bunch of classes which deal with validation of values. For instance, a RangeValidator class checks whether a value is within the specified range.
Every validator class contains two methods: is_valid(value), which returns True or False depending on the value, and ensure_valid(value) which checks for a specified... |
How do I create instances of classes which require a huge amount of components and attributes? Take for example a car. A car has hundreds of sub components each with their own specific properties. There would be thousands of parameters to pass or work with. Some components even repeat themselves inside of the car (whee... |
Hi all: I've gotten this question like four times interviewing in silicon valley. What is the correct solution?
Shuffling a deck of cards. The problem description is as follows:
You are given a deck containing n cards. While holding the deck:
Take the top card off the deck and set it on the table
Take the next card... |
Let's assume that I have the following interfaces and classes:
public interface ITest { }
public class Test : ITest { }
In NinjectWebCommon.cs:
kernel.Bind<ITest>().To<Test>();
And after this I want to use my ITest interface:
public class Vehicle
{
private ITest _test = null;
public Vehicle(ITest test)
... |
Assume we are building a system for managing large, tree-like domain-structures like banking loans or insurance contract. At the root of the domain model is a Loan class.
It serves as an entry point to the layers of the domain model e.g. loan parts, collection information, contractual parties, collateral, associated i... |
As a general rule, programming languages are designed for use by humans, and thus for entry using a US-QWERTY keyboard. (This makes some number of conceptual skips, myself as proof as I'm doing most of work on a BE-AZERTY, but indulge me and join me in this leap of faith.)
Using the letters of the alphabet for reserved... |
Stack overflow suggested that this question my be better suited here. I normally work in c#, but I'm working in a vb.net net application currently. So feel free to respond with vb.Net or c#...
Essentially I have a singleton that does all of the heavy lifting of getting global settings which are stored in the database;... |
(I've seen this question, but the first answer goes about auto properties more than about design, and the second one says hide the data storage code from the consumer, which I'm not sure is what I want/my code does, so I'd like to hear some other opinion)
I have two very similar entities, HolidayDiscount and RentalDisc... |
If I have ten classes, and they all need CRUD operations, how does an Aggregate Root and the Repository Pattern solve me having to write lots of boilerplate code (the DRY)?
Take the example of a School and I have a Student, Teacher, Subject, Schedule, Room, ..., etc.
If I did nothing, I'd have a service or class somew... |
This is my current CQRS use-case setup:
Command DTO is received in application layer handler where we map Command DTO to appropriate domain objects if needed, re-hydrate aggregate root from repo and call some method on AR
class CommandHandler{
handle(Command command){
Dom1 dom1 = new Dom1(command.d1);
... |
I'm currently trying to better design a database structure for defaults where a reference to preset defaults is maintained globally, but the system is flexible enough to allow for new defaults to be added.
Database:
Default Fruits
----------------------------
ID: Name: Colour:
----------------------------
1 ... |
There are some Tech Leads that perform code reviews for each Git pull request.
Apparently, a very good practice to be aware of the evolution of code.
Basically, they expect to inspect a few lines of code differing from previous code in order to ensure "quality" easily.
As a lot of good developers know, another very g... |
How does a programmer figure out multiple uses or applications for the original software he/she has written. I am an artist who has designed a RPG game with several different and separate applications that are all linked and combined in the software that I am attempting to find alternate uses/applications for. Since I ... |
Say we have 1001 clients that construct their dependencies directly rather than accept injections. Refactoring the 1001 is not an option according to our boss. We're actually not even allowed access to their source, just the class files.
What we are supposed to do is "modernize" the system that these 1001 clients g... |
In my day job I work on a tightly controlled project with features and overall scope ultimately decided on by committee.
Often the final features are the result of a single (or multiple) member's needs.
Thus every now and then an idea lands on my desk that can, technically speaking, be implemented but may not actually ... |
Often I change code but I don't know if I might need the old one, I can leave it under comment but then I find myself with lots of green lines while I hardly can read the real code.
Thanks.
|
I was trying to understand how jQuery's cross-browser events work, when I noticed these two functions in the source code:
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
Further down in the code these are used like:
if ( fn === false ) {
fn = returnFalse; <--- here
} els... |
So one day i was reading about RSA and over there it was written that we can secure the data using the public key. So as an idea can I secure the data on the client itself before sending it to the server using the public key provided. And decrypting using the private key on the server?
|
Is it good design to have a controller for each object of your API? I know this is a short question, but it's really a fundamental question that I do not know. Say I have a school or a CRM. That is a lot of controllers. I don't know another way to do it, but it feels like a DRY problem.
I am using ASPNET Core if th... |
I wrote multiple times different apps that have following requirement.
CRUD Operations via DataGrid control...
Everytime I start new prject I write new code for same requirement over and over - what is the best way to make custom DataGrid control which is reusable and generic. I'm a junior developer and I'm having hard... |
I have a method processDataAssumingLinkedHashMapInput() that processes a Map. The Map must be a LinkedHashMap ordered by values. Data comes from getStrIntMap(query). This method gets resultSet from SQL and puts it in a LinkedHashMap. Here is the code:
public void processDataAssumingLinkedHashMapInput(){
String quer... |
Let's say I have a three tier application structure, with Presentation, Service and Data layers. The data layer is managed by an ORM and has two models/entities, Show and Episode, with a one-to-many relationship (one show consists of many episodes).
In the service layer there is a ShowService, which can manage shows. T... |
I have been working in large multi module projects over a period of time. One major issue I faced is, how to communicate to other teams of a new feature which they may be interested in.
Consider this scenario. Projects X, Y and Z depend on a project P. All depend on version 1.0. Now I work on X and P, do some fixes and... |
Protobuf is nice and dandy, but it was not made with self-description in mind. Now this is totally okay if you're using a well-defined protocol and want to replace e.g. SOAP-messages or just want to replace a restful JSON API or the like.
However I would like to use it over a Websocket though and instead of closing and... |
Suppose that you are modeling and application in which you'll have 4 kinds of entities, say
a Person
a Job
a Machine
a Chemical
Now you have to model all possible relations (N:M) between those entities, because your business logic is such that it really does make sense, so you end up having many tables:
Person_Job (... |
I'm writing a Python tool to convert/store the data from a commonly used plaintext file format for volumetric data generated by computational chemistry calculations into the binary HDF5 format using h5py. The plaintext files are often huge, frequently 100MB or more, and in cases where certain types of semi-lossy compre... |
I am working on a local copy of a large project on github. Most of the changes I make are modifications to tailor the application for a speific use case, as such they are not going to be accepted by the maintainer.
I am trying to figure out the best way I can regularly update my local branch with changes made in the ma... |
Suppose I am developing mobile applications using C++, and I found some methods are not suppose to change once written, for example:
class MyClass{
public:
float kmHrToms(float kmHr){
return kmHr/3.6;
}
std::string toString(){
return "this class is used to...";
}
.
.
.
}
a... |
Suppose the following situation:
A CI server generated regular snapshot artifacts
At some point, an artifact is considered "stable" and is given to QA for testing
If it passes, it's deployed as an official release
If it doesn't pass, a newer snapshot gets tested until one passes
Given an arbitrary build, we want t... |
Progressive enhancement usually refers to web content, and the idea of having a page that is readable before it's fully functional.
I'm suddenly preoccupied with the idea that I can't progressively enhance my code. I want to be able to add methods to my values. I might have a string property. If I want to enhance it wi... |
Take an HTTP API endpoint which spits out the following response model:
{
"type": "Dog",
"name": "Jessi",
...
}
The type field has been described in the documentation as being one of Dog, Cator Fish.
Would adding a new option,say Rat, be considered a breaking API change?
Is adding an option to a finite li... |
There some times appears a task when you have a sequence of object and you need perform some action when a particular pattern (subsequence?) occurs.
As more concrete example we can imagine a log monitoring solution which should alert when a predefined sequence of messages is detected (A followed by B, followed by C, bu... |
I have a software which logs various events into a database (SQLite).
Currently the stored datas are :
Message
Date
Category
Criticality
The logs are written in the current software language. Which mean that the message :
User "admin" logged in
can become
L'utilisateur "admin" est connecté
if the software is in... |
I am using semantic versioning 2.0.0. In my situation I have a concrete implementation of some interface A in one library. And I have the interface that's being implemented (call it B) in another library.
I understand that if I were to add new methods to the interface B then that would be considered a major change for ... |
I believe everyone encountered this example numerous times, where there is a primary/foreign key relation. Now, I am interested when to add just a foreign key ID instead of all/some relevant foreign key information.
For example
Product
ID
Value
Name
Description
Order
ID
ProductID
Value
Name
Description
vs
Order
ID
Va... |
I've been dealing with a Sr Dev recently that loves unit testing. That's great! I'm not sure I agree with his testing methods though, contrived example:
function foo (String $var) {
switch ($var) {
case 'hello':
return '-world';
default:
return 'good-bye!';
}
}
function ... |
I have been reading the source code of some Java library classes, specifically CompletableFuture. I noticed that the authors are making extensive use of cryptic (single-letter) variables in the code, which makes the code arguably unreadable and difficult to track.
Is there a specific reason/rationale behind this appro... |
We have a solution containing a web application project (mostly webforms) and two separate "config" projects that are copied over depending on which client's specific output is needed.
Presently to "deploy" we zip up the web application folder, but of course it picks up files that were do not want such as project files... |
I have finished learning about java beans, and from what I understand, they are regular classes just that they are serializable, all the properties are private and are accessed through getter and setter methods, and they contain a public no arguments constructor.
I can see the advantages and disadvantages of writing be... |
I see wikipedia entries for:
https://en.wikipedia.org/wiki/Source_lines_of_code
aka SLOC.
Shouldn't there be some other kind of metric like SCC? (source character count).. or maybe there is and I just haven't found it?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.