instruction stringlengths 34 19.9k |
|---|
My Question is not about how to use HTTP session or how values are being used in session. Question is more oriented about approach.
In my current application there are few values being stored in the Session and we require those values every now and than, here are few values we fetching from session
Store
Language
Cust... |
In comparing REST [api] structure with a OO model, I see these similarities:
Both:
Are data oriented
REST = Resources
OO = Objects
Surround operation around data
REST = surround VERBS (Get, Post, ...) around resources
OO = promote operation around objects by encapsulation
However, good OO practices do not alwa... |
My team currently use an Ant script to execute various Java programs.
Note that I am not asking about managing the build/deployment cycle for which we are already using Maven (quite happily).
For example, we use something like the following:
<path id="lib">
<fileset dir="path/to/lib" />
</path>
<path id="run" >
... |
I've been thinking for a while about reasons that prevent a lot of programmers — myself first of all — from writing clean, modular and expressive code while developing, for example, CocoaTouch apps.
What I discovered is that my top-three of reasons are following:
UI code. Device-specific UI/UX, general clutter, 'quic... |
I am trying to write a simple program to find the product of two numbers (X, Y) without using multiplication. Meaning that I will only use summation to find the product.
I am trying to use the "Divide-and-Conquer" technique, and am using the obviously known concept that:
5*6 = 5+5+5+5+5+5
Multiply(uint X, uint Y)
{ ... |
In many articles about Rest API's best practices, it is recommended to not depend upon sessions on server side since it leads to a stateful mechanism.
I currently use Play 2.2 framework, with a mechanism that store the data about logged in user in the Play cache (temporary persistent so).
When the user wants to authent... |
Whenever a potential customer downloads a copy of my software they get the "Unknown Publisher" warning message. I understand that if I purchase a code signing certificate this message goes away and the customer does not get the scary warning.
I'd like to know if anyone has information on how effective these code signin... |
Thanks to a question over at Code Review I got into a little disagreement (which essentially is an opportunity to learn something) about what exactly the Cyclomatic Complexity is for the below code.
public static void main(String[] args) {
try {
thro();
thro();
thro();
thro();
... |
The problem that I face is how to combine encapsulating and optimal memory use.
I can't show you my code and therefore explain it on extensive (I hope) example.
Let's say we need to have a database of mans. We want to know only 2 things about those people:
Age of the man (in hours from birth).
Name of the town he live... |
I've recently started looking at Android development. This has brought me back into the world of Java software development. The last time I worked with Java, I'll admit, I didn't understand OOP nearly as much as (I think) I do now.
Having mainly used C# in my career, I'm noticing a startling difference in how inheritan... |
I've done this piece of code for creating bernulli samples, but I think that it is a so heavy algorithm because every time I call this recursive function I create a new vector that is passed to it. Is there a way for making this algorithm faster?
Here is the algorithm and the description:
As already said, this function... |
I'm working on a multiplatform game in Flash. This game utilizes Photon Server for authoritative physics and user statistics tracking. I'm looking to leverage Facebook authentication as an alternative to creating a domain specific account. I'm curious if I can use the Flash SDK for Facebook to indirectly authenticate a... |
What's the database design or business logic for creating an app for messaging between users?
I am having difficulties with choosing how to approach the relationship between each Conversation of User Thread. I show this figure, but it was really hard to grasp the concept
How all this threading message works (like Gma... |
I want to build a time expanded graph with time discretization Dt that starts at t = 0 and ends at t = T where between the node (n1, t) and the node (n2, t') is an arc if and only if (n1, n2) were connected in the original graph.
How can this be implemented in pseudo-code?
The problem I'm stuck on is how to pass from ... |
I have a rather difficult problem:
I periodically receive a Dictionary<decimal, int> subDict containing 100 records where
decimal is a Price
and int is Amount
The outcome I need is a dataGrid showing prices with amounts. But I cannot display subList directly, because sublist is often missing some prices:
subDict:
P... |
I've been working with some basic extreme programming concepts for the last two weeks, for a small scale, for-profit, multiplayer, arcade game. I've spent a week developing user stories and determining requirements to create a release plan. I've also spent a week coding and applying the first iteration plan I came up w... |
I have a big collection of strings a[1], …, a[N] where N is about several millions. I am provided a string m and I need to iterate over all the strings a[i] that contain m. In other words, I need to find all the strings a[i] having m as substring.
What would be the most efficient data structure for that problem? I need... |
localStorage and indexedDB are used for offline storage of data in HTML5. What are their key differences and which one is preferable in what situations?
|
I have designed a generic DAO in Java and am having confusion about whether to refactor it to different design or not.
PS Don't say to use already existing 3rd person framework. I know there are some present but I am learning Java and design patterns so I need all the practice I can get.
If there's any confusion then p... |
I have a requirement where MS Access application needs to be re-platformed to java application.The MS access app has about 45,000 records and 53 columns with SQL connectivity.These record data need to be edited,data used to send email with pdf report attachment.Report is designed using SQL reporting services.I need to ... |
I am having a lot of trouble understanding how to unit test my web client.
I have just finished a project using TDD for the first time - this project hd no external dependencies such as API calls or databases, it was pure C# code. I definitely saw the benefits of using TDD and I would like to continue practising it.
... |
Systems / programs / distributed algorithms / ... are often described with the predicate robust or fault-tolerant.
What is the difference?
Details:
When I google for +robust +"fault-tolerant", I only get two hits, both unhelpful.
When I googlescholar for the terms, I find a lot of papers that have both terms in thei... |
for clarity, code review = a team meeting and reviewing/sharing code
What are the potentially negative aspects of the code review process in a development environment?
What comes to mind for me
Strong criticism can lead to negative interactions and feelings of
animosity between colleagues.
Laziness to read and unde... |
I am working on a website with PHP as backend.
There are things from the front-end which I'd like to accomplish using AJAX calls.
Which of these methods should I use to design them and why?
Call to different PHP files for different uses
Call to the same PHP file, with instructions on what to do
A RESTful API
Any oth... |
I am working on a web application implemented in C#, that follows MVC conventions.
This application contains a page that allows me to create or update a Wingding. The view passes a complete Wingding Model back to the controller for me to create or update.
The problem is that the page also has a checkbox that allows me ... |
I want to sell a simple calculator that will help a certain industry. This calculator would be installed on the computer (as opposed to a web service). How is a registration key mechanism implemented?
|
I have a DB that stores some complex objects of my app. When my app starts I load the objects into list and store them on the RAM.
But sometimes I would like to search for an objects that fulfills conditions (filtering), even the conditions are complexes.
I was always wrote a for loop (sometimes a very complex one) for... |
In my ASP.NET application there is some data that doesn't change often and so there is no point in querying the database to re-check it every time.
In my current situation I am checking user credentials on every request to see if they have access for what they are attempting to do (i.e. view a particular page).
The sec... |
I need to expose an Array[][] to many different clients (iPhone, Android, PC, Unix, etc), and need to make it available over HTTP/s
This brings me to JSON, and makes me wonder how do all the other *endian machines work with JSON and will I need to worry about how the array will be reconstructed on other platforms.
Init... |
So I'm developing this small engine that does a remote integration between two systems in order to sync data, both systems have webhooks for create & update events, and both have APIs (one is REST one is XML), so it is an event-based integration rather than a typical batch one.
My problem is that if System A creates an... |
Don't understand some things about evolution versions of some applications. Please tell me why, for example, firefox 26.0b1 released earlier than 25.0? What it means to "x" version? (5.x)? release candidate (rc)? Alpha? Beta?
|
I am trying to understand the linux kernel and there is one thing that is puzzling me for quite a while. As linux is used across variety of platforms (like smartphones,desktop,supercomputers etc) and also on various architectures,
so does the same kernel code is used by all or a different one and also since it includ... |
I have a model which has timestamped entities. Now I want to do bucketing - "buckets" of entities which can be reasoned about a single entity. Also I want to be able to access related entities from a bucket and get a bucket of those entities.
My main concerns are an implementation of bucketing itself and architecture o... |
I was looking for a dictionary where are described the meanings and purposes of each directory name used in softwares file trees.
I can't find anything except for the Linux FHS, but that is restricted to GNU/Linux OS.
So I would like to ask you something to understand the meaning of the following folders:
/controller... |
Many web frameworks, such as Flask or Django use SQLite as their default database. SQLite is compelling because it's included in python, and administrative overhead is pretty low.
However, most high traffic public production sites wind up using a heavier database: mySQL, Oracle, or postgresql.
The questions:
Assume:
... |
I was wondering how much data should be logged.
I know this deeply depends on multiple factors. But it can still be hard to find the golden middle way.
Lets say I have an application where people can create and administrate a user. Furthermore they are able to create/read/update/delete other objects within the applica... |
I'm asking this question because I believe they did it for a very good reason and that most people do not use it properly, well from my experience in industry so far anyway.
But if my theory is true then I'm not sure why they included the private access modifier...?
I believe that if default access is properly used it ... |
What's the best place for a factory interface to create an instance of another interface?
OptionA: a separate class
public interface InterAFactory {
InterA createInterA();
}
public interface InterA {
void doStuff();
}
OptionB: a subclass
public interface InterA {
public interface Factory {
InterA... |
I have a windows service, 2 web services and a web interface that need to follow the same path (data wise).
So I came up with two ways of creating my solution.
My concern is the fact that the UI/WS/etc will have their own kind of DTO (let's say the model in ASP.Net MVC) that should be mapped to a DTO so the SL can the... |
This applies to C (and probably to any other similar non-object oriented language). If I have a central data store and potentially concurrent access there are two ways I can see of protecting it.
Let's say I have a data store with a few data elements...
struct MyStore
{
int data1, data2, data3, ...., dataN;
} store... |
I read the original text of Apache License, Version 2.0 and the explanation in plain English.
OK, I copy a class distributed by The Best Company in the World, their license, and modify the code a bit.
The original file with my changes.
/*
* Copyright (C) 2011 The Best Company in the World
*
* Licensed under the Apa... |
I have to implement a method to save my game in such a way that I can change the storage medium with the change of only a single variable.
Ideally I'd use an interface to designate the required method signatures and implement that interface with a different concrete class for each medium. For example, one for database,... |
Assume there is a web service which is visible publicly but it must be just responsive to a specific client application. Is there any mechanism to check client side application identity to prevent disallowed application to access the service?
For instance, I have a web service which is called by my iOS application. I w... |
I'm working on an open-source test framework.
90% of my codebase has good test coverage. My main problem area is the command-line entry point. This module began life as a very short script for calling into the domain model (see the call to _run_impl()) and exit with code 1 if the test run failed.
It didn't feel necessa... |
I know very well of the difference of static versus dynamic linking. What I want to know is, when linking statically (with a library like Winmm.lib on Windows), how does the linker "link" the pre-compiled format with the just compiled binary of the executable?
It does not have to pertain to any specific platform, OS, e... |
I am working on a simple API that I want to use for my own client, and to open to the public in the future.
I have "Item" objects which can have different "types". The type is a C "typedef enum", for the moment I have :
typedef enum {
ItemTypeBool,
ItemTypeNumber,
ItemTypeDate,
} ItemType;
(I may add some ... |
I'm taking an Introduction to Agile Software Development course, The instructor was discussing an example about online store and asked us to write the User Stories and the Conditions of satisfactions and one story was As a user I can commit for marketing card that was selected previously in order to buy my goods, the c... |
This is more of an architectural question regarding MVC and Data Access:
We have a custom program that generates all the stored procs and classes for the Data Tier from the MS SQL database. It's pretty nice as it generates a base class with the basic CRUD operations which includes ForeignKey reads. It also generates th... |
Me and a mate have a discussion about what would be the best way to implement the pattern state for managing several screens for an application we are developing.
We have a ScreenManager (I guess the Context class according some books) which looks like this (some irrelevant code has been removed to ease understanding) ... |
An employer I'm interviewing for does this, I have never heard of anyone doing it before and honestly I don't like the idea of being micromanaged. How does the community feel about this?
|
In the Scala community - there is an apparent fascination with the FlatMap function.
Now I understand that FlatMap is significant because it is used for the bind part of a Monad. (and that the Clojure community hasn't dived into Monads yet, with some wonderful exceptions).
Now in the Clojure Community - there is no c... |
I'm about to start working on a V2 of a mobile application and I'd like to adopt a more object-centric approach. Primarily because I think it makes for more maintainable code, but a secondary benefit is easier testability.
V1 of the app is pretty controller-centric. The Login ViewController has its login fields and ... |
I'm reading Sedgewick's book on algorithms in C and I'm looking for an algorithm to evaluate postfix expressions (addition and multiplication only) without using a stack. I tried to implement one but I always get nowhere.
I have a simple C implementation for prefix evaluation
int eval()
{
int x = 0;
while (a[i] =... |
We have a public RESTful web service which exposes functionality to third parties. We are writing automated tests against it. In order to set up all scenarios on it we need to change the data behind it.
We also have a private RESTful web service which exposes functionality to other systems owned by us. However, this w... |
I'm working through an API design where a user's authentication will be verified by the presence of a valid forms authentication ticket in a session cookie. However, there are additional levels of access that can exist for particular resource URLs. When attempting to access those, it seems like returning a 401 would ... |
I've tried to google for explanation but most links only say things like "FRACTRAN is turing complete. As an example, let's look at multiplication."
I remember seeing an xkcd forum post say that FRACTRAN helped the poster understand Turing Completeness. I am looking for an intuitive explanation as to why this esolang ... |
In general I try to avoid using raw types in the signature of methods in the libraries I develop.
However, lately I am starting to relax this (self-adopted) rule-of-thumb, and I am starting to write raw types more often than before.
For example, assuming a method receiving any list as parameter (i.e., the type of the l... |
I am developing a RESTful API in my project, but I do not have experience on that. To fill these gaps I've been watching some videos, mainly from Apigee, which are great.
One situation brings a lot of discussion on my project and I hope you can help me clear it out. The client using the API is able to create a user by ... |
My project involves validating and normalising email addresses in this format
[userpart]@[domainpart].[tld]
After syntactic validation of the address, [tld] is checked to exist, otherwise the validation fails.
After validation, [userpart] and [domainpart] are normalised into a 32-bit numeric ID called [partid] (one for... |
I have the following class with the following function (some implementation details have been skipped):
public class TitleScreen : GameScreen
{
public Texture2D titleScreen;
public override void Draw (GameTime gameTime)
{
ScreenManager.SpriteBatch.Draw (titleScreen, new Rectangle (0, 0, ScreenMana... |
I have a midi file that I'd like to algorithmically add notes to relative to other notes that already exist in the midi file using python, or if it's easier using a different language I'm open to that as well.
So basically, I have a midi file with a bunch of notes, and let's say I'd like to add 5 or 6 new notes surro... |
This is a tiny project of about 2000LOC. It is being compiled with -Wall. Now, I tried adding -Wextra. Two things happened:
Some minor but valid warnings popped up, e.g. Comparing signed with unsigned
Some minor but false warnings popped up, e.g. Unused function parameter.
Those functions implement agreed-upon protot... |
I keep wondering if it is legitimate to use verbs that are based on nouns in OOP.
I came across this brilliant article, though I still disagree with the point it makes.
To explain the problem a bit more, the article states that there shouldn't be, for instance, a FileWriter class, but since writing is an action it shou... |
Am am working on a small project for a USB device firmware.
I started from a working example, and am gradually adding new functionality and testing things. However, the new functionality is not all intended to be used in the final project. I am writing it to learn how to do things on this concrete platform, and fixing ... |
A piece of software is a patchwork of old and undocumented efforts. There are no comments, no documentation, and the code is hairy -- it involves Unix shell scripts that check for dummy files and then call SQL statements that call database procedures that modify data.
The original developers have left and we score a s... |
There is a service:
createUser(User user)
where you can create a new user, with so many attributes (name, address lines...). Now, some user attributes are mandatory. Other attributes are not mandatory (like nickname or image).
The problem is that, from the outside, you can't tell the difference (in compile time). You ... |
I'm currently doing an application design that involves sale of service. The application will ultimately be used internationally and will need to adjust prices based on user location.
Is it a good idea to store / work with all prices in an absolute unit? For example - credits. And I can specify conversion rules like 1 ... |
Suppose I have an array of float values in the following format:
{ 1.34, 1.15, 1.1, 1.2, 1.26, 1.10, 1.20, 1.17 }
Suppose they have been provided by user input (or some other mechanism), where the user takes "1.1" to actually mean "1.01" - meaning that it is separate from "1.10".
Using a standard sorting algorithm (bu... |
I have a function returning an Either such as GetUserFromDb(int id).
If the database is offline, should I catch the error in the function and wrap it in a failure / Left case or should I let it bubble out as an exception as there is nothing I can do and it really is an exceptional situation?
|
I am making a hybrid Android app.
At first I decided to use localStorage, after spending 2 days, I realized that it is very strange and so dropped it.
Then, I picked up indexedDB, after spending today's whole day and actually getting the output in Google Chrome, it is not running inside a WebView of the android app.
A... |
Can IndexedDB be used in offline hybrid android apps?
I have tried the [example presented in this post,1 while it is working in my laptopn on Google Chrome, it is not working inside the WebView in my android app.
The HTML part of the app is loading fine inside the webview but the javaScript part containing all Indexed... |
I'm impressed with the efficiency of some algorithms and I noticed the way the problem is solved can be and/or appear really unintuitive.
It may sound dumb, but I would like to know:
How do the authors come up with amazing algorithms? Do they just keep thinking about the problem and end up with the answer? Are they ge... |
Does using frameworks like AngularJS/Backbone JS/Bootstrap/Foundation etc. automatically make the web application mobile device compatible?
Is there a framework/design approach to make applications (new or existing) mobile compatible?
To put it simply; is there a framework/guideline/library which I can use in my JEE we... |
I'm writing a Java implementation of a card game, so I created a special type of Collection I'm calling a Zone. All modification methods of Java's Collection are unsupported, but there's a method in the Zone API, move(Zone, Card), which moves a Card from the given Zone to itself (accomplished by package-private techniq... |
My work place suffers from a bad case of the Pokemon Exception Handling anti-pattern with constructs like the following splattered across the code base:
try {
...
} catch (Exception ex) {
// Log and pretend nothing happened.
Log.LogException(ex);
}
I've found lots of answers on Stack Exchange sites... |
i have been learning python over the past month or so. i like many of the things about the language, but i find the differentiation between tuples, lists, dicts, ordered dicts, and sets to be cumbersome. i know these each have their own performance benefits and tradeoffs, but it seems to me that it would be far simpler... |
This one is a bit tough. It is publicly available information, is it not? But it's can also be used maliciously. So is it legal/ethical to store and/or gather information on users based on IP? It's mostly for curiosity, but it would also be important for marketing purposes, and maybe something to anonymously post on t... |
The situation
I have code which has features X and Y.
Bob needs access to the code to help develop feature X further.
Normally I would allow Bob to clone the code, but the problem is that feature Y is confidential, so this is not possible. Bob does not need to be able to view feature Y code to develop feature X further... |
In online shops there are areas with complicated rules. For example
is a product visible in the product catalog
is a product sold out
what is the price for the product (Discounts, Promotions, ...)
Is it a good idea to have an additional explanation API for each complicated rule?
Example: boolean isProductVisible() ha... |
Writing tests in single file or writing each test in a separate file?
I have found few advantages of keeping test cases in separate file.
Easy to maintain, better readability, easy to run single test.
There can be 80 to 100 lines of code for every test case including comments. Say if we write 10 tests in a single fil... |
I'm having a play around with emulating a simple old CPU.
I've set the structure up, so far anyway, as follows:
The device is the main and creates an instance of the CPU. The CPU then creates instances of the registers, clocks and MMU.
I'm in the position where the MMU needs to access the contents of the registers, ho... |
I want to create an undo history whenever the user updates a form. Because it's an update, I want to use a PUT request. However, I read that PUT needs to have no side effects.
Is it acceptable to use PUT here? Are there better alternatives?
PUT /person/F02E395A235
{
time: 1234567,
fields: {
name: 'John',
... |
The API has a Throttle on the number of requests you can make. So we queue our requests in a local database and make as many requests as possible until the "Throttle exception" is thrown. Upon catching we exit the program and a scheduled task starts the process over again in 15 minutes.
Is it standard to log this type ... |
I am looking for a simple explanation of the Paxos algorithm that can be used for reaching consensus in a distributed environment (possibly peer to peer network).
Every explanation I have encountered so far was a tough reading of multiple pages. I am looking for a simplified explanation that still preserves the core pr... |
I'm writing my thesis project in GNU Octave. My project basically consists of a bunch of ".m" files that are written in Octave. I'm also using a proprietary (and unreleased) shared library developed by my supervisor.
To be able to access the library, I've written an OCT-file wrapper (dynamic extension for Octave). My ... |
I am a junior developer and have only been in the industry for 5 years. At my current company there is a senior let's call him Infestus. Occasionally I am being given opportunity to shine and do something completely brand new from scratch.
One of the most recent examples was that I had to make a singleton in the multit... |
I mainly use dynamic languages. For many years I see statically typed hello world examples like
const int STACK_SIZE = 100;
And I will think "wow, I can't think like that". I understand memory management, syntax, pointers (mostly). Please let me into your brain for a second and analyze this use case with me.
Let's ... |
I am wondering where should the DB queries need to be in the three tier architecture.
The first association that think is in the DAL. But then if the BL want to search for an object, the DAL need to publish methods for each possible search (Unrealistic - a lot of work).
The second option, is in the BL. But then the BL ... |
A long time ago we added a feature where our users could "Accept" an image after it was added to a workflow queue. Turns out, we used the wrong term, and users actually "Approve" the image.
Changing Accept to Approve on our interface is easy, just replace one word. But we programmed all layers with the word "accept", f... |
I have a reservation table (a user fills out a form to request a reservation).
It has two parts that need to be confirmed. isReservationAccepted (decline,accept,waiting) and hasReservationBeenSent (sent, declined, waiting)
Not sure how to structure my table, thinking about making a lookup table for each column, or mayb... |
I know that there are a number of discussions about the GPL on this site but I just ran in to an interesting case of apparent misuse that I (surprisingly) haven’t seen discussed anywhere.
The CFEngine configuration management program is apparently distributed under the GPL (it even appears to be an FSF project) but the... |
Related question: How do I cache data that rarely changes?
I'm making an ASP.NET MVC4 application.
On every request the security details about the user will need to be checked with the area/controller/action that they are accessing to see if they are allowed to view it. The security information is stored in the databas... |
public final class ImmutableClass {
private StringBuffer name;
public ImmutableClass(StringBuffer name) {
this.name=name;
}
public StringBuffer getName() {
return name;
}
}
Points that I have considered:
Make the class final so that it cannot be extended
Do not provide public mut... |
Are there any scenarios where we should not write defensive checks for null?
Should we write defensive code or check for NULL every time we have passed a parameter or received a value back from a method?
Will this put an extra burden on the compiler?
|
My application has user controls within user controls. Please see a screen shot of one of the most beautiful applications of all time (UC = user control):
All the properties live in the MainWindow code behind, there are none in my UserControls. To bind to my properties I use
DataContext="{Binding RelativeSource={Rel... |
I've been delving into more "organized" programming recently and I've been learning that I should be programming to an interface, not an implementation. With that in mind, would it be better to "sketch" out a project in interfaces before writing the implementation for it where possible?
And if this is the case, in the ... |
I hear a lot that you should not write functions larger than one screen size, that you should extract things into functions if you call things very often and all these coding guidelines. One of them is also keep your indentation level low. Some people told me even I should max indent 4 times.
But in every day programmi... |
If I built some useful piece of python code to e.g. scrape a website or to calculate something big, at some point I might want to add a GUI to my project. For this I could use Tk, Qt, Pygame or any python graphic/GUI framework.
Now I also want this tool to be usable by clients without the need for a python installatio... |
This is one of the questions that I came across while preparing for a programming interview.
Design a system for Greek philosophers to exchange messages using stone tablets carried by dumb slaves.
Well, the guys who had this question have suggested to use analogy of a TCP/IP protocol to describe the communication a... |
I am still learning python and I started with Python 3. This question not Python 2 vs 3 or difference between them like print() is a function and not language construct and 3/2 = 1.5
My question is even if it is still python, what was the need of introduce something new which is not backward compatible, when -
Syntax... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.