instruction stringlengths 34 19.9k |
|---|
Public inheritance means that all fields from the base class retain their declared visibility, while private means that they are forced to 'private' within the derived class's scope.
What should be done if some of the parent's members (say, methods) need to be publicly exposed?
I can think of two solution. Public inhe... |
I tried to use the 'inspect element' of the firebug addon for Firefox but it doesn't give me any link to the javascript.
For example I got this from the firebug add-on:
<a href="javascript:">
text of the link
</a>
But there is no link to the actual javascript or anything that I can use to directly go to the said ... |
I've heard conflicting information from different sources, and I'm not really sure which one to believe. As such, I'll post what I understand and ask for corrections. Let's say I want to use a 2D matrix. There are three ways that I can do this (at least that I know of).
1:
int i;
char **matrix;
matrix = malloc(50 * siz... |
We have very frequent releases and we use Git for version control. When i am mentioning about frequency, please assume it to include bug-fixes and feature release too. All releases are eventually merged into ‘mainline’. When a release is deployed on production and if a bug is identified, people start fixing the bug on ... |
I want to refactor an OLD legacy application and give it a new feel... so, I want to use Twitter Boostrap for the UI... I've also been playing around a lot with AngularJS... is it common place to use them in conjunction with one another? Is it even the correct question to ask? I've done about an hour's worth of "googli... |
I know that Java uses a controlled mechanism to allow threads to be paused. If I understood correctly, they put a read from a protected page at the end of e.g. loops, and change the protection of that page if they want the thread to be paused.
What I don't understand is why this is necessary and whether this can even w... |
For a hobby project, I'm writing an x86 GC and JIT. For the GC, I need to maintain information about the stack layout (it's a precise GC), for which I need to be able to find out which method the IP currently is in (and the complete call chain of course). How can you do this?
The best solution so far was to keep a b-tr... |
You often see statements like "all non-trivial software has bugs" or "all non-trivial abstractions are leaky". But what makes a program "trivial" instead of non-trivial? Where is the cut-off line at which we can say that a program isn't trivial and "excuse" bugs?
Even something only a few lines long could have bugs. Sa... |
I was reading through the documentation for Bower here and I read this line: "The .bowerrc file should be a sibling of your project's bower.json." What does that mean exactly? Searching Google returned questions of people asking how to find siblings, but not what they actually are.
|
I'm working on a 2D-physics engine, and I need a certain variable to be precise only to the hundredths. Are there any methods for basically shaving off all of that unneeded precision?
I have tried things like
"{0:.2f}".format(a)
but that obviously produces a string, not a number.
I'm moving an object based upon its s... |
I know how the lambda expresion works and I know it is an argument for .filter() that establish the criteria to filter with. But I don't get how .filter() uses the argument, in this case a lambda expression, because .filter() does't have an implementation or at least require one at compile time. I search for this unkn... |
I'm going to start by saying, this may not be the correct place to post this.
So...I'm working in Embedded Development, using C.
Is there any benefit or disadvantages to doing the following:
while (1)
{
i++;
switch (i)
{
case 1:
x_get_inputs();
break;
case 2:
x_react();
... |
I'm writing a library for use in scientific computing and ran into a bit of a quandary. The types at work here are a class M which consists of some data and a reference to a container class C. There are many different implementations of C and I devoted a lot of work to making sure that M objects could use C objects wit... |
I'm building an application, and I'm thinking long-term I would like to be able to allow plugin support. The application I'm creating is a Java based application. How could I allow plugins using a scripting language, or is it better to require plugins to use Java?
Would I need to create some sort of plugin interface to... |
When handling exceptions for example in a method in my presentation logic, is it ok to catch all possible exceptions in a one catch block as follows if the only purpose here is alerting the user.
private void Do()
{
try
{
// Do some stuff here which might throw an exception
}
catch (Exception e... |
What I am trying to do is give the users/visitors the option to alter the whole website based on their taste. So they can move for example the sticky bar from top to bottom, alter background colors, news box from left to right etc.
For users I will probably store all the information in the DB but I am not sure how I sh... |
I have been given an online task in which I am supposed to develop a service which is based on some other class/service which has not been implemented yet but I have a rough API for that and the results return by my class would be used by some other class/service
I am not sure what would be the best way to return this.... |
Following is a code snippet from MVP Win Forms application and this explanation would be helpful when answering the questions.
My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be handled.
I'm using a single handler called ExecutAction... |
I've been lately thinking over design principles and patterns and a question did strike me.
Let us say, I want to design a racing game. I want to design the classes for a variety of cars.
each car may have different feature
the most common features can be put in the base class - 'Car'
Now, I learned that you should a... |
The video of Scala with style is here: http://parleys.com/play/51c1994ae4b0d38b54f4621b/chapter21/about
It's around 41:10 that he suggested another talk.
I can not hear the name of speaker or the name of the session very clearly.
Could someone help me to figure that out?
|
I want to make a roulette board with a ball spinning and landing on a certain field.
The catch is that the field the ball will land on, is known beforehand.
I want the animation to look somewhat realistic, even though the result is decided beforehand.
So I think I need to calculate the path the ball will follow, starti... |
I have a 2D array filled with a simple class:
class Tile
{
boolean N,E,S,W;
}
I also have a tilesheet representing all possible outcomes except all false (12 + crossroad). Now i need to reference all these possibilities to texture space on my sheet. Apart from having an if statement for each and every outcome is t... |
I'm reading "Rock Breaks Scissors", which describes two "outguessing machines" built at Bell Labs that try to exploit human non-randomness in the game of matching pennies. There was an outguessing machine built by the famous Claude Shannon, and one built by Dave Hagelbarger.
The machines worked like this (quoted from t... |
I have a small mobile quiz game, which consists of 30 questions, and a timer which starts from 0 seconds, and goes all the way up to 1 hour. Below you can see that my timer starts from 0, and it is displayed in the format of MM:SS.
var timestamp = new Date(0, 0, 0, 0, 0, 0);
function pad(n) { return ("0" + n).slice(-2... |
public interface IMyInputProviderPlugin
{
IMyOutput Provide(IMyInput data);
}
This is an interface I need to provide so that I can dynamically load the dlls and not have them bound to my implementation.
However, upon reading this, it seems like this is an anti-pattern?
http://blog.ploeh.dk/2011/04/27/Providerisno... |
I understand the advantages of using markdown in local text files, and then taking those files and generating HTML. This is great for documentation, readme's in git repositories and posts for static site generators. It is very simple to create markdown syntax in any text editor, it's human readable, and you can create ... |
I am looking for a way to solve an assignment problem, but I am having some problems finding the correct algorithm to use.
I have 2 list of nodes A and B, and in my problem may the length of A not be equal to B.
In addition, the node a in A may not be a potential match with all nodes in B. The preference is given by a ... |
I am reading the Core Java (9th edition) by Cay S. Horstmann and Gary Cornell. After making an effort, I cannot still understand the ? super Manager. Here are some materials relating to this question.
public class Pair<T> {
private T first;
private T second;
public Pair(T first, T second) {
this.fi... |
...or, can I license things separately within the project (i.e. images=LGPL, code=GPL). I've been confused about this for a little while now and I can't seem to find a clear answer.
|
Functional/non-functional and interpreted/compiled are two different categorizations, yet it seems that there are a lot of overlaps in the programming languages that fall under those categories. Is this a coincidence?
|
I was reading this blog post and liked the idea of using the DTO class for an entity and using it as a property in the corresponding business object class like so:
public class Person : BALBase
{
public PersonDTO Data { get; set; }
This also can eliminate the need for a mapping tool like AutoMapper (mapping be... |
I am using ownCloud - which is AGPL license - and only create few custom modules, and a theme, the core is not touched at all so:
should I allow download source for the whole app ( owncloud and my modules/theme ) ? ( as it is agpl based )
or should I only provide link to download owncloud code ( the original code ) ?
... |
I have following method in my presenters which validates the user inputs on the UI. Basically to capture the value of the text property of the text box, it uses sender object which was passed in by the event fire on the form.
PRESENTER
_View.ValidateInPut += new EventHandler(_View_ValidateInPut);
private void _View_Va... |
Wasn't sure how to phrase that title, sorry!
I've just come across this in our code base, and was wondering what the consensus was about how to unit test it:
C# (-ish, sorry, this is paraphrased from memory)
class DateCalculator
{
public static DateTime CalculateLeadTime(DateTime deliveryDate)
{
//return th... |
I have been tasked with creating a desktop client application that fetches data from web apis and presents it to the user.
During the last month or so, I've spent most of my time and energy bringing to life the functionality that UX described with two pictures.
Looking at the pictures, it seems like a simple design. Th... |
Are Data Warehouses bespoke projects that are developed to meet the needs of a specific organisation or can you buy off the shelf products that would meet the needs of many organisations?
I am talking about a product that will integrate information from many different systems e.g. finance system, sales system, producti... |
What limitations does inheritance of an interface through an abstract base class present that are addressed by zope.interface?
In the following talk given in 2010 by Jeff Rush about interfaces, at 11:50 Jeff argues that with providedby you are free of the inheritance hierarchy. Why is this important?
If I wanted to ... |
I have been refactoring an existing system to use dependency injection, and that work has been going smoothly.
After a while I noticed that a large number of in-house libraries became dependent upon the DI framework I used. As a result the entire project now depends upon this third-party framework.
I saw an irony in de... |
The currently most upvoted answer to a very recent question states that
DI containers are an "enterprise software" pattern, used when the object graph is very large and complex. I suspect that 95% of applications do not require it.
which is something I strongly disagree with. Maybe I've got the terminology wrong, but... |
This question is regarding MVP triads. Lets say I have two triads and first one has View1, Mode1 and Presenter1. Second triad has View2, Model2 and Presenter2. Now what I trying to do is, I just want to display the View2 when I click a button in View1.
You'd show the View1 calling it's presenter's show method.
View1Pre... |
Tarjan's algorithm for finding bridges in a graph is found here: http://en.wikipedia.org/wiki/Bridge_(graph_theory)#Tarjan.27s_Bridge-finding_algorithm.
However, I don't understand the condition for checking if an edge is a bridge. I get that L(w) = w is a necessary condition, but I think that the condition for H(w) < ... |
Was put on hold at stack overflow: hopefully it has value here.
I want to use a BDD / TDD / ATDD approach in c++. However I really want to emphasize vertical slices of end to end functionality rather than unit tests. There are plenty of unit testing frameworks.
How would you go about in c++ authoring an approach that e... |
I am a hobbyist programmer, bit of a stickler for terminology, currently learning C and recently came across the concept of Memory Leak. Now, I do understand what it means. Dynamic memory allocated to a program is not returned by the program.
But where does the term 'leak' come from? Is it coming from the fact that ot... |
For comparisons / evaluations of objects of the same class(and other purposes), is it better to define a static or a non-static (is this called "dynamic" by chance?) function?
Sample code:
class student
{
internal decimal medianOfMarks()
{
int count = 0;
decimal sum = 0;
foreach(float ... |
Considering favoring composition over inheritance and looking at various design patterns there are multiple approaches to modeling a domain.
Say you have some Entities which are very similar in some respects, yet differ widely when it comes to technical implementations. To try portray the scenario here is the classic ... |
I am new to state machine modeling and while trying to model a system, I have a question.
An example will explain it better:
Considering a system that does calling (probably a customized cell phone device) with possible states:
idle->calling->signal-dropping->handle->call ended
idle->calling->OS problem->handle->call e... |
So from the top-voted answer to this question, it appears that using raw pointers for storage isn't frowned upon so much. However, then what is the point of a std::weak_ptr? I thought that storage was the exact purpose of that class. If so, is there any circumstance in which a raw pointer is considered good, valid code... |
The game development package Unity uses the following version numbering scheme:
{major}.{minor}.{patch}{type}{number}
With the following known types:
a = alpha
b = beta
f = final
Some examples:
1.2.3a27
1.2.3b4
1.2.3f2
Is this a standard formatting for version numbers?
|
In our group we usually don't ponder too much about what kind of design or implementation decisions caused a bug, we just fix it. Of course if some module constantly produces bugs people start to notice it, and sometimes this leads to major refactoring. But we don't have a process where bugs are routinely analyzed for ... |
I have a function that works perfectly for detecting whether or not r1 overlaps with r2:
boolean overlaps( Rectangle r1, Rectangle r2 ) {
return r1.x < r2.x + r2.width && r1.x + r1.width > r2.x &&
r1.y < r2.y + r2.height && r1.y + r1.height > r2.y;
}
But now I would like to add a minimum threshold so that ... |
After I have written some commits, I very often git rebase -i over them, in order to test them, if necessary split them, take parts form one commit and squash them to another, more appropriate one.
But there is a problem. Say, today I am hunting for a bug, that 5 recent commits are causing. I rebase interactively on th... |
In an oft-cited (if dated) reference for C# coding standards (pdf; from Lance Hunt), the statement is made,
33. Avoid invoking methods within a conditional expression.
I've not seen this recommendation elsewhere, including in the .NET guidelines (here or here). Unlike the other very reasonable guidelines in Hunt's do... |
So for example say I had it so that all of my files will be transferred from a windows machine to a unix machine as such: C:\test\myFile.txt to {somewhere}/test/myFile.txt (drive letter is irrelevant at this point).
Currently, our utility library that we wrote ourselves provides a method that does a simple replace of a... |
I previously posted a question [link] on programmers.stackexchange.com asking when it makes sense to adopt an existing enterprise scale agile framework and when it makes sense to allow your own enterprise scale agile framework to emerge (e.g. through trial and error).
This question takes the previous question a step fu... |
We are writing a B2B application that uses OAuth 2.0. Before a token expires we want to refresh it since it is faster to refresh a token, than to request a new one. However, we want to build in some resilience in the system to clock skew, so we want to consider a token expired a few seconds/minutes before it would actu... |
I was designing a kind of a parser when I thought that it would be nice to have an operator overload like this: operator[]=(subscipt_type s, rvalue_type val). For example we have a class:
//collection of Foos
class FooCollection
{
public:
//assume class Foo is defined
Foo& operator[]=(int i, const Foo& val);
... |
Considering the Wavefront obj file format where this syntax fits in the Chomsky hierarchy and why ? I'm also not sure if PEG grammars are being considered in the kind of classification made by Chomsky and if an obj is a real example of a PEG grammar .
to formalize this: what kind of grammar and parser I need in order t... |
I understand the basics of what data races are, and how locks/mutexes/semaphores help prevent them. But what happens if you have a "race condition" on the lock itself? For example, two different threads, perhaps in the same application, but running on different processors, try to acquire a lock at the exact same time.... |
Let's say I have a social media website. On this website, users can upload several pieces of information about themselves, including their phone number. To implement this, I have a class called PhoneNumber that represents the users phone number. But phone numbers are optional. I have this PhoneNumber class which is sup... |
In order to handle several possible errors that shouldn't halt execution, I have an error variable that clients can check and use to throw exceptions. Is this an Anti-Pattern? Is there a better way to handle this? For an example of this in action you can see PHP's mysqli API. Assume that visibility problems (accessors,... |
Say you have arguments A1 >: A2 (contra-variant), and return types B1 <: B2 (covariant).
The corresponding functions are such that:
A1 => B1 <: A2 => B2
Sometimes, this makes sense to me - I will grasp it in a flash of lateral thinking. And then a few days later it is lost to me until I struggle through it for anoth... |
I understand that when naming RESTful URI's it is commonly accepted to use plurals to represent collections of resources. I am curious as to the argument for using singular nouns instead.
|
I'm implementing a sortable listview using bauerca's library here. This works, but now I need to define some things where I need some help. This is the functionality of my app_
I can create up to 5 names. These names are saved in a SQLite database. Then, in other activity, these names are loaded from the database and s... |
I am new to open source licenses and it seems very confusing, therefore need some suggestions. We are developing an application which utilities existing components with following license types:
Apache License v2
LGPL v2.1
MIT License
BSD style license
Mozilla Public License v1.1
Now my concern is:
What kind of distr... |
I work in C# and MSSQL and as you'd expect I store my passwords salted and hashed.
When I look at the hash stored in an nvarchar column (for example the out the box aspnet membership provider). I've always been curious why the generated Salt and Hash values always seem to end in either one or two equals signs.
I've see... |
As part of my job, I regularly get ad-hoc requests from users for snapshots of our very large database. However, there's no fixed format for delivering these and they usually come through in the form of bullet-pointed text, for example:
All customers
All active in last 0-24 months (including non-contactable customer... |
I am converting a project from C to mixed C/C++. It is going quite nice, and the new features are really lightening the work.
The platform is an ARM SAM4, compiler is arm-none-eabi-g++. This is not a safety-related equipment, but still could be left running for months and is not supposed to restart sporadically.
The or... |
In my project, I came across understanding that writing release notes is both helpful and necessary. However, it is not required by my management and I keep these files virtually to myself. You could say, I do it for self-organization. For each version of the internal prototyping software, I create a version number and... |
Sorry in advance if this question is so trivial.
The situation
There is a Customer entity whose ID is limited to two letters (A to Z) in the database.
Also, a user can enter the ID value from a Windows form. I think that the best option is that this form will validate (using the controller) with a regular expression l... |
I'm implementing a quadtree. For those who don't know this data structure, I am including the following small description:
A Quadtree is a data structure and is in the Euclidean plane
what an Octree is in a 3-dimensional space. A common use of quadtrees
is spatial indexing.
To summarize how they work, a quadtree i... |
Applications can always throw errors. If such an error occurs, the user should be notified, because what he asked the application to do has not succeeded.
However, how much information should the user be given? I think most of us agree on not showing a stack trace (Should a stack trace be in the error message presented... |
Is it possible to have a constructor in a class, that you can ignore certain arguments/parameters?
For example, I have this constructor
Car(color, make, model, wheels, type, doors)
Could I call this constructor and not include the type parameter?
|
My question is about a special case of the super class Animal.
My Animal can moveForward() and eat().
Seal extends Animal.
Dog extends Animal.
And there's a special creature that also extends Animal called Human.
Human implements also a method speak() (not implemented by Animal).
In an implementation of an abstract... |
I would like to define several names for the same type and have the compiler distinguish between them.
My motivation is that different int variables could represent very different units, and I would like the compiler to catch errors in units.
typedef int Speed does not generate any warnings, when assigning to Speed fro... |
A common pattern I come across is a backbone collection which is initially seeded from a database.
However, the user can also add to the collection. When the user does add to the collection, these should be reflected in the db.
Usually I would bind some kind of server call to the collection add event. However if I do t... |
I'm trying really hard to refactor some of my legacy code in the project using best practices and design patterns + DDD so I'd love some feedback on an issue I'm currently having.
Let's assume that I have two entity classes:
class Dog
{
protected $name;
function __construct($name)
{
$this->name = $... |
As the title states; what are the advantages and disadvantages of splitting teams by architecture tier rather than by product?
For example:
Organization A has three teams:
Team Web and Front End
Team APIs, Web-Services and Data Stuffs
Team Embedded Stuffs
Organization A teams, over time, have become more specialized ... |
My function takes an optional parameter, type, which is used to filter through a collection. However, the filter should only apply if the parameter is passed in (in other words, non-null). If the filter is not passed in, it should not be applied. How can I write my logic to reflect this? What I have now is -
if( other... |
I am about to start a Tetris clone using Java as my programming language. While I was designing how it'd be done, I've stumbled upon this question:
What would be better, if any difference at all, regarding performance 1, to draw my game?
For a matter of simplicity, I will use a background grid as an example. The follo... |
I've been a computer enthusiast my entire life, but didn't first start programming (web development) until I began College. It is now four years later - I am about to graduate, have had a handful of full-time internships and part-time work, all revolving around web dev... But I still find myself more often than not see... |
As a university project, I have to replicate Raptor. A flowchart interpreter. The interface looks like this
But as I am not a experienced swing developer, I don't have much idea about which swing components to use for which part.
I know:
The whole thing is a JFrame.
There is MenuBar on the top.
ToolBar exactly beneat... |
I need help in identifying a better algorithm.
I have developed a script using pythons scipy package to analyse a rather large model that I wish to solve. The model contains over 12GB of data including over 500 parameters.
The problem is that when I run small simulations of about 0.5GB of data with 20 parameters it c... |
I am trying to make a flexible particle system for my XNA game, and I've got these interfaces:
public interface IParticle : IUpdateable
{
bool Alive { get; }
float Percent { get; }
}
public interface IParticleEffect<T>
where T : IParticle
{
void Apply(GameTime time, ref T particle);
}
public interface... |
So I started thinking, what is the best practice for publishing generated documentation (e.g. Doxygen, NaturalDocs, etc.) in terms of infrastructure?
I would be generating it through continuous integration:
Should it be put in a regular web server?, or should I use something like Sharepoint or some other content publi... |
I am working with quite large files (pytables) and I am having problems with the Memory Error when I try to load the data for processing.
I would like some tips about how to avoid this in my python 32bits, since I am new working with pandas and pytables, and I do not know how to work splitting the data in small pieces.... |
I'm using a large interface with about 50 methods to access a database. The interface has been written by a colleague of mine. We discussed this:
Me: 50 methods is too much. It's a code smell.
Colleague: What shall I do about it? You want the DB access - you have it.
Me: Yeah, but it's unclear and hardly maintainable... |
I have a WCF service which will get an object with huge data from database in the form of collection.
I have a UI which has get and cancel buttons .
Get button : make service request and continue with data population with the returned data from service.I start it as below
Thread _workerThread = new Thread(DoExportTreeL... |
Can someone please explain to me the difference or benefits rather to using the rectangle class
ex. Rectangle r1 = new Rectangle(x,y,w,h);
versus the graphics class drawRec method?
g.drawRec(x,y,w,h);
I'm thinking that you can create a new object outside of paint() or paintcomponent() which gives creating an object... |
I have an ArrayList<LinkedHashSet<String>> setOfStrings for example this arraylist internally is composed like:
positionX[hello,car,three,hotel,beach]
positionY[.....]
...
I want to find car inside this data-structure, so I did it
for (Iterator<LinkedHashSet<String>> iterator = setOfStrings.iterator(); iterator.hasNex... |
I'm building a unittest system. At some point I want to bind two users together in order to make an assignment for those two.
So when the admin chooses to link two students together the system should figure out how to, maybe using the ID numbers of the both users. I have an idea on how implement this, but not very cle... |
It might be related to the Yeoman project, or they might have adopted this from somewhere else, but it seems to be the default for all of their generators. Aside from Yeoman generators I've also noticed it in other projects that have nothing to do with Yeoman (this one for example).
Where did this convention come from,... |
I had a loop through object Process, each process instance can be of a different type, derived from Process base class (e.g.: Process1, Process2,...). Each derived type of Process has different properties. For instance: some Processes are indexable, this is notified by IsIndexable flag. When a Process is indexable has ... |
Does anyone have a good mental model or metaphor for functional programming which references something in the real world?
Object Oriented programing intuitively makes sense to me. There are things that have properties and sometimes they also can do stuff or perform calculations on their properties (methods). (Ex: Car, ... |
When certain parts of code are unusual or unclear, common practice is to leave a comment explaining why it is so. However, sometimes a filesystem may have unusual configuration, such as a directory with 0477 privileges. Is there any convention for leaving comments about this?
I am writing a 'Developers Wiki' for the co... |
Here is a little background of my problem: I implemented a singleton logger class which is being called from several projects.
I want to log the name of the class as well as the name of the method asked for logging.
So far, I thought about two ways to get the name of the method and the class - either by reflection or... |
I have a rails app where my users can buddy up with other users. Since that relationship can have a status (approved/rejected/pending), I decided to go with a join model (UserRelationship) so now I have the attribute.
To handle state for that join model, I have a controller (UserRelationshipsController) with actions/R... |
In Java there are no virtual, new, override keywords for method definition. So the working of a method is easy to understand. Cause if DerivedClass extends BaseClass and has a method with same name and same signature of BaseClass then the overriding will take place at run-time polymorphism (provided the method is not s... |
I am reviewing an approach I see commonly used in storing objects (e.g. a socket client object). Namely, usage of a static container to hold the objects. Said objects are created by some helper function as follows:
create_client(params) {
...
client* cl = new client(...);
return cl;
}
The thing that confused me ... |
this question in my opinion straightforward.
How can I catch an DllNotFoundException in C# as it is just an attribute to some methods use like this:
[DllImport("NativeLib.dll")]
private static extern void print_line(string str);
When are these functions being invoked ? As I instance the class containing the method... |
I have been handed a very cluttered, "One Ring" object (one object to rule them all). The OR class has 40 fields. These fields map to 16 different objects (the OR has all the fields from the 16 objects concatenated together. Some of the fields are common to all objects, some are unique to individual objects [all of the... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.