I am working on a coding problem and I need to check whether a past date was a federal holiday. It is trivial and I have already pulled the historic planned holidays but there have been many federal holidays/non-working days that have been declared by Presidential Proclamation or Executive Order. These include the day before(or) after ...
Basically, projecting light like a flashlight, and checking if a point - I only need to check for a point, but it wouldn't hurt to be able to check for more than one - is in the area illuminated by it or not.
Also, I assume most (all?) algorithms work in 2D/3D, but would it be possible to use one that works in an N-dimensional space? I'...
It seems to me that the only difference is that Active Record has CRUD methods in data container class, and the Repository pattern uses separate class for data container and CRUD methods, but surely I'm wrong.
What are the differences between Active Record and Repository pattern? When should I use which pattern?
...
I want to accept an arbitrary regular expression from the user and anchor it on both sides in order to enforce a full match (^<user's-regex>$) however I don't know if I have to take into account the fact that the user may have already anchored his regex.
It looks like Perl, C++, .NET and JavaScript all allow double multiple anchoring.
...
Hi,
Most of the literature on security talks about the importance of defining a security policy before starting to workout on the mechanisms and implementation. While this seems logical, it is quite unclear as to what defining a security policy really means.
Has anyone here had any experience in defining a security policy, and if so:
...
I know it's evil, but I've seen swallowed exceptions in code written by a good programmer. So I'm wondering if this bad practice could have at least one positive point.
In other words, it is bad but why do good programmers, on rare occasions, use it?
try
{
//Some code
}
catch(Exception){}
...
I am novel software guy so I have little experience with software design. I have a question to ask: suppose I create a extensible software application with a plug in architecture, so that new applications can be integrated in this tool. If a new application is written in a different language and needs to be integrated in this application...
I recall being told by a professor the following is bad practice. But it makes stepping through code a lot less tedious. I'm just solicting comments on pros and cons:
Friend Class MyClass
Private isEmpty As Boolean
Public Property IsEmpty() As Boolean
Get
Return isEmpty
End Get
Set(ByVal Value As Integer)
isEmpty = value
...
So, this is probably a stupid question, but I have a mapping of unique IDs to unique values. Sometimes I want the value for a certain ID, sometimes I want to know the ID of a certain value. I search more than I modify the collection. I'm wondering if there's a special datastructure that makes sense here, or if I should just maintain two ...
Suppose I have 3 kinds of restrictions to computing a spanning tree:
Constrained degree (eg: a node in
a spanning tree may only be
connected up to 3 other nodes)
Bounded diameter (eg: all edges'
weights, once summed, cannot exceed
100).
2.1. If possible, show all subtrees that meet this criteria.
Both
Are there any good algorithms t...
I hope this isn't a dupe, but it's hard to boil down the problem into keywords!
This is always something that I've wondered about. Let's say you have a black box that takes n integers as an input (where n > 1). Given that there is a bounds on the integer values, how would you go about writing an algorithm that will push the entire sampl...
When i play a video game (any old game like a racing game or pack man or whatever) how does everything get displayed on the screen in terms of what is going on in the program? is there some big RenderEverything method that is executed once a frame? this strikes me as a bit of a slow way to go about such a thing though.
EDIT: as a follow...
There is DAL library that exposes dozen of repositories. One repository per entity. There is PersonRepository & PhotoRepository.
When I add a new method to repository and method deals with entity it's obvious where I have to put it. If I want CreatePerson I'll create PersonRepository::Create(...) or when I need to update photo I'll cre...
I more than once saw code of the form:
DiceThrower dt = new DiceThrower();
dt.throw(); //this is a void method
int result = dt.getResult();
instead of
DiceThrower dt = new DiceThrower();
int result = dt.throw();
My question is...why? Isn't it better to have the throw method returning the result? By not doing so, I could even incurr...
What is the use/advantage of function overloading?
...
I have legacy Reporting Engine class that is responsible for 50+ reports with a single method CreateReport(Guid reportId, ReportParams params);
Reports require 12+ of different parameter types (Guid, int, bool, enumerations) and their combination. For example:
Report #1: No parameters are required
Report #2: 2 Booleans (checkboxes pop...
Say I have a list of values, this list can be of any length:
"100","200","300","400","500", ...
And I have a template string that has a few tokens that need to be replaced:
"@token1@-@token2@-@[email protected]@tokenN@"
Using the list of values, how can I generate every possible combination of the values in the template?
Values can be...
I come from a statically/strongly typed language background (java), and I recently started to learn python and I think I see the value of dynamic/strongly typed language.
Now I'm wondering whether weak typing can be ever desirable.
Going through stackoverflow, I only found explanations that say it has performance benefits. Since th...
In theory, source code should not contain hardcoded values beyond 0, 1 and the empty string. In practice, I find it very hard to avoid all hardcoded values while being on very tight delivery times, so I end up using a few of them and feeling a little guilty.
How do you reconcile avoiding hardcoded values with tight delivery times?
...
Hey guys,
It dawned on me that I've never seen a single exception hierarchy for which creating subclasses but catching the parent class was actually useful (except, of course, for the base Exception class, that has to be derived).
Are exception hierarchies really useful, xor should all exceptions be derived from language's base excepti...