instruction stringlengths 34 36.1k |
|---|
I have to implement data synchronization between two big databases which have completely different structures. Basically, I need to grap some data about products in different tables in the first database and re-arrange them for other tables in the second database.
Creating my products on the first time is not very com... |
In my application I keep receiving crash reports where the root cause is an OutOfMemoryError.
The app is quite image heavy (I use Picasso for all the image loading) and also has a WebView component that is used to display all kinds of content from text and images to embedded videos and animated GIFs.
I used Square's Le... |
In Ada programming, What is a best practice way to create a 2D array of a size that is specified by the user?
I'm teaching myself Ada for work (after many years of C programming), and I'm having difficulty understanding how to create an array of a size that is only known at runtime...
My simple program needs to do the ... |
I'm designing a REST API for a project where users are always on one of several "plans" - each plan defines some resource limits, such as the max number of users an account may have or the max number of data they may upload. Once one of these limits is reached, users can upgrade their plans (essentially pay up) to get ... |
I came across the interesting topic about final method parameters and that they essentially don't provide much advantages. I wondered if it would be sensible to mark only those method parameters as final, when it is advisable to pass an immutable object.
I don't know if this might mislead some people when they're readi... |
What is the best way to design a class to see if an update occurs on a property?
I have a whole bunch of classes, and current am going through a re-design of the python package I created. Essentially what I do is take the values of a REST service description, and put them into a class along with the functions that c... |
I have made a few libraries that different projects use.
When I make changes to projects, I sometimes make changes to the codebase, and I want to be able to manage this all through sourcetree.
So, for example, I have a project with global.js and project1.js.
I also have another project with global.js and project2.js.
I... |
When developing with Symfony2 PHP framework I often see reccomendations to decouple code but most of the time that is accompanied by a 'if you want to release as a third party bundle'.
Which begs the questions, if my software is proprietary should I even bother to decouple it for e.g., using interfaces and models (abst... |
I looking at the best way to handle exceptions, the answer to this question may be to handle the exception in a different place or to not handle to exception at all but to control the flow of the code. Please let me know if this is the case.
Lets say we have a class NetworkConnection. This class has a Connect method th... |
When reviewing code, I prefer to read if statements that explicitly demonstrate that a fork in code execution may occur:
if ( isFoo(baz) ) {
runBar();
}
When scanning hundreds of lines of the nonindented version, it is not obvious that a conditional may or may not occur:
boom += 1;
baz = getBaz(boom);
if (isFoo(ba... |
In a enterprise distributed system, a user of a web portal can sign into one site, be redirected to a federation provider. Once they log in with, for example, a facebook account, that user is federated (single-sign-on) with each service that exists in the enterprise that trusts the same federation provider for authenti... |
I'm attempting to get into the habit of writing unit tests regularly with my code, but I've read that first it's important to write testable code.
This question touches on SOLID principles of writing testable code, but I want to know if those design principles are beneficial (or at least not harmful) without planning o... |
I need to find the font size of a text that fits in a box.
Given my current font size, I can get the bounding rectangle of the text.
If I set some arbitrary min and max font size, I suppose I can increment or decrement my font size until I get to the given box.
I am thinking bisection method:
ChangeFontMethod(float cur... |
I'm trying to wrap my head around the concept of a real jitter buffer. I'm basing the only knowledge that I have around this article:
http://toncar.cz/Tutorials/VoIP/VoIP_Basics_Jitter.html
This article states that:
In the jitter estimator formula, the value D(i-1, i) is the
difference of relative transit times for ... |
I'm writing a program for my grandpa. Occasionally an update will require a new module that's not installed on his computer. I don't want to have to manually install new modules every time, but he's not tech savvy enough to figure it out himself.
Is it OK for me to check for ImportErrors and install a module from the e... |
First, yes, I understand that you are not a lawyer and that you cannot give me legal advice. I swear I will not hold you accountable for any responses you may give, yada, yada, yada, etc, etc, etc.
Anyway...
Next, general details of my potential application:
Ext JS open source (GPL V3) app running all client-side code... |
Is it safe to only use intval to sanitize the user input for a database select, as in the following example?
$id = intval($_GET['id']);
$query = "SELECT * FROM table WHERE id='$id'";
|
I've been researching since my last project last semester and I haven't found a definitive answer for this question. Now I've got one more project to draw a Use-Case diagram and I'm still confused about it.
In the end, can I create a Login Use-Case or not?
Because in my project the user must be logged in to access his... |
I recently developed an application in LabVIEW, but although I'm pretty happy with its design I realised that I might be able to improve one part of it by making the various components of this particular subsystem collaborate with each other using a publisher/subscriber model.
If I do go down this road, I think it's be... |
At work we have a java backend that talks to python on some mobile devices. The mobile devices have no GUI, it's just pure string manipulation. All contact is initiated by the python; the java is just for listening and answering.
As such the python will send messages like:
message_name(field1, field2, field 3)
As stri... |
SRP states ...
There should never be more than one reason for a class to change.
But why a class? Why not use granularity of a function/method? What instead of separating my functionality into separate classes, I separate it into separate functions?
I don't claim that this works or is advisable in all cases, but in... |
In OOP, I can populate (initialize) an object using constructor injection at object creation time, or setter injection, after creation time.
I like the idea of populating object at creation time via constructor, for object parameters that are essential to the object. And use setter methods for things that are non-esse... |
I'm currently developing the Authorization module on a framework of mine.
I have the following class so far:
public interface IAuthorizationManager<C>
where C : AuthorizationConfiguration
{
void Configure(C configuration);
}
One of my implementations is going to be OAuth authentication.
For that I have crea... |
This is a specific problem but I believe the pattern here may be general enough to be useful to the audience here.
I'm working on an offline JS application. In my JS application, I would like to run programmatically generated reports. No problem. I can render to canvas and then convert to pdf (oh the wonders of JS libr... |
One of the main drawbacks of Ruby/Python is performance. I understand that they are interpreted and C is compiled. (And there are things like JRuby which do JIT compilation with Ruby). But they never manage to get the same speed/memory usage as a compiled program. Would it be possible to create a new language that had ... |
So I know that arrays use a block on contiguous memory addresses to store data to memory, and lists make use of static arrays and when data is appended to the list, if there is no room, a new static array is created elsewhere in memory larger in size so more data can be stored. My question is, how do binary trees use m... |
I am currently working on a large project involving at least 3 teams working on separate feature sets in the same codebase versioned on Git. Some features require back-end integration and stabilization and I've heard of features taking months from being ready to going live.
I've seen A successful Git branching model an... |
I hope this question fits this site.
You may know you can't detect undefined behaviour in C using compilers - and some tools (static analysis) can help you detect it.
My question is more empirical - I know exact solution cant' exist.
Question:
Say one developed software and performed intensive testing of the applicati... |
I want to avoid numbers used directly in expressions without obvious meaning. However, if a number is used only once, as an argument passed into a function, and that number can be easily changed without breaking the program, is that number considered a magic number?
For example, I have a function double doSimulation(do... |
I am using Angular Tree View in my web app. Data coming from the server is build with
https://www.npmjs.com/package/mongoose-materialized
getArrayTree() function.
What I need is, syncing the Angular Tree View with the database.
The first way is sending the final json data to server. And with a tree traversal library... |
I have written a software in python with unit tests and system tests together with an other developer. The software is version controlled with git. Before we merge branches, we ensure that the branches pass the tests, so conflicts after merge is only related to merge.
Is it a good idea to version control the test logs... |
Not asking for legal advice, just educated intuition.
Lets say a programmer creates a program to provide a service, for instance (hypothetically) face recognition. User logs in, uploads pictures and the program informs their friends that a picture of them was uploaded (or whatever).
Now the programmer finds another GPL... |
Say I create both a client and a server application. The server remains secret while the client is published under a GPL-ish license, so obviously the communication protocol can be reconstructed to some degree allowing others to attempt writing their own server. I'd be fine with that, if those servers were also bound b... |
I wrote a database wrapper class to help with queries and I'm trying to figure the best way to implement try-catch blocks.
In my database class, I have a helper function;
public function fetchAll($sql, $bind = array()) {
$stmt = $this->query($sql, $bind);
$result = $stmt->fetchAll($this->_fetch_mode);
... |
I have a hard time to find an ideal concept / design and would appreciate your thoughts on this.
I have 16 "tissues" that I need to keep track on. Each tissue holds a pressure that need to be calculated depending on the last value.
So I was going through few thoughts how to organise / structure it.
1. Use array of tiss... |
I am writing a small matlab function to analyze data from a laser probe.
The data to be analyzed is basically:
x-data: Position.
y-data: Laser (light) intensity.
The sensor automatically changes the light intensity data from millivolts to arbitrary Intensity Units which go from 0 to 255. I noticed that with intense sig... |
I'm writing a library that provides graphs for search algorithms.
Usually you want to rank nodes using a priority queue.
Normally you want to search for an specific node in the queue and lower its key (when you find a better path to it).
Searching would be O(n) unless you know the index of the node (you can add it to t... |
I've been asked to develop a "telemetry" application that records data generated by a hardware device, which I read every 100ms.
There are approx 250 data points (32-bit values), but only a subset of these (say 30-50) will be returned by each 100ms read, so it will take several reads before I've got all 250 data point... |
Is it possible to write a unit test (as opposed to an integration test) in the following scenario:
I have a list of Foo objects, some of which already exist in the database, some don't
I want to iterate over the list, update the ones I already have in the database and add new ones
So, I write a test which has a FooIm... |
I'm writing a PHP script which communicates with another program via files. I wonder if there is some policy or standard on where to put such files? I assume choosing a path like C:\foo\bar\ isn't the best? If nothing else it's not portable.
Would $_SERVER['HOME'] be a good place or is there something more appropriate?... |
How do I use DataMapper Pattern? I can use it as a glorified Database Access Object, aka TableGateway (loading a single class from a single database table), or I can use it more to drive business concerns (i.e. load complex objects from many DB tables). Or mix both?
Example
Suppose that in my business application I h... |
I'm working on a Python project which extends the functionality of some other python modules. Some are part of the standard Python library and mostly use the PSF License agreement while some are provided by a third-party and mostly use BSD licenses. All allow redistribution of modified code with attribution.
I understa... |
I came accross the accronym MDSE today on infoq, and the information I could find what quite unclear and the description was full of buzzwords :
MDSE is about enabling software engineers to work at a level of abstraction where requirements, architecture and design information is maximally ordered (in terms of informat... |
Inside a large polygon (say the USA boundaries) I need to find the shortest path that will encompass smaller polygons
(say the following cities: Kansas city, St Louis, Memphis, Oklahoma City)
By shortest I mean with the less nodes as possible. (then will the smaller inner surface)
A 'not-that-bad' result will be the bo... |
i'm currently working on a project which must provide intentionally flickering of some part of UI (white rectangle which must change color to black).
That changing of color must be done at some frequency, let's say 60Hz, which is practically supported on every monitor.
Flickering must follow the input data stream (bina... |
So I am working on a artificial intelligent assistant that is supposed to help you making correct decision when playing the game domino.
Basic rules: http://www.pagat.com/tile/wdom/caribbean.html
As this game has several rules and several different ways you can play a domino to ultimately win the game. Now the question... |
I'm writing a PCL that uses an HttpClient to go visit a few sites and extract data from them. My initial code looked like this:
public static class Download
{
public async static Task<byte[]> FromYouTubeAsync(string videoUri)
{
using (var client = new HttpClient())
{
string source = ... |
In the book Effective Java he give the best Singleton pattern implementation in his, that is implement by a Enum. I have doubt to how to implement this pattern with a third party API.
I'm using an third party API that provides an interface IRCApi that has a lot of methods like:
public interface IRCApi{
void connec... |
I have a scenario where I'm using an external service which requires a big hash of parameters like so:
def external_service_params(user, invoice)
{
name: user.name,
email: user.email,
phone: user.phone,
invoice_id: invoice.id,
invoice_number: invoice.number,
invoice_total: invoice.total
}
en... |
I am currently building the first of many different backend API's. They will to some extent share some common concepts (person information, court information, etc); although between them there are a lot of differences as well. For example, one will be for certain fines, others for speeding tickets, others more related ... |
I'm trying to understand some best practices when it comes to BDD and Cucumber. I've only recently started to use it,
and the first feature I have written a test for is testing a search feature, more specifically how a Repository layer
integrates with a JPA EntityManager that has been injected using the @PersistenceCon... |
Suppose
GET /users/<id>
{
user_id : "asdasdas-da-sd-asd-as-d",
firs_name : "asdasd",
....
department : [{
id : "asdas-da-sdasd-asd",
name : "asdasdasdasd",
...
},]
}
To add a new department for that user first create a department by:
POST /departments/
Then we use PATCH with departm... |
What is a good design for allowing backwards compatibility of a file type between different versions of software?
For instance, how does microsoft get word 2007, 2010 and 2013 etc... to all open docx files, but different editions can save more / less data and save the data in slightly different ways, all to the same fi... |
notify_one() of C++ 11 thread library is used to unblock one of the waiting threads.
How does it choose which thread to unblock?
To begin with, I tried googling but could not find any appropriate answer (even on Stack Exchange network), though I read somewhere that the selection of thread is "unspecified".
So I decided... |
I have two different classes; a Player and a Group. I need to be able to query a Player which Groups they are registered to (player.getGroups()), and which Players are registered to a Group (group.getPlayers()) quickly. The simplest solution is to have each Player keep a list of the Groups it's registered to, and each ... |
The agile manifesto states
Customer collaboration over contract negotiation
My question is how do you make this work effectively when there is distance between the developers and the users?
I currently work in a "waterfall" team maintaining a large enterprise system. The customer is in a different country but we d... |
I searched on Google but couldn't find an answer. I'd like to know what are the standard tab sizes for HTML and CSS. Is it 2 or 4?
|
I've recently joined a team working on radar observations. The team has access to a repository of software (written in C++) used for dealing with these observations, but their work is focused towards research, not software development.
There are various variables associated to reading and analysing radar information... |
I have a basic class in C# from which I create inherited classes for databinding scenarios. You can think of it as a substitute for .NET's DataRow class.
I want to automate testing of a typical row's lifetime, making sure that things such as object state and changes detection remains coherent throughout.
My first thoug... |
A team has implemented a web application using MySql, PHP with the Zend framework and Angular.js on the client side. I am in charge of implementing the SEO for this application.
I understand I have to take HTML snapshots of the Angular pages and serve them to web crawlers. That's the only solution working for search en... |
I have a device network where each device has different sensors (temperature, humidity, etc..). Each device uploads raw measured weather data every 10 seconds to a apache/php/mysql REST API. There are a few 100 devices sending data and this will become more over time. Currently the data is added to a mysql table withou... |
I ask this because it seems people usually consider the code that goes into a DAO or Repository implementation as "data access code", while the code that directly uses these DAOs/Repositories as "business logic code".
However, this doesn't seem to make logical sense.
Consider a business service method with code like th... |
I am reading the book "you don't know js this & object" and I ran into below where they are explaining 'this'. Now, below example, I understand somewhat but I just do not understand what 'arguments' it is getting.
Is the word 'arguments' just some sort of place holder? I just tried it w/ argumentsX in place of argumen... |
I do not have very clear what a base64 string is or how it is related to a file.
Right now I have a website that uploads an image as a base64 string to my server. This string is converted back into a bitmap and resized.
However, I would like the least amount of memory to be consumed in my server, therefore I would like... |
I have a case that needs to manipulate a large stream of JSON and inject it into Apache HBase. Our system works on Node.js with Mongo then, since we need to enhance performance, so HBase is choosen to handle the big data things.
To enhance my system scalability, I prefer using the Actor Model by Akka for messaging inst... |
I'm currently in the (re)design phase of several model classes of a C# .NET application. (Model as in M of MVC). The model classes already have plenty of well-designed data, behaviors, and interrelationships. I am rewriting the model from Python to C#.
In the old Python model, I think I see a wart. Each model knows... |
I've been studying the Objective-C runtime for some years, and even hacked libobjc a little bit (both Apple's and GNUStep's), and I've been wondering about a design decision on the compilers.
Every Objective-C object is expected to have its size at least of sizeof(Class), having its first field being Class isa, as seem... |
I'm practicing on writing testable code. One problem I have ran to (researched a lot too) is singleton pattern. It's global state nature makes it unreliable to test because singleton's property changes are kept between the execution of each case.
Even so, singleton is a design pattern that is used to address issues tha... |
I have a C# solution that reads records from a db and processes them into another db. The records to be processed are essentially one long string that represents the data and then another string "code" that determines how that big data string should be parsed. There are dozens and dozens of different kinds of records; ... |
In answer to Is testable code better code? I showed how time-dependent code could be testable by using mocks rather than modifying the implementation:
def time_of_day():
return datetime.datetime.utcnow().strftime('%H:%M:%S')
Test code:
@unittest.patch('datetime.datetime.utcnow')
def test_handle_leap_second(self, u... |
I have the following graph that I need to simulate a depth-first search of; starting at g:
My question is: How definite of an order is there when performing a depth-first search? When doing a DFS of a tree, I always see the left-most child searched first (completely), then after backtracking, the second-most-left chil... |
I was asked to create a class that will connect to a remote service via soap. The class has only one public method send(recordName).
The class ended like this:
private recordName;
private recordId;
public send(recordName)
{
this.recordName = recordName;
this.validateRecordName();
this.retrieveRecordId();
... |
The main two arguments against overriding Object.finalize() is that:
You don't get to decide when it's called.
It may not get called at all.
If I understand this correctly, I don't think those are good enough reasons to hate Object.finalize() so much.
It is up to the VM implementation and the GC to determine when th... |
I'm writing a Graph, and decided to make the Adjacency List its own class.
Right now, (stripped down) it looks like this:
public class AdjacencyList<Vertex> {
//A map between a vertex, and a list of vertices that it connects to.
private HashMap<Vertex, HashSet<Vertex>> vertices =
new HashMap<Vertex, Ha... |
In a login screen, a user may expose his username and password data. The same way, in a user list screen, it may expose user name, age, and phone. But none of this views may expose any other user information like address and some others.
I was under the idea that an entity (in this case, user) is the Model itself. And ... |
I was just hoping someone might be able to answer a few questions I have regarding the proper design of DTOs and Domain Models. I'm currently working on a project which involves leveraging a SOAP API.
Since we're working with SOAP we have the added benefit of generating a number of objects (DTOs) using the provided WSD... |
I have a requirement to implement a type of AI for a project, the issue is that I am having trouble visualizing how the AI should actually be implemented.
Essentially, I want the AI to be as dynamic as possible. That is, if I decide in the future to add another type of AI Action (as we'll call it), I don't need to rewr... |
Below is the diagram, where, if we just consider the implementations of List,
AbstractList maintains the core behavior of list. To introduce the new implementation class MyList(say) one can inherit AbstractList and override(if necessary) required methods. By extending AbstractList. Additionally, class MyList is obeyi... |
Below are the recommendation from section 5.1 of this essay.
While Java is not a pure object-oriented language, it is possible to program in a pure object-oriented style by obeying the following rules:
1) Classes only as constructors A class name may only be used after the keyword new.
2) No primitive equality The pro... |
I am searching for programming languages with a certain paradigm, or the name of the paradigm which works like follows:
You start with writing the source code of a program or something more like a script.
This is then executed by the "compiler" (interpreted or just in time compiled) and produces a actual executable.
Y... |
I discover mocking strategies after 50% of tests was writen, and I'm confused about how much focus unit tests should have, for example on class method. I know that for external dependencies you should mock those but what if we call some other method in the same class. Would this considered to be dependency? ... Because... |
I'm currently reading some literature about software development process models. Everywhere I look, I only read the problems with the Waterfall model and how the iterative and incremental development approach solves these problems. But, I cannot find any information about when you should avoid this approach.
So, for wh... |
I keep coming across this term when reading about reinforcement learning, for example in this sentence:
If the problem is modelled with care, some Reinforcement Learning algorithms can converge to the global optimum
(source)
or here:
For any fixed policy Pi, the TD algorithm described above has been proved to conver... |
Is there a connection between futures and exceptions? async-await looks very similar to throw-catch.
|
I'm currently working on a project which requires that we integration a 3rd party SOAP API to handle a number of basic CRUD type operations.
Our current implementation allows us to leveraging the Laravel framework's form validation classes prior to execution of these API requests data; however I have some concerns si... |
The general guidance for C# is to always use a property over a public field. This makes sense- by exposing a field, you're exposing a lot of implementation detail. With a property, you encapsulate that detail so it's hidden from consuming code, and implementation changes are decoupled from interface changes.
However, I... |
I am started to learn C++ using as IDLE Clion of jetbrain company. Normally using the IDLE of Python (i.e., Pycharm of Jetbrain) or R project i am able to execute selection in console line-by-line my code and understand all variables. Is it possible in C++ or i need to compile everytime?
|
I am working on a price comparator, one of the module of application crawls through the list of website against the product stored in the database and updates the price in the application database.
This crawler is a slow process and might take around 3 to 4 hours daily to complete. To test the crawling on my local I wa... |
We got a situation where we need to write a windows service using c#, the service need to be install on a particular -single- server. Also service need to communicate with a DB to access certain table to process data.
What will be the best approach to pass on the credentials to this service?
We have built the service, ... |
Suppose,
There is a user list.
<a href="user/5">Edit</a>
<a href="user/6">Edit</a>
When a system user clicked to edit a user info. Then it goes to url to browser like as
http://abc.com/user/5
He can manually replace 5 to 155 and edit(update) the user info. It is a problem to me. How can I remove this problem?
I have... |
Do (static) type systems exist which attempt to formalize the performance characteristics of programs? I cannot find seem to find such attempts.
Since type systems are (one of) the most powerful tools in the programmer's arsenal to make statements about programs, and since there are many instances in which performance ... |
I am a novice programmer who has inherited a software project that contains the following files and folders. The project is using C# and WPF. What should I expect to find and continue putting inside of the following folders and files:
Core
Assets
Common
Models
Resources
API.cs
Views
I am hoping tha... |
Our Scrum Scenario:
We have two Sprint Planning Meetings (Part 1 and Part 2).
Part 1: What should be done during the Sprint?
Part 2: How should these things be done?
I guess there are some differences in how this is handled. This is according to Boris Gloger's German book. In practice these things can be done on the ... |
In the last three years that I have worked as developer, I have seen a lot of examples where people use a switch statement to set the path (both in back-end and front-end) for a URL. Below is an example of this:
Back-end example (C#):
public static string getHost(EnvironmentEnum environment){
var path = String.Empt... |
I am using entity framework and I created multiple libs. XYZ is main lib which handles majority of operations. And for integration purpose I have created different libs which are comparatively smaller.
I want them to have database connection of external account table which handles authentication and token management. ... |
One benefit of single page applications like Angular.js, is that you can store data in a global variable and access in multiple routes.
With multiple page applications, the data is lost during navigation. Ideally, such data should remain available on the user side while the user session is active. Using SessionStore do... |
My team has written an application which we've decided needs to run a process, we'll say about once a day, as long as the application is being used. I've never done anything like this in Java before so am hoping to get a better idea of how I'd design a solution.
Initially, I've been going through the Oracle 'Overview o... |
I'm trying to come up with a nice design (preferably pythonic) for the following use case.
Say there's three services - A, B, C in multiple locations L1, L2, L3, etc. Each service provides different values, e.g. A returns a1, B returns b1, C returns c1.
The task is to periodically run a function that fetches these ... |
I'm reading "King K.N's C programming" and found the following statement:
We discussed using the expression sizeof(a)/sizeof(a[0]) to calculate the number of elements in an array. The expression sizeof(a)/sizeof(t), where t is the type of a's elements, would also work, but it is considered an inferior technique.
Why ... |
Is it appropriate to make a fully blown github project/repo for something that you believe would be useful to others, but is as small as a single function?
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.