instruction stringlengths 34 19.9k |
|---|
In several of our company's applications, we use a custom logger. It's fairly robust, though we may replace it with something like NLog in the future. One of the logger's tasks is to log any exceptions encountered in the application.
One concern I've always had is that the exception handling within the logger allows fo... |
Martin Fowler recommends replacing exceptions with notifications when dealing with validations. Essentially, instead of throwing an exception, you append error messages to a Notification object that gets returned. This allows you to keep exceptions to "exceptional" circumstances, and return all the validation informa... |
I'm developing a business-to-business SaaS.
I expect that most of my customers will be able to use my mainline product, and I intend to deploy it in an independent instance for each customer. Some low-demand customers may be sharing a VPS node with other low-demand customers, others might have dedicated deployments, bu... |
What is the searching algorithm used in switch statement in C language?
If the cases are not in order still it searches proper case which means it is not a binary search algorithm, can anybody explain?
|
I am programming a game. In this game I have 3 stages. In the first stage, there is a static goal and a static shooter in the game. In the second stage, the goal will move. And in the third one both are moving.
I want to use abstract factory to create objects of same family.
I want to know which of the following design... |
I've been learning HTML5/CSS3 for a month now, and I've built my first demo website. At first I was using a lot of the element selectors like: >, ,, + in combination with the type names for selecting nested tags.
Now I've moved more to the id and class selectors and use the >, ,, + less often for selecting nested tags.... |
I run a development team that recently started using Jira and we began using agile scrum. I'm curious about a certain aspect of backlogged issues.
So far I have been marking new issues as unassigned until the issues are actually assigned to anyone. Most of the time this process is done during the sprint planning meetin... |
Here is algorithmic problem I'm trying to solve:
Given a list [x_1,x_2,...,x_n] return a permutation of elements of the list [y_1,y_2,...,y_n] (where for each i we have y_i = x_j for only one j) which maximises the sum from k=1 to k=n-1 of |y_k-y_(k+1)|.
So to make it simpler - we get a list of integers and we need t... |
I have about 5000 lines of code which manipulates a large array in C++. The problem is that when I try to make the array even larger i.e. A[10000][10000], the gcc compiler throws me a segmentation fault error.
I believe the solution is to change the array to a dynamic array. Is it possible to do this by only changing t... |
I read So Singletons are bad, then what? which was a great explanation of dependency injection as the solution for inversion of control. The asker assumed singleton and single instance were synonyms, and as others pointed out singleton is a more restrictive example of single instance.
My question is, why did the respon... |
I am writing a class which basically is a wrapper around a dictionary with some extra functionality. This dictionary is stored as protected member _store. Now I am writing a __eq__ method to compare objects of my class. The criterion is, if the underlying dictionaries are equal, the objects are equal, therefore the eas... |
This question is raised with a clarification required to decide when to declare a method protected or public during class design of a package.
My point is, if one needs to override a method of a SuperClass then make that method access level as package private or protected in SuperClass but do not give access level publ... |
Say I have a function taking three arguments:
a symbol (an alias for a class, method or function name)
a mirror/reflection of a specific object
a mirror/reflection of a class in general
is there a how-to (e.g. for certain languages or libraries) to sort things in function calls to keep an API consistent?
|
I'm modelling a Filter class that stores the options for filtering a search. Some of the attributes are multiple choice.
For example, if you are filtering hotel rooms you have a Price attribute that can take these three values: Best, Average, High. You can choose many values at the same time. In an UI would be represe... |
If I have a normalized db, it's unlikely to map 1 to 1 with my domain entities. So I customize my EF entities to fit the domain. But now my EF entities are essentially my domain entities and my DAL is baked into my business objects.
On the other hand, if I let my EF entities map 1 to 1 with the db tables, I don't get a... |
Is it some kind of bad design to have something like this:
public interface IFooStream
{
long Length { get; }
long Position {get; set;}
//...
}
public interface IReadableFooStream<T> : IFooStream
{
int Read(T[] buffer, int offset, int count);
}
public interface IByteStream : IReadableFooStream<byte>
{... |
Let's say that I have 2 classes: Foo and Bar.
`Foo` {
List<Bar> bars
String bippy()
int boop()
}
`Bar` {
int biz()
String baz()
}
Observe that Foo's fields include a List<Bar>. Note that Foo has separate fields from Bar, but they share some fields.
Let's say that I have a method, f.
def f(Foo foo) {
...
}
T... |
Every VCS that I've seen includes a means (and sometimes requires you) to make a log of what a particular commit does. If this history is being properly kept, what is the purpose of manually keeping the same history in a regular file?
Note that I'm not positing the changelog is useless, I just don't see a use for it m... |
Background:
I have a rough, but working understanding of ~15 design patterns. It's been my experience using design patterns in my own projects that the resulting implementations usually end up as some variant of a pattern and don't always fit the canonical textbook examples.
Case:
I find it useful to leave tag-like com... |
When delivering a product, Release notes clearly contain known issues found by customer in the previous build.
But should we include defects that we, as a supplier, found during our testing, those unresolved and hence present in the build?
I mean, it makes sense to me but I would love to know what more experienced peop... |
The Steelman language requirements have this:
The language shall require some redundant, but not duplicative, specifications in programs.
I think I can see the underlying idea (that re-stating things may lead to fewer errors given the limitations of human cognition), but I would like a more detailed explanation.
What... |
We build a system which works as software as a service. Now I am wondering if it is needed to give the version number to the clients. For example Facebook doesn't give a version number neither does Google. My question is basically would one include version numbers in an application where the client cannot change the ve... |
int a = 1;
int b = 2;
int sum = a + b;
string expression = "Expression: " + a + " + " + b + " = " + sum;
Console.WriteLine(expression); //displays Expression 1 + 2 = 3
Should I use:
string expression = "Expression: " + a + " + " + b + " = " + sum;
or
string expression = "Expression: " + a.ToString() + " + " + b.ToStr... |
Question:
The software industry's consensus is that clean and simple code is fundamental to the long-term viability of the code base and the organization that owns it. These properties lead to lower maintenance costs and increased likelihood of the code base being continued.
However, SIMD code is different than general... |
I have some DAGs (directed acylic graphs) and I want to merge them in order to minimize the number of nodes (we could say that every node has a cost, while edges are free).
These four different DAGs (directed from left to right)...
a-b-c
a-d-c
a-c
c-a
...should become:
/---\
a--b--c-a
\-d-/
This is not a real DAWG ... |
I was wondering something about the multidimensional arrays and then I got a doubt about a concept, specifically about their representation on memory.
For example, an array can be defined as follows.
int a[3];
And this is represented as this.
Where each element is an int and all of them are in a continuous memory spa... |
Lets say I create an abstract class that manages some network functionality for me.
I want to be able to be notified when something changes. For example: OnConnect or OnDisconnect.
Should I create events for those kinds of functions or implement them as abstract methods?
public event OnConnectDelegate OnConnected;
or:... |
So, I've learnt about how GC works and how can I monitor it via VisualVM, but my question is about why we should ever perform GC optimization? In our web project (JSF/Spring/Hibernate) we haven't thought about this kind of optimization. Isn't it important and where such an optimization may be important?
|
I worked in a company where they tried to use Scrum but in practice it was hard to create a solid sprint backlog because they had a very active userbase, that used the software 8 hours a day, and because of that, reported many critical bugs that needed immediate attention.
This made me wonder... What is the best way to... |
Spoiler
My question is the following: Are there any design patterns for representing chainable functions that are for the problem described below?
High-Level Decription of the Process
I'm currently building an image-processing server, whose functionality is exposed via a web API.
Client Behavior
Clients first authenti... |
According to DDD domain logic should not be polluted with technical concerns like serialization, object-relational mapping, etc.
So how do you serialize or map the aggregates' state without publicly exposing it via getters and setters? I have seen lots of examples for e.g. repository implementations, but practically al... |
The closed source commercial software (CSCS), will just make system(3) calls to GPL applications.
The user machine will run CSCS and it will call these GPL applications, in realtime, in the very same way a user could use the command line and call the very same applications. Even a log of such actions could be provided,... |
The context: For all intents and purposes, I feel like I'm about the level of a pretty competent second year student at computer science. I have taken all the basic algorithms and systems classes; my C is pretty good, and I can even read disassembly with a bit of effort. OOP. Algo. P vs NP. Let's call this the "old sc... |
I have a data structure with data units containing different types of data. I've wrapped the data in "Field" objects so that each field is able to independently parse user input in a desired way.
public abstract class<T> AField {
protected T value = null;
public T getValue() {
return this.value;
}... |
I'm building an MVC .NET website where people can rate and review movies (similar to IMDb). I'm using SQL Server for the back-end.
I'll be implementing a feature where the homepage displays trending movies, i.e. movies which have been positively rated within a particular time-period (let's say last 7 days).
I'll be us... |
What are technologies like XML, JSON, and YAML classified as?
I already looked at
Query Language
Data-structured Language
But neither appeared accurate... None of them are really meant for creating queries. And JSON isn't a language, so DSL doesn't apply.
I see those technologies used a lot with configuration fil... |
In the context of a single-purpose website/application (for instance, based on Symfony2), I wish to have a set of forms fillable by users which then will be sent out as a formatted email (with the same labels as the forms on the website.) It is unlikely that they would need to be updated, although new ones may be creat... |
I'm working on integrating a reorderable lists UI widget with a Meteor.js (MongoDB, in effect) collection:
{
order: ???, // what type to use here?
property1: ...,
...
propertyN: ...
}
Each document in the collection has an order field. The UI gets the collection from the server, sorts it by the order field, a... |
I am sorry if this question isn't appropriate here, but this made me confused.
But what I read in MPL 2.0, any software derivated from a existing one with this license should keep it under such license.
Then my question is:
Is the PirateBrowser violating mozilla's license since there is no indication of the source an... |
The general consensus seems to favor the Crash Early approach, the most reputable source being the acclaimed Pragmatic Programmer book.
And while I understand and agree with the advice in many situations, I wonder if once the program is deployed in production, isn't it also valid to simply log a warning and proceed the... |
Of course the answer to the question above is, "you can't". But I didn't have a better way of describing what I'm looking for. If I did, I wouldn't be asking this question.
My problem stems from a C# project but I'm pretty sure it applies to other languages as well. I have an interface definition like:
public interface... |
A few years ago there was this hacker (don't remember who he was) that full disclosed a vulnerability in a given system, but to make sure nobody took credit for that, he created some kind of PGP key.
What I understood at the time is that he created a key to ensure he was the one who discovered it, but didn't disclosed ... |
I want to start a new HR web application based on asp.net mvc-5 & Entity Framework. as it is almost the case Users inside the HR system will exists inside the AD, and when a new user join our company we will create a new user inside the AD, then the HR dept will add the user to the HR system. but my question is how i c... |
Well, this is not specific to any programming languages. I came across this situation in Android, iOS, PHP and .NET.
The problem is many times I come across a situation while building IoT apps, where I need to call a webservice (each in a separate thread) which does the insert into DB (probably more than 20 - 50 insert... |
This is a generic question about using anonymous functions as arguments to other functions. I give an example in Python, but the question is not about Python (and I'm particularly interested in whether answers might be different for functional languages than for other paradigms).
In Python it is common to pass an anony... |
I'm implementing a feature in legacy system right now.
Instead of putting all my logic in some dummy application services and having anemic models, I thought I will try to do some OOP this time.
I'm not using DDD, but trying to follow DDD-like-style a little bit.
So imagine a situation where you have:
public class Cus... |
Sometimes I have a function that takes a System.Type parameter, like:
public void Foo(Type type) {
// do something with "type"
...
}
This must be called like this:
Foo(typeof(MyType));
I would like to rewrite it like this:
public void Foo<T>() {
var type = typeof(T);
// do something with "type"
..... |
I'm quite new to the field. So I need to clarify what would be the best method to follow in the following situation.
I'm developing a restful API using php and use json to represent resources. While I'm at this I read it's considered to be a good practice to conform with "HATEOAS" (is it?). So I wanted to use something... |
I have an Invoice object wich may contain several FacturedServices objects stord as a list.
In may interface, the user can edit an Invoice object, delete add or edit its FacturedServices list.
Whe the user hit the save button, the updates made to Invoice object should be passed to the database as well.
The problem is ... |
I just had a phone interview for ASP.Net developer, after initial introductory stuff the interviewer ask me first technical question:
"How would you store 5000 elements on client side for each user in a web application".
My answer started with,
What is the average size of each element ? Do we really have to store this... |
Should you add logging to common libraries that are used in many applications? For example, if I have a parser that's used in multiple apps, should I add logging inside the parser? My concern is that it couples all users to the logging framework.
I'm particularly interested in solutions for shared libraries that are us... |
I'll use C# to design the model to be persisted
Let's suppose I have the following entity:
public class Episode {
public int Id { get; set; }
public string Title { get; set; }
public string Image { get; set; }
}
This a very simple entity, which is easy to map to a relational model.
But, what about if I ... |
I'am the only one in my team who advocates for adding a little implicitness in favor of codebase reduction and decreasing repetition. Yet I don't want to be a biased 'Bad apple' playing against working design which was created prior my arrival at this job. Attempts to change the approach can be taken too personal by so... |
I am using the Accord.Math Namespace for Visual Studio in c#.
I am trying to use the method MeshGrid<> under the Matrix class for the Accord.Math namespace. However, I am unsure how to implement this method even after reading the documentation for it seen here:
http://accord-framework.net/docs/html/M_Accord_Math_Matri... |
A very general question. I was thinking about method chaining, which seems useful, and began wondering if there is a reason to not return the object in a class member, as a matter of course.
For instance:
function doStuffAndReturnThis() {
/* Does Stuff */
$this->variable = $stuff;
return $this;
}
I suppose... |
I have a basic (mathematical) vector class, which in my opinion benefits from C++'s operator overloading. Vector-scalar operations are defined as self-modifying functions in the class itself,
class Vec3i {
Vec3i& operator+=(int const n) {
for (int i = 0; i < 3; ++i) {
_data[i] += n;
}
}
std::array<i... |
I'm currently in development of an application that consists of two parts: PHP files that a user uploads to their own server, and a smartphone application.
Because the PHP files are going to reside on that person's server, I thought it would be beneficial to everyone that they might as well be open-sourced (Mozilla lis... |
While web-programmers surely know CSS/HTML rules by heart, and web-browsers have algorithms to render web-pages, what interests me whether there are any mathematical/theoretical models or at least formal specification languages for web-page layout ("physics", "geometry") allowing to generate bullet-proof html/css given... |
Is it considered decent form to write code like this:
int done = 0;
for (x = 0; !done; x++) {
... something involving 'x', that might end early ...
if (!(x < max))
done = 1;
}
as opposed to having to use a while loop:
int done;
x = 0;
while (!done) {
... something involving 'x', that might end e... |
In most of my code nowadays, I adapted to an approach which I think I read in the context of "Clean Code". It was some years ago and I cannot find the source again, so I would like to know what the name of this pattern really is (and if it's even a pattern).
The approach is so simple, yet powerful that I am baffled as ... |
I have been dappling in C# after coming from several years in PHP.
I don't find the language particularly difficult, although there are considerably more constructs for me to get used to.
My question is to help me change way of thinking when using C#. More specifically, to help me think of solutions in a static langua... |
Qt is a graphic framework which has a double license:
commercial (statically link and modify at your wish)
LGPL (you should either dynamically link against it or release your source code, any modification should be released under GPL)
If I create some Qt-based controls for an application that can link dynamically ag... |
I suspect that I'm focusing on the wrong problem so I will first describe what I think the problem is before presenting the possibly suboptimal solution I envision.
Current Situation:
Currently my co-workers commit their code changes only after loooong periods of time in huge chunks with changes spreading all over th... |
O/C principle dictates that production code should not be changed if system behavior augmention is required. Otherwise it becomes hard to trust tests.
Following it as a dogma we are going to end with either deep inheritance trees or aggregations.
On the other hand we never tried this approach so the former statement is... |
We were having a discussion at my work about the use of enums in Java.
A coworker was arguing that when using enums on the server-side, whenever required we should use string to reference to it (for instance when sending data from JS to the server or when storing in the database), arguing that this is much more cleare... |
Recently, I came across a problem that required me to define the logical "OR" operator programmatically, but without using the operator itself.
What I came up with is this:
OR(arg1, arg2)
if arg1 = True and arg2 = True
return True
else if arg1 = True and arg2 = False
return True
else if arg1 = False a... |
So, I understand Continuous Integration in theory, and have used Beanstalk. However, I've been charged with creating the process at my current PHP shop.
My hope was maybe PHPCI, since it looked perfect, and I'm a bit out of my depth. However, it turns out we will have to maintain a Java application.
Currently, we hav... |
Our company implemented a calendar system a few months back with recurring appointments, using iCal strings to store the recurring appointment criteria.
We are starting to run into performance problems because of these.
Our current thinking is something along these lines...
A user requests all appointments for a date ... |
I am taking the front-end role in a project. Should I be specifying for my back-end teammates the exact format of JSON that their PHP returns to my JavaScript?
For example, should I be telling them they should use a format similar to one described here:
Proper way to structure JSON for front-end consumption
Or should ... |
I think this question is specific to indie developers be concerned about. Think about it as a "license clarification" or a "license practical use case".
I need to know how must be my project basic packages structure and how can I distribute it?
I am an app developer, I have no site yet, I will just create the code (pac... |
Is it alright to use CSS3 with HTML4. It seems like CSS3 would be a HTML5 complaint deal. But I'm not sure if that's the case.
If it's not okay, what are the downfalls to using CSS3 with HTML4, opposed to CSS3 with HTML5?
|
So there is physical and virtual memory. Let's say we have 10 MB physical and 10 MB virtual.
There is also paging. As far as I get it, paging basically splits physical and virtual memory into slots of the same size. Such slots are called frames. So if we use slots of 1 MB, we will have 10 frames in physical memory and ... |
I am in a project where we want to componentify a lot of "information boxes".
These boxes (lets say they are mostly different types of tables) should easily be included into different pages and even different projects(we include the components as a library into an angular js project, so angular js a requirement). In th... |
I've recently come across an application by Yahoo called SmushIt. Apparently it does lossless compression on images. Sometimes the image size is reduced by as much as 90%. This of course has major implications when working on the web since it greatly improves performance on pages that have a lot of images. Now I'm sure... |
I was looking for the idiomatic way to implement thread-safe lazy initialization for a configuration collection retrieved from the DB inside a Spring bean.
I decided to adapt the initialisation-on-demand holder pattern as follows:
public class Security {
private static ParametersDao DAO;
/**
* Initiali... |
Is it better to use List<string> in type annotations or StringList where StringList
class StringList : List<String> { /* no further code!*/ }
I ran into several of these in Irony.
|
tl;dr: What is wrong with the efficiency of methods such as .append() and what can be alternatives to this?
Explanation:
Hello everyone. I occasionally have to build A/B tests for websites, which means that i have to change sites using only jQuery(or javascript of course) to alter appearances and functionalities of web... |
Why would you use an enum to create a singleton pattern?
To what purpose would it serve over a conventional singleton pattern?
I have seen the above used. The code uses an enum to create this pattern without benefit. It confuses the situation as the enum is not used to store a "set of named integral constants" but simp... |
I have a REST service producing JSON and consuming JSON.
A lot of this are simple CRUD operations. My initial idea was to simply use the DAOs directly in the controller:
@ResponseBody()
@RequestMapping(value="/cars/{carID}", method = RequestMethod.PUT)
public Car saveCar(@PathVariable Long carId, @RequestBody Car car)... |
I'm unsure of REST best practise in the following scenario:
GET /Customer/23 = returns Customer = OK
GET /Customer/23/Orders
In the second request should a Customer AND the Orders be returned, or should just the Orders be returned?
|
Suppose I have two entities author and post, were every post has an author.
Implemented are these REST calls
Get a paginated list of posts: GET /posts?page={page}
Get a list of authors: GET /authors
Get a single author: GET /authors/{id}
Suppose I also have a client using the REST service. This client wants to show ... |
I wanted to create a class CompileResult, that can be treated like an Either type but has some additional useful methods. It should be a CompileSuccess or a CompileFailure (which, too, has some extended functionality). However I can't do that because Either is an abstract class and I don't want to extend it but rather ... |
I am developing a server-side JavaScript tool, and trying to do so in a modular way.
I have a Parser class that is an EventEmitter - you call parse and it will eventually emit data and end events. It is generally invoked like so:
var parser = new Parser(options);
parser
.on('data', handleData)
.on('end', handleEnd... |
On a recent project, I needed to convert from bytes to kilobytes kibibyte. The code was straightforward enough:
var kBval = byteVal / 1024;
After writing that, I got the rest of the function working & moved on.
But later on, I started to wonder if I had just embedded a magic number within my code. Part of me says it ... |
So I see on a lot of people's resumes they list AJAX in their technologies (or programming languages - and I recognize that it is not a language). To me, AJAX seems like such a small concept to be individually listed. It seems it is almost as useful as listing MVC experience (because MVC too is a concept), which is goo... |
I'm writing a program that needs to test if a file is equivalent to one or more other files. To accomplish this, every time we see a new file we stat the file and get the size.
We use the size as a key and if we've never seen the size before than we know that's a new file.
If we have seen that size before we were plan... |
I often want to publish some useful standalone script - e.g., a matlab script which converts flac files into wav files. If it were a big project I would immediately place it in Github, however it seems weird to make a repository for a single file. I could group this script with other scripts of the same subject (e.g., ... |
My instructor told us that some programmers are not using SDLC methodologies for making a system. Because in our project, we used one of the methodologies. If we do not use one of them, maybe our system will not work.
How does what I'm learning now relate to what I can expect in my future life as a programmer?
How comm... |
I've been toying with the idea of feature toggles for various configuration/access purposes, but have been a little unsure of myself when it comes to toggling something like a downtime or maintenance mode, where users should be unable to access anything during that time.
It seems like such a simple thing to do implemen... |
For large legacy C++ code bases, notions like Herb Sutter's "const means threadsafe" don't seem to help much, because there can be an overwhelming amount of code in const functions which are modifying state with no synchronization. And even if legacy code wasn't a problem, for a class like a ThreadSafeQueue, you would... |
I am a freshman college student currently learning C++ programming. I am good at math and physics, so I am looking to specialize in 2D/3D graphics with OpenGL. My question is about the differences between OpenGL and OpenCV, and the amount of overlap these areas have. From what I have read, one creates graphics while... |
Learning about virtual memory with an program assignment. Currently this is what I have:
Main memory has 60 bytes and virtual memory another 60 bytes. The size of a frame/page is 10 bytes. So there are 6 frames for main and 6 for virtual memory.
I have a process that uses 40 bytes, so it needs 4 pages. By assignment sp... |
I have a number of worker threads which all perform a flood-fill task on different regions of a bitmap. They all make calls to a recursive sub-routine with different parameters(coordinates). Fyi, I am using a scan-line method.
I have implemented a reset feature which aims to kill these processes so that they would star... |
As per this link, this is the xml that maintains "BookStore" data.
I see that number of occurences of author are varying for any book.
xml's hierarchical representation of BookStore looks more meaningful/intuitive for me to visualise the data unlike relational table tuples. It is rather more difficult(kind of tweek) to... |
We are developing an application using Domain-Driven-Design(DDD).
We have to come up with Automated UI Test code.
The customer has used 3rd-party GUI Administration template (https://bootstraphunter.com/smartadmin-product.php) so that the GUI can be configured for the most part using the aforementioned 3rd-party tool.
... |
A lot of times, I have long forms that I divide into multiple tabbed sections. Each section is managed by it's own controller and there is a parent controller that manages the whole view. I use ui-router for dividing such sections into states.
Should I make a service instead of a controller to manage the all the sect... |
Is it good practice to have multiple test cases in one test or should I always create one test for single test case in every situation even if it is redundant? Why?
|
I'm currently working on a service that is supposed to aggregate data from a number of APIs, unify the data, and offer it through another API to the users. I had a couple of ideas for solving this, but I'm not confident my best solution is the best possible solution.
Solutions I considered:
Let the browser poll our AP... |
I do not think so, yet many sources say it is.
As I understand it:
Context-driven testing means that when planning testing on our project, I choose the methods, practices, etc. in order to fit the context. I choose the approach
While exploratory testing is a just a method of testing, where testers explore certain par... |
To me - if you're pair programming - then you don't open your email, or you decide you're cool with the other person looking at it.
I've worked with a person who looks away, and expects you not to look when they look at their email. I'm not familiar with this "code of practice".
My question is: What's the etiquette o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.