instruction stringlengths 34 36.1k |
|---|
I retrieve some pieces of information from four forecasting APIs, I have three main methods that I will implement in each API's manager:
history (only one of them provides this function)
forecasting (all of them)
yesterday data (only two)
I am thinking about the following pattern (it's similar to facada/str... |
Often, I'll abstract common logic out of a class by creating an abstract base class with only protected members. For example:
class Base {
protected:
void foo() { ... }
std::map<KeyType, ValueType> d_map;
};
class Derived : public Foo {
public:
Derived() : Base() { ... }
// ...
};
My logic here... |
Pretty much what the title says. I'm asking with Java in mind; however, I'm not limiting the premise to java. Would it be considered counter-intuitive to have a cloned object not pass equals function?
|
I'm working on a Desktop application, and to allow frequent updates without too much hassle, I want to install a simple "bootstrap" application to the "Program Files" directory, and the actual application to "C:\ProgramData". This would allow me to automatically update the application without administrative access, sin... |
I remember in the past, for some languages which I can't remember, be it Fortran, Pascal, or Scheme, a logical operator
2 || 3
will always return a boolean value.
But in the modern languages: JavaScript, Ruby, Python2, they all return 2.
I want to be careful about: which common languages return strictly true / false, ... |
I'm in the process of writing an bidirectional, asynchronous socket server and server handler. The base handler class I'm working off of is as follows:
class BaseAsyncSocketHandler:
async def send(self, data: bytes) -> int
However, I want to write a subclass that sends two arguments, an event and arbitrary corresp... |
I'm currently designing an application, and I'm confused at how to break apart my monolith application. After doing some research, service fabric actors seem to be the best solution for simple processing, but I'm confused at the approach I should take.
How my current application works in my monolith:
IRC Message comes... |
If got a native application which adds value by for instance analyzing measurement data from measurement programs. Some of them have an API, so I can get their data via IPC. But how can I achieve this for specific native programs, which won't support this?
AFAIK I have to reverse engineer the assembly, look for the var... |
Why is there no key specified with .NET KeyNotFoundException (in message/property)? Is it because of performance reasons? Is it because when Dictionary finds out there isnt any requested object by the hash it already doesnt know the context of the original key? I couldnt find an answer to this question anywhere.
|
On my local server, I create aliases like these to speed up my work:
alias bashrc='vi ~/.bashrc;source ~/.bashrc;echo bashrc has been sourced'
alias bashprofile='vi ~/.bash_profile;source ~/.bash_profile;echo bash profile has been sourced'
alias aliases="clear;cat ~/.bash_profile|grep --color \"alias\""
alias home='c... |
I'm working with an external system which sends event-like data to us. An existing SDK from the third-party guys parses the JSON so in the end we get something like the following class:
public class Event
{
public string Type;
public dynamic Data;
}
The requirements are as follows:
All events should have a d... |
According to a JSPerf snippet (and some others), default JavaScript map() implementation is 21% slower than using a basic for.
Looking at the official polyfill, I immediately understand why map() is that slow.
Polyfill strange part
line 15: var O = Object(this);
Initial object is converted (and duplicated) in a JavaSc... |
How do programmers retain knowledge for languages/technologies they don't use on a regular basis?
Take for example the PC Assembly Book. The author states he rarely uses ASM at all. Yet he was able to write an in depth book on the topic. How was he able to do this?
I've spoken to a lot of people who agree that they sta... |
A simple DB containing two tables could be:
CREATE TABLE Stock ( StockID INT StockDesc VARCHAR SupplierID INT
PRIMARY KEY (StockID) FOREIGN KEY (SupplierID) REFERENCES Supplier(SupplierID))
CREATE TABLE Supplier ( SupplierID INT SupplierName VARCHAR PRIMARY
KEY (SupplierID) )
(Assume each stockID has only one su... |
I have a set of nodes arranged like the below image. Left columns are parents, right columns are children. A line denotes ancestor/descendant.
When I select a node, I want to find the immediate family, and then any children-of-children and parents-of-parents. But not parents-of-children or children-of-parents.
So in... |
If I have written a privacy tool as a .NET web application which is to be hosted on a commercial hosting site, other than hosting it in a privacy friendly country, how can I assure users that the application has not been compromised by a third party at the host?
Obviously SSL will be used and the assemblies will be as ... |
Suppose I have a repository that is private (always has been), the code in this repository has been licensed under license A for a very long time with hopes of making the repository public in the future.
I now decide to make the code in this repository public, before I do this, I decide to change the license to license... |
I'm trying to think about the best method to write a function whose primary operation is going to be doing crud on the database. Here's what the overall structure of the function (sans any refactoring) will look like:
public function cancelWorkRelease (workReleaseID number, key string){
validate key...
... |
I'm reading the book "Agile Software Development, Principles, Patterns, and Practices" by Robert C. Martin.
When he talks about the Dependency Inversion Principle he gives the following example of a DIP violation:
This seems very clear to me, as the higher-level object Button is depending on a lower-level object Lamp.... |
I'm working on a system split into multiple services. Some services (and especially the front end web server) depend on other services to function. When developing these locally, do you point to the dependencies in staging, mock them out, or run them locally?
Are there any tools to make this easier? Would it be a good ... |
We need to have an endpoint that allows us to check if a user's email is unique. This operation doesn't seem incredibly RESTful and we're struggling to figure out how to make it fit. We've been debating on whether we should make this more of an RPC style endpoint that might look like the following:
URL
GET identities/c... |
This is a naming convention question.
In C#, someone suggested that variables of type List<T> should be named as listBlah instead of just blah. Similarly for variables of type Dictionary<keyT, valueT>.
I think the reason is because we can guess the type of a variable by just looking at its name, without having to find ... |
Suppose you have a PBI or User Story which can be split by platform like:
"As user I want to read my feed so I can be updated with news"
But that User Story is for iOS, Android and Web, so we use to split by platform and create a different card for each one, but when the sprint finish, and only two of the three cards a... |
I have a cyclic dependency in my architecture design.
Let's assume there are the following modules:
FileSystem (uses Logger)
Handles file operations like reading, writing files etc.
This module should log its actions. The logger is injected via dependency injection.
NullLogger (implements Logger)
Discards all log mess... |
I've been mainly programming PHP, and I recently started with C++.
In PHP the return of a function can be of any type, so you can do checks like this:
public function doSomething()
{
if (! this->userHasAttribute()) {
return false;
}
return "you are logged in.";
}
So basically, if the user would not... |
I'm designing an application that will be appending blobs to a file on disk (local filesystem) and I'm currently thinking of how to deal with consistency issues that could occur if:
The application suddenly crashes
The whole system stops, e.g. due to a power outage
The goal is that, when the file is later-on read, th... |
The system I am working on employs quite a sophisticated caching/preloading mechanism for external third-parties, and since it is built on a microservice architecture, I would like to extract the whole caching/preloading functionality from a feature microservice (say, booking/searching) to a dedicated one:
+-----+ ... |
I have a current situation where I have to design calls to multiple webservices, coming from different companies, let's say EnrollFacebook, EnrollGoogle, EnrollYelp, EnrollBing.
I need to build different options that bundle this enrolls, for instance:
PlanA: EnrollFacebook, EnrollGoogle, EnrollBing
PlanB: EnrollGoogl... |
I'm going to implement a BFD module (for MPLS LSPs) in VxWorks and was wondering the following:
Is it better to create and use a separate timer instance (<2048) per BFD session at the specified Tx interval
or
is it better to use a global timer that runs at 100us and checks each session's the time that has expired since... |
I've been puzzling over a good implementation for this for a while. I have a program that does a long-running I/O operation (downloading a file) and a long-running CPU operation (parsing its contents). To improve efficiency, I wanted to have one thread pool perform the I/O section and have it pass tasks to another th... |
I have a very simple question that has been haunting me for a while when my code starts growing.
Should parameters be replaced by global variables when they go through long routes of nested function calls?
I understand that global environment can make the state of a program unpredictable because many functions can mod... |
At work we have a project where we're pushing pieces of the monolith into modules. (A java project making smaller maven modules that we pull in via maven dependencies). The pattern we're using pushes each module into a 'pair' - with a module for the interface, and a module for the implementation.
The thought occurs t... |
Suppose we have a class Player with classes PhysicsComponent, InputComponent and StandingState, DuckingState.
The class Player itself does not have an input function, the InputComponent does. But when we change states to DuckingState, for example, the behavior of the input function changes. So how is it set up?
a) The ... |
I have implemented a mutex on an embedded system that have armv7 processor and a basic scheduler
There are several instructions in armv7 instruction set that are used for power efficiency.
Two of these instructions are WFE (wait for event) and WFI (wait for interrupt), the instructions enter the processor to idle mode... |
I know this is a classic problem but it's so hard to chose the right way or the best. Let me present you a simplified version of the code.
Design 1 using switch :
public class Disease {
private Color color;
}
public class City {
private String name;
private int yellowCubes;
private int redCubes;
private... |
So, at the moment I find myself building my c#/.net (web) application ( or folder/project/package-...) structure often like this, thinking about it in a "somewhat onion-architectural way":
myApp
- API
- Controllers for HTTP, REST etc., may even be a whole gui, though ...
- Domain.Model
- "Busine... |
I have two engineers with very different development styles.
Engineer A prefers a high degree of upfront planning and designing, considerations for all possible options with pros/cons mapped out. Engineer B prefers to find the quickest path to test.
We are a skunkworks team and are responsible for testing a bunch of n... |
I am facing a BIG BALL OF MUD pattern (according the Foot and Yoder paper) at my current job attribution.
Interestingly that's not really classified as an Anti-Pattern, and yes the Product works at least.
My question is a bit different regarding the
How do you dive into a big ball of mud?
How do you dive into large c... |
I have a large-ish application which's purpose is to aid the user in designing and analysing multiple configurations of Battle Mechs in Mechwarrior: Online. The curious can find the source here.
Essentially the data model is a VFS of directories and files where each file is a "loadout", a loadout is a base Battle Mech... |
I am building a solution for the recruitment division of an organization. The requirement is to create new employee records in the organization's database for the applicants who have cleared the interviews and are joining the organization.
I have built an API to receive the 'Applicant' object from my HR system and cre... |
Feel free to correct my history, but as far as I understand it, Rx and the Reactive Manifesto trace their roots back to C# and its Reactive Extensions, which is uses push (callback-based) messaging, so that Publishers call Subscriber methods with values, rather than returning values to a subscribing scope like an itera... |
If I had a development workflow that supports SCSS and uses bootstrap. I can place bootstrap tags two ways...
Inside the HTML: <div class="col-sm-3 offset-sm-9 col-xl-1 offset-xl-11">
Part of the SCSS: <div class="mymain"> with the following SCSS
.mymain {
@extends .col-sm-3;
@extends .offset-sm-... |
I need to design an UI to edit a research paper, I don't have enough knowledge about the research domain but still I tried to do my best and thought to design a normalized schema. I am describing the requirement below.
Sample paper format:
Below paper showing 4 authors affiliating 3 different organizations.
Decoupling... |
Might be a silly question, but what is more logical:
object.actions.bark() or object.action.bark()?
Simply about plurality. I know arrays are usually pluralized. But if I were to be consistent; ideally, objects should be singular in nature, right?
I guess you could say my example was more of an associative array rather... |
Let me provide an imaginary scenario so that my question is fully understood. Let's assume you are an experienced cross-platform developer for iOS, Android and Windows Mobile.
Someone asks you to make them a simple digital clock. Nothin fancy or special and not even a specific font is required. All they want you to d... |
I'm switching from Java to Python and am having trouble understanding the @Property decorator. I realized in OOP languages (such as Java) I don't fully understand the point of mutator methods in the following sense:
Say we have a private variable x. So we need to make a mutator method
public void setX(int val) {
x = ... |
Say for example I have some unused code that I want to use in the future and does not work with the rest program,or say that I come across some interesting code online. Is there any good program that I can store different pieces of code in?
|
Specifically for ReactJS and responsive frameworks that show/hide elements based on width like Bootstrap.
Because ReactJS has a virtual DOM I am presuming doing the DOM manipulation is faster and in the end a bit easier to debug because you are not trying to think which parts are display:none and there are less element... |
I need to design a system where I need to check if a key exists or not.
Currently I am already using aerospike for the cause but my use case is slightly different.
I will have a key like this ( A group of 3 integers)
--
For eg.
1-105-1133441
222-1000-1891893
I just need to know if this key exists or not in the set.
If ... |
Me and my collegue were having a discussion about when assignee should update 'due date' of the task in JIRA. My point is, assinee should update 'due date' only after he starts working over it so that he has some idea about the time estimate of efforts required. His idea is that 'due date' should be set by managers so ... |
In a Java program which I did not made and cannot change, only write extensions for it, the design forces me to create an object which will never be garbage collected. I tested and I can do it through the use of statics or anonymous object instantiation. I know I can do something like:
public static MyObject eternalObj... |
I want to test my web service/web method not by using SOAP but with Junit or other framework. The first solution that I have founded is to create stub of my project and use a client to call this method; but what I want to do, is not to use a client, but directly call my webmethod inside my project; I am using maven and... |
I am working on one project which redirects user to custom page after login, registration etc. FYI, the custom page can be configured as per customer from admin settings.
I am trying to follow some design-pattern guidelines to achieve this. So far I have designed my classes as below
File: RedirectInterface.php
interfac... |
I'm planning out a microservice adoption for a rather big monolith.
The current plan is to create new features using microservices and constantly extracting features from the monolith into services.
During that process is it problematic to let microservices talk to the old monolith?
For example, A new Product is develo... |
For example, facebook and google have a lot of APIs, like getting data and doing actions on behalf of a user (backup files to Google Drive).
I can read all of their documentation but I usually like to keep it very technical. Documentation has a lot of unnecessary text :(
Is there a standard for querying a site's (serve... |
I am currently in a class for software testing where for our semester project, we have to perform multiple types of testing on it, such as unit testing and integration testing. For integration testing, the professor said to use mocks and mocking libraries (like EasyMock and Mockito) for our integration testing. I'm g... |
The "Reinvent the wheel" antipattern is a pretty common one - instead of using a ready solution, write your own from scratch. Code base grows needlessly, slightly different interfaces that do the same thing but slightly differently abound, time is wasted to write (and debug!) functions that are readily available. We al... |
I'm designing the database for an application that will need to track inventory. I'm not sure if it's good database design to use "inventory pulls" and "inventory pushes" tables to store each change to the inventory, and calculate each item's count based on those pulls and pushes.
Doing it this way would would allow me... |
I'm designing a system where items can have tags, which is easy enough. The problem is we also need items to have arbitrary attributes. For example, an item could have an attribute called "Length" with the number value of 10. Another item could have no "Length" attribute. This is to allow users to search for all things... |
The background
I am working on an ECS in C++ for fun and I am trying to make it as efficient as possible. One of the optimisations I am striving to implement is to minimise cache misses by storing the components contiguously in the memory.
Since I want to expose the interface to Lua, I cannot use all the compile time g... |
Would like to start off by saying, I am asking this as a purely academic exercise; I am quite happy to just continue to use the repository pattern.
I have heard "I put persistence methods in my business objects because when to persist was an integral part of the business logic" which I do not think is a valid reason, ... |
I read with interest this answer from Jeff Sutherland, co-founder of Scrum:
Q: What's your view on the Business Analyst and how it relates to Scrum? Is there a place for the role or should the skill set of that position be spread across/owned by the team?
A: The Business Analyst is responsible for clarifying the requi... |
I understand that the main code uses the factory to return an abstract pointer of the object desired, but it doesn't change the heritability of classes.
Can you explain in which context does the factory pattern reduce coupling?
|
I had a conversation with a few co-workers and the concept of thread safety for a data structure came up.
In this example, we have 2 threads: a main thread and a background thread.
For the following pseudo class:
class Foo {
Array myArray;
// Only ever called on the main thread
// This method will call into the ... |
Suppose I am writing a test method for an object.
This object replaces sequences of blank characters in a paragraph with just one single blank character.
I came up with this partition:
Sentences with 0 blank spaces
Sentences with only blank characters.
Sentences with blank characters in the beginning sentence.
Sentenc... |
I am trying to design the best way to send reminders to users for events they are registered for:
reminders should be sent 72, 48 and 24 hours before the event
reminders cannot be sent twice (so user A registered to an event B should receive at most 3 notifications)
if users register after one of the three intervals t... |
I have been struggling to understand the reasons why typescript developers choose the way they implemented inheritance.
What I would expect from any language supporting inheritance is these order of work:
The derived class initialized properties are initialized
The base class initialized properties are initialized
The... |
I keep reading stories from developers who state that once they are able to get the FP programs written in languages like Haskell, Ocaml, Elm and even Rust, to compile without errors, they are pretty sure that the programs will work correctly.
They usually state that it is mostly due to the type systems of those FP lan... |
Another programmer just started working in our team and submitted a patch. What required was to have something that compares and check a couple of conditions and set a property based on the outcome. The patch, in essence, is a class that implements the requirement as something like this:
class Processor {
A a;
... |
Is it bad design to have an abstract class inherit from another abstract class?
I have a single base node (class BaseNode) and 3 possible child node types (Sink, Process, and Source).
Is the inheritance between BaseNode and SinkNode good practise? If not what is another solution?
class BaseNode (metaclass=ABCMeta):
... |
I have written a WPF app which is now starting to suffer. There is no real way of adding new features to it in it's current state, it has become sluggish to use. This application started as a demo and has unfortunately been sold and then expanded upon (sigh).
At first it was just lots of code all on Main. It was rap... |
In this 2003 article by Stephen Figgins on linuxdevcenter.com, Bram Cohen's BitTorrent is described as using the "Fix Everything" design pattern.
A less common approach that both makes BitTorrent harder to grasp, but worthy of study, is Cohen's use of idempotence. A process is idempotent when applying it more than on... |
It's been considered for a reason, that using for namespaces/names is side-effect-prone, and generally, fully qualified names should be preferred.
I've come up with an approach on that, which I couldn't find implemented yet, so I created my own project.
Briefly, the idea is to define a set of macro which would unfold i... |
I've noticed something strange in a few open source projects that use Semantic Version. In React 15, the React team switched to semver. Similarly, the Angular team switched to semver in Angular 2.0.0.
Semver declares that a major version bump will happen "when you make incompatible API changes". In React 16 and Angular... |
I am developing a small application and trying my best to make it as professional as possible in regards to design pattern etc.
It is a JavaFX app, and my app works fine but I am uneasy at the fact that I am instantiating the back end in the front end. I tried my best to follow MVC pattern and I think I have so far, ... |
Today a colleague who is studying systems engineering told me that software design constraints and GUI requirements (Exs.: the software shall be develop in three layers: presentation, business and persistence; the GUI shall use an tree object to display the structure) could not be considered system or software requirem... |
I am working on a project which is split into multiple git repositories instead of just one. Each repository is for a library or an application. The libraries are used by the projects or other libraries.
So I often have to deal with multiple repositories, for pulling the latest change, for working on a feature which sp... |
I'm trying to better understand the pros and cons of REST. I think I have a pretty good hold on the core factors, particularly creating endpoints/URIs that better represent the resources in play and using hypermedia to eliminate coupling of clients and the URIs to the application
My understanding is that if clients ar... |
I am working on a C library (SlipRock) for interprocess communication.
The library currently exposes a simple, blocking API. This is easy to use, makes misuse (relatively) difficult (this is C after all), and will be (relatively) easy to implement cross-platform, once I get around to implementing the Windows port (whi... |
Git can generate patches/diffs for binary files as well as for text files.
I'm trying to figure out what encoding it uses for its binary patches.
Here is an example:
diff --git a/www/images/openconnect.png b/www/images/openconnect.png
new file mode 100644
index 0000000000000000000000000000000000000000..51a5d620083cafdc... |
I have a class library-- call it Services.dll-- which is a wrapper for some third party functionality. The third party gave us a bunch of DLLs and those "inner" DLLs call a WCF service.
Normally, when Services.dll is running, it lives within the web site's process, and uses the web.config associated with the site. So... |
Originally, in most languages, I would like to put constants into a class like that:
public class AppConstants{
public static final double HEIGHT_MAX=20.0;
public static final int COUNT_MAX=100;
public static final double WEIGHT_MAX=30.0;
}
but I found it is violating single responsibility principle, for ... |
Like this:
Campaign:
type: object
properties:
id:
type: string
description: "A GUID identifier"
referenceId:
type: string
description: "A consumers identifier they have used to map their own systems logic to this object."
name:
type: string
description: "'Great Campaign 2017' as an exampl... |
I am working on a team that is geographically distributed between Australia and the Philippines. Until recently, we have been using a single SVN server to maintain our code, with the server containing a few repositories (let's call them Client, API and Common), with Common code shared between Client and API via SVN ext... |
Say I have a lot of page with ajax. Is there any convention or recommendation on the format/structure of an ajax response? Namely, if there's an error, a server returns http status 4xx or 5xx and... what structure should a json response have? Should it be with the root-level key "errors"? What structure should an an it... |
I have a cpp project which source code I want to split into 3 groups and want to define structure for these files by creating folders with nice name.
First group are files related to socket communication. These files contains implementation of company protocol used over the UDP socket. In future there will be another i... |
In one of the projects the CTO has chosen to use a message broker in order to connect microservices. Is the use of such software aligned with the microservices theory?
Attempt to answer the question
In Sam Newman's Building Microservices chapter 12: Bringing it All Together, the author mentions seven principles includ... |
I am developing a safety critical embedded system and I am programming in C.
We have a set of const structure declared in memory and they hold some critical data. I want to make sure that any of these structure is not corrupted.
One option is to add a CRC field in the structure. But problem is I have to manually calcul... |
I have 2 types of users of my API: ones who want translated error messages and ones who don't. I've tried 2 ways so far:
return both translated and untranslated message (https://github.com/Mudlet/Mudlet/pull/936/commits/0479c3f3dcd3446da38d7e4c6bf19636f8adfa6f). I don't like this because it is least efficient both in ... |
So I am working on a software design using C for a certain processor. The tool-kit includes the ability to compile C as well as C++. For what I am doing, there is no dynamic memory allocation available in this environment and the program is overall fairly simple. Not to mention that the device has almost no processor p... |
I have a web site with several web pages.
Each page requires some JavaScript: i.e. different JavaScript for different pages, which some JavaScript that's common to every page.
Some of the JavaScript is long (e.g. 4000 lines of code).
I coded the JavaScript using the basic Module Export pattern described in Adequately G... |
Is a scenario a bigger picture with more details than a use-case or how much difference is there? I write a report where I prefer the word scenario but in my training we used the word use-case (in a course about OOP).
I program in SMV which is not OOP. IIUC SMV is a domain-specific language specialized for model check... |
First year of Software Engineering, and we're learning OOP within Java. Came across an extension task to gain more credits. But could not think of what to do:
First Step: Design a checkout system
Build a checkout system for a shop which sells 3 products say Bread, Milk, and Bananas.
Costs of the products are : Bread - ... |
I'm currently working on a site for a friend, converting a google sheet to a webpage (to reduce the time it takes to modify the spreadsheets and apply them to all users).
One particular page is currently in a Google Sheet form, since the main purpose is to serve as a way of 'tracking' users. There's a lot of data that ... |
Yesterday, I removed duplication in a file. The code was performing translations in a grid[i][j]. The duplication was between the code for the i-axis and the code for the j-axis:
For instance, I rewrote:
void redrawGridLine(int iLine);
void redrawGridColumn(int jColumn);
as
enum CoordSelector { I = 0, J = 1 };
//S in... |
This issue indicates that:
From my understanding placing the tag on the release branch before
merging (and not on the master branch) is in fact the correct thing to
do so it can be found by git describe --tags from the develop branch,
too. See #374
while another post:
I accidentally installed the 0.4.2-pre ver... |
Consumer-Driven Contracts: A Service Evolution Pattern presents the idea of contracts verification.
But how detailed is the contract?
Is the contract defining only a syntax of requests/responses? Like WSDL in the case of SOAP Web services.
Or does it describes also the order of messages, i.e., the protocol? e.g.:
O... |
I'm here today, because I'd like to ask you a question about porting application built with Qt5 to linux. I have been asked to port this application to linux, I don't yet have the source code, but I have Windows binaries, so what I can tell you at this very moment is that:
- it's dynamically linked
- it depends on (a... |
I have two asynchronous tasks that need to get completed - say they're "make a pie" (make) and "bake a pie" (bake). I also need to cleanup after everything's done - "clean the kitchen" (cleanup). bake depends on make, and I want to cleanup when things are done. However, there are a few complications:
If some nice pers... |
I've licensed a piece of software under the Creative Commons Attribution-ShareAlike 4.0 International Public License, but I may not want to allow others to use it for commercial uses in the future, so I'm asking whether or not I can change the license for future versions of the piece of software to other licenses such ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.