instruction stringlengths 34 36.1k |
|---|
I'm kind of new to OOP, so I still have quite some doubts when it comes to how different objects should communicate with each other. I have a concrete case in which I can't figure out which is the best design between the two that came to my mind.
Basically, I'm building a web user-interface (HTML+javascript) in which t... |
In TDD you write the smallest unit of code to make your test pass.
For example if building a Stack object you will want to test the push and pop methods. That is pretty straightforward. Those are both small units that can be tested in isolation. No external dependencies. It is about that object and what it does.
This i... |
I am writing user documentation (an SOP) that involves third party programs that I am trying to describe well. One such program is a server that offers little indication of it's startup besides a graphic that shows during its initialization/startup routine.
As a developer, I have used this window as a quick status indi... |
I find several sources claiming that power-of-two bits in a binary word (such as 8-bits per byte) is a "good thing" or "convenient". I find no source pointing out why.
From What is the history of why bytes are eight bits? we read in the approved answer:
Binary computers motivate designers to making sizes powers of tw... |
I'm a self-taught, novice-ish coder, so I apologize if I don't nail the programmer lingo.
I'm working on a project in which I am providing data, which will be continually updated, to developers who will essentially create a tool to generate reports from queries on the data.
It seems that everyone involved thinks that t... |
I'm working as part of a team of 10 on an agile project, this is our first time using GitHub. We write our code, create a pull request and then start on our next task. 95% of these pull requests are being reviewed by our scrummaster/manager who tests whether everything is working but generally doesn't look at the code.... |
Is there a naming convention for protocols and concrete implementations of them in Objective-C? Specifically regarding a protocol that's used as an abstract 'service' or 'manager' class declaration.
For example, in Java you might have an interface SomeService to describe some data service and call its implementing clas... |
I see a lot of shader code on the internet where PI is simply defined as an approximate decimal near the top of the code. In general I try to let computers take care of doing math for me instead of approximating values with constants (i.e. (1./3.) instead of 0.333)
Pi seems like one of those things that would be easier... |
Imagine a simple module-based architecture, there is the Core system that contains an array of random values. It's possible to create modules/plugins that will interact with this array.
Plugin A wants to prepend a value in some global array
Plugin B wants to the same but a different value
Plugin C will put a value to ... |
I am 1 of 3 developers. The other 2 use Web API and angular to build web apps. I prefer ASP MVC with a repository and EF. The stated argument is that a service is more secure when accessing the database.
I think my way is just as secure if not more so. And I don't want to have to learn Angular. I could use Web API t... |
Description
I've got a series of events (points, objects, letters, what have you) that occur during a labeled time period (category.) Events can happen during multiple categories. I want to find the event which is most representative of each category. Put another way, for each category, I want to find the event that ha... |
tl;dr: Would there be a language-agnostic definition of Symbols and a reason to have them in other languages?
So, why did the Ruby creator use the concept of symbols in the language?
I ask this from the perspective of a non-ruby programmer. I've learned lots of other languages, and found in none of them, the need to s... |
Problem
Changes to product requirements/specifications during the development cycle are inevitable in a professional setting. In particular, I'm constantly dealing with changes to the specification for an embedded system's software parameters: I/O, user settings, calibration data, logging information, etc. Are there an... |
I am slowly creating a simple programming language (a bit like Lua).
The interpreter has 2 important methods, exec and evaluate.
exec reads the tokens 1 by 1 and does stuff as it says like creating new variables, etc.
evaluate basically interprets a bit differently.
It understands ==, new numbers (5.3), +-*/^% and new ... |
Let me be upfront: I love the RESTful constraints for network-based software applications, especially when they cross organizational boundaries.
That being said, I find that RESTful constraints go against business requirements laid out by people above me:
"No, we need to keep client state on the server to keep the cli... |
I'm using OAuth2 to secure an API. This API will be used solely by a known website and some Cordova apps.
The website will send always send a corresponding referer header.
The Cordova app will always send an x-requested-with header.
I have two similar questions regarding this.
May (or should) these headers be used t... |
Why is this OK and mostly expected:
abstract type Shape
{
abstract number Area();
}
concrete type Triangle : Shape
{
concrete number Area()
{
//...
}
}
...while this is not OK and nobody complains:
concrete type Name : string
{
}
concrete type Index : int
{
}
concrete type Quantity : int
{
}
My m... |
I need to navigate to js method source that I'm calling in sublime (for java script file). I try 'Ctrl'+'click method name' and nothing happens (It works for almost all IDE (eclipse, sts, netbeans, idea...)). I believe SubLime tool should have same ability (if it does not possible I need special plugin).
Can someone su... |
This is an optimisation problem involving string matching with wildcards. We have a set of wildcard patterns, each tagged with a numerical "score", as below.
Pattern Score
*AA* 20
*ABB* 10
*BA* 5
*C* -5
*B*A* -10
*AAAA* -100
In this example the vocabulary, V, is {A, B,... |
I need to compare the Background colour of a Button with the colour of a Rectangle.
Based on what I found, I did this and it works. However, since I am not completely sure why, I am asking if this is the preferred way to compare. Especially since I don't understand why I have to cast them, if they are the same type any... |
There is a company that I am pulling data from which has a unique ID for each record. However, the ID is alphanumeric (even contains a special character too). When I asked about this I was told that this is because the leading alphanumeric portion indicates the "type" of record that it is.
Is this a proper format to u... |
Does a pull request review consist of testing, code review or both and how long should the average PR take?
I don't know whether the testing just involves testing the functionality that's been altered, or thoroughly testing the whole app and what purpose this has if the author has already tested this.
If it involves a... |
I was wondering if there are general guides or standards which can be followed when trying to show if your own database implementation is ACID or BASE compliant?
For example are there any specific tests I can run?
|
I'm writing software that needs to be fairly configurable in nature. At this point what that means is that it first reads in a users configuration file and then builds the objects it needs based on that configuration.
As a result of creating objects based on a users desired functionality it seems to me that Inversion ... |
In the latest version of languages like TypeScript or ECMAScript you can use async/await constructs to write code that combines the clean structure of synchronous programming with the performance advantages of asynchronous code.
Take this as an example:
async function isAdmin() {
// Async IO request...
return f... |
I am developing a reporting framework that requires multi-step calculations for numerous customers. An added complication is that customers have specific though similar methods of calculations. For example some customers include datasets from stat holidays and some don't.
My question is around how I should stage these ... |
Does anyone have any comments on how to write unit tests for 3rd party applications like kamailio...that allow you to write "configuration scripts"?
https://www.kamailio.org/wiki/cookbooks/4.0.x/core/cfg#the_configuration_file
I'm looking for more an approach vs. specifics.
In this particular case, these configuration... |
We have developed a web based application for name matching. It operates by breaking names into parts and the Soundex value of each part is stored in a database. The Levenshtein distance metric is used to apply percentage matching of sound as well as spelling against a given name.
At runtime, we load all records into m... |
I have developed in the past always classic ASP.NET solution. I am starting currently to develop ASP.NET MVC solutions, but i have a problem understanding what a Model is and what it should contain.
In the past i had an Object. For example one for User, Product and an object for Countries and one for Product Categories... |
Today, virtually all C++ developers agree that std::vector<bool> was a mistake since it is deceivingly not a container, and its use cases largely overlap with those of std::bitset anyway.
How did it get voted into the standard? Was it controversial at the time? What were the main supporting arguments?
|
For example, say I have two XML Strings that I want to merge:
<Test>
<A>false</A>
<B>true</B>
<C>Transfers!</C>
</Test>
<Test2>
<A>false</A>
<B>false</B>
</Test2>
Where the final result looks like (notice, B is now false, because I would like a place to do some sort of logic to determine the final... |
Company A is building 5 separate in-house WPF applications, and they would like to share UserControls, ResourceDictionaries, and ADO Entity Data Models between each project. They would also like to incorporate 3rd Party libraries using Nuget. Should they incorporate all of these projects into one solution, or should th... |
we have web application which stores information in backend SQL 2014.
currently the way is set up that central database stores all key information for the customers and then we have seperate database for each customers.
Now tables structure for each customer's database is same for particular product.
e.g. if one cus... |
This would be behind a spoiler tag if I could get the markdown to work. Sorry.
As soon as I typed in "circular dependency", I got a ton of suggested results. Such as:
How to handle “circular dependency” in dependency injection
How to solve circular dependency
Is circular Dependency Injection a good practice?
Circula... |
In my application, I have resource A that is super class and A1, A2 that inherits A and other properties that are specific to them. A cannot exist by itself, it must be either A1 or A2. This is a classic example of hierarchical schema. I want to design an API that will return resource A with its subclass properties as ... |
My current process using asp mvc is:
Talk to the client a few times to find out what they want
Extract from m y notes a list of nouns, or entities that need to be tracked.
Make a list of the business rules to be enforced.
Build the database, based of the list of entities.
Do a wireframe that roughly lays out all the U... |
I've looked into numerous solutions for the simple version of this problem, but I've found no solutions for advanced cases, short of sorting through all possible permutations.
I don't know where to begin this question, but I'll do my best.
In my case, this will be in reference to a machine shop.
In order to run a part ... |
Say we have a class structure like the following:
// implementation.ts
export class A implements IA {
constructor(private b: IB) {}
}
export class B implements IB {
constructor(private c: IC) {}
}
export class C implements IC {
}
// ... interface declarations
Using an IoC container, it is possible to inject de... |
I want to write a Python application that "wraps" a command line utility, passing through all parameters intact, except for the parameters that I choose to modify.
I imagine there's an easy way to do this in Python but there's any number of ways to make this really hard.
Is there a "right" way to do this? Any suggestio... |
Using C++ I'd like to do something along the lines of:
Try to get a reference to something in, say, a map
If it throws, then return straight away
Otherwise, go and use the reference
However because we can't declare a reference object without initialising in C++, then we can't do this directly.
For example if I was ha... |
I was looking to use OpenCV to program an image recognition app for iOS. One thing I wanted to check is if I were to charge $0.99 or $1.99 for the app, would I be breaking OpenCV's license? I didn't see anything in the license regarding this.
|
I have been using Java for a while and PHP recently. Some things I miss from Java is
Code completion suggestions from the IDE
Error detection before runtime
Find places where a method/function is called
While these seem like IDE features, from what I understand, it has to do with how the language is implemented. (bec... |
I'm currently working on a software project in Swift that requires several different types of sorting mechanisms. I have been searching, to no avail, to find an algorithm to do a sort with tie-breaking. In other words, say you have a data set that could be represented like so:
[Name Of Data]:[Someone's ID]-[Same Someon... |
I have a new requirement to delete sensitive data when requested by the user.
The problem is that the system is complex and there is a lot of existing data in the system and they are all related.
If I simply do a cascade delete, it can easily affect how other functionality might operate in unpredictable ways.
How shou... |
I have two classes: Employee and Conversation.
Conversation has a property with the employees which participate in the conversation: List<Employee> Participants { get; set; }.
On the database, I store for each participant, whether or not there are messages in the conversation he didn't read yet.
How should I store this... |
Is it possible to pass dynamic data to the browser when it automatically GETs link and img and script etc tags after it has parsed the html containing them? Ultimately would want to pass an authentication token to allow the server to decide whether or not to return the resource.
Context:
I am trying to help somebody wi... |
I'm about to create a specific file format for a particular project.
There is no special metadata related to the file, as it can be saved in the database, in a file, etc. So the extension of the file, the date, etc. don't matter at all: only the content does.
I now know that the format will have several iterations, so ... |
When encoding a sequence of bits into a string (using an alphabet that is not yet known at compile time and with the goal that the resulting string is as short as possible and that this whole process is reversible), you can use the "divmod approach", see e.g. this post.
From my understanding, this appraoch only works ... |
I am trying test driven development for the first time (test first development, actually). I wrote down my specifications, then alternated writing tests, then code, writing the code to pass the latest test and not break prior tests. My code is doing input validation on a user-supplied file path:
Does the path exist an... |
I am the designer of an interface IModel, which will be used by the implementer of a the controller (MVC). The interface contains funcA().
Another programmer needs to implement a specific class for the IModel.
I want to direct the implementation of funcA() to use another function, funcB(). This forces some functional... |
Sorry for the long somewhat unclear title, couldn't think how to word the problem I'm having. So basically I have a package structure with two reasonable alternatives (as far as I can see) but both involve a repetition on the second level.
For example, my top level packages could include tcp and bluetooth and then each... |
I adopt a software architecture where I have one single data access in the persistence layer.
Indeed, the persistence layer is a mere java application (JAR file) that I consider as an dependency, thanks to Maven's POM.
So, when I need to access the database, I just call some DAO classes from some Servlet or such.
Since... |
I'm now stuck in the server I am programming, simply because I do not seem to find a good and realiable way to handle my "single object" classes, I've attempted the Singleton pattern but it is just plain ugly to have to type everything over and over again.
I have this class "TConnectionManager" which basically handles ... |
An application that I am working on and trying to optimize does data processing on large files, and so it alternates between being I/O bound with no CPU usage, and CPU bound with no I/O usage. It is block based processing, so this is same scenario happens across hundreds of iterations. The only strategy that I've come ... |
Most of financial apps have complex calculations and over time have change in calculation methods. Then you mostly create a new version for your calculator class that extends previous calculator and override some method.
You may extend new calculator from old version because you will avoid repeated code and use typeca... |
In this MSDN article, the following example code is provided (slightly edited for brevity):
public async Task<ActionResult> Details(int? id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Department department = await db.Departments.FindAsync(id);
if (dep... |
Problem
I want to design the class architecture for an agent that interacts with an environment by repeating three steps until the end of an episode: First, the environment provides an observation to the agent. Second, the agent chooses an action in response. Third, the environment rewards the action by a reward. The a... |
As part of a work assignment I've long dealt with a giant, dynamic SQL-creating stored procedure that's used for retrieving a bunch of inventory items. This stored procedure accepts a ton of parameters (maybe like 20+) which, in turn, turn on and off the dynamic SQL that's generated.
Eventually we exec all this SQL and... |
This is more of a design/user experience kind of question, so if it belongs somewhere else please let me know.
I have a program that has multiple PictureBoxes:
PictureBox1
PictureBox2
.
.
PictureBox60
Each PictureBox's Tag field is filled in with a String value.
When the user clicks on a picture box, the Tag property ... |
Can anyone explain why do we need
+1 byte for sentinel value?
As we know that 1 char = 1 byte so if we declare an array such as char a[50] why I can't store 50 chars instead of 49?
|
I am trying to figure out when to use the DIC/IoC registry for configuring my software and when to use factories, along with the reasoning behind either approach.
I am using StructureMap as my DI container (DIC), which is easy to configure using registries. In the DIC practically all registered objects are static in t... |
I'm developing a website (using PHP, JS, and MYSQL) which allow user to upload images. My requirements are as below:
User is able to upload 1 or multiple images at a time.
Website is able to save the original images and using the original images to create a re-sized version e.g. 500x500 px
What I've done
I need some... |
I am designing a CMS, and would like to start with a simple database schema, with the requirements
Two main types of entity,Post and Category
For Post, it need to support multilingual and versioning
For Category, only multilingual support is needed.
For both type, hierarchical relationship support (see the parent fiel... |
I started working in a project around 3 months ago and since I joined I saw so many mistakes in the whole design - the architecture is completely dysfunctional and badly implemented and a lot of used concepts like Inversion of Control are implemented in a way which completely goes against any proper conventions. People... |
I'm a software developer in a growing SaaS Human Capital Management provider (Agile) and we only use Team Foundation Server (TFS) to keep track of our backlog, stories, acceptance criteria, work order management, etc.
Requirements for stories are documented as acceptance criteria in TFS but highly unstructured. It is ... |
I'm using the repository pattern as the way to access the DbContext in my C# application, however, I have a report that generates an expensive query (actually several queries) because of relationships (and poorly written code).
Then I created a Stored Procedure that returns exactly what the report needs, without any e... |
To clear some potential confusion, let me start with the following statements
As far as I understand, inheritance is mostly about dynamic dispatch.
I understand how virtual pointer table based inheritance works and I assume that this is what 'classical' inheritance refers to.
I assume that 'pure' OO-style class-based ... |
I am copy/pasting my comment from this article sumarizing a post on reddit:
I really don't think "Protocol Orientation" is something new... You've
got protocols in Obj-C, you've got Interfaces in Java, Abstract
Classes in C++, etc.
You can segregate interfaces and avoid inheritance by replacing it
with compositi... |
I am developing a web framework in PHP, and I want to make it fully extendable. My goal is to make it possible for a developer to change the behavior of any component without having to modify the "core" codebase at all. Developers should be able to encapsulate all of their work in a separate directory. And, I want t... |
Our Scrum team has been having incomplete (not accepted) stories at the end of a sprint (usually 3 week sprint durations) that carry over into the next sprint. This has happened in every sprint except one in the team's 30 sprints.
We have tried to reduce the number of new story points that we accept in the next sprint ... |
I've read a related question Are there any design patterns that are unnecessary in dynamic languages like Python? and remembered this quote on Wikiquote.org
The wonderful thing about dynamic typing is it lets you express anything that is computable. And type systems don’t — type systems are typically decidable, and th... |
We are creating a project using Aurelia/Typescript. For those who don't know what that is, it's basically a better AngularJS (opinionated). Our project runs perfect, except for the fact that we need to incorporate windows authentication now, which we can get via ASP.NET Core. This is a bit of a problem. Considering tha... |
Some examples:
CSS image sprites
Compiling JS needed on every webpage to one file
Implementing lazy-loading for images
Consolidating all meta information (username, CDN address, etc) into one request
Specifically for AWS S3 browser uploads using signed policy documents: grabbing all the policy documents from the serve... |
Suppose I am writing a program in F# for end-users. If there is an unhandled exception, the program will crash.
Now suppose that I want application-specific data in the crash report. I can get this by catching all exceptions, logging the relevant data, and then rethrowing the exception. Is this good or bad practice?... |
I have an API endpoint written for version and health of tomcat applications. It returns a json response with details. I wanted to know, how can i monitor any change in the json response in real time. I am building a dashboard on top of the endpoints.
I will be using django channels consumers to consume events in real ... |
I'm making a game with trains.
I need to serialize which train is used for each level.
So I can simply do:
public class Level {
Track track;
Train train;
[...]
}
public class Train {
Wagon[] wagons;
}
public class Wagon {
float length;
float weight;
}
//Example:
level = new Level (track, new ... |
Before the introduction of the move constructor and move assignment in C++, I had two clear conceptual categories of classes: values for which using a copy was not different from using the original value, entities for which it was different. For values, I provided the copy constructor and assignment operator (and equa... |
I am considering how to set precise boundaries of bounded contexts. Considering that a bounded context is a solution space, sometimes it is very difficult to set what exactly is your solution space.
Here is an example.
I have following bounded contexts
Ordering
Messaging
Content management
Warehouse etc.
So in a real... |
I have an asp.net mvc 5 site.
I have a places table / POCO with 3 unique constraints (URL, Email & obviously ID).
Users are able to add places - but they may violate URL or Email unique constraints, and I need to tell them why an insert failed.
I am tempted to just let the insert fail (by violating the Unique Constrain... |
In an ongoing project my team is building a new web application that relies heavily on a rest api. As we decided to try react we naturally came to implement redux and a middleware, as we've read this is the way to go. However, further into the project, we noticed it would be a good approach to bundle all the api relate... |
I contribute to an open-source project that heavily uses the ctor-injection design pattern. Recently, there was a discussion about using interception for certain things, including injecting UI commands to a view model, and correctly binding the command to the correct value.
As an example, we have a command:
public cla... |
If I met all requirements on version 1.0 and go on working towards version 2.0, new features would be 1.1, 1.2, 1.3, and so on. What do I version the commits that represent an important fix or a forgotten feature which is required in version 1.0? Even if I didn't version fixes on version 1.0, there would still be two v... |
I have a few base, derived classes and need to dump their data to file. The difference is only a field, but I don't know how to reuse code of base class. Sorry if noob question :p
Those classes look like this: (C# implement)
class Base{
public int id {get;set;}
public string field1 {get;set;}
}
... |
I have two Float32Arrays each one of which is 1.6*10^7 in length(floating point array). Using JS I retrieve them from server and add them element by element. My webpage stops responding and I get the following error message. Is there a way of handling huge arrays on client side without using JS or with JS?
|
Which class of algorithms would this sort of a problem belong to? If I had to pick up a book on algorithms, which topic should I be looking at to find more problems of this nature and their explanation?
Given the current location on of the horse (or whatever the thing is that moves two spaces horizontally and one verti... |
Is it possible to move an application (or task) to another core to make it run faster and get all of that cores processing power?
The way I understand it is that in an operating system applications share the main CPU and get a shared "slice of time". So if ten applications are running over the course of one second eac... |
I am convinced that the amount of routine work in software development is - and should be - relatively small, if not negligible, and that this is the fundamental problem of software estimation.
Let me describe how I come to this conclusion and tell me if the argumentation has any serious flaws:
All that can be estimat... |
I need help with algorithm I'm working on, my problem have 3 main components:
Item: an object with 2 fields
{
Integer reward;
Boolean_2D_Array area;
}
Generator:a module that generates items according to certain logic.
Collection: where I keep generated Items
For every items that arrives from the Generator I need ... |
If you have an image sheet of facets and data to indicate which point on each facet should connect with other points on the other facets, is it possible to position those facets in 3D space based on the connecting points? Essentially turning 2D images into 3D objects. Similar to paper craft folding.
|
I've been looking at a javascript library for drawing graphs, Dygraph, source on github.
It has several enormous classes, such as here and here.
Personally, I don't think justifications for large classes are valid, since it goes against principles of OOP, such as the single responsibility rule. In this day and age, ev... |
I am trying to learn how lazy evaluation works because I'm going to implement try to implement it in the programming language I'm developing (I know it isn't the best thing to do (to try to implement something you don't even understand) but it's making for a good extensive lesson through the world of functional languag... |
I'm doing some code cleanup and I'm looking at my regexes. I have an extremely simple one:
(ARA|CHI|FRE|GER|ITA|JPN|RUS|SPA)\s[0-9]{3}-[0-9]{2}
It basically validates course identifiers for a specific department (Modern Languages and Literatures) at my university, e.g. FRE 101-01 is valid, CIS 101-01 is not; I cannot ... |
The word "Dependency" is used a lot in programming. But I think we might be using it wrong in many ways. I will use "Dependency Injection" in this post as an example. According to the Dictionary.com, the "Dependency" means:
the state of being dependent; dependence.
something dependent or subordinate; appurtenance.
a... |
Are there any matching and survivorship nodes in SSIS besides the one offered by Melissa Data? Any implementations in SQL on survivorship would be great as well.
An example on my use case is that given that I have some 2 records of referring to the same customer, I want to come up with a golden record that will combine... |
I'm a bit confused with TDD+SOLID.
1) I've watched MVA course about test driven development
https://mva.microsoft.com/en-US/training-courses/testdriven-development-16458?l=gLxGoEwXC_2306218965
2) I have read various blogs, posts etc. stating that TDD accompanies, if not enforces, SOLID principles
OK, let's say I write... |
I have an array of unsorted positive real numbers. I need to create a frequency distribution by their ranges.
The simplest approach goes like this
for num in numbers
if (num > 0 and num < 10) a++
elseif (num >= 10 and num < 20) b++
...
else z++
return [a, b, c, ..., z]
Is there any faster or more efficient way to... |
I am new to OOP. I've read definiton of both terms in many different articles and books, but still can't understand whether there is any relationship between them.
|
I am creating schedule tasks that run on daily basis monitor system events and send email notification based on some criteria.
For example, if user subscription will expire after one month, task scheduler will detect that by comparing dates then send email notification.
There are many tasks listen to many events occurr... |
Is it a poor idea for readability or maintainability to use functions in conditionals as in the following example?
if (move_uploaded_file($file['tmp_name'], $destinationFile)) {
// Do work
}
Versus the more verbose
$moveFileSuccessful = move_uploaded_file($file['tmp_name'], $destinationFile);
if ($moveFileSuccessf... |
I'm working with a model that currently looks like this:
class Sign {
enum Type { A, B }
Color color;
String textLine1;
String textLine2;
Type type;
Sign(Type type, Color color, String textLine1, String textLine2) { ... }
}
A sign of type A has a color and 2 lines of text. A sign of type B has a co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.