instruction stringlengths 34 36.1k |
|---|
In terms of good OOP design, what is the best way to structure code that is just containers of list of objects that contains other lists of objects that also are just other containers?
Example: A Cookbook owns a list of Chapters that owns a list of Recipes that owns a list of Directions. Each object is a different lay... |
For a new project we try to set up the development process and the intention is to have a simple, pragmatic process. We use Atlassian Stash with Git in our company.
We came up with the following proposal:
In the central repo exist two branches development and production.
All development takes place in the development b... |
I'm currently in the process of developing my first API. This is a private api that will send information back and forth between my two sites, not one that will be open to the public. I'm working on making it as robust as possible, but since this is my first time developing something like this I want to make sure I kno... |
I'm building my first app and have reached a point where I'm considering switching to a MySQL database. However, I noticed the GPL on the Community version of MySQL. So I did some prowling and noticed that it was also the connector supplied to connect MySQL to Python.
If this connector is going into my server's code, t... |
I'm building a boutique website using Kirby (a flat-file CMS) and I'm looking for a way to structure the site for best performance and maintainability.
The website will have multiple categories and under those categories, it will have subcategories. It will only go a max of two levels deep.
Example of current structure... |
In Angular 2 (currently 2.0.0-rc.6), routerLink is used as a directive to indicate a path we wish to follow in our routing, e.g. in response to clicking a link.
However, in the documentation both of the following are used:
routerLink
[routerLink]
I don't understand when I should use which. The Basics / Template Synta... |
recently I came across this blog post from asp.net monsters which talks about issues with using HttpClientin following way:
using(var client = new HttpClient())
{
}
As per the blog post, if we dispose the HttpClient after every request it can keep the TCP connections open. This can potentially lead to System.Net.Socke... |
I have a repository that contains login credentials
interface LoginCredentialRepository {
LoginCredential fetchCredentials(String username);
}
For this framework, I'm designating one thread to handle all IO-based tasks. This is only by convention, and if someone really wants to submit an IO-based task to a differ... |
The naive solution is to generate the set of subarrays/substrings and check each for the property, but that is very inefficient. Is there a general algorithm that offers better performance without knowing more about the data or the criteria themselves?
The substrings would be defined as contiguous subsets. So for insta... |
I m trying to learn DDD and I m having some troubles dealing with the Infrastructure services.
In fact, I understand what they aim to, but I don't see where they fit inside of my application.
Actually, I m having the following stuff
An application Service (REST API)
Some Domain Services (managed with Specification Pat... |
I have a view controller which has 5 different subviews, these subviews are changed according to some conditions, then there are functions which apply background color and add some minor aesthetics to the views.
I have segregated the functions in the viewcontroller
only for views
i.e Applying colors,adding views and b... |
Our company uses another companys api. This api is written using IBM domino. This api is horrifically inconsistent and outdated. E.g. sometimes returning JSON, sometimes html. Inconsistent naming and types.
What would be the best course of action? I don't think we can force them to update their api. Would it be best to... |
Let's say I write a parser. It takes an argument that is a String and does something with that. This String can be very long so keeping it in a test class can dirty my code. I think that it would be better to keep this String in a file and read it during unit test.
I have doubts if it is still unit test or maybe integr... |
When implementing a state machine and it comes to the fact that a transition depends on an external boolean a, or an enum value b which can be one out of three (which are set somewhere else in the control flow), like
// ... more states ...
L : { // example for a ‘common’ state
event27 → G
event12 → J
// events... |
I have a system in PHP that works like a booking system.
Once a booking is confirmed there are a total of 7 emails/sms that needs to be send. The times of when they need to be send are already known.
For example, 24h before the bookingdate, a email goes out.
Right now we have a cron checking if it is 24h< and the 24h e... |
I need to develop the following Java solution and I would like to double-check here that my approach is correct.
At the very basic level, I need the solution to (1) perform an automated activity at the same time every day. This requires no user input. (2) perform the same activity on an ad-hoc basis which is triggered ... |
How are multiple exit conditions in a system sequence diagram loop frame indicated? And how would the alternative event flow based on how the system exited the loop be shown?
For example a login loop could exit after a valid login or after a set number of failed login attempts.
|
I recently read the Three Big Lies blog post and I am having a hard time justifying the second lie, which is quoted here:
(LIE #2) CODE SHOULD BE DESIGNED AROUND A MODEL OF THE WORLD
There is no value in code being some kind of model or map of an imaginary world. I don't know why this one is so compelling for some pro... |
I have an api with 3 layers
1.) The endpoint layer which exposes api endpoint handler functions. These generally call the business layer, aggregate the results to form an http response.
2.) The business logic layer, which provides interfaces to get or edit data while employing business rules behind the scenes, modifyin... |
I m studying DDD these days, and I m having some questions concerning how to manage repositories with DDD.
Actually, I have met two possibilies :
First one
The first way of manage services I've read is to inject a repository and a domain model in an application service.
This way, in one of the application service metho... |
In the ARM C/C++ Language Implementation Guide (p 99), NOINIT is listed as a pragma directive. In the previous code that I'm working with, __no_init was defined as an intrinsic function (IAR compiler for MSP430). I understand that intrinsic functions are sets of assembly code that are convenient to not have to attempt ... |
I am currently taking AP Computer Science at my high school and while looking at some sample AP test problems I came across one that really confused me.
Sample Problem
The answer to the problem is letter A but I don't seem to understand why that is the answer or how to even begin to try and solve a problem like this.
|
Title say it all - I'm trying to remove every line from a file that contains the string "PresenceManager" I first loop through the file, removing any instance of the string. However, this leaves a TON of empty lines, so I have to go and remove those with another block of code. This seems like quite a lot of code to do ... |
Why aren't lisp keywords protected?
For example,
(define a 3)
(define define +) #makes define useless
(define a 1) #outputs 4, instead of assigning 1 to a.
Is this flexibility so important?
Or even worse:
(define + -)
(+ 1 1) #Output 0.
Where can this be useful, and, can this behavior be blocked? AFAIK, all programmi... |
I have an API that generates a resource randomly when requested.
What path could I use that would follow REST conventions?
A - /generate/random.png
B - /generators/random
C - ?
Should I place all my resources in a root like /api to differentiate them from web pages? (For example, I might want to display a HTML page at... |
I am currently developing a java application, which will communicate with a SQL server. Therefore I created the class Database which is responsible for open() and close().
I want to be able to add data to the database. In this example, the table is called job. Therefore I created a class Job. Besides these jobs, there... |
I'm studying Python and hung up on a simple problem. Let's say we have:
string = "hello"
When we invoke the find method on the string to find an empty string like this:
string.find("")
Why does that equal to 0? I thought it would equal to -1 since an empty space could not be found.
|
I have a design question in the "field" of CQRS / DDD.
I will not explain in depth the domain, but only what's needed.
It's a CONTACT domain, so it manages the contact informations of people and organisations.
A relation can exist between people and addresses. This relation exists in time so it can be active or inacti... |
Sometimes I see bits of code in functions that I suspect could be changed in a specific way later that would break its functionality. For example, function A could be changed to call function B, but it shouldn't.
Should there be a unit test that asserts that function A does not call function B?
The case I am thinking ... |
I am starting to learn parallel programming in c++, and I have a program like this:
for i = 1:N
do something time and memory intensive
end
If I program this in parallel, and my processors have shared memory access, will the parallel programming help?
I thought maybe I am going to overflow the memory, since I am l... |
Albeit a general question my scope is rather C# as I am aware that languages like C++ have different semantics regarding constructor execution, memory management, undefined behaviour, etc.
Somebody asked me an interesting question which was for me not easily answered.
Why (or is it at all?) regarded as bad design to le... |
I am working on client JavaScript SPA and a restful API on HTTPS.
Client application needs to call a public endpoint (no token required) in order to valid (GET) a specific TOKEN previously remember within the SPA application.
API returns:
If token is valid a status code 200 is returned and a json value {"isValid": "t... |
I am a 4+ years experienced C#, ASP.NET MVC5, Flex, Actionscript, Html, css, jquery, php developer.
I have a passion for developing and I'm not scared about learning new things. In fact I read technical books about what I know to get a deeper knowledge and dive also into new things like learning how to work with a rasp... |
I am tasked to design an OpenID provider for the public facing applications of my company.
The idea is to authorize the user via an email/PW combination. The subject will be a GUID.
Should an user be able to change his email address (that is used for login) or should there be a changeable contact email address.
|
System consists of several micro-services and each of them is in charge of it's own context, such as booking, payment, products and notifications.
Let's imagine we have a traveler who is seeking accommodation on website. Accommodation is listed by retrieving information from products micro-service.
Traveler found what ... |
I have a form and I was wondering about best practices when validating names (specifically throwing out characters which do not typically make up a name e.g. 123%^*$£ though theoretically could) and if it's sensible to carry out anything more than checking for presence. I've often read that you shouldn't try validating... |
Freeing unused memory is a major issue, causing unwanted GC delays in some languages, use-after-free vulnerabilities in others, and Rust has significant complexity to try to fix the issue.
Many server-side applications are request (or transaction) based, with no state shared between requests. An idea I had was that mem... |
I have a struct called State which holds all the variables for the program. Rather than being modified by functions directly, it is the value returned.
Here is some code:
#define USERNAME_LENGTH 20
#define MAX_NUMBEROFUSERS 64
#include <string.h>
#include <stdio.h>
struct User {
char name[USERNAME_LENGTH +1];
... |
This program run successfully . What is use of blank return in constructor as we know it return this implicitly . Is it is a bug in java or have some use .
class Demo
{
int salary;
Demo()
{
salary =11500;
//return this;(implicitly)
return;
}
public static void main(String...... |
This is a question for those times you are creating the read model by event handlers.
The question comes down to : How can a Event Handler draw from other sources of information than what is contained in the handled event itself to construct a read model?
I have two aggregates, Person and Address. A person can be assoc... |
Not too long ago I started using Scala instead of Java. Part of the "conversion" process between the languages for me was learning to use Eithers instead of (checked) Exceptions. I've been coding this way for a while, but recently I started wondering if that's really a better way to go.
One major advantage Either has o... |
Say you have an equation like x1 + c1 * x2 + c2 / (y1 + c3) = y2 - x3
My goal is to rearrange it so that all x's are on one side of the equation, and all y's are on the other, f(x1, x2, ..., xi) = g(y1, y2, ..., yj) (so, for my example, x1 + c1 * x2 + x3 = y2 - c2 / (y1 + c3) is a solution)
First of all, is there a nam... |
Unit testing is something I love now after forcing myself to do it in projects (and doing it at work) after seeing the massive rewards it offers down the road when refactoring and ensuring things work the way they should.
Right now I'm writing a software renderer an I'm unsure if there's ways to go about setting it up ... |
Given a set S of disjoint 2D line segments, is there a way to pre-process S into a data structure that can check if a single arbitrary segment L intersects any segment in S in log2(n) time, as well as modify the structure using the same time complexity bounds?
The endpoints in S are closed, and lines may have slopes.
S... |
I have gone through lot of explanations about a compiler and interpreter. I think I understood the difference between compiler and interpreter clearly. I'll explain my learning through the following example. Let's say we have the three lines of code in a file.
a=3;
b=4;
a=a+b;
A compiler converts these three lines in... |
I just picked up a React/Flux app and I'm new to the technology stack. One of the things that's throwing me off is that just about every tutorial I view on this stack very clearly defines Dispatchers as a necessary component.
I'm wondering if the previous developer chose not to use them, or if the notation he used act... |
I'm working on a suite of micro-services, with a web-based GUI. We are using a 3rd party state machine via REST calls. Sometimes we get/set state from one of our micro-services, while other times we go straight from the GUI directly to the state machine bypassing our micro-services entirely.
I'm of the opinion that the... |
I write a lot of software to interact with APIs. These APIs provide data usually in the form of an XML or JSON document. These documents are suppose to follow a spec and structure.
In practice however, this can be difficult to code for. Specs may change, fields may be renamed, moved, dropped, or made circumstantial.
Is... |
In the last days I have searched for a documentation on how and when is it best to use redux and how to design the state tree.
My research ended in the conclusion that there is no one correct answer.
Then I came across this answer in github on that manner by petehunt (The answer is intended for flux).
He's answer is a... |
Just saw a code snippet that used an array pop assignment in the while condition; was wondering if this is acceptable/good practice?
var arr = [0,1,2,3,4,5];
var current;
while (current = arr.pop())
{
// do stuff to each element stored in current
}
|
Whenever I learn about a high-level language I want to learn about, part of me says, "I should probably learn the lower-level language it's built upon to really master it". For example,
Ruby => C
Closure => Java
Elixir => Erlang
My experience with Ruby and C makes me think that I've got it backwards. I learned Rub... |
I've got java logging user activities to Fluentd, Fluentd is then writing these activities into an elasticsearch index.
Every user activity is recorded, some include:
User1 follows user2
User1 likes article1
User1 creates article
User1 searches for tag
user2 signs up
More...
Now for each of these activities I'm stor... |
Context:
With my team I created an "online platform" for a client which moved their operation from a paper based system to a content management system (CMS) based submission system on a Virturl Private Server (VPS).
A large group of users submit content to the CMS in the form of uploading PDF files. These are critical... |
I have a complex problem to be solved, I have several excel files containing data from over 1200 counties from 56 states. Problem is that most of the counties has some columns which are different from rest of the counties. And one county may be in more than one state and having different columns. I have to upload these... |
The interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use.
My question is: how exactly can a client depend on something that it does not use? It looks like the existence, the state and even non-existence of something I don't use, I don't depend on. Perhaps, in... |
the QA team should ideally do their testing on an environment that almost exactly matches the prod env (to minimize uncaught bugs that arise due to setting differences).
If that's true, does the QA team typically do the testing again on prod post deployment in the googles and amazons out there? If the answer is yes th... |
We are arguing with colleagues how to name a method:
ProcessInstructions vs ProcessInstructionsHavingDeliveryInProgrssStatus
Those who insist on the first name say that it is more generic, and does not reveal internal implementation. Furthermore, second name is really awkward.
The other half prefers the second name. De... |
I'm building an api and a bit into the development I realized that I constantly change the order of the page and pageSize parameters.
Currently I use C# and javascript, so the method declaration looks something like this:
public IEnumerable<Order> Get(int pageSize = 9, int page = 1, string name = null)
And the client ... |
I have a cli application, that has the option of displaying file paths in addition to typical output. Some file paths can be quite long so I want to cut the path off once it is longer than a certain amount of characters.
Traditionally cut off sentences would be cut off with an ellipsis ..., however using three dots wou... |
I'm trying to get my head around DDD, and I understand that I have a domain object and a domain service.
My domain object is an interaction which can be different types of interactions with a client, like a meeting, telephone call, visit etc.
So I created an interaction service and now I want to create the logic if the... |
Having worked with a few programming languages, I've always wondered why the thread stack has a predefined maximum size, instead of expanding automatically as required.
In comparison, certain very common high level structures (lists, maps, etc.) which are found in most programming languages are designed to grow as req... |
In my team we have a policy that each code should be reviewed by at least one other developer. When the review is done the reviewer just clicks the merge button so the code ends up in development. Recently a idea came up that the reviewer should not be able to merge directly, but should pass the code review to a member... |
I am a front-end developer who is familiar with HTML, CSS, JS and to a degree, AngularJS.
I've chanced upon Firebase (firebase.google.com) - and was wondering if I could, with my lack of knowledge with server-side code, use Firebase for my app.
Will I need to learn JSON for this?
|
I m trying to understand the core concepts of DDD and I m having some troubles dealing with validations.
In fact, I m actually wondering where and when should I use specification pattern instead of Entity / ValueObject validations.
Moreover, I m trying to find a way to avoid this kind of validation in my Application se... |
Sorry for the codeless post, but I am wondering how to handle a complete UI redesign for a big web product? Maybe somebody have experience and could actually determine the steps on how you would do this?
Should it be done incrementally? Should it be redesigned at once and delivered to production? What could be the step... |
I work for a software company which tend to deploy applications on premise for enterprise customers. The software normally consists of server side software (a few microservices) and 1 or many client applications.
The deployed applications are usually a highly customised version of a general application. So we have a s... |
I'm trying to understand what is the motivation for buffering the print to standard output.
I've experienced this in multiple programming languages, a scenario where you're trying to trace a bug by doing print outputs and your print statements aren't printed real time just because the buffer wasn't flushed.
So to get ... |
Have a plain WPF that started a proof of concept got demoed and bought and went down that path for a couple years.
Time to start fresh and would like to know proper pattern.
A WPF app that will talk to a WFP Service with a SQL data store.
The crazy light colors are sliders and clearly will not keep those colors.
What... |
I am implementing the dot operator/notation you see in languages (obj.method();) with ANTLR4.
Everything is working fine (except one thing), a simple hello world program works:
module test;
sfunc main {
std->println(obj="Hello, World!");
}
-> in this language is the equivalent to . in Java and many more languages.... |
Why is it
Create
Read
Update
Delete
instead of
Get
Remove
Add
Set
?
I've been working with an API that uses ADD and SET and REMOVE. Most accessor functions are named get...() and set...(). I couldn't find anything online https://duckduckgo.com/?q=gras+crud&ia=web
|
I read somewhere (probably on StackExchange) that certain large enterprises and government agencies will only use technologies that have been around for ten years. Can't find the source right now. Could someone please confirm this and provide details on which (types of) organizations have this policy? I'm wondering als... |
It happens so that the best practice of using EntityFramework includes taking advantage of the IQueryable inside using block, like:
using (var ctx = new SomeDbContext())
{
...(do something with ctx)
}
If we want to decouple database and business (and eventually presentation) tires, it involves creating other objects... |
I'm designing a vector drawing app.
I need to implemente copy and paste, shapes insertion, deletion and transforming while still being capable of including new tools with easy in the future.
The way I think about it, this is a finite state machine, so i thought about a State Pattern. The stage behaves differently based... |
I've been designing and programing websites for the most part of my adult life. I've always done this solo, freelancing mostly and working from a single machine.
Currently, I use Dreamweaver for the coding and also the publishing of the sites (via FTP) and I work directly on the live sites. That's about the extent of m... |
I'm designing a JWT authentication workflow for a RESTful API which uses two kinds of tokens:
Phone token, a short-lived token - issued by completing an One-Time-Password challenge. Its task is to prove "ownership" of a phone. It carries the phone number.
Access token, a long-lived token - issued by providing a valid... |
I'm coding along with the examples in Build Awesome Command-Line Applications in Ruby 2 I'm using git and storing my code on github. The example code can be found on the pragmatic bookshelf site. They mention:
Copyrights apply to this source code. You may use the source code in your own projects, however the source co... |
Let's say I have a client that is consuming Vehicle objects sent from a server.
I have two types of vehicles: Car and Truck. Some Cars can be inHybridMode but not all of them. The server currently supplies three specific models in a list: Prius, Camaro, and F150. In the client I have created this hierarchy:
abstract cl... |
I am using the lombok @NonNull annotation for some of my fields, parameters and methods, partly for null checking, and also partly for documentation purpose. It is then confusing if I added a @NonNull/@NotNull annotation from other libraries.
Then if I also want to add a @Nullable/@CanNull annotation for some of my cod... |
I'm now a huge fan/believer of Jeff Patton's user story map. I'm currently reading his book..
Jeff talks a lot about depicting different roles on a user story. However, I'm not sure how to do this when there are different platforms per role? I.e. say I'm developing a software for buyers and sellers. For buyers, I devel... |
Say, I created a custom button which includes some animation which is played when the button is clicked. The animation takes 500ms. During that time (until the animation is over), the button should not receive any inputs, and so should other items wait for it to end.
If I implement it like this:
public async void Click... |
Simply put, what happens when I have a delegate, that delegate contains a method with a tail call request, and then I call it from a non-tail position?
If I called the method directly, it would discard the existing params and reuse stack space. Does it do the same thing to the Delegate::Invoke's stack that triggers it?... |
Various kinds of buffers have different names that more or less describe the functionality that they achieve such as the FIFO, or the circular buffer. They are both buffers, and serve similar purposes however their implementations are different.
I have a kind of buffer that only holds the last X seconds worth of data. ... |
So i've been going through some of my old code from the time i was learning the basics of wpf and i found something intresting.
I had a class in the format below
public class TempClass
{
public bool IsValued { get; set; }
private SolidColorBrush _isValuedColour;
public SolidColorBrush IsValuedColor
get
... |
I have a small Elixir module that takes up almost all the execution time of my program. I would like to optimize it. It seems like it takes around 15x as long time as the same implementation in C, so there should be some margin to take from. The natural step seems to write BEAM assembly for this module, but that doesn'... |
I'm working on a software project which I intend to release as FOSS in some way. My code includes quite a few header/source files written by others:
Better Enums
A slightly modified GSL Lite
An adaptation of some of GCC 4.9.3's libstdc++ for use in CUDA device-side code (so originally FSF code based on SGI code)
An im... |
I am having some confusion as to how to decide what to choose between Data Consolidation/Data Integration and Data Synchronisation? I know that:
Data Consolidation/Data Integration: refers to the collection and integration of data from multiple sources into a single destination. During this process, different data sour... |
My team implemented an alert broker system. The way it works is this:
Event sources generate events, with mostly arbitrary structure, and the broker listens to them.
Users go to the broker and use an expression language to create alerts for the events. The expressions can reference arbitrary attributes of the events.
... |
First of all I am not a professional programmer, but a student with a programming hobby so I am sorry if my question is stupid.
I want to write a chess engine to be used on the web and had already started writing it in JavaScript. After searching around I however found out that JavaScript is not ideal for this task. I ... |
I'm creating notifier/notifee relationship. I'm not quite sure which is better in design though. As for "better", my goal is to get something that is extension friendly. As an example, see below:
alien_enthusiast.notify( UFO_Sighting( London, 1500 ) )
vs
alien_enthusiast.notify_ufo_sighting( London, 1500 )
Which i... |
After starting the design of a sample application with Hexagonal Architecture I got to the application layer that should be basically an API to manipulate the domain in some way. My question is: In what form should I pass the parameters to the application layer? I can't pass anything contained in the domain because it ... |
I'm trying to understand builder pattern usages and so to call to separate is usage types in groups. Here is what I discovered:
Builder can be used to provide immutability (avoiding telescoping) for an object he is building. So called Joshua Bloch's builder. So, we use builder to facilitate building of object with a l... |
I'm trying to build an architecture where I have a Domain project with all my domain models, an Infrastructure project with my Services and Infrastructure.Entity with my Repositories and entities.
However, I'm a little confused on what's the best way to pass objects between the different layers.
The presentation layer ... |
C++14 seems to have omitted a mechanism for checking whether an std::mutex is locked or not. See this SO question:
https://stackoverflow.com/questions/21892934/how-to-assert-if-a-stdmutex-is-locked
There are several ways around this, e.g. by using;
std::mutex::try_lock()
std::unique_lock::owns_lock()
But neither of th... |
I often find myself puzzled with such a questioning. I need to version my projects for two reasons:
publish source code with its whole history so that people will be able to get into it, explore it and make use of it.
archive my project with its whole history so that I will be able to revert, fork again etc.
There ar... |
When migrating a project from one heavily-used library X to another library Y which is essentially equivalent but doesn't have the same API, it may be necessary to make a lot of changes. In the case I'm working on right now, ≈500 additions and deletions: not impossible, but I'd normally say, that's too many for a singl... |
When I was reading Introduction to Algorithms (3rd edition, P188), there is
an algorithm called Tail-Recursive-QuickSort and we have to prove the correctness of this algorithm.
TAIL-RECURSIVE-QUICKSORT(A, p, r)
1 while p < r
2 // Partition and sort left subarray.
3 q = PARTITION(A, p, r)
4 TAIL-RECURSIVE-QU... |
I have been writing some automation test scripts for a mobile application.
Thus far my tests are very basic, I am struggling to know exactly what to test.
An example of a test I have written:
Enter valid login credentials > click submit button >
(if element on new page is visible) > pass else fail
So to test a click th... |
I've been learning C# lately to see the other side of the coin (I have a decent amount of Java knowledge already) so I've been reading up on C#, and I came across an article called C# for Java Developers, and in reading the article, I saw something that I had never heard before.
It is typically recommended that one cr... |
Would it be feasible to calculate directly a k-permutation like k = 10^200000000?
If not,
What would be the computational limit to calculate huge k-th permutation in a today computer? How can I estimate it?
Like, what's the biggest k-th permutation that I could calculate in less than a day?
*Note, the permutatio proces... |
In the interest of continuous improvement I'm interested in finding ways to improve our software development process. There are a lot of articles out there which define a set of workflows, but all of them always take the simple approach: 1 repository, 1 team, 1 product, 1 flow. But none of them seem to cover how someth... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.