instruction stringlengths 34 36.1k |
|---|
We're having a bit of a discussion in the office about how to implement good integration tests.
Example:
Account Creation
1. Create User
2. Add Role
One case we test is, if there is already a user with the same email address.
For this, I first created a user (programmatically ) and then tried to create an account wit... |
I have some SQL commands that I am trying to figure out the best way to have them in code so that:
1. They are very readable
2. They would be easy to update
3. They won't be performance overhead due to many string construction.
I have something like the following that did not turn out too good.
public class SQL... |
Abstract: Is it acceptable to include the type name in the variable name?
My scenario:
I am working with C# MVVM, and I have a lot of ICommand properties in my ViewModel, named various things like GetSomething, DoSomething, WriteSomething, etc. The "rule" for ordering members in C# is alphabetically, so I have my comma... |
I'm trying to figure out what the appropriate way to deal with this problem is in a functional way. I'm assuming there's a functional data structure or technique that will make this easy to handle.
The problem is that I'm making an API call to get two bits of data, I use one in another API call and if that call works t... |
To my understanding, standards are mainly for code portability between compilers, but I'm curious if some things in the standard that are only treated as warnings when not followed can cause software to actually fail, or if code is written that does not comply with the standard, and it compiles/executes where it needs ... |
This document on European Telecommunications Standards Institute website describes some Machine2Machine (M2M) communications protocols. I've seen mIa, mId and dIa interfaces in some research papers, however, this document, which seems to be one of the only few useful resources in describing what they are does not seem ... |
I am trying to implement Strategy Pattern for handling my content serialization and deserialization.
So I have four kind of requests namely CREATE, RETRIEVE, UPDATE, DELETE and for each request I want to serialize/deserialize the request and response content.
public interface ContentHandler{
String serializeReques... |
I have a REST API where:
GET or POST /foo/{foo_id}/bar?a=1,b=2,c=3
and
GET /bar/{bar_id}
both yield
200 { bar_id: <GUID>, foo_id: <foo_id>, a: 1, b: 2, c:3 }
When no matching bar is found for the first call, bar will be generated and persisted. The operation is idempotent, but it is potentially not read-only. Should... |
Hello I am new to PHP programming. Sorry if my question seems silly. I already know I have to use a version control.
My doubts about the source code protection.
How can I work with other programmers in a php script without the risk of the code being stolen?
Is there a development method that helps at this point?
When s... |
I'm building my first open source project. It's an API build with C#.
My project has layers
Api itself to receive requests
Services library, for logic.
Database library, for db operations.
I'm using Dapper as orm and i'm creating, altering tables in the database manually. If anyone ever downloads and runs my app, th... |
I've lately been using pcregrep to do Perl-style group matching when doing my bash scripts.
The problem with pcregrep is that it's not readily available on Linux machines in general.
An alternative would be to run Perl one liners or maybe, if possible, Python one liners to do those matches.
I was wondering how good of ... |
I am just trying to learn c# and am I little confused about the best way to validate data that's input from a user.
I have this code in a Person Class to validate a phonenumber
public string PhoneNumber
{
get { return phoneNumber; }
set
{
if (!Regex.IsMatch(value, @"^[0-9()+- ]+$"))
{
... |
Right now I am designing a new database for our family business. I have a few tables like in the image above, where the table only contains two foreign keys in order to represent an association between two records in two different tables.
Ex: transaction_id 123 contains the purchase of membership_id 100.
Is there a pr... |
In my organisation I build financial products, for mutual funds, 401Ks, life insurance and margin-loans (or the equivalent in my jurisdiction).
I take feature/epic requests from product managers - plan a project, design the software changes, provide costings, lead the team, drive the change through the organisation, s... |
MyBase is forcing implementation of method f() in all children. This can be achieved either by using abc.ABCMeta to make f() an abstractmethod:
import abc
class MyBase(metaclass=abc.ABCMeta):
@abc.abstractmethod
def f(self, x):
pass
class Child1(MyBase):
def f(self, x):
print(x)
class Ch... |
I need to design a service that preforms calculations, the calculations are of the form of invoicing a method and returning a value in some manner.
One of the requirements is that when a new calculation is made available I won't need to take down the entire system.
I thought of one of the method for achieving this, but... |
When writing custom deserialization code, what's the better practice: a static method that creates an uninitialised object (e.g. using the default constructor) and then performs deserialization, or a constructor that performs deserialization directly?
For example, deserializing a Foo:
class Foo
{
int bar;
this... |
I am relatively new in web development, but I am trying always to find the best way and make my code even CSS and HTML clean. So I've started exploring best practices.
First of all lets start with em and rem. Most of sites nowadays still used pixels instead of relative units. It works correctly, mobile phones can ... |
I'm trying to understand the approximate polynomial time algorithm for subset sum problem at Wikipedia, but I stuck at the pseudocode's 3rd line:
let T be a list consisting of xi + y, for all y in S
What does this line mean? What is x, and how do I create the correct T list?
|
I am experimenting with the mysql-binlog-connector-java library for Java. When running sample queries and observing the sequence of replicated events I noticed that the ROTATE event is received twice (with only slight difference). I was unable to find any information regarding this.
I am curious what is the purpose of ... |
I am recently developing multi-tents cloud application that can help to generate classes and dbcontext dynamically for other ASP MVC projects.
How can I do this task from my application to another projects with updating the DB for the new projects.
|
I am trying to design an system which can trigger certain events if an action has not taken place.
e.g Suppose a person needs to fill 3 forms every hour and if he hasnt then a trigger should take place.
The condition will be different for different users, each hour, each day , each week.
One way is to keep checking th... |
I am reading a book (Getting MEAN by Simon Holmes) about MEAN Stack which talks about different architectures that can be used while developing an app in MEAN Stack and I got a little confused with that.
First I'll tell you how I develop applications in MEAN:
My Front-End is a templating engine like EJS or Jade.
I ren... |
I am building a kind of School Management System.
I want to be managing the database records of things like assessment, term/season, academic years. every info must belong to a particular academic year so at anytime the admin can query for info pertaining to a particular year. Assessment too can belong not only to an a... |
I am preparing a Java project and working on MySQL database.
Currently I am stuck at a point where I want size of the resultset before I can actually fetch entries from it.
The fetching of size is such that I will be requiring to fire 6-7 queries.
The button on which the above event will occur is pressed frequently.
T... |
I've been tasked with writing SAD's for our current two projects and there are many more coming, all similar although different in small ways, mostly technical (they all have a similar requirements)
Let's first establish what I think an SAD is for: to provide a software design that satisfies functional and non-functio... |
I have a need to implement REST API which would support a complex filtering, so user would be able to make such requests:
Products?$filter=Price le 3.5 or Price gt 200
The API server will use a layered architecture and it will have a layer, which will abstract database access.
And here is the problem - on one hand I ... |
I'm gradually learning C, and, after my best attempt at piracy, have resigned myself to the fact that I will have to either shell out $60 to ANSI or settle for pirating the penultimate draft hosted on open-std.org, which Stack Overflow's C community recommends doing but ISO claim is a violation of their copyright and h... |
I'm about to start creating a music project website for a friend. It should be pretty simple for now: no dynamic content (tour dates, etc.), and nothing more than a few embedded sample songs or SoundCloud links. I'm not expecting to use anything more than vanilla JavaScript and Bootstrap or Foundation for a responsive ... |
I want to implement login system where same user account can be used to login in different web applications. How can I achieve this ? I want to make a similar architecture to Google and Microsoft Account where different services can be used using the same account.
I will be working in ASP.NET MVC for this.
|
For anyone who is expert in both Javascript and C#:
Can we think of JS closures the way we think about Private and Public Properties in c#?
A closure refers to an inner function (public property) that has access to the parent function's variables (private fields), even when the call to the Parent function is completed... |
At the consultancy I'm from we were encouraged to be "full stack" team players in "self organizing teams". This wasn't just "full stack" in the technical sense (DevOps, automated testing, UX/UI through back-end) but in the business sense too - we coached teams, product owners, gathered high level requirements, led whit... |
I have a webpage and frontend contains pages for Customer, Product and Order part and other parts may be added.
The actual implementation is that every part(modul) has its own Controller and every part(modul) has about 8 pages.
CustomerController
ProductController
OrderController
Other parts
Each page has its methods... |
I'm trying to understand why it's impossible to create a tool that calculates Big-O notation automatically.
I have read about Halting problems, but not related on Big-O notation and I was wondering, or at least have an example in which we're not able to determine a Big-O notation for a given function.
Can anybody give ... |
I'm working in PHP and building a subscription management system from scratch.
I'm trying to figure out the required functions for the Subscription interface (OOP) that need to be implemented by classes that will keep track of subscription type, price, start/end dates of billing cycles, billing day of month, the start ... |
I've looked for the solution of my problem but I've failed in finding a suitable answer.
I've been trying to develop an Android application with heavy asyncronous networking capabilities. The problem is syncronizing async parts at some point.
What I want to do is to create a service, download big amounts of data from s... |
I would like to know if any of you have any experiences and advice you'd like to share about middleware systems?
A little background first: the company I work for is based entirely on a closed environment, legacy ERP system. We are looking to build an ecommerce website, this would however be quite impossible with our c... |
There are a lot of questions on here that deal with the mechanics of authentication and authorization of RESTful APIs but none of them appear to go in to details of how to implement secure services at the application level.
For example let's say that my webapp (I've got Java in mind but this applies to any backend rea... |
I have this business event : "CustomerUpdated" published by my system.
I have many application listening to these events, and they do all king of action : sending email, updating the database, erasing cache etc ... so I can't use a queue here, but I can't use a topic, because If 2 instance of the mailing application ar... |
I have very large sorted array, stored on the disk.
I can random access any element.
I want to make it level-ordered in order to speed up binary search there. The idea is borrowed from:
http://bannalia.blogspot.bg/2015/06/cache-friendly-binary-search.html
If I do this way, I believe I will be able to utilize the disk c... |
Reading the comments to this blog post made me realize I don't know much about some really interesting functional mechanisms between languages like Haskell, OCaml and Standard ML. I'd love a high-level overview not of syntax but of the general concept of what these 3 things are.
|
I have been reading the Foreign Key Mapping section of the Martin Fowler's book(PEAA) and I really liked it but I can't see being a really good approach for problems like mapping friends to a user, since a user can have a lot of friends their approach of always loading all friends can take a lot of memory and time to c... |
I made a console application which makes the mouse click in the middle of the screen every two minutes. It has a while True loop in it which is meant to keep going for relatively long periods of time (until the application is closed). Should this really long loop be put in a thread? It seems to work as it is, but I'm n... |
This question has more to do with the structure and access of different configurations across a number of levels of development. What I mean by 'levels of development' is environments where the different versions of the code and product live. This can be things like a 'Development' branch, 'Quality' branch, or any of... |
We have a lot of in-house libraries that we would like to share between projects inside the company. These are some of the requirements:
library sources are stored in repositories separated from end-projects
end-projects include libraries via NuGet
it must be possible to easily inspect the source code for any given li... |
Let's look at those two scenarios.
First, you have a page that is using $_GET vars for routing and only requests/includes the files based on $_GET requests, like as follows:
index.php
<head>... </head>
<a href="index.php?page=home">
<a href="index.php?page=services">
...
<div id="content">
<?php
if($_GET['page'] == ... |
Let's say this getPhotoAsync method can be invoked a few times a second, and that the responses from the remote server can take anywhere from half a second to thirty seconds, depending on the size of the payload. So there will be several concurrent requests pending. Does .NET keep track "behind the scenes" of which r... |
Background:
I am new to the JNI world, and not an experienced C programmer.
I want to write an JNI for connecting a Java toolkit and a library in C (not just for speed, but for good functionality as well)
I've seen some code using C++ for doing such work. And since managing resources in C requires more explicit manu... |
The situation:
My company delivers an installed Windows Forms application to our clients.
This client application comes bundled with an object binary (let's call it Objects.dll)
Objects.dll contains the object properties, fields, method signatures, etc.
Objects.dll also contains the Service Contracts (interfaces), use... |
I'm writing a Websocket implementation in Java, and I've set it up so that it basically just wraps an InputStream and OutputStream, and has public methods for both sending and receiving. While input and output are related, they're also complete opposites, and share very little functionality. Would it make more sense ... |
I am writing automated functional tests for my application. To interact with the application, I use the SQL database to retrieve data and validate data.
The main challenge that I am facing is handling the test data for my tests. I need to access the database to be able to retrieve test data, which may get updated every... |
The PHP website tells you which versions each function is supported in and often the version a function was first introduced in, but it doesn't do the same for older language features. When was type casting first introduced? i.e. (int)$var or (string)$var.
|
I am in the planning phase of a project that will use a 3rd party service that supports both REST and SOAP. The SOAP API is more mature and thus supports more operations.
I'd love to depend only on the REST API, but specific use cases have forced the use of the SOAP API. So really there are two options:
Depend ONLY on... |
I recently came across the term "runtime inheritance" when reading this Wikipedia article. I tried to search for it and came across this article that tries to explain the difference between runtime and compile time inheritance, in which they explain runtime inheritance as the "ability to construct the parent/child hi... |
I've been developing an application which will support many users. The thing is I'm unable to figure out, how to authenticate the client/user.
I'm building an app like http://quickblox.com/ where I'll give credentials to my users and they will use those to build N applications in which they can't put their username and... |
First of all, I'm sorry if the title is a bit confusing.
I was reading this question (Is it a bad practice to have a "record status" column in a database table?), and like the idea of using record status for some tables. So intead of deleting records from the table, I would set the record status to "deleted". My questi... |
I've been reading a number of articles on "what is an API" but they're either too high level or two low level for me... I can't seem to quite grasp the entire concept, or have that sneaking feeling that i'm "missing something big"
I understand an API exposes functions which help to "talk" to a more complex backend... i... |
We're developing a large application, consisting of many small packages. Each package has its own set of resource files for localization.
What's the best approach to organizing and naming the localization strings?
Here are my thoughts so far:
Handling duplicates
The same text (say, "Zip code") may occur multiple times ... |
A couple of months ago I went to a Bruce Springsteen concert. I hadn't heard much of his songs before that, but really liked the concert and bought the live recording of it afterwards (which he sells via live.brucespringsteen.net). A bit later I even bought another live recording of a different concert and after listen... |
The problem
I have a number of clients connected via websocket to nodes of my web application through a load balancer. What I need is to deliver notifications on a per-user basis.
My idea
My idea is to have each web application node connected to a messaging system (RabbitMQ, Apache Kafka), and have each node creates a ... |
I'm working on a microservices architecture which contains a couple a REST API as a services and a SPA as an interface. In addition, there are an "special" (is not speacial at all, it just special because without auth you can't use the rest of APIs) API which performs authentication and manage Users info. The rest of s... |
I'm currently working on a project on an Arduino that should run for multiple years without interruption. To do this, I've attempted to avoid constructors, deconstructors and general dynamic variable allocation all together, as to avoid memory leaks and other ways of running out of memory.
This project has a couple of ... |
I am implementing producer-consumer where items to be consumed are of 1000 types type-0, type-1, ..., type-999.
Producer inserts item of type-i in queue. Consumer uses that to update state machine for type-i(one state machine per type-i) based on item(type-i)removed from queue.There are multiple consumers that are read... |
Suppose there is an entity class A like so:
class A {
public Id { get; private set; }
}
There is also another entity class B which holds a reference to A:
class B {
public Id { get; private set; }
public aId { get; private set; }
}
Do guidelines on setting the visibility of ID references to other entities... |
This is an issue that has somewhat been raised by the left-pad incident with NPM but I'm also interested in it from an internal business perspective.
For example imagine an organisation with 3 teams, A, B and C. Team A build a component for their site, it fits their needs perfectly because they built it themselves. Tea... |
I have implemented a tracking pixel that is simply an img tag that another party puts on their website. This works by making the src refer to our endpoint with query params set with extra information. The GET hits the server and we collect the QPs. Right now I have just regular key-value query params that refer to user... |
I recently ran across some code during a review that baffled me a bit. The dev was using structs to organize code within a larger file. I personally don't like the practice but wanted to hear others thoughts.
Assumptions:
This was an ASP.MVC app with several app specific areas.
The Settings.CS file has a lot of diff... |
We need to create an application that must diff relationships between entities.
As an example, let's say we're creating an application to model instances of a disease amongst pets, and we periodically collect data from multiple XML sources.
We have some model that represents pets and one to represent diseases. We are... |
Let's say I have a mobile app, android/iOS and a java Spring back end. Given the mobile connectivity, the number of network round trips must be limited, ideally, 1 or less per screen.
Now, let's say I want to add/rewrite some messaging capabilities when 2+ app users can send each other messages.
There are 2 tables / r... |
Many programs will supply one or more of the following as file encoding formats: UTF-8, UTF-16, UTF-32 and simply Unicode. How do I know what Unicode Transformation Format Unicode is referring to? I'm assuming it correlates to to one of the 8/16/32 formats but I have not been able to find that on the Unicode website.
|
Starting with Java 8, default methods were introduced into interfaces. Effectively, this means that not all methods in an interface are abstract.
Starting with Java 9 (maybe), private methods will be allowed. This means that not all methods in an interface are public abstract.
The question "Should methods in a Java int... |
I'm updating a few asp.net applications which use Windows Authentication and do role-based security via an xml file, then store this info in session variables (if the session times out, the program just recreates the session variable).
This approach works fine, but seems unnecessarily convoluted in the way it's been im... |
let's imagine we have an object User with a property of type Profile that can be accessed by the method getProfile and since we don't need the User's profile for every operation we decided to lazy load the User's Profile. But now, what happens when we decide to update the User object in the database using it's DataMapp... |
I've been reading a lot of hate spewed on ORMs, and am genuinely interested in finding out if there is a better way of doing things.
Unfortunately, while there are tons of books, blog posts, and articles about modeling and building apps using various ORMs, none exist for the non-ORM approach.
Are there any mid/large ... |
Martin Fowler talks about the Domain Model where the Business Logic Layer contains classes that contain state and behaviour. As far as I am concerned this means:
1) Controller calls a class in the Business Layer, which returns a business object e.g. Car. The business object is then casted to a ViewModel.
2) Business ... |
My workplace has several groups that have little to no software development process. They use source control, and lightly use an issue tracking system, depending on the project. Teams are not regularly creating unit tests and running them in a CI server and not performing code reviews. This varies from project to proje... |
I have a generic binary tree which is used for calculating combinations of things - i.e. a powerset in set parlance.
Most of the time it is used for calculating subsets of size N.
As a real world example, say we have 10 players in a basketball squad and we want to calculate every starting 5.
In my particular problem do... |
I want to avoid cyclic dependency in this schema:
DbRepository needs IUserDbEntityFactory to create User entity which needs IUserPublishedInfoInitializer to create UserPublishedInfo on request. And UserPublishedInfoInitializer itself needs IDbRepository to check whether the user is currently present in cache and activ... |
So I know that TTL is not available for counters because of design reasons and I've read https://issues.apache.org/jira/browse/CASSANDRA-2103 as well as some other SO questions regarding this but there seems to be no clear answer(unless I am missing something which is entirely plausible):
How do we elegantly handle the... |
I have frequent "access" classes that implement interfaces / abstract classes.
These classes all have different classes/ dlls to execute the implemented method.
What naming convent is commonly used to mark these Interface / Access classes for a package/namespace?
as example:
namespace Kitchen
{
interface IApplian... |
So I am new to agile, but not test-driven development. My professors in college were all about the idea of tests then code then tests. I am not sure I understand why. From my perspective it is a lot of upfront cost that will most likely be changed as your code evolves.
This is how I imagine TDD and why it confuses me. ... |
I have a class that needs to return a set of values e.g
public abstract class AbstractRule {
public abstract String getName();
//Property is an example here.
public abstract Set<Property> getApplicability();
}
public class ConstrainedRule extends AbstractRule {
@Override
public String getName() {
re... |
I am having a problem developing an object-orientated architecture to manage a network of sensors and controls. Currently, I am writing in Python, but this is more of a conceptual question.
I have an Arduino that is wired to a number of sensors. Several times a second, the Arduino sends data to a Raspberry Pi with info... |
If I have a typical "value object" (transport object) e g a Java class with only instance variables and getters and setters, then I said that I want to declare that outside of Java, like a Javabean in XML and let the container generate the class. What is the advantage? the other guy asked. I can think of several advant... |
Lets say I have multiple websocket servers that maintain many connections to clients to send updates. These websocket servers will be pulling said updates from a rabbitmq broker, and broadcasting them to all relevant clients who happen to be on a page that needs an update.
My question is how can all clients who are on ... |
In Flask 0.11 a flask CLI was introduced. Both the docs and the changelog state this is recommended.
Development Server docs:
Starting with Flask 0.11 there are multiple built-in ways to run a development server. The best one is the flask command line utility but you can also continue using the Flask.run() method.
Com... |
To begin, I have been assigned the task of automating a significantly outdated manufacturing tool. The tool and it's API and software are virtually unsupported now. I have a collection of documents describing what amounts to an operator's manual of the software, and an introductory level of the API. I have gotten this ... |
I have been practicing implementing some classic dynamic programming algorithms and was wondering if my implementation of the longest common subsequence search has a significant code smell.
In python, my version of the code is as follows:
def calculate_LCS_matrix(S, T):
'''
Computes the longest common subsequen... |
I have a program already internationalized with gettext module, however it bugs me for days whether should I centralize the strings (make them variables, so they can be referred by the main program or the tests suite) inside one module or not. If they are not centralized, then every time I change the strings, I must ma... |
I'm creating an API to publish and consume message from RabbitMQ. In my current design, the publisher is going to make a POST request. My API will route the POST request to the exchange. In this way, the publisher doesn't have to know the server address, exchange name etc. while publishing.
Now the consumer part is whe... |
Let's say you have the following application: users can be part of different organizations. Different users can create tasks and projects within an organization. In a microservice architecture, there are three separate services that manage tasks, projects and organizations respectively.
Now,let's say we want to send a ... |
I want to do some initialization in child class constructor and pass result to super().
But Java doesn't allow any processing in child class constructor before super() call.
Whats a good way to solve this problem?
|
I know base64 encoded binary data is equal to 1.37 times the original data according to Wikipedia.
What if you decode that string with php function base64_decode($encoded_string); and then make image out of that imagecreatefromstring($data); like so:
//Decode
$data = base64_decode($encoded_string);
//Create image
$i... |
Every time I read Merge branch 'origin/master' into master, or Oops, forgot to commit changes, in a Git history, I die a little inside.
Of course I know why it is bad to clutter your history with these types of commits. Mainly because I have worked with both horrible and clean histories, and clean histories are simply ... |
We are currently using a off the shelf ERP system. It lacks in several areas, one of those being quoting. So, I have been tasked with creating a quoting application that will need to use (in read only mode) data from the ERP system. The ERP database is stored on our local server (Windows Server 2012) in SQL Server 2014... |
While studying for my exam for software development I noticed that I couldn't give an example of cyclomatic coverage (the coverage reached through base path testing) that would satisfy the requirements for branch coverage, nor vice versa. And when searching online, I could not find examples where both types are discuss... |
Say I have different employees of type Employee stored in a list inside a class SubCase.
public class SubCase{
protected ArrayList<Employee> employees;
...
}
SubCase represents a part of a project where the employees work on.
They do have a fixed specific role in the project, but that role is inside
another cl... |
On page 85 of Leo Brodie's book, Thinking Forth, he describes a component which he calls the "Interface Component." He describes its differences from, and benefits over a standard interface as follows:
When it comes to data interfaces between modules, traditional wisdom says only that “interfaces should be carefully d... |
The users are on a Windows Form where they fill out a fax cover sheet and hit Send. The remote fax service takes anywhere from two seconds to two minutes to return a result (long timeout). By that time, the users have moved on to other things, having closed the form and opened another.
What is the proper way to invok... |
I have an app that needs to attach objects of different types between them. For example: I have to add Lead type object to a Contact type object , a Contact to an Event and so on.
Such relationship looks to me to be an undirected graph (If Car A is attached to Contact B has same meaning with Contact B is considered t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.