instruction stringlengths 34 19.9k |
|---|
This concept is unclear with me.
I have worked on several frameworks for an instance Spring. To implement a feature we always implement some interfaces provided by the framework.
For an instance if I have to create a custom scope in Spring, my class implements a org.springframework.beans.factory.config.Scope interface.... |
In most Java code, I see people declare Java objects like this:
Map<String, String> hashMap = new HashMap<>();
List<String> list = new ArrayList<>();
instead of:
HashMap<String, String> hashMap = new HashMap<>();
ArrayList<String> list = new ArrayList<>();
Why is there a preference to define the Java object using the... |
My primary language is statically typed (Java). In Java, you have to return a single type from every method. For example, you can't have a method that conditionally returns a String or conditionally returns an Integer. But in JavaScript, for example, this is very possible.
In a statically typed language I get why th... |
I'm not sure I understand what all fall under the disconnected context scenarios in EF (See this and this). This link says use Web API or WCF services to avoid the complexities of disconnected tier EF solutions.
Here's my understanding. If I create a new DbContext, get some entities, pass it to another process/machine ... |
I always see standard Order classes implemented with a "Status" property, but I don't feel comfortable with that. Isn't the status a property of the fulfillment process instead of the order itself? What about orders that can be subject to different fulfillment processes?
|
I realize that there are already a couple of questions about this, but they mostly are about if you should bring code to the interview, which is not the case here.
I have a job interview (at a startup) coming up next week and they requested to bring some code to the interview. I have two smaller open-source projects an... |
I'd like to ask you about one simple thing. I have class A that do something (for example counts something ). There is also one class B that handle some parameters to this class (class A is member of class B). Class B calls one method of class A that does something and writes value to database.
Class A uses parameters ... |
I'm programming a graph object which can be in either a mutable or immutable state. In both states, it has a get method, but only in the mutable state is the set method allowed. The transition occurs when one invokes a method compress which optimizes the storage of the graph.
How do I deal with the fact that some metho... |
I'm trying to find the best way to process about 20,000 lines of a statute in text format into HTML so that it can be displayed and manipulated in a granular fashion, i.e. by clause. The format is essentially a nested list like (a)(1)(A)(i)(II)(aa) and is fairly consistent. Each clause begins with a new line and is enc... |
The question is about typehinting of the role interfaces.
The code example has two DataMappers which typehint the interface they need in the constructor,
FooDataMapper type hints the Preparable interface. Because it dependens on it and no other method from the dependency.
In the other mapper, BarDataMapper i replaced ... |
What are a few ways constants and enums are dealt with when creating an API Client? I'm writing a client in python for our API and I've hit a sticking point with this. We use a lot of mappings to numbers (to save space) and I was wondering what the best technique is. I can hard code them into the client, but if a ne... |
I am working on some code right now that involves processing user requests. Each request requires going through an approval. When a request is made, one or more records are created on the database recording what the request entails. Then a ticket is created and placed on the approver's work queue.
For a typical request... |
At this point, I'm not much of a programmer, solid html/css, familiar with JS but not a programmer by any means. I'm looking to pick up whatever is necessary for an upcoming project.
I need to build an online image repository that will host around 15k photos. Those photos will need to have user entered data associated... |
I'm encountering a common issue in PHP (and most other languages) at the moment, where systems I'm designing need to be updated in multiple places to add new features, whereas I would like to have a core, where I can add new features, plugin's etc without having to touch the core code.
An example would be a a navigati... |
Our knowledge domain involves people walking over a pressure-recording plate with their bare feet. We do image recognition which results in objects of the 'Foot' class, if a human foot is recognized in the sensor data.
There are several calculations that must be performed on the foot's data.
Now, which API would be be... |
Can we say that Java or C# are OO languages with a unified inheritance tree/unified type system?
By unified inheritance tree/unified type system I mean that every class derives implicitly or explicitly from one single type? Are there any object oriented language that do not follow that concept?
|
I'm working on 300K line C/C++ Windows application that is spread across 23 different Eclipse projects (approximately one third for Qt interface, one third for DLLs and one third for static libraries).
I have complained to the project manager that it's cumbersome to work with so many different projects for one single ... |
We're using Git as our DVCS and we're about to start to do a clean up (never done before in this team) of files that are not necessary (not part of the sources) from our products.
This is done in two ways:
removing the product files from the repo and adding them to the ignore list.
deleting dead code
According to W... |
I have an IP network and want to automatically find a free IP address to provision a new server. Due to frequent server additions/removals the used IPs might be quite fragmented over the whole address space. To effectively check if an IP is free I have to ping and ask the DNS system, which is considered expensive. So I... |
For a while now I have been considering the formatting of sass files to maximise their usability by other coders and I think that this would be perfect place to get some feedback on the rules I try to apply when writing a sass file. I am specifically interested in the usability of the source code as it is created and m... |
I have adopted some jQuery code that has like 20 event-captures that look like this
// used on menu#edit
$('.show-headers-only-toggle').on('click',function(){
arc_eh.menu_edit.show_headers_only_toggle.call(this);
});
that call a method that does the functionality. This is the only place that this method is c... |
I've always had this question and I think it is time to settle the answer, is it a heavy load to do this :
public Rect Bounds
{
get
{
var Top = (_targetPosition + _translationY) - _size / 2.0f;
return new Rect(callOutStarMargin, Top, _size, _size);
}
}
as ... |
Imagine you want to set up a minimalist e-commerce website for a "lemonade stall". You only have two products - a large glass of lemonade OR a small glass of lemonade (always either/or; never both). You want people to select, to pay, to enjoy - that fast, that simple, and with no other distracting features/options offe... |
I'm having trouble coming up with a suitable way to navigate through a set of star coordinates in the Equatorial Coordinate System. My goal is to display those which are within a given range of horizontal coordinates. The display is square with about 10 degrees "length" in each direction.
I thought about binning the st... |
While preparing SQL introductory material, I've ended asking myself about the line of thought followed by a developer when writing a query. I believe it could be too valuable from a beginner's point of view.
Let me illustrate the subject with an example. For the sake of brevity, I won't include the database schema, hop... |
After college I worked at one company for 6 months, and I've just now joined another one, bringing the grand total in my career so far to two.
So the first company had a few hundred thousand lines of code, maybe, across a couple hundred files. There was absolutely no introduction to where to start learning the organiza... |
I am starting to work on a new commercial software project that may use elements of "open source" code.
I have been instructed to ensure that I only use code which is licensed for commercial use and although we may decide to make it open source in the future it should be required to be open source.
So this clearly proh... |
I am facing a conceptual development methodology problem that I was hoping you could help me with. Firstly, a little bit of background.
Background
The project I am developing is a niche application that contains a database of information, and the target audience for my application are private individuals on the lower-e... |
I'm building a large, editable data table with angular, and I'm trying to figure out what the best practice is.
The table will be a couple of hundred rows, with a couple of dozen columns, so upwards of 2000 cells. Each cell needs to be editable inline.
My first thought was to have directives at the cell level, so it wo... |
The answer in this question suggests creating a ServletUtilities class to handle text conversion between Java strings and XML text.
Generally when you create a JEE web application you put together a
class that handles general conversions like this in a class named
ServletUtilities.
I did a bit of a google for Se... |
I am just starting out my programming career and I have a chance to bid on a freelance job. I have looked over the specifications for the app and believe I am capable of meeting the requirements satisfactorily. I have worked on a team developing 2 different apps for the same platform , as well as one app I wrote for a ... |
Assume you have two variables a and b, and you need to swap them, and for whatever reason, making a temporary variable for storage is not an option. This is the algorithm in pseudocode
a ← a XOR b
b ← a XOR b
a ← a XOR b
Based on examples I can see that this does work.
But, why does it work?
More specifically, how wa... |
I am currently working on a software project that performs compression and indexing on video surveillance footage. The compression works by splitting background and foreground objects, then saving the background as a static image, and the foreground as a sprite.
Recently, I have embarked on reviewing some of the class... |
I am starting my first project in OpenGL/GLSL and I was wondering, how do you work with code of shaders?
Because it needs to be const char and syntax higlighting shows everything in the same color (as string) and so its difficult to navigate in code.
const char *shader = ..."void main()\n"...;
Do you edit the code a... |
First a note, I thought maybe this question belonged in the database exchange, but I think it is more broadly related to a programming solution as a whole than to databases. Will move to database exchange if people think thats the best one.
I was wondering when a database table should have a created and updated timesta... |
I was suggested to put my question here, so I'm doing so ;)
I need a common interface which represents some specific behavior:
public interface Contract(){
public void methodA();
public void methodB();
// and so on...
}
The problem is, that in order to fulfill this behavior, implementation can be totally stat... |
Fail-fast seems like a right way since it simplifies bug detection. But it's a harm for performance cause of multiple checking the same thing at several levels of the system.
Simple example.
There is a function that input parameters must be not null. And there is function wrapping it, that also await the same parameter... |
Let's say I have a method DoTheThing() which requires the precondition-check CanTheThingBeDone() to return true. The latter method is time consuming as it accesses the database.
I'm finding it hard to find a perfect way to perform the precondition check effectively (i.e. once) while maintaining both readability and AP... |
I appreciate a lot the new Java 8 features about lambdas and default methods interfaces. Yet, I still get bored with checked exceptions. For instance, if I just want to list all the visible fields of an object I would like to simply write this:
Arrays.asList(p.getClass().getFields()).forEach(
f -> System.ou... |
Here is my situation. I have implemented the accepted .NET 4.0 answer in this question, which is working.
However, my codebase is quite large and as responsible for this code I've started getting inquiries regarding this solution. I've been asked if there are no easier ways of accomplishing the same thing, and if there... |
I often use enum types in my code with a switch to apply logic to each type. In these cases it's important that each enum has code implemented.
For example;
public enum eERROR
{
REQUIRED,
DUPLICATE,
UNKNOWN,
MISSING_VALUE
}
public void Error(eERROR pError)
{
switch (pError)
{
case eERRO... |
I have a very simple question that baffles me for a long time. I am dealing with networks and databases so a lot of data I am dealing with are 32-bit and 64-bit counters (unsigned), 32-bit and 64-bit identification ids (also do not have meaningful mapping for sign). I am practically never deal with any real word matter... |
I am writing a script that does something to a text file (what it does is irrelevant for my question though). So before I do something to the file I want to check if the file exists. I can do this, no problem, but the issue is more that of aesthetics.
Here is my code, implementing the same thing in two different ways.
... |
I am working on a Chen ERD to model our organizations merchandise. Our central entity is a Style. We have supplemental entities of Color and Season.
I am defining our assortment as the relationship between these three entities, and this relationship itself will have attributes and is defined by the three entities w... |
I have a discount service that gets called if certain conditions are met. I need to write test cases to check if the discount service is called. My doubt is checking if the discount service is NOT called for type 4 and 5 is a valid test case scenario.
public void ApplyDiscount(int typeId, double amount)
{
if(typeId ... |
Suppose I have an interface declaring the following method signature:
SearchResults SearchProducts(string type, string filter, string anotherFilter);
Inside a concrete implementation of this, I instantiate a helper class (call it QueryBuilder), built to ease the construction of strongly-typed search queries for the sp... |
When creating my object I pass it an array of a row from my database.
(everything in the array we will need, disregarding unnecessary elements at sql query level)
When I need to access certain array elements from within my class, I do so like
$this->row['element']
However, As I continue development, I sometimes forget... |
I have a web service. Right now, I have passwords stored in plain text in a MySQL table on my server. I know this isn't the best practice, and that is why I am working on it.
Why should passwords be encrypted if they are being stored in a secure database? I realize that if someone hacks in to my database they will get ... |
Why is repeating yourself by writing tests so highly encouraged?
It seems that tests basically express the same thing as the code, and hence is a duplicate (in concept, not implementation) of the code. Wouldn't the ultimate target of DRY include elimination of all test code?
|
In our company we do usability test at the end of each Sprint. Many times we discover that the users don't like the implemented feature, so we either completely change it or scrap it in the next Sprint.
However if we start doing potentially shippable product, thus fixing all bugs, running a lot of tests, preparing docu... |
For a project planning I have an initial period, lets call it PPStart-PPEnd.
The planning is associated with a project. This also has a period PrjStart-PrjEnd. PrjStart and PrjEnd are fixed, and can be unbound, i.e. the project start time or end time are not defined.
PPStart-PPEnd should be adjusted so that people can ... |
The only unit tests tactic I'm familiar with is comparing against golden data _ a predefined set of input data for which output is known (preferably including corner cases).
I cannot think of any other reasonable way of unit testing. Trying to unit test using arbitrary input data is (at least) as difficult as writing t... |
I've just been involved in a debate regarding semantics of how to define approaches to the software development lifecycle.
As far as I have been concerned, waterfall and agile are not methodologies, they are vaguely defined approaches/models. The definition of a methodology being a set of tools and techniques used to e... |
In a webapp, I have a scenario where I need some kind of global context (Static like) for few variables, for the current thread only.
If there are 3 different concurrent users, then I expect three corresponding global context variable for the 3 separate threads/sessions.
Using a Static variable makes its scope global... |
I have been asked to be the SCM (Software Configuration Manager) in my company. I've read online documentation to learn what SCM is, what SCM does, etc.
Currently, the company works with a version control system (Bazaar), so the software is versioned correctly, but there are old programs that are not well versioned (so... |
Suppose in a manufacturing environment, there are certain stock materials available for use in a product. For example, there are only a few different sizes of copper tube, each having a specific thickness and diameter combination. For the purposes of clean and minimal code as well as the ability to control the availabl... |
In my app, I use a widget with a loading spinner to signify that a network request is waiting.
On failure, there will be another view which contains a failure message and a "Reload" button.
My question is, since both of these views/widgets will ALWAYS be used together (either one or the other will be shown - or neither... |
First, I know there are lot of answers about MVC but I need some more-specific ansewer based on my probably wrong understanding of MVC.
I've already read this very good answer (Explain Model View Controller) but I still need some clarification.
I need to understand if I've understood how MVC works because I'm using it ... |
When do you want (on purpose) to coerce type in JavaScript? I mean, beyond comparing strings and numbers, when does it benefit something you're building?
Examples of type coercion:
"The answer is " + 42
//=> "The answer is 42"
"37" - 7
//=> 30
"37" + 7
//=> "377"
var foo = [0];
console.log(foo == foo);
//=> true
... |
I have moved to a new job and code base (been doing C#, .NET, Windows Forms, etc. for last four years) and I have been on this for three months until today. During these three months I caught up with parts of the language and syntax that I didn't know before (MVVM, Silverlight, some advanced stuff in .NET like Action, ... |
So I'm working on a software product where we have a number of fields that the customer can leave blank, some of which are numeric. To persist these in the database we use nullable columns. Easy peasy.
I'm considering the utility of an object oriented domain model and one thing that bugs me is the issue of nullable fie... |
This is a very broad question, and I'm just looking for a pointer in the right direction more than a specific answer, but it's something I've always wondered and never known.
Lets say I have a program that I wrote, and I put it on a server. Then, I write an android app that I want to use to control that program (give i... |
I'll write this in PHP (where this thought originated), but this is generic to any object-orientated language. Basically, this is an addition to abstract classes that defines the implementation of its subclasses. Obviously, this could never go into interfaces because it defines how classes will be implemented, an immed... |
Lets say we have an abstract class called BaseSwitch, inherited by concrete implementations Switch A and Switch B, Each Switch representing a real-life switch (A telephony tool which among its responsibilities is writing CDR; all data records of calls hitting the switch).
Each Switch in real life writes CDR in a differ... |
In objective C, classes are objects, but what object owns the class objects?
I am trying to get as detailed an understanding of iOS programming as I can, and this question popped into my head, so I decided I should know the answer.
|
I am implementing an ecommerce database. This is slightly different than most as the 'products' that are for sale are for services provided. For example a user (vendor) of the system may define a service to 'wash your car'.
Table: Services
--------------------------------------------------
| ID (pk) | Title ... |
I have a very large in memory node tree and need to traverse the tree. Passing the returned values of each child node to their parent node. This has to be done until all the nodes have their data bubble up to the root node.
Traversal works like this.
private Data Execute(Node pNode)
{
Data[] values = new Data[pNode... |
Assuming a list of elements is sorted in ascending order, we search sequentially from the first element comparing the target to successive elements either until we find the target (succeed) or until the current element is greater than the target or we reach the end of the list (fail).
Is Short Sequential Search ever m... |
Going through Modulo operation (the avenue I entered while exploring the difference between rem and mod) I came across:
In mathematics the result of the modulo operation is the remainder of the Euclidean division. However, other conventions are possible. Computers and calculators have various ways of storing and repre... |
I can't remember but recently in one of the APIs I saw something like this class A (member:A){}. Scala does support it and there is no problem creating such a class but how do we initiate it and what purpose would such a class serve?
|
I'm moving over to work on a library that a fellow developer has been writing. It's full of == true and == false, which I find crazy frustrating to read.
I've tried asking him to quit doing it, but he just says that it makes it more straightforward to understand what is going on. Is there a good reason why this isn't a... |
I am writing a simple piece of code. Its a function that allowed the user to withdraw some money. There are some restrictions to this though.
The user can't withdraw more than the given withdraw limit.
The user cannot withdraw more money they that have.
The script will terminate if this happens, and let the users kn... |
How important are to-many relationships in iOS programming? Do you often hold a list of pointers to objects in an array in your codes?
I don't think I fully understand the concept of to-many relationships, let alone how to implement them into code. From my current understanding, to-many relationships holds a list of po... |
I'd like to create an app similar to Barbell Pro for Android, for practice / interest / educational purposes really. Or even as another example for database purposes, Fitocracy
The problem is, I have no idea how the database could be designed... For example:
We have a 1000 Persons using the app
Each Person could ha... |
I can't understand why connection pooling improves application performance.
I suppose connection establishment would cause latency. But reusing an established connection requires more complex error handling. Application server need track state of every connection to set connection to initial state before reusing (such ... |
Let's say you have a list of values that are:
a
b
c
d
e
The order on the list might be changed.
a
c
d
b
e
How would you detect this change? We needed something like this when we were building a revision history page for our online form building tool. We found a quick and dirty solution, but I am looking for a more ... |
I need to fill a form using data from a CSV file. I was planning to use CURL+PHP to do it, but then I realized the form has several steps (one on each page), plus it uses javascript to fill hidden inputs. It is an ASP.NET form, so it has a lot of variables a postback, etc.
I am thinking now, to make a browser extension... |
If my code contains a known defect which should be fixed, but isn't yet, and won't be fixed for the current release, and might not be fixed in the forseeable future, should there be a failing unit test for that bug in the test suite? If I add the unit test, it will (obviously) fail, and getting used to having failing t... |
Well this question is actually asked multiple times here already.
but the answers are contradictory
So that's why I ask it again (maybe time changed things). Can LGPL licensed libraries be used in closed source applications on androids? Specifically, when they are linked together dynamically through .so. but inside a ... |
I am reading Algorithms 4th Edition by Robert Sedgewick and in chapter 1.2 it discusses API design. It says:
"The key to success in modular programming is to maintain independence between modules. We do so by insisting on the API being the only point of dependence among modules."
Now the book is based on Java. I am ... |
If you borrow code from some source, it is probably best to cite it (like "adapted from [source]"). However, if you take let's say you borrowed this function (example in C++):
void doWork()
{
cout << "Doing work!\n" << endl;
}
and now you editted it to be like this:
void doWork()
{
string name = "";
co... |
Scrum master is a facilitator for the delivery team and acts as a bridge between Project Management and the team. In course of time if he realizes that his team is not delivering the deliverables perfectly possible w.r.t competency of his team, can he question his team members why it is not happening?
It is more like a... |
I've provided only simplified code as it's more of an abstract design question.
So I have many, many nested business/domain event objects, e.g.
public class Event
{
//bunch of properties and standard accessors
}
public class ExplosionEvent extends Event
{
//properties and standard accessors
}
And many mor... |
The main benefit of having a potentially shippable product at the end of each Sprint is the ability to release the product quickly in case market conditions change.
However, usually in the first half year or more the product doesn't have enough value to be actually shipped. So why spend all this energy to make a potent... |
I basically have one big gigantic table (about 1.000.000.000.000 records) in a database with these fields:
id, block_id, record
id is unique, block_id is not unique, it contains about 10k (max) records with the same block_id but with different records
To simplify my job that deals with the DB I have an API similar to t... |
I am absolutely miserable when I get in a situation where I have to merge other developers' changes into mine. When using git and working on a really extensive change, that happens a lot.
When I start working on a change, I make a new local branch and start working in it. The intent is to push my changes to the remot... |
Clearly Apple has the ability to create dynamically loaded libraries (known as frameworks) for iOS, as they ship several with XCode (such as UIKit). App developers only have the ability to create static libraries, or at best, trick Xcode into thinking it's loading a framework when it's actually loading a static library... |
Problem
I find myself nailing the class structure down by having too many unit tests which makes making changes hard.
Example
Assume we have a class A which uses classes B1 and B2.
Class B1 uses classes C1 and C2.
I start off by writing tests first for class A. During that process, classes B1 and B2 are created. To ma... |
Since DTMF seems impossible on Android devices, I really wonder how it is possible to setup a direct dail service like Jinggling (http://www.jinggling.com/how_it_works.html). I realize one registers his phone number, but to what end?
Say a customer now dails an international number, the App intercepts the call, rerout... |
I have a class 'Task' which represents any Task that is done by an individual employee. For this class I wrote properties like EmpID, Priority, etc. and methods like AddNewTask(), ArchiveTask(), MoveTaskToUser(int userid), etc.
Then I wrote a method
public List<Task> GetAllTasks()
This seemed incorrect to me with rega... |
I'm learning ruby (and OOP in the process) and I find keep having to write the same patterns when logging progress so I want to wrap this up in a logging library that my other code can then just pass data to - say a string, a file name and a log level. This of course couples the logging library with other code - other ... |
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int n = strcmp("hello","help");
printf("%d\n", n ) ;
return 0;
}
Result:
-1
Does the value for this program have to be the same on all machines or different compilers?
In other words can this return value take on different v... |
My list of the most important criteria is below. What do you think?
The value to the user - naturally features that are more important to the user must come first
Implementation time - the faster it is to implement a feature, the higher it should be on the list
Dependency between features - obviously you can't make a ... |
Working on an E commerce application where we need to send so many email to customer like
Registration email
Forget Password
Order placed
There are many other emails that can be sent, I already have emailService in place which is responsible for sending email and It needs an Email object, Everything is working find, ... |
The current Websocket RFC requires that websocket clients mask all data within frames when sending (but server is not required to). The reason the protocol was designed this way is to prevent frame data from being altered by malicious services between the client and server (proxies, etc). However, the masking key is st... |
I heard many people around still saying Perl is great language for CGI. But i think it is not as much as popular as now growing languages such as Python, Ruby.
Is there any solid reason for Perl still being the appropriate language for CGI.
|
As the title suggests my question is whether or not
unit-tests should be entirely self-contained or can
one rely on the results yielded by previous tests?
What I mean, in case that it isn't entirely clear,
is that if ones initial test sufficiently asserts
that a certain module A works in a certain way can,
or more appr... |
Two questions:
I assume that when Scrum coaches say "the team should decide" they mean there has to be a consensus decision process usually facilitated by the Scrum Master?
What if there is a disagreement between members of the Scrum team on the way to develop/design some feature and a consensus cannot be reached, wh... |
I have a website in which I'm loading all of the users' comments by the number of likes they have. This has caused me some troubles.
Let's say comment #1 has 5 likes, comment #2 has 2 likes, and the rest have 0 likes. We have the following comment id's:
1 2 3 4 5 6 7 8 9 10
Now let's assume someone e... |
I am the single programmer working on a website handling both frontend and backend. Recently in my task list I have to provide a social news feed (activities among friends) which should summarize activities from different modules (at least 7 modules). It has taken at least 20-25 days for me to develop that. Remember in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.