instruction stringlengths 34 36.1k |
|---|
We are using Apache Camel with ActiveMQ in a microservice architecture in a growing system of integration solutions. I was wondering how each service should react when they are unable to connect to the message queue, or if this should be handled at all.
As the system is right now each service logs an exception for each... |
I am wondering how compiler (or preprocessor) include headers. I have three files. First is header.h, second first.cpp <- and there is #include <iostream>, third <- it contains #include <iostream> too.
header.h:
#ifndef HEADER_H_
#define HEADER_H_
struct Student
{
std::string imie;
int ocena;
};
void foo();... |
I have seen several different diagrams in several different views.
Is is possible to use the state machine diagram in the development view in 4+1 Architecture?
|
I'm looking for advice on how to handle constraints on the input of a method. I have a method that only works if the input argument(s) fulfill certain constraints. If the method is called on input that does not fulfill the constraint(s), the method does something harmful.
The concrete problem is this. I have a class In... |
The title may have been a little vague... I am working on a piece of software that is designed to perform one task. I would like this task to work in parallel, allowing for multiple asynchronous threads to perform the same task.
I am not concerned about the order of which these tasks get completed but I am concerned a... |
I've been working on some embedded code that handles a Bluetooth Low Energy (BLE) radio. BLE has 40 channels, numbered 0 through 39. One function for the radio driver takes in the channel and sets the appropriate register with the correct setting.
The obvious function prototype was SetChannel(uint8_t channel);. Howe... |
I have a few services that sign some data with an asymmetric cryptography algorithm (like RSA).
I need to spread some secret (private) keys between all instances of the service.
I've found a few ways to do that:
Share keys as configuration (looks insecure when I need to spread private keys)
Embed keys into apps/images... |
Searching for simplest solution where a User can order an item.
If someone purchases an item he will have one address. Which then is the invoice and shipping address. But he could add another address if the invoice address is different from the shipping address.
I wrote some code with two Classes Purchase and Address. ... |
Here's the problem I'm trying to solve:
There's a rather large API I'm trying to write a wrapper class around. The simplest approach would be to make one class with a method representing each possible API call. This gets unwieldly though as the API is very large.
My first thought is to break up each API section into a ... |
My use case requires me to implement multiple validators which implement the interface:
public interface Validator {
boolean validate(Object o);
}
Based on the business group of the Object o, a different combination of validators need to be applied.
For each business group, I plan to maintain a list of Validators.
Th... |
This is intended to be a general language-agnostic question. It is written around a weird example simply because I could not find a better way to ask. Also, the "pseudocodes" provided look like a mixture of Java and JavaScript only because those are the languages I'm most familiarized with, but hopefully they will be e... |
I'm trying to implement the Service Locator pattern. In the below diagram is my references between projects (.net projects), each box represents a project.
The arrows indicate the dependencies.
I am asking if this is a correct implementation of this pattern or is there a better way?
|
Is code that runs fast but written with a bad and hard to understand syntax, good code?
Is code that runs slowly but written with a good and easy to understand syntax, good code?
|
One of my customers has a licensed software for business management and uses a SQL Server as database server (The database is open and I can run queries). They have a need that the current software does not satisfies and I would like to create a separate program to fill that need, using the same database that the progr... |
Let me start with the fact that I'm prepared for this question to be closed as opinion based, but I am going to attempt to phrase it in such a way to keep it less based on opinions.
The Short Version
Are there any practical or best practice resons why configuration settings should not be stored in a Resource (resx) fil... |
(Not sure if there was a relevant stack exchange site for this, I saw a few ones related to open source in companies and figured this was similar, but different enough to warrant a new question).
We have a client that we're about to pick up for some work. We've gone off and done the exploration for their product and co... |
I don't know much about how computers work internally, so I also don't know much about multithreading, and when it takes place. I know it is important in databases or web applications and such, where a lot of different machines try to access or modify the same resources, but what about "classic" code, like calculations... |
While working on a small class called FractionNumber I found asking myself if I should implement an interface that I am already implementing. Sounds stupid, I know, but bear with me.
My class FractionNumber extends Number; Number implements Serializable. And I am unsure if FractionNumber should explicitly implement Ser... |
I'm interested in which approach to prefer. Consider some code which retrieves a translation for some text. It has to respect these constraints:
Return translation only if the text will be used on a UI. If it's used some where else (debug log), return the normalized version of the text.
Text normalization is costly (c... |
I have the following constructors:
public Class1()
{
this.Variable = new Variable();
}
public Class1(Variable vari)
{
this.Variable = vari;
}
Which can be rewritten as:
public Class1()
: this(new Variable())
{
}
public Class1(Variable vari)
{
this.Variable = vari;
}
Is there any benefit from writin... |
Could you tell me your opinion that which layer is the right one to place domain event handlers in DDD? For example, I have application service to add a new contract and I'd like to send an email notification to the contact person, when the contract has added, so is that email sender (which handle ContractAdded event) ... |
Imagine this simple application use case, say, for fetching data from outisde of the app. These steps represent the "depth" of the layers, from top to bottom.
UI touch event
ViewModel handles said event
Some service / manager reacts accordingly
The correct request is built and executed
The object is fetched and return... |
In FP vs. OO, from the trenches, Michael Fogus says:
Whenever I write some code to deal with data about people then functional programming seems to work best.
Whenever I write some code to simulate people then object-oriented programming seems to work best.
My question is: In a pure FP language, how do you "simulat... |
We're in a project that has quite a lot of code and while in general we have a good test coverage and things work out pretty well, I noticed that our tests grew more and more complex over time up to a point where the tests are more complex than the code they test.
As a bit of background we're using Spock for testing an... |
Current situation
I have a situation that I find frustrating: the integration tests in my project (a RESTful API) contain both API HTTP calls and SQL queries. Whenever an API call is made that writes something to the DB (a POST, PUT or PATCH request), a hand-written SQL query is launched to compare the API response wit... |
Let's say we have an app deployed to Azure. App has external files not bundled with it, files which are required for app to operate. They are seperate but are essentially part of the software. Normally without a cloud service, we put these files on a disk path and tell the path to app using an environment variable.
Sin... |
We're facing the issue that we often have classes with lots of properties. But we don't need them for most API calls. So we end up having multiple versions for basically the same business object.
E.g.
public class SmallCountry
{
string Code { get; set; }
string Name { get; set; }
}
and
public class Country
{... |
I recently had engaged in a security discussion with my companies cyber security risk lead, discussing security controls and standards they would be holding the project to. The expectation of the Risk Lead was that these controls would trace back to architecturally driven Non-Functional Requirements defined for the pr... |
I'm developing a producer/consumer system with three deques (each for one priority level, from max to min); first deque has major priority, so it must be read before others: once empty, others deques will be served.
My code is something like this:
// this is the class associated to a deque
class DequeEntity {
publi... |
In C, we like to use #define or const globals to avoid hard-coding values and strings.
How can we avoid hard-coding strings that need to be formatted? Consider, for instance, building a filepath to an i2c bus in linux:
snprintf (dev, size, "/dev/i2c-%u", bus_no)
I don't like the idea of adding a #define I2C_BUS_FMT "/... |
I'm trying to figure out how to do something, and I can't quite seem to get it to work. Let me describe the situation:
Using a hosts file, we redirect the resources (CSS/JS/etc) of a website, let's say blah.website.com, to our local machine 127.0.0.1.
We then can do some development on any JS/CSS/etc on our local machi... |
I'm receiving flat files with the stock price and number of held shares for an account. One file contains the price and shares to 6 decimal places. The other file contains the price and shares to 12 decimal places.
The system needs to persist and later display these values (preferably to the number of decimal places re... |
I work on a large project (C++, C#) in areas that can have a lot of churn. I'm in the habit of getting latest sources multiple times a day. Every now and then this results in an awful back-merge. Usually it results in either having to fix little things, which doesn't take too long, or if I'm lucky they're no conflicts ... |
I would like to ask a question about XML and S-expressions(-ish) notation. S-expressions are pretty old; they are also really simple. We could consider two forms that are equal in meaning, different in syntax:
(xml code taken from Polish wikipedia)
<?xml version="1.0" encoding="UTF-8"?>
<ksiazka-telefoniczna kategoria=... |
Since high Cyclomatic Complexity is harmful, and it would be beneficial to lower it down by creating sub functions. However, it might lead to a long calling queue and lead to some super nested function that would also let the other programmers feel hard to read.
What would be the beneficial solution or where should we... |
Here's a pretty problem. I recently had a memory leak in a java program where one huge object was not collected, even though it "should" have been collected when the whole complex graph of objects that contained it became
garbage. (Concretely, the large object is an image, and the complex graph is a window and all ... |
I already have experience working with MVC based web apps and started reading recently about REST.
But went into confusion when re-thinking about how existing web app not using any kind of framework/pattern could be refactored to use these two.
So the application (entirely written in PHP) already has a web UI but it's ... |
I have a couple of questions regarding MVVM view models. I have 3 view models in my scenario, which I have put together a shorter sample below. I was looking for a nice solution for 3 views working in conjunction with one another in a small part of a large application. There are 3 classes in play here:
ParentViewMod... |
How to index a massive, randomly selected, uncontrollable, constantantly changing dataset?
Imagine you want to index all of the snow particles in a giant snowglobe that is constantly being shaken. Each snow particle represents a piece of lengthy text (say a book) that needs to be indexed, however, the particles are con... |
Here are some requirements for a queue:
Every few days add ~100k tasks with various priorities
Workers will pull tasks at typically less than 10 / second
Tasks need to be completed by ~2 unique workers (for error checking), and then depending on outcome potentially by an additional worker
Persistent storage of tasks
... |
I find myself often in the situation where I want to mock a non-copyable object, for example a DbHandle handle.
I was going back and forth looking at different design choices, and I settled on the following design:
In my production code, there is no need for a client of the Repository to know the DbHandle object, but f... |
I have been having a huge and heated argument with someone on a slack group - the debate is this :
My argument
Portable code is that which compiles with various compilers and runs exactly the same on various architectures without modification.
If your code depends on the sizeof(T) of an integral type, in order to keep... |
I find myself writing small test cases and applications to post bug cases, answer questions in some forums, make feature showcases for clients, etc. and for that I created a TestCases project inside my workspace.
Now, I want to keep track of all these small and unrelated applications in case I need to go back to them, ... |
I have an InputStream and an OutputStream to a server. I can send a bunch of JSON requests over the wire and get a stream of responses back from this server. From this, I'd like to build a wrapper that provides getters like getFoo() that create a request, send it, and get a response.
I'm not sure how to handle this con... |
In my program I need to create xls or xlsx files and the file type is chosen using an option in a property file.
This is how we can switch xls and xlsx file type using java code
For xls:
Workbook workbook = new XSSFWorkbook();
For xlsx:
Workbook workbook = new HSSFWorkbook();
And what I do is, for creating every fi... |
I would like to define a shared pointer whose operator== compares the pointed to values instead of the pointers, something like this:
template <typename T>
struct deref_shared_ptr: std::shared_ptr<T> {
bool operator==(const deref_shared_ptr rhs) const {
return (**this == *rhs);
}
};
This type has two ... |
We have an Android app. The Android App uses Volley (https://developer.android.com/training/volley/index.html) to transmit network data.
The point though is not about Volley, is about the pattern Volley uses to execute a remote call. Example:
final TextView mTextView = (TextView) findViewById(R.id.text);
...
// Instan... |
As an example, lets say I am working on creating an eCommerce solution. Part of the functionality of this solution will be to ensure that the final price of an order is correct. Lets say the final price will include the grand total of all products, the shipping costs and any tax.
Lets say I have two public methods:
/**... |
Say hi to the method:
public void hello(Data data);
This method uses some data and performs… whatever. Now, written like this, the method is very specific – i.e. the argument is very specific. But now, in real life, this Data (for example) may come from e.g. class called DataProvider:
public class DataProvider() {
... |
There are a few languages, that developed shorthand notations, notably e.g. ECMAScript can be generated from coffeescript:
CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the goo... |
I'm an amateur java developer and I have been working on this web application in my current company. The application is made in the Spring MVC framework. Hibernate is used as the ORM tool while the database is the DB2. Maven is used as the build and deployment tool for this application. The presentation layer and the s... |
Is it generally considered good practise for a class name to reflect the namespace name it exists under, or should the namespace name implicitly be considered part of the class name?
For example, suppose I have a collection of classes which all act to filter a class Foo:
class FooFilter
{
public virtual bool operat... |
Background
I created a mod for minecraft using Minecraft Forge which uses "other" mod. I have the permission from author of the "other" mod to use and distribute his code with my code.
Right now, my LICENSE.md file looks something like that:
# License
This project uses portion of code from ["other" mod](https://githu... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.