instruction stringlengths 34 36.1k |
|---|
I have a function that is called by
myStruct *structName = myFunction(0);
The function looks like
myStruct *myfunction(int x)
{
if ( x == NULL)
{
return NULL;
}
/*rest of code*/
}
Passing NULL or 0 BOTH trigger the if (x== NULL) statement and I can't figure out why. I need to return from the fu... |
I'm designing a web application. I'd like to use sub-domains to split the site into logic separate sections based on some category - exactly like the stack exchange websites do. I'm currently aware of two approaches to this ...
One large application that gathers context from the current domain (or some other way) and ... |
Last year, in university we used the library SDL to create a game from scratch. So I though of developping a game engine based on SDL. I will be using Qt to do the UI and SDL to implement the core of the engine (collisons, physics, game logic etc...). The game engine will be a simple application, for example the user c... |
Most people say when building micro-services, that it's best to have separate databases for each of the microservices.
E.g:
User-microservice:
DB - User
userId
name
Etc...
Review-microservice:
DB - Review
userId | The user who posted the review
Review-description
But I've been thinking, is it best to have a O... |
For example, I have a game, which has some tools to increase the ability of the Player:
Tool.h
class Tool{
public:
std::string name;
};
And some tools:
Sword.h
class Sword : public Tool{
public:
Sword(){
this->name="Sword";
}
int attack;
};
Shield.h
class Shield : public Tool{
public:
Shi... |
Consider the following CI procedure is in place:
Builds are only deployed (semi-)automatically.
All changes are version-controlled.
Configuration is fixed per environment.
Why use data files (*.config in .NET) versus code for configuration?
Yes, it would technically be "hard-coded" although still centralized rather t... |
Here are two links which briefly describe the difference between the two:
stateless, stateful
In short in the "Stateless" scenario we bind views directly to models, view models just expose the whole objects, not their properties, so we don't need any synchronization between models and view models.
In the "Stateful" sce... |
I am really reconsidering my current class hierarchy for timeslots (in a schedule). I wanted to make them as flexible as possible so it would cover many possibilities of what we could understand as a timeslot, so I ended up with this design:
All timeslots share a chronological/hierarchical order so we're able to define... |
Consider that you have some graphical interface that represents some data structure. For example a text field:
This field is connected to the data structure through events. I tried to make diagram of this:
Of course, there may be many GUI element and the structure can be complex. What happens is, that when GUI values... |
Let's say I got a series of services that are handled by a central hub, part of the behavior of the application is controlled by a series of settings that are stored on a file. Right now when I get a request and create the handler for it I inject an ApplicationSettings object that would allow the object to access the s... |
A question that gets asked a lot is "Why use low level languages if you can code in high level languages more easily (and often tersely)?". I think the answers are fairly straight forward here, being mainly efficiency concerns.
However, I pose "Why do we use high level languages in the first place?". Besides the fact t... |
Why are some programming languages such as Python or Julia considered to be "scientific" programming languages? I guess my real question what is the criteria that makes a programming language scientific?
|
I have a situation where I have an external library. In short, I need to be able to adapt my type to theirs, and theirs to mine. The library has a collection like so:
interface IExternalCollection
{
void Add(IExternal item);
IExternal Get(int index);
}
Now, let me start off by explaining the most straightforwa... |
I must persist handful of properties for several games in relational DB. No other type of DB can be used. Number of games will be around 4-5, and number of properties is (for now) kind of small, but maybe it will grow later. It is almost guaranteed that all games will have same properties (same "keys" to say, not same ... |
Based on the List monad I set out to define Monad instances for the Map type from Data.Map, to perform chained unions and folds on Maps like lists, but with the efficient sorting and merging of Maps:
{-# LANGUAGE FlexibleInstances #-}
import qualified Data.Map as M
instance Monad (M.Map Integer) where
return = M.si... |
Why do people prefer var is None over var == None when is can be used on few objects only?
|
Background
Okay, so let's say I have some high priority (ThreadPriority.Highest) thread t which needs to enter a critical region in order to consume some data. I will use the following code snippet to illustrate my point.
// create a consumer thread
t = new Thread(() =>
{
Monitor.Enter(myLock);
// consume data... |
TL;DR: To access DB functionality in my codebase I currently use a custom layer throughout the code. The layer needs an upgrade in order to begin accepting prepared statements, which it currently does not. I have a choice between abandoning using the custom layer in favor of using another layer directly instead - su... |
I am planning on converting an old project originally from Objective-C to Swift.
The project is currently under the MIT License, and any distributions of it must maintain the same MIT License. However, as far as I know, this only applies if the current code is used, but after I convert it to Swift, the whole syntax wou... |
It looks like a weird design choice, because a Dictionary and an ImmutableDictionary are quite different write-wise. (Read-wise, they both implement IReadOnlyDictionary, which is fine*)
In fact, the current implementation of IDictionary<TKey, TValue>.Add() in the ImmutableDictionary class throws a NotSupportedException... |
Does PI planning actually plan for only a few sprints ahead or does it plan for the whole project(all sprints until production)?
|
I have a hashed value X and need to ensure that any of the data sets D1...Dn can be concatenated with a correctional value C1...Cn and passed into a hashing algorithm to result in the value of X. What I need is a way to figure out what Ci should be in order to ensure that hash( Di ++ Ci ) == X. If I use a simple hash... |
I am trying to figure out what's the best approach when dealing with object references in a JSON to be sent to my server for deserialization.
To clarify, what I mean is how to refer to data contained in the JSON body itself.
For the example let's use the following (incorrect) JSON body:
{
"players": [
{ "name": "... |
I think most of us strive to make our code run smoothly, read logically, and altogether function well. But for those who really enjoy taking the time to figure out how to optimize already good code (whether it's their own or someone else's), where do these individuals best find themselves in the programming world?
Whet... |
I'm in an introductory programming class and we're only in lesson two, so try to keep terminology simple, ha.
I'm a bit confused about when you need to and when you don't need to initialize a variable.
My book says initialization is when you assign a value to a variable after it's declared.
I later looked at my lang... |
I am parsing a infix math expression to a postfix form. I want to store it in a list like [4.5, 3, 0.25, +, -] so that I can process it once it's parsed. I could store it in a string again, but I would have to parse it twice. The problem is that I don't know how to store operators and operands in the same list. I thoug... |
I'm trying to learn how the MVC pattern works so have been playing around a bit. I just wrote this, which was making sense to me, until I wanted to display the array content which has been collect by the Controller class via the View class output() method.
<?php
class Model {
public $arrayPeople = array(
... |
I've recently started designing apps in Android Studio, and I've noticed that the same operations (for example, using a widget) can be completed by either going into the activityname_java file and creating the widget as a java object, or by going into the activity_activityname.xml and using the combination of drag-and-... |
Sorry if I got the wording wrong in my title, but it would be easiest to provide an example in JavaFX
primaryStage.setScene(new Scene(grid, 300, 275));
Now from what I understand, this code is instantiating and initializing a Scene object, but it is not declaring it. If this is the case then would it be right to say t... |
What is a group/family of functions that is random but some number(s) are more likely to come?
For example, calling each of this fake functions 10 times give:
random2: 2,3,2,4,2,6,7,2,2,2
random4: 4,1,2,3,4,4,2,1,4,9
As you can see, random2 gives more number 2, random4 gives more number 4.
Both functions have some pa... |
I am working on this project of mine where I am the only developer. I have chosen git for the version control for the project. Currently, I work from multiple systems and commit to the master branch of my central repository.
I wanted to know if this is a proper strategy or I am missing out of any helpful Git feature. S... |
After learning OOP design then I got to know my programming way was not correct. One should convert physical entities or logically separable components into classes which are reusable and have their own behavior and properties. One must not simply convert all the entities into objects because that would be really cumbe... |
FNV-1, Murmur2, and DJB2 are examples of non-cryptographic hashing functions used in actual applications (see Which hashing algorithm is best for uniqueness and speed?). These are all similar in that they have an inner loop that computes the result by using simple operations such as XOR or bit shifting.
Perhaps these a... |
In javascript you can't use statements in expressions. Because of this you are forced to use logic and ternary operators in an expression when you want to use if or switch etc.. Since I didn't want to use ternary operators everytime I do a condition check, I've written simple functions to do condition checks.
Using the... |
Context
I have modified a lot a software that in under Affero GPL.
I have contributed back what made sense, as it has a completely different direction.
I plan to build a SaaS around it and charge money for its use.
The code is public, with both copyright notices in the LICENSE file: mine and the originals.
In our t... |
I am struggling with the following issue. Let's say I have a component that performs operations on guests and rooms, and uses a number of abstract interfaces, along the lines of:
class HotelManager
{
public HotelManager(IRoomsRepository rep, ILog log, ...);
public void PutGuestInRoom(string guest, int room, Da... |
I think that the type names in Rust are much better than the ones in C. I'd choose f64 over double and u32 over unsigned int or uint_32t any day. Is there any reason (other than tradition) to use those counter-intuitive hard-to-learn names?
I know that names like short and long are architecture-specific, but doesn't th... |
A private company allowed me to use their API to make REST API calls (using Basic Authentication) in my application's server side. They also asked to see my implementation before I can go live.
From their standpoint I understand they would like to make sure the API keys are secure enough.
From my standpoint I would pre... |
In many cases, it is useful to have a constructor or factory method that validates arguments before instantiating an object, returning a new object if the arguments are valid and null otherwise.
But in traditional javascript constructors, you're limited in what you can return. In particular, you cannot return null.
... |
I'm designing a RESTful API for my organization. We do use password-based authentication, which generates tokens. One part of our API requires that the users be physically in the office, i.e. there is no use case where someone would need to be using those particular endpoints while working remotely. (It has to do with ... |
In the following link, the author states that
We have already reasoned that ‘out’ is a static variable belonging to the class System. But now we can see that ‘out’ must be an instance of a class, because it is invoking the method ‘println()’.
But how can a class variable, i.e. static variable, be an instance variabl... |
I have a problem how to go about naming my namespaces and classes. I already figured they shouldn't both have the same name, as it causes all kinds of problems. Most notable problem for me is that I need to fully qualify the class or make an alias. Here is what I have:
Model.DataSource.DataSource
Model.DataSource.FileS... |
Suppose I have a parametrized data type with more than one nullary (constant) data constructor, such as:
data Check a = Valid | Invalid | Unsure a
Sometimes I want to manipulate the non-constant constructors with a function that keeps the nullary constants fixed, and I hope to do it like
instance Functor Check where
... |
We are developing an e-learning website where you can practice LearnItems (typically words of a foreign language). The concept is very similar to Memrise.
When a user practices a LearnItem, a Result object is created (it contains the date of the answer, plus a flag to indicate if the answer given by the user was correc... |
This post felt like it belonged somewhere in between SE Workplace and SE Programmers. However, since it's specifically targeting a programming issue, I decided to put it here.
What are the responsibilities of an architect? I'm asking because at every company that I've worked for, the architect's duties were along the l... |
If it possible
IList <dynamic> = new List <dynamic>;
or
class A <T> { }
class B: A <dynamic> { }
Why it is not possible to do
class U: IEnumerable <dynamic> {}
?
|
This answer describing how Spring for Java works instantiates an object of type Interface which is illegal yet it received 21 upvotes. Why is this answer upvoted for illegal behavior?
Spring contains (as Skaffman rightly pointed out) a MVC framework. To explain in short here are my inputs. Spring supports segregation o... |
This is a design question. I am building a mathematically oriented blog, where I can discuss various areas of statistics. Now with math comes the importance of visualization--in particular interactive visualization. I like the convenience of a static blog generator like nikola or others, but I also want to be able to i... |
So I'm confused on how exactly we as the programmers talk to devices on the computer. Now I'm not talking the big ideas. I know that there are device drivers that sit atop the hardware so that different programs can use there features.
But in general who exactly talks to the drivers? Is the programmer writing the appli... |
I have N buckets. I have M users. Each user can buy anywhere between 1 and N tickets to an upcoming lottery.
I would like to distribute the tickets more or less evenly between the buckets, with the additional constraint that a user can't have more than one ticket go into the same bucket.
It would also be nice if when I... |
I'm building a wpf application which interacts with a sql database.
I'm confused about adding children of children in my window.
For example.. I just created a fishing trip so my fishing trip doesnt have a primary key yet.
I add fishes in the window which when saved will get assigned the primary key of the fishing trip... |
Let's say I am to design a JIT interpreter that translates IL or bytecode to executable instructions at runtime. Every time a variable name is encountered in the code, the JIT interpreter has to translate that into the respective memory address, right?
What technique do JIT interpreters use in order to resolve variable... |
https://en.wikipedia.org/wiki/Rule_of_least_power
Does it mean that if you can do an animation with css you should do it with css instead of using javascript. Or if you can do an application in javascript you should do it with javascript instead of other languages like php or java?
|
I have a wall mesh that is divided into destructible pieces. As it gets destroyed, the wall can collapse into separate objects with physics that can be destroyed as well. (Cut the wall in half horizontally and the top wall becomes a separate object with its own physics).
I already have the adjacency info to know neighb... |
I recently set up my staging and production server environments on Heroku and everything is working great. Through Heroku, you can deploy from a Git branch - e.g. master or my-feature. This got me thinking - should I have a dev branch?
The dev branch would essentially function as the current stage in development; branc... |
I'm designing and application that spawns another processes to handle some specialized work. The application and the process it spawns will communicate through standard input and standard output (and standard error too).
I've been given this same task again and again and I never know how to handle it. The question is s... |
I've been hearing lately more and more about serverless architectures which are based on products such as AWS Lambdas, Azure Functions, Google Cloud Functions, etc.
I understand the advantages of using such architectures, but what eludes me is how small business logic components can be efficiently shared between those ... |
In a library project, I see numerous warnings suggesting that I reduce the visibility of public classes and methods. (Or in the case of methods I haven't written tests for, warnings about them being unused.) I'm using IntelliJ IDEA, but I assume that similar warnings would be seen if my project were imported into ano... |
From: https://en.wikipedia.org/wiki/Event-driven_architecture
Considering:
Events do not travel, they just occur.
Are the following statements valid?
Event channels are conduits in which events are transmitted from event emitters to event consumers.
...
An event can be made of two parts, the event header and the even... |
Does anyone know that Facebook mobile application is using their Graph API directly? or they create another layer specifically for handle their mobile application?
Thanks.
|
I have got a responsibility of designing an app which allocates time slots for doctors booking.
The scenario is like, there'll be entry for doctors and their time slot for each days. For E.g.
Doctor1 | Mon - Fri | 10:00 - 20:00
Doctor2 | Wed - Sun | 18:00 - 20:00
Now, when people will search for doctors, I need to sho... |
I'm an intermediate C++ programmer. Do I need any math knowledge in order to build computer applications using openCV?
|
I am looking for a concise way to refer to the phenomenon of a unit test failing to clean up one or more artifacts, which affects the behavior/outcome of subsequent tests.
Is there a standard term for this?
|
Consider a BDD scenario with some given steps that refer to existence of a set of data in database. For example consider the following scenario steps:
Given there is an active customer
When as and admin I change the email of the customer to 'xyz@gmail.com'
Then an email verification message is sent to the customer
My q... |
I have a number of custom 'server' applications that run on Windows, and I want a way of improving their 'availability' without significantly recoding any client-side (or, ideally, server-side) code.
My understanding is that Windows Failover Clustering allows a server IP address to 'float' between multiple systems, but... |
This is in the continuation of Small classes and methods, but code still difficult to maintain and follow as I have matured the problem and will rebound on people's answers.
Here are all the elements that should be modeled:
1.Model (in this case a link directory)
2.Validations (of the model fields from user submitted f... |
I have a type Bound as a sort of "alias" for an array of three numbers (working in TypeScript with: type Bound = [number, number, number]). I did this basically to help readability by specifying in the name what the array is used for. However, sometimes in my app I need to convert a number to a Bound and vice versa (f... |
I am currently looking into developing a new system utilizing hexagonal architecture and the commandpattern facilitated by a commandbus like tactician (it's a PHP system).
Now I really like the idea of the commandpattern but what I don't get yet is how to get back the actual result of what the command has done.
Lets sa... |
Strategy to display value for a html select
I have a spring boot, application. On the client side, I use JQuery
I would like to know the strategy to display "static value" for a html select.
Example
In the table communicationType I have:
1 - mobile
2 - fix
3 - email
Actually, I put directly the data in the html select... |
According to GNOME guidelines, how sentences should be written in Git messages?
Should sentence in git commit message start with upper-case letter and end with a full stop, or lower-case without a full stop? What is the recommendation?
Btw. I'm asking about English, not Chinese.
|
Im new to RESTful API's and would like to find some info out.
Currently we run a daily digest of eHealth material for the public to read and get up to date content regarding that topic. Which is powered by Laravel 5.2 and a MySQL Database.
We have a linux based server which is hosted with an ISP currently runs 8GB Ra... |
I am having some issues trying to incorporate jQuery UI into my project. I cannot use Nuget or anything else that goes to the internet, so I have downloaded the development package from the jQuery UI website, and have been trying to include the files from the download into the MVC 5 project in visual studio 2015 as fol... |
As a freelancer say for example you developed a web or mobile application for a client as a one time fixed price paid project. You send them the code, install it on their server, and they begin using it for themselves.
Now, normally I'd give my clients 30 days of free bug fixing, before I start charging them for my dev... |
I am trying to improve my programming skills and knowledge and I have been doing some reading about various design patterns and youtubing videos etc.
One subject I thought was interesting was about Singletons being an Anti-pattern which has lead me on to a problem that I am not quite sure how to solve. Allow me to exp... |
As Docker became a very popular tool I read a lot of information about it but I can't get - do I need it as single full-stack developer?
I develop web application that has 2 backend services written in ASP.NET Core and C++ talking to PostgreSQL database and Angular 2 frontend part.
All webapp is routed using nginx.
To... |
I work often with data-bound applications with WinForms; records are pulled from a database and updated in a client application that I write. Stored procedures are used for all database transactions in the client.
I need to programmatically refer to columns from the database - for example, to format a dollar value.
res... |
I'm working on a series of small projects (~1000 LoC each) on my own in C++. My background is in Python, where I'm used to being able to test out small changes in my code in by loading it into a jupyter notebook.
In C++, every time I change something, I have to rebuild the appropriate files and re-link, which can take ... |
I have looked into several message queues as referenced in this link. Several of the larger and more popular ones are in memory only.
I can understand the need for this in some situations however in a large architecture this makes little sense to me. For instance if I have a series of work that needs to be performed su... |
I'm writing a simple console app to rename a bunch of files/folders, and I want to design this console app to be as modular as possible.
The console app is as simple as it gets: Ask the user what the source folder path is, what they want to rename the folder to, and the user presses enter. The app then finds the folde... |
I've been working on a project for a couple years now, and I'm starting to gather a decent user base. I've created a project page with some basic documentation, but it's really not much more than a FAQ at this point. I know that I need to improve it so that it's more informative for both new and power users, and that's... |
I have an XML document like this:
<?xml version="1.0" encoding="utf-8"?><root><a>1</a></root>
I sign this document using a DLL-library, provided by crypto provider, and get a document like this:
<?xml version="1.0" encoding="utf-8"?><root><a>1</a>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:Signed... |
I am very new to workflows, and trying to understand why workflows are used. While surfing internet, I haven't found any strong point for using workflows.
Please explain me the scenarios where workflow based development has advantage in comparison to usual programming based development.
my project is using BPMN 2.0 di... |
I always try to adhere the semver spec when I commit changes. This time though I was wondering what to do when I update my tests: I'm working on an API client that includes a simplified API server running locally for testing the client (since many API methods are irreversibly changing data).
Now, what to do when I add ... |
We have a problem at our org where we have the need to know "with very high certainty" what specific versions of each app/web service/etc. is deployed to a given node and/or environment at any given point in time.
Some ideas have been kicked around, such as:
A custom deploy tool that is backed by a DB, and on each dep... |
My current scrum master is a true believer who is not willing to budge on the official forms of scrum. I don't want this to sound ranty, I am really asking about the orthodox solution to this issue because I have been successful resolving issues with him in the past by recasting things in official terms.
The current e... |
A recently-published article demonstrates a way to make "typo-squatting" attacks on popular programming package managers. It singles out Python's pip, Ruby's gem and Node's npm systems, and shows that they have two things in common:
Packages can be submitted and accepted automatically, with no manual review or human ... |
I am wondering if there is anything wrong with creating generic actions in redux which dynamically change different properties in the store , so that i can reduce boilerplate code.
For example:
//GenericActions.js
function replace(data, property) {
return {
actionType: GenericConstants.ADD
data,
... |
Given the problem...
Given a String comprising of non-alhpabetical symbols, and a Lookup
Table where a subset of those symbols may equate to a single
alphabetical character, output all possible Strings.
...is it possible to compute in polynomial time? I can only think of exponential solutions similar to...
getSt... |
When coding software, should the architecture always be best practices or practical practices in regards to the application being built?
If I am building a two page web application that might live 5 years and have 2 enhancements over that 5 years, should I code in dependency injection, design patterns, model-view-contr... |
I've written in PHP before and when a user connected they get an individual instance of the code which is then closed when the code has finished executing.
In node, I set up my first server to console.log("hi") on every request.
When I refreshed I didn't expect the "hi" to be logged again, but it was - I get its being ... |
When I design the architecture of an application, I usually think about the nature of the objects and the interactions between them.
The way I currently think about mutability is to ask myself if changing a member changes the object altogether. A car can be repainted, but if you change the manufacturer it's another car... |
Correct me if I'm wrong, but if I have an operating system that makes a context switch, then that context switch is in practice a switch from one thread to another, where one thread was running one task and then switches to another task and the reason the threads needs a stack is to save the variables of the task to be... |
I've been thinking about practicing with a simple Microservice (oxymoron I guess) application and I found an issue I was not able to resolve.
I'll go with a concrete example since the definition of cross-cutting concerns is kinda vague. Let's assume I use some of the cloud MQ providers to set up a communication for at... |
I'm a solo developer with a pretty time-constrained work environment where development time ranges usually from 1-4 weeks per project, depending on either requirements, urgency, or both. At any given time I handle around 3-4 projects, some having timelines that overlap with each other.
Expectedly, code quality suffers.... |
Our system has users but we want to perhaps allow some users to be able to use our API service. I'm looking at using OAuth2 for authorization. As it's going to be (trusted) machine-to-machine access I also thought to use client credentials.
So, for example, when we create an article through our API we want it to have a... |
I'm working on a project that requires assigning ID numbers to records about people in a database. Each person may have many records associated with their ID number.
There was a discussion about whether it was desirable to have information about each person encoded in their ID number. For instance, the ID number could... |
When I want to call a constructor on aggregate root class Task, I am interested how can I check if a passed taskType exists in TaskType repository (enforced later in DB on ORM level).
I want to enforce this relation so only predefined task types can be actually used to create a Task.
Is that something that is done in c... |
<?php
error_reporting(E_ALL);
//ini_set('display_errors', 1);
$db_server = "localhost";
$db_name = "2";
$db_user = "root";
$db_passwd = "";
$connection = mysql_connect($db_server,$db_user,$db_passwd);
$db = mysql_select_db($db_name,$connection) or die("Couldn't Select Database");
if($_POST['text']){
$result=mysq... |
Not so long ago I talked to my colleague and he was definitely against using bit masks because it is hard to understand all the values that are stored in the database. In my opinion it is not always a bad idea to use them, for example to determine the roles of the current user. Otherwise you need to store it in a separ... |
I have posted a question regarding Ubiquitous language and maturity level in REST API.
Ubiquitous language and maturity level in REST API?
After some extensive coding I realized that further questions can be derived from this post.
For example, if I am using resource based API, so the API endpoint looks like
http://dom... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.