instruction
stringlengths
34
36.1k
I'm trying to work out what the correct process for deploying a nodejs application to a production environment should me, using webpack. If this was a standard Java/Maven project I might do something like: mvn clean install -Pdeploy-production where the mvn install compiles the application, and the additional deploy...
I have implemented a checkout cart like this : Navigation rules are as follows : User can move to next step only on completing the current step. But he is free to click on the previous tab and edit the past information. Currently I have implemented this in a single page using jquery. However, the code appears extreme...
I want to test-drive functions in C that manipulate an array. But the solutions that I find make me feel somewhat uncomfortable. Lets speak about the limitations first: I'm using a forward declared struct that is a pointer to a kind of structure my test should have no knowledge of (only my implementation knows the actu...
I am looking at Fluent Validation for my rich domain model: https://github.com/JeremySkinner/FluentValidation Lets say I have a class called: Customer. The Customer must have a surname. I can do this: RuleFor(customer => customer.Surname).NotEmpty(); I can do something similar to make sure they are over a certain ag...
I wonder if somebody tried creating a language where you can write mutations in a straightforward imperative style, and the compiler transforms the changes automatically to pure, Redux-style actions. For example (pseudo-js): atomic function repaint_car(car) { car.color = "Blue" car.value += 1000 } would be con...
I noticed that there are couple of ways one can use to get a resource using rest API. I am currently trying to find a valid pros/cons on each of these technique in order to adopt them at the larger scale. What would be the main differences between these requests? Why would I add id into the path, and not into querystr...
We create a commercial library and code examples that are being used by external developers. We have (closed, available to registered users) documentation that extensively explains how to use the library. Many of the developers are first-time users, so a lot of rudimentary errors are encountered. Is it appropriate to i...
I'm trying to detect a clock hand in a video of an analogue display and extract the value it points to. I'm using Python with OpenCV for this. What I essentially do is: I'm using a Gaussian Blur to lower the noise in the current image. I use Canny Edge Detection to filter the edges I apply the probabilistic Hough Line...
How can I represent a "wait until customer representative is available" in the UML activity diagram below? A solution in UML 1 or UML 2 are both acceptable. Proposal 1 The simple line back to the second condition "looks" wrong. Proposal 2 I also came up with this "cleaner" solution. (I know that the final point is ...
Context My team of 8 engineers is currently transitioning to Git (from Subversion) for our next big thing. We have a handful of 'more experienced' engineers that are finding it quite difficult to pick up Git. I get asked the same trivial questions despite having provided user manuals, training activities and whiteboard...
I have created in Azure 2 Azure Functions resources with the following names: FrontApiFunctions PostProcessingFunctions My Visual Studio solutions is like this: AllFunctions.sln |- FrontApiFunctions |- FrontApiFunctions.csproj |- FrontApiFunctions.cs |- PostProcessingFunctions |- PostProcessingFunctions.cspr...
When reading about ACL and RBAC I seem to understand it easily - there are either usernames or roles that are given access to an asset. I can also see how I could implementing those. i.e. this image gives a clear view of ACL and RBAC for me (as in I can go on and design database tables based on above): (Image courtes...
I am working on developing a UML class diagram from C++ code. I have a classless header file that is basically a definitions file (it has structs, enums and defined constants). I know how to represent structs and enums in general, but I am unclear about how to represent (or if I should represent) constants in the cla...
Each time i read an article or a book about asp.net MVC , there will be a chapter for dependency injection and repository . now i can easily feel the benefits of using repository over hard coding the entity framework code inside the action methods, as using repository i can write the methods which uses the entity frame...
In my understanding, standard library is a whole separate piece of software than a compiler is. In my opinion, they should be kept separate. Advantages of this approach pretty much boil down to "they can evolve independently". Disadvantage: Some standard library features could be rewritten in more modern core languag...
I've written an application which reads a list of filenames and does stuff on those files. Dynamic allocation is not allowed and our language of choice is C. The app has an array to hold the filenames, and its size is determined by ARRAY_LIMIT in the Makefile, and used via C macro. The important bits of the Makefile lo...
I'm currently working on a project, where we'll have to keep a local system in "sync" with a remote application. For example if a new customer is created in the local application, this customer must also be created in the remote app - via a rest api - and the "remote" user id must be stored within the local app for fur...
In no particular language: class fooclass { int A, B, C, D; public int GetItemSum() { int sum = this.A + this.B + this.C; this.D = sum; return this.A + this.B + this.C; } } compared to: struct foostruct { public int A, B, C, D; } int GetItemSum(foostruct ref fs) {...
For an application which: Will use Google OpenID for account creation & authorization I plan on allowing any user to "create an account" which is why I want to use Google for this AWS API gateway (to route requests) AWS lambda functions (to process requests) where should authorization live? Authentication is easy...
I understand Uber (or any other cab service) server receives the user coordinates through apps. Say I book the cab at 10am. How does Uber know which cab is vacant and nearest to the user coordinate, then notifies that driver? Say I am at location X of city New York. How does the Uber server know what are the cabs near ...
A simple scenario from today: A developer gets a user story to display nice, layout constant, user-friendly error pages in case of an exception. Developers want to have detailed pages on dev (local machines) environment and same behavior on staging (to trace bugs). While test case needs to validate the new look of erro...
I have just read the following blog entry: Validation and DDD By Vladimir Khorikov. The blog talks about using the following patterns for validating an entity object: IsValid method Check validity in application services layer TryExecute pattern Execute/CanExecute pattern Please see the code below: public Person(Abst...
What is the most common and wise way to specify many entities' ids in an API request? For a singular entity request I have: GET /v1/entities/{entity_id} My suggestions for requesting many entities: GET /v1/entities?entity_ids={entity_id1},{entity_id2} With the same variable name entity_id: GET /v1/entities?entity_id=...
I know that I want to develop a React App like so: <PhotoPage> <FeedFilter/> <PhotoFeed/> </PhotoPage> Without using Redux, I know that I need to fetch a dataset of photos which will manifest itself as the <PhotoFeed/>. Should I fetch this data in the PhotoPage parent component or in the PhotoFeed component itself...
I have simple REST API, based on Asp.Net Core technology. Now, I want to add OpenID for this API. API would be used from mobile applications, single page applications and possibly other API services (not necessary). It seems that I need Authorization flow, or Implicit, or even Hybrid, but as far as I understand, that w...
A while ago, I asked what are cons and pros between the two version control designs of a project: multiple repositories, vs single repository When a project has a single git repository and developed by multiple people simultaneously, what are some ways to manage the contributions from different developers so that t...
I am aware of the existence of several threads on the topic, but I am looking for fresh hand-on experience, that I was unable to find. I have an application written in C++ (core, linear algebra and image processing) and python (interaction with the operating system, aka text files save, plot production, etc). The two a...
Rolling my own GUI library for a side-project. Refactoring to use smart pointers; however, I ran into an issue. I'm aware that you do not want to to use smart pointers across DLL boundaries for obvious reasons. But I feel dirty using 'new' in application code. See below: // MYFINANCEAPP.H class MyFinanceApp : public...
I learnt the SOLID principles back in 2011 and I try to use them in my day to day work. However, I often find myself wandering if I am breaking the Single Responsibility principle. A class can have a number of responsibilities: Presentation Repository Service Domain Infrastructure etc. I also see complaints if one c...
Consider this simplified example: In an online ticket sale website, tickets have variable prices that change over time. User searches for tickets. Once he finds a ticket he wants, clicks "Buy" and then a quote is issued. Quotes are persisted and they have they own locator that is sent by email. The quote page opens, s...
Python's re.match does exactly the same thing as re.search except it appends a \A at the beginning of the pattern (meaning match only at the beginning of the string). What is the point of having a whole other method just to do that?
How does git help deal with the scenario below: I have a task broken down into 2 parts: backend task and frontend task. I make a pull request to merge the backend changes and wait for it to be merged (and address feedback). While waiting, I can't really work on the frontend changes because it depends on backend changes...
Hoping to get some guidance regarding version control of Angular2 project. Recently i started coding in Angular2, used angular-cli to create a brand new project and go through standard 5 minute setup as per angular.io site. Now to the version control dilemma i seem to face. I currently ignore node_modules folder and st...
Is a segfault (array index out of bounds) always the programmer's mistake or could it be misuse from the user?
Some code I wrote was sent back to me during peer review, telling me to add logging to the start of each case in a switch statement in a servlet (Java, if that matters), so if something goes wrong, we can see where. I figured that doesn't make sense, as we log entire stack traces anyway, but the response I got to that ...
I am designing the architecture of an application which has your typical backend and frontend components. The frontend application must be semi real-time. For this requirement, the backend is pushing messages on a queue and the frontend is consuming that queue. Most likely, I will be using RabbitMQ for this. Let me exp...
I am using lex/yacc to parse a simple language which allows 'if blocks': IF something something [ELSE IF something][ELSE] END IF and also other nested logic under a 'DEFINE' statement: DEFINE something something something else END DEFINE I am in need of a common term to refer to these blocks (as the name of ...
Where I work, we've been gradually beefing up our automated testing capabilities and coverage. We're at the point where we've got a wide range of tests, and one configuration of "what needs to be run" is no longer sufficient. We want one set of tests to run when new code is checked in; a larger set for nightly builds; ...
I am wondering what the most idiomatic text abbreviations for comparison operators are. I need to build a custom enum with them, so I cannot use their symbols. To me personally, these seem idiomatic: == EQ != NEQ < LT <= LTE > GT >= GTE However, some other languages seem to use 2-letter words: EQ, NE, GT, GE, ...
Let's say I have the following Java code: public class ObjectConsumer implements Consumer<Object> { @Override public void accept(Object o) { System.out.println("Accepted " + o); } } Example singleton implementation: public enum ObjectConsumer implements Consumer<Object> { INSTANCE; @Overri...
I am updating some code to allow us to implement unit tests. What I have so far is a Business Layer which calls the repository to get data from the database. Business Layer example: public class ConversationLogic { private IConversationData _conversationData { get; set; } public ConversationLogic(IConversatio...
This site and SO contain many pages about getters/setters and if they break encapsulation or enforce it. My question is for those developers that agree that getters/setters break encapsulation and should be avoided. Questions: How do you display your data in a GUI if necessary without getters? I found this link, but ...
In Swift, if I have a class with only type properties and methods (everything declared static) would that be considered a singleton object? If not, why?
I am trying to publish a C# application that does two main things. First, it runs a VBScript that goes into the SAP (Software solutions business) service and retrieves information in an excel type format. Then my program runs the main C# part and manipulates the data and then stores it into an excel file on the desktop...
So I am using Stanford CoreNLP in my project. I have data which consists of reviews of products on a forum. I need to be able to assign a sentiment value to a given review. CoreNLP allows you to predict a sentiment class of a given sentence. The class varies from 0 - very negative to 4 - very positive. How do I combine...
If you have a program that has a front-end and a back-end written in two different languages, how do those two systems communicate with each other? I have no professional experience in programming, I'm still in school. I know how, for example, to communicate between two java programs if I needed to. If I had two progra...
I'm a C++ developer who has been using the MVC pattern to design GUIs ever since. Recently I wanted to get back into C#, and I set up a Windows Forms application, but now I am a little bit lost on how to push it to a MVC compliant structure. What I am currently trying to do is to "declare" the class I am given for the ...
I have a style question for designing a class to represent a real model. Let's say I have Guide that has PointsOfInterest as a member. Would I want to do something like: class Guide { public points: PointsOfInterest[]; } This seems bad, because let's say I've fetched a Guide from my back-end. To add a POI I append...
In Single Page Applications, it's common to update the URL when navigating, and re-render based on the new URL. This can happen when the user hits the back and forward button, clicks on an anchor tag, or does something that pushes a new state on the history object. The consensus for detecting any kind of url change th...
So what I know about socket is that a socket is an end point of a connection for a process, hence 1 socket on a host binds to an IP and a unique port number for each connection. But a webserver (by default use port 80) to listen for connections coming in from multiple clients. My question is: Does that mean a single ...
I want to build a middleware system that my company can use and expand on to handle the integration points between our various bespoke and 3rd party systems as well as our hosted websites. I am having some trouble with the design/architecture and would like some advice (please let me know if there is a better site to a...
Let's say, for example, I want to test that a warning is shown on the Dashboard of a Car only when the Engine is broken. The method implementing this functionality might look as follows: class Dashboard { function showWarningIfEngineIsBroken() { if ($this->engine->isBroken()) { $this->showWarnin...
I'm going through this series. The author mentions that since state is maintained in object oriented programming, it is harder to write unit tests. He also says that since functional programming doesn't maintain state (not always), it is easier to write unit tests. I didn't see any examples that demonstrate this proble...
Instead of using #define or const, I usually define constants using class static methods as follows: //AppConstants.h #include <string> class AppConstants{ public: static int getMax(); static std::string getPrefix(); }; //AppConstants.cpp #include "AppConstants.h" int AppConstants::getMax(){ return 30; } ...
The following situation: a product which consists of multiple components, each component versioned individually (all artefacts of the same component having the same version) POs are talking of product version X and plan releases X.a, X.b containing specific functionality each sprint a new release is made (that potenti...
From time to time I feel exhausted in my software development efforts because I am pressed to think and develop in very specific and very short term manner. One client here and now requires one feature and I should implement it for him. Nor client, nor management of my company are interested in investing some time and ...
Imagine a structure like this, a list with products. <div class="container"> <div class="teaser"> <img src="..."> <p>Product 1</p> </div> <div class="teaser"> <img src="..."> <p>Product 2</p> </div> </div> We need to test the amount of .teaser elements in .container is ...
I'd like to ask about best practices on return statements. So, what would be more preferable, something like... ... String r = null; if(var != null) { r = "NOT NULL!"; } return r; Or something like this... ... if(var != null) { return "NOT NULL!"; } return null; In other words, one return statement and the val...
I need a little advice with project design. I have taken on a personal project to enhance my knowledge of Java Swing, API integration, JDBC and OOP I have chosen to do this in Java as I previously did a similar project in HTML and JSP's and learnt a lot. For those who are interested, here is a breakdown of the App From...
I am required to speak at daily stand ups, change review and architect reference group meetings. I usually find that I speak too quickly, include too much or not enough details, or go back and forth without a narrative. However I always understand the material and write well structured emails and technical documentatio...
I am fairly new to implementing CQRS and Event Sourcing, while applying rules of domain driven design. Let's say I have an Order aggregate and inside it is a list of OrderLine entities. I'm using this model in the context of an event-sourced system (with CQRS) and so the state changes are mainly driven by events. Chang...
I'm building a system using a document type database. The system has users. I was told that in production it is best to avoid making outright deletes. I understand the convention is to either mark users as deleted or to transfer them to a deleted table in a RDBMS. For document type databases what is the convention? I ...
I am working with an N-tier application, and I'm updating the Data Access Layer (DAL) to use a new ORM. As I'm updating the DAL I'm finding some issues with how we save objects to the database. One question I have is should the DAL have a simple SaveObject(objectToSave) method that checks for it's existence in the dat...
I am designing a RESTful API that has a set up like this: /users - returns all users /users/123 - returns user with the id 123 /users/123/comments - returns all comments for user 123 I am looking for the most correct way to return all comments for all users. Comments don't have their own ID or identifier and they don't...
I'm a software developer recently in charge of entire project (project manager). The project I'm working on (with 6 other persons) is a complex Java-based application that's being developed for over 5 years. The entire time we were using SVN, without branching. Now, I would like to switch to Git as I do believe Git wil...
In the context of creating an ecosystem, the graph below reveals information about it's behavior. Dot : A node with the entity's name. There's a tree, grass, a fern, etc. Blue arrow : A requirement. The tree requires grass and high altitude. Red line : Cannot co-exist with. Grass cannot co-exist with stone. This ma...
There are a lot of functions that accomplish the same thing, but using Applicative vs Monad definitions. Some examples are: (<*>) vs ap pure vs return (*>) vs (>>) traverse vs mapM sequenceA vs sequence liftA vs liftM liftA2 vs liftM2 etc. And for Alternative vs MonadPlus: empty vs mzero (<|>) vs mplus In the scena...
I realize this may be subjective, but I don't see any clear-cut place for asking questions on good software design principals. I'm sure there are some software patterns and anti-patterns I should be aware of here. I'm not asking about UI/UX or how to code anything. I am asking what would be a good design pattern to fo...
I have read Eric Evans book. I was under the impression that a Domain Model should not have dependencies injected (even repositories). This statement is supported by questions like this: https://stackoverflow.com/questions/20035810/should-domain-objects-have-dependencies-injected-into-them, where the answerer says tha...
I am running 10 instances of the same executable where each executable is accessing a different 1/10 chunk of the total data that needs to be processed on a Windows Server 2012 R2. (Intel(R) Xeon(R) 2.4GHz (2 processors), 64GB RAM) My question is if the CPU hits 100% usage, are the 10 instances still being parallel pro...
I'm not sure how to best approach this problem. I've got an object in my local database, for example this one: { title: "my-object", uploaded: false } I convert this to a file, say my-object.txt and upload it to a server. Once it has been uploaded I set, locally, the field uploaded to true, so it will now become: { ti...
I'm storing files as REST API resources, sending and receiving them as base64 strings, along with some other metadata. What's the best way to handle GET for the collection? (e.g GET .../api/files) The standard response to GETting the collection (to my understanding) is to return the full contents of all resources, but ...
Thanks Maven archetypes the barrier to start developing of services for new RESTful APIs is very straightforward - you can get more or less a project template and start filling in your code. Now as I am new to Scala, is there some compatibility to use/integrate with Jersey in a similarly convenient way or is there a "S...
I'm working on my final project for a course named Web Applications in ASP.NET. Basically, it's a web application for shopkeepers to manage their clients' money accounts in their stores. In order to open an account, the shopkeeper and the other person have to agree on the length of period for the account, the interest ...
I have several services that implement an observer interface and one service that implements the corresponding observable interface. I'm currently using unity together with Prism so I would prefer to keep this combination. My current solution is to inject the observable service in the observer services and let the obse...
I am building this IoT device which should send data to an API. I would use some "hardcoded" api key to access it, but on the other side I also have a front-end that uses JWT to access data. What do you suggest? Maybe RPC instead?
I came to know about virtualenv and pyenv a while ago, and used them separately for a while. Recently, while investigating best practices and tools for Python development I found pyenv-virtualenv. I find it useful (it takes care of using the right method for creating the virtual environment depending on the Python vers...
I am looking for algorithms to make single elimination and double elimination brackets. The first step was figuring out the seeding algorithm, byes included, which I found in several places in SO: here (where byes can be introduced simply b replacing the last n excess teams and shifting the seed positions n times) and ...
That question bothers me for years, so, imagine some code that in 99% looks like a non-sequential (order does not matter) list of some specific objects method calls - and those calls are independent one from each other, like: conf.addCollection(...); conf.addRule(...); conf.registerEvent(...); I can implement method c...
I am new to Assembly, and based on my understanding, an ISA (Instruction Set Architecture) specifies what instructions are available for a particular CPU. But does an ISA also specify what registers are available in the CPU?
I encountered a scenario where I cannot decide on which is the best (or worst) naming strategy. The context is the following: a bracket (as in a tournament) made up of nodes, where is node is made up of two abstract elements which can be a seeded player, a bye, or a reference to another node. We clearly see a hierarchy...
The following image shows where the sections of a process are laid out in the process's virtual address space: You can see that there is only one stack section (since this process only has one thread I assume). But what if this process has another thread, where will the stack for this second thread be located? will it...
Use-case: As part of an Airline Application I am building - I am developing a set of (RESTful) API's each for Flights, Lounges, Loyalty etc. There are some common methods which should be accessible from all the API's. Current Implementation: At present, we have deployed these as separate war files on our Tomcat servers...
Currently we are slowly replacing a custom made ORM framework with Entity Framework (EF). One of the steps is to make sure we can update and insert records through database views with EF, just like we are doing with the current ORM. The views provide security by filtering on accessible records for the user, preventing ...
I have been wondering about this for a while. What applications is programs like visual studio programmed in? But also, where is operating systems like android, ios and windows written in? I just find it hard to imagine how developer environments are/were made, when they didn't exist! Get me right, I know that other d...
The C# docs have a page on indexers, which appears to use "indexer" to refer to the construct required to enable instances of a class to be accessed via square bracket notation. Indexers allow instances of a class or struct to be indexed just like arrays. // Define the indexer to allow client code to use [] notation....
I've read a bunch of online resources about this, but wondering if there's a better way to test an idea for a product before spending countless weeks building the darn thing? I've read about things like Validate.tech that test product ideas in under a day, but it seems wrong to lure people in with a landing page and no...
I am implementing a token-based authentication system for a REST API using a short-lived access token and a long-lived refresh token. This is an abstract overview of the relevant API endpoints (HTTPS is enforced for all endpoints): Endpoints: POST /register/ POST /login/ POST /logout/ POST /password/change/ Implement...
Suppose a function deserializes and validates some object from string and returns the result as Either<string, MyObject>. So an object is either completely deserialized and valid or some kind of error happened. Now suppose if even only some of the fields are valid the deserialization function should return them. How th...
I have seen this done in some applications, and it's not clear to me that this is ok or if it's a separation of powers violation.
I haven't developed any production applications for the Linux OS. There are a couple of things that bother me: As I understand different distros have different set of libraries Debian vs RPM packages Different UI - Gnome vs KDE What do people do to handle all of these differences? Is there a way to abstract away from...
Background Based on Item 4 in Scott Mayers Effective C++, when appropriate, it can be good practice to initialize all member properties of custom types via the member initialization list (in same order as their declarations), even for non-POD types with accessible default CTOR:s. [Excerpt From: Scott Meyers. “Effectiv...
In a calendar app adopting a MVC architecture, the Model consists of objects representing the days of the week. The View consists of labels displaying the days as strings or integers, depending on the user interaction. Therefore I need some logic in my app for the mapping from strings to integers, and viceversa. Is thi...
I'm building my first ever web-based game in PHP/MySQL and I'am having difficulty conceptualising how to deal with saved game data instances. It's a football manager game with tables like... players, managers, matches, results, injuries, stadiums, leagues etc My problem is that some of those tables need to hold comple...
I've got one requirement that is: When one employee starts working on a project and when he finishes working on it he must inform the system so that it can generate a report afterwards of how much hours a certain project required. The requirement itself is simple, I just want to see if I'm thinking right about it. My...
I apologize in advance if this is a dumb question As an amateur at programming who has been learning the basics of Java, I have started to wonder how the visual side of applications is created. Basically I am wondering if there is a sort of equivalent to HTML/CSS for programs.
I am refactoring the code for a music player I wrote in Java/JavaFX. I have a few key objects which are accessed throughout the program by various other classes. I think there will be four or five by the time I finish moving everything around. There is only ever one instance of these objects instantiated for the life ...
I'm developing an API that allows consumers to create a resource. For example, a "user" resource can somewhat be created via POST and this payload (trying to use JSON API, btw): POST /users HTTP/1.1 Content-Type: application/vnd.api+json Accept: application/vnd.api+json { "data": { "type": "users", "attribut...
Since bundling and minification is all about optimization and making pages load faster, it appears to me that it would be logical to create one bundle for scripts and one bundle for styles per view basis, so that to load all scripts and styles a browser will need to make 2 requests at most. So let's say I have a _Layou...
I have a class which contains various fields and they could be accessed with the help of getters and setters like the following public class Student { private String name; private int age; private int sibblingsCount; private String elderSibblingName; private String youngerSibblingName; public ...