instruction stringlengths 34 36.1k |
|---|
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... |
I am working on an application that is currently localized in six languages. Localization engineers occasionally test to make sure that all of their strings are contextually appropriate and appear correctly in the application.
Something that's taking ever more time is their testing of error messages that are unlikely t... |
When I'm creating a docstring, sometimes I want to refer to a value, for instance:
def try_download(data, path):
"""Tries to download ATTEMPTS times, catching socket errors."""
Where ATTEMPTS is just a constant int defined at the start of the file. But would it be better to write it so that it's generating a strin... |
After researching modern web servers, I feel that I am pretty ignorant when it comes to server design and concurrent task management by both the operating system and the server. I understand some important basic functionality such as thread/process blocking and that the operating system will context switch from a block... |
I have to provide a Python CLI-based program to one of my clients. I will give him both the compiled version (using py2exe or something simillar) of the application and the source code.
The application structure is the following:
a cfg folder which holds some configuration files (the main .py parses these configs usin... |
I am writing a website, and I've come up with quite a few scripts taking up a lot of space and ruining the aesthetics of my code. I came up with the idea of creating one script that fills a div below it with scripts, but that sounds like it could present some sort of problem. Is this an okay thing to do, or is this bad... |
As part of my continuous integration server, I am running a bunch of performance profiling. If the performance profiling tests don't crash and pass a threshold then it declares them successful. I then manually take the log files, convert them to JSON, plot them in a web browser, then print the page as a PDF. This provi... |
Today I was reading a lot of articles complaining about Java Generics or C++ Templates. Now, my question is: How can someone implement a collection data structure like Stack without using them?
|
I'm using a some C++ Facade classes like this:
Suppose that there is package named "SubSystem" with a lot of classes inside, like in the picture above.
I cannot name the package of the facade class "SubSystem", because there is already a namespace with the same name.
What is a good standard or practice to name Faca... |
Background
I have been programming mainly in Python in the past years and mostly on my own projects. I have developed some of my own small stilistic conventions like leaving 4 numbers of empty lines between classes and 1-2 lines between methods, etc.
Currently I moved to a company with 8 developers developing mainly in... |
Since every time a web browser requests a page, we are almost certain that there are .css and .js files to be sent as well. Why do we wait for the browser to parse the DOM and discover those files before issuing a request for the CSS and JS files? The server has the HTML files and knows all the links to other resources... |
I'm using SignalR with StackExchange Redis. What I gather from the
basic usage doc is the way to implement this is using a singleton. I've never used this patter before. My class looks like this:
public class RedisInstance
{
public static readonly RedisInstance Instance = new RedisInstance();
public static Con... |
I'm looking at BDD test tools, like SpecFlow, MSpec or NSpec, and I can't see from the examples what advantages they offer over simple unit test tools like MSTest.
As far as I can see, when creating a BDD test I would write a test method similar to a normal unit test that I would write in MSTest. The difference I can ... |
I'm sure that there is a similar question like this already in existence, but I didn't see one that matched closely enough, so here goes...
We use a third party company to host our site and do most of the code updates and the code is maintained in a Git repository. However, we haven't been too happy with the job they'... |
I'm trying to understand how licensing generally works in software development, but this seems to be a rather broad topic that won't have a single straight-forward answer. Hopefully this example is specific enough to illuminate where my confusion on the subject may lie.
The GCC compiler is licensed under GNU General P... |
I have an application where I'd like to add ways for external modules/components to hook during the processes and data-flow and perform actions/modify data.
For the first requirement—performing actions—I assume the best pattern would be to emit events and have other modules/components subscribe to those events and perf... |
I have a kind of minimal language (sort of parser for CISCO-like CLI) that have parser described below. The parser should be serializable to JSON, that's why not Parsec or Attoparsec.
I need a sort of completion tree for those commands, i.e for each prefix there are should be all possible sub-commands. Cp type describ... |
For example, I have something need to do depend on user input:
test.cpp
#include <iostream>
#include <fstream>
int main(){
std::string input;
std::cin >> std::noskipws >> input;
if(input=="A"){
std::cout << "A selected" << std::endl;
}else if(input=="B"){
std::ofstream myfile;
m... |
After long 3 months of debate and research in choosing between React (with Redux) and Angular 2, front-end team in my company has concluded to go with Angular 2 (given that it is more suited for our problem).
We're into enterprise app business, which is currently comprises of many different front-end technologies (whil... |
What were the motivations for java to use the @Override annotation, instead of creating a new override modifier?
@Override
public String toString() {
return "";
}
vs.
public override String toString() {
return "";
}
|
In the process of developing a realtime Single Page Application, I have progressively adopted websockets to empower my users with up to date data. During this phase, I was sad to notice that I was destroying way too much of my app structure, and I failed to find a solution to this phenomenon.
Before getting into specif... |
I've tried looking on google but can't get the answer I want to this. Is there a book or article or a video where various commonalities of different popular high level languages like Python, Java, C++ etc. are contrasted with each other ?
By commonalities I mean:
If you learned something in one language is it true fo... |
In Scala is it acceptable to have id variables written as _id instead of the regular camel case notation?
In the code most variables respect the camel case notation. However for variables referring to id, I like to append _id at the end instead of Id. To me it makes it clearer and also different from other variables. E... |
We're in the process of shifting our datasource from Mongo to MS SQL Server. Our challenge is that we have two testers who are green. As a team, we're trying to work through the most sensible test approach.
We have two datasources (one MS SQL, one Oracle) that are integrated via flat file feed to a MongoDB, which is us... |
We have a codebase at work that:
Ingests (low) thousands of small files. Each of these input files contains about 50k “micro-items”
These “micro-items” are then clustered together to find “macro-items”
The “macro-items” become the input to a variety of other important business computations and analyses. These macro-... |
Imagine a domotic webapp, to command a heater.
You could setup N plans, for a plan I mean a similar table:
+----+---------+--------------------+
| id | name | target_temperature |
+----+---------+--------------------+
| 1 | confort | 19 |
+----+---------+--------------------+
| 2 | hot | 22 ... |
I am trying to build a RESTful search api (POST request) that can return different types of resources (e.g A, B, C, etc). I have defined a data model for each of the resource type. There are some propeties that are common across all the types and there are some that are specific to some types.
"A" : {
"a_property1... |
I'm java developer. We developed good back end application. Customer asked UI part for it, but UI part development in our program needs each time restart the server (to refresh WEB static files). Is it possible develop UI without restarting back end with ability update WEB UI (js) libraries and files (css\js\html)? It ... |
Let's talk about three projects. I have a Cinema project, a Cinema.Engine project, and a Cinema.Client1 project.
In the Cinema project, I have an interface ICinema and a factory class CinemaFactory.
In the Cinema.Engine project, I have a class that implements ICinema... we'll call it CinemaEngine : ICinema. This projec... |
I understand the recursion and find it useful and intuitive while solving problems on trees but for many other problems recursion never fails me to leave puzzled. Recently I was solving the following problem:
Write a recursive function that counts how many different ways you can
make change for an amount, given a li... |
We design RESTful API for our system.
90% of resources have dependency from other resource called as "user", for example. "User" also can be used as an independent resource.
We found two ways how to reflect it in API URIs.
First-level resource.
Pros: transparently for clients what resources depends and what doesn't.
Co... |
In the following DOM event handling example (using jQuery):
$('#shopping-cart').on('click', function(event){...});
could I not call the shopping-cart DOM element the observable, and the function the observer? There is no "general" click event being hooked to, but a click event specific to the shopping-cart object itse... |
If the goal is to be able to swap out backend DB providers (EF, OleDB, ODBC, etc) then I'm wondering where the different DB CRUD changes? Currently I have an interface (IGenericContext) that has Add/Update/Delete/Select functions. I then make an ADOContext which implements this and inside these functions is where I do ... |
Maybe this question is not going to mean a lot if C and C++ are put into context, but I kept wondering why later languages such as Java and specially C# haven't been made simpler in regards of their syntax?
That's why I was wondering if there's some important reason for this, because for me it looks like these language... |
I'm trying to implement a branching model that is similar to git-flow, but simpler (no release or hotfix branches).
The idea is to have the master branch always up to date with the latest tagged release, a develop branch that runs parallel to it, and feature branches to implement longer (more than 1-2 commits) features... |
Lets imagine I have points in a 2D plane that I want to connect in a directionless graph. However, I don't want these connections to overlap. The only data I'm given is where a connection exists, and what direction is goes. For example, one of my (very simple) data sets might look like this
1 > 2
2 > 3
4 > 3, 5
5 > 3
... |
What is the meaning of the term "value" in statements such as:
A Haskell function is a first-class value
Every value has a type
In both statements, I am left wondering what a value is and have a
nagging conceptual gap when reading Haskell programming texts.
So, bottom-line: is there a definition of a Haskell value?
... |
Say you're designing a C API, and one of your big concerns is ABI stability (it's going to be deployed as a shared library, or whatever).
You have a function exported
int foo_bar(int a, int b, int* c);
And you feel that someday, you may need to add one or more parameters to this function, but you don't know which on... |
In assembly language, is there a difference between a function and a procedure?
I use them interchangeably but I'm not sure this is appropriate a professional environment.
|
I try to find out not according to semantics but weight. I mean, should I take care when set a long name to a variable?
|
I am building a relational database-backed Line-of-Business application for my consulting client (or rather, I'm rewriting it - long story). This software product is a SaaS service for a niche industry. In this case, as far as we're concerned, it's a system which manages reports for woodchucks - it generates woodchucki... |
We are developing a mobile app/apps which has two parties involved, creators and consumers. Creators first register themselves, get verified and then create the events. Consumers browse for desired events and if found interesting, register for the event.
What will be the best practice to achieve the above scenario. Two... |
I have a question related to modeling similar Class of objects in a DB:
Suppose in the database i have a list of clients which can be in different categories - eg. Client --> can be in Category1 ... Category10
now, Client in Category1 has some behavior that is specific only to that kind of client, but Clients in Catego... |
Usually the Repository pattern looks like :
What would be the best practice to make the repository handle more gateways (for Cache Redis, FTS/filtering Elasticsearch, Db Mysql etc.)
My ideas so far are to make a Repository array class that will loop through each repository when calling a method.
Also where would I im... |
In Python specifically (I don't know if this generalizes) is there a "best" way to return multiple items from a function?
def func1():
return a,b #equivalent to (a,b)
def func2():
return[a,b]
def func3():
return{"valueA":a,"valueB":b}
The first is what I see most generally, but I feel like the last one ... |
Most places where I have seen prototypes defined for a constructor it was done like so.
var Person = function(){
this.stuff = stuff;
}
Person.prototype.doSomething = function(){console.log("something")}
var john = new Person();
But to me, coming from Java it seems more intuitive to define it directly inside the co... |
I don't getFoo/setFoo naming convention, that is so spread that it become a standard. Instead, I am using more and more just: foo() and foo(value) for reading and setting value. I also see this trend in some libraries like VertX.
While this is fine when I work on my projects; should I do the same for the 3rd party libr... |
After asking it in stackoverflow : polymorphism-and-tree-structre
I came to a conclusion that I am not being specific and my question is not about any specific technology so I will try to rewrite it.
in the stackoverflow question I wrote about a grandparent/parent/child classes
in order for my question to be concise, t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.