instruction stringlengths 34 36.1k |
|---|
I am trying to build something like Manic Time - which is an application that tracks what the user is currently working on. It worked flawlessly on Windows, but doesn't support Linux.
It has mad features, but the core is basically just tracking what the current 'active' window is, it's process, window title etc.
I've b... |
I am contemplating on creating a public api for my team to use that will encapsulate the workings of webdriver and testng as it's main tools.
Primary to the concern is re usability of code when possible to cater the many test scenarios.
My idea is to allow the qa team to define a set of parameters per scenario to test... |
I was at a bar last night with a few of my colleagues. They said that it's a bad idea to extend the functionality of basic JavaScript Objects with a prototype method.
For example, let's say you created a method for finding the factorial
Number.prototype.factorial = function(n) {
return n == 0 ? 1 : factorial(n - 1)
... |
I'm integrating with a bluetooth blood pressure monitor, and I've come across one of the most bizarre data formats I've ever seen.
The systolic, diastolic and pulse rate (all ints, should all be below 200) are transmitted like this:
the int value is converted to hex
the last two characters of the hex value are taken a... |
I have a tree structure on the left side of my page from which the user can drill down and select items. Each branch has similar items. When clicking a leaf node, I make a JQuery .load(...) call that loads the leaf's data into a div on the right side of the page.
The user can view and/or make changes to the displayed d... |
I've noticed that HTML game developers are recommending the use of requestAnimationFrame as opposed to a timer for the animation loop. I understand that this can be optimized by the browser, but how con you insure that the speed of your animation is consistent on all devices? If a certain device has twice the frame rat... |
So, I have a form that has security questions and textfields for the user to type in their answer. I want to prevent the user from typing in the same answer to every security question selected. So I am wondering, if there is a .NET attribute I can use to do validation on client side or server side approach that would p... |
Can someone help me find the language and/or programming term for delimiters (?) that must be paired?
Quotes, parenthesis, angle-brackets, square-brackets, etc. are often used to symbolize these constructs.
Is there a terminology distinction when the begin/end symbols are identical (such as some quotes) and when they a... |
A binary tree is height balanced if and only if the two subtrees of root are height balanced and the difference between the two subtrees height is at most 1.
I implemented a code in java to find whether a binary search tree is height balanced or not. I did it this way:
Recursively call the function isBalanced(Node) sta... |
It is generally accepted that the best programmers produce at least an order of magnitude more than average ones. This seems like it would cause problems with the usual approaches to sprint planning that focus on whole-team metrics - mostly around estimation and velocity.
For estimation, the great programmer is likely ... |
I'm working on a project(web application) where I have a DataManager(IDALContract dalImplementation) class that does some stuff with the data after retrieving it from the database or before saving it in the database.
My question: Is there any reason why the IDALContract object I'm passing in to the constructor should/s... |
Scenario
I am working on a web application that handles financial transactions, and my code will need to be reusable for everything from consumer carts to manufacturer/distributor shipments. The project uses Laravel in a fairly typical LAMP environment.
I can use PHP's BCMath functions or MySQL queries to handle math o... |
I'm creating a library that contains a class that exposes several Async methods:
public class MyClass {
public async Task<Foo> DoFooAsync() { /*...*/ }
public async Task<Bar> DoBarAsync() { /*...*/ }
}
I have two (main) questions about this:
I understand that not everybody likes to (or needs to) work asynchronou... |
In our codebase I saw a method that is similar to following:
public void doSomething() {
try {
...
} catch (Exception e) {
...
//log something
...
}
}
The caller has no way to know if the method did what it is supposed to. Are there any general Java guidelines on not writing... |
I have a method that takes in a dictionary and enum value and produces a string output. Enum value defines what template string to insert the dictionary key value pairs into.
public string InsertVariables(MessageType type, Dictionary<string, string> variables) { }
It works fine, but every time I use it, I find that it... |
This Mkyong tutorial suggests intialising loggers this way:
@Controller
public class WelcomeController {
private static final Logger logger = Logger.getLogger(WelcomeController.class);
// etc
}
Now presumably every other class you use, that has a logger will initialise their loggers the same way.
My questio... |
My app has some tables that will be rarely updated, probably just once in the beginning and at the system setup. Despite that, they will be frequently accessed. Almost every operation depends on querying them, but as I said they will not be changed.
I'm looking for advices for optimizing this web app.
I have defined in... |
Note: this question has been re-written to simplify and generalize the problem. The original is available below.
Suppose I created a simple compression scheme for lists of 2-digit numbers. It has 2 modes:
Mode 0: The numbers are written as-is, uncompressed.
Mode 1: Only the ones digit is written for each number, but t... |
I am in the middle of an agile sprint. Midway we realize that the requirement that we were working upon, could have been done in an easier fashion in a totally different way. The development work done on the current requirement wont be needed at all or needs to be changed totally. How is this handled in Agile? Even if ... |
I'm constantly creating util classes like Files to be able to mock files functionality in tests.
It is convenient but violates basic idea - don't modify production code to comply with tests. I could also prepare test directory with test files but it is also sounds like not proper unit testing.
Are there good approach h... |
So I'm pretty new in my current company and my current task is to create a webservice that sends some serialized java objects from service A to service B using jaxws (webservices). The senior on the team encouraged me to copy (ctrl + c) the beans from project A into project B. I think this is not a good idea. As soon a... |
I'm using this script in one of my projects. It's licensed under MIT or Apache 2.
I've committed JSON.sh (as in, just the script) to my project, and copy+pasted the MIT license (as it appears in LICENSE.MIT) to the bottom of it.
Is that sufficient?
|
I am thinking about the software development process of my team, more specifically, I am thinking about tests and code review into our development process.
I came to the conclusion that, in order to validate a development task, the development done has to be tested by one tester, and the code has to be reviewed, eithe... |
Let's say there are Users and Pets. Each Pet has a single User as its owner, and a globally unique id. Endpoints could be
/users/1/pets/2
/pets/2
I feel like the first option could be unintuitive since IDs are inconsistent within one User. Which one should I use?
|
I have some code written in Matlab. I use the code in different folders which contains different data. Because I want to change some parameters for each different data, I keep the code in the folder of each data to remember what parameters I have used.
The problem is that sometimes I improve the code and it is hard to ... |
The principle of duck typing says that you shouldn't care what type of object you have - just whether or not you can do the required action with your object. For this reason the isinstance keyword is frowned upon. - -Definition
In below snippet(function) group_tweets_by_state, following definition of duck typing, act... |
I'm trying to figure out the best way to solve a design issue. I have to be able to clone (I'm cloning them to Apache HttpClient) different types of HttpServletRequest (POST, GET...) and then send them. I want a super class with the common logic and then some subclasses for each method.
public abstract class ClonedRequ... |
We have a large team comprising of developers, interns who write rails and backbone js code with large codebase.
We already have tools like JSCS and code climate to analyze the code and report errors to the developers so that they fix it.
I tried to introduce fixmyjs, tool which corrects silly syntax errors automatic... |
I'm surprised this doesn't seem to have been asked before, or at least I can't find it anywhere. I know this is more of a philosophical question, but is there any particular reason not to use a factory (I'm assuming everyone knows the benefits of the factory pattern, so I won't go into that) for instantiating public A... |
I have quite a few Helper classes in my project. I have read that this is a bad thing, but I suspect that "Helper" is the wrong suffix for them. I'll give an example.
First, I have a User class. I need a method GetSuggestedFriends() for a user. I want to keep the logic for determining the list of suggested friends out ... |
I'm finding myself unable to solve a design problem.
For the sake of my simplicity, I'm going to use C# (Web API).
Let's say I have an abstract class RestController:
public abstract class RestController
{
// ... Irrelevant code here
protected virtual async Task<IHttpActionResult> UseAuthorization(HttpMethod me... |
I'm in the process of reading Code Complete 2 and learned that using global state is a no-no. What can I do to avoid using global state in this situation?
Some background information: I have two different methods (formAdded and formRemoved), each of which is called depending on whether an Add button is clicked or a R... |
Background:
I have a question which is outline at Use different local storage between windows. The very high level question is "How can I keep tabs and windows sessions from clashing".
Requirement:
I want to be able to have separate "sessions" for each tab(s) or window(s).
Problem:
The problem is if I store the data in... |
In general, I write a debug log whenever one of my functions is entered, including the parameters.
For instance:
function execute_query($query, $conn_string)
{
$this->log->debug(sprintf('Entering execute_query(query=%s, conn_string=%s)', $query, $conn_string));
//Do Stuff
}
The potential pr... |
I have several Lists<> that holds objects of different classes.
List<classA> listA;
List<classB> listB;
List<classC> listC;
//...
List<classM> listM;
The classes do not relate in any way and have nothing in common except that they might have a single property marked with an Attribute SortBy=true
[CustomObjectCompa... |
I'm in a situation where I already have a working, high-performance C++ program with GTK and OpenGL that renders data as a real-time graph. The data is saved as a report in a database which can be looked up at a later date from a browser. I now need to display those same graphs from the web-based reports (this wasn't i... |
To start off, this is more of a best-practice question than anything.
Introduction to the Environment
I have myself an abstract class. Let's call this class Item. I also have another abstract class, we'll call this one Container. The Container class inherits the Item class.
Here's my dilemma: I'm trying to right-proper... |
I am writing a program, where in the beginning of the execution, I am instantiating a number of classifier objects using parameters stored in some files.
I later use those classifiers in multiple objects.
My question is: how should an object which uses a classifier obtain this classifier object?
The objects which use... |
Suppose there is a small team with 1 senior developer and 3 junior developers working on the same repo in a team on a github organization. The senior developer has admin access. What is the most common approach in the industry to setup the access for the junior developers?
Is it giving them read access only and ask the... |
I'm building a matchmaking queueing service for a 5v5 team-based game.
I have a large set of users that are grouped into unique lobbies comprised of 1-5 users each. Each user has an integer based rank from 1-16. These ranks will eventually be converted to a trueskill rating, but for now, we're sticking with integers s... |
I built an iOS app similar to Vine, where a user can scroll a feed of videos that auto play. All of these video have a View_Count field in the backend to keep track of how many times the video has been viewed.
Right now the way I have it set up, is as soon as the user starts watching the video, I increase the View_Coun... |
I'm writing a text-based game, in C. I want the game to handle NPCs movement and actions in the background, while the user is making his moves. I'd also use time-based events to tell the user when midnight is (in game-time), or to activate certain things at certain times.
I know that Dwarf Fortress is all single thr... |
I've seen a few useful plugins for Eclipse such as jshint-eclipse. However, I'm a bit leery of installing third-party code.
Is it generally safe to install Eclipse plugins without worrying about my local system being compromised?
|
Java applications can run on different platforms because they always run on top of a Virtual Machine specifically developed for each platform. So, there's no native installation, you just drop the compiled jar anywhere and run it.
Now, I'm not very familiarized with the details of C/C++ development. So I'm curious, how... |
I know that it's possible perform automation of testing. That is, take tests that are manual, and make them automatic.
However, is there such a thing as the testing of automation? That is, checking if an automation process is working correctly or not?
I came across a job ad talking about "testing automation", and I'm 9... |
As I understand, when a file is being written, the process writing to the file obtains an exclusive lock. So other processes cannot access this file for read.
With the above knowledge, I'm unable to understand how I'm able to play a video in media player, when the browser is still downloading it.
|
Let me start of by saying that by "worth it" I don't mean "remove DI and interfaces" and such.
What I mean is to place the code in separate class libraries. Like done in the Onion architecture - which I like very much.
The problem is that the ASP.NET project is the bootstrapper when it really it should just do web pres... |
I'm thinking about contributing to a small R package on github that has only 1 contributor. What's the standard etiquette when there's not Contributing.md page on small projects like this?
Should I email him about whether my feature is wanted? Or just clone and then issue a pull request?
|
I am creating a base API in JavaSE, which includes modules like MVP architecture, Service & Repository Layer, Event Model to fire events between presenter etc.
I am trying to implement all best practices of Software Design. Recently, I read about Dependency Injection & its advantages and decided to use Guice as DI fram... |
I'm taking my first foray into .NET and I'm designing a web app that's heavy on other web services right now. I'm intending to do the following:
Take user input (a USDOT number)
Request data from a public, government API on that DOT number (provided it is not available in local storage)
Commit to DB (if needed)
Pass ... |
I'm following this tutorial: http://wiki4.caucho.com/Building_a_simple_listing_in_JSP It creates a basic web application in Eclipse using the MVC pattern with Resin as the web container. Here's the part I don't understand.
For the model, it creates a POJO, Interface and Interface Implementation. The data represents a... |
I have seen several implementations of "State Machines" on github. As far as I understand, a state machine takes input that may or may not transform its state into one of a finite set of other states. How is that different from any other computer program?
|
I have a class: A that is a composite of a number of smaller classes, B, Cand D.
B, C, and D implement interfaces IB, IC, and ID respectively.
Since A supports all the functionality of B, C and D, A implements IB, IC and ID as well, but this unfortunately leads to a lot of re-routing in the implementation of A
Like so:... |
In the short chapter, What is Node by McLaughlin, he writes:
"Node has no blocks, no threads competing for the same resource (Node
is happy to just let things happen however they happen), nothing that
has to start up upon request. Node just sits around waiting (quite
literally; unused Node responders are sleepin... |
Is there a way to use a loop to create more nested loops? E.g. Doing this
for (int i = 0; i < iterations; i++)
{
//Do stuff
for (int ii = 0; ii < iterations; ii++)
{
// Do stuff
for (int iii = 0; iii < iterations; iii++)... |
I am developing a noSQL database and currently moving the code from C to C++.
It have class Pair, which contains a raw pointer to a memory blob.
class Pair {
Blob* blob;
...
};
Then if you add this Pair to the List class, the List class stores this raw pointer internally, without copying. In order not to leak memo... |
I'm currently working in a project where we discuss the question whether it is a good idea or not to rotate the scrum masters through all teams.
We have different teams for ONE project. The context where they work in is the same. They only switch teams for a couple of weeks. We hope to benefit from each ScrumMaster as ... |
Writing my own JVM compiler, I am facing a giant problem that I am desperately unable to solve:
Lambda Return Type Inference
1. Overview of the compiler lifecycle
More specifically, the order in which things should happen in a compiler to make this work correctly. First of all, as probably every compiler, mine is divid... |
I want to verify that my services (used to collect data from database and handle it according logic) are not connecting to production database which can cause data loss.
my first idea was to mark the service with its configuration file with Enviroment property and verify it against DB's data but our QA enviroment datab... |
I am learning about the GRASP (Greedy Randomized Adaptive Search) meta-heuristics.
From what I understood, GRASP is based on two main phases.
The first one:
Construct a initial solution based on a greedy and random strategy
and the second one:
Construct a local search on the previous found solution
The question tha... |
I am using wxHaskell to create a simple GUI that has typical components like Buttons, Panels, etc.
When some of these components perform an action (like callback), the generic status of the application can change.
To keep the status I am using IORef as a sort of pointer to a generic data structure with all the properti... |
From what I understand, in most sites, passwords are stored as a hash; not in their original form. This means that if the database is hacked into, the attacker will see the (nearly) useless hashes instead of the actual passwords.
For the website to authenticate your login attempt, it hashes your attempt of a password, ... |
I'm trying to build an architecture in C#, and I can't figure out a way to accomplish the task. Basically, there's a set of classes A, B, C and D that inherit from I. Each of these classes has an operation Foo that operates on one of the other classes, and returns an object of type R:
class A : I
{
public R Foo(A a... |
I'm writing a Hash Table that uses linear probing to resolve collisions.
I looked over how linear probing works, and it seems like to allow for deletions, I can't simply remove an element, since that may prevent a previously-collided element from being found post-deletion (since searching ends on an unoccupied cell).
I... |
I'm struggling to come up with the name of a design pattern that I need to write about. I've been lead to think it was abstraction but apparently not.
Let's say I had a driver class which has a Drive method:
public void Drive()
{
if(IsOnGasPedal)
{
//Lots of code
}
if(IsOnBrake)
{
//... |
Suppose I create a simple functional Domain-specific language (DSL) using an imperative language, in this case C++. Here is a simple implementation of a DSL that can has the notion of a simple value and operator (in this case the addition operator):
// some operator
template <typename LHS, typename RHS>
struct OpImpl
{... |
I'm creating a system to store holidays and events. I have a basic understanding of the schema for the static dates (every 23rd of march for instance).
My trouble lies with the relative dates (i.e. : every 3rd friday of march).
For the static dates we can safely have a schema that looks like this :
+----------+------... |
What is the difference between over-engineering, under-engineering and right-engineering at coding/design perspective?
I found over-engineering: Coding too much like doing future requirement code and implementing simple logic as very complex code. Am I right?
and I do not understand under-engineering and right-engine... |
I try to program to an interface whenever possible, but its not clear to me how I could apply it to a model as broad as a user. Which can hold many disparate fields (name, age, phone number, ssn, etc.) or be composed of many modules.
I could design a general purpose library of functionality for use across applications,... |
I try to program to an interface whenever possible, but when I have a class that fulfills a very specific and unique purpose, one that can't be abstracted. Is it correct for me to say that I've reached the limits of "abstraction" and that I need to just pass in the concrete class?
public void DoSomethingWith (HighlySpe... |
How do I design a subclass whose method contradicts its superclass? Let's say we have this example:
# Example 1
class Scissor
def right_handed?
true
end
end
class LeftHandedScissor < Scissor
def right_handed?
false
end
end
Let's assume that the inheritance is necessary in this example e.g. that there... |
I have a utility which runs at certain intervals. My customer now wishes for it to send an email when the task is completed.
They want to be able to control the email address, meaning, they want to be able to enter their SMTP details.
This is quite a trivial task, but, the storage of the password is not.
When customer... |
I'm working with a system in ASP.NET MVC, with Entity Framework for ORM. The application has a requirements to allow users to have different types of roles, and authorization rules will be different for each role (.e.g. user with role A will be able to see some pages, role B will see some different pages)
In most of th... |
I'm reading a book about C programming By "King.K.N" and I'm reading the following statement:
If we store 0.1 in a float variable, we may later find that the variable has a value such as 0.0999999999999999987
But I can't understand why float type variable may have different value?
|
I would like to use a piece of software I wrote for my company in a private open source project. I have already talked to my manager about the possibilities of the company open sourcing that software. It is not decided yet, but it could well be that my company might just turn down my request, simply because all the leg... |
I am currently in process of writing a software application.
In this application, I use another software project which is licensed by GNU GPL. I have widely modified the GNU licensed component and tailored it to fit my needs.
But I do not want my software application to be released under GNU GPL license, I would rather... |
For most of my programming career, I've used the "build/compile/run" command in whatever IDE I'm working with to produce a runnable program. This is one button, pretty easy. As I learn more about different languages and frameworks, though, I see more and more talk of "build scripts" (ANT, Maven, Gradle, etc.) to get a ... |
I'm making a program that supports plugins. The program is being written in F#.
The program maintains a single object that represents the state of the program. When a plugin is invoked, it takes the state and returns a new state which replaces the old one.
Example:
The filereader plugin takes an empty state and puts ... |
In our API we've got a few central datatypes which need to be "decorated" (so to speak) after retrieval from the database with calculated values. The database is accessed through an ORM which follows a Table/Entity dynamic heavily inspired by the CakePHP 3 database layer, where a Table object is used as an intermediary... |
We use C# MVC and Angularjs as the primary tools to develop our web applications. We've recently been discussing best practices, with an eye towards revising our development approaches into something a bit more structured.
One of the topics is how we handle APIs.
More specifically, we're looking to utilize web APIs as... |
Macros are considered a good thing by one and evil by another.
Is there a rule of thumb when to and when not to use macros in C++?
When are macros idiomatic and when should they be avoided?
|
I understand the structure of binary trees and how to traverse them. However, I am struggling to realize their actual uses, purposes in programs and programming. When I think about 'real life' examples of hierarchical data they almost certainly have more than 2 children. For example, in a family tree, a mother may ofte... |
I modified some code and added few (minor) changes to an open source Android app. Now I want to publish it on play store. The app is licensed under Apache license v2. The license file is included in the project but there is no name of the author on it. It is just an Apache terms and conditions file nothing else.
There ... |
Summary
I want to look into separating the concern of "creating a populated object from database", to use inside my application. DataMapper pattern seems to be doing just that for me.
DataMapper pattern definition: http://martinfowler.com/eaaCatalog/dataMapper.html
However, inside the DataMapper pattern itself there ... |
I am confused over the interpretation of the following statement
Fruit x= new Fruit();
My interpretation is that the new operator along with Fruit(); creates a new object somewhere in the memory.
Now x is a reference variable that points toward the object created and if I write Fruit x , does it only mean that a refer... |
I see the following statements in Arphic Public License:
Automatic Receipt
Each time you redistribute the Font, the recipient automatically
receives a license from the original licensor to copy, distribute or
modify the Font subject to these terms and conditions. You may not
impose any further restrictions on... |
Different programming language always/most of the time use different syntax.
For example take PHP, Java and Python.
In Php & Java semicolons are compulsory at the end of the line, yet Python gives an error if I put semicolon at the end of line.
In PHP & Java we must use brackets for more than 1 statement, whereas it i... |
This could be a quirk of the IDE I am using, Android Studio, or it could be something more nuanced that I don't understand.
I have a method setCustomFont that appears as a property in the Structure view in my IDE. It appears that AS is making this decision to class it as a property based on its signature and the set /... |
I have dual-licensed library, LGPL 3 and commercial license. Someone downloads the LGPL version, makes some improvements and sends back few patches. So far so good. But what now? It's legal to just merge those patches into code base and use them under commercial license?
I know some project (Qt, Canonical) have contrib... |
Within an enterprise distributed system I have many services - an E-commerce service, a CRM, support desk, finance, billing. Many of these services share common data, such as Customer data.
These services communicate with each other using an Enterprise Service Bus (ESB) to ensure that data in all systems is eventually ... |
Can I take a GPL program and relicense my changes under the AGPL?
Say I clone a GPL project, make some changes, can I only allow people to use my changes under the AGPL license?
|
How would you design a REST interface that triggers a status change of an object, but requires additional properties in that moment? For example, the deliverer of a package needs to change the status of the package from in transport to delivered, but also specify how it was delivered (letterbox or in person).
I see two... |
I'm writing a Gateway class that wraps access to a web service which provides information about a player's item inventory in a video game. This web service returns a variety of information, however I do not need to use all of it.
The only thing I need to know from the web service is if a given game item is present in t... |
I am refactoring and introducing unit tests in a large application.
It's currently a collection of static classes with static methods that return data, like such:
// in data access project
public static class DataStock {
public static Stock GetStock(int operation) { return my data; }
}
// in business layer projec... |
I am working on a project that uses ABCL. License of ABCL is GNU GPL with classpath exception, which means we can link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your cho... |
Taking an example of a simple Ruby on Rails application. It creates a Logger object during application load process:
# in environment.rb
config.logger = Logger.new(<STDOUT | file | whatever>)
# and in our application we use this object
logger.warn "This process is taking too long to process. Optimization needed."
My ... |
I am creating a schema for Doctrine but first I'm creating interfaces, abstract classes (models) which will be extended by the entities.
I have a PresentationInterface which contain getter and setters for presentation info, ParticipantInterface which contains the same (firstname, lastname, email).
Both have their abst... |
I'm developing a registration system for a project I'm working on.
Since users tend not to sign up if the process is too long, I've thought to require (at least initially) just their email, where I would send them their automatically generated password (and that would also allow me to verify their email address). That ... |
To preface, I think this problem would be easier to understand if I gave an example: How does a complex tax evaluation application manage multiple tax laws and personal situations?
I inherited a web application which has a lot of business logic lodged in the views. This logic controls page flow and control visualizatio... |
I'm implementing a restful service automation tool for client applications. Basically, the tool takes a config file that defines restful resources, and creates some DTOs and resource classes for client to use. But I need a standard for this config file. WSDL seems well known, but it was intended to use with soap, and f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.