instruction stringlengths 34 19.9k |
|---|
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... |
Whilst I have good experience with OOP, I'm fairly new to the concept of (H)MVC. I understand the basic concept of modular design that comes with HMVC, it's the great attraction of it. But one thing that has been bugging me, and will hopefully help me understand HMVC better is how do you handle the database connection?... |
I have multiple regexes matching an input in greedy-first mode. All regexes are already compiled and I don't see what I can do more to speed-up things. I mean using tools coming with .Net framework.
Since I don't do any replace, or capturing, I wonder if it makes sense to built my own regex matching -- in result I woul... |
Some friends and me wish to develop a 2D game just for the experience of learning this paradigm. We are all software engineers with experience in business apps, but we are unsure if the typical design patterns and architectures (MVC, 3-layer, etc) apply as well, and we are totally unknown about the techniques that are ... |
I am creating an application with lots of photos. They will take > 100 mb on memory. So far I have 3 ideas:
Place it in @drawable - app will be heavy
Download by JSON and place in java array - caching - How long it can be there?
Download by JSON, place it on phone memory/SD card and read in the application from memo... |
I'm planning the creation of a webapp with a dedicated mobile web interface and a dedicated desktop/tablet interface.
I am considering ASP.NET MVC, but it is clear to me that MVC is for separation of concerns as explained here, anyway in my case i'd like to minimize the code and to support elegantly phones and desktop ... |
At a previous job (circa 2010), my manager mentioned that he's doing some research into quality metrics. The bottom line is to answer the question how many bugs should I expect? The goal is to try and predict how many bugs are incoming, and more importantly, how many bugs we probably haven't yet found.
There are some p... |
I am working on some C++ code that uses several libraries, including some C libraries, that all have different coding styles. It will be open sourced once it reaches a usable stage. Which would cause the least confusion for a short-term contributor who checks out the code to fix one bug or add one feature?
Have one ... |
I am developing a CRUD type web application. It is a project management system having projects, milestones, tasks, employees etc. Each employee has his/her own account to login and view the system. The problems come here:
If one user deletes a task while the second has it opened at the same time, the second user will ... |
I recently came across an internal project where they were using DTOs throughout the solution, and when I sat down to implement a new MVC controller with a JSON REST endpoint I decided to use an anonymous object convention instead of declaring a discrete DTO class solely for the purpose of this API endpoint.
public Jso... |
General, high-level question for people who work with code regularly.
I was repurposing some old, outdated Javascript code into a Chrome extension, and to help me understand it, I wrote some quick code to help (see below). I regularly put messages in my code such as dbmsg('Begin function loadDefaults()'); or dbmsg('Se... |
On my form I have an icon which represents whether my entity is locked (shown by a locked padlock) or unlocked (an open padlock). At the model level, this is represented by a boolean property (isLocked). The user can toggle the entity between locked and unlocked by clicking the icon. This also updates the icon tool-tip... |
TLDR: Should TIMEOUT be a public property on my static class, or a parameter to every function?
Background:
I am releasing a c# client-api library that facilitates communicating with our REST api.
The client-api consists of an object model and one large static class with a bunch of request extension methods for variou... |
I am trying to put together a way to figure out if incidents occurred based on log content. Typically, on log (or DB table) would contain a list of transactions composed as follow:
{Timestamp} {TransactionID} {Message}
As an example problem I have run into, I used this to detect if "incidents" occured by running some v... |
By loop constructs I mean for… and while… constructs with nested statements.
Currently I am coding a tool in Python and decided out of curiosity not to use the regular loops - and rely on filter/map/reduce instead. E.g. now I have code like:
fields = filter(None, map(parse_field, struct_decl.get_children()))
So far it... |
I will have international users use my database, but I don't know how the mailing system operates outside of the US.
Are the concepts "City", "State, Country and possibly "Zip" sufficient to capture any hierarchy (even if it was only 2 levels deep: (city/country)
|
How do certain services, just like google plus and facebook, check for new content without reloading the page? Whenever you are on any of those websites a new notification of a post related content just pops up without the need to refresh the page. Can someone give me some tips on how this works? :)
|
Should user permission checks take place in the model or the controller? And who should handle the permission checks, the User object or some UserManagement helper?
Where should it happen?
Checking in the Controller:
class MyController {
void performSomeAction() {
if (user.hasRightPermissions()) {
model.som... |
I'm curious about how to test reports that seem rather straightforward. I'm supposed to create test cases for an Oracle report(XML Publisher/BI Publisher). So for example, a report is supposed to just return columns(say , 10 columns).
Here is what I thought of so far:
Validate that the report returns accurate output... |
I know so little about this that I'm having trouble formulating the question.
Apparently due to technical limitations, nastaleeq style of writing Urdu is very difficult, perhaps impossible, given current standards used on the web. I'd like to do a deep dive into why this is so (the technical aspects, at least).
My, ver... |
We are using PHP (a dynamically-typed language) in our project. However, I have found my colleagues asking questions such as https://stackoverflow.com/questions/20438322/modeling-a-binary-relationship-between-two-types.
I’m feeling like we have a paranoia that we are going to get unexpected errors (E.G. if you look at ... |
I started working on a new project lately related to Big Data for my internship.
My managers recommended to start learning functional programming (They highly recommended Scala).
I had a humbled experience using F#, but I couldn't see the the important of using this paradigm of programming as it's expensive in some c... |
I'm hunting a metric to measure the cost of cut-and-paste programming. We already use tools to detect duplicated code - but if we don't clean up our duplicated code, how much will it cost us?
We know that the DRY principle, Don't Repeat Yourself, is a core principle of Extreme Programming. How can we actually measure ... |
I understand the concept and can use both the Factory Pattern and Dependency Injection, however they seem a little at odds with each other conceptually. Is it a case of using one over the other? Or can they be used in conjunction with each other?
If using DI would you hard code the creation of classes within a Factory?... |
This is one of my assignment for this semester. And just to be clear, this question is not about the answer to my assignment as I have already finished it, it is more about the sanity of the question
I am confused because as I know from the textbook, ATAM is a software architecture evaluation process which has multiple... |
I started learning functional programming, I am trying to compare between different algorithms that are written in an imperative, functional , parallel programming and using Collections and Lambda expressions.
In order to make my question clear and avoid sharing long algorithms that I am working on. I will take as an e... |
I normally construct my search tree by following the common convention:
Place Queries or Goals in need of unification inside node boxes.
Write down decision points on the edges, where Prolog has assigned an element to a variable.
Leaf nodes which are fully satisifed will be an empty box, they represent a solution.
Lea... |
What's the OO principle that states (in sum):
A base object should have no knowledge of its subtypes.
I thought it was Liskov Substitution but after reading that wikipedia article I don't believe I'm correct. Thanks in advance!
|
I have a small responsibility separation issue that I hope someone can clarify. I have a small model composed by 2 classes: GameBoard and GamePiece, and the obvious relationship is that a GameBoard can have several GamePieces.
In the application I'm implementing, GameBoard and GamePiece contain data related to renderin... |
I recently purchased a product (a website template, licensed by GNU GPL 2.0). My product, which is a web software, coded in PHP, uses that web template as its appearance.
The question is: How can I sell a software which includes some parts of a GNU GPL 2.0 commercial website template? Do I have to pay a license for the... |
Why does Mono for Android cost money if the mono project is opensource and therefore everything based on it must be opensource?
|
I was reading Cohen–Sutherland algorithm on Wikipedia and I am confused in these two parts,
int ComputeOutCode(double x, double y) {
...
if (x < xmin) code |= LEFT;
else if (x > xmax) code |= RIGHT;
if (y < ymin) code |= BOTTOM;
else if (y > ymax) code |= TOP;
...
}
and
if (outco... |
I have just realized something disturbing. Every time I have written a method that accepts a std::string as a paramater, I have opened up myself to undefined behaviour.
For example, this...
void myMethod(const std::string& s) {
/* Do something with s. */
}
...can be called like this...
char* s = 0;
myMethod(s);
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.